Commit 70bc18350980382cecad0d1660f69841a8aaf85b

Authored by pengyongcheng
1 parent 9b4b3e20

角色权限配置,默认不展开权限树

ant-design-vue-jeecg/src/views/system/modules/UserRoleModal.vue
... ... @@ -40,7 +40,7 @@
40 40 </a-menu>
41 41 <a-button>
42 42 树操作
43   - <a-icon type="up"/>
  43 + <a-icon type="up" />
44 44 </a-button>
45 45 </a-dropdown>
46 46 <a-popconfirm title="确定放弃编辑?" @confirm="close" okText="确定" cancelText="取消">
... ... @@ -57,17 +57,17 @@
57 57  
58 58 </template>
59 59 <script>
60   -import {queryTreeListForRole, queryRolePermission, saveRolePermission} from '@/api/api'
  60 +import { queryRolePermission, queryTreeListForRole, saveRolePermission } from '@/api/api'
61 61 import RoleDataruleModal from './RoleDataruleModal.vue'
62 62  
63 63 export default {
64   - name: "RoleModal",
  64 + name: 'RoleModal',
65 65 components: {
66 66 RoleDataruleModal
67 67 },
68 68 data() {
69 69 return {
70   - roleId: "",
  70 + roleId: '',
71 71 treeData: [],
72 72 defaultCheckedKeys: [],
73 73 checkedKeys: [],
... ... @@ -75,7 +75,7 @@ export default {
75 75 allTreeKeys: [],
76 76 autoExpandParent: true,
77 77 checkStrictly: true,
78   - title: "角色权限配置",
  78 + title: '角色权限配置',
79 79 visible: false,
80 80 loading: false,
81 81 selectedKeys: []
... ... @@ -90,22 +90,22 @@ export default {
90 90 },
91 91 onCheck(o) {
92 92 if (this.checkStrictly) {
93   - this.checkedKeys = o.checked;
  93 + this.checkedKeys = o.checked
94 94 } else {
95 95 this.checkedKeys = o
96 96 }
97 97 },
98 98 show(roleId) {
99 99 this.roleId = roleId
100   - this.visible = true;
  100 + this.visible = true
101 101 },
102 102 close() {
103 103 this.reset()
104   - this.$emit('close');
105   - this.visible = false;
  104 + this.$emit('close')
  105 + this.visible = false
106 106 },
107 107 onExpand(expandedKeys) {
108   - this.expandedKeysss = expandedKeys;
  108 + this.expandedKeysss = expandedKeys
109 109 this.autoExpandParent = false
110 110 },
111 111 reset() {
... ... @@ -128,9 +128,9 @@ export default {
128 128 this.checkedKeys = []
129 129 },
130 130 switchCheckStrictly(v) {
131   - if (v == 1) {
  131 + if (v === 1) {
132 132 this.checkStrictly = false
133   - } else if (v == 2) {
  133 + } else if (v === 2) {
134 134 this.checkStrictly = true
135 135 }
136 136 },
... ... @@ -138,40 +138,38 @@ export default {
138 138 this.close()
139 139 },
140 140 handleSubmit(exit) {
141   - let that = this;
  141 + let that = this
142 142 let params = {
143 143 roleId: that.roleId,
144   - permissionIds: that.checkedKeys.join(","),
145   - lastpermissionIds: that.defaultCheckedKeys.join(","),
146   - };
147   - that.loading = true;
148   - console.log("请求参数:", params);
  144 + permissionIds: that.checkedKeys.join(','),
  145 + lastpermissionIds: that.defaultCheckedKeys.join(',')
  146 + }
  147 + that.loading = true
149 148 saveRolePermission(params).then((res) => {
150 149 if (res.success) {
151   - that.$message.success(res.message);
152   - that.loading = false;
  150 + that.$message.success(res.message)
  151 + that.loading = false
153 152 if (exit) {
154 153 that.close()
155 154 }
156 155 } else {
157   - that.$message.error(res.message);
158   - that.loading = false;
  156 + that.$message.error(res.message)
  157 + that.loading = false
159 158 if (exit) {
160 159 that.close()
161 160 }
162 161 }
163   - this.loadData();
  162 + this.loadData()
164 163 })
165 164 },
166 165 loadData() {
167 166 queryTreeListForRole().then((res) => {
168 167 this.treeData = res.result.treeList
169 168 this.allTreeKeys = res.result.ids
170   - queryRolePermission({roleId: this.roleId}).then((res) => {
171   - this.checkedKeys = [...res.result];
172   - this.defaultCheckedKeys = [...res.result];
173   - this.expandedKeysss = this.allTreeKeys;
174   - console.log(this.defaultCheckedKeys)
  169 + queryRolePermission({ roleId: this.roleId }).then((res) => {
  170 + this.checkedKeys = [...res.result]
  171 + this.defaultCheckedKeys = [...res.result]
  172 + //this.expandedKeysss = this.allTreeKeys 注释为了加载数据后,控件不展开
175 173 })
176 174 })
177 175 }
... ... @@ -179,7 +177,7 @@ export default {
179 177 watch: {
180 178 visible() {
181 179 if (this.visible) {
182   - this.loadData();
  180 + this.loadData()
183 181 }
184 182 }
185 183 }
... ...