Pārlūkot izejas kodu

Merge branch 'master' into test-dev

duy 1 nedēļu atpakaļ
vecāks
revīzija
f1b1be3060
2 mainītis faili ar 101 papildinājumiem un 67 dzēšanām
  1. 13 5
      src/api/modules/data-fill/query.js
  2. 88 62
      src/views/data-fill/query.vue

+ 13 - 5
src/api/modules/data-fill/query.js

@@ -166,17 +166,25 @@ export default {
     //重置文件题名
 
     //预览文件题名接口
+        //文件题名确认修改接口
+    async flushQueryName(form) {
+        return HcApi({
+            url: '/api/blade-business/informationWriteQuery/flushQueryName',
+            method: 'post',
+            data: form,
+        })
+    },
     async previewNodeName(form) {
         return HcApi({
             url: '/api/blade-business/informationWriteQuery/previewNodeName',
-            method: 'get',
-            params: form,
+            method: 'post',
+            data: form,
         })
     },
-        //文件题名确认修改接口
-    async flushQueryName(form) {
+    
+    async getNameRuleList(form) {
         return HcApi({
-            url: '/api/blade-business/informationWriteQuery/flushQueryName ',
+            url: '/api/blade-business/informationWriteQuery/getNameRuleList',
             method: 'post',
             data: form,
         })

+ 88 - 62
src/views/data-fill/query.vue

@@ -336,16 +336,17 @@
                         :value="item.value"
                     />
                 </el-select>
-                <el-button type="primary" hc-btn size="small" class="ml-2" @click="batchSetRule">设置</el-button>
+                <el-button type="primary" hc-btn size="small" class="ml-2" :disabled="setValue.length === 0" @click="batchSetRule">设置</el-button>
             </div>
             
             <div style="position: relative; height: 440px" class="mt-2">
-                <hc-table :column="ruleTableColumn" :datas="ruleTableData">
+                <HcTable v-loading="ruleTableLoading" :column="ruleTableColumn" :datas="ruleTableData" :loading="ruleTableLoading">
                     <template #rule="{ row }">
                         <div class="flex items-center">
                             <span class="text-red">*</span>
                             <el-select 
-                                v-model="row.rule" 
+                                v-model="row.rule"
+                                :class="{ 'error-border': !row.rule || row.rule.length === 0 }" 
                                 placeholder="请选择" 
                                 multiple
                                 clearable
@@ -362,26 +363,26 @@
                             </el-select>
                         </div>
                     </template>
-                </hc-table>
+                </HcTable>
             </div>
         </hc-new-dialog>
     </div>
 </template>
 
 <script setup>
-import { onMounted, ref, watch } from 'vue'
+import { nextTick, onMounted, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import { getStoreValue, setStoreValue } from '~src/utils/storage'
 import { arrToId, arrToKey, downloadBlob, getArrValue, getObjValue, isString } from 'js-fast-way'
 import queryApi from '~api/data-fill/query'
-import divisionApi from '~api/data-fill/division'
+
 import { eVisaTaskCheckApi } from '~api/other'
 import { toPdfPage } from '~uti/btn-auth'
 import wbsApi from '~api/data-fill/wbs'
 import website from '~src/config'
 import { getDictionaryData } from '~uti/tools'
 import { getDictionary } from '~api/other'
-import { reRendering } from 'element-plus/es/components/watermark/src/utils.mjs'
+
 //变量
 const useAppState = useAppStore()
 const projectId = ref(useAppState.getProjectId)
@@ -1116,6 +1117,7 @@ const resignTitleSave = async ()=>{
         arr.push({
             id:item.id,
             nodeName:'',
+            nameRule:'',
         })
     })
      ruleModalSaveLoad.value = true
@@ -1141,28 +1143,30 @@ const resignTitleSaveLoad = ref(false)
 //规则更改
 const changeRuleClick = async ()=>{
   await getWbsNodeTypeApi()
-   
     ruleModal.value = true
     ruleTableData.value = []
-    tableCheckedKeys.value.forEach(async (ele)=>{
-       let returnData = await getNodeNameConfigApi(ele.wbsId)
-
-          
-       ele.rule = returnData
-          let str = ''
-          if (ele.rule.length > 0) {
-                str = ele.rule.join('-')
-         }
-          ele.nodeName = await getRuleValue(ele.wbsId, str)
-
-         ruleTableData.value.push({
-            name:ele.name,
-            wbsId:ele.wbsId,
-            id:ele.id,
-            rule:ele.rule,
-            nodeName:ele.nodeName,
-         })
+
+    let arr = tableCheckedKeys.value.map(item=>{
+        return {
+         
+            wbsId:item.wbsId,
+            projectId:projectId.value,
+
+           
+        }
     })
+    let arr1 = await getRuleListData(arr)
+    ruleTableData.value = arr1
+
+        for (let i = 0; i < ruleTableData.value.length; i++) {
+            const currentItem = ruleTableData.value[i]
+            const matchedItem = tableCheckedKeys.value.find(item => item.wbsId === currentItem.wbsId)
+            if (matchedItem) {
+                currentItem.name = matchedItem.name
+                currentItem.id = matchedItem.id
+            }
+        }
+    // ruleTableData.value = arr
  
     
     
@@ -1179,12 +1183,13 @@ const ruleModalSave = async ()=>{
         window.$message.warning('请选择题名规规则')
         return
      }
+
     let arr = []
     ruleTableData.value.forEach(item=>{
         arr.push({
             id:item.id,
-            nodeName:item.nodeName,
-            nodeRule:item.rule.join('-'),
+            nodeName:item.newNodeName,
+            nameRule:item.rule.join('-'),
         })
     })
 
@@ -1209,46 +1214,60 @@ const setValue = ref('')
 
 const ruleTableColumn = ref([
      { key: 'name', name: '文件题名' },
-    { key: 'nodeName', name: '修改后' },
+    { key: 'newNodeName', name: '修改后' },
     { key: 'rule', name: '题名规则' },
 ])
 const ruleTableData = ref([])
-const batchSetRule = ()=>{
-   ruleTableData.value.forEach(async (ele)=>{
+const batchSetRule = async ()=>{
+    if (setValue.value.length === 0) {
+        window.$message.warning('请选择题名规则')
+        return
+    }
+   ruleTableData.value.forEach( (ele)=>{
         ele.rule = setValue.value
-         let str = ''
-        if (ele.rule.length > 0) {
-            str = ele.rule.join('-')
-        }
-        ele.nodeName = await getRuleValue(ele.wbsId, str)
-        setValue.value = ''
+   })
 
+   let arr = []
+   ruleTableData.value.forEach((item)=>{
+        arr.push({
+            wbsId:item.wbsId,
+            nameRule:item.rule.join('-'),
+        })
    })
+   let afterArr = await getRuleValue(arr)
+
+
+      for (let i = 0; i < ruleTableData.value.length; i++) {
+            const currentItem = ruleTableData.value[i]
+            const matchedItem = afterArr.find(item => item.wbsId === currentItem.wbsId)
+            if (matchedItem) {
+                currentItem.newNodeName = matchedItem.newNodeName
+            }
+        }
+
 }
 const ruleChange = async (ele)=>{
    let str = ''
    if (ele.rule.length > 0) {
     str = ele.rule.join('-')
    }
-
-    ele.nodeName = await getRuleValue(ele.wbsId, str)
-   
+ let arr = [{
+    wbsId:ele.wbsId,
+  
+    nameRule:str,
+ }]
+    let afterArr = await getRuleValue(arr)
+    ele.newNodeName = afterArr[0].newNodeName
    
 }
 const getRuleLoad = ref(false)
-const getRuleValue = async (wbsId, param) => { 
-    if (!param) {
-        window.$message?.warning('请选择题名规则')
-        return
-    }
-    getRuleLoad.value = true
-    const { error, code, msg, data } = await queryApi.previewNodeName({
-        wbsId:wbsId,
-        param:param,
+const ruleTableLoading = ref(false)
+const getRuleListData = async (arr) => { 
 
-    })
+    ruleTableLoading.value = true
+    const { error, code, msg, data } = await queryApi.getNameRuleList(arr)
     //处理数据
-    getRuleLoad.value = false
+    ruleTableLoading.value = false
     if (!error && code === 200) {
         return data || ''
     } else {
@@ -1256,22 +1275,25 @@ const getRuleValue = async (wbsId, param) => {
     }
 
 }
-//获取节点命名配置
-
-const getNodeNameConfigApi = async (wbsId) => {
-
-    const { error, code, msg, data } = await divisionApi.getNodeNameConfig({
-       pKeyId:wbsId, projectId: projectId.value,
-    })
+const getRuleValue = async (arr) => { 
+  // 检查 arr 中每一项的 nameRule 是否有值
+  const hasInvalidItem = arr.some(item => !item.nameRule || item.nameRule.length === 0)
+  if (hasInvalidItem) {
+   window.$message.warning('请选择题名规则')
+    return
+  }
+    getRuleLoad.value = true
+    const { error, code, msg, data } = await queryApi.previewNodeName(arr)
     //处理数据
+    getRuleLoad.value = false
     if (!error && code === 200) {
-        console.log(data, 'data')
-        
-        return data || []
+        return data || ''
     } else {
-        return []
+       return ''
     }
+
 }
+
 //获取节点类型
 const nodeTypeData = ref([])
 const getWbsNodeTypeApi = async () => {
@@ -1296,6 +1318,10 @@ const getWbsNodeTypeApi = async () => {
 
 <style lang="scss" scoped>
 @import "../../styles/data-fill/query.scss";
+
+.error-border {
+    border: 1px solid red;
+}
 .iscusor {
     cursor: pointer;
 }