@94ai/nf-search-form 6.1.1 → 6.1.7
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/lib/index.d.ts +2927 -0
- package/lib/nf-search-form-item.vue.d.ts +0 -6
- package/lib/nf-search-form.cjs.js +160 -403
- package/lib/nf-search-form.esm-bundler.js +162 -405
- package/lib/nf-search-form.vue.d.ts +666 -0
- package/lib/types.d.ts +0 -9
- package/package/nf-column-check-dialog.vue +1 -0
- package/package/nf-search-form-item.vue +4 -15
- package/package/nf-search-form.vue +155 -418
- package/package/types.ts +0 -9
- package/package.json +18 -20
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="nf-search-form" ref="topDom">
|
|
3
|
-
<!-- 空行以下保留原有,未重新梳理 -->
|
|
4
3
|
<nf-form ref="nfSearchFormRef"
|
|
5
4
|
:model="nfSearchFormModel"
|
|
6
5
|
:inline="inline"
|
|
7
6
|
:label-position="labelPosition"
|
|
8
|
-
:label-width="useLabelWidth"
|
|
9
|
-
:size="size"
|
|
10
|
-
:disabled="disabled"
|
|
11
|
-
|
|
12
7
|
:rules="rules"
|
|
13
8
|
:label-suffix="labelSuffix"
|
|
14
9
|
:hide-required-asterisk="hideRequiredAsterisk"
|
|
@@ -16,6 +11,11 @@
|
|
|
16
11
|
:inline-message="inlineMessage"
|
|
17
12
|
:status-icon="statusIcon"
|
|
18
13
|
:validate-on-rule-change="validateOnRuleChange"
|
|
14
|
+
:size="size"
|
|
15
|
+
:disabled="disabled"
|
|
16
|
+
|
|
17
|
+
:label-width="labelWidth+'px'"
|
|
18
|
+
|
|
19
19
|
:expand-btn-type="expandBtnType"
|
|
20
20
|
:expand-btn-icon="expandBtnIcon"
|
|
21
21
|
:expand-btn-plain="expandBtnPlain"
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
:expand-btn-circle="expandBtnCircle"
|
|
25
25
|
:expand-btn-loading="expandBtnLoading"
|
|
26
26
|
:expand-btn-disabled="expandBtnDisabled"
|
|
27
|
+
|
|
27
28
|
:columns="inline ? newColumns : columns"
|
|
28
29
|
:up-icon="upIcon"
|
|
29
30
|
:down-icon="downIcon"
|
|
@@ -31,7 +32,9 @@
|
|
|
31
32
|
:is-collapse="isCollapse"
|
|
32
33
|
:expand-btn-tooltip-desc="expandBtnTooltipDesc"
|
|
33
34
|
:shrink-btn-tooltip-desc="shrinkBtnTooltipDesc"
|
|
35
|
+
|
|
34
36
|
@isCollapseChange="isCollapseChange"
|
|
37
|
+
|
|
35
38
|
>
|
|
36
39
|
<template
|
|
37
40
|
v-for="item in renderSearchFormItemOptions"
|
|
@@ -56,14 +59,11 @@
|
|
|
56
59
|
:key="item.key"
|
|
57
60
|
:item-width="itemWidth"
|
|
58
61
|
v-model="nfSearchFormModel[item.prop]"
|
|
59
|
-
:item-options="item"
|
|
60
|
-
:nfSearchFormModel="nfSearchFormModel"
|
|
61
|
-
@handleChangeProps="handleChangeProps"
|
|
62
|
-
>
|
|
62
|
+
:item-options="item">
|
|
63
63
|
<!-- 定制化SearchItem?提示-->
|
|
64
64
|
<slot :name="item.tooltip.slot" v-if="item.tooltip" :slot="item.tooltip.slot" />
|
|
65
65
|
<!-- 定制化SearchItem插槽-->
|
|
66
|
-
<slot :name="item.slot" v-if="item.slot" :slot="item.slot"
|
|
66
|
+
<slot :name="item.slot" v-if="item.slot" :slot="item.slot" />
|
|
67
67
|
<slot :name="item.inputSlot?.prepend" v-if="item.inputSlot?.prepend" :slot="item.inputSlot?.prepend" />
|
|
68
68
|
<slot :name="item.inputSlot?.append" v-if="item.inputSlot?.append" :slot="item.inputSlot?.append" />
|
|
69
69
|
<slot :name="item.inputSlot?.suffix" v-if="item.inputSlot?.suffix" :slot="item.inputSlot?.suffix" />
|
|
@@ -80,7 +80,6 @@
|
|
|
80
80
|
</div>
|
|
81
81
|
</nf-form-item>
|
|
82
82
|
</template>
|
|
83
|
-
<!-- 表单按钮 -->
|
|
84
83
|
<nf-form-item :label="showBtnBoxLabel"
|
|
85
84
|
v-if="btnModel==='inline'"
|
|
86
85
|
class="nf-search-form-nf-form-item-btn-box-label"
|
|
@@ -88,68 +87,48 @@
|
|
|
88
87
|
>
|
|
89
88
|
<div class="nf-flex nf-flex-align-items-start">
|
|
90
89
|
<slot v-if="isShowBtnBoxSlot && !reverseBtnSlot" name="btnBox" />
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
:class="(resetBtnClass || '') + ' nf-btn-reset'"
|
|
134
|
-
@click="resetNfSearchFormModel"
|
|
135
|
-
>{{ resetBtnText }}
|
|
136
|
-
</nf-button>
|
|
137
|
-
<nf-button
|
|
138
|
-
v-else-if="btnIsShow(item)"
|
|
139
|
-
:key="'btn-' + idx"
|
|
140
|
-
:type="item.type || queryBtnType"
|
|
141
|
-
:icon="item.icon || queryBtnIcon"
|
|
142
|
-
:plain="item.plain || queryBtnPlain"
|
|
143
|
-
:size="item.size || size"
|
|
144
|
-
:round="item.round || queryBtnRound"
|
|
145
|
-
:circle="item.circle || queryBtnCircle"
|
|
146
|
-
:loading="item.loading || queryBtnLoading"
|
|
147
|
-
:disabled="item.disabled || queryBtnDisabled"
|
|
148
|
-
:class="item.class"
|
|
149
|
-
@click="onNfSearchFormClick(item)"
|
|
150
|
-
>{{ item.name }}
|
|
151
|
-
</nf-button>
|
|
152
|
-
</template>
|
|
90
|
+
<nf-button
|
|
91
|
+
v-if="btnItems.includes('search')"
|
|
92
|
+
:type="queryBtnType"
|
|
93
|
+
:icon="queryBtnIcon"
|
|
94
|
+
:plain="queryBtnPlain"
|
|
95
|
+
:size="queryBtnSize"
|
|
96
|
+
:round="queryBtnRound"
|
|
97
|
+
:circle="queryBtnCircle"
|
|
98
|
+
:loading="queryBtnLoading"
|
|
99
|
+
:disabled="queryBtnDisabled"
|
|
100
|
+
:class="(queryBtnClass || '') + ' nf-btn-search'"
|
|
101
|
+
@click="onNfSearchFormSearch"
|
|
102
|
+
>{{ queryBtnText }}
|
|
103
|
+
</nf-button>
|
|
104
|
+
<nf-button
|
|
105
|
+
v-if="btnItems.includes('export')"
|
|
106
|
+
:type="exportBtnType"
|
|
107
|
+
:icon="exportBtnIcon"
|
|
108
|
+
:plain="exportBtnPlain"
|
|
109
|
+
:size="exportBtnSize"
|
|
110
|
+
:round="exportBtnRound"
|
|
111
|
+
:circle="exportBtnCircle"
|
|
112
|
+
:loading="exportBtnLoading"
|
|
113
|
+
:disabled="exportBtnDisabled"
|
|
114
|
+
:class="(exportBtnClass || '') + ' nf-btn-export'"
|
|
115
|
+
@click="onNfSearchFormExport"
|
|
116
|
+
>{{ exportBtnText }}
|
|
117
|
+
</nf-button>
|
|
118
|
+
<nf-button
|
|
119
|
+
v-if="btnItems.includes('reset')"
|
|
120
|
+
:type="resetBtnType"
|
|
121
|
+
:icon="resetBtnIcon"
|
|
122
|
+
:plain="resetBtnPlain"
|
|
123
|
+
:size="resetBtnSize"
|
|
124
|
+
:round="resetBtnRound"
|
|
125
|
+
:circle="resetBtnCircle"
|
|
126
|
+
:loading="resetBtnLoading"
|
|
127
|
+
:disabled="resetBtnDisabled"
|
|
128
|
+
:class="(resetBtnClass || '') + ' nf-btn-reset'"
|
|
129
|
+
@click="resetNfSearchFormModel"
|
|
130
|
+
>{{ resetBtnText }}
|
|
131
|
+
</nf-button>
|
|
153
132
|
<nf-button :type="checkBtnType"
|
|
154
133
|
:plain="checkBtnPlain"
|
|
155
134
|
:size="checkBtnSize"
|
|
@@ -171,68 +150,48 @@
|
|
|
171
150
|
</nf-form>
|
|
172
151
|
<div class="nf-flex nf-flex-align-items nf-mt10" v-if="btnModel==='block'">
|
|
173
152
|
<slot v-if="isShowBtnBoxSlot && !reverseBtnSlot" name="btnBox" />
|
|
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
|
-
:class="(resetBtnClass || '') + ' nf-btn-reset'"
|
|
217
|
-
@click="resetNfSearchFormModel"
|
|
218
|
-
>{{ resetBtnText }}
|
|
219
|
-
</nf-button>
|
|
220
|
-
<nf-button
|
|
221
|
-
v-else-if="btnIsShow(item)"
|
|
222
|
-
:key="'btn-' + idx"
|
|
223
|
-
:type="item.type || queryBtnType"
|
|
224
|
-
:icon="item.icon || queryBtnIcon"
|
|
225
|
-
:plain="item.plain || queryBtnPlain"
|
|
226
|
-
:size="item.size || size"
|
|
227
|
-
:round="item.round || queryBtnRound"
|
|
228
|
-
:circle="item.circle || queryBtnCircle"
|
|
229
|
-
:loading="item.loading || queryBtnLoading"
|
|
230
|
-
:disabled="item.disabled || queryBtnDisabled"
|
|
231
|
-
:class="item.class"
|
|
232
|
-
@click="onNfSearchFormClick(item)"
|
|
233
|
-
>{{ item.name }}
|
|
234
|
-
</nf-button>
|
|
235
|
-
</template>
|
|
153
|
+
<nf-button
|
|
154
|
+
v-if="btnItems.includes('search')"
|
|
155
|
+
:type="queryBtnType"
|
|
156
|
+
:icon="queryBtnIcon"
|
|
157
|
+
:plain="queryBtnPlain"
|
|
158
|
+
:size="queryBtnSize || size"
|
|
159
|
+
:round="queryBtnRound"
|
|
160
|
+
:circle="queryBtnCircle"
|
|
161
|
+
:loading="queryBtnLoading"
|
|
162
|
+
:disabled="queryBtnDisabled"
|
|
163
|
+
:class="(queryBtnClass || '') + ' nf-btn-search'"
|
|
164
|
+
@click="onNfSearchFormSearch"
|
|
165
|
+
>{{ queryBtnText }}
|
|
166
|
+
</nf-button>
|
|
167
|
+
<nf-button
|
|
168
|
+
v-if="btnItems.includes('export')"
|
|
169
|
+
:type="exportBtnType"
|
|
170
|
+
:icon="exportBtnIcon"
|
|
171
|
+
:plain="exportBtnPlain"
|
|
172
|
+
:size="exportBtnSize || size"
|
|
173
|
+
:round="exportBtnRound"
|
|
174
|
+
:circle="exportBtnCircle"
|
|
175
|
+
:loading="exportBtnLoading"
|
|
176
|
+
:disabled="exportBtnDisabled"
|
|
177
|
+
:class="(exportBtnClass || '') + ' nf-btn-export'"
|
|
178
|
+
@click="onNfSearchFormExport"
|
|
179
|
+
>{{ exportBtnText }}
|
|
180
|
+
</nf-button>
|
|
181
|
+
<nf-button
|
|
182
|
+
v-if="btnItems.includes('reset')"
|
|
183
|
+
:type="resetBtnType"
|
|
184
|
+
:icon="resetBtnIcon"
|
|
185
|
+
:plain="resetBtnPlain"
|
|
186
|
+
:size="resetBtnSize || size"
|
|
187
|
+
:round="resetBtnRound"
|
|
188
|
+
:circle="resetBtnCircle"
|
|
189
|
+
:loading="resetBtnLoading"
|
|
190
|
+
:disabled="resetBtnDisabled"
|
|
191
|
+
:class="(resetBtnClass || '') + ' nf-btn-reset'"
|
|
192
|
+
@click="resetNfSearchFormModel"
|
|
193
|
+
>{{ resetBtnText }}
|
|
194
|
+
</nf-button>
|
|
236
195
|
<nf-button :type="checkBtnType"
|
|
237
196
|
v-if="columnEdit"
|
|
238
197
|
:plain="checkBtnPlain"
|
|
@@ -260,7 +219,7 @@
|
|
|
260
219
|
v-if="columnEdit && configNfSearchItemVisibleDialog && checkMode === 'dialog'"
|
|
261
220
|
:show.sync="configNfSearchItemVisibleDialog"
|
|
262
221
|
:modal-append-to-body="modalAppendToBody"
|
|
263
|
-
:storage-key="
|
|
222
|
+
:storage-key="storageKey"
|
|
264
223
|
:table-columns="formOptions"
|
|
265
224
|
:width="moreDialogWidth"
|
|
266
225
|
:modal="modal"
|
|
@@ -313,7 +272,7 @@
|
|
|
313
272
|
:get-all-check-desc="columnCheckGetAllCheckDesc"
|
|
314
273
|
|
|
315
274
|
ref="columnCheckDrawer"
|
|
316
|
-
:storage-key="
|
|
275
|
+
:storage-key="storageKey"
|
|
317
276
|
:table-columns="formOptions"
|
|
318
277
|
:column-edit="columnEdit"
|
|
319
278
|
/>
|
|
@@ -335,6 +294,7 @@ import SearchFormItem from './nf-search-form-item.vue'
|
|
|
335
294
|
import ColumnCheckDialog from './nf-column-check-dialog.vue'
|
|
336
295
|
import ColumnCheckDrawer from './nf-column-check-drawer.vue'
|
|
337
296
|
import ResizeObserver from 'resize-observer-polyfill'
|
|
297
|
+
import { createUniqueString } from '@94ai/common-utils'
|
|
338
298
|
import { NfSearchFormItemOption } from './types'
|
|
339
299
|
import {
|
|
340
300
|
ref,
|
|
@@ -346,48 +306,20 @@ import {
|
|
|
346
306
|
onBeforeUnmount,
|
|
347
307
|
nextTick
|
|
348
308
|
} from 'vue-demi'
|
|
309
|
+
import { ITabItem } from '@94ai/nf-drawer/lib/types'
|
|
349
310
|
import {
|
|
350
311
|
NfTableColumnAttributes
|
|
351
312
|
} from '@94ai/nf-table/lib/types'
|
|
352
313
|
import { set } from 'vue'
|
|
353
314
|
import {
|
|
354
315
|
CachedManager,
|
|
355
|
-
deepClone,
|
|
356
|
-
createUniqueString,
|
|
357
|
-
validate as useValidate,
|
|
358
|
-
mapDispose
|
|
359
316
|
} from '@94ai/common-utils'
|
|
360
317
|
import {
|
|
361
318
|
throttle
|
|
362
319
|
} from 'lodash-es'
|
|
363
|
-
import { useRoute } from 'vue-router/composables'
|
|
364
|
-
import { ELEMENT_LABEL_TYPE_DEFAULT_VALUE, EXCHANGE_KEY_TYPE } from '@94ai/common-constants'
|
|
365
|
-
import { ITabItem } from '@94ai/nf-drawer/lib/types'
|
|
366
320
|
|
|
367
|
-
interface IBtnItems {
|
|
368
|
-
btnType?: 'search' | 'export' | 'reset'
|
|
369
|
-
name?: string,
|
|
370
|
-
type?: string,
|
|
371
|
-
icon?: string,
|
|
372
|
-
plain?: boolean,
|
|
373
|
-
size?: string,
|
|
374
|
-
round?: boolean,
|
|
375
|
-
circle?: boolean,
|
|
376
|
-
loading?: boolean,
|
|
377
|
-
disabled?: boolean,
|
|
378
|
-
class?: string,
|
|
379
|
-
validate?: boolean,
|
|
380
|
-
onClick?: (formData: Record<string, any>) => void,
|
|
381
|
-
show?: (formData: Record<string, any>) => boolean,
|
|
382
|
-
[key: string]: any,
|
|
383
|
-
}
|
|
384
321
|
|
|
385
322
|
const props = withDefaults(defineProps<{
|
|
386
|
-
/**
|
|
387
|
-
* isMvc版本改造参数
|
|
388
|
-
*/
|
|
389
|
-
isMvc?: boolean, // 单向数据流传版本
|
|
390
|
-
defaultFormData?: Object; // 默认的表单数据
|
|
391
323
|
/**
|
|
392
324
|
* nf-form扩展配置项
|
|
393
325
|
*/
|
|
@@ -433,7 +365,7 @@ const props = withDefaults(defineProps<{
|
|
|
433
365
|
/**
|
|
434
366
|
* label宽度
|
|
435
367
|
*/
|
|
436
|
-
labelWidth?: number
|
|
368
|
+
labelWidth?: number,
|
|
437
369
|
/**
|
|
438
370
|
* 所有的表单项
|
|
439
371
|
*/
|
|
@@ -505,7 +437,7 @@ const props = withDefaults(defineProps<{
|
|
|
505
437
|
/**
|
|
506
438
|
* 兼容ai-search-form,控制额外的默认功能按钮
|
|
507
439
|
*/
|
|
508
|
-
btnItems?: string[] |
|
|
440
|
+
btnItems?: string[] | 'search' | 'export' | 'reset' | '',
|
|
509
441
|
reverseBtnSlot?: boolean,
|
|
510
442
|
/**
|
|
511
443
|
* 导出按钮
|
|
@@ -547,13 +479,8 @@ const props = withDefaults(defineProps<{
|
|
|
547
479
|
resetBtnText?: string,
|
|
548
480
|
resetBtnClass?: string,
|
|
549
481
|
}>(), {
|
|
550
|
-
isMvc: false, // 单向数据流传版本
|
|
551
|
-
defaultFormData: () => {
|
|
552
|
-
return {}
|
|
553
|
-
}, // 默认的表单数据
|
|
554
|
-
|
|
555
482
|
priority: 'cached',
|
|
556
|
-
storageKey: '
|
|
483
|
+
storageKey: 'nf-search-form-columns-cached-key',
|
|
557
484
|
checkMode: 'drawer',
|
|
558
485
|
upIcon: 'icon-xiangshang2',
|
|
559
486
|
downIcon: 'icon-xiangxia2',
|
|
@@ -694,128 +621,18 @@ const emit = defineEmits<{
|
|
|
694
621
|
*/
|
|
695
622
|
(e: 'update:showItems', event: string[] | undefined): void
|
|
696
623
|
}>()
|
|
697
|
-
|
|
624
|
+
|
|
698
625
|
const instance = getCurrentInstance()?.proxy
|
|
699
626
|
const defaultButtonSlot = ref()
|
|
700
627
|
const nfSearchFormRef = ref()
|
|
701
628
|
const columnCheckNfDrawer = ref()
|
|
702
629
|
const columnCheckDrawer = ref()
|
|
703
630
|
const columnCheckDialog = ref()
|
|
704
|
-
const useLabelWidth = ref<string | number>(useValidate.isNumber(props.labelWidth) ? `${props.labelWidth}px` : props.labelWidth)
|
|
705
|
-
const changeUpdateKeys = ref<string[]>([])
|
|
706
|
-
const cBtnItems = ref<object[]>([]) // 处理后的bthItems
|
|
707
|
-
const cStorageKey = ref(props.storageKey || `nf-search-form-columns-cached-key-${routeName.value}`)
|
|
708
631
|
|
|
709
632
|
/**
|
|
710
633
|
* 表单填充的数据
|
|
711
634
|
*/
|
|
712
|
-
const nfSearchFormModel = ref<Record<string, any>>(
|
|
713
|
-
|
|
714
|
-
// 获取value
|
|
715
|
-
const getValue = (item) => {
|
|
716
|
-
return mapDispose.getValue(nfSearchFormModel.value, item.prop)
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
// 设置值
|
|
720
|
-
const setValue = (item, val) => {
|
|
721
|
-
mapDispose.setValue(nfSearchFormModel.value, item.prop, val)
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
/**
|
|
725
|
-
* 设置默认值
|
|
726
|
-
* @param {Boolean} init 是否是初始化
|
|
727
|
-
*/
|
|
728
|
-
const setDefaultVal = (item, init = true) => {
|
|
729
|
-
if (init) {
|
|
730
|
-
// // 拓展初始化属性
|
|
731
|
-
// if (item.extendMap) {
|
|
732
|
-
// handleMap.setRecursionValue(this.formData, this.$deepClone(item.extendMap))
|
|
733
|
-
// return
|
|
734
|
-
// } else
|
|
735
|
-
if (mapDispose.hasKey(nfSearchFormModel.value, item.prop)) {
|
|
736
|
-
return
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
const { element = '', multiple = false } = item
|
|
740
|
-
let initValue: any = null
|
|
741
|
-
if (item.hasOwnProperty('initValue')) {
|
|
742
|
-
initValue = item.initValue
|
|
743
|
-
} else if (multiple) {
|
|
744
|
-
initValue = []
|
|
745
|
-
} else if (ELEMENT_LABEL_TYPE_DEFAULT_VALUE.hasOwnProperty(element)) {
|
|
746
|
-
initValue = ELEMENT_LABEL_TYPE_DEFAULT_VALUE[element]
|
|
747
|
-
}
|
|
748
|
-
setValue(item, deepClone(initValue))
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
// 获取changeProps所有涉及的key
|
|
752
|
-
const getChangePropKeys = () => {
|
|
753
|
-
let list = []
|
|
754
|
-
props.formOptions.forEach(item => {
|
|
755
|
-
list = list.concat(item.changeProps || [])
|
|
756
|
-
})
|
|
757
|
-
changeUpdateKeys.value = list
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
// 动态获取option
|
|
761
|
-
const triggerGetOptions = async (item) => {
|
|
762
|
-
if (item.getOptions) {
|
|
763
|
-
const canSetParams = changeUpdateKeys.value.includes(item.prop)
|
|
764
|
-
await nextTick()
|
|
765
|
-
item['options'] = []
|
|
766
|
-
item['loading'] = true
|
|
767
|
-
item.getOptions((data) => {
|
|
768
|
-
nextTick(() => {
|
|
769
|
-
item.loading = false
|
|
770
|
-
item.options = data
|
|
771
|
-
})
|
|
772
|
-
// 依赖查询条件的才传formData
|
|
773
|
-
}, canSetParams ? getFormData() : {})
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* 初始化按钮列表
|
|
779
|
-
*/
|
|
780
|
-
const btnItemsInit = () => {
|
|
781
|
-
if (!props.btnItems) return
|
|
782
|
-
let list = deepClone(props.btnItems)
|
|
783
|
-
// string类型
|
|
784
|
-
if (useValidate.isString(props.btnItems)) {
|
|
785
|
-
list = [
|
|
786
|
-
...(props.btnItems ? [{ btnType: props.btnItems }] : [])
|
|
787
|
-
]
|
|
788
|
-
}
|
|
789
|
-
list = list.map(item => {
|
|
790
|
-
if (useValidate.isString(item)) {
|
|
791
|
-
return { btnType: item }
|
|
792
|
-
} else {
|
|
793
|
-
return item
|
|
794
|
-
}
|
|
795
|
-
})
|
|
796
|
-
cBtnItems.value = list
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
/**
|
|
801
|
-
* changeProps: [k1, k2, ...] 需重新请求数据的key值数组
|
|
802
|
-
*/
|
|
803
|
-
const handleChangeProps = (changeProps: string[]) => {
|
|
804
|
-
if (changeProps?.length) {
|
|
805
|
-
props.formOptions.forEach(item => {
|
|
806
|
-
if (!changeProps.includes(item.prop)) return
|
|
807
|
-
setDefaultVal(item, false)
|
|
808
|
-
triggerGetOptions(item)
|
|
809
|
-
// 联动changeProps
|
|
810
|
-
const list = (item.changeProps || []).filter(item => !changeProps.includes(item))
|
|
811
|
-
if (list.length) {
|
|
812
|
-
nextTick(() => {
|
|
813
|
-
handleChangeProps(list)
|
|
814
|
-
})
|
|
815
|
-
}
|
|
816
|
-
})
|
|
817
|
-
}
|
|
818
|
-
}
|
|
635
|
+
const nfSearchFormModel = ref<Record<string, any>>({})
|
|
819
636
|
|
|
820
637
|
/**
|
|
821
638
|
* 同步用户参数
|
|
@@ -844,16 +661,12 @@ const initLocalShow = (init = false) => {
|
|
|
844
661
|
* 表单显示的item集合
|
|
845
662
|
*/
|
|
846
663
|
const localShowItems = ref<string[]>(initLocalShow(true))
|
|
847
|
-
watch(() => localShowItems.value, async (
|
|
848
|
-
emit('update:showItems',
|
|
849
|
-
if (
|
|
850
|
-
|
|
851
|
-
if (Object.keys(nfSearchFormModel.value).length) { // 有可能用computed或异步引起数据更改实时同步model
|
|
852
|
-
refreshNfSearchFormModel()
|
|
853
|
-
}
|
|
664
|
+
watch(() => localShowItems.value?.length, async () => {
|
|
665
|
+
emit('update:showItems', localShowItems.value)
|
|
666
|
+
if (Object.keys(nfSearchFormModel.value).length) { // 有可能用computed或异步引起数据更改实时同步model
|
|
667
|
+
refreshNfSearchFormModel(false)
|
|
854
668
|
}
|
|
855
669
|
}, {
|
|
856
|
-
deep: true,
|
|
857
670
|
immediate: true
|
|
858
671
|
})
|
|
859
672
|
const syncLocalShowColumnToCookies = () => {
|
|
@@ -867,7 +680,7 @@ const syncLocalShowColumnToCookies = () => {
|
|
|
867
680
|
index
|
|
868
681
|
}
|
|
869
682
|
})
|
|
870
|
-
CachedManager.syncCachedSet(
|
|
683
|
+
CachedManager.syncCachedSet(props.storageKey, columnState)
|
|
871
684
|
}
|
|
872
685
|
}
|
|
873
686
|
const syncShowItemToInitHidden = () => {
|
|
@@ -897,9 +710,9 @@ const setLocalShowItems = (list, syncToInitHidden = false) => {
|
|
|
897
710
|
const syncCookiesToLocalShowColumn = async (refreshModel = false) => {
|
|
898
711
|
if (props.columnEdit) {
|
|
899
712
|
try {
|
|
900
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
713
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(props.storageKey)
|
|
901
714
|
if (!columnState) {
|
|
902
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
715
|
+
columnState = await CachedManager.asyncCachedGet(props.storageKey)
|
|
903
716
|
}
|
|
904
717
|
if (columnState) {
|
|
905
718
|
if (typeof columnState === 'string') {
|
|
@@ -926,9 +739,9 @@ const syncCookiesToLocalShowColumn = async (refreshModel = false) => {
|
|
|
926
739
|
const initCachedData = async () => {
|
|
927
740
|
if (props.columnEdit) {
|
|
928
741
|
// 同步缓存参数
|
|
929
|
-
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
742
|
+
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(props.storageKey)
|
|
930
743
|
if (!cached) {
|
|
931
|
-
cached = await CachedManager.asyncCachedGet(
|
|
744
|
+
cached = await CachedManager.asyncCachedGet(props.storageKey)
|
|
932
745
|
}
|
|
933
746
|
const cachedPriority = props.priority === 'cached'
|
|
934
747
|
if (cachedPriority ? cached : localShowItems.value?.length) {
|
|
@@ -958,16 +771,27 @@ const isShowBtnBoxSlot = computed(() => {
|
|
|
958
771
|
})
|
|
959
772
|
|
|
960
773
|
/**
|
|
961
|
-
*
|
|
774
|
+
* 转换成最终的表单项渲染数据
|
|
962
775
|
*/
|
|
963
|
-
const
|
|
964
|
-
|
|
776
|
+
const renderSearchFormItemOptions = ref<NfSearchFormItemOption[]>([])
|
|
777
|
+
let initSearchForm = true
|
|
778
|
+
const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
|
|
779
|
+
props.formOptions._skip = true
|
|
780
|
+
const columns = props.formOptions!.map((item, index) => {
|
|
781
|
+
item.key = item.key || createUniqueString()
|
|
782
|
+
item._index = index // 混合缓存后的数据
|
|
783
|
+
item.__index = index // 原始顺序
|
|
784
|
+
set(item, 'initHidden', !!item.initHidden)
|
|
785
|
+
set(item, 'destory', !!item.destory)
|
|
786
|
+
return item
|
|
787
|
+
})
|
|
788
|
+
if (readCached && props.columnEdit) {
|
|
965
789
|
// 读取缓存 Column 配置
|
|
966
790
|
try {
|
|
967
791
|
// 同步缓存参数
|
|
968
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
792
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(props.storageKey)
|
|
969
793
|
if (!columnState) {
|
|
970
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
794
|
+
columnState = await CachedManager.asyncCachedGet(props.storageKey)
|
|
971
795
|
}
|
|
972
796
|
props.formOptions._skip = true
|
|
973
797
|
if (columnState) {
|
|
@@ -990,28 +814,6 @@ const handleColumnsInitHideAndSort = async(columns: any[]) => {
|
|
|
990
814
|
console.log(e)
|
|
991
815
|
}
|
|
992
816
|
}
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
/**
|
|
996
|
-
* 转换成最终的表单项渲染数据
|
|
997
|
-
*/
|
|
998
|
-
const renderSearchFormItemOptions = ref<NfSearchFormItemOption[]>([])
|
|
999
|
-
let initSearchForm = true
|
|
1000
|
-
const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
|
|
1001
|
-
props.formOptions._skip = true
|
|
1002
|
-
const columns = props.formOptions!.map((item, index) => {
|
|
1003
|
-
item.key = item.key || createUniqueString()
|
|
1004
|
-
item._index = index // 混合缓存后的数据
|
|
1005
|
-
item.__index = index // 原始顺序
|
|
1006
|
-
set(item, 'initHidden', !!item.initHidden)
|
|
1007
|
-
set(item, 'destory', !!item.destory)
|
|
1008
|
-
if (!item.options) set(item, 'options', [])
|
|
1009
|
-
return item
|
|
1010
|
-
})
|
|
1011
|
-
if (readCached) {
|
|
1012
|
-
// 读取缓存 Column 配置(隐藏 & 排序)
|
|
1013
|
-
await handleColumnsInitHideAndSort(columns)
|
|
1014
|
-
}
|
|
1015
817
|
renderSearchFormItemOptions.value = columns.sort((a, b) => a._index - b._index < 0 ? -1 : a._index - b._index > 0 ? 1 : 0);
|
|
1016
818
|
nextTick(() => {
|
|
1017
819
|
if (initSearchForm) {
|
|
@@ -1021,8 +823,6 @@ const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
|
|
|
1021
823
|
props.formOptions._skip = false;
|
|
1022
824
|
})
|
|
1023
825
|
}
|
|
1024
|
-
|
|
1025
|
-
// 初始化表单配置
|
|
1026
826
|
syncCookiesToSearchFormItemOptions()
|
|
1027
827
|
|
|
1028
828
|
/**
|
|
@@ -1030,18 +830,9 @@ syncCookiesToSearchFormItemOptions()
|
|
|
1030
830
|
* @param prop
|
|
1031
831
|
*/
|
|
1032
832
|
const itemIsShow = (item: NfSearchFormItemOption) => {
|
|
1033
|
-
return !item.initHidden && !item.destory
|
|
1034
|
-
useValidate.isFunction(item.show) ? item?.show?.(nfSearchFormModel.value) : true
|
|
1035
|
-
)
|
|
833
|
+
return !item.initHidden && !item.destory
|
|
1036
834
|
}
|
|
1037
835
|
|
|
1038
|
-
/**
|
|
1039
|
-
* 判断按钮是否显示
|
|
1040
|
-
* @param prop
|
|
1041
|
-
*/
|
|
1042
|
-
const btnIsShow = (item: IBtnItems) => {
|
|
1043
|
-
return item.show ? item.show(nfSearchFormModel.value) : true
|
|
1044
|
-
}
|
|
1045
836
|
|
|
1046
837
|
/**
|
|
1047
838
|
* 实时触发onChange
|
|
@@ -1088,35 +879,32 @@ onBeforeMount(() => {
|
|
|
1088
879
|
}, {
|
|
1089
880
|
deep: true
|
|
1090
881
|
})
|
|
1091
|
-
|
|
1092
|
-
formsInit()
|
|
882
|
+
refreshNfSearchFormModel(false, true)
|
|
1093
883
|
})
|
|
1094
884
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
*/
|
|
1099
|
-
const refreshNfSearchFormModel = () => {
|
|
885
|
+
|
|
886
|
+
const refreshNfSearchFormModel = (outEmit = true, init = false) => {
|
|
887
|
+
const obj: Record<string, any> = {}
|
|
1100
888
|
props.formOptions.filter(item => !item.destory).forEach(v => {
|
|
1101
|
-
if (
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
889
|
+
if (localShowItems.value.includes(v.prop)) {
|
|
890
|
+
if (init) {
|
|
891
|
+
if (v.initValue !== undefined) {
|
|
892
|
+
obj[v.prop!] = v.initValue
|
|
893
|
+
} else {
|
|
894
|
+
obj[v.prop!] = null
|
|
895
|
+
}
|
|
896
|
+
} else {
|
|
897
|
+
const value = nfSearchFormModel.value[v.prop]
|
|
898
|
+
obj[v.prop!] = typeof value === 'undefined' ? null : value
|
|
899
|
+
}
|
|
1105
900
|
}
|
|
1106
901
|
})
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
props.formOptions.forEach(item => {
|
|
1114
|
-
if (item.destory || !localShowItems.value.includes(item.prop)) return
|
|
1115
|
-
// 设置默认值
|
|
1116
|
-
setDefaultVal(item, true)
|
|
1117
|
-
// // 处理动态表单列表
|
|
1118
|
-
triggerGetOptions(item)
|
|
1119
|
-
})
|
|
902
|
+
if (JSON.stringify(nfSearchFormModel.value) !== JSON.stringify(obj)) {
|
|
903
|
+
nfSearchFormModel.value = obj
|
|
904
|
+
if (outEmit) {
|
|
905
|
+
emit('itemsChange', localShowItems.value)
|
|
906
|
+
}
|
|
907
|
+
}
|
|
1120
908
|
}
|
|
1121
909
|
|
|
1122
910
|
const isCollapseChange = async (val: boolean) => {
|
|
@@ -1136,10 +924,6 @@ const refreshLabel = () => {
|
|
|
1136
924
|
}
|
|
1137
925
|
}
|
|
1138
926
|
}
|
|
1139
|
-
|
|
1140
|
-
/**
|
|
1141
|
-
* 计算收起展开的数量
|
|
1142
|
-
*/
|
|
1143
927
|
const calcColumns = () => {
|
|
1144
928
|
if (props.columns) {
|
|
1145
929
|
newColumns.value = props.columns
|
|
@@ -1210,7 +994,7 @@ const onNfSearchFormValidate = (callback) => {
|
|
|
1210
994
|
*/
|
|
1211
995
|
const onNfSearchFormSearch = () => {
|
|
1212
996
|
onNfSearchFormValidate(() => {
|
|
1213
|
-
emit('onSearch',
|
|
997
|
+
emit('onSearch', nfSearchFormModel.value)
|
|
1214
998
|
})
|
|
1215
999
|
}
|
|
1216
1000
|
/**
|
|
@@ -1218,25 +1002,12 @@ const onNfSearchFormSearch = () => {
|
|
|
1218
1002
|
*/
|
|
1219
1003
|
const onNfSearchFormExport = () => {
|
|
1220
1004
|
onNfSearchFormValidate(() => {
|
|
1221
|
-
emit('onExport',
|
|
1005
|
+
emit('onExport', nfSearchFormModel.value)
|
|
1222
1006
|
})
|
|
1223
1007
|
}
|
|
1224
1008
|
|
|
1225
1009
|
/**
|
|
1226
|
-
*
|
|
1227
|
-
*/
|
|
1228
|
-
const onNfSearchFormClick = (item) => {
|
|
1229
|
-
if (item.validate) { // 需要校验表单
|
|
1230
|
-
onNfSearchFormValidate(() => {
|
|
1231
|
-
item.onClick?.(getFormData())
|
|
1232
|
-
})
|
|
1233
|
-
} else {
|
|
1234
|
-
item.onClick?.(getFormData())
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
/**
|
|
1239
|
-
* 把该item暂时隐藏【❌有错误待修复,prop命名重复】
|
|
1010
|
+
* 把该item暂时隐藏
|
|
1240
1011
|
* @param prop
|
|
1241
1012
|
*/
|
|
1242
1013
|
const hiddenNfSearchFormItemOptionField = async (prop) => {
|
|
@@ -1289,11 +1060,11 @@ const columnCheckConfirm = async (cb, error) => {
|
|
|
1289
1060
|
}
|
|
1290
1061
|
|
|
1291
1062
|
async function clearDragCached() {
|
|
1292
|
-
await CachedManager.asyncCachedSet(`${
|
|
1063
|
+
await CachedManager.asyncCachedSet(`${props.storageKey}$drag-column-width`, null)
|
|
1293
1064
|
}
|
|
1294
1065
|
|
|
1295
1066
|
async function clearColumnEditCached() {
|
|
1296
|
-
await CachedManager.asyncCachedSet(
|
|
1067
|
+
await CachedManager.asyncCachedSet(props.storageKey, null)
|
|
1297
1068
|
}
|
|
1298
1069
|
|
|
1299
1070
|
/**
|
|
@@ -1307,41 +1078,7 @@ const nfSearchFormItemOptionFieldsSave = async (value) => {
|
|
|
1307
1078
|
refreshLabel()
|
|
1308
1079
|
}
|
|
1309
1080
|
|
|
1310
|
-
/**
|
|
1311
|
-
* 数组值分割多个字段
|
|
1312
|
-
*/
|
|
1313
|
-
const handleExchangeKey = (data) => {
|
|
1314
|
-
props.formOptions.forEach(item => {
|
|
1315
|
-
if (!item.exchangeKey) return
|
|
1316
|
-
const { type, value } = item.exchangeKey
|
|
1317
|
-
const key = item.prop
|
|
1318
|
-
// 日期时间范围变化字段
|
|
1319
|
-
if (type === EXCHANGE_KEY_TYPE.range) {
|
|
1320
|
-
value?.forEach?.((k, i) => {
|
|
1321
|
-
data[k] = data?.[key]?.[i] || null
|
|
1322
|
-
})
|
|
1323
|
-
delete data[key]
|
|
1324
|
-
} else if (type === EXCHANGE_KEY_TYPE.multiple) {
|
|
1325
|
-
// ids变化字段,字符串切割成数组
|
|
1326
|
-
data[key] = data[key]?.trim()?.split(value || ',')?.filter(s => s !== '')
|
|
1327
|
-
}
|
|
1328
|
-
})
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
/**
|
|
1332
|
-
* 获取当前数据
|
|
1333
|
-
*/
|
|
1334
|
-
const getFormData = () => {
|
|
1335
|
-
const data = deepClone(nfSearchFormModel.value)
|
|
1336
|
-
handleExchangeKey(data)
|
|
1337
|
-
return data
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
1081
|
defineExpose({
|
|
1341
|
-
/**
|
|
1342
|
-
* 获取表单实时数据(已深拷贝)
|
|
1343
|
-
*/
|
|
1344
|
-
getFormData,
|
|
1345
1082
|
/**
|
|
1346
1083
|
* 列编辑显示的列prop
|
|
1347
1084
|
*/
|