Browse Source

关联清表

zhangh 3 years ago
parent
commit
625ada5e60
2 changed files with 113 additions and 67 deletions
  1. 17 0
      src/api/manager/wbstree.js
  2. 96 67
      src/views/manager/projectinfo/tree.vue

+ 17 - 0
src/api/manager/wbstree.js

@@ -194,4 +194,21 @@ export const parameters = (params) => {
         method: 'get',
         params
     })
+}
+
+// 保存参数
+export const saveOrUpdateBatch = (data) => {
+        return request({
+            url: '/api/blade-manager/param/saveOrUpdateBatch',
+            method: 'post',
+            data
+        })
+    }
+    // 参数名称接口
+export const keymap = (params) => {
+    return request({
+        url: '/api/blade-manager/param/keymap',
+        method: 'get',
+        params
+    })
 }

+ 96 - 67
src/views/manager/projectinfo/tree.vue

@@ -396,7 +396,7 @@
         <el-button
           style="margin-left:30px;"
           type="primary"
-          @click="saveLinkTab"
+          @click="saveLinkTab()"
         >确 定</el-button>
       </span>
     </el-dialog>
@@ -1089,7 +1089,7 @@
           type="text"
           icon="el-icon-s-operation"
           class="right-btn"
-          @click="infoNameVisible = true"
+          @click="setNodeParameters()"
         ></el-button>
         <div class="flexEnd">
           <i
@@ -1118,8 +1118,8 @@
                 <el-option
                   v-for="item in namelist"
                   :key="item.id"
-                  :label="item.dictValue"
-                  :value="item.dictKey"
+                  :label="item.name"
+                  :value="item.id"
                 ></el-option>
               </el-select>
             </template>
@@ -1170,6 +1170,7 @@
       </span>
     </el-dialog>
 
+    <!-- 设置参数名称 -->
     <el-dialog
       title="设置参数名称"
       :visible.sync="infoNameVisible"
@@ -1187,7 +1188,7 @@
           ></i>
         </div>
         <el-table
-          :data="namelist"
+          :data="namelists"
           border
           style="width: 100%"
           height="400"
@@ -1198,12 +1199,7 @@
             label="参数名称"
           >
             <template slot-scope="scope">
-              <template v-if="scope.row.isEdit">
-                <el-input v-model="scope.row.name"></el-input>
-              </template>
-              <template v-else>
-                {{scope.row.name}}
-              </template>
+              <el-input v-model="scope.row.name"></el-input>
             </template>
           </el-table-column>
           <el-table-column
@@ -1212,12 +1208,7 @@
             label="参数值KEY"
           >
             <template slot-scope="scope">
-              <template v-if="scope.row.isEdit">
-                <el-input v-model="scope.row.key"></el-input>
-              </template>
-              <template v-else>
-                {{scope.row.key}}
-              </template>
+              <el-input v-model="scope.row.k"></el-input>
             </template>
           </el-table-column>
           <el-table-column
@@ -1226,12 +1217,7 @@
             label="描述"
           >
             <template slot-scope="scope">
-              <template v-if="scope.row.isEdit">
-                <el-input v-model="scope.row.describe"></el-input>
-              </template>
-              <template v-else>
-                {{scope.row.describe}}
-              </template>
+              <el-input v-model="scope.row.remark"></el-input>
             </template>
           </el-table-column>
           <el-table-column
@@ -1240,18 +1226,6 @@
             align="center"
           >
             <template slot-scope="scope">
-              <el-button
-                type="text"
-                size="small"
-                v-show="scope.row.isEdit"
-                @click="saveNodeInfoHandle(scope.$index, scope.row)"
-              >保存</el-button>
-              <el-button
-                type="text"
-                size="small"
-                v-show="!scope.row.isEdit"
-                @click="editNodeInfo(scope.$index, scope.row)"
-              >编辑</el-button>
               <el-button
                 type="text"
                 size="small"
@@ -1267,7 +1241,7 @@
         class="dialog-footer"
       >
         <el-button @click="addParameterName()">保 存</el-button>
-        <el-button @click="infoNameVisible = false">关 闭</el-button>
+        <el-button @click="closeParameter()">关 闭</el-button>
       </span>
     </el-dialog>
 
@@ -1279,7 +1253,7 @@ import ManualSorting from '@/components/WbsTree/ManualSorting'
 import dynamicExcel from "./treeTemplate/dynamicExcel.vue";
 import {
   saveFormAndElement, selectFormElements,
-  importWbsTree, findWbsTreePrivateSameLevel, wbsTreePrivateSort, parameters
+  importWbsTree, findWbsTreePrivateSameLevel, wbsTreePrivateSort, parameters, saveOrUpdateBatch, keymap
 } from "@/api/manager/wbstree";
 import {
   saveElement, remove as removeElement, updateBatchElements, getTemplate,
@@ -1395,6 +1369,7 @@ export default {
       nodeInfoVisible: false,
       nodeInfoTable: [],
       namelist: [],
+      namelists: [],
 
       infoNameVisible: false,
       //#endregion
@@ -1441,7 +1416,6 @@ export default {
       })
     },
     getNodeDetail (data, node) {
-      //console.log(data,node,ref)
       let parentName = '';
       if (node.parent.data) {
         parentName = node.parent.data.title;
@@ -1804,19 +1778,6 @@ export default {
       //console.log(file)
       this.upFile = file;
     },
-
-    nodeInfo (data) {
-      console.log(data);
-      this.parameters(data.primaryKeyId)
-      this.nodeInfoVisible = true;
-    },
-    nodeInfoSave () {
-
-    },
-
-    delNodeInfo () {
-
-    },
     editNodeInfo (index, row) {
       this.$set(row, 'isEdit', true);
     },
@@ -2088,19 +2049,32 @@ export default {
       }
     },
     async saveLinkTab () {//保存按钮
-      const { data: res } = await saveLinkTab({
-        exceTabId: this.$refs.tree.getCheckedNodes()[this.$refs.tree.getCheckedNodes.length - 1].id,
-        tabId: this.GLExcelFrom.id,
-      })
-      console.log(res);
-      if (res.code === 200) {
+      if (this.$refs.tree.getCheckedNodes.length > 0) {
+        const { data: res } = await saveLinkTab({
+          exceTabId: this.$refs.tree.getCheckedNodes()[this.$refs.tree.getCheckedNodes().length - 1].id,
+          tabId: this.GLExcelFrom.id,
+        })
+        console.log(res);
+        if (res.code === 200) {
+          this.$message({
+            type: 'success',
+            message: '关联清表成功',
+          })
+          this.GLExcel = false
+          this.GLExcelMD()
+          selectByNodeTable(this.jiedianId, this.projectid, this.id).then((res) => {
+            if (res.data.data.length) {
+              this.formData = res.data.data;
+            } else {
+              this.formData = [];
+            }
+          })
+        }
+      } else {
         this.$message({
           type: 'success',
-          message: '关联清表成功',
+          message: '请先设置清表',
         })
-        this.GLExcel = false
-        this.GLExcelMD()
-        this.setLeftType(4, { id: this.jiedianId })
       }
     },
     filterNode222 (GLExcelFromvalue, dataAssociationlist) {
@@ -2110,21 +2084,76 @@ export default {
     //#endregion
 
     //#region 节点参数
+    nodeInfo (data) {//节点参数按钮
+      console.log(data);
+      this.keymap()
+      this.jiedianId = data.primaryKeyId
+      this.parameters(data.primaryKeyId)
+      this.nodeInfoVisible = true;
+    },
     addNodeInfoTable () {//添加节点参数数据
       this.nodeInfoTable.unshift({ name: '', value: '', describe: '' })
     },
-    async parameters (wbsId) {
+    delNodeInfo (key) {//设置参数名称中的删除按钮
+      this.namelists.splice(key, 1)
+    },
+    setNodeParameters () {//打开设置节点参数弹框按钮
+      this.infoNameVisible = true
+      this.namelists = [...this.namelist]
+    },
+    async setParameterName () {//设置参数名称中添加节点参数按钮
+      this.namelists.unshift({ name: '', remark: '', k: '', type: 0, wbsId: this.jiedianId })
+    },
+    nodeInfoSave () {//节点参数弹框保存按钮
+
+    },
+    async addParameterName () {//设置参数名称中的保存按钮
+      if (this.namelists) {
+        let tag = true
+        this.namelists.forEach(val => {
+          if (!val.name || !val.k) {
+            return tag = false
+          }
+        })
+        if (tag) {
+          console.log({ wps: this.namelists });
+          await this.saveOrUpdateBatch(this.namelists) //保存设置参数
+          this.infoNameVisible = false
+          this.keymap()
+        } else {
+          this.$message({
+            type: "error",
+            message: "请填写所有的参数名称和参数值KEY!"
+          })
+        }
+      } else {
+        this.$message({
+          type: "error",
+          message: "请设置参数"
+        })
+      }
+    },
+    closeParameter () {//设置参数名称,关闭按钮
+      this.namelists = []
+      this.infoNameVisible = false
+    },
+    async parameters (wbsId) {//获取接待你参数列表
       const { data: res } = await parameters({ wbsId })
       console.log(res);
       if (res.code == 200) {
         this.nodeInfoTable = res.data
       }
     },
-    //#endregion
-
-    //#region
-    async setParameterName () {
-      this.namelist.unshift({ name: '', remark: '', k: '' })
+    async saveOrUpdateBatch (da) {//保存
+      const { data: res } = await saveOrUpdateBatch(da)
+      console.log(res);
+    },
+    async keymap () {//节点参数枚举
+      const { data: res } = await keymap()
+      console.log(res);
+      if (res.code = 200) {
+        this.namelist = res.data
+      }
     },
     //#endregion