@netang/quasar 0.0.29 → 0.0.30
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.
|
@@ -182,11 +182,8 @@ export default {
|
|
|
182
182
|
data: Object,
|
|
183
183
|
// 已选数据
|
|
184
184
|
selected: Array,
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
type: Boolean,
|
|
188
|
-
default: true,
|
|
189
|
-
},
|
|
185
|
+
// 初始时不加载选择数据
|
|
186
|
+
noLoadSelected: Boolean,
|
|
190
187
|
// 值字段(必填)
|
|
191
188
|
valueKey: {
|
|
192
189
|
type: String,
|
|
@@ -233,6 +230,11 @@ export default {
|
|
|
233
230
|
type: [ Number, String ],
|
|
234
231
|
default: 500
|
|
235
232
|
},
|
|
233
|
+
// 值分隔符(值为非数组有效)
|
|
234
|
+
valueSeparator: {
|
|
235
|
+
type: String,
|
|
236
|
+
default: ',',
|
|
237
|
+
},
|
|
236
238
|
},
|
|
237
239
|
|
|
238
240
|
/**
|
|
@@ -324,7 +326,7 @@ export default {
|
|
|
324
326
|
// 选择类型, 可选值 single multiple none
|
|
325
327
|
selection: props.multiple ? 'multiple' : 'single',
|
|
326
328
|
// 已选数据
|
|
327
|
-
selected:
|
|
329
|
+
selected: initSelected(),
|
|
328
330
|
// http 设置
|
|
329
331
|
httpSettings: {
|
|
330
332
|
// 头部请求
|
|
@@ -340,6 +342,12 @@ export default {
|
|
|
340
342
|
// 创建防抖睡眠方法
|
|
341
343
|
const sleep = utils.debounceSleep()
|
|
342
344
|
|
|
345
|
+
// 停止观察值
|
|
346
|
+
let stopValueWatcher = false
|
|
347
|
+
|
|
348
|
+
// 停止观察已选数据
|
|
349
|
+
let stopSelectedWatcher = false
|
|
350
|
+
|
|
343
351
|
// 输入框节点
|
|
344
352
|
const inputRef = ref(null)
|
|
345
353
|
|
|
@@ -374,54 +382,76 @@ export default {
|
|
|
374
382
|
*/
|
|
375
383
|
watch(()=>props.modelValue, async function() {
|
|
376
384
|
|
|
385
|
+
// 如果停止观察值
|
|
386
|
+
if (stopValueWatcher === true) {
|
|
387
|
+
// 取消停止观察值
|
|
388
|
+
stopValueWatcher = false
|
|
389
|
+
return
|
|
390
|
+
}
|
|
391
|
+
|
|
377
392
|
// 格式化值
|
|
378
393
|
let values = formatModelValue()
|
|
379
394
|
|
|
380
|
-
//
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
395
|
+
// 如果值是有效数组
|
|
396
|
+
if (utils.isValidArray(values)) {
|
|
397
|
+
|
|
398
|
+
// 去重
|
|
399
|
+
values = _.uniq(values)
|
|
400
|
+
|
|
401
|
+
// 已选数据值数组
|
|
402
|
+
const selectedValues = utils.isValidArray(selected.value)
|
|
403
|
+
// 如果有已选数据
|
|
404
|
+
? _.uniq(selected.value.map(e => e[props.valueKey]))
|
|
405
|
+
// 否则为空
|
|
406
|
+
: []
|
|
407
|
+
|
|
408
|
+
// 需增删除的值
|
|
409
|
+
const removeValues = selectedValues.filter(e => values.indexOf(e) === -1)
|
|
410
|
+
if (removeValues.length) {
|
|
411
|
+
utils.forEachRight(selected.value, function (item, index) {
|
|
412
|
+
if (removeValues.indexOf(item[props.valueKey]) > -1) {
|
|
413
|
+
selected.value.splice(index, 1)
|
|
414
|
+
}
|
|
415
|
+
})
|
|
416
|
+
}
|
|
387
417
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
418
|
+
// 需增加的值
|
|
419
|
+
const addValues = values.filter(e => selectedValues.indexOf(e) === -1)
|
|
420
|
+
if (addValues.length) {
|
|
421
|
+
// 请求选择数据
|
|
422
|
+
selected.value.push(...await onRequestSelected(addValues))
|
|
423
|
+
}
|
|
394
424
|
|
|
395
|
-
//
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
if (removeValues.indexOf(item[props.valueKey]) > -1) {
|
|
400
|
-
selected.value.splice(index, 1)
|
|
401
|
-
}
|
|
402
|
-
})
|
|
425
|
+
// 否则
|
|
426
|
+
} else {
|
|
427
|
+
// 清空已选数据
|
|
428
|
+
selected.value = []
|
|
403
429
|
}
|
|
404
430
|
|
|
405
|
-
//
|
|
406
|
-
|
|
407
|
-
if (addValues.length) {
|
|
408
|
-
// 请求选择数据
|
|
409
|
-
selected.value.push(...await onRequestSelected(addValues))
|
|
410
|
-
}
|
|
431
|
+
// 检查值更新
|
|
432
|
+
checkModelValueChange()
|
|
411
433
|
})
|
|
412
434
|
|
|
413
435
|
/**
|
|
414
436
|
* 监听声明选择数据
|
|
415
437
|
*/
|
|
416
438
|
watch(()=>props.selected, function(val) {
|
|
439
|
+
|
|
440
|
+
// 如果停止观察已选数据
|
|
441
|
+
if (stopSelectedWatcher === true) {
|
|
442
|
+
// 取消停止观察已选数据
|
|
443
|
+
stopSelectedWatcher = false
|
|
444
|
+
return
|
|
445
|
+
}
|
|
446
|
+
|
|
417
447
|
if (val !== selected.value) {
|
|
418
448
|
// 设置选择数据
|
|
419
449
|
selected.value = val
|
|
420
|
-
|
|
421
|
-
// 检查值更新
|
|
422
|
-
checkModelValueChange()
|
|
423
450
|
}
|
|
424
451
|
|
|
452
|
+
// 检查值更新
|
|
453
|
+
checkModelValueChange()
|
|
454
|
+
|
|
425
455
|
// 设置输入框焦点
|
|
426
456
|
setInputFocus()
|
|
427
457
|
|
|
@@ -437,15 +467,19 @@ export default {
|
|
|
437
467
|
* 监听当前已选数据
|
|
438
468
|
*/
|
|
439
469
|
watch(selected, function(val) {
|
|
470
|
+
|
|
440
471
|
if (val !== props.selected) {
|
|
441
472
|
|
|
473
|
+
// 停止观察已选数据
|
|
474
|
+
stopSelectedWatcher = true
|
|
475
|
+
|
|
442
476
|
// 更新选择数据
|
|
443
477
|
emit('update:selected', val)
|
|
444
|
-
|
|
445
|
-
// 检查值更新
|
|
446
|
-
checkModelValueChange()
|
|
447
478
|
}
|
|
448
479
|
|
|
480
|
+
// 检查值更新
|
|
481
|
+
checkModelValueChange()
|
|
482
|
+
|
|
449
483
|
// 设置输入框焦点
|
|
450
484
|
setInputFocus()
|
|
451
485
|
|
|
@@ -504,6 +538,36 @@ export default {
|
|
|
504
538
|
|
|
505
539
|
// ==========【方法】=============================================================================================
|
|
506
540
|
|
|
541
|
+
/**
|
|
542
|
+
* 初始化已选数据
|
|
543
|
+
*/
|
|
544
|
+
function initSelected() {
|
|
545
|
+
|
|
546
|
+
// 如果有已选数据
|
|
547
|
+
if (utils.isValidArray(props.selected)) {
|
|
548
|
+
|
|
549
|
+
// 则返回已选数据
|
|
550
|
+
return props.selected
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// 如果初始时不加载选择数据
|
|
554
|
+
if (props.noLoadSelected) {
|
|
555
|
+
|
|
556
|
+
// 将值格式化为已选数据数组
|
|
557
|
+
const vals = formatModelValue()
|
|
558
|
+
if (utils.isValidArray(vals)) {
|
|
559
|
+
return vals.map(function (val) {
|
|
560
|
+
const obj = {}
|
|
561
|
+
obj[props.valueKey] = val
|
|
562
|
+
obj[currentlabelKey.value] = val
|
|
563
|
+
return obj
|
|
564
|
+
})
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return []
|
|
569
|
+
}
|
|
570
|
+
|
|
507
571
|
/**
|
|
508
572
|
* 当前格式化显示标签
|
|
509
573
|
*/
|
|
@@ -527,7 +591,8 @@ export default {
|
|
|
527
591
|
}
|
|
528
592
|
|
|
529
593
|
// 否则值是字符串/数字
|
|
530
|
-
return utils.split(props.modelValue,
|
|
594
|
+
return _.uniq(utils.split(props.modelValue, props.valueSeparator))
|
|
595
|
+
.filter(e => utils.isValidValue(e))
|
|
531
596
|
}
|
|
532
597
|
|
|
533
598
|
/**
|
|
@@ -575,7 +640,7 @@ export default {
|
|
|
575
640
|
|
|
576
641
|
if (
|
|
577
642
|
// 如果初始不加载选择数据
|
|
578
|
-
|
|
643
|
+
props.noLoadSelected
|
|
579
644
|
// 如果没有请求路由路径
|
|
580
645
|
|| ! routePath
|
|
581
646
|
// 如果有选择数据
|
|
@@ -617,11 +682,14 @@ export default {
|
|
|
617
682
|
|
|
618
683
|
// 如果值为字符串或数字
|
|
619
684
|
if (! props.valueArray) {
|
|
620
|
-
newModelValue = utils.numberDeep(utils.join(newModelValue,
|
|
685
|
+
newModelValue = utils.numberDeep(utils.join(newModelValue, props.valueSeparator))
|
|
621
686
|
}
|
|
622
687
|
|
|
623
688
|
// 如果值发生改变
|
|
624
|
-
if (
|
|
689
|
+
if (newModelValue !== props.modelValue) {
|
|
690
|
+
|
|
691
|
+
// 停止观察值
|
|
692
|
+
stopValueWatcher = true
|
|
625
693
|
|
|
626
694
|
// 提交更新值
|
|
627
695
|
emit('update:modelValue', newModelValue)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<q-input
|
|
3
|
+
v-model="currentValue"
|
|
4
|
+
@blur="onBlur"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
>
|
|
7
|
+
<!-- 插槽 -->
|
|
8
|
+
<template
|
|
9
|
+
v-for="slotName in slotNames"
|
|
10
|
+
v-slot:[slotName]
|
|
11
|
+
>
|
|
12
|
+
<slot :name="slotName" />
|
|
13
|
+
</template>
|
|
14
|
+
</q-input>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import { computed, ref, watch } from 'vue'
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 标识
|
|
24
|
+
*/
|
|
25
|
+
name: 'NInputFormat',
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 声明属性
|
|
29
|
+
*/
|
|
30
|
+
props: {
|
|
31
|
+
// 值
|
|
32
|
+
modelValue: {
|
|
33
|
+
required: false,
|
|
34
|
+
},
|
|
35
|
+
// 格式化值
|
|
36
|
+
format: [Function, String],
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 声明事件
|
|
41
|
+
*/
|
|
42
|
+
emits: [
|
|
43
|
+
'update:modelValue',
|
|
44
|
+
'blur',
|
|
45
|
+
],
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 组合式
|
|
49
|
+
*/
|
|
50
|
+
setup(props, { emit, slots }) {
|
|
51
|
+
|
|
52
|
+
// ==========【计算属性】=========================================================================================
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 插槽标识
|
|
56
|
+
*/
|
|
57
|
+
const slotNames = computed(function() {
|
|
58
|
+
return utils.isValidObject(slots) ? Object.keys(slots) : []
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// ==========【数据】============================================================================================
|
|
62
|
+
|
|
63
|
+
// 当前值
|
|
64
|
+
const currentValue = ref(props.modelValue)
|
|
65
|
+
|
|
66
|
+
// ==========【监听数据】=========================================================================================
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 监听声明值
|
|
70
|
+
*/
|
|
71
|
+
watch(()=>props.modelValue, function (val) {
|
|
72
|
+
currentValue.value = val
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// ==========【方法】=============================================================================================
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 失去焦点触发
|
|
79
|
+
*/
|
|
80
|
+
function onBlur() {
|
|
81
|
+
|
|
82
|
+
let val = currentValue.value
|
|
83
|
+
|
|
84
|
+
if (
|
|
85
|
+
props.format
|
|
86
|
+
&& _.isFunction(props.format)
|
|
87
|
+
) {
|
|
88
|
+
val = props.format(val)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 更新值
|
|
92
|
+
emit('update:modelValue', val)
|
|
93
|
+
|
|
94
|
+
// 失去焦点触发
|
|
95
|
+
emit('blur', val)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ==========【返回】=============================================================================================
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
// 插槽标识
|
|
102
|
+
slotNames,
|
|
103
|
+
// 当前值
|
|
104
|
+
currentValue,
|
|
105
|
+
|
|
106
|
+
// 失去焦点触发
|
|
107
|
+
onBlur,
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
</script>
|
|
@@ -10,25 +10,49 @@
|
|
|
10
10
|
|
|
11
11
|
<template v-if="dataType">
|
|
12
12
|
|
|
13
|
-
<!--
|
|
14
|
-
<
|
|
13
|
+
<!-- 新窗口有效 -->
|
|
14
|
+
<template v-if="dataType === dicts.POWER_DATA_TYPE__OPEN">
|
|
15
15
|
|
|
16
|
-
<!--
|
|
17
|
-
<
|
|
18
|
-
class="n-field-fieldset"
|
|
19
|
-
label="跳转页面"
|
|
20
|
-
outlined
|
|
21
|
-
clearable
|
|
22
|
-
stack-label
|
|
23
|
-
dense
|
|
16
|
+
<!-- 设置跳转页面(没有路由类型) -->
|
|
17
|
+
<div class="col-xs-12 col-sm-6 col-md-3" v-if="routeType === 0">
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
<!-- 树 -->
|
|
20
|
+
<n-field-tree
|
|
21
|
+
class="n-field-fieldset"
|
|
22
|
+
label="跳转页面"
|
|
23
|
+
outlined
|
|
24
|
+
clearable
|
|
25
|
+
stack-label
|
|
26
|
+
dense
|
|
27
|
+
|
|
28
|
+
v-model="formData.toPage"
|
|
29
|
+
:nodes="treeNodes"
|
|
30
|
+
:expanded="treeExpanded"
|
|
31
|
+
strict
|
|
32
|
+
accordion
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<!-- 是否记录来源页面 -->
|
|
37
|
+
<div class="col-xs-12 col-sm-6 col-md-3">
|
|
38
|
+
<q-select
|
|
39
|
+
class="n-field-fieldset"
|
|
40
|
+
label="是否增加来源页面参数"
|
|
41
|
+
v-model="formData.addFromPageQuery"
|
|
42
|
+
:options="[
|
|
43
|
+
{ label: '否', value: false },
|
|
44
|
+
{ label: '是', value: true },
|
|
45
|
+
]"
|
|
46
|
+
map-options
|
|
47
|
+
emit-value
|
|
48
|
+
outlined
|
|
49
|
+
stack-label
|
|
50
|
+
dense
|
|
51
|
+
options-dense
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
</template>
|
|
32
56
|
|
|
33
57
|
<!-- 非表单显示 -->
|
|
34
58
|
<template v-if="dataType !== dicts.POWER_DATA_TYPE__FORM">
|
|
@@ -138,16 +162,16 @@
|
|
|
138
162
|
[
|
|
139
163
|
{ label: '无', value: '' },
|
|
140
164
|
{ label: '关闭窗口', value: 'close' },
|
|
141
|
-
{ label: '
|
|
142
|
-
{ label: '
|
|
165
|
+
{ label: '关闭窗口并跳转来源页面', value: 'closePush' },
|
|
166
|
+
{ label: '关闭窗口、跳转并刷新来源页面', value: 'closePushRefresh' },
|
|
143
167
|
{ label: '重置表单', value: 'resetForm' },
|
|
144
168
|
] :
|
|
145
169
|
[
|
|
146
170
|
{ label: '无', value: '' },
|
|
147
171
|
{ label: '关闭窗口', value: 'close' },
|
|
148
|
-
{ label: '
|
|
149
|
-
{ label: '
|
|
150
|
-
{ label: '
|
|
172
|
+
{ label: '关闭窗口并跳转来源页面', value: 'closePush' },
|
|
173
|
+
{ label: '关闭窗口、跳转并刷新来源页面', value: 'closePushRefresh' },
|
|
174
|
+
{ label: '刷新列表', value: 'refreshTable' },
|
|
151
175
|
]
|
|
152
176
|
"
|
|
153
177
|
map-options
|
|
@@ -160,31 +184,31 @@
|
|
|
160
184
|
</div>
|
|
161
185
|
|
|
162
186
|
<!-- 请求成功参数 -->
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
187
|
+
<!--<div class="col-xs-12 col-sm-6 col-md-3" v-if="utils.indexOf(['closePush', 'closePushRefresh'], formData.requestSuccess.type) > -1">-->
|
|
188
|
+
|
|
189
|
+
<!-- <!– 树 –>-->
|
|
190
|
+
<!-- <n-field-tree-->
|
|
191
|
+
<!-- class="n-field-fieldset"-->
|
|
192
|
+
<!-- label="跳转页面"-->
|
|
193
|
+
<!-- outlined-->
|
|
194
|
+
<!-- clearable-->
|
|
195
|
+
<!-- stack-label-->
|
|
196
|
+
<!-- dense-->
|
|
197
|
+
|
|
198
|
+
<!-- v-model="formData.requestSuccess.params"-->
|
|
199
|
+
<!-- :nodes="treeNodes"-->
|
|
200
|
+
<!-- :expanded="treeExpanded"-->
|
|
201
|
+
<!-- strict-->
|
|
202
|
+
<!-- accordion-->
|
|
203
|
+
<!-- />-->
|
|
204
|
+
<!--</div>-->
|
|
181
205
|
|
|
182
206
|
</template>
|
|
183
207
|
|
|
184
208
|
<template v-if="dataType !== dicts.POWER_DATA_TYPE__FORM">
|
|
185
209
|
|
|
186
210
|
<!-- 栏目标题 -->
|
|
187
|
-
<n-column-title label="
|
|
211
|
+
<n-column-title label="请求列表参数" tooltip='示例:id / sku_id AS sku' />
|
|
188
212
|
|
|
189
213
|
<!-- 表格请求参数 -->
|
|
190
214
|
<div class="col-xs-12">
|
|
@@ -274,9 +298,6 @@
|
|
|
274
298
|
<script>
|
|
275
299
|
import { ref, watch } from 'vue'
|
|
276
300
|
|
|
277
|
-
import _isString from 'lodash/isString'
|
|
278
|
-
import _isPlainObject from 'lodash/isPlainObject'
|
|
279
|
-
|
|
280
301
|
export default {
|
|
281
302
|
|
|
282
303
|
/**
|
|
@@ -353,24 +374,12 @@ export default {
|
|
|
353
374
|
}
|
|
354
375
|
}
|
|
355
376
|
|
|
356
|
-
//
|
|
357
|
-
|
|
358
|
-
_.has(obj, 'requestSuccess')
|
|
359
|
-
&& ! utils.isValidObject(obj.requestSuccess)
|
|
360
|
-
) {
|
|
361
|
-
delete(obj.requestSuccess)
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
if (
|
|
365
|
-
_.has(obj, 'requestQuery')
|
|
366
|
-
&& ! utils.isValidObject(obj.requestQuery)
|
|
367
|
-
) {
|
|
368
|
-
delete(obj.requestQuery)
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
obj = _.merge({
|
|
377
|
+
// 原始数据默认值
|
|
378
|
+
const rawObj = {
|
|
372
379
|
// 显示类型, 可选 single / multi / 空(默认显示)
|
|
373
380
|
show: '',
|
|
381
|
+
// 是否增加来源页面参数
|
|
382
|
+
addFromPageQuery: false,
|
|
374
383
|
// 跳转页面 id
|
|
375
384
|
toPage: '',
|
|
376
385
|
// 是否固定列
|
|
@@ -386,7 +395,7 @@ export default {
|
|
|
386
395
|
// 表格: 字符串组成的数组, 如: [ "id", "sku_id AS sku" ]
|
|
387
396
|
table: [],
|
|
388
397
|
// 参数: 字符串 / 对象(自定义参数) 组成的数组, 如: [ "id", "sku_id AS sku", { "type": 1, "name": "age" } ]
|
|
389
|
-
|
|
398
|
+
query: null,
|
|
390
399
|
},
|
|
391
400
|
// 请求成功执行
|
|
392
401
|
requestSuccess: {
|
|
@@ -396,8 +405,38 @@ export default {
|
|
|
396
405
|
params: '',
|
|
397
406
|
},
|
|
398
407
|
// 自定义参数, 任意类型
|
|
399
|
-
|
|
400
|
-
}
|
|
408
|
+
params: '',
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// 【格式化数据】删除无效键值
|
|
412
|
+
// --------------------------------------------------
|
|
413
|
+
|
|
414
|
+
// 原始键值
|
|
415
|
+
const rawKeys = Object.keys(rawObj)
|
|
416
|
+
|
|
417
|
+
// 删除数据中的无效键值
|
|
418
|
+
utils.forIn(obj, function (item, key) {
|
|
419
|
+
// 如果键值不在原始键值中
|
|
420
|
+
if (rawKeys.indexOf(key) === -1) {
|
|
421
|
+
// 则删除
|
|
422
|
+
delete obj[key]
|
|
423
|
+
}
|
|
424
|
+
})
|
|
425
|
+
|
|
426
|
+
// 判断 requestSuccess 值是否合法
|
|
427
|
+
if (_.has(obj, 'requestSuccess') && ! utils.isValidObject(obj.requestSuccess)) {
|
|
428
|
+
delete(obj.requestSuccess)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// 判断 requestQuery 值是否合法
|
|
432
|
+
if (_.has(obj, 'requestQuery') && ! utils.isValidObject(obj.requestQuery)) {
|
|
433
|
+
delete(obj.requestQuery)
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// --------------------------------------------------
|
|
437
|
+
|
|
438
|
+
// 合并原始数据
|
|
439
|
+
obj = Object.assign(rawObj, obj)
|
|
401
440
|
|
|
402
441
|
// 【格式化是否确认参数】
|
|
403
442
|
// ------------------------------------------------------------
|
|
@@ -430,15 +469,16 @@ export default {
|
|
|
430
469
|
// 【格式化请求参数中的 query】
|
|
431
470
|
// ------------------------------------------------------------
|
|
432
471
|
if (_.has(obj.requestQuery, 'query')) {
|
|
472
|
+
|
|
433
473
|
// 如果是有效值
|
|
434
474
|
if (utils.isValidValue(obj.requestQuery.query)) {
|
|
435
475
|
obj.requestQuery.query = [obj.requestQuery.query]
|
|
436
476
|
|
|
437
|
-
//
|
|
477
|
+
// 如果是有效对象
|
|
438
478
|
} else if (utils.isValidObject(obj.requestQuery.query)) {
|
|
439
479
|
obj.requestQuery.query = [utils.json.stringify(obj.requestQuery.query)]
|
|
440
480
|
|
|
441
|
-
//
|
|
481
|
+
// 如果是有效数组
|
|
442
482
|
} else if (utils.isValidArray(obj.requestQuery.query)) {
|
|
443
483
|
const query = []
|
|
444
484
|
utils.forEach(obj.requestQuery.query, function(item, key) {
|
|
@@ -513,7 +553,7 @@ export default {
|
|
|
513
553
|
// 如果为表格
|
|
514
554
|
if (field === 'table') {
|
|
515
555
|
|
|
516
|
-
if (Array.isArray(value) ||
|
|
556
|
+
if (Array.isArray(value) || _.isPlainObject(value)) {
|
|
517
557
|
|
|
518
558
|
// 轻提示
|
|
519
559
|
utils.toast({
|
|
@@ -555,7 +595,7 @@ export default {
|
|
|
555
595
|
) {
|
|
556
596
|
value = utils.json.parse(value)
|
|
557
597
|
|
|
558
|
-
if (! Array.isArray(value) && !
|
|
598
|
+
if (! Array.isArray(value) && ! _.isPlainObject(value)) {
|
|
559
599
|
return ''
|
|
560
600
|
}
|
|
561
601
|
}
|
|
@@ -611,6 +651,11 @@ export default {
|
|
|
611
651
|
obj.toPage = data.toPage
|
|
612
652
|
}
|
|
613
653
|
|
|
654
|
+
// 如果增加来源页面参数
|
|
655
|
+
if (data.addFromPageQuery) {
|
|
656
|
+
obj.addFromPageQuery = true
|
|
657
|
+
}
|
|
658
|
+
|
|
614
659
|
// 否则为其他
|
|
615
660
|
} else {
|
|
616
661
|
|
|
@@ -632,13 +677,13 @@ export default {
|
|
|
632
677
|
obj.requestSuccess = {
|
|
633
678
|
type: data.requestSuccess.type
|
|
634
679
|
}
|
|
635
|
-
if (utils.indexOf(['closePush', 'closePushRefresh'], data.requestSuccess.type) > -1) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}
|
|
680
|
+
// if (utils.indexOf(['closePush', 'closePushRefresh'], data.requestSuccess.type) > -1) {
|
|
681
|
+
// if (data.requestSuccess.params) {
|
|
682
|
+
// obj.requestSuccess.params = data.requestSuccess.params
|
|
683
|
+
// } else {
|
|
684
|
+
// obj.requestSuccess.type = 'close'
|
|
685
|
+
// }
|
|
686
|
+
// }
|
|
642
687
|
}
|
|
643
688
|
}
|
|
644
689
|
|
package/package.json
CHANGED
package/utils/$power.js
CHANGED
|
@@ -221,6 +221,8 @@ function create(params) {
|
|
|
221
221
|
await request({
|
|
222
222
|
// 按钮数据
|
|
223
223
|
data,
|
|
224
|
+
// 当前路由参数
|
|
225
|
+
$route,
|
|
224
226
|
// 表格选中数据
|
|
225
227
|
tableSelected,
|
|
226
228
|
// 表格实例
|
|
@@ -399,21 +401,22 @@ function setData(data) {
|
|
|
399
401
|
if (_.has(item.data, 'toPage')) {
|
|
400
402
|
// 设置跳转页面地址
|
|
401
403
|
item.data.toPage = _.has(all, item.data.toPage) ? all[item.data.toPage].data.url : null
|
|
404
|
+
}
|
|
402
405
|
|
|
403
406
|
// 如果有请求成功执行类型
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
407
|
+
// else if (_.has(item.data, 'requestSuccess.type')) {
|
|
408
|
+
// // 如果请求成功执行类型是关闭窗口、跳转并刷新页面
|
|
409
|
+
// if (item.data.requestSuccess.type === 'closePushRefresh') {
|
|
410
|
+
// // 设置刷新页面地址
|
|
411
|
+
// item.data.requestSuccess.params =
|
|
412
|
+
// (
|
|
413
|
+
// // 如果有刷新页面的参数 id
|
|
414
|
+
// _.has(item.data.requestSuccess, 'params')
|
|
415
|
+
// // 如果有页面数据
|
|
416
|
+
// && _.has(all, item.data.requestSuccess.params)
|
|
417
|
+
// ) ? all[item.data.requestSuccess.params].data.url : null
|
|
418
|
+
// }
|
|
419
|
+
// }
|
|
417
420
|
|
|
418
421
|
if (
|
|
419
422
|
// 数据/按钮
|
|
@@ -722,8 +725,6 @@ async function request(params) {
|
|
|
722
725
|
const o = Object.assign({
|
|
723
726
|
// 按钮数据
|
|
724
727
|
data: {},
|
|
725
|
-
// 参数
|
|
726
|
-
query: {},
|
|
727
728
|
// 表格选中数据
|
|
728
729
|
tableSelected: [],
|
|
729
730
|
// 检查是否正在上传文件
|
|
@@ -738,6 +739,12 @@ async function request(params) {
|
|
|
738
739
|
requestAfter: null,
|
|
739
740
|
}, params)
|
|
740
741
|
|
|
742
|
+
const {
|
|
743
|
+
$route,
|
|
744
|
+
} = params
|
|
745
|
+
|
|
746
|
+
o.query = $route.query
|
|
747
|
+
|
|
741
748
|
// 判断类型
|
|
742
749
|
if (! _.get(o.data, 'type')) {
|
|
743
750
|
|
|
@@ -778,7 +785,7 @@ async function request(params) {
|
|
|
778
785
|
}
|
|
779
786
|
|
|
780
787
|
// 获取请求参数
|
|
781
|
-
|
|
788
|
+
let query = getRequestQuery(o)
|
|
782
789
|
|
|
783
790
|
// 如果是打开新窗口
|
|
784
791
|
// --------------------------------------------------
|
|
@@ -789,9 +796,16 @@ async function request(params) {
|
|
|
789
796
|
return
|
|
790
797
|
}
|
|
791
798
|
|
|
799
|
+
query = formatQuery(query, true)
|
|
800
|
+
|
|
801
|
+
// 如果有增加来源页面参数
|
|
802
|
+
if (_.get(o.data, 'addFromPageQuery') === true) {
|
|
803
|
+
query.n_frompage = encodeURIComponent($route.fullPath)
|
|
804
|
+
}
|
|
805
|
+
|
|
792
806
|
utils.router.push({
|
|
793
807
|
path: o.data.url,
|
|
794
|
-
query
|
|
808
|
+
query,
|
|
795
809
|
})
|
|
796
810
|
return
|
|
797
811
|
}
|
|
@@ -929,14 +943,24 @@ async function request(params) {
|
|
|
929
943
|
type: 'closeCurrentTab',
|
|
930
944
|
}
|
|
931
945
|
|
|
932
|
-
|
|
933
|
-
|
|
946
|
+
if (
|
|
947
|
+
// 如果不是关闭当前页面, 则为关闭窗口并跳转页面
|
|
948
|
+
o.data.requestSuccess.type !== 'close'
|
|
949
|
+
// 如果有来源页面
|
|
950
|
+
&& _.has($route.query, 'n_frompage')
|
|
951
|
+
&& utils.isValidString($route.query.n_frompage)
|
|
952
|
+
) {
|
|
934
953
|
Object.assign(opts, {
|
|
935
954
|
// 跳转页面地址
|
|
936
|
-
pushPage:
|
|
955
|
+
pushPage: decodeURIComponent($route.query.n_frompage),
|
|
937
956
|
// 是否跳转并刷新页面
|
|
938
957
|
isPushRefresh: o.data.requestSuccess.type === 'closePushRefresh',
|
|
939
958
|
})
|
|
959
|
+
|
|
960
|
+
// 否则如果定义了跳转页面
|
|
961
|
+
// else if (_.has(o.data, 'requestSuccess.params') && utils.isValidString(o.data.requestSuccess.params)) {
|
|
962
|
+
// pushPage = o.data.requestSuccess.params
|
|
963
|
+
// }
|
|
940
964
|
}
|
|
941
965
|
|
|
942
966
|
// 关闭当前标签页
|
package/utils/$table.js
CHANGED
|
@@ -102,7 +102,7 @@ function create(params) {
|
|
|
102
102
|
: (hasPowr ? $power.getRoute() : utils.router.getRoute())
|
|
103
103
|
|
|
104
104
|
// 是否有权限按钮
|
|
105
|
-
const hasPowerBtns = hasPowr ?
|
|
105
|
+
const hasPowerBtns = hasPowr ? $power.powerBtns.value.length : false
|
|
106
106
|
|
|
107
107
|
// 表格已选数据
|
|
108
108
|
const tableSelected = hasPowr ? $power.tableSelected : ref([])
|
|
@@ -897,7 +897,7 @@ function create(params) {
|
|
|
897
897
|
* 获取表格配置
|
|
898
898
|
*/
|
|
899
899
|
function config(routePath, path, defaultValue) {
|
|
900
|
-
return _.get(tablesConfig, utils.slash(routePath, 'start', false) + (path ? '.' + path : ''), defaultValue)
|
|
900
|
+
return _.cloneDeep(_.get(tablesConfig, utils.slash(routePath, 'start', false) + (path ? '.' + path : ''), defaultValue))
|
|
901
901
|
}
|
|
902
902
|
|
|
903
903
|
/**
|