Pārlūkot izejas kodu

项目级 立卷规则配置

gangyj 2 gadi atpakaļ
vecāks
revīzija
64e072613d
1 mainītis faili ar 245 papildinājumiem un 54 dzēšanām
  1. 245 54
      src/views/manager/projectinfo/archivetreeRule.vue

+ 245 - 54
src/views/manager/projectinfo/archivetreeRule.vue

@@ -236,24 +236,6 @@
                     <el-button type="primary" plain @click="setType">设置为分类卷并卷</el-button>
                     <el-button type="primary" plain @click="setAlone">设置为独立组卷</el-button>
                   </el-row>
-                    <div style="display: flex;justify-content: space-between;">
-                         <el-select v-model="publictreevalue" clearable placeholder="请选择公有质检化分树" style="  margin-bottom:15px;  width:45%;">
-                            <el-option
-                              v-for="item in publictreeoptions"
-                              :key="item.id"
-                              :label="item.wbsName"
-                              :value="item.id">
-                            </el-option>
-                        </el-select>
-                        <el-select v-model="testtreevalue" clearable placeholder="请选择公有试验化分树"   style="    width: 45%;">
-                            <el-option
-                              v-for="item in testtreeoptions"
-                              :key="item.id"
-                              :label="item.wbsName"
-                              :value="item.id">
-                            </el-option>
-                        </el-select>
-                      </div>
                 </el-tab-pane>
                 <el-tab-pane label="工程文件入口配置" name="first"></el-tab-pane>
           </el-tabs>
@@ -264,10 +246,10 @@
                     :props="Rightprops"
                     :data="rightData"
                     node-key="id"
-                    ref="tree"
+                    ref="settree"
                     class="filter-tree"
-                    show-checkbox
-                    @check-change="handleCheckChange"
+                    show-checkbox :check-strictly="true"
+                    @check="handleCheckChange"
                   >
                    <div class="custom-tree-node" slot-scope="{ node, data }"   @mouseover="mouseOver(data)"
                     @mouseleave="mouseLeave(data)">
@@ -280,7 +262,7 @@
                             @click.stop="() => viewConfig(data)">
                             查看配置
                           </el-button>
-
+                          <el-link @click.stop="removeArchive(data)" type="danger" :underline="false" class="marleft10"><i class="el-icon-delete"></i></el-link>
                         </span>
                    </div>
                   </el-tree>
@@ -634,9 +616,9 @@
       append-to-body
     >
      <el-checkbox-group v-model="checkList">
-      <el-checkbox label="复选框 A" style="margin-bottom:10px"></el-checkbox><br/>
-      <el-checkbox label="复选框 B" style="margin-bottom:10px"></el-checkbox><br/>
-      <el-checkbox label="复选框 C" style="margin-bottom:10px"></el-checkbox><br/>
+      <div v-for="node in nodesList" :key="node.id">
+        <el-checkbox :label="node.id" style="margin-bottom:10px">{{node.pathName}}</el-checkbox>
+      </div>
     </el-checkbox-group>
       <span
         slot="footer"
@@ -645,12 +627,12 @@
         <el-button @click="highVisible=false,highVisible=false">取 消</el-button>
         <el-button
           type="primary"
-          @click="editSort()"
+          @click="setRecordsHandle()"
         >确 定</el-button>
       </span>
     </el-dialog>
     <!-- 查看配置 -->
-    <el-dialog
+    <!-- <el-dialog
         title="设置最高并卷层级"
         :visible.sync="configVisible"
         width="50%"
@@ -660,7 +642,7 @@
           <el-tab-pane label="最高层级配置" name="first"></el-tab-pane>
           <el-tab-pane label="分类并卷配置" name="second"></el-tab-pane>
           <el-tab-pane label="独立组卷配置" name="third"></el-tab-pane>
-
+         
         </el-tabs>
       <el-checkbox-group v-model="checkList">
         <el-checkbox label="复选框 A" style="margin-bottom:10px"></el-checkbox><br/>
@@ -677,13 +659,49 @@
             @click="editSort()"
           >确 定</el-button>
         </span>
+      </el-dialog> -->
+      <el-dialog
+        :visible.sync="configVisible"
+        width="50%"
+        append-to-body
+      >
+        <div v-if="configInfo && configInfo.type">
+          <div class="config-type-name">
+            <span>配置类别:</span>
+            <span v-if="configInfo.type == 1">最高并卷层级</span>
+            <span v-if="configInfo.type == 2">分类并卷</span>
+            <span v-if="configInfo.type == 3">独立组卷</span>
+          </div>
+          <template v-if="configInfo.type !== 2">
+            <div class="config-allname">
+              {{configInfo.data.allName}}
+            </div>
+          </template>
+          <template v-else>
+            <el-tree :data="configInfo.data.tree" :props="{label: 'nodeName'}" show-checkbox :check-strictly="true" :default-checked-keys="checkedKeys" :default-expanded-keys="checkedKeys" node-key="id" ref="configtree" @check="configCheckChange" class="config-allname"></el-tree>
+          </template>
+        </div>
+        <div style="text-align: center;font-size: 22px;" v-else>
+          该节点尚未配置
+        </div>
+
+        <span
+          slot="footer"
+          class="dialog-footer"
+        >
+          <el-button @click="configVisible=false">取消查看</el-button>
+          <el-button v-if="configInfo && configInfo.type == 2"
+            type="primary"
+            @click="changeConfig"
+          >确认修改配置</el-button>
+        </span>
       </el-dialog>
   </basic-container>
 </template>
 
 <script>
 import ManualSorting from '@/components/WbsTree/ManualSorting'
-import { archiveTreeInit, lazyTree, dictionary, remove, archiveTreeSave, archiveTreeUpdate, archiveTreeDetail, archiveTreetree, submitDisplayConfigTree, getSameGradeNode, submitArchiveTreeSort,syncProjectTree } from "@/api/manager/archivetree";
+import { archiveTreeInit, lazyTree, dictionary, remove, archiveTreeSave, archiveTreeUpdate, archiveTreeDetail, archiveTreetree, submitDisplayConfigTree, getSameGradeNode, submitArchiveTreeSort,syncProjectTree,saveArchiveAutoRule,getArchiveAutoRule,updateArchiveAutoRule,removeArchiveAutoRule } from "@/api/manager/archivetree";
 import {getWbsList} from "@/api/manager/wbsinfo";
 import { getToken } from '@/util/auth';
 import { roletree } from "@/api/system/role.js";
@@ -947,6 +965,30 @@ export default {
         configVisible:false,
 
         projectId:'',
+	archiveAutoType:'',//最高1  分类2  独立3
+        nodesList:[],
+
+        configInfo:null,
+        checkedKeys:[],//分类并卷 回显 勾选数组
+
+        treeSelectId:'',//选中的划分树
+    }
+  },
+  computed:{
+    setName(){
+      let name = '';
+      switch (this.archiveAutoType) {
+        case 1:
+          name = '设置最高并卷层级';
+          break;
+        case 2:
+          name = '设置分类并卷层级';
+          break;
+        case 3:
+          name = '设置单独并卷层级';
+          break;
+      }
+      return name;
     }
   },
   methods: {
@@ -962,21 +1004,87 @@ export default {
         console.log(tab, event);
      },
      setHigh(){
-        this.highVisible=true
-       console.log('设置最高');
+      if(this.showHighVisible()){
+        this.archiveAutoType =1;
+      }
+        
+       //console.log('设置最高');
      },
      setType(){
-          console.log('设置类型');
+      if(this.showHighVisible()){
+        this.archiveAutoType =2;
+      }
+        //console.log('设置类型');
      },
     setAlone(){
-      console.log('设置独立');
+      if(this.showHighVisible()){
+        this.archiveAutoType =3;
+      }
+      //console.log('设置独立');
      },
-     viewConfig(data){
+      
+    showHighVisible(){
+      let nodes = this.$refs.settree.getCheckedNodes();
+      if(nodes.length < 1){
+        this.$message({
+          message: '请先勾选节点,再进行设置',
+          type: 'warning'
+        });
+        return false;
+      }
+
+      let ids = [];
+      nodes.forEach((element)=>{
+        element.pathName = this.getTreeNodePath(element,'settree')
+        ids.push(element.id);
+      })
+      //console.log(nodes)
+      this.checkList = ids;
+      this.nodesList = nodes;
+      this.highVisible=true;
+      return true;
+    },
+
+    async viewConfig(data){
        console.log(data,'查看配置');
-       this.configVisible=true
+       this.configInfo = null;
+       const { data: res } = await  getArchiveAutoRule({
+        nodeId:data.id,//归档树节点的id 或者 挂载wbs节点的ID(具体哪个ID待定)
+        iswbsNode:data.iswbsNode,//是否是wbs节点
+        projectId:this.projectId,//   系统级为0  项目级为项目id
+        wbsNode2ArchiveTreeNodeId:data.wbsNode2ArchiveTreeNodeId,// 这个树节点里面有(iswbsNode为true需传)
+        wbsId:this.treeSelectId // 这个就是一开始上面选择划分树的id(iswbsNode为true需传)
+       })
+
+       if (res.code == 200 && res.msg == "操作成功") {
+        //console.log(res.data)
+        if(res.data.type){
+          this.configInfo = res.data;
+        }else if(res.data.archiveAutoType){
+          this.configInfo = {
+            type:2,
+            data:res.data
+          }
+          this.checkedKeys = res.data.selectNodeIds.split(',');
+        }
+        this.configVisible=true
+      }
      },
-     handleCheckChange(data, checked, indeterminate) {
-        console.log(data, checked, indeterminate);
+     handleCheckChange(data, checks) {
+        //console.log(data, checks);
+        let array = checks.checkedNodes;
+        for (let index = 1; index < array.length; index++) {
+          const element = array[index];
+          if(element.iswbsNode !== array[0].iswbsNode){
+            //取消勾选
+            this.$refs.settree.setChecked(data.id,false,false)
+            this.$message({
+              message: '非wbs节点不能和wbs节点一起设置规则',
+              type: 'warning'
+            });
+            return;
+          }
+        }
       },
      handleentrybtn(){
        console.log(this.entrybtn,'entrybtn');
@@ -1505,19 +1613,6 @@ export default {
       this.testtreeoptions = datas[1].data.data;
     },
 
-    //切换树
-    async treeIdChange(id){
-      this.rightTreeLoading = true;
-      const { data: res } = await archiveTreetree({
-        projectId:0,
-        wbsId:id
-      })
-      //console.log(res);
-      this.rightTreeLoading = false;
-      if (res.code == 200 && res.msg == "操作成功") {
-        this.rightData = res.data
-      }
-    },
 
     synctree(data){
       this.$confirm('是否同步该节点?', '提示', {
@@ -1533,7 +1628,98 @@ export default {
         }).catch(() => {
                    
         });
-    }
+    },
+
+    //获取树节点名字路径
+    getTreeNodePath(node,refName){
+      let nodeInfo = this.$refs[refName].getNode(node.id);
+      //console.log(nodeInfo)
+      let pathArr = [];
+      while (nodeInfo.parent) {
+        pathArr.push(nodeInfo.data.title)
+        nodeInfo = nodeInfo.parent
+      }
+      return pathArr.reverse().join('/');
+    },
+
+    async setRecordsHandle(){
+      const { data: res } = await saveArchiveAutoRule({
+        archiveAutoType:this.archiveAutoType,//最高1  分类2  独立3
+        selectNodeIds:this.checkList.join(','),//鼠标选择的节点ID(只要鼠标选择的节点,选择节点的下级子节点那种不要),逗号拼接
+        iswbsNode:this.nodesList[0].iswbsNode,//是否是wbs节点 
+        projectId:this.projectId,//   系统级为0  项目级为项目id
+      })
+
+      if (res.code == 200 && res.msg == "操作成功") {
+        this.$message({
+          type: 'success',
+          message: '设置成功'
+        })
+        this.highVisible = false;
+      }
+    },
+
+    //立卷树勾选修改
+    configCheckChange(data, checks){
+      let array = checks.checkedNodes;
+        for (let index = 1; index < array.length; index++) {
+          const element = array[index];
+          if(element.iswbsNode !== array[0].iswbsNode){
+            //取消勾选
+            this.$refs.configtree.setChecked(data.id,false,false)
+            this.$message({
+              message: '非wbs节点不能和wbs节点一起设置规则',
+              type: 'warning'
+            });
+            return;
+          }
+        }
+    },
+
+    //立卷规则修改
+    async changeConfig(){
+      let keys = this.$refs.configtree.getCheckedKeys(true);
+      let nodes = this.$refs.configtree.getCheckedNodes();
+      console.log(nodes)
+      const { data: res } = await updateArchiveAutoRule({
+        archiveAutoType:2,//最高1  分类2  独立3
+        archiveAutoGroupId:this.configInfo.data.archiveAutoGroupId,
+        selectNodeIds:keys.join(','),//鼠标选择的节点ID(只要鼠标选择的节点,选择节点的下级子节点那种不要),逗号拼接
+        iswbsNode:nodes[0].iswbsNode,//是否是wbs节点 
+        projectId:this.projectId,//   系统级为0  项目级为项目id
+      })
+
+      if (res.code == 200 && res.msg == "操作成功") {
+        this.$message({
+          type: 'success',
+          message: '修改成功'
+        })
+        this.configVisible = false;
+      }
+    },
+
+    async removeArchive(data){
+      this.$confirm('此操作将永久删除配置, 是否继续?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          removeArchiveAutoRule({
+            nodeId:data.id,
+            iswbsNode:data.iswbsNode,//是否是wbs节点   flase 不是 true 是 (先false,具体怎么区分后面再看)
+            projectId:this.projectId,//   系统级为0  项目级为项目id
+          }).then((res)=>{
+            //console.log(res)
+            if (res.data.code == 200 && res.data.msg == "操作成功") {
+              this.$message({
+                type: 'success',
+                message: '修改成功'
+              })
+            }
+          })
+        });
+    },
+
   },
   watch: {
     filterText (val) {
@@ -1550,8 +1736,8 @@ export default {
 
     this.archiveTreetree({
       token: this.token,
-      disPlayTree: 1,
-      nodeType: 2,
+      //disPlayTree: 1,
+      //nodeType: 2,
     })
     this.archiveTreetree4()//全加载左侧树
     
@@ -1581,5 +1767,10 @@ export default {
    overflow: visible!important;
  }
 
-
+.config-type-name{
+  font-size: 18px;
+}
+.config-allname{
+  margin-top: 20px;
+}
 </style>