From a3c868db4d017961be2d394eadb7d428045d5adc Mon Sep 17 00:00:00 2001
From: lihang <lihang@vci-tech.com>
Date: 星期四, 13 七月 2023 11:13:16 +0800
Subject: [PATCH] 业务类型页面增加生命周期的处理

---
 Source/UBCS-WEB/src/views/modeling/cycle.vue |  361 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 199 insertions(+), 162 deletions(-)

diff --git a/Source/UBCS-WEB/src/views/modeling/cycle.vue b/Source/UBCS-WEB/src/views/modeling/cycle.vue
index 5e3686d..c7a5fd2 100644
--- a/Source/UBCS-WEB/src/views/modeling/cycle.vue
+++ b/Source/UBCS-WEB/src/views/modeling/cycle.vue
@@ -1,190 +1,227 @@
 <template>
-  <el-container>
-  <el-aside width="240px">
-    <el-button @click="addHandlers"></el-button>
-    <basic-container style="margin-top: 10px">
-      <avue-tree id="basic" :data="treeData" :option="treeOption"  >
-      </avue-tree>
-    </basic-container>
-  </el-aside>
-  <basic-container >
-    <el-button type="primary" @click="dialogTableVisible=true" size="small">鍒涘缓妯℃澘</el-button>
-    <el-button type="primary"  size="small" @click="addHandlers">缂栬緫妯℃澘</el-button>
-    <el-button type="primary" size="small" @click="$refs.flow.addNode('ffff')">娣诲姞鑺傜偣</el-button>
-    <br/><br/>
-    <avue-flow ref="flow" v-model="form" :height="703" :option="option" :width="1500">
-      <template slot="header" slot-scope="scope">
-        <i class="el-icon-delete" @click="$refs.flow.deleteNode(scope.node.id)" style="margin-top: 8px"></i>
+  <basic-container class="">
+    <avue-crud
+      :data="data"
+      :option="option"
+      :page="page"
+      :table-loading="loading"
+      @refresh-change="search"
+      @search-change="search('search', ...arguments)"
+      @search-reset="search('reset', ...arguments)"
+    >
+      <template slot-scope="scope" slot="menuLeft">
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          size="small"
+          @click="openDialog('add', {})"
+          >鏂板</el-button
+        >
       </template>
-      <div slot-scope="{node}">
-        <span>{{ (node || {}).name }}</span>
-      </div>
-    </avue-flow>
-    <!--    鍒涘缓瀵硅瘽妗�-->
-    <el-dialog title="鍒涘缓妯℃澘" :visible.sync="dialogTableVisible" append-to-body>
-      <avue-form :data="addData" :option="addoption" v-model="forms">
-
-        <template slot="filetype">
-          <el-select v-model="forms.select" slot="prepend" placeholder="璇烽�夋嫨" style="max-width: 300px">
-            <el-option label="娴嬭瘯1" value="1"></el-option>
-            <el-option label="娴嬭瘯2" value="2"></el-option>
-            <el-option label="娴嬭瘯3" value="3"></el-option>
-          </el-select>
-          <el-button  type="primary" @click="handelLife" style="display: inline-block;margin-left: 5px">
-            娣诲姞璧峰鐘舵��
-          </el-button>
-        </template>
-      </avue-form>
+      <template slot-scope="{ row, index }" slot="menu">
+        <el-button
+          type="text"
+          icon="el-icon-edit"
+          size="mini"
+          @click="openDialog('edit', row)"
+          >缂栬緫</el-button
+        >
+        <el-button
+          type="text"
+          icon="el-icon-view"
+          size="mini"
+          @click="openDialog('detail', row)"
+          >棰勮</el-button
+        >
+      </template></avue-crud
+    >
+    <el-dialog
+      :visible="visible"
+      :width="dialogWidth"
+      :title="title"
+      append-to-body
+      :before-close="
+        () => {
+          visible = false;
+        }
+      "
+      top="10vh"
+    >
+      <CycleFlow
+        v-if="visible"
+        class="cycle_flow"
+        :type="type"
+        :chart-data="nodesEdgesData"
+        :chart-data-node-items="flowChartNodeItems"
+        :rowData="rowData"
+        ref="vueFlowchartEditor"
+        @save-data="save"
+      />
+      <template #footer v-if="type !== 'detail'">
+        <el-button type="primary" size="mini" @click="submit">淇濆瓨</el-button>
+        <el-button type="" size="mini" @click="visible = false">鍙栨秷</el-button>
+      </template>
     </el-dialog>
   </basic-container>
-
-
-  </el-container>
-
 </template>
 
 <script>
+import API from "@/api/modeling/cycle";
+import CycleFlow from "@/components/flow-cycle/flowchartEditor.vue";
 export default {
   name: "cycle.vue",
+  components: { CycleFlow },
   data() {
     return {
-      //妯℃澘瀵硅瘽妗�,
-      dialogTableVisible:false,
-      forms:{
-        select:""
+      form: {},
+      page: {
+        pageSize: 10,
+        total: 0,
+        currentPage: 1,
+        layout: "total, sizes, prev, pager, next, jumper",
       },
-      addData:[],
-      addoption:{
-        formslot:true,
-        column:[
+      option: {
+        searchMenuSpan: 12,
+        searchMenuPosition: "right",
+        border: true,
+        align: "center",
+        menuAlign: "center",
+        menu: true,
+        delBtn: false,
+        editBtn: false,
+        addBtn: false,
+        column: [
           {
-            label:"鍚嶇О",
-            prop:"name"
+            label: "缂栧彿",
+            prop: "id",
           },
           {
-            label:"鏍囩",
-            prop:"tag"
+            label: "鍚嶇О",
+            prop: "name",
+            search: true,
           },
           {
-            label:"璧峰鐘舵��",
-            prop:"filetype",
-            formslot: true,
-            span:24
+            label: "璧峰鐘舵��",
+            prop: "startStatusName",
+            search: true,
           },
           {
             label: "鎻忚堪",
-            prop:"desc",
-            type:"textarea",
-            span:13
-          }
-        ]
-      },
-      count: 0,
-      form: {},
-      treeData: [{
-        value: 0,
-        label: '鐢熷懡鍛ㄦ湡妯℃澘鍒楄〃',
-        children: [
-          {
-            value: 1,
-            label: 'A',
+            prop: "description",
           },
-          {
-            value: 2,
-            label: 'B',
-          },
-          {
-            value: 3,
-            label: 'C',
-          },
-          {
-            value: 4,
-            label: 'D',
-          },
-          {
-            value: 5,
-            label: 'E',
-          }
-        ]
-      }],
-      treeOption: {
-        defaultExpandAll: true,
-      },
-      option: {
-        nodeList: [
-          {
-            "id": "nodeA",
-            "name": "娴佺▼A-鑺傜偣A",
-            "left": 39,
-            "top": 110,
-          },
-          {
-            "id": "nodeB",
-            "name": "娴佺▼A-鑺傜偣B",
-            "left": 340,
-            "top": 161,
-          },
-          {
-            "id": "nodeC",
-            "name": "娴佺▼A-鑺傜偣C",
-            "left": 739,
-            "top": 161,
-          },
-          {
-            "id": "nodeD",
-            "name": "鑺傜偣D",
-            "left": 739,
-            "top": 20,
-          }
         ],
-        lineList: [
-          {
-            "from": "nodeA",
-            "to": "nodeB"
-          },
-          {
-            "from": "nodeB",
-            "to": "nodeC"
-          },
-          {
-            "from": "nodeC",
-            "to": "nodeD"
-          }
-        ]
       },
-      computed: {
-        nodeList() {
-          return this.option.nodeList
-        }
-      },
-      mounted() {
-        this.form = this.nodeList[this.count].id;
-      },
-      methods: {
-        handleClick(node) {
-          this.$message.success(JSON.stringify(node))
-          console.log(node)
-        },
-        addHandler(){
-          this.dialogTableVisible=true
-          console.log(1)
-        },
-
-        handelLife(){
-          console.log("鐐瑰嚮鎴愬姛")
-        },
-        addHandlers(){
-          console.log(111)
-        }
+      data: [],
+      title: "棰勮鐢熷懡鍛ㄦ湡娴佺▼鍥�",
+      visible: false,
+      flowChartNodeItems: [],
+      rowData: {},
+      nodesEdgesData: {},
+      dialogWidth: "50%",
+      type: "detail",
+      loading: false,
+    };
+  },
+  created() {
+    this.search("search", {});
+  },
+  methods: {
+    search(type, params, done) {
+      if (type === "search") {
+        this.page.currentPage = 1;
+      } else if (type === "reset") {
+        this.page = {
+          pageSize: 10,
+          total: 0,
+          currentPage: 1,
+        };
       }
-    }
-  }
-}
+      this.loading = true;
+      const { limit, page } = this.page;
+      API.getList(Object.assign({}, params, { limit, page })).then((res) => {
+        this.loading = false;
+        this.data = res.data.data.records;
+        this.page.total = res.data.data.total;
+        this.loading = false;
+        done && done();
+      });
+    },
+    openDialog(type, row) {
+      this.type = type;
+      if (type === "edit") {
+        this.$set(row, "editLoading", true);
+        this.title = "缂栬緫鐢熷懡鍛ㄦ湡娴佺▼鍥�";
+        this.dialogWidth = "95%";
+      } else if (type === "detail") {
+        this.$set(row, "detailLoading", true);
+        this.title = "棰勮鐢熷懡鍛ㄦ湡娴佺▼鍥�";
+        this.dialogWidth = "50%";
+      }
+      if (type !== "add") {
+        API.detail({ id: row.id }).then((res) => {
+          this.$set(row, "detailLoading", false);
+          this.$set(row, "editLoading", false);
+          this.rowData = row;
+          this.nodesEdgesData = {nodes: res.nodes, edges: res.edges}
+        });
+      } else {
+        this.title = "鏂板鐢熷懡鍛ㄦ湡娴佺▼鍥�";
+        this.dialogWidth = "95%";
+        this.visible = true;
+      }
+    },
+    async submit() {
+      const newRowData = await this.$refs.vueFlowchartEditor.getNewRowData();
+      console.log(newRowData, "newRowDatanewRowData");
+      if (!newRowData) {
+        return;
+      }
+      const flowData = this.$refs.vueFlowchartEditor.getFlowData();
+      if (Array.isArray(flowData.nodes)) {
+        flowData.nodes = flowData.nodes.map((item) => {
+          item.name = item.id;
+          return item;
+        });
+      }
+      if (Array.isArray(flowData.edges)) {
+        flowData.edges = flowData.edges.map((item) => {
+          item.name = item.label;
+          return item;
+        });
+      }
+
+      let params = {
+        ...flowData,
+        ...newRowData,
+      };
+      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;
+      },
+    },
+  },
+};
 </script>
 
-<style lang="scss">
-#basic {
-  height: 761px;
-  border-radius: 10px;
+<style lang="scss" scoped>
+/deep/ .el-dialog__body {
+  padding: 0 20px;
+}
+.cycle_flow {
+  height: 600px !important;
+  display: flex;
+  flex-direction: column;
+  margin: 0;
+  padding: 0;
 }
 </style>

--
Gitblit v1.9.3