@94ai/nf-search-form 3.2.4 → 3.2.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/lib/index.d.ts +727 -257
- package/lib/nf-column-check-drawer.vue.d.ts +113 -0
- package/lib/nf-search-form.cjs.js +6183 -364
- package/lib/nf-search-form.esm-bundler.js +6183 -364
- package/lib/nf-search-form.vue.d.ts +274 -89
- package/lib/tools.d.ts +2 -1
- package/lib/types.d.ts +4 -0
- package/package/index.ts +13 -1
- package/package/nf-column-check-dialog.vue +10 -0
- package/package/nf-column-check-drawer.vue +404 -0
- package/package/nf-search-form-item.vue +1 -0
- package/package/nf-search-form.vue +442 -188
- package/package/tools.ts +18 -4
- package/package/types.ts +4 -0
- package/package.json +19 -15
|
@@ -16,43 +16,49 @@
|
|
|
16
16
|
|
|
17
17
|
:label-width="labelWidth+'px'"
|
|
18
18
|
|
|
19
|
-
:columns=
|
|
19
|
+
:columns="inline ? newColumns : columns"
|
|
20
20
|
:up-icon="upIcon"
|
|
21
21
|
:down-icon="downIcon"
|
|
22
22
|
:show-btn="showBtn"
|
|
23
23
|
:is-collapse="isCollapse"
|
|
24
24
|
@isCollapseChange="isCollapseChange"
|
|
25
25
|
>
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
v-for="(item, index) in renderSearchFormItemOptions"
|
|
29
|
-
:hidden="!!item.hidden"
|
|
30
|
-
:key="newKeys[index]"
|
|
31
|
-
:prop="item.prop"
|
|
32
|
-
:label="item.label ? (item.isShowColon?item.label + ':':item.label) : ''"
|
|
33
|
-
:rules="item.rules"
|
|
34
|
-
:show-message="item.showMessage"
|
|
35
|
-
:size="item.size"
|
|
36
|
-
:inline-message="item.inlineMessage"
|
|
37
|
-
:required="item.required"
|
|
38
|
-
:label-width="item.labelWidth"
|
|
26
|
+
<template
|
|
27
|
+
v-for="item in renderSearchFormItemOptions"
|
|
39
28
|
>
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
<nf-form-item
|
|
30
|
+
v-if="itemIsShow(item)"
|
|
31
|
+
:class="(item.class || '') + ' nf-search-form-nf-form-item'"
|
|
32
|
+
:hidden="!!item.hidden"
|
|
33
|
+
:key="item.key"
|
|
34
|
+
:prop="item.prop"
|
|
35
|
+
:label="item.label ? (item.isShowColon?item.label + ':':item.label) : ''"
|
|
36
|
+
:rules="item.rules"
|
|
37
|
+
:show-message="item.showMessage"
|
|
38
|
+
:size="item.size"
|
|
39
|
+
:inline-message="item.inlineMessage"
|
|
40
|
+
:required="item.required"
|
|
41
|
+
:label-width="item.labelWidth"
|
|
42
|
+
>
|
|
43
|
+
<search-form-item v-model="nfSearchFormModel[item.prop]" :item-width="itemWidth" :label-width="labelWidth"
|
|
44
|
+
:item-options="item">
|
|
45
|
+
<!-- 定制化SearchItem?提示-->
|
|
46
|
+
<template v-if="item.tooltip" :slot="item.tooltip.slot">
|
|
47
|
+
<slot :name="item.tooltip.slot" />
|
|
48
|
+
</template>
|
|
49
|
+
<!-- 定制化SearchItem插槽-->
|
|
50
|
+
<template v-if="item.slot" :slot="item.slot">
|
|
51
|
+
<slot :name="item.slot" />
|
|
52
|
+
</template>
|
|
53
|
+
</search-form-item>
|
|
54
|
+
<!-- 控制显示该表单项-->
|
|
55
|
+
<div v-if="closable" class="nf-search-form-nf-form-item-close-icon">
|
|
56
|
+
<i class="el-icon-error" @click="hiddenNfSearchFormItemOptionField(item.prop)" />
|
|
57
|
+
</div>
|
|
58
|
+
</nf-form-item>
|
|
59
|
+
</template>
|
|
60
|
+
<nf-form-item :label="showBtnBoxLabel" v-if="btnModel==='inline'"
|
|
61
|
+
class="nf-search-form-nf-form-item-btn-box-label" ref="defaultButtonSlot">
|
|
56
62
|
<div class="nf-flex nf-flex-align-items-start">
|
|
57
63
|
<slot v-if="isShowBtnBoxSlot && !reverseBtnSlot" name="btnBox" />
|
|
58
64
|
<el-button
|
|
@@ -97,21 +103,21 @@
|
|
|
97
103
|
@click="resetNfSearchFormModel"
|
|
98
104
|
>{{ resetBtnText }}
|
|
99
105
|
</el-button>
|
|
100
|
-
<el-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
>
|
|
106
|
+
<el-button :type="checkBtnType"
|
|
107
|
+
:plain="checkBtnPlain"
|
|
108
|
+
:size="checkBtnSize"
|
|
109
|
+
:round="checkBtnRound"
|
|
110
|
+
:circle="checkBtnCircle"
|
|
111
|
+
:loading="checkBtnLoading"
|
|
112
|
+
:disabled="checkBtnDisabled"
|
|
113
|
+
:class="(checkBtnClass || '') + ' nf-btn-check'"
|
|
114
|
+
@click.stop="configNfSearchItemVisibleDialog = true"
|
|
115
|
+
v-if="columnEdit"
|
|
116
|
+
>
|
|
117
|
+
<el-tooltip :content="columnDisplayBtnText" placement="bottom">
|
|
112
118
|
<i class="iconfont icon-shaixuan1 nf-fs12"></i>
|
|
113
|
-
</el-
|
|
114
|
-
</el-
|
|
119
|
+
</el-tooltip>
|
|
120
|
+
</el-button>
|
|
115
121
|
<slot v-if="isShowBtnBoxSlot && reverseBtnSlot" name="btnBox" />
|
|
116
122
|
</div>
|
|
117
123
|
</nf-form-item>
|
|
@@ -160,9 +166,8 @@
|
|
|
160
166
|
@click="resetNfSearchFormModel"
|
|
161
167
|
>{{ resetBtnText }}
|
|
162
168
|
</el-button>
|
|
163
|
-
<el-button
|
|
164
|
-
|
|
165
|
-
:icon="checkBtnIcon"
|
|
169
|
+
<el-button :type="checkBtnType"
|
|
170
|
+
v-if="columnEdit"
|
|
166
171
|
:plain="checkBtnPlain"
|
|
167
172
|
:size="checkBtnSize"
|
|
168
173
|
:round="checkBtnRound"
|
|
@@ -172,12 +177,16 @@
|
|
|
172
177
|
:class="(checkBtnClass || '') + ' nf-btn-check'"
|
|
173
178
|
@click.stop="configNfSearchItemVisibleDialog = true"
|
|
174
179
|
>
|
|
175
|
-
|
|
180
|
+
<el-tooltip :content="columnDisplayBtnText" placement="bottom">
|
|
181
|
+
<i class="iconfont icon-shaixuan1 nf-fs12"></i>
|
|
182
|
+
</el-tooltip>
|
|
176
183
|
</el-button>
|
|
177
184
|
<slot v-if="isShowBtnBoxSlot && reverseBtnSlot" name="btnBox" />
|
|
178
185
|
</div>
|
|
179
186
|
<column-check-dialog
|
|
180
|
-
|
|
187
|
+
ref="columnCheckDialog"
|
|
188
|
+
:storage-key="storageKey"
|
|
189
|
+
v-if="configNfSearchItemVisibleDialog && checkMode === 'dialog'"
|
|
181
190
|
:show.sync="configNfSearchItemVisibleDialog"
|
|
182
191
|
:table-columns="formOptions"
|
|
183
192
|
:title="moreDialogTitle"
|
|
@@ -205,6 +214,36 @@
|
|
|
205
214
|
<slot slot="title" name="dialogTitle"></slot>
|
|
206
215
|
<slot slot="footer" name="dialogFooter"></slot>
|
|
207
216
|
</column-check-dialog>
|
|
217
|
+
<nf-drawer
|
|
218
|
+
ref="columnCheckNfDrawer"
|
|
219
|
+
size="680px"
|
|
220
|
+
v-if="checkMode === 'drawer'"
|
|
221
|
+
:title="moreDialogTitle"
|
|
222
|
+
:cancel-button-text="columnCheckCancelButtonText"
|
|
223
|
+
:confirm-button-text="columnCheckConfirmButtonText"
|
|
224
|
+
:destroy-on-close="true"
|
|
225
|
+
:visible.sync="configNfSearchItemVisibleDialog"
|
|
226
|
+
:tabs="columnCheckTabs"
|
|
227
|
+
:current-tab="columnCheckCurrentTab"
|
|
228
|
+
@confirm="columnCheckConfirm"
|
|
229
|
+
@changeTab="(done) => $emit('changeTab', done)"
|
|
230
|
+
@cancel="(event) => $emit('cancel', event)"
|
|
231
|
+
>
|
|
232
|
+
<slot slot="title" name="columCheckTitle" />
|
|
233
|
+
<slot slot="footer" name="columCheckFooter" />
|
|
234
|
+
<column-check-drawer
|
|
235
|
+
:search-placeholder="columnCheckSearchPlaceholder"
|
|
236
|
+
:fixed-left-desc="columnCheckFixedLeftDesc"
|
|
237
|
+
:clear-desc="columnCheckClearDesc"
|
|
238
|
+
:no-fixed-desc="columnCheckNoFixedDesc"
|
|
239
|
+
:get-checked-length-desc="columnCheckGetCheckedLengthDesc"
|
|
240
|
+
:get-all-check-desc="columnCheckGetAllCheckDesc"
|
|
241
|
+
ref="columnCheckDrawer"
|
|
242
|
+
:storage-key="storageKey"
|
|
243
|
+
:table-columns="formOptions"
|
|
244
|
+
:select-empty-warning-tips="selectEmptyWarningTips"
|
|
245
|
+
/>
|
|
246
|
+
</nf-drawer>
|
|
208
247
|
</div>
|
|
209
248
|
</template>
|
|
210
249
|
|
|
@@ -212,7 +251,7 @@
|
|
|
212
251
|
import { defineComponent } from 'vue-demi'
|
|
213
252
|
|
|
214
253
|
export default defineComponent({
|
|
215
|
-
name:
|
|
254
|
+
name: 'nf-search-from'
|
|
216
255
|
})
|
|
217
256
|
</script>
|
|
218
257
|
|
|
@@ -220,6 +259,8 @@ export default defineComponent({
|
|
|
220
259
|
<script lang="ts" setup>
|
|
221
260
|
import SearchFormItem from './nf-search-form-item.vue'
|
|
222
261
|
import ColumnCheckDialog from './nf-column-check-dialog.vue'
|
|
262
|
+
import ColumnCheckDrawer from './nf-column-check-drawer.vue'
|
|
263
|
+
|
|
223
264
|
import {
|
|
224
265
|
createUniqueString,
|
|
225
266
|
debounce
|
|
@@ -235,6 +276,11 @@ import {
|
|
|
235
276
|
onUnmounted,
|
|
236
277
|
nextTick
|
|
237
278
|
} from 'vue-demi'
|
|
279
|
+
import { ITabItem } from '@94ai/nf-drawer/lib/types'
|
|
280
|
+
import {
|
|
281
|
+
ElTableColumnAttributes,
|
|
282
|
+
NfTableColumnAttributes
|
|
283
|
+
} from '@94ai/nf-table/lib/types'
|
|
238
284
|
|
|
239
285
|
|
|
240
286
|
const props = withDefaults(defineProps<{
|
|
@@ -246,12 +292,9 @@ const props = withDefaults(defineProps<{
|
|
|
246
292
|
columns?: number,
|
|
247
293
|
showBtn?: boolean,
|
|
248
294
|
isCollapse?: boolean,
|
|
249
|
-
|
|
250
295
|
/**
|
|
251
296
|
* 以下同el-form配置项
|
|
252
297
|
*/
|
|
253
|
-
labelPosition?: 'top' | 'right' | 'left'
|
|
254
|
-
inline?: boolean
|
|
255
298
|
rules?: Record<string, any>
|
|
256
299
|
labelSuffix?: string
|
|
257
300
|
hideRequiredAsterisk?: boolean
|
|
@@ -261,39 +304,41 @@ const props = withDefaults(defineProps<{
|
|
|
261
304
|
validateOnRuleChange?: boolean
|
|
262
305
|
size?: 'medium' | 'small' | 'mini'
|
|
263
306
|
disabled?: boolean
|
|
264
|
-
labelWidth?: number,
|
|
265
|
-
|
|
266
307
|
/**
|
|
267
|
-
*
|
|
308
|
+
* 控制label和content和按钮的组合位置
|
|
268
309
|
*/
|
|
269
|
-
|
|
310
|
+
labelPosition?: 'top' | 'right' | 'left'
|
|
311
|
+
inline?: boolean
|
|
312
|
+
btnBoxLabel?: string
|
|
313
|
+
btnModel?: 'inline' | 'block'
|
|
270
314
|
/**
|
|
271
|
-
*
|
|
315
|
+
* 兼容ai-search-form控制item父dom宽度
|
|
272
316
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
317
|
+
itemWidth?: number,
|
|
318
|
+
labelWidth?: number,
|
|
275
319
|
/**
|
|
276
|
-
*
|
|
320
|
+
* 所有的表单项
|
|
277
321
|
*/
|
|
278
|
-
|
|
279
|
-
|
|
322
|
+
formOptions?: NfSearchFormItemOption[],
|
|
280
323
|
/**
|
|
281
|
-
*
|
|
324
|
+
* 列编辑,是否显示关闭选项功能
|
|
282
325
|
*/
|
|
283
|
-
|
|
284
|
-
|
|
326
|
+
closable?: boolean,
|
|
285
327
|
/**
|
|
286
|
-
*
|
|
328
|
+
* 列编辑,是否显示按钮配置表单项显示
|
|
287
329
|
*/
|
|
288
|
-
|
|
330
|
+
columnEdit?: boolean,
|
|
289
331
|
/**
|
|
290
|
-
*
|
|
332
|
+
* 列编辑,显示的表单项,prop数组
|
|
291
333
|
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
334
|
+
showItems?: string[],
|
|
335
|
+
priority?: 'cached' | 'value',
|
|
336
|
+
storageKey?: string
|
|
337
|
+
checkMode?: 'dialog' | 'drawer',
|
|
338
|
+
selectEmptyWarningTips?: string,
|
|
339
|
+
columnDisplayBtnText?: string
|
|
295
340
|
/**
|
|
296
|
-
*
|
|
341
|
+
* 列编辑按钮修饰
|
|
297
342
|
*/
|
|
298
343
|
checkBtnIcon?: string,
|
|
299
344
|
checkBtnType?: string,
|
|
@@ -303,8 +348,46 @@ const props = withDefaults(defineProps<{
|
|
|
303
348
|
checkBtnCircle?: boolean,
|
|
304
349
|
checkBtnLoading?: boolean,
|
|
305
350
|
checkBtnDisabled?: boolean,
|
|
306
|
-
checkBtnText?: string,
|
|
307
351
|
checkBtnClass?: string,
|
|
352
|
+
/**
|
|
353
|
+
* 列编辑drawer/dialog
|
|
354
|
+
*/
|
|
355
|
+
columnCheckCancelButtonText?: string,
|
|
356
|
+
columnCheckConfirmButtonText?: string,
|
|
357
|
+
moreDialogTitle?: string,
|
|
358
|
+
/**
|
|
359
|
+
* 列编辑dialog设置
|
|
360
|
+
*/
|
|
361
|
+
moreDialogWidth?: string,
|
|
362
|
+
modalAppendToBody?: boolean,
|
|
363
|
+
modal?: boolean,
|
|
364
|
+
fullscreen?: boolean,
|
|
365
|
+
top?: string,
|
|
366
|
+
appendToBody?: boolean,
|
|
367
|
+
lockScroll?: boolean,
|
|
368
|
+
customClass?: string,
|
|
369
|
+
closeOnlickModal?: boolean,
|
|
370
|
+
closeOnPressEscape?: boolean,
|
|
371
|
+
showClose?: boolean,
|
|
372
|
+
beforeClose?: Function,
|
|
373
|
+
center?: boolean,
|
|
374
|
+
destroyOnClose?: boolean,
|
|
375
|
+
/**
|
|
376
|
+
* 列编辑drawer
|
|
377
|
+
*/
|
|
378
|
+
columnCheckSearchPlaceholder?: string
|
|
379
|
+
columnCheckFixedLeftDesc?: string
|
|
380
|
+
columnCheckClearDesc?: string
|
|
381
|
+
columnCheckNoFixedDesc?: string
|
|
382
|
+
columnCheckGetCheckedLengthDesc?: Function
|
|
383
|
+
columnCheckGetAllCheckDesc?: Function
|
|
384
|
+
columnCheckTabs?: ITabItem[],
|
|
385
|
+
columnCheckCurrentTab?: string,
|
|
386
|
+
/**
|
|
387
|
+
* 兼容ai-search-form,控制额外的默认功能按钮
|
|
388
|
+
*/
|
|
389
|
+
btnItems?: string[] | 'search' | 'export' | 'reset' | '',
|
|
390
|
+
reverseBtnSlot?: boolean,
|
|
308
391
|
/**
|
|
309
392
|
* 导出按钮
|
|
310
393
|
*/
|
|
@@ -344,37 +427,17 @@ const props = withDefaults(defineProps<{
|
|
|
344
427
|
resetBtnDisabled?: boolean,
|
|
345
428
|
resetBtnText?: string,
|
|
346
429
|
resetBtnClass?: string,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
reverseBtnSlot?: boolean,
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* 字段弹框设置
|
|
353
|
-
*/
|
|
354
|
-
moreDialogWidth?: string,
|
|
355
|
-
moreDialogTitle?: string,
|
|
356
|
-
modalAppendToBody?: boolean,
|
|
357
|
-
modal?: boolean,
|
|
358
|
-
fullscreen?: boolean,
|
|
359
|
-
top?: string,
|
|
360
|
-
appendToBody?: boolean,
|
|
361
|
-
lockScroll?: boolean,
|
|
362
|
-
customClass?: string,
|
|
363
|
-
closeOnlickModal?: boolean,
|
|
364
|
-
closeOnPressEscape?: boolean,
|
|
365
|
-
showClose?: boolean,
|
|
366
|
-
beforeClose?: Function,
|
|
367
|
-
center?: boolean,
|
|
368
|
-
destroyOnClose?: boolean,
|
|
369
|
-
|
|
370
430
|
}>(), {
|
|
371
|
-
|
|
431
|
+
selectEmptyWarningTips: '请选择至少一个选项',
|
|
432
|
+
priority: 'cached',
|
|
433
|
+
columnDisplayBtnText: '添加筛选条件',
|
|
434
|
+
storageKey: 'nf-search-form-columns-cached-key',
|
|
435
|
+
checkMode: 'drawer',
|
|
372
436
|
upIcon: 'icon-xiangshang2',
|
|
373
437
|
downIcon: 'icon-xiangxia2',
|
|
374
438
|
showBtn: true,
|
|
375
|
-
isCollapse:
|
|
439
|
+
isCollapse: false,
|
|
376
440
|
columns: 3,
|
|
377
|
-
|
|
378
441
|
labelPosition: 'top',
|
|
379
442
|
inline: true,
|
|
380
443
|
rules: undefined,
|
|
@@ -387,18 +450,15 @@ const props = withDefaults(defineProps<{
|
|
|
387
450
|
size: undefined,
|
|
388
451
|
disabled: false,
|
|
389
452
|
labelWidth: 150,
|
|
390
|
-
|
|
391
453
|
formOptions: () => [],
|
|
392
|
-
showItems:() => [],
|
|
454
|
+
showItems: () => [],
|
|
393
455
|
closable: false,
|
|
394
456
|
itemWidth: 190,
|
|
395
457
|
btnItems: () => '',
|
|
396
|
-
|
|
397
|
-
isShowAdd: true,
|
|
458
|
+
columnEdit: false,
|
|
398
459
|
btnBoxLabel: '',
|
|
399
460
|
btnModel: 'block',
|
|
400
|
-
|
|
401
|
-
checkBtnIcon: 'el-icon-plus',
|
|
461
|
+
checkBtnIcon: '',
|
|
402
462
|
checkBtnPlain: true,
|
|
403
463
|
checkBtnType: '',
|
|
404
464
|
checkBtnSize: 'mini',
|
|
@@ -406,9 +466,7 @@ const props = withDefaults(defineProps<{
|
|
|
406
466
|
checkBtnCircle: false,
|
|
407
467
|
checkBtnLoading: false,
|
|
408
468
|
checkBtnDisabled: false,
|
|
409
|
-
checkBtnText: '定制表单列目显示隐藏',
|
|
410
469
|
checkBtnClass: '',
|
|
411
|
-
|
|
412
470
|
queryBtnIcon: '',
|
|
413
471
|
queryBtnPlain: false,
|
|
414
472
|
queryBtnType: 'primary',
|
|
@@ -419,7 +477,6 @@ const props = withDefaults(defineProps<{
|
|
|
419
477
|
queryBtnDisabled: false,
|
|
420
478
|
queryBtnText: '查询',
|
|
421
479
|
queryBtnClass: '',
|
|
422
|
-
|
|
423
480
|
resetBtnIcon: '',
|
|
424
481
|
resetBtnPlain: true,
|
|
425
482
|
resetBtnType: 'default',
|
|
@@ -430,7 +487,6 @@ const props = withDefaults(defineProps<{
|
|
|
430
487
|
resetBtnDisabled: false,
|
|
431
488
|
resetBtnText: '重置',
|
|
432
489
|
resetBtnClass: '',
|
|
433
|
-
|
|
434
490
|
exportBtnIcon: '',
|
|
435
491
|
exportBtnPlain: true,
|
|
436
492
|
exportBtnType: 'primary',
|
|
@@ -441,9 +497,7 @@ const props = withDefaults(defineProps<{
|
|
|
441
497
|
exportBtnDisabled: false,
|
|
442
498
|
exportBtnText: '导出',
|
|
443
499
|
exportBtnClass: '',
|
|
444
|
-
|
|
445
500
|
reverseBtnSlot: false,
|
|
446
|
-
|
|
447
501
|
moreDialogWidth: '600',
|
|
448
502
|
moreDialogTitle: '设置显示查询框',
|
|
449
503
|
modalAppendToBody: true,
|
|
@@ -459,6 +513,14 @@ const props = withDefaults(defineProps<{
|
|
|
459
513
|
beforeClose: undefined,
|
|
460
514
|
center: false,
|
|
461
515
|
destroyOnClose: false,
|
|
516
|
+
columnCheckCancelButtonText: '取消',
|
|
517
|
+
columnCheckConfirmButtonText: '确定',
|
|
518
|
+
columnCheckSearchPlaceholder: '搜索',
|
|
519
|
+
columnCheckFixedLeftDesc: '固定在左侧',
|
|
520
|
+
columnCheckClearDesc: '清除',
|
|
521
|
+
columnCheckNoFixedDesc: '不固定',
|
|
522
|
+
columnCheckGetCheckedLengthDesc: (length) => '已选(' + length + ')',
|
|
523
|
+
columnCheckGetAllCheckDesc: (length) => '全选(' + length + ')'
|
|
462
524
|
})
|
|
463
525
|
|
|
464
526
|
const emit = defineEmits<{
|
|
@@ -496,30 +558,109 @@ const emit = defineEmits<{
|
|
|
496
558
|
* @param e
|
|
497
559
|
*/
|
|
498
560
|
(e: 'isCollapseChange', event: boolean): void
|
|
561
|
+
/**
|
|
562
|
+
* 同步showItems
|
|
563
|
+
* @param e
|
|
564
|
+
* @param event
|
|
565
|
+
*/
|
|
566
|
+
(e: 'update:showItems', event: string[] | undefined): void
|
|
499
567
|
}>()
|
|
500
568
|
|
|
501
|
-
const
|
|
569
|
+
const instance = getCurrentInstance()?.proxy
|
|
502
570
|
const defaultButtonSlot = ref()
|
|
571
|
+
const nfSearchFormRef = ref()
|
|
572
|
+
const columnCheckNfDrawer = ref()
|
|
573
|
+
const columnCheckDrawer = ref()
|
|
574
|
+
const columnCheckDialog = ref()
|
|
575
|
+
|
|
503
576
|
/**
|
|
504
577
|
* 表单填充的数据
|
|
505
578
|
*/
|
|
506
579
|
const nfSearchFormModel = ref<Record<string, any>>({})
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* 同步用户参数
|
|
583
|
+
*/
|
|
584
|
+
const initLocalShow = () => {
|
|
585
|
+
return props.formOptions.filter(item => {
|
|
586
|
+
if (props.showItems?.includes(item.prop!)) {
|
|
587
|
+
item.initHidden = true
|
|
588
|
+
}
|
|
589
|
+
return item.initHidden
|
|
590
|
+
}).map(item => item.prop!)
|
|
591
|
+
}
|
|
507
592
|
/**
|
|
508
593
|
* 表单显示的item集合
|
|
509
594
|
*/
|
|
510
|
-
const localShowItems = ref<string[]>(
|
|
595
|
+
const localShowItems = ref<string[]>(initLocalShow())
|
|
596
|
+
watch(() => localShowItems.value?.length, () => {
|
|
597
|
+
emit('update:showItems', localShowItems.value)
|
|
598
|
+
}, {
|
|
599
|
+
immediate: true
|
|
600
|
+
})
|
|
601
|
+
const syncLocalShowColumnToCookies = () => {
|
|
602
|
+
if (props.columnEdit) {
|
|
603
|
+
const columnState = {}
|
|
604
|
+
props.formOptions.map((i, index) => {
|
|
605
|
+
const prop = i.prop
|
|
606
|
+
columnState[prop!] = {
|
|
607
|
+
initHidden: i.initHidden || false,
|
|
608
|
+
prop,
|
|
609
|
+
index
|
|
610
|
+
}
|
|
611
|
+
})
|
|
612
|
+
// @ts-ignore
|
|
613
|
+
instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1)
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
const syncCookiesToLocalShowColumn = () => {
|
|
617
|
+
if (props.columnEdit) {
|
|
618
|
+
let columnState: string | NfTableColumnAttributes | null = instance?.$cookies?.get(props.storageKey)
|
|
619
|
+
if (columnState) {
|
|
620
|
+
if (typeof columnState === 'string') {
|
|
621
|
+
columnState = JSON.parse(columnState)
|
|
622
|
+
}
|
|
623
|
+
const showColumnItems: string[] = []
|
|
624
|
+
for (const key in columnState as NfTableColumnAttributes) {
|
|
625
|
+
if (!columnState![key].initHidden) {
|
|
626
|
+
showColumnItems.push(columnState![key].prop)
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
localShowItems.value = showColumnItems
|
|
630
|
+
syncShowItemToInitHidden()
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
const syncShowItemToInitHidden = () => {
|
|
636
|
+
props.formOptions.forEach(item => {
|
|
637
|
+
if (localShowItems.value?.includes(item.prop!)) {
|
|
638
|
+
item.initHidden = false
|
|
639
|
+
} else {
|
|
640
|
+
item.initHidden = true
|
|
641
|
+
}
|
|
642
|
+
})
|
|
643
|
+
}
|
|
644
|
+
if (props.columnEdit) {
|
|
645
|
+
// 同步缓存参数
|
|
646
|
+
const cached = instance?.$cookies?.get(props.storageKey)
|
|
647
|
+
const cachedPriority = props.priority === 'cached'
|
|
648
|
+
|
|
649
|
+
if (cachedPriority ? cached : localShowItems.value?.length) {
|
|
650
|
+
cachedPriority ? syncCookiesToLocalShowColumn() : syncLocalShowColumnToCookies()
|
|
651
|
+
} else if (cachedPriority ? localShowItems.value?.length : cached) {
|
|
652
|
+
cachedPriority ? syncLocalShowColumnToCookies() : syncCookiesToLocalShowColumn()
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
511
656
|
/**
|
|
512
657
|
* 超过数量显示更多
|
|
513
658
|
*/
|
|
514
659
|
const configNfSearchItemVisibleDialog = ref(false)
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const
|
|
519
|
-
return props.formOptions.map(v => {
|
|
520
|
-
return createUniqueString()
|
|
521
|
-
})
|
|
522
|
-
})
|
|
660
|
+
/**
|
|
661
|
+
* 计算一行展示的个数
|
|
662
|
+
*/
|
|
663
|
+
const newColumns = ref(3)
|
|
523
664
|
|
|
524
665
|
/**
|
|
525
666
|
* 定制按钮
|
|
@@ -531,28 +672,47 @@ const isShowBtnBoxSlot = computed(() => {
|
|
|
531
672
|
/**
|
|
532
673
|
* 转换成最终的表单项渲染数据
|
|
533
674
|
*/
|
|
534
|
-
const renderSearchFormItemOptions =
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
nfSearchFormItemOptions.push(item)
|
|
542
|
-
}
|
|
675
|
+
const renderSearchFormItemOptions = ref<NfSearchFormItemOption[]>([])
|
|
676
|
+
const syncCookiesToSearchFormItemOptions = (readCached = true) => {
|
|
677
|
+
const columns = props.formOptions!.map((item, index) => {
|
|
678
|
+
item._index = index
|
|
679
|
+
item.__index = index
|
|
680
|
+
item.key = item.key || createUniqueString()
|
|
681
|
+
return item
|
|
543
682
|
})
|
|
544
|
-
|
|
545
|
-
|
|
683
|
+
if (readCached && props.columnEdit) {
|
|
684
|
+
// 读取缓存 Column 配置
|
|
685
|
+
let columnState: string | NfTableColumnAttributes | null = instance?.$cookies?.get(props.storageKey)
|
|
686
|
+
if (columnState) {
|
|
687
|
+
if (typeof columnState === 'string') {
|
|
688
|
+
columnState = JSON.parse(columnState)
|
|
689
|
+
}
|
|
690
|
+
for (const key in columnState as NfTableColumnAttributes) {
|
|
691
|
+
const state = columnState![key]
|
|
692
|
+
columns.every(i => {
|
|
693
|
+
if (i.prop === key) {
|
|
694
|
+
i.initHidden = state.initHidden
|
|
695
|
+
i._index = state.index
|
|
696
|
+
return false
|
|
697
|
+
}
|
|
698
|
+
return true
|
|
699
|
+
})
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
renderSearchFormItemOptions.value = columns.sort((a, b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0)
|
|
704
|
+
}
|
|
705
|
+
syncCookiesToSearchFormItemOptions()
|
|
546
706
|
|
|
547
707
|
/**
|
|
548
708
|
* 判断SearchItem是否显示
|
|
549
709
|
* @param prop
|
|
550
710
|
*/
|
|
551
|
-
const itemIsShow = (
|
|
711
|
+
const itemIsShow = (item: NfSearchFormItemOption) => {
|
|
552
712
|
if (!localShowItems.value?.length) {
|
|
553
713
|
return true
|
|
554
714
|
}
|
|
555
|
-
return localShowItems.value.includes(prop)
|
|
715
|
+
return localShowItems.value.includes(item.prop!) && !item.initHidden
|
|
556
716
|
}
|
|
557
717
|
|
|
558
718
|
|
|
@@ -563,9 +723,9 @@ watch(
|
|
|
563
723
|
() => nfSearchFormModel.value,
|
|
564
724
|
() => {
|
|
565
725
|
emit('onChange', nfSearchFormModel.value)
|
|
566
|
-
}, {
|
|
567
|
-
|
|
568
|
-
})
|
|
726
|
+
}, {
|
|
727
|
+
deep: true
|
|
728
|
+
})
|
|
569
729
|
|
|
570
730
|
const showBtnBoxLabel = ref('')
|
|
571
731
|
|
|
@@ -577,17 +737,6 @@ watch(() => {
|
|
|
577
737
|
immediate: true
|
|
578
738
|
})
|
|
579
739
|
|
|
580
|
-
/**
|
|
581
|
-
* 同步展示的数据项
|
|
582
|
-
*/
|
|
583
|
-
watch(() => {
|
|
584
|
-
return props.showItems
|
|
585
|
-
}, () => {
|
|
586
|
-
localShowItems.value = props.showItems?.length ? [...props.showItems] : (props.formOptions?.map(_ => _.prop!) || [])
|
|
587
|
-
}, {
|
|
588
|
-
immediate: true
|
|
589
|
-
})
|
|
590
|
-
|
|
591
740
|
|
|
592
741
|
/**
|
|
593
742
|
* 初始化formData表单数据
|
|
@@ -601,6 +750,11 @@ onBeforeMount(() => {
|
|
|
601
750
|
obj[v.prop!] = undefined
|
|
602
751
|
}
|
|
603
752
|
})
|
|
753
|
+
for (const key in obj) {
|
|
754
|
+
if (!localShowItems.value.includes(key)) {
|
|
755
|
+
delete obj[key]
|
|
756
|
+
}
|
|
757
|
+
}
|
|
604
758
|
nfSearchFormModel.value = obj
|
|
605
759
|
})
|
|
606
760
|
|
|
@@ -612,27 +766,48 @@ const isCollapseChange = async (val: boolean) => {
|
|
|
612
766
|
|
|
613
767
|
|
|
614
768
|
const onResize = () => {
|
|
615
|
-
if (props.btnModel==='inline' && !props.btnBoxLabel && props.labelPosition === 'top') {
|
|
769
|
+
if (props.btnModel === 'inline' && !props.btnBoxLabel && props.labelPosition === 'top') {
|
|
616
770
|
if (nfSearchFormRef.value.$el.getBoundingClientRect().left === defaultButtonSlot.value.$el.getBoundingClientRect().left) {
|
|
617
771
|
showBtnBoxLabel.value = ''
|
|
618
772
|
} else {
|
|
619
|
-
showBtnBoxLabel.value = '
|
|
773
|
+
showBtnBoxLabel.value = '...'
|
|
620
774
|
}
|
|
621
775
|
}
|
|
622
776
|
}
|
|
623
777
|
|
|
778
|
+
const calcColumns = () => {
|
|
779
|
+
if (!nfSearchFormRef.value) return
|
|
780
|
+
let count = 0
|
|
781
|
+
const formWidth = nfSearchFormRef.value.$el.offsetWidth
|
|
782
|
+
nfSearchFormRef.value.formItems.reduce((prev, cur) => {
|
|
783
|
+
// 每项的宽度加上marginRight:16
|
|
784
|
+
const ret = prev + cur.$el.offsetWidth + 16
|
|
785
|
+
if (ret > formWidth) return prev
|
|
786
|
+
count += 1
|
|
787
|
+
return ret
|
|
788
|
+
}, 0)
|
|
789
|
+
newColumns.value = count
|
|
790
|
+
}
|
|
791
|
+
|
|
624
792
|
const debounceResize = debounce(onResize, 100, false)
|
|
793
|
+
const debounceCalcColumns = debounce(calcColumns, 100, false)
|
|
625
794
|
|
|
626
795
|
onMounted(async () => {
|
|
627
796
|
window.addEventListener('resize', debounceResize)
|
|
797
|
+
window.addEventListener('resize', debounceCalcColumns)
|
|
628
798
|
await nextTick()
|
|
629
799
|
onResize()
|
|
800
|
+
calcColumns()
|
|
630
801
|
})
|
|
631
802
|
|
|
632
803
|
onUnmounted(() => {
|
|
633
804
|
window.removeEventListener('resize', debounceResize)
|
|
805
|
+
window.removeEventListener('resize', debounceCalcColumns)
|
|
634
806
|
})
|
|
635
807
|
|
|
808
|
+
/**
|
|
809
|
+
* 重置校验
|
|
810
|
+
*/
|
|
636
811
|
const resetNfSearchFormModel = () => {
|
|
637
812
|
nfSearchFormRef.value?.resetFields()
|
|
638
813
|
emit('onResetFields')
|
|
@@ -643,19 +818,23 @@ const resetNfSearchFormModel = () => {
|
|
|
643
818
|
* @param callback
|
|
644
819
|
*/
|
|
645
820
|
const onNfSearchFormValidate = (callback) => {
|
|
646
|
-
|
|
821
|
+
nfSearchFormRef.value.validate(valid => {
|
|
647
822
|
if (valid) {
|
|
648
|
-
callback()
|
|
823
|
+
callback?.()
|
|
649
824
|
}
|
|
650
825
|
})
|
|
651
826
|
}
|
|
652
|
-
|
|
827
|
+
/**
|
|
828
|
+
* 搜索
|
|
829
|
+
*/
|
|
653
830
|
const onNfSearchFormSearch = () => {
|
|
654
831
|
onNfSearchFormValidate(() => {
|
|
655
832
|
emit('onSearch', nfSearchFormModel.value)
|
|
656
833
|
})
|
|
657
834
|
}
|
|
658
|
-
|
|
835
|
+
/**
|
|
836
|
+
* 导出
|
|
837
|
+
*/
|
|
659
838
|
const onNfSearchFormExport = () => {
|
|
660
839
|
onNfSearchFormValidate(() => {
|
|
661
840
|
emit('onExport', nfSearchFormModel.value)
|
|
@@ -666,11 +845,16 @@ const onNfSearchFormExport = () => {
|
|
|
666
845
|
* 把该item暂时隐藏
|
|
667
846
|
* @param prop
|
|
668
847
|
*/
|
|
669
|
-
const hiddenNfSearchFormItemOptionField = (prop) => {
|
|
848
|
+
const hiddenNfSearchFormItemOptionField = async (prop) => {
|
|
670
849
|
const index = localShowItems.value.indexOf(prop)
|
|
671
850
|
if (index > -1) {
|
|
672
851
|
localShowItems.value.splice(index, 1)
|
|
852
|
+
syncShowItemToInitHidden()
|
|
853
|
+
syncLocalShowColumnToCookies()
|
|
854
|
+
syncCookiesToSearchFormItemOptions()
|
|
673
855
|
refreshNfSearchFormModel()
|
|
856
|
+
await nextTick()
|
|
857
|
+
onResize()
|
|
674
858
|
}
|
|
675
859
|
}
|
|
676
860
|
|
|
@@ -678,62 +862,132 @@ const hiddenNfSearchFormItemOptionField = (prop) => {
|
|
|
678
862
|
* 更新item对应的formData
|
|
679
863
|
* @param prop
|
|
680
864
|
*/
|
|
681
|
-
const refreshNfSearchFormModel = () => {
|
|
682
|
-
let changeTimer: undefined | ReturnType<typeof setTimeout> = undefined
|
|
865
|
+
const refreshNfSearchFormModel = async () => {
|
|
683
866
|
for (const key in nfSearchFormModel.value) {
|
|
684
867
|
if (!localShowItems.value.includes(key)) {
|
|
685
868
|
delete nfSearchFormModel.value[key]
|
|
686
869
|
}
|
|
687
870
|
}
|
|
688
871
|
emit('onChange', nfSearchFormModel.value)
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
872
|
+
await nextTick()
|
|
873
|
+
emit('itemsChange', localShowItems.value)
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
const columnCheckConfirmFeedback = (value: Record<string, any>) => {
|
|
877
|
+
if (!props.columnEdit) {
|
|
878
|
+
const itemsList: string[] = []
|
|
879
|
+
for (const key in value) {
|
|
880
|
+
if (value[key]) {
|
|
881
|
+
itemsList.push(key)
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
localShowItems.value = itemsList
|
|
885
|
+
syncShowItemToInitHidden()
|
|
692
886
|
}
|
|
693
|
-
changeTimer = setTimeout(() => {
|
|
694
|
-
clearTimeout(changeTimer!)
|
|
695
|
-
changeTimer = undefined
|
|
696
|
-
emit('itemsChange', localShowItems.value)
|
|
697
|
-
})
|
|
698
887
|
}
|
|
699
888
|
|
|
889
|
+
// 抽屉确定
|
|
890
|
+
const columnCheckConfirm = async (cb, error) => {
|
|
891
|
+
try {
|
|
892
|
+
const value = columnCheckDrawer.value.syncTableColumnsToCookies()
|
|
893
|
+
columnCheckConfirmFeedback(value)
|
|
894
|
+
syncCookiesToLocalShowColumn()
|
|
895
|
+
syncCookiesToSearchFormItemOptions()
|
|
896
|
+
refreshNfSearchFormModel()
|
|
897
|
+
await nextTick()
|
|
898
|
+
onResize()
|
|
899
|
+
cb()
|
|
900
|
+
} catch (e) {
|
|
901
|
+
error()
|
|
902
|
+
console.log(e)
|
|
903
|
+
}
|
|
904
|
+
}
|
|
700
905
|
|
|
701
906
|
/**
|
|
702
907
|
* 保存表单显示的字段
|
|
703
|
-
* @param value
|
|
704
908
|
*/
|
|
705
|
-
const nfSearchFormItemOptionFieldsSave = (value) => {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
}
|
|
713
|
-
if (JSON.stringify(localShowItems.value) !== JSON.stringify(itemsList)) {
|
|
714
|
-
localShowItems.value = itemsList
|
|
715
|
-
emit('onChange', nfSearchFormModel.value)
|
|
716
|
-
if (changeTimer) {
|
|
717
|
-
clearTimeout(changeTimer)
|
|
718
|
-
changeTimer = undefined
|
|
719
|
-
}
|
|
720
|
-
changeTimer = setTimeout(() => {
|
|
721
|
-
clearTimeout(changeTimer)
|
|
722
|
-
changeTimer = undefined
|
|
723
|
-
emit('itemsChange', localShowItems.value)
|
|
724
|
-
})
|
|
725
|
-
}
|
|
909
|
+
const nfSearchFormItemOptionFieldsSave = async (value) => {
|
|
910
|
+
columnCheckConfirmFeedback(value)
|
|
911
|
+
syncCookiesToLocalShowColumn()
|
|
912
|
+
syncCookiesToSearchFormItemOptions()
|
|
913
|
+
refreshNfSearchFormModel()
|
|
914
|
+
await nextTick()
|
|
915
|
+
onResize()
|
|
726
916
|
}
|
|
727
917
|
|
|
728
918
|
defineExpose({
|
|
919
|
+
/**
|
|
920
|
+
* 列编辑显示的列prop
|
|
921
|
+
*/
|
|
922
|
+
localShowItems,
|
|
923
|
+
/**
|
|
924
|
+
* 列编辑同步组件到cookies
|
|
925
|
+
*/
|
|
926
|
+
syncLocalShowColumnToCookies,
|
|
927
|
+
/**
|
|
928
|
+
* 列编辑同步cookies到组件localShowItems
|
|
929
|
+
*/
|
|
930
|
+
syncCookiesToLocalShowColumn,
|
|
931
|
+
/**
|
|
932
|
+
* showItems同步props.formOptions[i].initHidden
|
|
933
|
+
*/
|
|
934
|
+
syncShowItemToInitHidden,
|
|
935
|
+
/**
|
|
936
|
+
* 列编辑隐藏某个表单列目
|
|
937
|
+
*/
|
|
938
|
+
hiddenNfSearchFormItemOptionField,
|
|
939
|
+
/**
|
|
940
|
+
* 列编辑操作后刷新表单数据模式
|
|
941
|
+
*/
|
|
942
|
+
refreshNfSearchFormModel,
|
|
943
|
+
/**
|
|
944
|
+
* 渲染表单项数据
|
|
945
|
+
*/
|
|
729
946
|
renderSearchFormItemOptions,
|
|
947
|
+
/**
|
|
948
|
+
* 重置
|
|
949
|
+
*/
|
|
730
950
|
resetNfSearchFormModel,
|
|
951
|
+
/**
|
|
952
|
+
* 校验
|
|
953
|
+
*/
|
|
731
954
|
onNfSearchFormValidate,
|
|
955
|
+
/**
|
|
956
|
+
* 搜索
|
|
957
|
+
*/
|
|
732
958
|
onNfSearchFormSearch,
|
|
959
|
+
/**
|
|
960
|
+
* 导出
|
|
961
|
+
*/
|
|
733
962
|
onNfSearchFormExport,
|
|
963
|
+
/**
|
|
964
|
+
* 表单数据
|
|
965
|
+
*/
|
|
734
966
|
nfSearchFormModel,
|
|
967
|
+
/**
|
|
968
|
+
* 表单 ref
|
|
969
|
+
*/
|
|
735
970
|
nfSearchFormRef,
|
|
971
|
+
/**
|
|
972
|
+
* 列编辑nf-drawer ref
|
|
973
|
+
*/
|
|
974
|
+
columnCheckNfDrawer,
|
|
975
|
+
/**
|
|
976
|
+
* 列编辑column-check-dialog ref
|
|
977
|
+
*/
|
|
978
|
+
columnCheckDialog,
|
|
979
|
+
/**
|
|
980
|
+
* 列编辑column-check-drawer ref
|
|
981
|
+
*/
|
|
982
|
+
columnCheckDrawer,
|
|
983
|
+
/**
|
|
984
|
+
* 列编辑dialog/drawer显示/隐藏
|
|
985
|
+
*/
|
|
736
986
|
configNfSearchItemVisibleDialog,
|
|
987
|
+
/**
|
|
988
|
+
* 列编辑同步cookies到组件渲染数据
|
|
989
|
+
*/
|
|
990
|
+
syncCookiesToSearchFormItemOptions
|
|
737
991
|
})
|
|
738
992
|
|
|
739
993
|
</script>
|