From ae6d20ec4a30b7e796feb05958bcfc80e55f247b Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期四, 20 七月 2023 15:21:45 +0800
Subject: [PATCH] 整合代码部署

---
 Source/UBCS-WEB/dist/src/views/system/menu.vue |  422 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 422 insertions(+), 0 deletions(-)

diff --git a/Source/UBCS-WEB/dist/src/views/system/menu.vue b/Source/UBCS-WEB/dist/src/views/system/menu.vue
new file mode 100644
index 0000000..8d70338
--- /dev/null
+++ b/Source/UBCS-WEB/dist/src/views/system/menu.vue
@@ -0,0 +1,422 @@
+<template>
+  <basic-container>
+    <avue-crud :option="option"
+               :table-loading="loading"
+               :data="data"
+               ref="crud"
+               v-model="form"
+               :permission="permissionList"
+               :before-open="beforeOpen"
+               :before-close="beforeClose"
+               @row-del="rowDel"
+               @row-update="rowUpdate"
+               @row-save="rowSave"
+               @search-change="searchChange"
+               @search-reset="searchReset"
+               @selection-change="selectionChange"
+               @current-change="currentChange"
+               @size-change="sizeChange"
+               @refresh-change="refreshChange"
+               @on-load="onLoad"
+               @tree-load="treeLoad">
+      <template slot="menuLeft">
+        <el-button type="danger"
+                   size="small"
+                   icon="el-icon-delete"
+                   v-if="permission.menu_delete"
+                   plain
+                   @click="handleDelete">鍒� 闄�
+        </el-button>
+      </template>
+      <template slot-scope="scope" slot="menu">
+        <el-button
+          type="text"
+          icon="el-icon-circle-plus-outline"
+          size="small"
+          @click.stop="handleAdd(scope.row,scope.index)"
+          v-if="userInfo.role_name.includes('admin') && scope.row.category === 1"
+        >鏂板瀛愰」
+        </el-button>
+      </template>
+      <template slot-scope="{row}"
+                slot="source">
+        <div style="text-align:center">
+          <i :class="row.source"/>
+        </div>
+      </template>
+    </avue-crud>
+  </basic-container>
+</template>
+
+<script>
+  import {getLazyList, remove, update, add, getMenu} from "@/api/system/menu";
+  import {mapGetters} from "vuex";
+  import iconList from "@/config/iconList";
+  import func from "@/util/func";
+  import {getMenuTree} from "@/api/system/menu";
+
+  export default {
+    data() {
+      return {
+        form: {},
+        query: {},
+        loading: true,
+        selectionList: [],
+        parentId: 0,
+        page: {
+          pageSize: 10,
+          currentPage: 1,
+          total: 0,
+        },
+        option: {
+          lazy: true,
+          tip: false,
+          simplePage: true,
+          searchShow: true,
+          searchMenuSpan: 6,
+          dialogWidth: "60%",
+          tree: true,
+          border: true,
+          index: true,
+          selection: true,
+          viewBtn: true,
+          menuWidth: 300,
+          dialogClickModal: false,
+          column: [
+            {
+              label: "鑿滃崟鍚嶇О",
+              prop: "name",
+              search: true,
+              rules: [
+                {
+                  required: true,
+                  message: "璇疯緭鍏ヨ彍鍗曞悕绉�",
+                  trigger: "blur"
+                }
+              ]
+            },
+            {
+              label: "璺敱鍦板潃",
+              prop: "path",
+              rules: [
+                {
+                  required: true,
+                  message: "璇疯緭鍏ヨ矾鐢卞湴鍧�",
+                  trigger: "blur"
+                }
+              ]
+            },
+            {
+              label: "涓婄骇鑿滃崟",
+              prop: "parentId",
+              type: "tree",
+              dicData: [],
+              hide: true,
+              addDisabled: false,
+              props: {
+                label: "title"
+              },
+              rules: [
+                {
+                  required: false,
+                  message: "璇烽�夋嫨涓婄骇鑿滃崟",
+                  trigger: "click"
+                }
+              ]
+            },
+            {
+              label: "鑿滃崟鍥炬爣",
+              prop: "source",
+              type: "icon",
+              slot: true,
+              iconList: iconList,
+              rules: [
+                {
+                  required: true,
+                  message: "璇疯緭鍏ヨ彍鍗曞浘鏍�",
+                  trigger: "click"
+                }
+              ]
+            },
+            {
+              label: "鑿滃崟缂栧彿",
+              prop: "code",
+              search: true,
+              rules: [
+                {
+                  required: true,
+                  message: "璇疯緭鍏ヨ彍鍗曠紪鍙�",
+                  trigger: "blur"
+                }
+              ]
+            },
+            {
+              label: "鑿滃崟绫诲瀷",
+              prop: "category",
+              type: "radio",
+              dicData: [
+                {
+                  label: "鑿滃崟",
+                  value: 1
+                },
+                {
+                  label: "鎸夐挳",
+                  value: 2
+                }
+              ],
+              hide: true,
+              rules: [
+                {
+                  required: true,
+                  message: "璇烽�夋嫨鑿滃崟绫诲瀷",
+                  trigger: "blur"
+                }
+              ]
+            },
+            {
+              label: "鑿滃崟鍒悕",
+              prop: "alias",
+              search: true,
+              rules: [
+                {
+                  required: true,
+                  message: "璇疯緭鍏ヨ彍鍗曞埆鍚�",
+                  trigger: "blur"
+                }
+              ]
+            },
+            {
+              label: "鏂扮獥鍙�",
+              prop: "isOpen",
+              type: "radio",
+              disabled: false,
+              display: false,
+              dicData: [
+                {
+                  label: "鍚�",
+                  value: 1
+                },
+                {
+                  label: "鏄�",
+                  value: 2
+                }
+              ],
+              value: 1,
+              rules: [
+                {
+                  required: true,
+                  message: "璇烽�夋嫨鏂扮獥鍙f墦寮�",
+                  trigger: "blur"
+                }
+              ]
+            },
+            {
+              label: "鑿滃崟鎺掑簭",
+              prop: "sort",
+              type: "number",
+              rules: [
+                {
+                  required: true,
+                  message: "璇疯緭鍏ヨ彍鍗曟帓搴�",
+                  trigger: "blur"
+                }
+              ]
+            },
+            {
+              label: "鑿滃崟澶囨敞",
+              prop: "remark",
+              type: "textarea",
+              span: 24,
+              minRows: 2,
+              hide: true
+            }
+          ]
+        },
+        data: []
+      };
+    },
+    watch: {
+      'form.category'() {
+        const category = func.toInt(this.form.category);
+        this.$refs.crud.option.column.filter(item => {
+          if (item.prop === "path") {
+            item.rules[0].required = category === 1;
+          }
+          if (item.prop === 'isOpen') {
+            item.disabled = category === 2;
+          }
+        });
+      },
+    },
+    computed: {
+      ...mapGetters(["userInfo", "permission"]),
+      permissionList() {
+        return {
+          addBtn: this.vaildData(this.permission.menu_add, false),
+          viewBtn: this.vaildData(this.permission.menu_view, false),
+          delBtn: this.vaildData(this.permission.menu_delete, false),
+          editBtn: this.vaildData(this.permission.menu_edit, false)
+        };
+      },
+      ids() {
+        let ids = [];
+        this.selectionList.forEach(ele => {
+          ids.push(ele.id);
+        });
+        return ids.join(",");
+      }
+    },
+    methods: {
+      initData() {
+        getMenuTree().then(res => {
+          const column = this.findObject(this.option.column, "parentId");
+          column.dicData = res.data.data;
+        });
+      },
+      handleAdd(row) {
+        this.parentId = row.id;
+        const column = this.findObject(this.option.column, "parentId");
+        column.value = row.id;
+        column.addDisabled = true;
+        this.$refs.crud.rowAdd();
+      },
+      rowSave(row, done, loading) {
+        add(row).then((res) => {
+          // 鑾峰彇鏂板鏁版嵁鐨勭浉鍏冲瓧娈�
+          const data = res.data.data;
+          row.id = data.id;
+          this.$message({
+            type: "success",
+            message: "鎿嶄綔鎴愬姛!"
+          });
+          // 鏁版嵁鍥炶皟杩涜鍒锋柊
+          done(row);
+        }, error => {
+          window.console.log(error);
+          loading();
+        });
+      },
+      rowUpdate(row, index, done, loading) {
+        update(row).then(() => {
+          this.$message({
+            type: "success",
+            message: "鎿嶄綔鎴愬姛!"
+          });
+          // 鏁版嵁鍥炶皟杩涜鍒锋柊
+          done(row);
+        }, error => {
+          window.console.log(error);
+          loading();
+        });
+      },
+      rowDel(row, index, done) {
+        this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", {
+          confirmButtonText: "纭畾",
+          cancelButtonText: "鍙栨秷",
+          type: "warning"
+        })
+          .then(() => {
+            return remove(row.id);
+          })
+          .then(() => {
+            this.$message({
+              type: "success",
+              message: "鎿嶄綔鎴愬姛!"
+            });
+            // 鏁版嵁鍥炶皟杩涜鍒锋柊
+            done(row);
+          });
+      },
+      handleDelete() {
+        if (this.selectionList.length === 0) {
+          this.$message.warning("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�");
+          return;
+        }
+        this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", {
+          confirmButtonText: "纭畾",
+          cancelButtonText: "鍙栨秷",
+          type: "warning"
+        })
+          .then(() => {
+            return remove(this.ids);
+          })
+          .then(() => {
+            // 鍒锋柊琛ㄦ牸鏁版嵁骞堕噸杞�
+            this.data = [];
+            this.parentId = 0;
+            this.$refs.crud.refreshTable();
+            this.$refs.crud.toggleSelection();
+            // 琛ㄦ牸鏁版嵁閲嶈浇
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "鎿嶄綔鎴愬姛!"
+            });
+          });
+      },
+      searchReset() {
+        this.query = {};
+        this.parentId = 0;
+        this.onLoad(this.page);
+      },
+      searchChange(params, done) {
+        this.query = params;
+        this.parentId = '';
+        this.page.currentPage = 1;
+        this.onLoad(this.page, params);
+        done();
+      },
+      selectionChange(list) {
+        this.selectionList = list;
+      },
+      selectionClear() {
+        this.selectionList = [];
+        this.$refs.crud.toggleSelection();
+      },
+      beforeOpen(done, type) {
+        if (["add", "edit"].includes(type)) {
+          this.initData();
+        }
+        if (["edit", "view"].includes(type)) {
+          getMenu(this.form.id).then(res => {
+            this.form = res.data.data;
+          });
+        }
+        done();
+      },
+      beforeClose(done) {
+        this.parentId = "";
+        const column = this.findObject(this.option.column, "parentId");
+        column.value = "";
+        column.addDisabled = false;
+        done();
+      },
+      currentChange(currentPage) {
+        this.page.currentPage = currentPage;
+      },
+      sizeChange(pageSize) {
+        this.page.pageSize = pageSize;
+      },
+      refreshChange() {
+        this.onLoad(this.page, this.query);
+      },
+      onLoad(page, params = {}) {
+        this.loading = true;
+        getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
+          this.data = res.data.data;
+          this.loading = false;
+          this.selectionClear();
+        });
+      },
+      treeLoad(tree, treeNode, resolve) {
+        const parentId = tree.id;
+        getLazyList(parentId).then(res => {
+          resolve(res.data.data);
+        });
+      }
+    }
+  };
+</script>
+
+<style>
+</style>

--
Gitblit v1.9.3