Forráskód Böngészése

文件题名全局接口调用

duy 7 hónapja
szülő
commit
a2f9f6127c
1 módosított fájl, 169 hozzáadás és 61 törlés
  1. 169 61
      src/views/manager/projectinfo/tree.vue

+ 169 - 61
src/views/manager/projectinfo/tree.vue

@@ -1810,10 +1810,25 @@
       append-to-body
       :close-on-click-modal="false"
     >
+ 
+        <div class="flexEnd">
+          <i
+            class="el-icon-circle-plus "
+            style="font-size: 24px; color: rgb(37, 193, 99); cursor: pointer"
+            @click="addRow"
+          ></i>
+          <i
+            class="el-icon-refresh "
+            style="font-size: 24px; color: rgb(37, 193, 99); cursor: pointer"
+            @click="addRow"
+          ></i>
+        </div>
+     
     <el-table
     :data="fileTableData"
     style="width: 100%;height: 500px;"
     align="center"
+    v-loading="fileTableLoading"
     >
  
     <el-table-column
@@ -1821,7 +1836,7 @@
       prop="roleNameVal">
       <template #default="scope">
         <el-select
-           v-if="scope.row.isEdit1"
+        v-if="scope.row.isEdit"
             v-model="scope.row.ruleName"
             multiple
             placeholder="请选择"
@@ -1832,7 +1847,7 @@
               v-for="item in nodeTypelist"
               :key="item.id"
               :label="item.dictValue"
-              :value="item.dictValue"
+              :value="item.dictKey"
             ></el-option>
           </el-select>
        <span v-else>
@@ -1847,22 +1862,15 @@
       prop="ruleSizeVal">
     
       <template #default="scope">
-        <el-link type="warning" @click="chooseFile(scope.$index, scope.row)"  v-if="scope.row.isEdit1">选择题名范围</el-link>
-        <span v-else>{{ scope.row.ruleSizeVal }}</span>
+        <el-link type="warning" @click="chooseFile(scope.$index, scope.row)"  v-if="!scope.row.ruleSizeVal">选择题名范围</el-link>
+        <span v-else  @click="chooseFile(scope.$index, scope.row)" :class="{'orange': scope.row.isEdit}">{{ scope.row.ruleSizeVal }}</span>
       </template>
     </el-table-column>
     <el-table-column
-      align="right">
-      <template slot="header" slot-scope="scope">
-        <div class="flexEnd">
-          <i
-            class="el-icon-circle-plus "
-            style="font-size: 24px; color: rgb(37, 193, 99); cursor: pointer"
-            @click="addRow"
-          ></i>
-         
-        </div>
-      </template>
+      label="操作"
+      width="150px"
+>
+      
       <template slot-scope="scope">
         <el-link
         v-if="!scope.row.isEdit"
@@ -1890,21 +1898,33 @@
     align-center
     append-to-body
   >  
-  <el-scrollbar class="h-100p" style="height: 400px;">
-    <el-tree
-    lazy
-    :load="loadNode"
-    :props="defaultProps"
-    :expand-on-click-node="false"
-    highlight-current
-    node-key="id"
-    show-checkbox
-    @check="checkFileSize"
-     :default-checked-keys="deCheckTreeKeys"
-
-  >
-   </el-tree>
-  </el-scrollbar>
+
+
+  <el-form label-position="left" label-width="80px" :model="fileTitleModel"  :rules="fileTitleRules" ref="fileTitleRef">
+     
+      <el-form-item label="题名范围" prop="type">
+        <el-radio v-model="fileTitleModel.type" :label="1">所有节点</el-radio><br/>
+        <el-radio v-model="fileTitleModel.type" :label="2">部分节点</el-radio>  
+        <div v-if="fileTitleModel.type==2" class="warning-text">请选择节点</div>
+
+          <el-scrollbar class="h-100p" style="height: 400px;" v-if="fileTitleModel.type==2" v-loading="fileTreeLoading">
+                <el-tree
+                       
+                        :data="fileTreeData"
+                        :props="filedefaultProps"
+                        :expand-on-click-node="false"
+                        highlight-current
+                        node-key="id"
+                        show-checkbox
+                        @check="checkFileSize"
+                        :default-checked-keys="deCheckTreeKeys"
+
+                      >
+                      </el-tree>
+        </el-scrollbar>
+      </el-form-item>
+   
+    </el-form>
 
     <template #footer>
       <div class="dialog-footer">
@@ -1965,7 +1985,7 @@ import {
   tabTypeLazyTree,
   syncContractTabSort,
   linkNodeTree,
-  getLinekNodeTreelist,
+  getLinekNodeTreelist,getNameRule,getTitleRange,saveOrUpdateNameRule,deletedNameRule
 } from "@/api/manager/wbsprivate";
 import { findProjectTree as getAlltree } from "@/api/manager/projectinfo";
 import { findProjectTreeTrial as getAlltreeTrial } from "@/api/manager/projectinfo";
@@ -2294,8 +2314,28 @@ export default {
       fileTitleVisible:false,
       deCheckTreeKeys:[],
       fileTableData:[
-        {roleNameVal:['子单位工程'],ruleSizeVal:'单位工程1'}
+        
       ],
+      fileTitleRef:null,
+     
+      fileTitleModel:{
+        type:'',
+  
+      },
+      fileTreeLoading:false,
+      fileTreeData:[],
+      filedefaultProps:{
+         children: 'children',
+          label: 'nodeName'
+      },
+      fileTitleRules:{
+        type: [
+            { required: true, message: '请选择题名范围', trigger: 'blur' },
+          
+          ],
+      },
+      
+      fileTableLoading:false,
       chooseFileVisible:false,
       chooseFileRow: {},
       chooseFileIndex: -1,
@@ -3061,30 +3101,14 @@ export default {
       });
     },
     getNodeTypelist() {
-      const type = this.wbsType;
-      if (this.nodeTypelist.length > 1) {
-        return;
-      }
-      let code = "";
-      if (type === 5) {
-        code = "lar_node_type"; //征拆
-      } else if (type === 2) {
-        code = "trial_node_type"; //试验
-      } else if (type === 3) {
-        code = "meter_node_type"; //计量
-      } else {
-        code = "wbs_node_type"; //质检
-      }
+      let code = "name_rule";
 
       getDictionary({
         code,
-        // code: type === 2 ? "trial_node_type" : "wbs_node_type",
       }).then((res) => {
-        res.data.data.forEach((element) => {
-          element.dictKey = Number(element.dictKey);
-        });
-
         this.nodeTypelist = res.data.data;
+ 
+        
       });
     },
     getMajorDataTypeList() {
@@ -4325,40 +4349,117 @@ export default {
     },
     //文件题名(全局按钮)
     fileTitleHandle(){
+      this.getFileTableData()
       this.fileTitleVisible = true;
+      
     
+    },
+    //获取文件题名规则
+    getFileTableData(){
+      this.fileTableLoading=true
+      getNameRule(
+       { projectId:this.projectid}
+      ).then((res) => {
+        this.fileTableLoading=false
+        if(res.data.data){
+          this.fileTableData = res.data.data;
+        }else{
+          this.fileTableData =[]
+        }
+      });
+    },
+    //获取文件题名范围
+    getTitleRangeData(){
+     this.fileTreeLoading=true
+      getTitleRange(
+       { projectId:this.projectid}
+      ).then((res) => {
+        this.fileTreeLoading=false
+        if(res.data.data){
+          this.fileTreeData = res.data.data;
+        }else{
+          this.fileTreeData =[]
+        }
+      });
     },
     //选择题名范围
     chooseFile(index,row){
-      this.chooseFileVisible = true;
-      this.chooseFileIndex= index;
-      this.deCheckTreeKeys=[]
+      const {ruleName}=row
+      if(ruleName.length>0){
+         this.chooseFileVisible = true;
+        this.chooseFileIndex= index;
+        this.deCheckTreeKeys=row.ruleSizeValId
+        console.log(row,'row');
+        
+        this.getTitleRangeData()
+       
+      }else{
+      this.$message.warning('请先选择文件题名规则');
+      }
+      
     
     },
-    checkFileSize(data,{checkedNodes}){
-      let checkedTitles = checkedNodes.map(node => node.title).join('、');
-      this.fileTableData[this.chooseFileIndex].ruleSizeVal=checkedTitles
-      this.fileTableData[this.chooseFileIndex].isEdit1=false
-
+    checkFileSize(data,{checkedNodes,checkedKeys}){
+      let checkedTitles = checkedNodes.map(node => node.nodeName).join('、');
     
-   
+      // this.fileTableData[this.chooseFileIndex].ruleSizeVal=checkedTitles
+          this.fileTableData[this.chooseFileIndex].isEdit1=false
+      const fileItem = this.fileTableData[this.chooseFileIndex];
+      this.$set(fileItem, 'ruleSizeVal', checkedTitles);
+    
+      this.$set(fileItem, 'ruleSizeValId', checkedKeys);
       
     },
     saveFileSize(){
       this.chooseFileVisible = false;
+      // this.fileTableData[this.chooseFileIndex].isEdit1=false
+      // this.fileTableData[this.chooseFileIndex].isEdit=false
       
 
     },
     editRow(index,row){
+      console.log(row,'row');
+      
       this.$set(row, "isEdit", true);
       this.$set(row, "isEdit1", true);
     },
+    //保存文件题名
     saveRow(index,row){
       this.$set(row, "isEdit", false);
       this.$set(row, "isEdit1", false)
+
+     const ruleName=row.ruleName.join('-')
+     const ruleSizeVal=row.ruleSizeValId.join(',')
+      console.log(ruleName,'ruleName');
+      
+      let nameRuleDtos={
+        nameId:"",
+        nameRule:ruleName,
+        nodeId:ruleSizeVal,
+        projectId:this.projectid,
+        type:2
+      }
+      // saveOrUpdateNameRule(
+        
+      //     {nameRuleDtos}
+        
+      // ).then((res) => {
+      //  if(res.data.code==200){
+      //     this.$message.success('保存成功')
+      //   }else{
+      //     this.$message.error('保存失败')
+      //   }
+      // });
     },
     changeRoleName(data,row){
-      this.$set(row, "roleNameVal", data);
+      // 找到对应的 dictValue
+      const originalData=this.nodeTypelist
+      const dictKeyToDictValueMap = originalData.reduce((acc, item) => {
+        acc[item.dictKey] = item.dictValue;
+        return acc;
+      }, {});
+      const result = data.map(dictKey => dictKeyToDictValueMap[dictKey]);
+      this.$set(row, "roleNameVal", result);
       
     },
     addRow(){
@@ -4514,4 +4615,11 @@ export default {
     display: inline-block;
   }
 }
+.warning-text{
+  color: orange;
+  font-weight: bold;
+}
+.orange {
+  color: orange;
+}
 </style>