@netang/quasar 0.0.20
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.
- package/LICENSE +21 -0
- package/README.md +17 -0
- package/components/column-title/index.vue +32 -0
- package/components/dialog/components/index.js +6 -0
- package/components/dialog/components/move-to-tree/index.vue +150 -0
- package/components/dialog/index.vue +330 -0
- package/components/dialog-table/index.vue +92 -0
- package/components/dragger/index.vue +202 -0
- package/components/drawer/index.vue +262 -0
- package/components/field-date/index.vue +844 -0
- package/components/field-date/methods.js +100 -0
- package/components/field-table/index.vue +468 -0
- package/components/field-text/index.vue +167 -0
- package/components/field-tree/index.vue +435 -0
- package/components/input-number/index.vue +324 -0
- package/components/input-number/number.js +67 -0
- package/components/input-price-cent/index.vue +213 -0
- package/components/input-price-yuan/index.vue +179 -0
- package/components/layout/index.vue +119 -0
- package/components/list-menu/index.vue +137 -0
- package/components/list-menu-item/index.vue +79 -0
- package/components/power-data/index.vue +667 -0
- package/components/search/index.vue +176 -0
- package/components/search-item/index.vue +219 -0
- package/components/select/index.vue +71 -0
- package/components/select-filter/index.vue +75 -0
- package/components/table/index.vue +347 -0
- package/components/table-column-fixed/index.vue +68 -0
- package/components/table-pagination/index.vue +83 -0
- package/components/table-summary/index.vue +91 -0
- package/components/thumbnail/index.vue +87 -0
- package/components/toolbar/container.vue +31 -0
- package/components/toolbar/index.vue +405 -0
- package/components/uploader/index.vue +157 -0
- package/components/uploader-query/index.vue +731 -0
- package/package.json +21 -0
- package/sass/common.scss +165 -0
- package/sass/index.scss +14 -0
- package/sass/line.scss +39 -0
- package/sass/quasar/btn.scss +46 -0
- package/sass/quasar/common.scss +3 -0
- package/sass/quasar/dialog.scss +7 -0
- package/sass/quasar/drawer.scss +6 -0
- package/sass/quasar/field.scss +210 -0
- package/sass/quasar/loading.scss +6 -0
- package/sass/quasar/menu.scss +8 -0
- package/sass/quasar/table.scss +112 -0
- package/sass/quasar/toolbar.scss +22 -0
- package/store/index.js +32 -0
- package/utils/$area.js +387 -0
- package/utils/$auth.js +135 -0
- package/utils/$dialog.js +43 -0
- package/utils/$role.js +807 -0
- package/utils/$rule.js +17 -0
- package/utils/$search.js +336 -0
- package/utils/$table.js +802 -0
- package/utils/$tree.js +620 -0
- package/utils/$uploader.js +1029 -0
- package/utils/alert.js +10 -0
- package/utils/bus.js +6 -0
- package/utils/config.js +22 -0
- package/utils/confrim.js +11 -0
- package/utils/dict.js +44 -0
- package/utils/getData.js +61 -0
- package/utils/getFile.js +30 -0
- package/utils/getImage.js +136 -0
- package/utils/getTime.js +94 -0
- package/utils/http.js +251 -0
- package/utils/loading.js +13 -0
- package/utils/notify.js +13 -0
- package/utils/previewImage.js +8 -0
- package/utils/symbols.js +3 -0
- package/utils/timestamp.js +18 -0
- package/utils/toast.js +13 -0
- package/utils/uploader/aliyun.js +6 -0
- package/utils/uploader/local.js +8 -0
- package/utils/uploader/qiniu.js +311 -0
- package/utils/useAuth.js +26 -0
- package/utils/useRouter.js +36 -0
- package/utils/useUploader.js +58 -0
package/utils/$tree.js
ADDED
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
import { isRef, watch } from 'vue'
|
|
2
|
+
import { useRoute } from 'vue-router'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 获取节点
|
|
6
|
+
*/
|
|
7
|
+
function getTreeNode(data, nodeId) {
|
|
8
|
+
for (const item of data) {
|
|
9
|
+
|
|
10
|
+
if (item.id === nodeId) {
|
|
11
|
+
return item
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 如果是父节点
|
|
15
|
+
if (item.children.length) {
|
|
16
|
+
const res = getTreeNode(item.children, nodeId)
|
|
17
|
+
if (res) {
|
|
18
|
+
return res
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 获取子节点
|
|
28
|
+
*/
|
|
29
|
+
function getChildren(data, callback) {
|
|
30
|
+
for (const item of data) {
|
|
31
|
+
if (utils.run(callback)(item) === false) {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
// 如果是父节点
|
|
35
|
+
if (item.children.length) {
|
|
36
|
+
const res = getChildren(item.children, callback)
|
|
37
|
+
if (res === false) {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return true
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 树业务
|
|
47
|
+
*/
|
|
48
|
+
utils.$tree = function(params) {
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
// 树节点列表
|
|
52
|
+
nodes,
|
|
53
|
+
// 树展开节点
|
|
54
|
+
expanded,
|
|
55
|
+
// 权限按钮列表
|
|
56
|
+
roleBtnLists,
|
|
57
|
+
// 原始表单数据
|
|
58
|
+
rawFormData,
|
|
59
|
+
// 表单数据
|
|
60
|
+
formData,
|
|
61
|
+
// 重新加载
|
|
62
|
+
reload,
|
|
63
|
+
// 是否开启展开节点缓存
|
|
64
|
+
cache,
|
|
65
|
+
} = Object.assign({
|
|
66
|
+
// 是否开启展开节点缓存
|
|
67
|
+
cache: false,
|
|
68
|
+
}, params)
|
|
69
|
+
|
|
70
|
+
// 如果没有地址, 则使用当前路由地址
|
|
71
|
+
let url = ''
|
|
72
|
+
if (! _.get(params, 'url')) {
|
|
73
|
+
// 当前路由
|
|
74
|
+
url = useRoute().fullPath
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 是否有展开节点
|
|
78
|
+
const hasExpanded = ! _.isNil(expanded) && isRef(expanded)
|
|
79
|
+
|
|
80
|
+
// 如果开启展开节点缓存
|
|
81
|
+
if (hasExpanded && cache) {
|
|
82
|
+
|
|
83
|
+
// 设置树展开节点初始缓存
|
|
84
|
+
expanded.value = getExpandedCache(expanded.value)
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 监听树展开节点
|
|
88
|
+
*/
|
|
89
|
+
watch(expanded, function(val) {
|
|
90
|
+
// 设置树展开节点缓存
|
|
91
|
+
setExpandedCache(val)
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 获取节点
|
|
97
|
+
*/
|
|
98
|
+
function getNode(nodeId) {
|
|
99
|
+
return getTreeNode(nodes.value, nodeId)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 格式化节点
|
|
104
|
+
*/
|
|
105
|
+
function formatNode(attr) {
|
|
106
|
+
|
|
107
|
+
// 设置属性
|
|
108
|
+
attr = Object.assign({}, attr)
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
attr,
|
|
112
|
+
id: attr.id,
|
|
113
|
+
label: attr.title,
|
|
114
|
+
children: [],
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 更新节点
|
|
120
|
+
*/
|
|
121
|
+
function updateNode(data) {
|
|
122
|
+
|
|
123
|
+
// 获取 id
|
|
124
|
+
const id = _.get(formData.value, 'id')
|
|
125
|
+
|
|
126
|
+
// 更新表单数据
|
|
127
|
+
formData.value = Object.assign({}, formData.value, data)
|
|
128
|
+
|
|
129
|
+
// 获取节点数据
|
|
130
|
+
const nodeItem = getNode(data.id)
|
|
131
|
+
|
|
132
|
+
// 如果为更新节点
|
|
133
|
+
if (id) {
|
|
134
|
+
if (nodeItem) {
|
|
135
|
+
Object.assign(nodeItem, {
|
|
136
|
+
attr: Object.assign({}, formData.value),
|
|
137
|
+
label: formData.value.title,
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 否则为新增节点
|
|
142
|
+
} else if (
|
|
143
|
+
// 如果为新增节点
|
|
144
|
+
_.get(data, 'id')
|
|
145
|
+
// 没有节点存在
|
|
146
|
+
&& ! nodeItem
|
|
147
|
+
) {
|
|
148
|
+
// 获取父级节点
|
|
149
|
+
const parentNodeItem = getNode(formData.value.pid)
|
|
150
|
+
if (! parentNodeItem) {
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 新增节点
|
|
155
|
+
parentNodeItem.children.push(formatNode(formData.value))
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 删除节点
|
|
161
|
+
*/
|
|
162
|
+
function deleteNode({ id, attr }) {
|
|
163
|
+
|
|
164
|
+
// 获取父节点数据
|
|
165
|
+
const parentNodeItem = getNode(attr.pid)
|
|
166
|
+
if (! parentNodeItem) {
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// 获取节点索引
|
|
171
|
+
const nodeIndex = _.findIndex(parentNodeItem.children, { id })
|
|
172
|
+
if (nodeIndex > -1) {
|
|
173
|
+
parentNodeItem.children.splice(nodeIndex, 1)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 获取菜单状态
|
|
179
|
+
*/
|
|
180
|
+
function getMenuStatus(params) {
|
|
181
|
+
|
|
182
|
+
const o = Object.assign({
|
|
183
|
+
updateName: 'update',
|
|
184
|
+
moveName: 'move',
|
|
185
|
+
copyName: 'copy',
|
|
186
|
+
deleteName: 'realdel',
|
|
187
|
+
statusName: 'status'
|
|
188
|
+
}, params)
|
|
189
|
+
|
|
190
|
+
const maps = {}
|
|
191
|
+
maps[o.updateName] = 'update'
|
|
192
|
+
maps[o.moveName] = 'move'
|
|
193
|
+
maps[o.copyName] = 'copy'
|
|
194
|
+
maps[o.deleteName] = 'delete'
|
|
195
|
+
maps[o.statusName] = 'status'
|
|
196
|
+
|
|
197
|
+
const allRoleBtn = {}
|
|
198
|
+
for (const item of roleBtnLists.value) {
|
|
199
|
+
if (_.has(maps, _.get(item, 'name'))) {
|
|
200
|
+
allRoleBtn[maps[item.name]] = item
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
all: utils.isValidObject(allRoleBtn),
|
|
206
|
+
update: _.has(allRoleBtn, 'update'),
|
|
207
|
+
move: _.has(allRoleBtn, 'move'),
|
|
208
|
+
copy: _.has(allRoleBtn, 'copy'),
|
|
209
|
+
delete: _.has(allRoleBtn, 'delete'),
|
|
210
|
+
status: _.has(allRoleBtn, 'status'),
|
|
211
|
+
allRoleBtn,
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 确认菜单
|
|
217
|
+
*/
|
|
218
|
+
function confirmMenu(callback) {
|
|
219
|
+
// 确认框
|
|
220
|
+
utils.confirm({
|
|
221
|
+
message: '确认要执行该操作吗?',
|
|
222
|
+
})
|
|
223
|
+
// 点击确认执行
|
|
224
|
+
.onOk(callback)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 菜单点击
|
|
229
|
+
*/
|
|
230
|
+
function menuClick(params) {
|
|
231
|
+
|
|
232
|
+
// 参数
|
|
233
|
+
const o = Object.assign({
|
|
234
|
+
// 菜单类型
|
|
235
|
+
type: '',
|
|
236
|
+
// 节点
|
|
237
|
+
node: null,
|
|
238
|
+
}, params)
|
|
239
|
+
|
|
240
|
+
// 菜单类型
|
|
241
|
+
switch (o.type) {
|
|
242
|
+
|
|
243
|
+
// 添加下级
|
|
244
|
+
case 'update':
|
|
245
|
+
// 更新表单数据
|
|
246
|
+
formData.value = Object.assign({}, rawFormData, {
|
|
247
|
+
pid: o.node.attr.id,
|
|
248
|
+
})
|
|
249
|
+
break
|
|
250
|
+
|
|
251
|
+
// 移至节点上
|
|
252
|
+
case 'moveUp':
|
|
253
|
+
// 移至节点内
|
|
254
|
+
case 'moveIn':
|
|
255
|
+
// 移至节点下
|
|
256
|
+
case 'moveDown':
|
|
257
|
+
|
|
258
|
+
if (! _.get(o.menuStatus, 'value.allRoleBtn.move.url')) {
|
|
259
|
+
console.error('没有找到复制地址')
|
|
260
|
+
return
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// 创建对话框
|
|
264
|
+
utils.$dialog.create({
|
|
265
|
+
// 标题
|
|
266
|
+
title: `移动至节点的${o.type === 'moveUp' ? '上方' : (o.type === 'moveDown' ? '下方' : '内部')}`,
|
|
267
|
+
width: 500,
|
|
268
|
+
minWidth: 500,
|
|
269
|
+
// 组件标识
|
|
270
|
+
name: 'moveToTree',
|
|
271
|
+
// 传参
|
|
272
|
+
props: {
|
|
273
|
+
// 树节点列表
|
|
274
|
+
nodes,
|
|
275
|
+
// 树展开节点
|
|
276
|
+
expanded,
|
|
277
|
+
},
|
|
278
|
+
// 显示取消按钮
|
|
279
|
+
cancel: true,
|
|
280
|
+
// 点击确认执行
|
|
281
|
+
async onConfirm({ value: moveNodeId }) {
|
|
282
|
+
|
|
283
|
+
// 是否为正确的 id
|
|
284
|
+
if (! utils.hasId(moveNodeId)) {
|
|
285
|
+
utils.toast({
|
|
286
|
+
message: '请选择节点',
|
|
287
|
+
})
|
|
288
|
+
return false
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// 如果节点是自己
|
|
292
|
+
if (moveNodeId === o.node.id) {
|
|
293
|
+
utils.toast({
|
|
294
|
+
message: '不能选择当前节点',
|
|
295
|
+
})
|
|
296
|
+
return false
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// 获取需移动至的节点
|
|
300
|
+
const moveNodeItem = getNode(moveNodeId)
|
|
301
|
+
if (! moveNodeItem) {
|
|
302
|
+
utils.alert({
|
|
303
|
+
message: '移动至的节点不存在',
|
|
304
|
+
})
|
|
305
|
+
return false
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// 克隆当前树列表数据
|
|
309
|
+
const nodesClone = _.cloneDeep(nodes.value)
|
|
310
|
+
|
|
311
|
+
// 获取当前节点
|
|
312
|
+
const nodeItem = getNode(o.node.id)
|
|
313
|
+
|
|
314
|
+
// 获取当前节点的父节点
|
|
315
|
+
const parentNodeItem = getNode(o.node.attr.pid)
|
|
316
|
+
|
|
317
|
+
// 移动列表数据
|
|
318
|
+
const moveLists = []
|
|
319
|
+
|
|
320
|
+
// 如果是移动至节点内部
|
|
321
|
+
// --------------------------------------------------
|
|
322
|
+
if (o.type === 'moveIn') {
|
|
323
|
+
|
|
324
|
+
// 修改当前节点数据
|
|
325
|
+
nodeItem.attr.pid = moveNodeItem.attr.id
|
|
326
|
+
// console.log('moveNodeItem.children', moveNodeItem.children)
|
|
327
|
+
|
|
328
|
+
nodeItem.attr.sort =
|
|
329
|
+
// 如果移动至的节点有子节点
|
|
330
|
+
moveNodeItem.children.length
|
|
331
|
+
// 则获取移动至的节点中最后一个子节点的排序号 + 1
|
|
332
|
+
? moveNodeItem.children[moveNodeItem.children.length - 1].attr.sort + 1
|
|
333
|
+
// 否则排序号设为 1
|
|
334
|
+
: 1
|
|
335
|
+
|
|
336
|
+
// 添加移动列表数据
|
|
337
|
+
moveLists.push({
|
|
338
|
+
id: nodeItem.id,
|
|
339
|
+
pid: nodeItem.attr.pid,
|
|
340
|
+
sort: nodeItem.attr.sort,
|
|
341
|
+
})
|
|
342
|
+
|
|
343
|
+
// 将本节点从原父节点中删除
|
|
344
|
+
const nodeItemIndex = _.findIndex(parentNodeItem.children, { id: nodeItem.id })
|
|
345
|
+
parentNodeItem.children.splice(nodeItemIndex, 1)
|
|
346
|
+
|
|
347
|
+
// 将本节点添加至移动至的节点的子节点中
|
|
348
|
+
moveNodeItem.children.push(nodeItem)
|
|
349
|
+
|
|
350
|
+
// 否则移动至节点的上方/下方
|
|
351
|
+
// --------------------------------------------------
|
|
352
|
+
} else {
|
|
353
|
+
|
|
354
|
+
// 获取移动至节点的父节点
|
|
355
|
+
let moveParentNodeItem = getNode(moveNodeItem.attr.pid)
|
|
356
|
+
|
|
357
|
+
// 修改当前节点数据
|
|
358
|
+
nodeItem.attr.pid = moveNodeItem.attr.pid
|
|
359
|
+
nodeItem.attr.sort = moveNodeItem.attr.sort + (o.type === 'moveUp' ? 0 : 1)
|
|
360
|
+
|
|
361
|
+
// 添加移动列表数据
|
|
362
|
+
moveLists.push({
|
|
363
|
+
id: nodeItem.id,
|
|
364
|
+
pid: nodeItem.attr.pid,
|
|
365
|
+
sort: nodeItem.attr.sort,
|
|
366
|
+
})
|
|
367
|
+
|
|
368
|
+
// 将本节点从原父节点中删除
|
|
369
|
+
const nodeItemIndex = _.findIndex(parentNodeItem.children, { id: nodeItem.id })
|
|
370
|
+
parentNodeItem.children.splice(nodeItemIndex, 1)
|
|
371
|
+
|
|
372
|
+
// 获取移动至节点的索引
|
|
373
|
+
const moveNodeItemIndex = _.findIndex(moveParentNodeItem.children, { id: moveNodeId })
|
|
374
|
+
|
|
375
|
+
for (let i = moveNodeItemIndex + (o.type === 'moveUp' ? 0 : 1); i < moveParentNodeItem.children.length; i++) {
|
|
376
|
+
const item = moveParentNodeItem.children[i]
|
|
377
|
+
item.attr.sort = item.attr.sort + 1
|
|
378
|
+
moveLists.push({
|
|
379
|
+
id: item.id,
|
|
380
|
+
pid: item.attr.pid,
|
|
381
|
+
sort: item.attr.sort,
|
|
382
|
+
})
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// 将本节点插入移动至位置
|
|
386
|
+
moveParentNodeItem.children.splice(moveNodeItemIndex + (o.type === 'moveUp' ? 0 : 1), 0, nodeItem)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// 请求 - 移动
|
|
390
|
+
const { status } = await utils.http({
|
|
391
|
+
url: o.menuStatus.value.allRoleBtn.move.url,
|
|
392
|
+
data: {
|
|
393
|
+
data: moveLists,
|
|
394
|
+
},
|
|
395
|
+
})
|
|
396
|
+
if (! status) {
|
|
397
|
+
// 移动失败, 还原数据
|
|
398
|
+
nodes.value = nodesClone
|
|
399
|
+
return false
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
})
|
|
403
|
+
break
|
|
404
|
+
|
|
405
|
+
// 复制
|
|
406
|
+
case 'copy':
|
|
407
|
+
// 确认菜单
|
|
408
|
+
confirmMenu(async function() {
|
|
409
|
+
|
|
410
|
+
if (! _.get(o.menuStatus, 'value.allRoleBtn.copy.url')) {
|
|
411
|
+
console.error('没有找到复制地址')
|
|
412
|
+
return
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// 复制的当前节点的属性
|
|
416
|
+
const newAttr = Object.assign({}, o.node.attr, {
|
|
417
|
+
title: '【复制】' + o.node.attr.title,
|
|
418
|
+
})
|
|
419
|
+
|
|
420
|
+
// 复制列表
|
|
421
|
+
const copyLists = [ newAttr ]
|
|
422
|
+
|
|
423
|
+
// 是否复制叶子节点
|
|
424
|
+
const isLeafNode = ! o.node.children.length
|
|
425
|
+
|
|
426
|
+
// 如果复制的是父级节点
|
|
427
|
+
if (! isLeafNode) {
|
|
428
|
+
getChildren(o.node.children, function(item) {
|
|
429
|
+
copyLists.push(item.attr)
|
|
430
|
+
})
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// 请求 - 复制
|
|
434
|
+
const { status, data: res } = await utils.http({
|
|
435
|
+
url: o.menuStatus.value.allRoleBtn.copy.url,
|
|
436
|
+
data: {
|
|
437
|
+
data: copyLists,
|
|
438
|
+
},
|
|
439
|
+
})
|
|
440
|
+
if (! status) {
|
|
441
|
+
return
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// 如果复制的是叶子节点
|
|
445
|
+
if (isLeafNode) {
|
|
446
|
+
|
|
447
|
+
// 如果返回了 id
|
|
448
|
+
if (utils.hasId(res)) {
|
|
449
|
+
|
|
450
|
+
// 更新数据
|
|
451
|
+
Object.assign(newAttr, res)
|
|
452
|
+
|
|
453
|
+
// 获取该叶子节点的父级节点
|
|
454
|
+
const parentNodeItem = getNode(newAttr.pid)
|
|
455
|
+
if (! parentNodeItem) {
|
|
456
|
+
return
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// 新增节点
|
|
460
|
+
parentNodeItem.children.push(formatNode(newAttr))
|
|
461
|
+
|
|
462
|
+
// 否则重新加载列表
|
|
463
|
+
} else {
|
|
464
|
+
reload()
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// 否则重新加载列表
|
|
468
|
+
} else {
|
|
469
|
+
reload()
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// 轻提示
|
|
473
|
+
utils.toast({
|
|
474
|
+
type: 'positive',
|
|
475
|
+
message: '复制成功',
|
|
476
|
+
})
|
|
477
|
+
})
|
|
478
|
+
break
|
|
479
|
+
|
|
480
|
+
// 删除
|
|
481
|
+
case 'delete':
|
|
482
|
+
|
|
483
|
+
// 如果有子节点
|
|
484
|
+
if (o.node.children.length) {
|
|
485
|
+
// 提示框
|
|
486
|
+
utils.alert({
|
|
487
|
+
message: '请先删除该节点下的子节点',
|
|
488
|
+
})
|
|
489
|
+
return
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (! _.get(o.menuStatus, 'value.allRoleBtn.delete.url')) {
|
|
493
|
+
console.error('没有找到删除地址')
|
|
494
|
+
return
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// 确认菜单
|
|
498
|
+
confirmMenu(async function() {
|
|
499
|
+
|
|
500
|
+
// 请求 - 删除
|
|
501
|
+
const { status } = await utils.http({
|
|
502
|
+
url: o.menuStatus.value.allRoleBtn.delete.url,
|
|
503
|
+
data: {
|
|
504
|
+
id: o.node.id,
|
|
505
|
+
},
|
|
506
|
+
})
|
|
507
|
+
if (! status) {
|
|
508
|
+
return
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// 删除节点
|
|
512
|
+
deleteNode(o.node)
|
|
513
|
+
|
|
514
|
+
// 轻提示
|
|
515
|
+
utils.toast({
|
|
516
|
+
type: 'positive',
|
|
517
|
+
message: '删除成功',
|
|
518
|
+
})
|
|
519
|
+
})
|
|
520
|
+
break
|
|
521
|
+
|
|
522
|
+
// 全部禁用
|
|
523
|
+
case 'statusDisable':
|
|
524
|
+
// 全部正常
|
|
525
|
+
case 'statusNormal':
|
|
526
|
+
|
|
527
|
+
if (! _.get(o.menuStatus, 'value.allRoleBtn.status.url')) {
|
|
528
|
+
console.error('没有找到状态地址')
|
|
529
|
+
return
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// 确认菜单
|
|
533
|
+
confirmMenu(async function() {
|
|
534
|
+
|
|
535
|
+
// 设置状态 ids
|
|
536
|
+
const statusIds = [ o.node.id ]
|
|
537
|
+
|
|
538
|
+
// 新状态
|
|
539
|
+
const newStatus = o.type === 'statusNormal' ? 1 : 0
|
|
540
|
+
|
|
541
|
+
// 是否叶子节点
|
|
542
|
+
const isLeafNode = ! o.node.children.length
|
|
543
|
+
|
|
544
|
+
// 如果复制的是父级节点
|
|
545
|
+
if (! isLeafNode) {
|
|
546
|
+
getChildren(o.node.children, function(item) {
|
|
547
|
+
statusIds.push(item.id)
|
|
548
|
+
})
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// 请求 - 全部禁用/正常
|
|
552
|
+
const { status } = await utils.http({
|
|
553
|
+
url: o.menuStatus.value.allRoleBtn.status.url,
|
|
554
|
+
data: {
|
|
555
|
+
// ids
|
|
556
|
+
ids: statusIds,
|
|
557
|
+
// 新状态值
|
|
558
|
+
status: newStatus,
|
|
559
|
+
},
|
|
560
|
+
})
|
|
561
|
+
if (! status) {
|
|
562
|
+
return
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// 设置当前节点状态
|
|
566
|
+
o.node.attr.status = newStatus
|
|
567
|
+
|
|
568
|
+
// 如果是父级节点
|
|
569
|
+
if (! isLeafNode) {
|
|
570
|
+
getChildren(o.node.children, function(item) {
|
|
571
|
+
item.attr.status = newStatus
|
|
572
|
+
})
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// 轻提示
|
|
576
|
+
utils.toast({
|
|
577
|
+
type: 'positive',
|
|
578
|
+
message: '恭喜您,操作成功',
|
|
579
|
+
})
|
|
580
|
+
})
|
|
581
|
+
break
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* 获取展开节点缓存
|
|
587
|
+
*/
|
|
588
|
+
function getExpandedCache(defaultValue = []) {
|
|
589
|
+
// 获取展开节点缓存
|
|
590
|
+
const res = utils.storage.get('tree_expanded_' + url)
|
|
591
|
+
return utils.isValidArray(res) ? res : defaultValue
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* 设置展开节点缓存
|
|
596
|
+
*/
|
|
597
|
+
function setExpandedCache(expanded) {
|
|
598
|
+
// 设置展开节点缓存(永久缓存)
|
|
599
|
+
utils.storage.set('tree_expanded_' + url, expanded, 0)
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
return {
|
|
603
|
+
// 当前地址
|
|
604
|
+
url,
|
|
605
|
+
// 获取节点
|
|
606
|
+
getNode,
|
|
607
|
+
// 更新节点
|
|
608
|
+
updateNode,
|
|
609
|
+
// 删除节点
|
|
610
|
+
deleteNode,
|
|
611
|
+
// 获取菜单状态
|
|
612
|
+
getMenuStatus,
|
|
613
|
+
// 菜单点击
|
|
614
|
+
menuClick,
|
|
615
|
+
// 获取展开节点缓存
|
|
616
|
+
getExpandedCache,
|
|
617
|
+
// 设置展开节点缓存
|
|
618
|
+
setExpandedCache,
|
|
619
|
+
}
|
|
620
|
+
}
|