¶Ô±ÈÐÂÎļþ |
| | |
| | | <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-scope="{row}" slot="menu"> |
| | | <el-button type="text" |
| | | icon="el-icon-setting" |
| | | size="small" |
| | | v-if="permission.data_scope_setting" |
| | | plain |
| | | style="border: 0;background-color: transparent !important;" |
| | | @click.stop="handleDataScope(row)">æéé
ç½® |
| | | </el-button> |
| | | </template> |
| | | <template slot-scope="{row}" slot="source"> |
| | | <div style="text-align:center"> |
| | | <i :class="row.source"/> |
| | | </div> |
| | | </template> |
| | | </avue-crud> |
| | | <el-drawer :title="`[${scopeMenuName}] æ°æ®æéé
ç½®`" :visible.sync="drawerVisible" :direction="direction" |
| | | append-to-body |
| | | :before-close="handleDrawerClose" size="1000px"> |
| | | <basic-container> |
| | | <avue-crud :option="optionScope" |
| | | :data="dataScope" |
| | | :page="pageScope" |
| | | v-model="formScope" |
| | | :table-loading="scopeLoading" |
| | | ref="crudScope" |
| | | @row-del="rowDelScope" |
| | | @row-update="rowUpdateScope" |
| | | @row-save="rowSaveScope" |
| | | :before-open="beforeOpenScope" |
| | | @search-change="searchChangeScope" |
| | | @search-reset="searchResetScope" |
| | | @selection-change="selectionChangeScope" |
| | | @current-change="currentChangeScope" |
| | | @size-change="sizeChangeScope" |
| | | @on-load="onLoadScope"> |
| | | <template slot="menuLeft"> |
| | | <el-button type="danger" |
| | | size="small" |
| | | icon="el-icon-delete" |
| | | plain |
| | | @click="handleDeleteScope">å é¤ |
| | | </el-button> |
| | | </template> |
| | | <template slot-scope="{row}" |
| | | slot="scopeType"> |
| | | <el-tag>{{row.scopeTypeName}}</el-tag> |
| | | </template> |
| | | </avue-crud> |
| | | </basic-container> |
| | | </el-drawer> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | add, |
| | | remove, |
| | | update, |
| | | getLazyMenuList, |
| | | getMenu |
| | | } from "@/api/system/menu"; |
| | | import { |
| | | addDataScope, |
| | | removeDataScope, |
| | | updateDataScope, |
| | | getListDataScope, |
| | | getMenuDataScope |
| | | } from "@/api/system/scope"; |
| | | import {mapGetters} from "vuex"; |
| | | import iconList from "@/config/iconList"; |
| | | import func from "@/util/func"; |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | | form: {}, |
| | | selectionList: [], |
| | | query: {}, |
| | | loading: true, |
| | | parentId: 0, |
| | | page: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0 |
| | | }, |
| | | drawerVisible: false, |
| | | direction: 'rtl', |
| | | scopeMenuId: 0, |
| | | scopeMenuCode: '', |
| | | scopeMenuName: "èå", |
| | | scopeLoading: false, |
| | | menu: true, |
| | | watchMode: true, |
| | | option: { |
| | | lazy: true, |
| | | tip: false, |
| | | simplePage: true, |
| | | searchShow: true, |
| | | searchMenuSpan: 6, |
| | | dialogWidth: "60%", |
| | | tree: true, |
| | | border: true, |
| | | index: true, |
| | | selection: true, |
| | | viewBtn: false, |
| | | editBtn: false, |
| | | addBtn: false, |
| | | delBtn: false, |
| | | menuWidth: 150, |
| | | 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", |
| | | dicUrl: "/api/ubcs-system/menu/tree", |
| | | hide: true, |
| | | props: { |
| | | label: "title" |
| | | }, |
| | | rules: [ |
| | | { |
| | | required: false, |
| | | message: "è¯·éæ©ä¸çº§èå", |
| | | trigger: "click" |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | label: "èå徿 ", |
| | | prop: "source", |
| | | type: "icon", |
| | | slot: true, |
| | | width: 80, |
| | | 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", |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: "请è¾å
¥èåå«å", |
| | | trigger: "blur" |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | label: "æé®åè½", |
| | | prop: "action", |
| | | type: "radio", |
| | | dicData: [ |
| | | { |
| | | label: "å·¥å
·æ ", |
| | | value: 0 |
| | | }, |
| | | { |
| | | label: "æä½æ ", |
| | | value: 1 |
| | | }, |
| | | { |
| | | label: "å·¥å
·æä½æ ", |
| | | value: 2 |
| | | } |
| | | ], |
| | | hide: true, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: "è¯·éæ©æé®åè½", |
| | | trigger: "blur" |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | label: "èåæåº", |
| | | prop: "sort", |
| | | type: "number", |
| | | width: 80, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: "请è¾å
¥èåæåº", |
| | | trigger: "blur" |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | label: "æ°çªå£", |
| | | prop: "isOpen", |
| | | type: "radio", |
| | | dicData: [ |
| | | { |
| | | label: "å¦", |
| | | value: 0 |
| | | }, |
| | | { |
| | | label: "æ¯", |
| | | value: 1 |
| | | }, |
| | | ], |
| | | hide: true |
| | | }, |
| | | { |
| | | label: "èå夿³¨", |
| | | prop: "remark", |
| | | type: "textarea", |
| | | span: 24, |
| | | minRows: 6, |
| | | hide: true |
| | | } |
| | | ] |
| | | }, |
| | | data: [], |
| | | formScope: {}, |
| | | selectionListScope: [], |
| | | pageScope: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0 |
| | | }, |
| | | optionScope: { |
| | | tip: false, |
| | | searchShow: true, |
| | | searchMenuSpan: 6, |
| | | border: true, |
| | | index: true, |
| | | viewBtn: true, |
| | | selection: true, |
| | | menuWidth: 200, |
| | | dialogWidth: 900, |
| | | dialogClickModal: false, |
| | | column: [ |
| | | { |
| | | label: "æéåç§°", |
| | | prop: "scopeName", |
| | | search: true, |
| | | value: "", |
| | | rules: [{ |
| | | required: true, |
| | | message: "请è¾å
¥æ°æ®æéåç§°", |
| | | trigger: "blur" |
| | | }] |
| | | }, |
| | | { |
| | | label: "æéç¼å·", |
| | | prop: "resourceCode", |
| | | search: true, |
| | | width: 100, |
| | | rules: [{ |
| | | required: true, |
| | | message: "请è¾å
¥æ°æ®æéç¼å·", |
| | | trigger: "blur" |
| | | }] |
| | | }, |
| | | { |
| | | label: "æéåæ®µ", |
| | | prop: "scopeColumn", |
| | | width: 130, |
| | | rules: [{ |
| | | required: true, |
| | | message: "请è¾å
¥æ°æ®æéç¼å·", |
| | | trigger: "blur" |
| | | }] |
| | | }, |
| | | { |
| | | label: "è§åç±»å", |
| | | type: "select", |
| | | dicUrl: "/api/ubcs-system/dict/dictionary?code=data_scope_type", |
| | | props: { |
| | | label: "dictValue", |
| | | value: "dictKey" |
| | | }, |
| | | dataType: "number", |
| | | slot: true, |
| | | width: 140, |
| | | prop: "scopeType", |
| | | rules: [{ |
| | | required: true, |
| | | message: "请è¾å
¥éç¥ç±»å", |
| | | trigger: "blur" |
| | | }] |
| | | }, |
| | | { |
| | | label: "å¯è§å段", |
| | | prop: "scopeField", |
| | | span: 24, |
| | | hide: true, |
| | | value: "*", |
| | | rules: [{ |
| | | required: true, |
| | | message: "请è¾å
¥æ°æ®æéå¯è§çåæ®µ", |
| | | trigger: "blur" |
| | | }], |
| | | }, |
| | | { |
| | | label: "æéç±»å", |
| | | prop: "scopeClass", |
| | | span: 24, |
| | | hide: true, |
| | | rules: [{ |
| | | required: true, |
| | | message: "请è¾å
¥MybatisMapperå¯¹åºæ¹æ³ç宿´ç±»åè·¯å¾", |
| | | trigger: "blur" |
| | | }], |
| | | }, |
| | | { |
| | | label: "è§åå¼", |
| | | prop: "scopeValue", |
| | | span: 24, |
| | | minRows: 5, |
| | | type: "textarea", |
| | | display: true, |
| | | hide: true, |
| | | }, |
| | | { |
| | | label: "夿³¨", |
| | | prop: "remark", |
| | | span: 24, |
| | | hide: true, |
| | | }, |
| | | ] |
| | | }, |
| | | dataScope: [] |
| | | }; |
| | | }, |
| | | watch: { |
| | | 'formScope.scopeType'() { |
| | | this.initScope(); |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters(["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(","); |
| | | }, |
| | | scopeIds() { |
| | | let ids = []; |
| | | this.selectionListScope.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(","); |
| | | } |
| | | }, |
| | | methods: { |
| | | initScope() { |
| | | const scopeType = func.toInt(this.formScope.scopeType); |
| | | const watchMode = this.watchMode; |
| | | let column = "-", name = "ææ "; |
| | | if (scopeType === 1) { |
| | | column = "-"; |
| | | name = "å
¨é¨å¯è§"; |
| | | } else if (scopeType === 2) { |
| | | column = "create_user"; |
| | | name = "æ¬äººå¯è§"; |
| | | } else if (scopeType === 3) { |
| | | column = "create_dept"; |
| | | name = "æå¨æºæå¯è§"; |
| | | } else if (scopeType === 4) { |
| | | column = "create_dept"; |
| | | name = "æå¨æºæå¯è§åå级å¯è§"; |
| | | } else if (scopeType === 5) { |
| | | column = ""; |
| | | name = "èªå®ä¹"; |
| | | } |
| | | this.$refs.crudScope.option.column.filter(item => { |
| | | if (watchMode) { |
| | | if (item.prop === "scopeName") { |
| | | this.formScope.scopeName = `${this.scopeMenuName} [${name}]`; |
| | | } |
| | | if (item.prop === "resourceCode") { |
| | | this.formScope.resourceCode = this.scopeMenuCode; |
| | | } |
| | | if (item.prop === "scopeColumn") { |
| | | this.formScope.scopeColumn = column; |
| | | } |
| | | } |
| | | if (item.prop === "scopeValue") { |
| | | item.display = scopeType === 5; |
| | | } |
| | | }); |
| | | }, |
| | | // èåç®¡çæ¨¡å |
| | | 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: "æä½æå!" |
| | | }); |
| | | }); |
| | | }, |
| | | 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(); |
| | | }, |
| | | 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(); |
| | | }); |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (["edit", "view"].includes(type)) { |
| | | getMenu(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | }); |
| | | } |
| | | done(); |
| | | }, |
| | | beforeClose(done) { |
| | | this.formScope = {}; |
| | | 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; |
| | | getLazyMenuList(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; |
| | | getLazyMenuList(parentId).then(res => { |
| | | resolve(res.data.data); |
| | | }); |
| | | }, |
| | | // æ°æ®æé模å |
| | | handleDataScope(row) { |
| | | this.drawerVisible = true; |
| | | this.scopeMenuId = row.id; |
| | | this.scopeMenuCode = row.code; |
| | | this.scopeMenuName = row.name; |
| | | this.onLoadScope(this.pageScope) |
| | | }, |
| | | handleDrawerClose(hide) { |
| | | hide(); |
| | | }, |
| | | rowSaveScope(row, done, loading) { |
| | | row = { |
| | | ...row, |
| | | menuId: this.scopeMenuId, |
| | | }; |
| | | addDataScope(row).then(() => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "æä½æå!" |
| | | }); |
| | | done(); |
| | | }, error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | }); |
| | | }, |
| | | rowUpdateScope(row, index, done, loading) { |
| | | row = { |
| | | ...row, |
| | | menuId: this.scopeMenuId, |
| | | }; |
| | | updateDataScope(row).then(() => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "æä½æå!" |
| | | }); |
| | | done(); |
| | | }, error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | }); |
| | | }, |
| | | rowDelScope(row) { |
| | | this.$confirm("ç¡®å®å°éæ©æ°æ®å é¤?", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }) |
| | | .then(() => { |
| | | return removeDataScope(row.id); |
| | | }) |
| | | .then(() => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "æä½æå!" |
| | | }); |
| | | }); |
| | | }, |
| | | handleDeleteScope() { |
| | | if (this.selectionListScope.length === 0) { |
| | | this.$message.warning("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | return; |
| | | } |
| | | this.$confirm("ç¡®å®å°éæ©æ°æ®å é¤?", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }) |
| | | .then(() => { |
| | | return removeDataScope(this.scopeIds); |
| | | }) |
| | | .then(() => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "æä½æå!" |
| | | }); |
| | | this.$refs.crudScope.toggleSelection(); |
| | | }); |
| | | }, |
| | | beforeOpenScope(done, type) { |
| | | if (["add"].includes(type)) { |
| | | this.watchMode = true; |
| | | this.initScope(); |
| | | } |
| | | if (["edit", "view"].includes(type)) { |
| | | this.watchMode = false; |
| | | getMenuDataScope(this.formScope.id).then(res => { |
| | | this.formScope = res.data.data; |
| | | }); |
| | | } |
| | | done(); |
| | | }, |
| | | searchResetScope() { |
| | | this.onLoadScope(this.pageScope); |
| | | }, |
| | | searchChangeScope(params, done) { |
| | | this.onLoadScope(this.pageScope, params); |
| | | done(); |
| | | }, |
| | | selectionChangeScope(list) { |
| | | this.selectionListScope = list; |
| | | }, |
| | | currentChangeScope(currentPage) { |
| | | this.pageScope.currentPage = currentPage; |
| | | }, |
| | | sizeChangeScope(pageSize) { |
| | | this.pageScope.pageSize = pageSize; |
| | | }, |
| | | onLoadScope(page, params = {}) { |
| | | this.scopeLoading = true; |
| | | const values = { |
| | | ...params, |
| | | menuId: this.scopeMenuId, |
| | | } |
| | | getListDataScope(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(res => { |
| | | const data = res.data.data; |
| | | this.pageScope.total = data.total; |
| | | this.dataScope = data.records; |
| | | this.selectionListScope = []; |
| | | this.scopeLoading = false; |
| | | }); |
| | | }, |
| | | } |
| | | }; |
| | | </script> |
| | | |