duy пре 1 недеља
родитељ
комит
b17bc86120
2 измењених фајлова са 85 додато и 62 уклоњено
  1. 13 5
      src/api/modules/data-fill/query.js
  2. 72 57
      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,
         })

+ 72 - 57
src/views/data-fill/query.vue

@@ -336,11 +336,11 @@
                         :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>
@@ -362,7 +362,7 @@
                             </el-select>
                         </div>
                     </template>
-                </hc-table>
+                </HcTable>
             </div>
         </hc-new-dialog>
     </div>
@@ -1116,6 +1116,7 @@ const resignTitleSave = async ()=>{
         arr.push({
             id:item.id,
             nodeName:'',
+            nameRule:'',
         })
     })
      ruleModalSaveLoad.value = true
@@ -1141,28 +1142,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
  
     
     
@@ -1183,8 +1186,8 @@ const ruleModalSave = async ()=>{
     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 +1212,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)
+console.log(afterArr, 'afterArr')
+
+      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 +1273,20 @@ const getRuleValue = async (wbsId, param) => {
     }
 
 }
-//获取节点命名配置
+const getRuleValue = async (arr) => { 
 
-const getNodeNameConfigApi = async (wbsId) => {
-
-    const { error, code, msg, data } = await divisionApi.getNodeNameConfig({
-       pKeyId:wbsId, projectId: projectId.value,
-    })
+    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 () => {