cloud-web-corejs 1.0.140 → 1.0.142

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,429 +1,499 @@
1
- <template>
2
- <div class="detail-wrap">
3
- <el-form ref="editForm" :model="role">
4
- <div class="d-header clearfix">
5
- <div class="fl">
6
- <i class="el-icon-info"/>
7
- {{ dataId ? $t1('查看用户角色') : $t1('新增用户角色') }}
8
- </div>
9
- <div class="fr">
10
- <el-button type="primary" plain class="button-sty" @click="$baseReload()" icon="el-icon-refresh-right">
11
- {{ $t1('重置') }}
12
- </el-button>
13
- <el-button type="primary" class="button-sty" icon="el-icon-check" @click="saveData">{{ $t1('保存') }}
14
- </el-button>
15
- </div>
16
- </div>
17
- <baseTabs>
18
- <baseTabPane :label="$t1('基本信息')">
19
- <template #default>
20
- <table class="table-detail">
21
- <tbody>
22
- <tr>
23
- <th>
24
- <em class="f-red">*</em>
25
- {{ $t1('用户角色') }}
26
- </th>
27
- <td>
28
- <el-form-item prop="name" :rules="[{ required: true, trigger: 'blur' }]" v-if="!role.systems">
29
- <el-input type="text" autocomplete="off" v-model="role.name" clearable/>
30
- </el-form-item>
31
- <template v-else>
32
- {{ role.name }}
33
- </template>
34
- </td>
35
- <th>{{ $t1('角色编码') }}</th>
36
- <td>
37
- <el-form-item prop="code" :rules="[{ required: false, trigger: 'blur' }]" v-if="!dataId">
38
- <el-input type="text" autocomplete="off" v-model="role.code" clearable/>
39
- </el-form-item>
40
- <template v-else>
41
- {{ role.code }}
42
- </template>
43
- </td>
44
- <th>{{ $t1('角色描述') }}</th>
45
- <td>
46
- <el-form-item prop="description" :rules="[{ required: false, trigger: 'blur' }]">
47
- <el-input type="text" autocomplete="off" v-model="role.description" clearable/>
48
- </el-form-item>
49
- </td>
50
- <th>{{ $t1('是否内置') }}</th>
51
- <td>
52
- <template v-if="role.systems">
53
- {{ $t1('是') }}
54
- </template>
55
- <template v-else>
56
- {{ $t1('否') }}
57
- </template>
58
- </td>
59
- </tr>
60
- <tr>
61
- <th>{{ $t1('创建人') }}</th>
62
- <td>{{ role.createBy }}</td>
63
- <th>{{ $t1('创建时间') }}</th>
64
- <td>{{ role.createDate }}</td>
65
- <th>{{ $t1('更新人') }}</th>
66
- <td>{{ role.modifyBy }}</td>
67
- <th>{{ $t1('更新时间') }}</th>
68
- <td>{{ role.modifyDate }}</td>
69
- </tr>
70
- </tbody>
71
- </table>
72
- </template>
73
- </baseTabPane>
74
- <baseTabPane :label="$t1('菜单信息')">
75
- <template #default>
76
- <div class="role-box">
77
- <div class="item" v-for="item in basicMenus" :key="item.id">
78
- <div class="t">
79
- {{ item.menuName }}
80
- <i class="fr" @click="$set(item, 'visibleRole', !item.visibleRole)"
81
- :class="!item.visibleRole?'el-icon-arrow-up':'el-icon-arrow-down'"></i>
82
- </div>
83
- <div class="c" :class="{ hide: item.visibleRole }">
84
- <div v-for="subItem in item.children" :key="subItem.id">
85
- <div class="c-2nd">
86
- <el-checkbox :label="subItem.menuName" v-model="subItem.hasAuth"
87
- @change="selectAll(subItem)"></el-checkbox>
88
- </div>
89
- <div class="c-3rd">
90
- <div class="c-item" v-for="(thrItem, index3) in subItem.children" :key="thrItem.id">
91
- <div class="name">
92
- <el-checkbox :label="thrItem.menuName" v-model="thrItem.hasAuth"
93
- @change="cancelSelect(subItem, index3)"></el-checkbox>
94
- </div>
95
- <div class="c-4th">
96
- <el-checkbox
97
- v-for="(fourthItem, index4) in thrItem.children"
98
- :key="fourthItem.id"
99
- :label="fourthItem.menuName"
100
- v-model="fourthItem.hasAuth"
101
- @change="changeBtnSelect(subItem, index3, index4)"
102
- ></el-checkbox>
103
- </div>
104
- </div>
105
- </div>
106
- </div>
107
- </div>
108
- </div>
109
- <div class="item">
110
- <div class="t">
111
- {{ $t1('首页设置') }}
112
- <i class="fr" @click="visibleHome = !visibleHome"
113
- :class="!visibleHome?'el-icon-arrow-up':'el-icon-arrow-down'"></i>
114
- </div>
115
- <div class="c" :class="{ hide: visibleHome }">
116
- <div>
117
- <div class="c-3rd">
118
- <div class="c-item">
119
- <el-checkbox v-for="homeItem in homeMenus" :key="homeItem.id" :label="homeItem.menuName"
120
- v-model="homeItem.hasAuth" @change="$forceUpdate()"></el-checkbox>
121
- </div>
122
- </div>
123
- </div>
124
- </div>
125
- </div>
126
- </div>
127
- </template>
128
- </baseTabPane>
129
- <baseTabPane :label="$t1('移动端菜单信息')">
130
- <template #default>
131
- <div class="role-box">
132
- <div class="item" v-for="(item,index) in allMobileMenus" :key="index">
133
- <div class="t">
134
- {{ item.menuName }}
135
- <i class="fr" @click="$set(item, 'visibleRole', !item.visibleRole)"
136
- :class="!item.visibleRole?'el-icon-arrow-up':'el-icon-arrow-down'"></i>
137
- </div>
138
- <div class="c" :class="{ hide: item.visibleRole }">
139
- <div>
140
- <div class="c-2nd" style="width: 100%">
141
- <el-checkbox v-for="(subItem,index2) in item.children" :key="index2" :label="subItem.menuName"
142
- v-model="subItem.hasAuth"
143
- @change="selectAll(subItem)"></el-checkbox>
144
- </div>
145
- </div>
146
- </div>
147
- </div>
148
- </div>
149
- </template>
150
- </baseTabPane>
151
- </baseTabs>
152
- </el-form>
153
- </div>
154
- </template>
155
-
156
- <script>
157
- export default {
158
- name: 'roleEdit',
159
- props: ['_dataId'],
160
- components: {},
161
- data() {
162
- return {
163
- tabIndex: 0,
164
- isEdit: false,
165
- dataId: '',
166
- role: {
167
- menus: [],
168
- mobileMenuIds: []
169
- },
170
- allMenus: [],
171
- allMobileMenus: [],
172
- showCompanyDialog: false,
173
- cParam: {selectMulti: false},
174
- visibleHome: false
175
- };
176
- },
177
- computed: {
178
- basicMenus() {
179
- return this.allMenus.filter(menu => menu.type != 2);
180
- },
181
- homeMenus() {
182
- return this.allMenus.filter(menu => menu.type == 2);
183
- }
184
- },
185
- created() {
186
- if (this._dataId) this.dataId = this._dataId;
187
- },
188
- mounted() {
189
- var that = this;
190
- this.getData();
191
- },
192
- methods: {
193
- getData() {
194
- if (this.dataId) {
195
- this.isEdit = true;
196
- this.$commonHttp({
197
- url: USER_PREFIX + `/role/get`,
198
- method: `post`,
199
- data: {
200
- id: this.dataId
201
- },
202
- isLoading: true,
203
- modalStrictly: true,
204
- success: res => {
205
- this.role = res.objx || {};
206
- this.initMenuData();
207
- }
208
- });
209
- } else {
210
- this.initMenuData();
211
- }
212
- },
213
- saveData() {
214
- this.$refs.editForm.$baseValidate(valid => {
215
- if (valid) {
216
- this.$baseConfirm(this.$t1('您确定要保存吗?')).then(() => {
217
- var url = USER_PREFIX + (this.isEdit ? `/role/update` : `/role/save`);
218
- let formData = this.role;
219
- formData.menuIds = this.getMenuFormData();
220
- formData.mobileMenuIds = this.getMobileMenuFormData();
221
-
222
- this.$http({
223
- url: url,
224
- method: `post`,
225
- data: formData,
226
- isLoading: true,
227
- success: res => {
228
- this.$message({
229
- message: res.content,
230
- type: 'success',
231
- duration: 500,
232
- onClose: t => {
233
- if (this.isEdit) {
234
- this.$baseReload();
235
- } else {
236
- this.$baseReload({
237
- updateParam: {
238
- _dataId: res.objx
239
- }
240
- });
241
- }
242
- }
243
- });
244
- }
245
- });
246
- });
247
- }
248
- });
249
- },
250
- initMenuData(menus) {
251
- this.$http({
252
- url: USER_PREFIX + '/menu/getAll',
253
- method: 'POST',
254
- isLoading: true,
255
- modalStrictly: true,
256
- success: res => {
257
- let menus = res.objx || [];
258
- this.handleRoles(menus, this.role.menuIds || []);
259
- this.allMenus = menus;
260
- }
261
- });
262
- this.$http({
263
- url: USER_PREFIX + '/mobile_menu/getAll',
264
- method: 'POST',
265
- isLoading: true,
266
- modalStrictly: true,
267
- success: res => {
268
- let menus = res.objx || [];
269
- this.handleMobileRoles(menus, this.role.mobileMenuIds || []);
270
- this.allMobileMenus = menus;
271
- }
272
- });
273
- },
274
- selectAll(subItem) {
275
- //subItem.hasAuth = !subItem.hasAuth;
276
- let res = subItem.hasAuth;
277
- if (subItem.children) {
278
- subItem.children.forEach(function (thrItem) {
279
- thrItem.hasAuth = res;
280
- if (thrItem.children) {
281
- thrItem.children.forEach(function (fourthItem) {
282
- fourthItem.hasAuth = res;
283
- });
284
- }
285
- });
286
- }
287
- this.$forceUpdate();
288
- },
289
- cancelSelect(subItem, index3) {
290
- let citem = subItem.children[index3];
291
- // citem.hasAuth = !citem.hasAuth;
292
- let res = citem.hasAuth;
293
- let isCheckSubItem = false;
294
- subItem.children.forEach(function (thrItem) {
295
- if (thrItem.hasAuth) {
296
- isCheckSubItem = true;
297
- }
298
- });
299
- subItem.hasAuth = isCheckSubItem;
300
- if (citem.children) {
301
- citem.children.forEach(function (fourthItem) {
302
- fourthItem.hasAuth = res;
303
- });
304
- }
305
- this.$forceUpdate();
306
- },
307
- changeBtnSelect(subItem, index3, index4) {
308
- let citem = subItem.children[index3].children[index4];
309
- // citem.hasAuth = !citem.hasAuth;
310
- let res = citem.hasAuth;
311
- let isCheckthrItem = false;
312
- subItem.children[index3].children.forEach(function (fourthItem) {
313
- if (fourthItem.hasAuth) {
314
- isCheckthrItem = true;
315
- }
316
- });
317
-
318
- let isCheckSubItem = false;
319
- subItem.children.forEach(function (thrItem) {
320
- if (thrItem.hasAuth) {
321
- isCheckSubItem = true;
322
- }
323
- });
324
- subItem.hasAuth = isCheckSubItem;
325
- this.$forceUpdate();
326
- },
327
- getMenuFormData() {
328
- let selectIds = [];
329
- let menus = this.allMenus;
330
- menus.forEach(function (item) {
331
- if (item.type != 2 || item.hasAuth) {
332
- selectIds.push(item.id);
333
- }
334
- if (item.children) {
335
- item.children.forEach(function (subItem) {
336
- if (subItem.hasAuth) {
337
- selectIds.push(subItem.id);
338
- }
339
- if (subItem.children) {
340
- subItem.children.forEach(function (thrItem) {
341
- if (thrItem.hasAuth) {
342
- selectIds.push(thrItem.id);
343
- }
344
- if (thrItem.children) {
345
- thrItem.children.forEach(function (fourthItem) {
346
- if (fourthItem.hasAuth) {
347
- selectIds.push(fourthItem.id);
348
- }
349
- });
350
- }
351
- });
352
- }
353
- });
354
- }
355
- });
356
- return selectIds;
357
- },
358
- getMobileMenuFormData() {
359
- let selectIds = [];
360
- let menus = this.allMobileMenus;
361
- menus.forEach(function (item) {
362
- if (item.type != 2 || item.hasAuth) {
363
- selectIds.push(item.id);
364
- }
365
- if (item.children) {
366
- item.children.forEach(function (subItem) {
367
- if (subItem.hasAuth) {
368
- selectIds.push(subItem.id);
369
- }
370
- if (subItem.children) {
371
- subItem.children.forEach(function (thrItem) {
372
- if (thrItem.hasAuth) {
373
- selectIds.push(thrItem.id);
374
- }
375
- if (thrItem.children) {
376
- thrItem.children.forEach(function (fourthItem) {
377
- if (fourthItem.hasAuth) {
378
- selectIds.push(fourthItem.id);
379
- }
380
- });
381
- }
382
- });
383
- }
384
- });
385
- }
386
- });
387
- return selectIds;
388
- },
389
- handleRoles(rows, menuIds) {
390
- let newRows = [];
391
- for (let i = 0; i < rows.length; i++) {
392
- let row = rows[i];
393
- if (menuIds.includes(row.id)) {
394
- row.hasAuth = true;
395
- } else {
396
- row.hasAuth = false;
397
- }
398
- newRows.push(row);
399
- if (row.children) {
400
- let cRows = this.handleRoles(row.children, menuIds);
401
- if (cRows) {
402
- newRows = newRows.concat(cRows);
403
- }
404
- }
405
- }
406
- return newRows;
407
- },
408
- handleMobileRoles(rows, menuIds) {
409
- let newRows = [];
410
- for (let i = 0; i < rows.length; i++) {
411
- let row = rows[i];
412
- if (menuIds.includes(row.id)) {
413
- row.hasAuth = true;
414
- } else {
415
- row.hasAuth = false;
416
- }
417
- newRows.push(row);
418
- if (row.children) {
419
- let cRows = this.handleMobileRoles(row.children, menuIds);
420
- if (cRows) {
421
- newRows = newRows.concat(cRows);
422
- }
423
- }
424
- }
425
- return newRows;
426
- }
427
- }
428
- };
429
- </script>
1
+ <template>
2
+ <div class="detail-wrap">
3
+ <el-form ref="editForm" :model="role">
4
+ <div class="d-header clearfix">
5
+ <div class="fl">
6
+ <i class="el-icon-info" />
7
+ {{ dataId ? $t1("查看用户角色") : $t1("新增用户角色") }}
8
+ </div>
9
+ <div class="fr">
10
+ <el-button
11
+ type="primary"
12
+ plain
13
+ class="button-sty"
14
+ @click="$baseReload()"
15
+ icon="el-icon-refresh-right"
16
+ >
17
+ {{ $t1("重置") }}
18
+ </el-button>
19
+ <el-button
20
+ type="primary"
21
+ class="button-sty"
22
+ icon="el-icon-check"
23
+ @click="saveData"
24
+ >{{ $t1("保存") }}
25
+ </el-button>
26
+ </div>
27
+ </div>
28
+ <baseTabs>
29
+ <baseTabPane :label="$t1('基本信息')">
30
+ <template #default>
31
+ <table class="table-detail">
32
+ <tbody>
33
+ <tr>
34
+ <th>
35
+ <em class="f-red">*</em>
36
+ {{ $t1("用户角色") }}
37
+ </th>
38
+ <td>
39
+ <el-form-item
40
+ prop="name"
41
+ :rules="[{ required: true, trigger: 'blur' }]"
42
+ v-if="!role.systems"
43
+ >
44
+ <el-input
45
+ type="text"
46
+ autocomplete="off"
47
+ v-model="role.name"
48
+ clearable
49
+ />
50
+ </el-form-item>
51
+ <template v-else>
52
+ {{ role.name }}
53
+ </template>
54
+ </td>
55
+ <th>{{ $t1("角色编码") }}</th>
56
+ <td>
57
+ <el-form-item
58
+ prop="code"
59
+ :rules="[{ required: false, trigger: 'blur' }]"
60
+ v-if="!dataId"
61
+ >
62
+ <el-input
63
+ type="text"
64
+ autocomplete="off"
65
+ v-model="role.code"
66
+ clearable
67
+ />
68
+ </el-form-item>
69
+ <template v-else>
70
+ {{ role.code }}
71
+ </template>
72
+ </td>
73
+ <th>{{ $t1("角色描述") }}</th>
74
+ <td>
75
+ <el-form-item
76
+ prop="description"
77
+ :rules="[{ required: false, trigger: 'blur' }]"
78
+ >
79
+ <el-input
80
+ type="text"
81
+ autocomplete="off"
82
+ v-model="role.description"
83
+ clearable
84
+ />
85
+ </el-form-item>
86
+ </td>
87
+ <th>{{ $t1("是否内置") }}</th>
88
+ <td>
89
+ <template v-if="role.systems">
90
+ {{ $t1("") }}
91
+ </template>
92
+ <template v-else>
93
+ {{ $t1("否") }}
94
+ </template>
95
+ </td>
96
+ </tr>
97
+ <tr>
98
+ <th>{{ $t1("创建人") }}</th>
99
+ <td>{{ role.createBy }}</td>
100
+ <th>{{ $t1("创建时间") }}</th>
101
+ <td>{{ role.createDate }}</td>
102
+ <th>{{ $t1("更新人") }}</th>
103
+ <td>{{ role.modifyBy }}</td>
104
+ <th>{{ $t1("更新时间") }}</th>
105
+ <td>{{ role.modifyDate }}</td>
106
+ </tr>
107
+ </tbody>
108
+ </table>
109
+ </template>
110
+ </baseTabPane>
111
+ <baseTabPane :label="$t1('菜单信息')">
112
+ <template #default>
113
+ <div class="role-box">
114
+ <div class="item" v-for="item in basicMenus" :key="item.id">
115
+ <div class="t">
116
+ {{ item.menuName }}
117
+ <i
118
+ class="fr"
119
+ @click="$set(item, 'visibleRole', !item.visibleRole)"
120
+ :class="!item.visibleRole ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
121
+ ></i>
122
+ </div>
123
+ <div class="c" :class="{ hide: item.visibleRole }">
124
+ <div v-for="subItem in item.children" :key="subItem.id">
125
+ <div class="c-2nd">
126
+ <el-checkbox
127
+ :label="subItem.menuName"
128
+ v-model="subItem.hasAuth"
129
+ @change="selectAll(subItem)"
130
+ ></el-checkbox>
131
+ </div>
132
+ <div class="c-3rd">
133
+ <div
134
+ class="c-item"
135
+ v-for="(thrItem, index3) in subItem.children"
136
+ :key="thrItem.id"
137
+ >
138
+ <div class="name">
139
+ <el-checkbox
140
+ :label="thrItem.menuName"
141
+ v-model="thrItem.hasAuth"
142
+ @change="cancelSelect(subItem, index3)"
143
+ ></el-checkbox>
144
+ </div>
145
+ <div class="c-4th">
146
+ <el-checkbox
147
+ v-for="(fourthItem, index4) in thrItem.children"
148
+ :key="fourthItem.id"
149
+ :label="fourthItem.menuName"
150
+ v-model="fourthItem.hasAuth"
151
+ @change="changeBtnSelect(subItem, index3, index4)"
152
+ ></el-checkbox>
153
+ </div>
154
+ </div>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ </div>
159
+ <div class="item">
160
+ <div class="t">
161
+ {{ $t1("首页设置") }}
162
+ <i
163
+ class="fr"
164
+ @click="visibleHome = !visibleHome"
165
+ :class="!visibleHome ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
166
+ ></i>
167
+ </div>
168
+ <div class="c" :class="{ hide: visibleHome }">
169
+ <div>
170
+ <div class="c-3rd">
171
+ <div class="c-item">
172
+ <el-checkbox
173
+ v-for="homeItem in homeMenus"
174
+ :key="homeItem.id"
175
+ :label="homeItem.menuName"
176
+ v-model="homeItem.hasAuth"
177
+ @change="$forceUpdate()"
178
+ ></el-checkbox>
179
+ </div>
180
+ </div>
181
+ </div>
182
+ </div>
183
+ </div>
184
+ </div>
185
+ </template>
186
+ </baseTabPane>
187
+ <baseTabPane :label="$t1('移动端菜单信息')">
188
+ <template #default>
189
+ <div class="role-box">
190
+ <div class="item" v-for="(item, index) in allMobileMenus" :key="index">
191
+ <div class="t">
192
+ {{ item.menuName }}
193
+ <i
194
+ class="fr"
195
+ @click="$set(item, 'visibleRole', !item.visibleRole)"
196
+ :class="!item.visibleRole ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
197
+ ></i>
198
+ </div>
199
+ <div class="c" :class="{ hide: item.visibleRole }">
200
+ <div>
201
+ <div class="c-2nd" style="width: 100%">
202
+ <el-checkbox
203
+ v-for="(subItem, index2) in item.children"
204
+ :key="index2"
205
+ :label="subItem.menuName"
206
+ v-model="subItem.hasAuth"
207
+ @change="selectAll(subItem)"
208
+ ></el-checkbox>
209
+ </div>
210
+ </div>
211
+ </div>
212
+ </div>
213
+ </div>
214
+ </template>
215
+ </baseTabPane>
216
+ </baseTabs>
217
+ </el-form>
218
+ </div>
219
+ </template>
220
+
221
+ <script>
222
+ export default {
223
+ name: "roleEdit",
224
+ props: ["_dataId"],
225
+ components: {},
226
+ data() {
227
+ return {
228
+ tabIndex: 0,
229
+ isEdit: false,
230
+ dataId: "",
231
+ role: {
232
+ menus: [],
233
+ mobileMenuIds: [],
234
+ },
235
+ allMenus: [],
236
+ allMobileMenus: [],
237
+ showCompanyDialog: false,
238
+ cParam: { selectMulti: false },
239
+ visibleHome: false,
240
+ };
241
+ },
242
+ computed: {
243
+ basicMenus() {
244
+ return this.allMenus.filter((menu) => menu.type != 2);
245
+ },
246
+ homeMenus() {
247
+ return this.allMenus.filter((menu) => menu.type == 2);
248
+ },
249
+ },
250
+ created() {
251
+ if (this._dataId) this.dataId = this._dataId;
252
+ },
253
+ mounted() {
254
+ var that = this;
255
+ this.getData();
256
+ },
257
+ methods: {
258
+ getData() {
259
+ if (this.dataId) {
260
+ this.isEdit = true;
261
+ this.$commonHttp({
262
+ url: USER_PREFIX + `/role/get`,
263
+ method: `post`,
264
+ data: {
265
+ id: this.dataId,
266
+ },
267
+ isLoading: true,
268
+ modalStrictly: true,
269
+ success: (res) => {
270
+ this.role = res.objx || {};
271
+ this.initMenuData();
272
+ },
273
+ });
274
+ } else {
275
+ this.initMenuData();
276
+ }
277
+ },
278
+ saveData() {
279
+ this.$refs.editForm.$baseValidate((valid) => {
280
+ if (valid) {
281
+ this.$baseConfirm(this.$t1("您确定要保存吗?")).then(() => {
282
+ var url = USER_PREFIX + (this.isEdit ? `/role/update` : `/role/save`);
283
+ let formData = this.role;
284
+ formData.menuIds = this.getMenuFormData();
285
+ formData.mobileMenuIds = this.getMobileMenuFormData();
286
+
287
+ this.$http({
288
+ url: url,
289
+ method: `post`,
290
+ data: formData,
291
+ isLoading: true,
292
+ success: (res) => {
293
+ this.$message({
294
+ message: res.content,
295
+ type: "success",
296
+ duration: 500,
297
+ onClose: (t) => {
298
+ if (this.isEdit) {
299
+ this.$baseReload();
300
+ } else {
301
+ this.$baseReload({
302
+ updateParam: {
303
+ _dataId: res.objx,
304
+ },
305
+ });
306
+ }
307
+ },
308
+ });
309
+ },
310
+ });
311
+ });
312
+ }
313
+ });
314
+ },
315
+ initMenuData(menus) {
316
+ this.$http({
317
+ url: USER_PREFIX + "/menu/getAll",
318
+ method: "POST",
319
+ isLoading: true,
320
+ modalStrictly: true,
321
+ success: (res) => {
322
+ let menus = res.objx || [];
323
+ this.handleRoles(menus, this.role.menuIds || []);
324
+ this.allMenus = menus;
325
+ },
326
+ });
327
+ this.$http({
328
+ url: USER_PREFIX + "/mobile_menu/getAll",
329
+ method: "POST",
330
+ isLoading: true,
331
+ modalStrictly: true,
332
+ success: (res) => {
333
+ let menus = res.objx || [];
334
+ this.handleMobileRoles(menus, this.role.mobileMenuIds || []);
335
+ this.allMobileMenus = menus;
336
+ },
337
+ });
338
+ },
339
+ selectAll(subItem) {
340
+ //subItem.hasAuth = !subItem.hasAuth;
341
+ let res = subItem.hasAuth;
342
+ if (subItem.children) {
343
+ subItem.children.forEach(function (thrItem) {
344
+ thrItem.hasAuth = res;
345
+ if (thrItem.children) {
346
+ thrItem.children.forEach(function (fourthItem) {
347
+ fourthItem.hasAuth = res;
348
+ });
349
+ }
350
+ });
351
+ }
352
+ this.$forceUpdate();
353
+ },
354
+ cancelSelect(subItem, index3) {
355
+ let citem = subItem.children[index3];
356
+ // citem.hasAuth = !citem.hasAuth;
357
+ let res = citem.hasAuth;
358
+ let isCheckSubItem = false;
359
+ subItem.children.forEach(function (thrItem) {
360
+ if (thrItem.hasAuth) {
361
+ isCheckSubItem = true;
362
+ }
363
+ });
364
+ if (citem.type !== 1) {
365
+ subItem.hasAuth = isCheckSubItem;
366
+ } else {
367
+ if (isCheckSubItem) subItem.hasAuth = true;
368
+ }
369
+
370
+ if (citem.children) {
371
+ citem.children.forEach(function (fourthItem) {
372
+ fourthItem.hasAuth = res;
373
+ });
374
+ }
375
+ this.$forceUpdate();
376
+ },
377
+ changeBtnSelect(subItem, index3, index4) {
378
+ let citem = subItem.children[index3].children[index4];
379
+ // citem.hasAuth = !citem.hasAuth;
380
+ let res = citem.hasAuth;
381
+ let isCheckthrItem = false;
382
+ subItem.children[index3].children.forEach(function (fourthItem) {
383
+ if (fourthItem.hasAuth) {
384
+ isCheckthrItem = true;
385
+ }
386
+ });
387
+
388
+ let isCheckSubItem = false;
389
+ subItem.children.forEach(function (thrItem) {
390
+ if (thrItem.hasAuth) {
391
+ isCheckSubItem = true;
392
+ }
393
+ });
394
+ subItem.hasAuth = isCheckSubItem;
395
+ this.$forceUpdate();
396
+ },
397
+ getMenuFormData() {
398
+ let selectIds = [];
399
+ let menus = this.allMenus;
400
+ menus.forEach(function (item) {
401
+ if (item.type != 2 || item.hasAuth) {
402
+ selectIds.push(item.id);
403
+ }
404
+ if (item.children) {
405
+ item.children.forEach(function (subItem) {
406
+ if (subItem.hasAuth) {
407
+ selectIds.push(subItem.id);
408
+ }
409
+ if (subItem.children) {
410
+ subItem.children.forEach(function (thrItem) {
411
+ if (thrItem.hasAuth) {
412
+ selectIds.push(thrItem.id);
413
+ }
414
+ if (thrItem.children) {
415
+ thrItem.children.forEach(function (fourthItem) {
416
+ if (fourthItem.hasAuth) {
417
+ selectIds.push(fourthItem.id);
418
+ }
419
+ });
420
+ }
421
+ });
422
+ }
423
+ });
424
+ }
425
+ });
426
+ return selectIds;
427
+ },
428
+ getMobileMenuFormData() {
429
+ let selectIds = [];
430
+ let menus = this.allMobileMenus;
431
+ menus.forEach(function (item) {
432
+ if (item.type != 2 || item.hasAuth) {
433
+ selectIds.push(item.id);
434
+ }
435
+ if (item.children) {
436
+ item.children.forEach(function (subItem) {
437
+ if (subItem.hasAuth) {
438
+ selectIds.push(subItem.id);
439
+ }
440
+ if (subItem.children) {
441
+ subItem.children.forEach(function (thrItem) {
442
+ if (thrItem.hasAuth) {
443
+ selectIds.push(thrItem.id);
444
+ }
445
+ if (thrItem.children) {
446
+ thrItem.children.forEach(function (fourthItem) {
447
+ if (fourthItem.hasAuth) {
448
+ selectIds.push(fourthItem.id);
449
+ }
450
+ });
451
+ }
452
+ });
453
+ }
454
+ });
455
+ }
456
+ });
457
+ return selectIds;
458
+ },
459
+ handleRoles(rows, menuIds) {
460
+ let newRows = [];
461
+ for (let i = 0; i < rows.length; i++) {
462
+ let row = rows[i];
463
+ if (menuIds.includes(row.id)) {
464
+ row.hasAuth = true;
465
+ } else {
466
+ row.hasAuth = false;
467
+ }
468
+ newRows.push(row);
469
+ if (row.children) {
470
+ let cRows = this.handleRoles(row.children, menuIds);
471
+ if (cRows) {
472
+ newRows = newRows.concat(cRows);
473
+ }
474
+ }
475
+ }
476
+ return newRows;
477
+ },
478
+ handleMobileRoles(rows, menuIds) {
479
+ let newRows = [];
480
+ for (let i = 0; i < rows.length; i++) {
481
+ let row = rows[i];
482
+ if (menuIds.includes(row.id)) {
483
+ row.hasAuth = true;
484
+ } else {
485
+ row.hasAuth = false;
486
+ }
487
+ newRows.push(row);
488
+ if (row.children) {
489
+ let cRows = this.handleMobileRoles(row.children, menuIds);
490
+ if (cRows) {
491
+ newRows = newRows.concat(cRows);
492
+ }
493
+ }
494
+ }
495
+ return newRows;
496
+ },
497
+ },
498
+ };
499
+ </script>