From 7ce592bb5a5b9e0dc78786e727f042b95ebc81c8 Mon Sep 17 00:00:00 2001
From: lihang <lihang@vci-tech.com>
Date: 星期四, 13 七月 2023 16:00:59 +0800
Subject: [PATCH] Merge branch 'master' of http://dev.vci-tech.com:1065/r/ubcs

---
 Source/UBCS-WEB/src/views/modeling/cycle.vue |  175 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 150 insertions(+), 25 deletions(-)

diff --git a/Source/UBCS-WEB/src/views/modeling/cycle.vue b/Source/UBCS-WEB/src/views/modeling/cycle.vue
index c7a5fd2..5df55c7 100644
--- a/Source/UBCS-WEB/src/views/modeling/cycle.vue
+++ b/Source/UBCS-WEB/src/views/modeling/cycle.vue
@@ -5,9 +5,13 @@
       :option="option"
       :page="page"
       :table-loading="loading"
+      selection
+      @size-change="search('size', ...arguments)"
+      @current-change="search('current', ...arguments)"
       @refresh-change="search"
       @search-change="search('search', ...arguments)"
       @search-reset="search('reset', ...arguments)"
+      @selection-change="selectionChange"
     >
       <template slot-scope="scope" slot="menuLeft">
         <el-button
@@ -17,12 +21,22 @@
           @click="openDialog('add', {})"
           >鏂板</el-button
         >
+        <el-button
+          type="danger"
+          icon="el-icon-delete"
+          size="small"
+          @click="batchDel()"
+          v-if="selectedData.length > 0"
+          :loading="delLoading"
+          >鍒犻櫎</el-button
+        >
       </template>
       <template slot-scope="{ row, index }" slot="menu">
         <el-button
           type="text"
           icon="el-icon-edit"
           size="mini"
+          :loading="row.editLoading"
           @click="openDialog('edit', row)"
           >缂栬緫</el-button
         >
@@ -30,8 +44,18 @@
           type="text"
           icon="el-icon-view"
           size="mini"
+          :loading="row.detailLoading"
           @click="openDialog('detail', row)"
           >棰勮</el-button
+        >
+        <el-button
+          class="btn_link_del"
+          type="text"
+          icon="el-icon-delete"
+          size="mini"
+          :loading="row.delLoading"
+          @click="rowDel(row)"
+          >鍒犻櫎</el-button
         >
       </template></avue-crud
     >
@@ -58,7 +82,13 @@
         @save-data="save"
       />
       <template #footer v-if="type !== 'detail'">
-        <el-button type="primary" size="mini" @click="submit">淇濆瓨</el-button>
+        <el-button
+          type="primary"
+          size="mini"
+          @click="submit"
+          :loading="submitLoading"
+          >淇濆瓨</el-button
+        >
         <el-button type="" size="mini" @click="visible = false">鍙栨秷</el-button>
       </template>
     </el-dialog>
@@ -73,7 +103,12 @@
   components: { CycleFlow },
   data() {
     return {
-      form: {},
+      form: {
+        // 'contionMap[id]': 'qwe'
+        // contionMap: [
+        //   {id: 'qwe'}
+        // ]
+      },
       page: {
         pageSize: 10,
         total: 0,
@@ -81,7 +116,8 @@
         layout: "total, sizes, prev, pager, next, jumper",
       },
       option: {
-        searchMenuSpan: 12,
+        selection: true,
+        searchMenuSpan: 6,
         searchMenuPosition: "right",
         border: true,
         align: "center",
@@ -94,6 +130,7 @@
           {
             label: "缂栧彿",
             prop: "id",
+            search: true,
           },
           {
             label: "鍚嶇О",
@@ -102,7 +139,7 @@
           },
           {
             label: "璧峰鐘舵��",
-            prop: "startStatusName",
+            prop: "startStatus",
             search: true,
           },
           {
@@ -120,6 +157,9 @@
       dialogWidth: "50%",
       type: "detail",
       loading: false,
+      delLoading: false,
+      submitLoading: false,
+      selectedData: [],
     };
   },
   created() {
@@ -135,10 +175,18 @@
           total: 0,
           currentPage: 1,
         };
+      } else if (type === "size") {
+        this.page.pageSize = params;
+      } else if (type === "current") {
+        this.page.currentPage = params;
       }
       this.loading = true;
-      const { limit, page } = this.page;
-      API.getList(Object.assign({}, params, { limit, page })).then((res) => {
+      API.getList(
+        Object.assign({}, params, {
+          size: this.page.pageSize,
+          current: this.page.currentPage,
+        })
+      ).then((res) => {
         this.loading = false;
         this.data = res.data.data.records;
         this.page.total = res.data.data.total;
@@ -162,52 +210,126 @@
           this.$set(row, "detailLoading", false);
           this.$set(row, "editLoading", false);
           this.rowData = row;
-          this.nodesEdgesData = {nodes: res.nodes, edges: res.edges}
+          const nodes = res.data.data.nodes.map((item) => {
+            item.label = item.id;
+            item.index = item.indexNum;
+            return item;
+          });
+          const edges = res.data.data.edges.map((item) => {
+            item.label = item.name;
+            item.width = 80;
+            item.height = 48;
+            item.index = 1;
+            item.index = item.indexNum;
+            return item;
+          });
+          this.nodesEdgesData = { nodes, edges };
+          this.visible = true;
         });
       } else {
+        this.nodesEdgesData = {};
+        this.rowData = {};
         this.title = "鏂板鐢熷懡鍛ㄦ湡娴佺▼鍥�";
         this.dialogWidth = "95%";
         this.visible = true;
       }
     },
+    // 閫変腑鏁版嵁
+    selectionChange(selectedData) {
+      this.selectedData = selectedData;
+    },
+    // 鍒犻櫎
+    rowDel(row) {
+      this.$confirm("纭鍒犻櫎璇ユ潯鏁版嵁?", "鎻愮ず", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      }).then(() => {
+        this.$set(row, "delLoading", true);
+        API.del({ oid: row.oid, id: row.id })
+          .then((res) => {
+            this.$set(row, "delLoading", false);
+            if (res.data.code === 200) {
+              this.$message.success("鍒犻櫎鎴愬姛锛�");
+              this.search();
+            }
+          })
+          .catch(() => {
+            this.$set(row, "delLoading", false);
+          });
+      });
+    },
+    batchDel() {
+      this.$confirm("纭鍒犻櫎鎵�閫夋暟鎹�?", "鎻愮ず", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      }).then(() => {
+        const data = this.selectedData.map((item) => {
+          return {
+            id: item.id,
+            oid: item.oid,
+          };
+        });
+        this.delLoading = true;
+        API.del(data, true)
+          .then((res) => {
+            this.delLoading = false;
+            if (res.data.code === 200) {
+              this.$message.success("鍒犻櫎鎴愬姛锛�");
+              this.search();
+            }
+          })
+          .catch(() => {
+            this.delLoading = false;
+          });
+      });
+    },
     async submit() {
       const newRowData = await this.$refs.vueFlowchartEditor.getNewRowData();
-      console.log(newRowData, "newRowDatanewRowData");
       if (!newRowData) {
         return;
       }
-      const flowData = this.$refs.vueFlowchartEditor.getFlowData();
+      const flowData = await this.$refs.vueFlowchartEditor.getFlowData();
       if (Array.isArray(flowData.nodes)) {
         flowData.nodes = flowData.nodes.map((item) => {
           item.name = item.id;
+          item.indexNum = item.index;
           return item;
         });
       }
       if (Array.isArray(flowData.edges)) {
         flowData.edges = flowData.edges.map((item) => {
           item.name = item.label;
+          item.indexNum = item.index;
           return item;
         });
       }
-
       let params = {
-        ...flowData,
         ...newRowData,
+        ...flowData,
       };
-      console.log(flowData, newRowData);
-      API.add(params).then((res) => {
-        console.log(res, "res");
-      });
-    },
-  },
-  watch: {
-    page: {
-      deep: true,
-      immediate: true,
-      handler(newV) {
-        this.page.page = newV.currentPage;
-        this.page.limit = newV.pageSize;
-      },
+
+      this.submitLoading = true;
+      let APIFun = API.add;
+      if (this.type === "edit") {
+        APIFun = API.edit;
+        this.$delete(params, "id");
+      }
+      APIFun(params)
+        .then((res) => {
+          this.submitLoading = false;
+          if (res.data.code === 200) {
+            this.$message.success(
+              this.type === "edit" ? "淇敼鎴愬姛锛�" : "鏂板鎴愬姛锛�"
+            );
+            this.visible = false;
+            this.search();
+          }
+        })
+        .catch(() => {
+          this.submitLoading = false;
+        });
     },
   },
 };
@@ -224,4 +346,7 @@
   margin: 0;
   padding: 0;
 }
+.btn_link_del {
+  color: red;
+}
 </style>

--
Gitblit v1.9.3