Parcourir la source

项目数据同步修改

duy il y a 2 mois
Parent
commit
5c2dc44f04

+ 18 - 0
src/api/manager/ledger.js

@@ -9,3 +9,21 @@ export const page = (params) => {
         params
     })
 }
+//获取当前项目的模板项目
+
+export const getTempProject = (params) => {
+    return request({
+        url: '/api/blade-manager/synchronousRecord/getTempProject',
+        method: 'get',
+        params
+    })
+}
+//新增数据
+
+export const addSync = (projectInfo) => {
+    return request({
+        url: '/api/blade-manager/synchronousRecord/add',
+        method: 'post',
+        data: projectInfo
+    })
+}

+ 2 - 7
src/views/manager/projectinfo/ledger.vue

@@ -19,11 +19,9 @@
             </el-option>
           </el-select>
           <el-select 
-
             v-model="searchForm.range"
             filterable
             style="width: 200px;margin-left: 10px;margin-right: 10px"
-
             placeholder="同步范围"
             clearable
             @change="listpage"
@@ -36,11 +34,9 @@
             ></el-option>
           </el-select>
           <el-select 
-                
-                  v-model="searchForm.type"
+                 v-model="searchForm.type"
                 filterable
                 style="width: 200px;margin-right: 10px"
-
                 placeholder="同步类型"
                 clearable
                 @change="listpage"
@@ -59,8 +55,7 @@
               >重置</el-button
             >
 
-  
-    
+
       </div>
   
       <el-table

+ 183 - 39
src/views/manager/projectinfo/tree.vue

@@ -1908,6 +1908,7 @@
       :visible.sync="proSyncTag"
       width="80%"
       append-to-body
+      @close=closeProSyncTag
     >
     <span slot="title" class="dialog-title">
         项目数据同步
@@ -1925,11 +1926,10 @@
                     :props="defaultProps"
                     :expand-on-click-node="false"
                     highlight-current
-                    node-key="id"
+                    node-key="primaryKeyId"
                     ref="tree"
-                   @check-change="handleCheckChange"
+                   @check="handleCheckChange"
                   >
-              
                   </el-tree>
                  
                 </div>
@@ -1938,35 +1938,36 @@
         <el-card class="box-card-2">
             <el-form ref="syncForm" :model="syncForm"  label-position="top">
                 <el-form-item label="同步范围">
-                      <el-radio-group v-model="syncForm.size">
-                        <el-radio label="1">从后管同步</el-radio>
-                        <el-radio label="2">同步到合同段</el-radio>
+                      <el-radio-group v-model="syncForm.range">
+                        <el-radio
+                          v-for="item in rangeOptions"
+                          :key="item.id"
+                          :label="item.dictKey"
+                        >{{  item.dictValue}}</el-radio>
                       </el-radio-group>
                 </el-form-item>
                   <el-form-item label="同步类型" prop="type">
-                    <el-checkbox-group v-model="syncForm.type">
-                      <el-checkbox label="全选" ></el-checkbox>
-                      <el-checkbox label="新增表单"></el-checkbox>
-                      <el-checkbox label="表单排序" ></el-checkbox>
-                      <el-checkbox label="电签配置"></el-checkbox>
-                      <el-checkbox label="公式配置"></el-checkbox>
-                      <el-checkbox label="默认值配置"></el-checkbox>
-                      <el-checkbox label="清表配置" ></el-checkbox>
-                      <el-checkbox label="元素配置"></el-checkbox>
-                    </el-checkbox-group>
+                    <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
+                        <div style="margin: 15px 0;"></div>
+                        <el-checkbox-group v-model="syncForm.type" @change="handleCheckedTypeChange">
+                          <el-checkbox v-for="item in typeOptions" :label="item.dictKey" :key="item.id">{{ item.dictValue}}</el-checkbox>
+                        </el-checkbox-group>
                   </el-form-item>
-                  <el-form-item label="选择同步范围(节点状态)" prop="checkId1" v-if="syncForm.size==='2'">
-                    <el-checkbox-group v-model="syncForm.checkId1">
+                  <el-form-item label="选择同步范围(节点状态)" prop="contractRange" v-if="syncForm.range==='2'">
+                    <el-checkbox-group v-model="syncForm.contractRange">
                       <el-checkbox label="全选" name="1"></el-checkbox>
-                      <el-checkbox v-for="(item,index) in checkIdList" :key="index" :label="item.name"  ></el-checkbox>
+                      <el-checkbox v-for="(item,index) in checkIdList"  :label="item.dictKey" :key="item.id">{{ item.dictValue}}</el-checkbox>
                     
                     </el-checkbox-group>
                   </el-form-item>
-                  <el-form-item label="选择同步源" prop="checkId" v-else>
-                    <el-select v-model="syncForm.checkId" placeholder="请选择同步源" style="width: 100%;" size="small">
-                      <el-option label="区域一" value="shanghai"></el-option>
-                      <el-option label="区域二" value="beijing"></el-option>
-                      <el-option label="区域二" value="beijing"></el-option>
+                  <el-form-item label="选择同步源" prop="templateId" v-else>
+                    <el-select v-model="syncForm.templateId" placeholder="请选择同步源" style="width: 100%;" size="small">
+                      <el-option
+                        v-for="item in templateIdList"
+                        :key="item.id"
+                        :label="item.name"
+                        :value="item.id">
+                      </el-option>
                     </el-select>
                 </el-form-item>
             </el-form>
@@ -2005,7 +2006,7 @@
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="closeProSyncTag">取 消</el-button>
-        <el-button type="primary" @click="saveProTag">确 定</el-button>
+        <el-button type="primary" @click="saveProTag" :loading="saveProTagLoading">确 定</el-button>
       </span>
     </el-dialog>
   </div>
@@ -2075,7 +2076,7 @@ import {
 } from "@/api/exctab/excelmodel";
 import { getStore, setStore } from "@/util/store";
 
-
+import { getTempProject,addSync } from "@/api/manager/ledger";
 
 export default {
   data() {
@@ -2416,11 +2417,20 @@ export default {
       selectDiv:Math.random(),
       saveFileLoading:false,
       proSyncTag:false,
+      rangeOptions:[],
+      typeOptions:[],
+      checkAll: false,
+      isIndeterminate: true,
       syncForm:{
-        size:'',
+        range:'',
+        rangeName:'',
         type:[],
-        checkId:'',
-        checkId1:[]
+        typeName:'',
+        templateId:'',
+        templateName:'',
+        contractRange:[],
+        contractRangeName:'',
+        formIds:''
       },
       preTableData:
       [{
@@ -2431,14 +2441,12 @@ export default {
       ],
       multipleSelection: [],
       checkIdList:[
-        {name:'未填报',value:'1'},
-        {name:'已填报-未上报',value:'2'},
-        {name:'待审批',value:'3'},
-        {name:'已审批',value:'4'},
+       
       ],
       isShowLeft:true,
       isShowTable:false,
-     
+      templateIdList:[],//同步源
+      saveProTagLoading:false,
     };
   },
   computed: {
@@ -4671,19 +4679,82 @@ export default {
     },
     proSyncbtn(){
       console.log('项目数据同步');
+      this.getTypeOptions()
+      this.getRangeOptions()
+      this.getCheckIdList()
       this.proSyncTag=true
       this.isShowLeft=true
       this.isShowTable=false
     },
+    getRangeOptions(){
+      getDictionary({
+        code: "wbs_snyc_range",
+      }).then((res) => {
+        this.rangeOptions = res.data.data;
+      });
+     },
+     getTypeOptions(){
+      getDictionary({
+        code: "wbs_sync_type",
+      }).then((res) => {
+        this.typeOptions = res.data.data;
+      });
+     },
+     handleCheckChange(_,{checkedKeys,halfCheckedNodes}) {
+        let ids=checkedKeys && checkedKeys.length ? checkedKeys.join(',') : ''
+        this.getTempProjectList(ids)
+      },
+     async getTempProjectList(ids){
+         //分页获取证书列表数据
+         const { data: res } = await getTempProject({
+          nodeIds:ids
+        });
+        if (res.code == 200) {
+          this.templateIdList = res.data;
+         
+        }
+     },
+     async getCheckIdList(){
+      let code=this.wbsType!==1?'wbs_sync_contract_range':'wbs_sync_contract_quality'
+          getDictionary({
+            code: code,
+          }).then((res) => {
+            this.checkIdList = res.data.data;
+          });
+     },
+     
     closeProSyncTag(){
-      
+      this.syncForm={}
     },
     saveProTag(){
-      
-    },
-    handleCheckChange(data, checked, indeterminate) {
-      console.log(data, checked, indeterminate);
+      console.log(this.syncForm,'this.syncForm');
+      this.syncForm.projectId=this.projectid
+      this.saveProTagLoading=true
+      addSync({
+        ...this.syncForm,
+       type:this.syncForm.type.join(','),
+       contractRange:this.syncForm.contractRange.join(',')
+      }
+      ).then((res) => {
+        if(res.data.code==200){
+        this.$message.success(res.data.msg)
+         
+        }else{
+          this.$message.error(res.data.msg)
+        }
+      })
     },
+    handleCheckAllChange(val) {
+        // this.syncForm.type = val ? this.typeOptions : [];
+        // this.isIndeterminate = false;
+        this.syncForm.type = val ? this.typeOptions.map(item => item.dictKey) : [];
+        this.isIndeterminate = false;
+     },
+     handleCheckedTypeChange(value){
+      let checkedCount = value.length;
+        this.checkAll = checkedCount === this.typeOptions.length;
+        this.isIndeterminate = checkedCount > 0 && checkedCount < this.typeOptions.length;
+     },
     handleSelectionChange(val) {
       this.multipleSelection = val;
     },
@@ -4719,6 +4790,79 @@ export default {
         this.$refs.tree.filter(val);
       }
     },
+    'syncForm.contractRange': {
+    handler(newVal) {
+      if (newVal && newVal.length) {
+        const selectedValues = newVal.map(key => {
+          const item = this.checkIdList.find(item => item.dictKey === key);
+          return item ? item.dictValue : key;
+        });
+        this.syncForm.contractRangeName = selectedValues.join(',');
+      } else {
+        this.syncForm.contractRangeName = '';
+      }
+    },
+    immediate: true
+  },
+  'syncForm.templateId': {
+    handler(newVal) {
+      // if (newVal && newVal.length) {
+      //   const selectedValues = newVal.map(key => {
+      //     const item = this.templateIdList.find(item => item.dictKey === key);
+      //     return item ? item.dictValue : key;
+      //   });
+      //   this.syncForm.templateName = selectedValues.join(',');
+      // } else {
+      //   this.syncForm.templateName = '';
+      // }
+      if (newVal && newVal.length) {
+          for (let index = 0; index < this.templateIdList.length; index++) {
+            const elemet = this.rangeOptions[index];
+            if(elemet.id==newVal){
+              this.syncForm.templateName = elemet.name;
+              break
+            }
+          }
+
+          } else {
+            this.syncForm.rangeName = '';
+          }
+    },
+    immediate: true
+  },
+    'syncForm.type': {
+      handler(newVal) {
+        if (newVal && newVal.length) {
+            const selectedValues = newVal.map(key => {
+              const item = this.typeOptions.find(item => item.dictKey === key);
+              return item ? item.dictValue : key;
+            });
+            this.syncForm.typeName = selectedValues.join(',');
+          } else {
+            this.syncForm.typeName = '';
+          }
+      },
+      immediate: true
+    },
+    'syncForm.range': {
+      handler(newVal) {
+        console.log(newVal,'newVal');
+        
+        if (newVal && newVal.length) {
+          for (let index = 0; index < this.rangeOptions.length; index++) {
+            const elemet = this.rangeOptions[index];
+            if(elemet.dictKey==newVal){
+              this.syncForm.rangeName = elemet.dictValue;
+              break
+            }
+          }
+
+          } else {
+            this.syncForm.rangeName = '';
+          }
+      },
+      immediate: true
+    },
   },
   components: {
     dynamicExcel,