@netang/quasar 0.0.107 → 0.1.9
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.
|
@@ -588,7 +588,6 @@ export default {
|
|
|
588
588
|
* 加载已选数据
|
|
589
589
|
*/
|
|
590
590
|
async function loadSelected() {
|
|
591
|
-
|
|
592
591
|
if (
|
|
593
592
|
// 如果值类型不是数组对象
|
|
594
593
|
props.valueType !== 'objectArray'
|
|
@@ -600,7 +599,6 @@ export default {
|
|
|
600
599
|
// 获取值数组
|
|
601
600
|
const values = valueToSelected(props.modelValue, false, false)
|
|
602
601
|
if (values.length) {
|
|
603
|
-
|
|
604
602
|
// 初始的已选数据
|
|
605
603
|
const _selected = await onRequestSelected(values)
|
|
606
604
|
const _value = selectedToValue(_selected)
|
|
@@ -791,7 +789,7 @@ export default {
|
|
|
791
789
|
}
|
|
792
790
|
),
|
|
793
791
|
// 是否开启防抖(防止重复请求)
|
|
794
|
-
debounce: false,
|
|
792
|
+
// debounce: false,
|
|
795
793
|
}
|
|
796
794
|
|
|
797
795
|
// 请求数据
|
|
@@ -56,6 +56,8 @@ export default {
|
|
|
56
56
|
props: {
|
|
57
57
|
// 组件标识
|
|
58
58
|
name: String,
|
|
59
|
+
// 组件
|
|
60
|
+
component: Object,
|
|
59
61
|
// 组件路径
|
|
60
62
|
path: String,
|
|
61
63
|
// 参数
|
|
@@ -86,8 +88,13 @@ export default {
|
|
|
86
88
|
|
|
87
89
|
// 如果有组件标识
|
|
88
90
|
} else if (props.name && $n_has(components, props.name)) {
|
|
89
|
-
//
|
|
91
|
+
// 设置自定义组件
|
|
90
92
|
comp = components[props.name]
|
|
93
|
+
|
|
94
|
+
// 如果有声明组件
|
|
95
|
+
} else if (props.component) {
|
|
96
|
+
// 设置声明组件
|
|
97
|
+
comp = props.component
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
// 如果没有组件
|
|
@@ -165,6 +165,7 @@
|
|
|
165
165
|
:options="tableSearchOptions"
|
|
166
166
|
:on-search="tableReload"
|
|
167
167
|
:on-reset="tableSearchReset"
|
|
168
|
+
v-if="showSearch"
|
|
168
169
|
>
|
|
169
170
|
<!-- 插槽 -->
|
|
170
171
|
<template
|
|
@@ -180,7 +181,7 @@
|
|
|
180
181
|
</template>
|
|
181
182
|
|
|
182
183
|
<script>
|
|
183
|
-
import { ref, watch, computed, inject } from 'vue'
|
|
184
|
+
import { ref, watch, computed, inject, onMounted } from 'vue'
|
|
184
185
|
|
|
185
186
|
import $n_isFunction from 'lodash/isFunction'
|
|
186
187
|
|
|
@@ -290,8 +291,6 @@ export default {
|
|
|
290
291
|
// 获取表格注入
|
|
291
292
|
const $table = inject(NTableKey)
|
|
292
293
|
|
|
293
|
-
// console.log('----$table222---', $table, $table.tableSearchValue.value)
|
|
294
|
-
|
|
295
294
|
// 获取对话框注入
|
|
296
295
|
const $dialog = inject(NDialogKey)
|
|
297
296
|
const inDialog = !! $dialog
|
|
@@ -327,6 +326,9 @@ export default {
|
|
|
327
326
|
// 树选择数据
|
|
328
327
|
const treeSelected = ref(null)
|
|
329
328
|
|
|
329
|
+
// 是否显示搜索
|
|
330
|
+
const showSearch = ref(false)
|
|
331
|
+
|
|
330
332
|
// ==========【计算属性】==========================================================================================
|
|
331
333
|
|
|
332
334
|
/**
|
|
@@ -432,6 +434,17 @@ export default {
|
|
|
432
434
|
})
|
|
433
435
|
}
|
|
434
436
|
|
|
437
|
+
// ==========【生命周期】=========================================================================================
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* 实例被挂载后调用
|
|
441
|
+
*/
|
|
442
|
+
onMounted( async function() {
|
|
443
|
+
|
|
444
|
+
// 显示搜索
|
|
445
|
+
showSearch.value = true
|
|
446
|
+
})
|
|
447
|
+
|
|
435
448
|
// ==========【返回】=============================================================================================
|
|
436
449
|
|
|
437
450
|
return {
|
|
@@ -444,6 +457,8 @@ export default {
|
|
|
444
457
|
treeFilterValue,
|
|
445
458
|
// 树选择数据
|
|
446
459
|
treeSelected,
|
|
460
|
+
// 是否显示搜索
|
|
461
|
+
showSearch,
|
|
447
462
|
|
|
448
463
|
// 插槽 body 单元格标识
|
|
449
464
|
slotNames,
|
|
@@ -1,360 +1,366 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<n-splitter
|
|
3
|
-
class="absolute-full"
|
|
4
|
-
v-model="currentValue"
|
|
5
|
-
:reverse="reverse"
|
|
6
|
-
:unit="unit"
|
|
7
|
-
:limits="limits"
|
|
8
|
-
:horizontal="horizontal"
|
|
9
|
-
|
|
10
|
-
v-model:after="currentAfter"
|
|
11
|
-
@update:after="setSelection"
|
|
12
|
-
:hide-after-in-mobile="hideAfterInMobile"
|
|
13
|
-
:cache="cache"
|
|
14
|
-
>
|
|
15
|
-
<!-- 表格 -->
|
|
16
|
-
<template v-slot:before="{ after, toggleAfter }">
|
|
17
|
-
<n-table
|
|
18
|
-
v-bind="$attrs"
|
|
19
|
-
>
|
|
20
|
-
<!-- 工具栏右边插槽(手机端不显示) -->
|
|
21
|
-
<template #toolbar-right v-if="isWatcher">
|
|
22
|
-
|
|
23
|
-
<!-- 工具栏右边插槽 -->
|
|
24
|
-
<slot name="toolbar-right" />
|
|
25
|
-
|
|
26
|
-
<!-- 是否显示详情 -->
|
|
27
|
-
<q-toggle
|
|
28
|
-
icon="apps"
|
|
29
|
-
:model-value="after"
|
|
30
|
-
@click="toggleAfter"
|
|
31
|
-
>
|
|
32
|
-
<q-tooltip anchor="center left" self="center right" :offset="[10, 0]">{{tooltip}}</q-tooltip>
|
|
33
|
-
</q-toggle>
|
|
34
|
-
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<!-- 插槽 -->
|
|
38
|
-
<template
|
|
39
|
-
v-for="slotName in slotNames"
|
|
40
|
-
v-slot:[slotName]="props"
|
|
41
|
-
>
|
|
42
|
-
<!-- 有传参的插槽 -->
|
|
43
|
-
<slot
|
|
44
|
-
:name="slotName"
|
|
45
|
-
v-bind="props"
|
|
46
|
-
v-if="props"
|
|
47
|
-
/>
|
|
48
|
-
|
|
49
|
-
<!-- 无传参的插槽 -->
|
|
50
|
-
<slot
|
|
51
|
-
:name="slotName"
|
|
52
|
-
v-else
|
|
53
|
-
/>
|
|
54
|
-
</template>
|
|
55
|
-
|
|
56
|
-
</n-table>
|
|
57
|
-
</template>
|
|
58
|
-
|
|
59
|
-
<!-- 渲染详情页面(手机端不显示) -->
|
|
60
|
-
<template v-slot:after>
|
|
61
|
-
|
|
62
|
-
<!-- 渲染 -->
|
|
63
|
-
<n-render
|
|
64
|
-
:
|
|
65
|
-
:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
</template>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
import
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
import
|
|
91
|
-
|
|
92
|
-
import
|
|
93
|
-
|
|
94
|
-
import
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
//
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
//
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
//
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
//
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
//
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
//
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<n-splitter
|
|
3
|
+
class="absolute-full"
|
|
4
|
+
v-model="currentValue"
|
|
5
|
+
:reverse="reverse"
|
|
6
|
+
:unit="unit"
|
|
7
|
+
:limits="limits"
|
|
8
|
+
:horizontal="horizontal"
|
|
9
|
+
|
|
10
|
+
v-model:after="currentAfter"
|
|
11
|
+
@update:after="setSelection"
|
|
12
|
+
:hide-after-in-mobile="hideAfterInMobile"
|
|
13
|
+
:cache="cache"
|
|
14
|
+
>
|
|
15
|
+
<!-- 表格 -->
|
|
16
|
+
<template v-slot:before="{ after, toggleAfter }">
|
|
17
|
+
<n-table
|
|
18
|
+
v-bind="$attrs"
|
|
19
|
+
>
|
|
20
|
+
<!-- 工具栏右边插槽(手机端不显示) -->
|
|
21
|
+
<template #toolbar-right v-if="isWatcher">
|
|
22
|
+
|
|
23
|
+
<!-- 工具栏右边插槽 -->
|
|
24
|
+
<slot name="toolbar-right" />
|
|
25
|
+
|
|
26
|
+
<!-- 是否显示详情 -->
|
|
27
|
+
<q-toggle
|
|
28
|
+
icon="apps"
|
|
29
|
+
:model-value="after"
|
|
30
|
+
@click="toggleAfter"
|
|
31
|
+
>
|
|
32
|
+
<q-tooltip anchor="center left" self="center right" :offset="[10, 0]">{{tooltip}}</q-tooltip>
|
|
33
|
+
</q-toggle>
|
|
34
|
+
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<!-- 插槽 -->
|
|
38
|
+
<template
|
|
39
|
+
v-for="slotName in slotNames"
|
|
40
|
+
v-slot:[slotName]="props"
|
|
41
|
+
>
|
|
42
|
+
<!-- 有传参的插槽 -->
|
|
43
|
+
<slot
|
|
44
|
+
:name="slotName"
|
|
45
|
+
v-bind="props"
|
|
46
|
+
v-if="props"
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<!-- 无传参的插槽 -->
|
|
50
|
+
<slot
|
|
51
|
+
:name="slotName"
|
|
52
|
+
v-else
|
|
53
|
+
/>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
</n-table>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<!-- 渲染详情页面(手机端不显示) -->
|
|
60
|
+
<template v-slot:after>
|
|
61
|
+
|
|
62
|
+
<!-- 渲染 -->
|
|
63
|
+
<n-render
|
|
64
|
+
:name="renderName"
|
|
65
|
+
:path="renderPath"
|
|
66
|
+
:component="renderComponent"
|
|
67
|
+
:query="currentQuery"
|
|
68
|
+
:props="renderProps"
|
|
69
|
+
v-if="currentQuery"
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<!-- 空状态 -->
|
|
73
|
+
<n-empty
|
|
74
|
+
:description="renderDescription"
|
|
75
|
+
fit
|
|
76
|
+
v-else
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
</template>
|
|
80
|
+
|
|
81
|
+
</n-splitter>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<script>
|
|
85
|
+
import { nextTick, ref, watch, computed, inject } from 'vue'
|
|
86
|
+
import { useQuasar } from 'quasar'
|
|
87
|
+
|
|
88
|
+
import $n_isFunction from 'lodash/isFunction'
|
|
89
|
+
|
|
90
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
91
|
+
|
|
92
|
+
import NSplitter from '../splitter'
|
|
93
|
+
import NTable from '../table'
|
|
94
|
+
import NRender from '../render'
|
|
95
|
+
import NEmpty from '../empty'
|
|
96
|
+
|
|
97
|
+
import { NTableKey } from '../../utils/symbols'
|
|
98
|
+
|
|
99
|
+
export default {
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 关闭组件 attribute 透传行为
|
|
103
|
+
*/
|
|
104
|
+
inheritAttrs: false,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 标识
|
|
108
|
+
*/
|
|
109
|
+
name: 'NTableSplitter',
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 组件
|
|
113
|
+
*/
|
|
114
|
+
components: {
|
|
115
|
+
NSplitter,
|
|
116
|
+
NTable,
|
|
117
|
+
NRender,
|
|
118
|
+
NEmpty,
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 声明属性
|
|
123
|
+
*/
|
|
124
|
+
props: {
|
|
125
|
+
// 值 v-model
|
|
126
|
+
modelValue: {
|
|
127
|
+
type: Number,
|
|
128
|
+
default: 50,
|
|
129
|
+
},
|
|
130
|
+
// 反转插槽
|
|
131
|
+
reverse: Boolean,
|
|
132
|
+
// 模型的 CSS 单位
|
|
133
|
+
unit: String,
|
|
134
|
+
// 两个值的数组,表示两个面板的最小和最大分割大小
|
|
135
|
+
limits: Array,
|
|
136
|
+
// 是否水平拆分
|
|
137
|
+
horizontal: Boolean,
|
|
138
|
+
|
|
139
|
+
// 显示后置插槽 v-model:after
|
|
140
|
+
// 注意: 如果非双向绑定, 如 :after 并不会影响内部值变化, 仅做初始值使用
|
|
141
|
+
after: {
|
|
142
|
+
type: Boolean,
|
|
143
|
+
default: true,
|
|
144
|
+
},
|
|
145
|
+
// 手机模式隐藏后插槽
|
|
146
|
+
hideAfterInMobile: {
|
|
147
|
+
type: Boolean,
|
|
148
|
+
default: true,
|
|
149
|
+
},
|
|
150
|
+
// 是否开启缓存
|
|
151
|
+
cache: {
|
|
152
|
+
type: [ Boolean, String ],
|
|
153
|
+
default: true,
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
// 工具提示
|
|
157
|
+
tooltip: {
|
|
158
|
+
type: String,
|
|
159
|
+
default: '是否显示详情',
|
|
160
|
+
},
|
|
161
|
+
// 渲染组件标识
|
|
162
|
+
renderName: String,
|
|
163
|
+
// 渲染组件路径
|
|
164
|
+
renderPath: String,
|
|
165
|
+
// 渲染组件的组件
|
|
166
|
+
renderComponent: Object,
|
|
167
|
+
// 格式化已选表格的数据并返回渲染组件参数
|
|
168
|
+
renderQuery: Function,
|
|
169
|
+
// 渲染组件的传参
|
|
170
|
+
renderProps: Object,
|
|
171
|
+
// 渲染空状态描述
|
|
172
|
+
renderDescription: {
|
|
173
|
+
type: String,
|
|
174
|
+
default: '没有找到任何数据',
|
|
175
|
+
},
|
|
176
|
+
// 不需要加载渲染页面标识参数
|
|
177
|
+
// 额外加载参数 { n_renderpage: 1 }
|
|
178
|
+
noRendPageName: Boolean,
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 声明事件
|
|
183
|
+
*/
|
|
184
|
+
emits: [
|
|
185
|
+
'update:modelValue',
|
|
186
|
+
'update:after',
|
|
187
|
+
],
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 组合式
|
|
191
|
+
*/
|
|
192
|
+
setup(props, { emit, slots }) {
|
|
193
|
+
|
|
194
|
+
// ==========【计算属性】=========================================================================================
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 插槽标识
|
|
198
|
+
*/
|
|
199
|
+
const slotNames = computed(function() {
|
|
200
|
+
return $n_isValidObject(slots) ? Object.keys(slots).filter(e => e !== 'toolbar-right') : []
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* 是否监听
|
|
205
|
+
*/
|
|
206
|
+
const isWatcher = computed(function () {
|
|
207
|
+
return ! props.hideAfterInMobile || ! $q.platform.is.mobile
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* 当前传参
|
|
212
|
+
*/
|
|
213
|
+
const currentQuery = computed(function() {
|
|
214
|
+
|
|
215
|
+
// 如果有已选数据
|
|
216
|
+
if (
|
|
217
|
+
currentSelectedItem.value
|
|
218
|
+
&& $n_isFunction(props.renderQuery)
|
|
219
|
+
) {
|
|
220
|
+
const resQuery = props.renderQuery(currentSelectedItem.value)
|
|
221
|
+
if ($n_isValidObject(resQuery)) {
|
|
222
|
+
|
|
223
|
+
// 如果需要加载渲染页面标识参数
|
|
224
|
+
if (! props.noRendPageName) {
|
|
225
|
+
// 格式化已选数据, 并返回参数
|
|
226
|
+
return Object.assign({}, resQuery, {
|
|
227
|
+
// 是否为渲染页面
|
|
228
|
+
n_renderpage: 1,
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return resQuery
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return null
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
// ==========【数据】=============================================================================================
|
|
240
|
+
|
|
241
|
+
// quasar 对象
|
|
242
|
+
const $q = useQuasar()
|
|
243
|
+
|
|
244
|
+
// 获取表格注入
|
|
245
|
+
const $table = inject(NTableKey)
|
|
246
|
+
|
|
247
|
+
// 原始表格选择状态
|
|
248
|
+
const rawTableSelection = $table.tableSelection.value
|
|
249
|
+
|
|
250
|
+
// 当前已选单条数据
|
|
251
|
+
const currentSelectedItem = ref(null)
|
|
252
|
+
|
|
253
|
+
// 当前值
|
|
254
|
+
const currentValue = ref(props.modelValue)
|
|
255
|
+
|
|
256
|
+
// 当前显示前置插槽
|
|
257
|
+
const currentAfter = ref(props.after)
|
|
258
|
+
|
|
259
|
+
// ==========【监听数据】=========================================================================================
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 监听声明值
|
|
263
|
+
*/
|
|
264
|
+
watch(() => props.modelValue, function (val) {
|
|
265
|
+
currentValue.value = val
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 监听声明显示前置插槽
|
|
270
|
+
*/
|
|
271
|
+
watch(() => props.after, function (val) {
|
|
272
|
+
currentAfter.value = val
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* 监听当前值
|
|
277
|
+
*/
|
|
278
|
+
watch(currentValue, function (val) {
|
|
279
|
+
emit('update:modelValue', val)
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* 监听当前显示前置插槽
|
|
284
|
+
*/
|
|
285
|
+
watch(currentAfter, function (val) {
|
|
286
|
+
emit('update:after', val)
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* 监听表格已选数据(非手机端有效)
|
|
291
|
+
*/
|
|
292
|
+
watch($table.tableSelected, async function (selected) {
|
|
293
|
+
|
|
294
|
+
// 先清空当前已选单条数据
|
|
295
|
+
currentSelectedItem.value = null
|
|
296
|
+
|
|
297
|
+
// 如果不监听
|
|
298
|
+
if (! isWatcher.value) {
|
|
299
|
+
|
|
300
|
+
// 则无需任何操作
|
|
301
|
+
return
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// 下次 DOM 更新
|
|
305
|
+
await nextTick()
|
|
306
|
+
|
|
307
|
+
// 如果有已选单条数据
|
|
308
|
+
if (selected.length === 1) {
|
|
309
|
+
|
|
310
|
+
// 设置当前已选数据
|
|
311
|
+
currentSelectedItem.value = selected[0]
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
}, {
|
|
315
|
+
// 深度监听
|
|
316
|
+
deep: true,
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
// ==========【方法】============================================================================================
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* 设置表格选择类型
|
|
323
|
+
*/
|
|
324
|
+
function setSelection(showAfter) {
|
|
325
|
+
|
|
326
|
+
// 如果不监听
|
|
327
|
+
if (! isWatcher.value) {
|
|
328
|
+
|
|
329
|
+
// 则无需任何操作
|
|
330
|
+
return
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const selection = showAfter ? 'single' : rawTableSelection
|
|
334
|
+
if ($table.tableSelection.value !== selection) {
|
|
335
|
+
$table.tableSelection.value = selection
|
|
336
|
+
|
|
337
|
+
// 如果显示后置插槽
|
|
338
|
+
if (showAfter && $table.tableSelected.value.length > 1) {
|
|
339
|
+
|
|
340
|
+
// 如果有多条已选数据, 则只取第一条数据
|
|
341
|
+
$table.tableSelected.value = [ $table.tableSelected.value[$table.tableSelected.value.length - 1] ]
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// ==========【返回】=========================================================================================
|
|
347
|
+
|
|
348
|
+
return {
|
|
349
|
+
// 插槽标识
|
|
350
|
+
slotNames,
|
|
351
|
+
// 是否监听
|
|
352
|
+
isWatcher,
|
|
353
|
+
// 当前传参
|
|
354
|
+
currentQuery,
|
|
355
|
+
|
|
356
|
+
// 当前值
|
|
357
|
+
currentValue,
|
|
358
|
+
// 当前显示前置插槽
|
|
359
|
+
currentAfter,
|
|
360
|
+
|
|
361
|
+
// 设置表格选择类型
|
|
362
|
+
setSelection,
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
</script>
|