@94ai/nf-search-form 3.1.36 → 3.1.38
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 +28 -26
- package/lib/nf-column-check-dialog.vue.d.ts +1 -1
- package/lib/nf-search-form-item.vue.d.ts +1 -10
- package/lib/nf-search-form.cjs.js +626 -11676
- package/lib/nf-search-form.esm-bundler.js +626 -11676
- package/lib/nf-search-form.vue.d.ts +10 -9
- package/lib/types.d.ts +2 -2
- package/package/README.md +137 -0
- package/package/index.ts +8 -0
- package/package/nf-column-check-dialog.vue +161 -0
- package/package/nf-number-range.vue +130 -0
- package/package/nf-search-form-item.vue +380 -0
- package/package/nf-search-form.vue +737 -0
- package/package/nf-time-range.vue +128 -0
- package/package/style/css.ts +1 -0
- package/package/style/index.ts +1 -0
- package/package/tools.ts +163 -0
- package/package/types.ts +85 -0
- package/package.json +15 -15
- package/lib/nf-search-form.css +0 -824
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="nf-search-form">
|
|
3
|
+
<nf-form ref="nfSearchFormRef"
|
|
4
|
+
:model="nfSearchFormModel"
|
|
5
|
+
:inline="inline"
|
|
6
|
+
:label-position="labelPosition"
|
|
7
|
+
:rules="rules"
|
|
8
|
+
:label-suffix="labelSuffix"
|
|
9
|
+
:hide-required-asterisk="hideRequiredAsterisk"
|
|
10
|
+
:show-message="showMessage"
|
|
11
|
+
:inline-message="inlineMessage"
|
|
12
|
+
:status-icon="statusIcon"
|
|
13
|
+
:validate-on-rule-change="validateOnRuleChange"
|
|
14
|
+
:size="size"
|
|
15
|
+
:disabled="disabled"
|
|
16
|
+
|
|
17
|
+
:label-width="labelWidth+'px'"
|
|
18
|
+
|
|
19
|
+
:columns='columns'
|
|
20
|
+
:up-icon="upIcon"
|
|
21
|
+
:down-icon="downIcon"
|
|
22
|
+
:show-btn="showBtn"
|
|
23
|
+
:is-collapse="isCollapse"
|
|
24
|
+
@isCollapseChange="isCollapseChange"
|
|
25
|
+
>
|
|
26
|
+
<nf-form-item
|
|
27
|
+
:class="(item.class || '') + ' nf-search-form-nf-form-item'"
|
|
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"
|
|
39
|
+
>
|
|
40
|
+
<search-form-item v-model="nfSearchFormModel[item.prop]" :item-width="itemWidth" :label-width="labelWidth" :item-options="item">
|
|
41
|
+
<!-- 定制化SearchItem?提示-->
|
|
42
|
+
<template v-if="item.tooltip" :slot="item.tooltip.slot">
|
|
43
|
+
<slot :name="item.tooltip.slot" />
|
|
44
|
+
</template>
|
|
45
|
+
<!-- 定制化SearchItem插槽-->
|
|
46
|
+
<template v-if="item.slot" :slot="item.slot">
|
|
47
|
+
<slot :name="item.slot" />
|
|
48
|
+
</template>
|
|
49
|
+
</search-form-item>
|
|
50
|
+
<!-- 控制显示该表单项-->
|
|
51
|
+
<div v-if="closable" class="nf-search-form-nf-form-item-close-icon">
|
|
52
|
+
<i class="el-icon-error" @click="hiddenNfSearchFormItemOptionField(item.prop)" />
|
|
53
|
+
</div>
|
|
54
|
+
</nf-form-item>
|
|
55
|
+
<nf-form-item :label="showBtnBoxLabel" v-if="btnModel==='inline'" class="nf-search-form-nf-form-item-btn-box-label" ref="defaultButtonSlot">
|
|
56
|
+
<div class="nf-flex nf-flex-align-items-start">
|
|
57
|
+
<slot v-if="isShowBtnBoxSlot && !reverseBtnSlot" name="btnBox" />
|
|
58
|
+
<el-button
|
|
59
|
+
v-if="btnItems.includes('search')"
|
|
60
|
+
:type="queryBtnType"
|
|
61
|
+
:icon="queryBtnIcon"
|
|
62
|
+
:plain="queryBtnPlain"
|
|
63
|
+
:size="queryBtnSize"
|
|
64
|
+
:round="queryBtnRound"
|
|
65
|
+
:circle="queryBtnCircle"
|
|
66
|
+
:loading="queryBtnLoading"
|
|
67
|
+
:disabled="queryBtnDisabled"
|
|
68
|
+
:class="(queryBtnClass || '') + ' nf-btn-search'"
|
|
69
|
+
@click="onNfSearchFormSearch"
|
|
70
|
+
>{{ queryBtnText }}
|
|
71
|
+
</el-button>
|
|
72
|
+
<el-button
|
|
73
|
+
v-if="btnItems.includes('export')"
|
|
74
|
+
:type="exportBtnType"
|
|
75
|
+
:icon="exportBtnIcon"
|
|
76
|
+
:plain="exportBtnPlain"
|
|
77
|
+
:size="exportBtnSize"
|
|
78
|
+
:round="exportBtnRound"
|
|
79
|
+
:circle="exportBtnCircle"
|
|
80
|
+
:loading="exportBtnLoading"
|
|
81
|
+
:disabled="exportBtnDisabled"
|
|
82
|
+
:class="(exportBtnClass || '') + ' nf-btn-export'"
|
|
83
|
+
@click="onNfSearchFormExport"
|
|
84
|
+
>{{ exportBtnText }}
|
|
85
|
+
</el-button>
|
|
86
|
+
<el-button
|
|
87
|
+
v-if="btnItems.includes('reset')"
|
|
88
|
+
:type="resetBtnType"
|
|
89
|
+
:icon="resetBtnIcon"
|
|
90
|
+
:plain="resetBtnPlain"
|
|
91
|
+
:size="resetBtnSize"
|
|
92
|
+
:round="resetBtnRound"
|
|
93
|
+
:circle="resetBtnCircle"
|
|
94
|
+
:loading="resetBtnLoading"
|
|
95
|
+
:disabled="resetBtnDisabled"
|
|
96
|
+
:class="(resetBtnClass || '') + ' nf-btn-reset'"
|
|
97
|
+
@click="resetNfSearchFormModel"
|
|
98
|
+
>{{ resetBtnText }}
|
|
99
|
+
</el-button>
|
|
100
|
+
<el-button v-if="isShowAdd"
|
|
101
|
+
:type="checkBtnType"
|
|
102
|
+
:icon="checkBtnIcon"
|
|
103
|
+
:plain="checkBtnPlain"
|
|
104
|
+
:size="checkBtnSize"
|
|
105
|
+
:round="checkBtnRound"
|
|
106
|
+
:circle="checkBtnCircle"
|
|
107
|
+
:loading="checkBtnLoading"
|
|
108
|
+
:disabled="checkBtnDisabled"
|
|
109
|
+
:class="(checkBtnClass || '') + ' nf-btn-check'"
|
|
110
|
+
@click.stop="configNfSearchItemVisibleDialog = true"
|
|
111
|
+
>
|
|
112
|
+
{{ checkBtnText }}
|
|
113
|
+
</el-button>
|
|
114
|
+
<slot v-if="isShowBtnBoxSlot && reverseBtnSlot" name="btnBox" />
|
|
115
|
+
</div>
|
|
116
|
+
</nf-form-item>
|
|
117
|
+
</nf-form>
|
|
118
|
+
<div class="nf-flex nf-flex-align-items nf-mt10" v-if="btnModel==='block'">
|
|
119
|
+
<slot v-if="isShowBtnBoxSlot && !reverseBtnSlot" name="btnBox" />
|
|
120
|
+
<el-button
|
|
121
|
+
v-if="btnItems.includes('search')"
|
|
122
|
+
:type="queryBtnType"
|
|
123
|
+
:icon="queryBtnIcon"
|
|
124
|
+
:plain="queryBtnPlain"
|
|
125
|
+
:size="queryBtnSize"
|
|
126
|
+
:round="queryBtnRound"
|
|
127
|
+
:circle="queryBtnCircle"
|
|
128
|
+
:loading="queryBtnLoading"
|
|
129
|
+
:disabled="queryBtnDisabled"
|
|
130
|
+
:class="(queryBtnClass || '') + ' nf-btn-search'"
|
|
131
|
+
@click="onNfSearchFormSearch"
|
|
132
|
+
>{{ queryBtnText }}
|
|
133
|
+
</el-button>
|
|
134
|
+
<el-button
|
|
135
|
+
v-if="btnItems.includes('export')"
|
|
136
|
+
:type="exportBtnType"
|
|
137
|
+
:icon="exportBtnIcon"
|
|
138
|
+
:plain="exportBtnPlain"
|
|
139
|
+
:size="exportBtnSize"
|
|
140
|
+
:round="exportBtnRound"
|
|
141
|
+
:circle="exportBtnCircle"
|
|
142
|
+
:loading="exportBtnLoading"
|
|
143
|
+
:disabled="exportBtnDisabled"
|
|
144
|
+
:class="(exportBtnClass || '') + ' nf-btn-export'"
|
|
145
|
+
@click="onNfSearchFormExport"
|
|
146
|
+
>{{ exportBtnText }}
|
|
147
|
+
</el-button>
|
|
148
|
+
<el-button
|
|
149
|
+
v-if="btnItems.includes('reset')"
|
|
150
|
+
:type="resetBtnType"
|
|
151
|
+
:icon="resetBtnIcon"
|
|
152
|
+
:plain="resetBtnPlain"
|
|
153
|
+
:size="resetBtnSize"
|
|
154
|
+
:round="resetBtnRound"
|
|
155
|
+
:circle="resetBtnCircle"
|
|
156
|
+
:loading="resetBtnLoading"
|
|
157
|
+
:disabled="resetBtnDisabled"
|
|
158
|
+
:class="(resetBtnClass || '') + ' nf-btn-reset'"
|
|
159
|
+
@click="resetNfSearchFormModel"
|
|
160
|
+
>{{ resetBtnText }}
|
|
161
|
+
</el-button>
|
|
162
|
+
<el-button v-if="isShowAdd"
|
|
163
|
+
:type="checkBtnType"
|
|
164
|
+
:icon="checkBtnIcon"
|
|
165
|
+
:plain="checkBtnPlain"
|
|
166
|
+
:size="checkBtnSize"
|
|
167
|
+
:round="checkBtnRound"
|
|
168
|
+
:circle="checkBtnCircle"
|
|
169
|
+
:loading="checkBtnLoading"
|
|
170
|
+
:disabled="checkBtnDisabled"
|
|
171
|
+
:class="(checkBtnClass || '') + ' nf-btn-check'"
|
|
172
|
+
@click.stop="configNfSearchItemVisibleDialog = true"
|
|
173
|
+
>
|
|
174
|
+
{{ checkBtnText }}
|
|
175
|
+
</el-button>
|
|
176
|
+
<slot v-if="isShowBtnBoxSlot && reverseBtnSlot" name="btnBox" />
|
|
177
|
+
</div>
|
|
178
|
+
<column-check-dialog
|
|
179
|
+
v-if="configNfSearchItemVisibleDialog"
|
|
180
|
+
:show.sync="configNfSearchItemVisibleDialog"
|
|
181
|
+
:table-columns="formOptions"
|
|
182
|
+
:title="moreDialogTitle"
|
|
183
|
+
:width="moreDialogWidth"
|
|
184
|
+
:show-columns="localShowItems"
|
|
185
|
+
:modal-append-to-body="modalAppendToBody"
|
|
186
|
+
:modal="modal"
|
|
187
|
+
:fullscreen="fullscreen"
|
|
188
|
+
:top="top"
|
|
189
|
+
:append-to-body="appendToBody"
|
|
190
|
+
:lock-scroll="lockScroll"
|
|
191
|
+
:custom-class="customClass"
|
|
192
|
+
:close-on-click-modal="closeOnlickModal"
|
|
193
|
+
:close-on-press-escape="closeOnPressEscape"
|
|
194
|
+
:show-close="showClose"
|
|
195
|
+
:before-close="beforeClose"
|
|
196
|
+
:center="center"
|
|
197
|
+
:destroy-on-close="destroyOnClose"
|
|
198
|
+
@save="nfSearchFormItemOptionFieldsSave"
|
|
199
|
+
@open="$emit('open', $event)"
|
|
200
|
+
@opened="$emit('opened', $event)"
|
|
201
|
+
@close="$emit('close', $event)"
|
|
202
|
+
@closed="$emit('closed', $event)"
|
|
203
|
+
>
|
|
204
|
+
<slot slot="title" name="dialogTitle"></slot>
|
|
205
|
+
<slot slot="footer" name="dialogFooter"></slot>
|
|
206
|
+
</column-check-dialog>
|
|
207
|
+
</div>
|
|
208
|
+
</template>
|
|
209
|
+
|
|
210
|
+
<script lang="ts">
|
|
211
|
+
import { defineComponent } from 'vue-demi'
|
|
212
|
+
|
|
213
|
+
export default defineComponent({
|
|
214
|
+
name: "nf-search-from",
|
|
215
|
+
})
|
|
216
|
+
</script>
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
<script lang="ts" setup>
|
|
220
|
+
import SearchFormItem from './nf-search-form-item.vue'
|
|
221
|
+
import ColumnCheckDialog from './nf-column-check-dialog.vue'
|
|
222
|
+
import {
|
|
223
|
+
createUniqueString,
|
|
224
|
+
debounce
|
|
225
|
+
} from './tools'
|
|
226
|
+
import { NfSearchFormItemOption } from './types'
|
|
227
|
+
import {
|
|
228
|
+
ref,
|
|
229
|
+
computed,
|
|
230
|
+
getCurrentInstance,
|
|
231
|
+
watch,
|
|
232
|
+
onBeforeMount,
|
|
233
|
+
onMounted,
|
|
234
|
+
onUnmounted,
|
|
235
|
+
nextTick
|
|
236
|
+
} from 'vue-demi'
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
const props = withDefaults(defineProps<{
|
|
240
|
+
/**
|
|
241
|
+
* nf-form扩展配置项
|
|
242
|
+
*/
|
|
243
|
+
upIcon?: string,
|
|
244
|
+
downIcon?: string,
|
|
245
|
+
columns?: number,
|
|
246
|
+
showBtn?: boolean,
|
|
247
|
+
isCollapse?: boolean,
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 以下同el-form配置项
|
|
251
|
+
*/
|
|
252
|
+
labelPosition?: 'top' | 'right' | 'left'
|
|
253
|
+
inline?: boolean
|
|
254
|
+
rules?: Record<string, any>
|
|
255
|
+
labelSuffix?: string
|
|
256
|
+
hideRequiredAsterisk?: boolean
|
|
257
|
+
showMessage?: boolean
|
|
258
|
+
inlineMessage?: boolean
|
|
259
|
+
statusIcon?: boolean
|
|
260
|
+
validateOnRuleChange?: boolean
|
|
261
|
+
size?: 'medium' | 'small' | 'mini'
|
|
262
|
+
disabled?: boolean
|
|
263
|
+
labelWidth?: number,
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 所有的表单项
|
|
267
|
+
*/
|
|
268
|
+
formOptions?: NfSearchFormItemOption[],
|
|
269
|
+
/**
|
|
270
|
+
* 显示的表单项,prop数组
|
|
271
|
+
*/
|
|
272
|
+
showItems?: string[],
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* 是否显示关闭选项功能
|
|
276
|
+
*/
|
|
277
|
+
closable?: boolean,
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 兼容ai-search-form控制item父dom宽度
|
|
281
|
+
*/
|
|
282
|
+
itemWidth?: number,
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* 以下兼容ai-search-form,控制额外的默认功能按钮
|
|
286
|
+
*/
|
|
287
|
+
btnItems?: string[] | 'search' | 'export' | 'reset' | '',
|
|
288
|
+
/**
|
|
289
|
+
* 是否显示更多按钮配置表单项显示
|
|
290
|
+
*/
|
|
291
|
+
isShowAdd?: boolean,
|
|
292
|
+
btnBoxLabel?: string
|
|
293
|
+
btnModel?: 'inline' | 'block'
|
|
294
|
+
/**
|
|
295
|
+
* 更多按钮
|
|
296
|
+
*/
|
|
297
|
+
checkBtnIcon?: string,
|
|
298
|
+
checkBtnType?: string,
|
|
299
|
+
checkBtnPlain?: boolean,
|
|
300
|
+
checkBtnSize?: string,
|
|
301
|
+
checkBtnRound?: boolean,
|
|
302
|
+
checkBtnCircle?: boolean,
|
|
303
|
+
checkBtnLoading?: boolean,
|
|
304
|
+
checkBtnDisabled?: boolean,
|
|
305
|
+
checkBtnText?: string,
|
|
306
|
+
checkBtnClass?: string,
|
|
307
|
+
/**
|
|
308
|
+
* 导出按钮
|
|
309
|
+
*/
|
|
310
|
+
exportBtnIcon?: string,
|
|
311
|
+
exportBtnType?: string,
|
|
312
|
+
exportBtnPlain?: boolean,
|
|
313
|
+
exportBtnSize?: string,
|
|
314
|
+
exportBtnRound?: boolean,
|
|
315
|
+
exportBtnCircle?: boolean,
|
|
316
|
+
exportBtnLoading?: boolean,
|
|
317
|
+
exportBtnDisabled?: boolean,
|
|
318
|
+
exportBtnText?: string,
|
|
319
|
+
exportBtnClass?: string,
|
|
320
|
+
/**
|
|
321
|
+
* 查询按钮
|
|
322
|
+
*/
|
|
323
|
+
queryBtnIcon?: string,
|
|
324
|
+
queryBtnType?: string,
|
|
325
|
+
queryBtnPlain?: boolean,
|
|
326
|
+
queryBtnSize?: string,
|
|
327
|
+
queryBtnRound?: boolean,
|
|
328
|
+
queryBtnCircle?: boolean,
|
|
329
|
+
queryBtnLoading?: boolean,
|
|
330
|
+
queryBtnDisabled?: boolean,
|
|
331
|
+
queryBtnText?: string,
|
|
332
|
+
queryBtnClass?: string,
|
|
333
|
+
/**
|
|
334
|
+
* 重置按钮
|
|
335
|
+
*/
|
|
336
|
+
resetBtnIcon?: string,
|
|
337
|
+
resetBtnType?: string,
|
|
338
|
+
resetBtnPlain?: boolean,
|
|
339
|
+
resetBtnSize?: string,
|
|
340
|
+
resetBtnRound?: boolean,
|
|
341
|
+
resetBtnCircle?: boolean,
|
|
342
|
+
resetBtnLoading?: boolean,
|
|
343
|
+
resetBtnDisabled?: boolean,
|
|
344
|
+
resetBtnText?: string,
|
|
345
|
+
resetBtnClass?: string,
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
reverseBtnSlot?: boolean,
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* 字段弹框设置
|
|
352
|
+
*/
|
|
353
|
+
moreDialogWidth?: string,
|
|
354
|
+
moreDialogTitle?: string,
|
|
355
|
+
modalAppendToBody?: boolean,
|
|
356
|
+
modal?: boolean,
|
|
357
|
+
fullscreen?: boolean,
|
|
358
|
+
top?: string,
|
|
359
|
+
appendToBody?: boolean,
|
|
360
|
+
lockScroll?: boolean,
|
|
361
|
+
customClass?: string,
|
|
362
|
+
closeOnlickModal?: boolean,
|
|
363
|
+
closeOnPressEscape?: boolean,
|
|
364
|
+
showClose?: boolean,
|
|
365
|
+
beforeClose?: Function,
|
|
366
|
+
center?: boolean,
|
|
367
|
+
destroyOnClose?: boolean,
|
|
368
|
+
|
|
369
|
+
}>(), {
|
|
370
|
+
|
|
371
|
+
upIcon: 'icon-xiangshang2',
|
|
372
|
+
downIcon: 'icon-xiangxia2',
|
|
373
|
+
showBtn: true,
|
|
374
|
+
isCollapse: true,
|
|
375
|
+
columns: 3,
|
|
376
|
+
|
|
377
|
+
labelPosition: 'top',
|
|
378
|
+
inline: true,
|
|
379
|
+
rules: undefined,
|
|
380
|
+
labelSuffix: undefined,
|
|
381
|
+
hideRequiredAsterisk: false,
|
|
382
|
+
showMessage: true,
|
|
383
|
+
inlineMessage: false,
|
|
384
|
+
statusIcon: false,
|
|
385
|
+
validateOnRuleChange: true,
|
|
386
|
+
size: undefined,
|
|
387
|
+
disabled: false,
|
|
388
|
+
labelWidth: 150,
|
|
389
|
+
|
|
390
|
+
formOptions: () => [],
|
|
391
|
+
showItems:() => [],
|
|
392
|
+
closable: false,
|
|
393
|
+
itemWidth: 190,
|
|
394
|
+
btnItems: () => '',
|
|
395
|
+
|
|
396
|
+
isShowAdd: true,
|
|
397
|
+
btnBoxLabel: '',
|
|
398
|
+
btnModel: 'block',
|
|
399
|
+
|
|
400
|
+
checkBtnIcon: 'el-icon-plus',
|
|
401
|
+
checkBtnPlain: true,
|
|
402
|
+
checkBtnType: 'primary',
|
|
403
|
+
checkBtnSize: 'mini',
|
|
404
|
+
checkBtnRound: false,
|
|
405
|
+
checkBtnCircle: false,
|
|
406
|
+
checkBtnLoading: false,
|
|
407
|
+
checkBtnDisabled: false,
|
|
408
|
+
checkBtnText: '定制表单列目显示隐藏',
|
|
409
|
+
checkBtnClass: '',
|
|
410
|
+
|
|
411
|
+
queryBtnIcon: '',
|
|
412
|
+
queryBtnPlain: true,
|
|
413
|
+
queryBtnType: 'primary',
|
|
414
|
+
queryBtnSize: 'mini',
|
|
415
|
+
queryBtnRound: false,
|
|
416
|
+
queryBtnCircle: false,
|
|
417
|
+
queryBtnLoading: false,
|
|
418
|
+
queryBtnDisabled: false,
|
|
419
|
+
queryBtnText: '查询',
|
|
420
|
+
queryBtnClass: '',
|
|
421
|
+
|
|
422
|
+
resetBtnIcon: '',
|
|
423
|
+
resetBtnPlain: true,
|
|
424
|
+
resetBtnType: 'default',
|
|
425
|
+
resetBtnSize: 'mini',
|
|
426
|
+
resetBtnRound: false,
|
|
427
|
+
resetBtnCircle: false,
|
|
428
|
+
resetBtnLoading: false,
|
|
429
|
+
resetBtnDisabled: false,
|
|
430
|
+
resetBtnText: '重置',
|
|
431
|
+
resetBtnClass: '',
|
|
432
|
+
|
|
433
|
+
exportBtnIcon: '',
|
|
434
|
+
exportBtnPlain: true,
|
|
435
|
+
exportBtnType: 'primary',
|
|
436
|
+
exportBtnSize: 'mini',
|
|
437
|
+
exportBtnRound: false,
|
|
438
|
+
exportBtnCircle: false,
|
|
439
|
+
exportBtnLoading: false,
|
|
440
|
+
exportBtnDisabled: false,
|
|
441
|
+
exportBtnText: '导出',
|
|
442
|
+
exportBtnClass: '',
|
|
443
|
+
|
|
444
|
+
reverseBtnSlot: false,
|
|
445
|
+
|
|
446
|
+
moreDialogWidth: '600',
|
|
447
|
+
moreDialogTitle: '设置显示查询框',
|
|
448
|
+
modalAppendToBody: true,
|
|
449
|
+
modal: true,
|
|
450
|
+
fullscreen: false,
|
|
451
|
+
top: '15vh',
|
|
452
|
+
appendToBody: false,
|
|
453
|
+
lockScroll: true,
|
|
454
|
+
customClass: '',
|
|
455
|
+
closeOnlickModal: true,
|
|
456
|
+
closeOnPressEscape: true,
|
|
457
|
+
showClose: true,
|
|
458
|
+
beforeClose: undefined,
|
|
459
|
+
center: false,
|
|
460
|
+
destroyOnClose: false,
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
const emit = defineEmits<{
|
|
464
|
+
/**
|
|
465
|
+
* 通知FormData更改
|
|
466
|
+
* @param e
|
|
467
|
+
* @param event
|
|
468
|
+
*/
|
|
469
|
+
(e: 'onChange', event: Record<string, any>): void,
|
|
470
|
+
/**
|
|
471
|
+
* 通知显示Items更改
|
|
472
|
+
* @param e
|
|
473
|
+
* @param event
|
|
474
|
+
*/
|
|
475
|
+
(e: 'itemsChange', event: string[]): void
|
|
476
|
+
/**
|
|
477
|
+
* 搜索
|
|
478
|
+
* @param e
|
|
479
|
+
* @param event
|
|
480
|
+
*/
|
|
481
|
+
(e: 'onSearch', event: Record<string, any>): void
|
|
482
|
+
/**
|
|
483
|
+
* 导出
|
|
484
|
+
* @param e
|
|
485
|
+
* @param event
|
|
486
|
+
*/
|
|
487
|
+
(e: 'onExport', event: Record<string, any>): void
|
|
488
|
+
/**
|
|
489
|
+
* 重置字段
|
|
490
|
+
* @param e
|
|
491
|
+
*/
|
|
492
|
+
(e: 'onResetFields'): void
|
|
493
|
+
/**
|
|
494
|
+
* 表单折叠展开
|
|
495
|
+
* @param e
|
|
496
|
+
*/
|
|
497
|
+
(e: 'isCollapseChange', event: boolean): void
|
|
498
|
+
}>()
|
|
499
|
+
|
|
500
|
+
const nfSearchFormRef = ref()
|
|
501
|
+
const defaultButtonSlot = ref()
|
|
502
|
+
/**
|
|
503
|
+
* 表单填充的数据
|
|
504
|
+
*/
|
|
505
|
+
const nfSearchFormModel = ref<Record<string, any>>({})
|
|
506
|
+
/**
|
|
507
|
+
* 表单显示的item集合
|
|
508
|
+
*/
|
|
509
|
+
const localShowItems = ref<string[]>([])
|
|
510
|
+
/**
|
|
511
|
+
* 超过数量显示更多
|
|
512
|
+
*/
|
|
513
|
+
const configNfSearchItemVisibleDialog = ref(false)
|
|
514
|
+
|
|
515
|
+
const instance = getCurrentInstance()?.proxy
|
|
516
|
+
|
|
517
|
+
const newKeys = computed(() => {
|
|
518
|
+
return props.formOptions.map(v => {
|
|
519
|
+
return createUniqueString()
|
|
520
|
+
})
|
|
521
|
+
})
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* 定制按钮
|
|
525
|
+
*/
|
|
526
|
+
const isShowBtnBoxSlot = computed(() => {
|
|
527
|
+
return instance?.$slots.btnBox
|
|
528
|
+
})
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* 转换成最终的表单项渲染数据
|
|
532
|
+
*/
|
|
533
|
+
const renderSearchFormItemOptions = computed(() => {
|
|
534
|
+
if (!localShowItems.value?.length) { // 没有配置显示的选项,就显示全部
|
|
535
|
+
return props.formOptions
|
|
536
|
+
}
|
|
537
|
+
const nfSearchFormItemOptions: NfSearchFormItemOption[] = []
|
|
538
|
+
props.formOptions.map(item => {
|
|
539
|
+
if (itemIsShow(item.prop!)) {
|
|
540
|
+
nfSearchFormItemOptions.push(item)
|
|
541
|
+
}
|
|
542
|
+
})
|
|
543
|
+
return nfSearchFormItemOptions
|
|
544
|
+
})
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* 判断SearchItem是否显示
|
|
548
|
+
* @param prop
|
|
549
|
+
*/
|
|
550
|
+
const itemIsShow = (prop: string) => {
|
|
551
|
+
if (!localShowItems.value?.length) {
|
|
552
|
+
return true
|
|
553
|
+
}
|
|
554
|
+
return localShowItems.value.includes(prop)
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* 实时触发onChange
|
|
560
|
+
*/
|
|
561
|
+
watch(
|
|
562
|
+
() => nfSearchFormModel.value,
|
|
563
|
+
() => {
|
|
564
|
+
emit('onChange', nfSearchFormModel.value)
|
|
565
|
+
}, {
|
|
566
|
+
deep: true
|
|
567
|
+
})
|
|
568
|
+
|
|
569
|
+
const showBtnBoxLabel = ref('')
|
|
570
|
+
|
|
571
|
+
watch(() => {
|
|
572
|
+
return props.btnBoxLabel
|
|
573
|
+
}, () => {
|
|
574
|
+
showBtnBoxLabel.value = props.btnBoxLabel
|
|
575
|
+
}, {
|
|
576
|
+
immediate: true
|
|
577
|
+
})
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* 同步展示的数据项
|
|
581
|
+
*/
|
|
582
|
+
watch(() => {
|
|
583
|
+
return props.showItems
|
|
584
|
+
}, () => {
|
|
585
|
+
localShowItems.value = props.showItems?.length ? [...props.showItems] : (props.formOptions?.map(_ => _.prop!) || [])
|
|
586
|
+
}, {
|
|
587
|
+
immediate: true
|
|
588
|
+
})
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* 初始化formData表单数据
|
|
593
|
+
*/
|
|
594
|
+
onBeforeMount(() => {
|
|
595
|
+
const obj: Record<string, any> = {}
|
|
596
|
+
props.formOptions.forEach(v => {
|
|
597
|
+
if (v.initValue !== undefined) {
|
|
598
|
+
obj[v.prop!] = v.initValue
|
|
599
|
+
} else {
|
|
600
|
+
obj[v.prop!] = undefined
|
|
601
|
+
}
|
|
602
|
+
})
|
|
603
|
+
nfSearchFormModel.value = obj
|
|
604
|
+
})
|
|
605
|
+
|
|
606
|
+
const isCollapseChange = async (val: boolean) => {
|
|
607
|
+
emit('isCollapseChange', val)
|
|
608
|
+
await nextTick()
|
|
609
|
+
onResize()
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
const onResize = () => {
|
|
614
|
+
if (props.btnModel==='inline' && !props.btnBoxLabel && props.labelPosition === 'top') {
|
|
615
|
+
if (nfSearchFormRef.value.$el.getBoundingClientRect().left === defaultButtonSlot.value.$el.getBoundingClientRect().left) {
|
|
616
|
+
showBtnBoxLabel.value = ''
|
|
617
|
+
} else {
|
|
618
|
+
showBtnBoxLabel.value = '该部分透明度为0用来占位'
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
const debounceResize = debounce(onResize, 100, false)
|
|
624
|
+
|
|
625
|
+
onMounted(() => {
|
|
626
|
+
onResize()
|
|
627
|
+
window.addEventListener('resize', debounceResize)
|
|
628
|
+
})
|
|
629
|
+
|
|
630
|
+
onUnmounted(() => {
|
|
631
|
+
window.removeEventListener('resize', debounceResize)
|
|
632
|
+
})
|
|
633
|
+
|
|
634
|
+
const resetNfSearchFormModel = () => {
|
|
635
|
+
nfSearchFormRef.value?.resetFields()
|
|
636
|
+
emit('onResetFields')
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* 校验
|
|
641
|
+
* @param callback
|
|
642
|
+
*/
|
|
643
|
+
const onNfSearchFormValidate = (callback) => {
|
|
644
|
+
nfSearchFormRef.value.validate(valid => {
|
|
645
|
+
if (valid) {
|
|
646
|
+
callback()
|
|
647
|
+
}
|
|
648
|
+
})
|
|
649
|
+
}
|
|
650
|
+
// 搜索
|
|
651
|
+
const onNfSearchFormSearch = () => {
|
|
652
|
+
onNfSearchFormValidate(() => {
|
|
653
|
+
emit('onSearch', nfSearchFormModel.value)
|
|
654
|
+
})
|
|
655
|
+
}
|
|
656
|
+
// 导出
|
|
657
|
+
const onNfSearchFormExport = () => {
|
|
658
|
+
onNfSearchFormValidate(() => {
|
|
659
|
+
emit('onExport', nfSearchFormModel.value)
|
|
660
|
+
})
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* 把该item暂时隐藏
|
|
665
|
+
* @param prop
|
|
666
|
+
*/
|
|
667
|
+
const hiddenNfSearchFormItemOptionField = (prop) => {
|
|
668
|
+
const index = localShowItems.value.indexOf(prop)
|
|
669
|
+
if (index > -1) {
|
|
670
|
+
localShowItems.value.splice(index, 1)
|
|
671
|
+
refreshNfSearchFormModel()
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* 更新item对应的formData
|
|
677
|
+
* @param prop
|
|
678
|
+
*/
|
|
679
|
+
const refreshNfSearchFormModel = () => {
|
|
680
|
+
let changeTimer: undefined | ReturnType<typeof setTimeout> = undefined
|
|
681
|
+
for (const key in nfSearchFormModel.value) {
|
|
682
|
+
if (!localShowItems.value.includes(key)) {
|
|
683
|
+
delete nfSearchFormModel.value[key]
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
emit('onChange', nfSearchFormModel.value)
|
|
687
|
+
if (changeTimer) {
|
|
688
|
+
clearTimeout(changeTimer)
|
|
689
|
+
changeTimer = undefined
|
|
690
|
+
}
|
|
691
|
+
changeTimer = setTimeout(() => {
|
|
692
|
+
clearTimeout(changeTimer!)
|
|
693
|
+
changeTimer = undefined
|
|
694
|
+
emit('itemsChange', localShowItems.value)
|
|
695
|
+
})
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* 保存表单显示的字段
|
|
701
|
+
* @param value
|
|
702
|
+
*/
|
|
703
|
+
const nfSearchFormItemOptionFieldsSave = (value) => {
|
|
704
|
+
let changeTimer
|
|
705
|
+
const itemsList: string[] = []
|
|
706
|
+
for (const key in value) {
|
|
707
|
+
if (value[key]) {
|
|
708
|
+
itemsList.push(key)
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (JSON.stringify(localShowItems.value) !== JSON.stringify(itemsList)) {
|
|
712
|
+
localShowItems.value = itemsList
|
|
713
|
+
emit('onChange', nfSearchFormModel.value)
|
|
714
|
+
if (changeTimer) {
|
|
715
|
+
clearTimeout(changeTimer)
|
|
716
|
+
changeTimer = undefined
|
|
717
|
+
}
|
|
718
|
+
changeTimer = setTimeout(() => {
|
|
719
|
+
clearTimeout(changeTimer)
|
|
720
|
+
changeTimer = undefined
|
|
721
|
+
emit('itemsChange', localShowItems.value)
|
|
722
|
+
})
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
defineExpose({
|
|
727
|
+
renderSearchFormItemOptions,
|
|
728
|
+
resetNfSearchFormModel,
|
|
729
|
+
onNfSearchFormValidate,
|
|
730
|
+
onNfSearchFormSearch,
|
|
731
|
+
onNfSearchFormExport,
|
|
732
|
+
nfSearchFormModel,
|
|
733
|
+
nfSearchFormRef,
|
|
734
|
+
configNfSearchItemVisibleDialog,
|
|
735
|
+
})
|
|
736
|
+
|
|
737
|
+
</script>
|