From 1ef38f7b420900816f27bdea509017cab11a96d2 Mon Sep 17 00:00:00 2001 From: qushaowei <qushaowei@163.com> Date: 星期日, 29 十月 2023 23:34:48 +0800 Subject: [PATCH] 主页面 --- src/views/system/modules/UserRoleModalNew.vue | 245 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 245 insertions(+), 0 deletions(-) diff --git a/src/views/system/modules/UserRoleModalNew.vue b/src/views/system/modules/UserRoleModalNew.vue new file mode 100644 index 0000000..3ecb6ef --- /dev/null +++ b/src/views/system/modules/UserRoleModalNew.vue @@ -0,0 +1,245 @@ +<template> + <a-modal + :title="title" + :width="650" + :visible="visible" + :maskClosable="false" + :confirmLoading="confirmLoading" + @ok="handleOk" + cancelText="鍏抽棴" + @cancel="handleCancel" + > + <a-form> + <a-form-item label='鎵�鎷ユ湁鐨勬潈闄�'> + <a-tree + checkable + @check="onCheck" + :checkedKeys="checkedKeys" + :treeData="treeData" + @expand="onExpand" + @select="onTreeNodeSelect" + :selectedKeys="selectedKeys" + :expandedKeys="expandedKeysss" + :checkStrictly="checkStrictly" + > + <span + slot="hasDatarule" + slot-scope="{slotTitle,ruleFlag}" + > + {{ slotTitle }}<a-icon + v-if="ruleFlag" + type="align-left" + style="margin-left:5px;color: red;" + ></a-icon> + </span> + </a-tree> + </a-form-item> + </a-form> + + <div class="drawer-bootom-button"> + <a-dropdown + style="float: left" + :trigger="['click']" + placement="topCenter" + > + <a-menu slot="overlay"> + <a-menu-item + key="1" + @click="switchCheckStrictly(1)" + >鐖跺瓙鍏宠仈</a-menu-item> + <a-menu-item + key="2" + @click="switchCheckStrictly(2)" + >鍙栨秷鍏宠仈</a-menu-item> + <a-menu-item + key="3" + @click="checkALL" + >鍏ㄩ儴鍕鹃��</a-menu-item> + <a-menu-item + key="4" + @click="cancelCheckALL" + >鍙栨秷鍏ㄩ��</a-menu-item> + <a-menu-item + key="5" + @click="expandAll" + >灞曞紑鎵�鏈�</a-menu-item> + <a-menu-item + key="6" + @click="closeAll" + >鍚堝苟鎵�鏈�</a-menu-item> + </a-menu> + <a-button> + 鏍戞搷浣� <a-icon type="up" /> + </a-button> + </a-dropdown> + <a-popconfirm + title="纭畾鏀惧純缂栬緫锛�" + @confirm="close" + okText="纭畾" + cancelText="鍙栨秷" + > + <a-button style="margin-right: .8rem">鍙栨秷</a-button> + </a-popconfirm> + </div> + + <template slot="footer"> + <a-button + @click="handleSubmit(false)" + type="primary" + :loading="loading" + ghost + style="margin-right: 0.8rem" + >浠呬繚瀛�</a-button> + <a-button + @click="handleSubmit(true)" + type="primary" + :loading="loading" + >淇濆瓨骞跺叧闂�</a-button> + </template> + <role-datarule-modal ref="datarule"></role-datarule-modal> + </a-modal> + +</template> + +<script> +import { queryTreeListForRole, queryRolePermission, saveRolePermission } from '@/api/api' +import RoleDataruleModal from './RoleDataruleModal.vue' + +export default { + name: "RoleModal", + components: { + RoleDataruleModal + }, + data() { + return { + roleId: "", + treeData: [], + defaultCheckedKeys: [], + checkedKeys: [], + expandedKeysss: [], + allTreeKeys: [], + autoExpandParent: true, + checkStrictly: true, + title: "瑙掕壊鏉冮檺閰嶇疆", + visible: false, + loading: false, + selectedKeys: [] + } + }, + methods: { + onTreeNodeSelect(id) { + if (id && id.length > 0) { + this.selectedKeys = id + } + this.$refs.datarule.show(this.selectedKeys[0], this.roleId) + }, + onCheck(o) { + if (this.checkStrictly) { + this.checkedKeys = o.checked; + } else { + this.checkedKeys = o + } + }, + show(roleId) { + this.roleId = roleId + this.visible = true; + }, + close() { + this.reset() + this.$emit('close'); + this.visible = false; + }, + onExpand(expandedKeys) { + this.expandedKeysss = expandedKeys; + this.autoExpandParent = false + }, + reset() { + this.expandedKeysss = [] + this.checkedKeys = [] + this.defaultCheckedKeys = [] + this.loading = false + }, + expandAll() { + this.expandedKeysss = this.allTreeKeys + }, + closeAll() { + this.expandedKeysss = [] + }, + checkALL() { + this.checkedKeys = this.allTreeKeys + }, + cancelCheckALL() { + //this.checkedKeys = this.defaultCheckedKeys + this.checkedKeys = [] + }, + switchCheckStrictly(v) { + if (v == 1) { + this.checkStrictly = false + } else if (v == 2) { + this.checkStrictly = true + } + }, + handleCancel() { + this.close() + }, + handleSubmit(exit) { + let that = this; + let params = { + roleId: that.roleId, + permissionIds: that.checkedKeys.join(","), + lastpermissionIds: that.defaultCheckedKeys.join(","), + }; + that.loading = true; + console.log("璇锋眰鍙傛暟锛�", params); + saveRolePermission(params).then((res) => { + if (res.success) { + that.$message.success(res.message); + that.loading = false; + if (exit) { + that.close() + } + } else { + that.$message.error(res.message); + that.loading = false; + if (exit) { + that.close() + } + } + this.loadData(); + }) + }, + loadData() { + queryTreeListForRole().then((res) => { + this.treeData = res.result.treeList + this.allTreeKeys = res.result.ids + queryRolePermission({ roleId: this.roleId }).then((res) => { + this.checkedKeys = [...res.result]; + this.defaultCheckedKeys = [...res.result]; + this.expandedKeysss = this.allTreeKeys; + console.log(this.defaultCheckedKeys) + }) + }) + } + }, + watch: { + visible() { + if (this.visible) { + this.loadData(); + } + } + } +} +</script> +<style lang="less" scoped> +.drawer-bootom-button { + position: absolute; + bottom: 0; + width: 100%; + border-top: 1px solid #e8e8e8; + padding: 10px 16px; + text-align: right; + left: 0; + background: #fff; + border-radius: 0 0 2px 2px; +} +</style> -- Gitblit v1.9.3