From ca294bbef3a47d80b6f3f44f85ac587a8ee430d2 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期四, 13 七月 2023 10:15:33 +0800 Subject: [PATCH] 提交代码 --- Source/UBCS-WEB/dist/src/views/system/topmenu.vue | 332 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 332 insertions(+), 0 deletions(-) diff --git a/Source/UBCS-WEB/dist/src/views/system/topmenu.vue b/Source/UBCS-WEB/dist/src/views/system/topmenu.vue new file mode 100644 index 0000000..fdb6388 --- /dev/null +++ b/Source/UBCS-WEB/dist/src/views/system/topmenu.vue @@ -0,0 +1,332 @@ +<template> + <basic-container> + <avue-crud :option="option" + :table-loading="loading" + :data="data" + :page.sync="page" + :permission="permissionList" + :before-open="beforeOpen" + v-model="form" + ref="crud" + @row-update="rowUpdate" + @row-save="rowSave" + @row-del="rowDel" + @search-change="searchChange" + @search-reset="searchReset" + @selection-change="selectionChange" + @current-change="currentChange" + @size-change="sizeChange" + @refresh-change="refreshChange" + @on-load="onLoad"> + <template slot="menuLeft"> + <el-button type="danger" + size="small" + icon="el-icon-delete" + plain + v-if="permission.topmenu_delete" + @click="handleDelete">鍒� 闄� + </el-button> + <el-button size="small" + icon="el-icon-delete" + @click="handleMenuSetting" + v-if="permission.topmenu_setting" + plain>鑿滃崟閰嶇疆 + </el-button> + </template> + <template slot-scope="{row}" slot="source"> + <div style="text-align:center"> + <i :class="row.source"></i> + </div> + </template> + <template slot="sort" slot-scope="{row}" > + <el-input-number v-model="row.sort" @change="sortChange(row)" :min="1" :max="100"></el-input-number> + </template> + </avue-crud> + <el-dialog title="涓嬬骇鑿滃崟閰嶇疆" + append-to-body + :visible.sync="box" + width="345px"> + + <el-tree :data="menuGrantList" + show-checkbox + node-key="id" + ref="treeMenu" + :default-checked-keys="menuTreeObj" + :props="props"> + </el-tree> + + <span slot="footer" + class="dialog-footer"> + <el-button @click="box = false">鍙� 娑�</el-button> + <el-button type="primary" + @click="submit">纭� 瀹�</el-button> + </span> + </el-dialog> + </basic-container> +</template> + +<script> + import {getList, getDetail, add, update, remove, grant, grantTree, getTopTree} from "@/api/system/topmenu"; + import {mapGetters} from "vuex"; + import iconList from "@/config/iconList"; + + export default { + data() { + return { + form: {}, + box: false, + query: {}, + loading: true, + props: { + label: "title", + value: "key" + }, + page: { + pageSize: 10, + currentPage: 1, + total: 0 + }, + selectionList: [], + menuGrantList: [], + menuTreeObj: [], + option: { + height: 'auto', + calcHeight: 30, + tip: false, + searchShow: true, + searchMenuSpan: 6, + border: true, + index: true, + viewBtn: true, + selection: true, + dialogWidth: 900, + dialogClickModal: false, + column: [ + { + label: "鑿滃崟鍚�", + prop: "name", + search: true, + rules: [{ + required: true, + message: "璇疯緭鍏ヨ彍鍗曞悕", + trigger: "blur" + }] + }, + { + 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: "sort", + type: "number", + slot: true, + rules: [{ + required: true, + message: "璇疯緭鍏ヨ彍鍗曟帓搴�", + trigger: "blur" + }] + }, + ] + }, + data: [] + }; + }, + computed: { + ...mapGetters(["permission"]), + permissionList() { + return { + addBtn: this.vaildData(this.permission.topmenu_add, false), + viewBtn: this.vaildData(this.permission.topmenu_view, false), + delBtn: this.vaildData(this.permission.topmenu_delete, false), + editBtn: this.vaildData(this.permission.topmenu_edit, false) + }; + }, + ids() { + let ids = []; + this.selectionList.forEach(ele => { + ids.push(ele.id); + }); + return ids.join(","); + }, + idsArray() { + let ids = []; + this.selectionList.forEach(ele => { + ids.push(ele.id); + }); + return ids; + } + }, + methods: { + submit() { + const menuList = this.$refs.treeMenu.getCheckedKeys(); + grant(this.idsArray, menuList).then(() => { + this.box = false; + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + this.onLoad(this.page); + }); + }, + rowSave(row, done, loading) { + add(row).then(() => { + this.onLoad(this.page); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + done(); + }, error => { + window.console.log(error); + loading(); + }); + }, + rowUpdate(row, index, done, loading) { + update(row).then(() => { + this.onLoad(this.page); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + done(); + }, error => { + window.console.log(error); + loading(); + }); + }, + rowDel(row) { + this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + return remove(row.id); + }) + .then(() => { + this.onLoad(this.page); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + }); + }, + handleDelete() { + if (this.selectionList.length === 0) { + this.$message.warning("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�"); + return; + } + this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + return remove(this.ids); + }) + .then(() => { + this.onLoad(this.page); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + this.$refs.crud.toggleSelection(); + }); + }, + handleMenuSetting() { + if (this.selectionList.length !== 1) { + this.$message.warning("鍙兘閫夋嫨涓�鏉℃暟鎹�"); + return; + } + this.menuTreeObj = []; + grantTree() + .then(res => { + this.menuGrantList = res.data.data.menu; + getTopTree(this.ids).then(res => { + this.menuTreeObj = res.data.data.menu; + this.box = true; + }); + }); + }, + beforeOpen(done, type) { + if (["edit", "view"].includes(type)) { + getDetail(this.form.id).then(res => { + this.form = res.data.data; + }); + } + done(); + }, + sortChange(row) { + update(row).then(() => { + this.onLoad(this.page); + }, error => { + window.console.log(error); + }); + }, + searchReset() { + this.query = {}; + this.onLoad(this.page); + }, + searchChange(params, done) { + this.query = params; + this.page.currentPage = 1; + this.onLoad(this.page, params); + done(); + }, + selectionChange(list) { + this.selectionList = list; + }, + selectionClear() { + this.selectionList = []; + this.$refs.crud.toggleSelection(); + }, + 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; + getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => { + const data = res.data.data; + this.page.total = data.total; + this.data = data.records; + this.loading = false; + this.selectionClear(); + }); + } + } + }; +</script> + +<style> + .none-border { + border: 0; + background-color: transparent !important; + } +</style> -- Gitblit v1.9.3