vue2-client 1.12.45 → 1.12.49

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.
@@ -1,1265 +1,1310 @@
1
- <template>
2
- <!-- 输入框 -->
3
- <x-form-col
4
- v-if="attr.type === 'input' && show"
5
- :occupyCol="attr.occupyCol"
6
- :labelCol="labelCol"
7
- :flex="attr.flex">
8
- <a-form-model-item
9
- :ref="attr.model"
10
- :label="showLabel?attr.name:undefined"
11
- :prop="attr.prop ? attr.prop : attr.model">
12
- <!-- 如果配置了后置按钮插槽 -->
13
- <a-input-group
14
- v-if="((attr.inputOnAfterName && attr.inputOnAfterFunc) || (attr.inputOnAfterIcon && attr.inputOnAfterIconFunc)) && mode !== '查询'"
15
- style="display: flex; width: 100%; padding: 4px 0"
16
- compact>
17
- <a-input
18
- v-model="form[attr.model]"
19
- :read-only="readOnly"
20
- :disabled="disabled && !readOnly"
21
- :whitespace="true"
22
- @input="attr.dataChangeFunc && debouncedDataChangeFunc()"
23
- :suffix="attr.inputSuffix && mode !== '新增' ? attr.inputSuffix : ''"
24
- @blur="mode !== '查询' && attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
25
- @keyup.enter="mode !== '查询' && attr.inputOnEnterFunc && emitFunc(attr.inputOnEnterFunc, attr)"
26
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
27
- :ref="`${attr.model}input`"/>
28
- <a-button
29
- v-if="attr.inputOnAfterName && attr.inputOnAfterFunc && !attr.inputOnAfterName.includes('|')"
30
- style="width: auto; min-width: 4rem;max-width: 6rem"
31
- type="primary"
32
- @click="emitFunc(attr.inputOnAfterFunc,attr)">
33
- {{ attr.inputOnAfterName }}
34
- </a-button>
35
- <!-- 仅可以配置 一个按钮 以及 一个图标插槽 -->
36
- <a-button
37
- style="width: 2rem; flex-shrink: 0;"
38
- v-else-if="attr.inputOnAfterIcon"
39
- :type="attr.inputOnAfterIcon && attr.inputOnAfterName ? 'primary' :''"
40
- :icon="attr.inputOnAfterIcon || 'question'"
41
- @click="emitFunc(attr.inputOnAfterIconFunc,attr)">
42
- </a-button>
43
- <!-- 状态按钮 -->
44
- <x-status-button
45
- v-else
46
- :states="parseStates(attr.inputOnAfterName, attr.inputOnAfterFunc)"
47
- v-on="generateDynamicEvents(attr.inputOnAfterFunc, attr)"
48
- style="width: auto; min-width: 4rem; max-width: 6rem"
49
- />
50
- </a-input-group>
51
- <a-input-number
52
- v-else-if="attr.numberInput && !readOnly"
53
- v-model="form[attr.model]"
54
- :whitespace="true"
55
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
56
- :disabled="disabled && !readOnly"
57
- style="width:100%"
58
- @blur="mode !== '查询' && attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
59
- @keyup.enter="mode !== '查询' && attr.inputOnEnterFunc && emitFunc(attr.inputOnEnterFunc, attr)"
60
- :suffix="attr.inputSuffix && mode !== '新增' ? attr.inputSuffix : ''"
61
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
62
- :ref="`${attr.model}input`"/>
63
- <a-input
64
- v-else
65
- v-model="form[attr.model]"
66
- :whitespace="true"
67
- :read-only="readOnly"
68
- :disabled="disabled && !readOnly"
69
- @input="attr.dataChangeFunc && debouncedDataChangeFunc()"
70
- :suffix="attr.inputSuffix && mode !== '新增' ? attr.inputSuffix : ''"
71
- style="width:100%"
72
- @blur="mode !== '查询' && attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
73
- @keyup.enter="mode !== '查询' && attr.inputOnEnterFunc && emitFunc(attr.inputOnEnterFunc, attr)"
74
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
75
- :ref="`${attr.model}input`"/>
76
- </a-form-model-item>
77
- </x-form-col>
78
- <!-- 下拉框 -->
79
- <x-form-col
80
- v-else-if="attr.type === 'select' && show"
81
- :labelCol="labelCol"
82
- :flex="attr.flex">
83
- <a-form-model-item
84
- v-if="!attr.showMode || mode === '查询' || attr.showMode === 'select' "
85
- :ref="attr.model"
86
- :label="showLabel?attr.name:undefined"
87
- :prop="attr.prop ? attr.prop : attr.model">
88
- <!-- <span slot="label" class="label-box">{{ showLabel?attr.name:undefined }}</span>-->
89
- <a-select
90
- v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
91
- v-model="form[attr.model]"
92
- :disabled="disabled"
93
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
94
- :filter-option="filterOption"
95
- :getPopupContainer="getPopupContainer"
96
- dropdownClassName="custom-dropdown"
97
- :dropdownMatchSelectWidth="false"
98
- :dropdownStyle="{ position: 'absolute'}"
99
- :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
100
- show-search
101
- >
102
- <a-select-option
103
- v-if="mode === '查询'"
104
- key="999999"
105
- value="">全部
106
- </a-select-option>
107
- <template v-if="attr.keys">
108
- <a-select-option
109
- v-for="(item,index) in attr.keys"
110
- :key="index.value"
111
- :value="item.value + ''">
112
- {{ item.label }}
113
- </a-select-option>
114
- </template>
115
- <template v-else>
116
- <template
117
- v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
118
- ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
119
- <a-select-option
120
- v-for="(item,index) in option"
121
- :key="index.value"
122
- :value="item.value + ''">
123
- <template v-if="attr.keyName.indexOf('config@') !== -1 && item.status">
124
- <!-- 徽标(badge) -->
125
- <a-badge v-if="item.status !== 'gary'" :color="item.status" :text="item.label"/>
126
- <a-badge v-else color="#D9D9D9" :text="item.label"/>
127
- </template>
128
- <template v-else>
129
- {{ item.label }}
130
- </template>
131
- </a-select-option>
132
- </template>
133
- <template
134
- v-else-if="attr.keyName.indexOf('async ') !== -1 || attr.keyName.indexOf('function ') !== -1">
135
- <a-select-option
136
- v-for="(item,index) in optionForFunc"
137
- :key="index.value"
138
- :value="item.value + ''">
139
- <template>
140
- {{ item.label }}
141
- </template>
142
- </a-select-option>
143
- </template>
144
- <template v-else>
145
- <a-select-option
146
- v-for="item in $appdata.getDictionaryList(attr.keyName)"
147
- :key="item.value"
148
- :value="item.value + ''">
149
- <!-- 徽标(badge) -->
150
- <x-badge
151
- :badge-key="attr.keyName"
152
- :replaceText="item.text"
153
- :value="item.value"
154
- :service-name="serviceName"
155
- :env="env"/>
156
- </a-select-option>
157
- </template>
158
- </template>
159
- </a-select>
160
- <a-select
161
- v-else
162
- v-model="form[attr.model]"
163
- :disabled="disabled"
164
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
165
- :filter-option="filterOption"
166
- :getPopupContainer="getPopupContainer"
167
- dropdownClassName="custom-dropdown"
168
- :dropdownMatchSelectWidth="false"
169
- :dropdownStyle="{ position: 'absolute'}"
170
- :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
171
- show-search
172
- @search="fetchFunction"
173
- >
174
- <template #notFoundContent>
175
- <a-spin v-if="searching" size="small"/>
176
- </template>
177
- <a-select-option
178
- v-if="mode === '查询'"
179
- key="999999"
180
- value="">全部
181
- </a-select-option>
182
- <a-select-option
183
- v-for="(item,index) in option"
184
- :key="index"
185
- :value="item.value + ''">{{ item.label }}
186
- </a-select-option>
187
- </a-select>
188
- </a-form-model-item>
189
- <a-form-model-item
190
- v-else-if="attr.showMode === 'radioGroup'"
191
- :ref="attr.model"
192
- :label="showLabel?attr.name:undefined"
193
- :prop="attr.prop ? attr.prop : attr.model">
194
- <a-radio-group v-model="form[attr.model]">
195
- <a-radio-button v-for="modeItem in option" :key="modeItem.value" :value="modeItem.value">
196
- {{ modeItem.label }}
197
- </a-radio-button>
198
- </a-radio-group>
199
- </a-form-model-item>
200
- <a-form-model-item
201
- v-else-if="attr.showMode === 'clickChange' && option.length > 0"
202
- :ref="attr.model"
203
- :label="showLabel?attr.name:undefined"
204
- :prop="attr.prop ? attr.prop : attr.model">
205
- <XClickChangeBtn></XClickChangeBtn>
206
- </a-form-model-item>
207
- </x-form-col>
208
- <!-- 多选框 -->
209
- <x-form-col
210
- v-else-if="attr.type === 'checkbox' && show"
211
- :labelCol="labelCol"
212
- :flex="attr.flex">
213
- <a-form-model-item
214
- v-if="!attr.showMode || mode === '查询' || attr.showMode === 'select' "
215
- :ref="attr.model"
216
- :label="showLabel?attr.name:undefined"
217
- :prop="attr.prop ? attr.prop : attr.model">
218
- <a-select
219
- style="width:100%"
220
- v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
221
- v-model="form[attr.model]"
222
- :disabled="disabled"
223
- :filter-option="filterOption"
224
- :getPopupContainer="getPopupContainer"
225
- :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
226
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
227
- mode="multiple"
228
- show-search
229
- allowClear
230
- >
231
- <template v-if="attr.keys">
232
- <a-select-option
233
- v-for="(item,index) in attr.keys"
234
- :key="index"
235
- :value="item.value + ''">
236
- {{ item.label }}
237
- </a-select-option>
238
- </template>
239
- <template v-else>
240
- <template
241
- v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
242
- ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
243
- <a-select-option
244
- v-for="(item,index) in option"
245
- :key="index"
246
- :value="item.value">{{ item.label }}
247
- </a-select-option>
248
- </template>
249
- <template v-else>
250
- <a-select-option
251
- v-for="item in $appdata.getDictionaryList(attr.keyName)"
252
- :key="item.value"
253
- :value="item.value + ''">{{ item.text }}
254
- </a-select-option>
255
- </template>
256
- </template>
257
- </a-select>
258
- <a-select
259
- v-else
260
- v-model="form[attr.model]"
261
- :disabled="disabled"
262
- :filter-option="filterOption"
263
- :getPopupContainer="getPopupContainer"
264
- :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
265
- mode="multiple"
266
- style="width:100%"
267
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
268
- show-search
269
- allowClear
270
- @search="fetchFunction"
271
- >
272
- <template #notFoundContent>
273
- <a-spin v-if="searching" size="small"/>
274
- </template>
275
- <a-select-option
276
- v-for="(item,index) in option"
277
- :key="index"
278
- :value="item.value + ''">{{ item.label }}
279
- </a-select-option>
280
- </a-select>
281
- </a-form-model-item>
282
- <a-form-model-item
283
- v-else
284
- :ref="attr.model"
285
- :label="showLabel?attr.name:undefined"
286
- :prop="attr.prop ? attr.prop : attr.model">
287
- <a-checkbox-group
288
- v-model="form[attr.model]"
289
- :options="option"
290
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
291
- />
292
- </a-form-model-item>
293
- </x-form-col>
294
- <!-- 单选框 -->
295
- <x-form-col
296
- v-else-if="attr.type === 'radio' && show"
297
- :labelCol="labelCol"
298
- :flex="attr.flex">
299
- <a-form-model-item
300
- v-if="!attr.showMode || attr.type === 'radio' "
301
- :ref="attr.model"
302
- :label="showLabel?attr.name:undefined"
303
- :prop="attr.prop ? attr.prop : attr.model">
304
- <a-radio-group
305
- v-model="form[attr.model]"
306
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
307
- >
308
- <template v-if="attr.keys">
309
- <a-radio v-for="(item,index) in attr.keys" :key="index" :value="item.value">
310
- {{ item.label }}
311
- </a-radio>
312
- </template>
313
- <template v-else>
314
- <template
315
- v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
316
- ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
317
- <a-radio v-for="(item,index) in option" :key="index" :value="item.value">
318
- {{ item.label }}
319
- </a-radio>
320
- </template>
321
- <template v-else>
322
- <a-radio v-for="(item,index) in $appdata.getDictionaryList(attr.keyName)" :key="index" :value="item.value">
323
- {{ item.text }}
324
- </a-radio>
325
- </template>
326
- </template>
327
- </a-radio-group>
328
- </a-form-model-item>
329
- <a-form-model-item
330
- v-else-if="attr.showMode === 'radioGroup'"
331
- :ref="attr.model"
332
- :label="showLabel?attr.name:undefined"
333
- :prop="attr.prop ? attr.prop : attr.model">
334
- <a-radio-group v-model="form[attr.model]">
335
- <a-radio-button v-for="modeItem in option" :key="modeItem.value" :value="modeItem.value">
336
- {{ modeItem.label }}
337
- </a-radio-button>
338
- </a-radio-group>
339
- </a-form-model-item>
340
- <a-form-model-item
341
- v-else-if="attr.showMode === 'clickChange' && option.length > 0"
342
- :ref="attr.model"
343
- :label="showLabel?attr.name:undefined"
344
- :prop="attr.prop ? attr.prop : attr.model">
345
- <XClickChangeBtn></XClickChangeBtn>
346
- </a-form-model-item>
347
- </x-form-col>
348
- <!-- 时间 日期 框整合 -->
349
- <x-form-col
350
- v-else-if="['datePicker', 'rangePicker', 'yearPicker', 'monthPicker', 'yearRangePicker', 'monthRangePicker'].includes(attr.type) && show"
351
- :labelCol="labelCol"
352
- :flex="attr.flex">
353
- <a-form-model-item
354
- :ref="attr.model"
355
- :label="showLabel?attr.name:undefined"
356
- :prop="attr.prop ? attr.prop : attr.model">
357
- <XFormDatePicker
358
- :attr="attr"
359
- :mode="mode"
360
- :disabled="disabled"
361
- :readOnly="readOnly"
362
- :showLabel="showLabel"
363
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
364
- v-model="form[attr.model]"/>
365
- </a-form-model-item>
366
- </x-form-col>
367
- <!-- 文本域 -->
368
- <x-form-col
369
- v-else-if="attr.type === 'textarea' && show"
370
- :labelCol="labelCol"
371
- :flex="attr.flex">
372
- <!-- :style="layout === 'inline'?{width:'calc(100% - 60px)'}:{}"-->
373
- <a-form-model-item
374
- :ref="attr.model"
375
- :label="showLabel?attr.name:undefined"
376
- :prop="attr.prop ? attr.prop : attr.model">
377
- <a-textarea
378
- v-model="form[attr.model]"
379
- style="width: 100%;"
380
- :disabled="disabled"
381
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
382
- :rows="4"/>
383
- </a-form-model-item>
384
- </x-form-col>
385
- <!-- 文件上传 -->
386
- <x-form-col
387
- v-else-if="(attr.type === 'file' || attr.type === 'image') && show"
388
- :labelCol="labelCol"
389
- :flex="attr.flex">
390
- <a-form-model-item
391
- :ref="attr.model"
392
- :label="showLabel?attr.name:undefined"
393
- :prop="attr.prop ? attr.prop : attr.model">
394
- <upload
395
- :files="files"
396
- :images="images"
397
- :model="attr"
398
- v-bind="attr"
399
- :service-name="serviceName"
400
- @setFiles="setFiles"></upload>
401
- </a-form-model-item>
402
- </x-form-col>
403
- <!-- 省市区选择框 -->
404
- <x-form-col
405
- v-else-if="attr.type === 'citySelect' && show"
406
- :labelCol="labelCol"
407
- :flex="attr.flex">
408
- <a-form-model-item
409
- :ref="attr.model"
410
- :label="showLabel?attr.name:undefined"
411
- :prop="attr.prop ? attr.prop : attr.model">
412
- <citySelect
413
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
414
- ref="citySelect"
415
- v-model="form[attr.model]"
416
- :contexts="attr.contexts"
417
- :value-type="attr.valueType"
418
- :default-value="form[attr.model]"></citySelect>
419
- </a-form-model-item>
420
- </x-form-col>
421
- <!-- 地点搜索框 -->
422
- <x-form-col
423
- v-else-if="attr.type === 'addressSearch' && show"
424
- :labelCol="labelCol"
425
- :occupyCol="attr.occupyCol"
426
- :flex="attr.flex">
427
- <a-form-model-item
428
- :ref="attr.model"
429
- :label="showLabel?attr.name:undefined"
430
- :prop="attr.prop ? attr.prop : attr.model">
431
- <address-search-combobox
432
- :emitFunc="emitFunc"
433
- :attr="attr"
434
- :read-only="readOnly"
435
- v-model="searchResult"
436
- :resultKeys="{ address: attr.model, coords: `${attr.model}_lng_lat` }"
437
- ref="addressSearchCombobox"
438
- searchResultType="Object"
439
- @onSelect="addressSearchComboboxSelect"
440
- @onDivisionsChange="onDivisionsChange"
441
- ></address-search-combobox>
442
- </a-form-model-item>
443
- </x-form-col>
444
- <!-- 人员选择框 -->
445
- <x-form-col
446
- v-else-if="attr.type === 'personSetting' && show"
447
- :labelCol="labelCol"
448
- :flex="attr.flex">
449
- <a-form-model-item
450
- :ref="attr.model"
451
- :label="showLabel?attr.name:undefined"
452
- :prop="attr.prop ? attr.prop : attr.model">
453
- <PersonSetting v-model="form[attr.model]"></PersonSetting>
454
- </a-form-model-item>
455
- </x-form-col>
456
- <!-- 树形选择框 -->
457
- <x-form-col
458
- v-else-if="attr.type === 'treeSelect' && show"
459
- :labelCol="labelCol"
460
- :flex="attr.flex">
461
- <x-tree-select
462
- @onChange="attr.dataChangeFunc && debouncedDataChangeFunc()"
463
- v-model="form[attr.model]"
464
- :attr="attr"
465
- @mounted="itemMounted"
466
- ref="xTreeSelect">
467
- </x-tree-select>
468
- </x-form-col>
469
- <!-- 列表选择框 -->
470
- <x-form-col
471
- v-else-if="attr.type === 'listSelect' && show"
472
- :labelCol="labelCol"
473
- :flex="attr.flex">
474
- <a-form-model-item
475
- :ref="attr.model"
476
- :label="showLabel?attr.name:undefined"
477
- :style="layout === 'inline'&& attr.occupyCol && attr.occupyCol > 1? {width:`calc(100% - ${attr.occupyCol * 1.533}rem)`}:{}"
478
- :prop="attr.prop ? attr.prop : attr.model">
479
- <a-popover
480
- ref="rowChoosePopover"
481
- :visible="rowChoosePopoverVisible"
482
- title="选择数据"
483
- placement="bottom"
484
- trigger="focus"
485
- :arrowPointAtCenter="true"
486
- :overlayStyle="{ width: '1000px', height: '30vh' }">
487
- <template #content>
488
- <x-report
489
- v-if="isCover"
490
- :use-oss-for-img="false"
491
- :config-name="queryParamsName"
492
- :service-name="serviceName"
493
- :show-img-in-cell="true"
494
- :display-only="true"
495
- :edit-mode="false"
496
- :show-save-button="true"
497
- :no-padding="true"
498
- :dont-format="true"
499
- @rowChoose="rowChoose"
500
- @cancel="closeRowChooseInput"
501
- >
502
- </x-report>
503
- <x-form-table
504
- v-else
505
- title="请选择数据"
506
- :queryParamsName="queryParamsName"
507
- :rowSelectMode="true"
508
- :allowSelectRowNum="1"
509
- :service-name="serviceName"
510
- :fixed-query-form="rowChooseFixedQueryValue"
511
- @rowChoose="rowChoose"
512
- @afterQuery="rowChooseSearchAfterQuery"
513
- ref="rowChooseTable">
514
- <template #button>
515
- <a-button @click="closeRowChooseInput">
516
- 关闭
517
- </a-button>
518
- </template>
519
- </x-form-table>
520
- </template>
521
- <a-input
522
- v-model="form[attr.model]"
523
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
524
- @change="searchRowChooseData"
525
- @focus="showCloseRowChooseInput"/>
526
- </a-popover>
527
- </a-form-model-item>
528
- </x-form-col>
529
- <!-- 评分框 -->
530
- <x-form-col
531
- v-else-if="attr.type === 'rate' && show"
532
- :labelCol="labelCol"
533
- :flex="attr.flex">
534
- <a-form-model-item
535
- :ref="attr.model"
536
- :label="showLabel?attr.name:undefined"
537
- :prop="attr.prop ? attr.prop : attr.model">
538
- <x-rate
539
- v-model="form[attr.model]"
540
- :mode="mode"
541
- :disabled="disabled"
542
- :query-type="attr.queryType"
543
- :max-count="attr.maxCount"
544
- :allow-half="attr.allowHalf"
545
- :icon="attr.rateIcon"
546
- :placeholder="attr.placeholder ? attr.placeholder : '请选择'+attr.name.replace(/\s*/g, '')"
547
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
548
- />
549
- </a-form-model-item>
550
- </x-form-col>
551
- <!-- 区间选择器 -->
552
- <x-form-col
553
- v-else-if="attr.type === 'intervalPicker' && show"
554
- :labelCol="labelCol"
555
- :flex="attr.flex">
556
- <a-form-model-item
557
- :ref="attr.model"
558
- :label="showLabel?attr.name:undefined"
559
- :prop="attr.prop ? attr.prop : attr.model">
560
- <x-interval-picker
561
- v-model="form[attr.model]"
562
- :mode="mode"
563
- :read-only="readOnly"
564
- :disabled="disabled && !readOnly"
565
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
566
- :start-placeholder="attr.startPlaceholder || '起始值'"
567
- :end-placeholder="attr.endPlaceholder || '结束值'"
568
- @blur="attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
569
- />
570
- </a-form-model-item>
571
- </x-form-col>
572
- <!-- 车牌号选择 -->
573
- <x-form-col
574
- v-else-if="attr.type === 'licensePlate' && show"
575
- :labelCol="labelCol"
576
- :flex="attr.flex">
577
- <a-form-model-item
578
- :ref="attr.model"
579
- :label="showLabel?attr.name:undefined"
580
- :style="layout === 'inline'&& attr.occupyCol && attr.occupyCol > 1? {width:`calc(100% - ${attr.occupyCol * 1.533}rem)`}:{}"
581
- :prop="attr.prop ? attr.prop : attr.model">
582
- <!-- 如果配置了后置按钮插槽 -->
583
- <a-input
584
- v-if="mode ==='查询'"
585
- v-model="form[attr.model]"
586
- :whitespace="true"
587
- :read-only="readOnly"
588
- :disabled="disabled && !readOnly"
589
- style="width:100%"
590
- @blur="attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
591
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
592
- :ref="`${attr.model}input`"/>
593
- <x-license-plate
594
- v-else
595
- v-model="form[attr.model]"
596
- @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
597
- ></x-license-plate>
598
- </a-form-model-item>
599
- </x-form-col>
600
- <!-- 录音 -->
601
- <x-form-col
602
- v-else-if="attr.type === 'recording' && show"
603
- :labelCol="labelCol"
604
- :flex="attr.flex">
605
- <recording
606
- ref="recording"
607
- @recordingData="recordingData"
608
- >
609
- </recording>
610
- </x-form-col>
611
- <!-- 表格录入 -->
612
- <x-form-col
613
- v-else-if="attr.type === 'rowEdit' && show"
614
- :labelCol="labelCol"
615
- :flex="attr.flex">
616
- <a-form-model-item
617
- :ref="attr.model"
618
- :label="showLabel?attr.name:undefined"
619
- :prop="attr.prop ? attr.prop : attr.model">
620
- <x-form-table
621
- :key="'childTable_' + attr.model"
622
- :title="attr.name"
623
- :queryParamsName="attr.crud"
624
- :localEditMode="true"
625
- :fixed-query-form="childTableFixedQueryForm(attr)"
626
- :service-name="serviceName"
627
- @hook:mounted="(h)=>onComponentMounted(h, attr)"
628
- :ref="'childXFormTable_' + attr.model">
629
- </x-form-table>
630
- </a-form-model-item>
631
- </x-form-col>
632
- </template>
633
- <script>
634
- import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
635
- import XFormCol from '@vue2-client/base-client/components/common/XFormCol'
636
- import XBadge from '@vue2-client/base-client/components/common/XBadge'
637
- import CitySelect from '@vue2-client/base-client/components/common/CitySelect'
638
- import PersonSetting from '@vue2-client/base-client/components/common/PersonSetting'
639
- import AddressSearchCombobox from '@vue2-client/base-client/components/common/AddressSearchCombobox'
640
- import Upload from '@vue2-client/base-client/components/common/Upload'
641
- import moment from 'moment'
642
- import { getConfigByName, runLogic, getConfigByNameAsync } from '@vue2-client/services/api/common'
643
- import * as util from '@vue2-client/utils/util'
644
- import XTreeSelect from '@vue2-client/base-client/components/common/XForm/XTreeSelect'
645
- import { searchToListOption, searchToOption } from '@vue2-client/services/v3Api'
646
- import { mapState } from 'vuex'
647
- import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
648
- import XLicensePlate from '@vue2-client/base-client/components/common/XLicensePlate/XLicensePlate.vue'
649
- import XStatusButton from './XStatusButton.vue'
650
- import XClickChangeBtn from './itemComponent/XClickChangeBtn'
651
- import 'moment/locale/zh-cn'
652
- import XFormDatePicker from '@vue2-client/base-client/components/common/XDatePicker/index.vue'
653
- import XIntervalPicker from '@vue2-client/base-client/components/common/XIntervalPicker/XIntervalPicker.vue'
654
- import XRate from '@vue2-client/base-client/components/common/XRate/index.vue'
655
-
656
- export default {
657
- name: 'XFormItem',
658
- components: {
659
- XFormDatePicker,
660
- XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue'),
661
- Recording: () => import('@vue2-client/base-client/components/common/Recording/Recording.vue'),
662
- XReport: () => import('@vue2-client/base-client/components/common/XReportGrid/XReport.vue'),
663
- XLicensePlate,
664
- XTreeSelect,
665
- XFormCol,
666
- XBadge,
667
- CitySelect,
668
- PersonSetting,
669
- AddressSearchCombobox,
670
- Upload,
671
- XStatusButton,
672
- XClickChangeBtn,
673
- XIntervalPicker,
674
- XRate
675
- },
676
- data () {
677
- // 检索去抖
678
- this.fetchFunction = debounce(this.fetchFunction, 800)
679
- return {
680
- option: [],
681
- // 最后检索版本
682
- lastFetchId: 0,
683
- // 检索中
684
- searching: false,
685
- searchResult: '',
686
- optionForFunc: [],
687
- // 控制当前表单项是否展示
688
- show: true,
689
- // moment
690
- moment,
691
- // 行选择器浮层是否显示
692
- rowChoosePopoverVisible: false,
693
- // 行选择器CRUD固定查询值
694
- rowChooseFixedQueryValue: undefined
695
- }
696
- },
697
- props: {
698
- attr: {
699
- type: Object,
700
- default:
701
- () => {
702
- return {}
703
- }
704
- },
705
- form: {
706
- type: Object,
707
- required:
708
- true
709
- },
710
- disabled: {
711
- type: Boolean,
712
- default:
713
- () => {
714
- return false
715
- }
716
- },
717
- readOnly: {
718
- type: Boolean,
719
- default:
720
- () => {
721
- return false
722
- }
723
- },
724
- mode: {
725
- type: String,
726
- default:
727
- () => {
728
- return '查询'
729
- }
730
- },
731
- files: {
732
- type: Array,
733
- default:
734
- () => {
735
- return []
736
- }
737
- },
738
- images: {
739
- type: Array,
740
- default:
741
- () => {
742
- return []
743
- }
744
- },
745
- serviceName: {
746
- type: String,
747
- default:
748
- undefined
749
- },
750
- // 调用logic获取数据源的追加参数
751
- getDataParams: {
752
- type: Object,
753
- default:
754
- undefined
755
- },
756
- // 布局
757
- layout: {
758
- type: String,
759
- default:
760
- 'horizontal'
761
- },
762
- // 环境
763
- env: {
764
- type: String,
765
- default:
766
- () => {
767
- return 'prod'
768
- }
769
- },
770
- // 设置表单值
771
- setForm: {
772
- type: Function,
773
- default: (val) => {
774
- console.log(val)
775
- }
776
- },
777
- showLabel: {
778
- type: Boolean,
779
- default:
780
- () => {
781
- return true
782
- }
783
- },
784
- labelCol: {
785
- type: Object,
786
- default: () => {
787
- return { span: 8 }
788
- }
789
- }
790
- },
791
- provide () {
792
- return {
793
- FormItemContext: this
794
- }
795
- },
796
- created () {
797
- this.init()
798
- if (this.attr.keyName && (this.attr?.keyName?.toString().indexOf('async ') !== -1 || this.attr?.keyName?.toString()?.indexOf('function') !== -1)) {
799
- this.debouncedUpdateOptions = debounce(this.updateOptions, 200)
800
- }
801
- if (this.attr.dataChangeFunc) {
802
- this.debouncedDataChangeFunc = debounce(this.dataChangeFunc, 200)
803
- // 执行一次
804
- this.dataChangeFunc()
805
- }
806
- if (this.attr.showFormItemFunc) {
807
- this.debouncedShowFormItemFunc = debounce(this.showFormItemFunc, 100)
808
- // 执行一次
809
- this.showFormItemFunc()
810
- }
811
- if (this.attr.showQueryFormItemFunc) {
812
- this.debouncedShowQueryFormItemFunc = debounce(this.showQueryFormItemFunc, 100)
813
- // 执行一次
814
- this.showFormItemFunc()
815
- }
816
- // 人员联动框增加监听
817
- if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString().endsWith(']联动人员')) {
818
- this.debouncedUserLinkFunc = debounce(() => this.updateResOptions('人员'), 200)
819
- }
820
- if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString().endsWith(']联动部门')) {
821
- this.debouncedDepLinkFunc = debounce(() => this.updateResOptions('部门'), 200)
822
- }
823
- // xTreeSelect 自己调用 mounted
824
- if (this.attr.type !== 'treeSelect') {
825
- this.$emit('mounted', this.attr)
826
- }
827
- },
828
- computed: {
829
- ...mapState('account', { currUser: 'user' }),
830
- queryParamsName () {
831
- if (this.attr.keyName.startsWith('function')) {
832
- // 调用异步函数获取内容
833
- return executeStrFunctionByContext(this, this.attr.keyName, [this.form, runLogic, this.mode, getConfigByNameAsync])
834
- } else {
835
- // 按现有方式处理
836
- return this.attr.keyName.split('@')[this.attr.keyName.split('@').length - 1]
837
- }
838
- },
839
- // 判断弹出时是否Cover,弹出只支持Cover以及CRUD
840
- isCover () {
841
- // 如果 queryParamsName 为空,返回空
842
- if (!this.queryParamsName) {
843
- return false
844
- }
845
- const result = this.queryParamsName.endsWith('Cover')
846
- return result
847
- },
848
- },
849
- watch: {
850
- attr: {
851
- handler () {
852
- this.init()
853
- },
854
- deep: true
855
- },
856
- form: {
857
- handler (newVal, oldVal) {
858
- // 如果是从函数获取 options
859
- if (this.attr.keyName && (this.attr.keyName.toString().indexOf('async ') !== -1 || this.attr.keyName.toString().indexOf('function') !== -1)) {
860
- this.debouncedUpdateOptions()
861
- }
862
- // 如果有自定义是否展示表单项函数
863
- if (this.attr.showFormItemFunc) {
864
- this.debouncedShowFormItemFunc()
865
- }
866
- // 如果有自定义是否展示查询表单项函数
867
- if (this.attr.showQueryFormItemFunc) {
868
- this.debouncedShowQueryFormItemFunc()
869
- }
870
- // 地址搜索框赋值
871
- if (this.attr.type === 'addressSearch') {
872
- this.$refs.addressSearchCombobox.addressInput = this.form[this.attr.model]
873
- }
874
- // 数据源来自人员联动时更新数据
875
- if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString().endsWith(']联动人员')) {
876
- this.debouncedUserLinkFunc()
877
- }
878
- // 数据源来自人员联动时更新数据
879
- if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString().endsWith(']联动部门')) {
880
- this.debouncedDepLinkFunc()
881
- }
882
- },
883
- deep: true
884
- }
885
- },
886
- inject: {
887
- getComponentByName: {
888
- default: () => () => {
889
- console.warn('getComponentByName is not provided')
890
- return null // 或者返回一个默认的函数
891
- },
892
- },
893
- registerComponent: {
894
- default: () => () => {
895
- console.warn('registerComponent is not provided')
896
- return null // 或者返回一个默认的函数
897
- },
898
- },
899
- getSelf: {
900
- default: () => () => {
901
- console.warn('getSelf is not provided')
902
- return null // 或者返回一个默认的函数
903
- },
904
- },
905
- },
906
- methods: {
907
- // 把内部的crud表单录入放到表单中,以便外部可以调用
908
- onComponentMounted (h, attr) {
909
- console.log('crud表单', h)
910
- if (attr.crud) {
911
- this.registerComponent(attr.model, this.$refs['childXFormTable_' + attr.model])
912
- }
913
- },
914
- childTableFixedQueryForm (item) {
915
- console.log('传递的form', this.form)
916
- if (this.modifyModelData?.primaryKeyData) {
917
- const fixedForm = {}
918
- fixedForm[item.childTableForeignKeyName] = Object.values(this.modifyModelData.primaryKeyData)[0]
919
- return fixedForm
920
- }
921
- return null
922
- },
923
- // 动态生成事件绑定对象
924
- generateDynamicEvents (inputOnAfterFunc, attr) {
925
- const events = {}
926
- const states = this.parseStates(attr.inputOnAfterName, inputOnAfterFunc)
927
-
928
- states.forEach((state) => {
929
- // 动态绑定事件名到 emitFunc
930
- events[state.event] = () => {
931
- console.info('事件名', state.event)
932
- this.emitFunc(state.event, attr)
933
- }
934
- })
935
-
936
- return events // 返回 { state1Event: handler, state2Event: handler, ... }
937
- },
938
- parseStates (input, events) {
939
- const eventNames = events.split('|')
940
- return input.split('|').map((label, index) => ({
941
- label,
942
- event: eventNames[index] // 如果没有提供事件名称,则使用默认值
943
- }))
944
- },
945
- focusInput () {
946
- if (this.attr.defaultFocus) {
947
- this.$nextTick(h => {
948
- const el = this.$refs[`${this.attr.model}input`]?.$el
949
- let inputEl
950
- if (el) {
951
- if (el.tagName.toLowerCase() === 'input') {
952
- inputEl = el
953
- } else {
954
- inputEl = el.querySelector('input')
955
- }
956
- }
957
- if (inputEl) {
958
- inputEl.focus()
959
- if (inputEl.type === 'number') {
960
- if (inputEl.valueAsNumber) {
961
- inputEl.setSelectionRange(0, inputEl.valueAsNumber.toString().length)
962
- }
963
- } else {
964
- if (inputEl.value) {
965
- inputEl.setSelectionRange(0, inputEl.value.length)
966
- }
967
- }
968
- }
969
- })
970
- }
971
- },
972
- // 更新人员下拉框数据
973
- async updateResOptions (type) {
974
- if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString()?.endsWith(`]联动${type}`)) {
975
- const startIndex = this.attr.keyName.indexOf('[') + 1
976
- const endIndex = this.attr.keyName.indexOf(']', startIndex)
977
- const fromModel = this.attr.keyName.substring(startIndex, endIndex).replace('.', '_')
978
- const formModelData = Array.isArray(this.form[fromModel])
979
- ? this.form[fromModel]
980
- : [this.form[fromModel]]
981
- if (fromModel?.length && formModelData?.length) {
982
- const searchData = { source: `获取${type}`, userid: this.currUser.id, filter: formModelData, filterType: fromModel.indexOf('org') > -1 ? 'org' : 'dep' }
983
- await searchToListOption(searchData, res => {
984
- this.getDataCallback(
985
- res.filter(h => {
986
- if (fromModel.indexOf('org') > -1) {
987
- return formModelData?.includes(h.orgid || h.f_organization_id || h.parentid)
988
- } else {
989
- return formModelData?.includes(h?.parentid)
990
- }
991
- }
992
- )
993
- )
994
- })
995
- }
996
- }
997
- },
998
- // js 函数作为数据源
999
- async updateOptions () {
1000
- if (this.attr.keyName && (this.attr.keyName.indexOf('async ') !== -1 || this.attr.keyName.indexOf('function ') !== -1)) {
1001
- this.optionForFunc = await executeStrFunctionByContext(this, this.attr.keyName, [this.form, runLogic, this.mode, getConfigByNameAsync])
1002
- }
1003
- },
1004
- async dataChangeFunc () {
1005
- if (this.attr.dataChangeFunc) {
1006
- await executeStrFunctionByContext(this, this.attr.dataChangeFunc, [this.form, this.setForm, this.attr, util, this.mode, runLogic, getConfigByNameAsync])
1007
- }
1008
- },
1009
- async showFormItemFunc () {
1010
- if (this.attr.showFormItemFunc) {
1011
- const obj = executeStrFunctionByContext(this, this.attr.showFormItemFunc, [this.form, this.setForm, this.attr, util, this.mode])
1012
- // 判断是 bool 还是 obj 兼容
1013
- if (typeof obj === 'boolean') {
1014
- this.show = obj
1015
- } else if (obj && typeof obj === 'object') {
1016
- // obj 是一个对象,并且不是数组
1017
- this.show = obj?.show
1018
- this.readOnly = obj?.readOnly
1019
- }
1020
- } else {
1021
- this.show = true
1022
- }
1023
- },
1024
- async showQueryFormItemFunc () {
1025
- if (this.attr.showQueryFormItemFunc) {
1026
- const obj = executeStrFunctionByContext(this, this.attr.showQueryFormItemFunc, [this.form, this.setForm, this.attr, util, this.mode])
1027
- // 判断是 bool 还是 obj 兼容
1028
- if (typeof obj === 'boolean') {
1029
- this.show = obj
1030
- } else if (obj && typeof obj === 'object') {
1031
- // obj 是一个对象,并且不是数组
1032
- this.show = obj?.show
1033
- this.readOnly = obj?.readOnly
1034
- }
1035
- } else {
1036
- this.show = true
1037
- }
1038
- },
1039
- init () {
1040
- if (!this.attr.flex) {
1041
- if (this.mode === '新增/修改') {
1042
- if (['horizontal', 'vertical'].includes(this.layout) || ['textarea', 'file', 'image'].includes(this.attr.type)) {
1043
- // 新增修改表单 horizontal 模式下默认为一行
1044
- this.attr.flex = {
1045
- xs: 24,
1046
- sm: 24,
1047
- md: 24,
1048
- lg: 24,
1049
- xl: 24,
1050
- xxl: 24,
1051
- fullWidth: true
1052
- }
1053
- } else {
1054
- // 新增修改表单 vertical 模式下默认为1列
1055
- this.attr.flex = {
1056
- xs: 24,
1057
- sm: 12,
1058
- md: 8,
1059
- lg: 8,
1060
- xl: 6,
1061
- xxl: 6
1062
- }
1063
- }
1064
- } else {
1065
- this.attr.flex = {
1066
- xs: 24,
1067
- sm: 24,
1068
- md: 8,
1069
- lg: 6,
1070
- xl: 6,
1071
- xxl: 6
1072
- }
1073
- }
1074
- }
1075
- if (this.attr.keyName && typeof this.attr.keyName === 'string') {
1076
- if (this.attr.keyName.indexOf('logic@') !== -1) {
1077
- this.getData({}, res => this.getDataCallback(res))
1078
- } else if (this.attr.keyName.indexOf('search@') !== -1) {
1079
- // `tool.getFullTree(this.getRights().where(row.getType()==$organization$))`
1080
- // 判断是否根据角色查询
1081
- let source = this.attr.keyName.substring(7)
1082
- const userid = this.currUser.id
1083
- let roleName = 'roleName'
1084
- if (source.startsWith('根据角色[') && source.endsWith(']获取人员')) {
1085
- const startIndex = source.indexOf('[') + 1
1086
- const endIndex = source.indexOf(']', startIndex)
1087
- roleName = source.substring(startIndex, endIndex)
1088
- source = '根据角色获取人员'
1089
- }
1090
- const searchData = { source, userid, roleName }
1091
- // 判断是否根据某个表单项联动 仅返回列表结构并筛选
1092
- if (source.startsWith('根据表单项[') && source.endsWith(']联动人员')) {
1093
- this.updateResOptions('人员')
1094
- } else if (source.startsWith('根据表单项[') && source.endsWith(']联动部门')) {
1095
- this.updateResOptions('部门')
1096
- } else if (this.attr.type === 'select' || this.attr.type === 'checkbox') {
1097
- // 仅获取最内层数据
1098
- searchToListOption(searchData, res => this.getDataCallback(res))
1099
- } else {
1100
- // 其他资源通用逻辑
1101
- searchToOption(searchData, res => this.getDataCallback(res))
1102
- }
1103
- } else if (this.attr.keyName.indexOf('config@') !== -1) {
1104
- const configName = this.attr.keyName.substring(7)
1105
- getConfigByName(configName, this.serviceName, res => {
1106
- this.getDataCallback(res.value)
1107
- }, this.env === 'dev')
1108
- } else if (this.attr.keyName.indexOf('async ') !== -1 || this.attr.keyName.indexOf('function ') !== -1) {
1109
- this.updateOptions()
1110
- }
1111
- } else if (this.attr.keys) {
1112
- this.getDataCallback(this.attr.keys)
1113
- }
1114
- this.focusInput()
1115
- },
1116
- addressSearchComboboxSelect (data) {
1117
- this.form = Object.assign(this.form, JSON.parse(data))
1118
- },
1119
- onDivisionsChange (data) {
1120
- this.emitFunc('addressSearchComboboxSelect', {
1121
- key: this.attr.model,
1122
- value: data
1123
- })
1124
- },
1125
- getDataCallback (res) {
1126
- this.option = res
1127
- if (this.attr.type === 'treeSelect') {
1128
- this.$nextTick(() => {
1129
- this.$refs.xTreeSelect.init({
1130
- option: this.option,
1131
- form: this.form,
1132
- queryType: this.attr.queryType,
1133
- name: this.attr.name,
1134
- model: this.attr.model,
1135
- mode: this.mode,
1136
- disabled: this.disabled
1137
- })
1138
- })
1139
- } else if (this.attr.type === 'radio' || ['radioGroup', 'clickChange'].includes(this.attr.showMode)) {
1140
- this.initRadioValue()
1141
- }
1142
- },
1143
- initRadioValue () {
1144
- const model = this.attr.model
1145
- if (this.mode === '新增/修改' && (this.form[model] === undefined || this.form[model] === null) && !this.attr.prop) {
1146
- if (this.attr.keys && this.attr.keys.length > 1) {
1147
- this.form[model] = this.attr.keys[0].value
1148
- } else if (this.option.length > 1) {
1149
- this.form[model] = this.option[0].value
1150
- }
1151
- }
1152
- },
1153
- // 文件框时设置上传组件的值
1154
- setFiles (fileIds) {
1155
- if (!this.form[this.attr.model]) {
1156
- this.form[this.attr.model] = []
1157
- }
1158
- this.form[this.attr.model] = [...fileIds]
1159
- },
1160
- // 懒加载检索方法
1161
- fetchFunction (value) {
1162
- this.lastFetchId += 1
1163
- const fetchId = this.lastFetchId
1164
- this.option = []
1165
- this.searching = true
1166
- this.getData({
1167
- word: value
1168
- }, res => {
1169
- if (fetchId !== this.lastFetchId) {
1170
- return
1171
- }
1172
- this.option = res
1173
- this.searching = false
1174
- })
1175
- },
1176
- // 获取数据
1177
- getData (value, callbackFun) {
1178
- if (value !== '') {
1179
- const logicName = this.attr.keyName
1180
- const logic = logicName.substring(6)
1181
- // 调用logic前设置参数
1182
- if (this.getDataParams && this.getDataParams[this.attr.model]) {
1183
- Object.assign(value, this.getDataParams[this.attr.model])
1184
- }
1185
- runLogic(logic, Object.assign(value, {
1186
- orgId: this.currUser.orgid,
1187
- userId: this.currUser.id
1188
- }), this.serviceName, this.env === 'dev').then(res => {
1189
- callbackFun(res)
1190
- }).catch(e => {
1191
- callbackFun([])
1192
- console.error('获取数据失败:' + e)
1193
- })
1194
- }
1195
- },
1196
- filterOption (input, option) {
1197
- const child = option.componentOptions.children[0]
1198
- if (child.text) {
1199
- return child.text.toLowerCase().indexOf(input.toLowerCase()) >= 0
1200
- } else if (child.elm.innerText) {
1201
- return child.elm.innerText.toLowerCase().indexOf(input.toLowerCase()) >= 0
1202
- } else {
1203
- return child.child.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
1204
- }
1205
- },
1206
- // 表单项变更函数中调用 控制表单组中表单项组名为 groupName 的表单是否展示
1207
- // func:x-form-show(显示)/x-form-no-show(不显示)
1208
- emitShowFormFunc (func, groupName) {
1209
- this.emitFunc(func, groupName)
1210
- },
1211
- emitFunc (func, data) {
1212
- this.$emit('x-form-item-emit-func', func, data, data?.model ? this.form[data.model] : this.form)
1213
- },
1214
- itemMounted (h) {
1215
- this.$emit('mounted', h)
1216
- },
1217
- rowChoose (rows) {
1218
- this.$emit('rowChoose', rows, this.attr, this.closeRowChooseInput)
1219
- },
1220
- searchRowChooseData () {
1221
- if (this.searching) {
1222
- return
1223
- }
1224
- this.lastFetchId += 1
1225
- const fetchId = this.lastFetchId
1226
- this.searching = true
1227
- if (fetchId !== this.lastFetchId) {
1228
- return
1229
- }
1230
- this.rowChooseFixedQueryValue = []
1231
- this.rowChooseFixedQueryValue[this.attr.model] = this.form[this.attr.model]
1232
- this.$nextTick(() => {
1233
- this.$refs.rowChooseTable.refresh(true)
1234
- })
1235
- },
1236
- showCloseRowChooseInput () {
1237
- this.rowChoosePopoverVisible = true
1238
- },
1239
- closeRowChooseInput () {
1240
- this.rowChoosePopoverVisible = false
1241
- },
1242
- rowChooseSearchAfterQuery () {
1243
- this.searching = false
1244
- },
1245
- // 获取 recording 转换后的数据
1246
- getRecodingData () {
1247
- return this.$refs.recording.getRecordingData()
1248
- },
1249
- recordingData (data) {
1250
- this.emitFunc('recordingData', data)
1251
- },
1252
- getPopupContainer (triggerNode) {
1253
- return document.body
1254
- // return triggerNode.parentNode
1255
- },
1256
- }
1257
- }
1258
- </script>
1259
-
1260
- <style lang="less" scoped>
1261
- .custom-dropdown {
1262
- position: absolute;
1263
- z-index: 1050;
1264
- }
1265
- </style>
1
+ <template>
2
+ <!-- 输入框 -->
3
+ <x-form-col
4
+ v-if="attr.type === 'input' && show"
5
+ :occupyCol="attr.occupyCol"
6
+ :labelCol="labelCol"
7
+ :flex="attr.flex">
8
+ <a-form-model-item
9
+ :rules="rules"
10
+ :ref="attr.model"
11
+ :label="showLabel?attr.name:undefined"
12
+ :prop="attr.prop ? attr.prop : attr.model">
13
+ <!-- 如果配置了后置按钮插槽 -->
14
+ <a-input-group
15
+ v-if="((attr.inputOnAfterName && attr.inputOnAfterFunc) || (attr.inputOnAfterIcon && attr.inputOnAfterIconFunc)) && mode !== '查询'"
16
+ style="display: flex; width: 100%; padding: 4px 0"
17
+ compact>
18
+ <a-input
19
+ v-model="form[attr.model]"
20
+ :read-only="readOnly"
21
+ :disabled="disabled && !readOnly"
22
+ :whitespace="true"
23
+ @input="attr.dataChangeFunc && debouncedDataChangeFunc()"
24
+ :suffix="attr.inputSuffix && mode !== '新增' ? attr.inputSuffix : ''"
25
+ @blur="mode !== '查询' && attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
26
+ @keyup.enter="mode !== '查询' && attr.inputOnEnterFunc && emitFunc(attr.inputOnEnterFunc, attr)"
27
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
28
+ :ref="`${attr.model}input`"/>
29
+ <a-button
30
+ v-if="attr.inputOnAfterName && attr.inputOnAfterFunc && !attr.inputOnAfterName.includes('|')"
31
+ style="width: auto; min-width: 4rem;max-width: 6rem"
32
+ type="primary"
33
+ @click="emitFunc(attr.inputOnAfterFunc,attr)">
34
+ {{ attr.inputOnAfterName }}
35
+ </a-button>
36
+ <!-- 仅可以配置 一个按钮 以及 一个图标插槽 -->
37
+ <a-button
38
+ style="width: 2rem; flex-shrink: 0;"
39
+ v-else-if="attr.inputOnAfterIcon"
40
+ :type="attr.inputOnAfterIcon && attr.inputOnAfterName ? 'primary' :''"
41
+ :icon="attr.inputOnAfterIcon || 'question'"
42
+ @click="emitFunc(attr.inputOnAfterIconFunc,attr)">
43
+ </a-button>
44
+ <!-- 状态按钮 -->
45
+ <x-status-button
46
+ v-else
47
+ :states="parseStates(attr.inputOnAfterName, attr.inputOnAfterFunc)"
48
+ v-on="generateDynamicEvents(attr.inputOnAfterFunc, attr)"
49
+ style="width: auto; min-width: 4rem; max-width: 6rem"
50
+ />
51
+ </a-input-group>
52
+ <a-input-number
53
+ v-else-if="attr.numberInput && !readOnly"
54
+ v-model="form[attr.model]"
55
+ :whitespace="true"
56
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
57
+ :disabled="disabled && !readOnly"
58
+ style="width:100%"
59
+ @blur="mode !== '查询' && attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
60
+ @keyup.enter="mode !== '查询' && attr.inputOnEnterFunc && emitFunc(attr.inputOnEnterFunc, attr)"
61
+ :suffix="attr.inputSuffix && mode !== '新增' ? attr.inputSuffix : ''"
62
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
63
+ :ref="`${attr.model}input`"/>
64
+ <a-input
65
+ v-else
66
+ v-model="form[attr.model]"
67
+ :whitespace="true"
68
+ :read-only="readOnly"
69
+ :disabled="disabled && !readOnly"
70
+ @input="attr.dataChangeFunc && debouncedDataChangeFunc()"
71
+ :suffix="attr.inputSuffix && mode !== '新增' ? attr.inputSuffix : ''"
72
+ style="width:100%"
73
+ @blur="mode !== '查询' && attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
74
+ @keyup.enter="mode !== '查询' && attr.inputOnEnterFunc && emitFunc(attr.inputOnEnterFunc, attr)"
75
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
76
+ :ref="`${attr.model}input`"/>
77
+ </a-form-model-item>
78
+ </x-form-col>
79
+ <!-- 下拉框 -->
80
+ <x-form-col
81
+ v-else-if="attr.type === 'select' && show"
82
+ :labelCol="labelCol"
83
+ :flex="attr.flex">
84
+ <a-form-model-item
85
+ :rules="rules"
86
+ v-if="!attr.showMode || mode === '查询' || attr.showMode === 'select' "
87
+ :ref="attr.model"
88
+ :label="showLabel?attr.name:undefined"
89
+ :prop="attr.prop ? attr.prop : attr.model">
90
+ <!-- <span slot="label" class="label-box">{{ showLabel?attr.name:undefined }}</span>-->
91
+ <a-select
92
+ v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
93
+ v-model="form[attr.model]"
94
+ :disabled="disabled"
95
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
96
+ :filter-option="filterOption"
97
+ :getPopupContainer="getPopupContainer"
98
+ dropdownClassName="custom-dropdown"
99
+ :dropdownMatchSelectWidth="false"
100
+ :dropdownStyle="{ position: 'absolute'}"
101
+ :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
102
+ show-search
103
+ >
104
+ <a-select-option
105
+ v-if="mode === '查询'"
106
+ key="999999"
107
+ value="">全部
108
+ </a-select-option>
109
+ <template v-if="attr.keys">
110
+ <a-select-option
111
+ v-for="(item,index) in attr.keys"
112
+ :key="index.value"
113
+ :value="item.value + ''">
114
+ {{ item.label }}
115
+ </a-select-option>
116
+ </template>
117
+ <template v-else>
118
+ <template
119
+ v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
120
+ ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
121
+ <a-select-option
122
+ v-for="(item,index) in option"
123
+ :key="index.value"
124
+ :value="item.value + ''">
125
+ <template v-if="attr.keyName.indexOf('config@') !== -1 && item.status">
126
+ <!-- 徽标(badge) -->
127
+ <a-badge v-if="item.status !== 'gary'" :color="item.status" :text="item.label"/>
128
+ <a-badge v-else color="#D9D9D9" :text="item.label"/>
129
+ </template>
130
+ <template v-else>
131
+ {{ item.label }}
132
+ </template>
133
+ </a-select-option>
134
+ </template>
135
+ <template
136
+ v-else-if="attr.keyName.indexOf('async ') !== -1 || attr.keyName.indexOf('function ') !== -1">
137
+ <a-select-option
138
+ v-for="(item,index) in optionForFunc"
139
+ :key="index.value"
140
+ :value="item.value + ''">
141
+ <template>
142
+ {{ item.label }}
143
+ </template>
144
+ </a-select-option>
145
+ </template>
146
+ <template v-else>
147
+ <a-select-option
148
+ v-for="item in $appdata.getDictionaryList(attr.keyName)"
149
+ :key="item.value"
150
+ :value="item.value + ''">
151
+ <!-- 徽标(badge) -->
152
+ <x-badge
153
+ :badge-key="attr.keyName"
154
+ :replaceText="item.text"
155
+ :value="item.value"
156
+ :service-name="serviceName"
157
+ :env="env"/>
158
+ </a-select-option>
159
+ </template>
160
+ </template>
161
+ </a-select>
162
+ <a-select
163
+ v-else
164
+ v-model="form[attr.model]"
165
+ :disabled="disabled"
166
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
167
+ :filter-option="filterOption"
168
+ :getPopupContainer="getPopupContainer"
169
+ dropdownClassName="custom-dropdown"
170
+ :dropdownMatchSelectWidth="false"
171
+ :dropdownStyle="{ position: 'absolute'}"
172
+ :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
173
+ show-search
174
+ @search="fetchFunction"
175
+ >
176
+ <template #notFoundContent>
177
+ <a-spin v-if="searching" size="small"/>
178
+ </template>
179
+ <a-select-option
180
+ v-if="mode === '查询'"
181
+ key="999999"
182
+ value="">全部
183
+ </a-select-option>
184
+ <a-select-option
185
+ v-for="(item,index) in option"
186
+ :key="index"
187
+ :value="item.value + ''">{{ item.label }}
188
+ </a-select-option>
189
+ </a-select>
190
+ </a-form-model-item>
191
+ <a-form-model-item
192
+ :rules="rules"
193
+ v-else-if="attr.showMode === 'radioGroup'"
194
+ :ref="attr.model"
195
+ :label="showLabel?attr.name:undefined"
196
+ :prop="attr.prop ? attr.prop : attr.model">
197
+ <a-radio-group v-model="form[attr.model]">
198
+ <a-radio-button v-for="modeItem in option" :key="modeItem.value" :value="modeItem.value">
199
+ {{ modeItem.label }}
200
+ </a-radio-button>
201
+ </a-radio-group>
202
+ </a-form-model-item>
203
+ <a-form-model-item
204
+ v-else-if="attr.showMode === 'clickChange' && option.length > 0"
205
+ :ref="attr.model"
206
+ :label="showLabel?attr.name:undefined"
207
+ :prop="attr.prop ? attr.prop : attr.model">
208
+ <XClickChangeBtn></XClickChangeBtn>
209
+ </a-form-model-item>
210
+ </x-form-col>
211
+ <!-- 多选框 -->
212
+ <x-form-col
213
+ v-else-if="attr.type === 'checkbox' && show"
214
+ :labelCol="labelCol"
215
+ :flex="attr.flex">
216
+ <a-form-model-item
217
+ :rules="rules"
218
+ v-if="!attr.showMode || mode === '查询' || attr.showMode === 'select' "
219
+ :ref="attr.model"
220
+ :label="showLabel?attr.name:undefined"
221
+ :prop="attr.prop ? attr.prop : attr.model">
222
+ <a-select
223
+ style="width:100%"
224
+ v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
225
+ v-model="form[attr.model]"
226
+ :disabled="disabled"
227
+ :filter-option="filterOption"
228
+ :getPopupContainer="getPopupContainer"
229
+ :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
230
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
231
+ mode="multiple"
232
+ show-search
233
+ allowClear
234
+ >
235
+ <template v-if="attr.keys">
236
+ <a-select-option
237
+ v-for="(item,index) in attr.keys"
238
+ :key="index"
239
+ :value="item.value + ''">
240
+ {{ item.label }}
241
+ </a-select-option>
242
+ </template>
243
+ <template v-else>
244
+ <template
245
+ v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
246
+ ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
247
+ <a-select-option
248
+ v-for="(item,index) in option"
249
+ :key="index"
250
+ :value="item.value">{{ item.label }}
251
+ </a-select-option>
252
+ </template>
253
+ <template v-else>
254
+ <a-select-option
255
+ v-for="item in $appdata.getDictionaryList(attr.keyName)"
256
+ :key="item.value"
257
+ :value="item.value + ''">{{ item.text }}
258
+ </a-select-option>
259
+ </template>
260
+ </template>
261
+ </a-select>
262
+ <a-select
263
+ v-else
264
+ v-model="form[attr.model]"
265
+ :disabled="disabled"
266
+ :filter-option="filterOption"
267
+ :getPopupContainer="getPopupContainer"
268
+ :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
269
+ mode="multiple"
270
+ style="width:100%"
271
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
272
+ show-search
273
+ allowClear
274
+ @search="fetchFunction"
275
+ >
276
+ <template #notFoundContent>
277
+ <a-spin v-if="searching" size="small"/>
278
+ </template>
279
+ <a-select-option
280
+ v-for="(item,index) in option"
281
+ :key="index"
282
+ :value="item.value + ''">{{ item.label }}
283
+ </a-select-option>
284
+ </a-select>
285
+ </a-form-model-item>
286
+ <a-form-model-item
287
+ :rules="rules"
288
+ v-else
289
+ :ref="attr.model"
290
+ :label="showLabel?attr.name:undefined"
291
+ :prop="attr.prop ? attr.prop : attr.model">
292
+ <a-checkbox-group
293
+ v-model="form[attr.model]"
294
+ :options="option"
295
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
296
+ />
297
+ </a-form-model-item>
298
+ </x-form-col>
299
+ <!-- 单选框 -->
300
+ <x-form-col
301
+ v-else-if="attr.type === 'radio' && show"
302
+ :labelCol="labelCol"
303
+ :flex="attr.flex">
304
+ <a-form-model-item
305
+ :rules="rules"
306
+ v-if="!attr.showMode || attr.type === 'radio' "
307
+ :ref="attr.model"
308
+ :label="showLabel?attr.name:undefined"
309
+ :prop="attr.prop ? attr.prop : attr.model">
310
+ <a-radio-group
311
+ v-model="form[attr.model]"
312
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
313
+ >
314
+ <template v-if="attr.keys">
315
+ <a-radio v-for="(item,index) in attr.keys" :key="index" :value="item.value">
316
+ {{ item.label }}
317
+ </a-radio>
318
+ </template>
319
+ <template v-else>
320
+ <template
321
+ v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
322
+ ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
323
+ <a-radio v-for="(item,index) in option" :key="index" :value="item.value">
324
+ {{ item.label }}
325
+ </a-radio>
326
+ </template>
327
+ <template v-else>
328
+ <a-radio v-for="(item,index) in $appdata.getDictionaryList(attr.keyName)" :key="index" :value="item.value">
329
+ {{ item.text }}
330
+ </a-radio>
331
+ </template>
332
+ </template>
333
+ </a-radio-group>
334
+ </a-form-model-item>
335
+ <a-form-model-item
336
+ :rules="rules"
337
+ v-else-if="attr.showMode === 'radioGroup'"
338
+ :ref="attr.model"
339
+ :label="showLabel?attr.name:undefined"
340
+ :prop="attr.prop ? attr.prop : attr.model">
341
+ <a-radio-group v-model="form[attr.model]">
342
+ <a-radio-button v-for="modeItem in option" :key="modeItem.value" :value="modeItem.value">
343
+ {{ modeItem.label }}
344
+ </a-radio-button>
345
+ </a-radio-group>
346
+ </a-form-model-item>
347
+ <a-form-model-item
348
+ :rules="rules"
349
+ v-else-if="attr.showMode === 'clickChange' && option.length > 0"
350
+ :ref="attr.model"
351
+ :label="showLabel?attr.name:undefined"
352
+ :prop="attr.prop ? attr.prop : attr.model">
353
+ <XClickChangeBtn></XClickChangeBtn>
354
+ </a-form-model-item>
355
+ </x-form-col>
356
+ <!-- 时间 日期 框整合 -->
357
+ <x-form-col
358
+ v-else-if="['datePicker', 'rangePicker', 'yearPicker', 'monthPicker', 'yearRangePicker', 'monthRangePicker'].includes(attr.type) && show"
359
+ :labelCol="labelCol"
360
+ :flex="attr.flex">
361
+ <a-form-model-item
362
+ :rules="rules"
363
+ :ref="attr.model"
364
+ :label="showLabel?attr.name:undefined"
365
+ :prop="attr.prop ? attr.prop : attr.model">
366
+ <XFormDatePicker
367
+ :attr="attr"
368
+ :mode="mode"
369
+ :disabled="disabled"
370
+ :readOnly="readOnly"
371
+ :showLabel="showLabel"
372
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
373
+ v-model="form[attr.model]"/>
374
+ </a-form-model-item>
375
+ </x-form-col>
376
+ <!-- 文本域 -->
377
+ <x-form-col
378
+ v-else-if="attr.type === 'textarea' && show"
379
+ :labelCol="labelCol"
380
+ :flex="attr.flex">
381
+ <!-- :style="layout === 'inline'?{width:'calc(100% - 60px)'}:{}"-->
382
+ <a-form-model-item
383
+ :rules="rules"
384
+ :ref="attr.model"
385
+ :label="showLabel?attr.name:undefined"
386
+ :prop="attr.prop ? attr.prop : attr.model">
387
+ <a-textarea
388
+ v-model="form[attr.model]"
389
+ style="width: 100%;"
390
+ :disabled="disabled"
391
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
392
+ :rows="4"/>
393
+ </a-form-model-item>
394
+ </x-form-col>
395
+ <!-- 文件上传 -->
396
+ <x-form-col
397
+ v-else-if="(attr.type === 'file' || attr.type === 'image') && show"
398
+ :labelCol="labelCol"
399
+ :flex="attr.flex">
400
+ <a-form-model-item
401
+ :rules="rules"
402
+ :ref="attr.model"
403
+ :label="showLabel?attr.name:undefined"
404
+ :prop="attr.prop ? attr.prop : attr.model">
405
+ <upload
406
+ :files="files"
407
+ :images="images"
408
+ :model="attr"
409
+ v-bind="attr"
410
+ :service-name="serviceName"
411
+ @setFiles="setFiles"></upload>
412
+ </a-form-model-item>
413
+ </x-form-col>
414
+ <!-- 省市区选择框 -->
415
+ <x-form-col
416
+ v-else-if="attr.type === 'citySelect' && show"
417
+ :labelCol="labelCol"
418
+ :flex="attr.flex">
419
+ <a-form-model-item
420
+ :rules="rules"
421
+ :ref="attr.model"
422
+ :label="showLabel?attr.name:undefined"
423
+ :prop="attr.prop ? attr.prop : attr.model">
424
+ <citySelect
425
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
426
+ ref="citySelect"
427
+ v-model="form[attr.model]"
428
+ :contexts="attr.contexts"
429
+ :value-type="attr.valueType"
430
+ :default-value="form[attr.model]"></citySelect>
431
+ </a-form-model-item>
432
+ </x-form-col>
433
+ <!-- 地点搜索框 -->
434
+ <x-form-col
435
+ v-else-if="attr.type === 'addressSearch' && show"
436
+ :labelCol="labelCol"
437
+ :occupyCol="attr.occupyCol"
438
+ :flex="attr.flex">
439
+ <a-form-model-item
440
+ :rules="rules"
441
+ :ref="attr.model"
442
+ :label="showLabel?attr.name:undefined"
443
+ :prop="attr.prop ? attr.prop : attr.model">
444
+ <address-search-combobox
445
+ :emitFunc="emitFunc"
446
+ :attr="attr"
447
+ :read-only="readOnly"
448
+ v-model="searchResult"
449
+ :resultKeys="{ address: attr.model, coords: `${attr.model}_lng_lat` }"
450
+ ref="addressSearchCombobox"
451
+ searchResultType="Object"
452
+ @onSelect="addressSearchComboboxSelect"
453
+ @onDivisionsChange="onDivisionsChange"
454
+ ></address-search-combobox>
455
+ </a-form-model-item>
456
+ </x-form-col>
457
+ <!-- 人员选择框 -->
458
+ <x-form-col
459
+ v-else-if="attr.type === 'personSetting' && show"
460
+ :labelCol="labelCol"
461
+ :flex="attr.flex">
462
+ <a-form-model-item
463
+ :rules="rules"
464
+ :ref="attr.model"
465
+ :label="showLabel?attr.name:undefined"
466
+ :prop="attr.prop ? attr.prop : attr.model">
467
+ <PersonSetting v-model="form[attr.model]"></PersonSetting>
468
+ </a-form-model-item>
469
+ </x-form-col>
470
+ <!-- 树形选择框 -->
471
+ <x-form-col
472
+ v-else-if="attr.type === 'treeSelect' && show"
473
+ :labelCol="labelCol"
474
+ :flex="attr.flex">
475
+ <x-tree-select
476
+ :rules="rules"
477
+ @onChange="attr.dataChangeFunc && debouncedDataChangeFunc()"
478
+ v-model="form[attr.model]"
479
+ :attr="attr"
480
+ @mounted="itemMounted"
481
+ ref="xTreeSelect">
482
+ </x-tree-select>
483
+ </x-form-col>
484
+ <!-- 列表选择框 -->
485
+ <x-form-col
486
+ v-else-if="attr.type === 'listSelect' && show"
487
+ :labelCol="labelCol"
488
+ :flex="attr.flex">
489
+ <a-form-model-item
490
+ :rules="rules"
491
+ :ref="attr.model"
492
+ :label="showLabel?attr.name:undefined"
493
+ :style="layout === 'inline'&& attr.occupyCol && attr.occupyCol > 1? {width:`calc(100% - ${attr.occupyCol * 1.533}rem)`}:{}"
494
+ :prop="attr.prop ? attr.prop : attr.model">
495
+ <a-popover
496
+ ref="rowChoosePopover"
497
+ :visible="rowChoosePopoverVisible"
498
+ title="选择数据"
499
+ placement="bottom"
500
+ trigger="focus"
501
+ :arrowPointAtCenter="true"
502
+ :overlayStyle="{ width: '1000px', height: '30vh' }">
503
+ <template #content>
504
+ <x-report
505
+ v-if="isCover"
506
+ :use-oss-for-img="false"
507
+ :config-name="queryParamsName"
508
+ :service-name="serviceName"
509
+ :show-img-in-cell="true"
510
+ :display-only="true"
511
+ :edit-mode="false"
512
+ :show-save-button="true"
513
+ :no-padding="true"
514
+ :dont-format="true"
515
+ @rowChoose="rowChoose"
516
+ @cancel="closeRowChooseInput"
517
+ >
518
+ </x-report>
519
+ <x-form-table
520
+ v-else
521
+ title="请选择数据"
522
+ :queryParamsName="queryParamsName"
523
+ :rowSelectMode="true"
524
+ :allowSelectRowNum="1"
525
+ :service-name="serviceName"
526
+ :fixed-query-form="rowChooseFixedQueryValue"
527
+ @rowChoose="rowChoose"
528
+ @afterQuery="rowChooseSearchAfterQuery"
529
+ ref="rowChooseTable">
530
+ <template #button>
531
+ <a-button @click="closeRowChooseInput">
532
+ 关闭
533
+ </a-button>
534
+ </template>
535
+ </x-form-table>
536
+ </template>
537
+ <a-input
538
+ v-model="form[attr.model]"
539
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
540
+ @change="searchRowChooseData"
541
+ @focus="showCloseRowChooseInput"/>
542
+ </a-popover>
543
+ </a-form-model-item>
544
+ </x-form-col>
545
+ <!-- 评分框 -->
546
+ <x-form-col
547
+ v-else-if="attr.type === 'rate' && show"
548
+ :labelCol="labelCol"
549
+ :flex="attr.flex">
550
+ <a-form-model-item
551
+ :rules="rules"
552
+ :ref="attr.model"
553
+ :label="showLabel?attr.name:undefined"
554
+ :prop="attr.prop ? attr.prop : attr.model">
555
+ <x-rate
556
+ v-model="form[attr.model]"
557
+ :mode="mode"
558
+ :disabled="disabled"
559
+ :query-type="attr.queryType"
560
+ :max-count="attr.maxCount"
561
+ :allow-half="attr.allowHalf"
562
+ :icon="attr.rateIcon"
563
+ :placeholder="attr.placeholder ? attr.placeholder : '请选择'+attr.name.replace(/\s*/g, '')"
564
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
565
+ />
566
+ </a-form-model-item>
567
+ </x-form-col>
568
+ <!-- 区间选择器 -->
569
+ <x-form-col
570
+ v-else-if="attr.type === 'intervalPicker' && show"
571
+ :labelCol="labelCol"
572
+ :flex="attr.flex">
573
+ <a-form-model-item
574
+ :rules="rules"
575
+ :ref="attr.model"
576
+ :label="showLabel?attr.name:undefined"
577
+ :prop="attr.prop ? attr.prop : attr.model">
578
+ <x-interval-picker
579
+ v-model="form[attr.model]"
580
+ :mode="mode"
581
+ :read-only="readOnly"
582
+ :disabled="disabled && !readOnly"
583
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
584
+ :start-placeholder="attr.startPlaceholder || '起始值'"
585
+ :end-placeholder="attr.endPlaceholder || '结束值'"
586
+ @blur="attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
587
+ />
588
+ </a-form-model-item>
589
+ </x-form-col>
590
+ <!-- 车牌号选择 -->
591
+ <x-form-col
592
+ v-else-if="attr.type === 'licensePlate' && show"
593
+ :labelCol="labelCol"
594
+ :flex="attr.flex">
595
+ <a-form-model-item
596
+ :rules="rules"
597
+ :ref="attr.model"
598
+ :label="showLabel?attr.name:undefined"
599
+ :style="layout === 'inline'&& attr.occupyCol && attr.occupyCol > 1? {width:`calc(100% - ${attr.occupyCol * 1.533}rem)`}:{}"
600
+ :prop="attr.prop ? attr.prop : attr.model">
601
+ <!-- 如果配置了后置按钮插槽 -->
602
+ <a-input
603
+ v-if="mode ==='查询'"
604
+ v-model="form[attr.model]"
605
+ :whitespace="true"
606
+ :read-only="readOnly"
607
+ :disabled="disabled && !readOnly"
608
+ style="width:100%"
609
+ @blur="attr.inputOnBlurFunc && emitFunc(attr.inputOnBlurFunc,attr)"
610
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
611
+ :ref="`${attr.model}input`"/>
612
+ <x-license-plate
613
+ v-else
614
+ v-model="form[attr.model]"
615
+ @change="attr.dataChangeFunc && debouncedDataChangeFunc()"
616
+ ></x-license-plate>
617
+ </a-form-model-item>
618
+ </x-form-col>
619
+ <!-- 录音 -->
620
+ <x-form-col
621
+ v-else-if="attr.type === 'recording' && show"
622
+ :labelCol="labelCol"
623
+ :flex="attr.flex">
624
+ <recording
625
+ ref="recording"
626
+ @recordingData="recordingData"
627
+ >
628
+ </recording>
629
+ </x-form-col>
630
+ <!-- 表格录入 -->
631
+ <x-form-col
632
+ v-else-if="attr.type === 'rowEdit' && show"
633
+ :labelCol="labelCol"
634
+ :flex="attr.flex">
635
+ <a-form-model-item
636
+ :rules="rules"
637
+ :ref="attr.model"
638
+ :label="showLabel?attr.name:undefined"
639
+ :prop="attr.prop ? attr.prop : attr.model">
640
+ <x-form-table
641
+ :key="'childTable_' + attr.model"
642
+ :title="attr.name"
643
+ :queryParamsName="attr.crud"
644
+ :localEditMode="true"
645
+ :fixed-query-form="childTableFixedQueryForm(attr)"
646
+ :service-name="serviceName"
647
+ @hook:mounted="(h)=>onComponentMounted(h, attr)"
648
+ :ref="'childXFormTable_' + attr.model">
649
+ </x-form-table>
650
+ </a-form-model-item>
651
+ </x-form-col>
652
+ </template>
653
+ <script>
654
+ import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
655
+ import XFormCol from '@vue2-client/base-client/components/common/XFormCol'
656
+ import XBadge from '@vue2-client/base-client/components/common/XBadge'
657
+ import CitySelect from '@vue2-client/base-client/components/common/CitySelect'
658
+ import PersonSetting from '@vue2-client/base-client/components/common/PersonSetting'
659
+ import AddressSearchCombobox from '@vue2-client/base-client/components/common/AddressSearchCombobox'
660
+ import Upload from '@vue2-client/base-client/components/common/Upload'
661
+ import moment from 'moment'
662
+ import { getConfigByName, runLogic, getConfigByNameAsync } from '@vue2-client/services/api/common'
663
+ import * as util from '@vue2-client/utils/util'
664
+ import XTreeSelect from '@vue2-client/base-client/components/common/XForm/XTreeSelect'
665
+ import { searchToListOption, searchToOption } from '@vue2-client/services/v3Api'
666
+ import { mapState } from 'vuex'
667
+ import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
668
+ import XLicensePlate from '@vue2-client/base-client/components/common/XLicensePlate/XLicensePlate.vue'
669
+ import XStatusButton from './XStatusButton.vue'
670
+ import XClickChangeBtn from './itemComponent/XClickChangeBtn'
671
+ import 'moment/locale/zh-cn'
672
+ import XFormDatePicker from '@vue2-client/base-client/components/common/XDatePicker/index.vue'
673
+ import XIntervalPicker from '@vue2-client/base-client/components/common/XIntervalPicker/XIntervalPicker.vue'
674
+ import XRate from '@vue2-client/base-client/components/common/XRate/index.vue'
675
+
676
+ export default {
677
+ name: 'XFormItem',
678
+ components: {
679
+ XFormDatePicker,
680
+ XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue'),
681
+ Recording: () => import('@vue2-client/base-client/components/common/Recording/Recording.vue'),
682
+ XReport: () => import('@vue2-client/base-client/components/common/XReportGrid/XReport.vue'),
683
+ XLicensePlate,
684
+ XTreeSelect,
685
+ XFormCol,
686
+ XBadge,
687
+ CitySelect,
688
+ PersonSetting,
689
+ AddressSearchCombobox,
690
+ Upload,
691
+ XStatusButton,
692
+ XClickChangeBtn,
693
+ XIntervalPicker,
694
+ XRate
695
+ },
696
+ data () {
697
+ // 检索去抖
698
+ this.fetchFunction = debounce(this.fetchFunction, 800)
699
+ return {
700
+ option: [],
701
+ // 最后检索版本
702
+ lastFetchId: 0,
703
+ // 检索中
704
+ searching: false,
705
+ searchResult: '',
706
+ optionForFunc: [],
707
+ // 控制当前表单项是否展示
708
+ show: true,
709
+ // moment
710
+ moment,
711
+ // 行选择器浮层是否显示
712
+ rowChoosePopoverVisible: false,
713
+ // 行选择器CRUD固定查询值
714
+ rowChooseFixedQueryValue: undefined
715
+ }
716
+ },
717
+ props: {
718
+ attr: {
719
+ type: Object,
720
+ default:
721
+ () => {
722
+ return {}
723
+ }
724
+ },
725
+ form: {
726
+ type: Object,
727
+ required:
728
+ true
729
+ },
730
+ disabled: {
731
+ type: Boolean,
732
+ default:
733
+ () => {
734
+ return false
735
+ }
736
+ },
737
+ readOnly: {
738
+ type: Boolean,
739
+ default:
740
+ () => {
741
+ return false
742
+ }
743
+ },
744
+ mode: {
745
+ type: String,
746
+ default:
747
+ () => {
748
+ return '查询'
749
+ }
750
+ },
751
+ files: {
752
+ type: Array,
753
+ default:
754
+ () => {
755
+ return []
756
+ }
757
+ },
758
+ images: {
759
+ type: Array,
760
+ default:
761
+ () => {
762
+ return []
763
+ }
764
+ },
765
+ serviceName: {
766
+ type: String,
767
+ default:
768
+ undefined
769
+ },
770
+ // 调用logic获取数据源的追加参数
771
+ getDataParams: {
772
+ type: Object,
773
+ default:
774
+ undefined
775
+ },
776
+ // 布局
777
+ layout: {
778
+ type: String,
779
+ default:
780
+ 'horizontal'
781
+ },
782
+ // 环境
783
+ env: {
784
+ type: String,
785
+ default:
786
+ () => {
787
+ return 'prod'
788
+ }
789
+ },
790
+ // 设置表单值
791
+ setForm: {
792
+ type: Function,
793
+ default: (val) => {
794
+ console.log(val)
795
+ }
796
+ },
797
+ showLabel: {
798
+ type: Boolean,
799
+ default:
800
+ () => {
801
+ return true
802
+ }
803
+ },
804
+ labelCol: {
805
+ type: Object,
806
+ default: () => {
807
+ return { span: 8 }
808
+ }
809
+ },
810
+ rules: {
811
+ type: Array,
812
+ default:
813
+ () => {
814
+ return undefined
815
+ }
816
+ }
817
+ },
818
+ provide () {
819
+ return {
820
+ FormItemContext: this
821
+ }
822
+ },
823
+ created () {
824
+ this.init()
825
+ if (this.attr.keyName && (this.attr?.keyName?.toString().indexOf('async ') !== -1 || this.attr?.keyName?.toString()?.indexOf('function') !== -1)) {
826
+ this.debouncedUpdateOptions = debounce(this.updateOptions, 200)
827
+ }
828
+ if (this.attr.dataChangeFunc) {
829
+ this.debouncedDataChangeFunc = debounce(this.dataChangeFunc, 200)
830
+ // 执行一次
831
+ this.dataChangeFunc()
832
+ }
833
+ if (this.attr.showFormItemFunc) {
834
+ this.debouncedShowFormItemFunc = debounce(this.showFormItemFunc, 100)
835
+ // 执行一次
836
+ this.showFormItemFunc()
837
+ }
838
+ if (this.attr.showQueryFormItemFunc) {
839
+ this.debouncedShowQueryFormItemFunc = debounce(this.showQueryFormItemFunc, 100)
840
+ // 执行一次
841
+ this.showFormItemFunc()
842
+ }
843
+ // 人员联动框增加监听
844
+ if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString().endsWith(']联动人员')) {
845
+ this.debouncedUserLinkFunc = debounce(() => this.updateResOptions('人员'), 200)
846
+ }
847
+ if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString().endsWith(']联动部门')) {
848
+ this.debouncedDepLinkFunc = debounce(() => this.updateResOptions('部门'), 200)
849
+ }
850
+ // xTreeSelect 自己调用 mounted
851
+ if (this.attr.type !== 'treeSelect') {
852
+ this.$emit('mounted', this.attr)
853
+ }
854
+ },
855
+ computed: {
856
+ ...mapState('account', { currUser: 'user' }),
857
+ queryParamsName () {
858
+ if (this.attr.keyName.startsWith('function')) {
859
+ // 调用异步函数获取内容
860
+ return executeStrFunctionByContext(this, this.attr.keyName, [this.form, runLogic, this.mode, getConfigByNameAsync])
861
+ } else {
862
+ // 按现有方式处理
863
+ return this.attr.keyName.split('@')[this.attr.keyName.split('@').length - 1]
864
+ }
865
+ },
866
+ // 判断弹出时是否Cover,弹出只支持Cover以及CRUD
867
+ isCover () {
868
+ // 如果 queryParamsName 为空,返回空
869
+ if (!this.queryParamsName) {
870
+ return false
871
+ }
872
+ const result = this.queryParamsName.endsWith('Cover')
873
+ return result
874
+ },
875
+ },
876
+ watch: {
877
+ attr: {
878
+ handler () {
879
+ this.init()
880
+ },
881
+ deep: true
882
+ },
883
+ form: {
884
+ handler (newVal, oldVal) {
885
+ // 如果是从函数获取 options
886
+ if (this.attr.keyName && (this.attr.keyName.toString().indexOf('async ') !== -1 || this.attr.keyName.toString().indexOf('function') !== -1)) {
887
+ this.debouncedUpdateOptions()
888
+ }
889
+ // 如果有自定义是否展示表单项函数
890
+ if (this.attr.showFormItemFunc) {
891
+ this.debouncedShowFormItemFunc()
892
+ }
893
+ // 如果有自定义是否展示查询表单项函数
894
+ if (this.attr.showQueryFormItemFunc) {
895
+ this.debouncedShowQueryFormItemFunc()
896
+ }
897
+ // 地址搜索框赋值
898
+ if (this.attr.type === 'addressSearch') {
899
+ this.$refs.addressSearchCombobox.addressInput = this.form[this.attr.model]
900
+ }
901
+ // 数据源来自人员联动时更新数据
902
+ if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString().endsWith(']联动人员')) {
903
+ this.debouncedUserLinkFunc()
904
+ }
905
+ // 数据源来自人员联动时更新数据
906
+ if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString().endsWith(']联动部门')) {
907
+ this.debouncedDepLinkFunc()
908
+ }
909
+ },
910
+ deep: true
911
+ }
912
+ },
913
+ inject: {
914
+ getComponentByName: {
915
+ default: () => () => {
916
+ console.warn('getComponentByName is not provided')
917
+ return null // 或者返回一个默认的函数
918
+ },
919
+ },
920
+ registerComponent: {
921
+ default: () => () => {
922
+ console.warn('registerComponent is not provided')
923
+ return null // 或者返回一个默认的函数
924
+ },
925
+ },
926
+ getSelf: {
927
+ default: () => () => {
928
+ console.warn('getSelf is not provided')
929
+ return null // 或者返回一个默认的函数
930
+ },
931
+ },
932
+ XFormContext: {
933
+ default: () => () => {
934
+ console.warn('XFormContext is not provided')
935
+ return null // 或者返回一个默认的函数
936
+ },
937
+ },
938
+ setRequired: {
939
+ default: () => () => {
940
+ console.warn('setRequired is not provided')
941
+ return null // 或者返回一个默认的函数
942
+ },
943
+ },
944
+ removeRequired: {
945
+ default: () => () => {
946
+ console.warn('removeRequired is not provided')
947
+ return null // 或者返回一个默认的函数
948
+ },
949
+ }
950
+ },
951
+ methods: {
952
+ // 把内部的crud表单录入放到表单中,以便外部可以调用
953
+ onComponentMounted (h, attr) {
954
+ console.log('crud表单', h)
955
+ if (attr.crud) {
956
+ this.registerComponent(attr.model, this.$refs['childXFormTable_' + attr.model])
957
+ }
958
+ },
959
+ childTableFixedQueryForm (item) {
960
+ console.log('传递的form', this.form)
961
+ if (this.modifyModelData?.primaryKeyData) {
962
+ const fixedForm = {}
963
+ fixedForm[item.childTableForeignKeyName] = Object.values(this.modifyModelData.primaryKeyData)[0]
964
+ return fixedForm
965
+ }
966
+ return null
967
+ },
968
+ // 动态生成事件绑定对象
969
+ generateDynamicEvents (inputOnAfterFunc, attr) {
970
+ const events = {}
971
+ const states = this.parseStates(attr.inputOnAfterName, inputOnAfterFunc)
972
+
973
+ states.forEach((state) => {
974
+ // 动态绑定事件名到 emitFunc
975
+ events[state.event] = () => {
976
+ console.info('事件名', state.event)
977
+ this.emitFunc(state.event, attr)
978
+ }
979
+ })
980
+
981
+ return events // 返回 { state1Event: handler, state2Event: handler, ... }
982
+ },
983
+ parseStates (input, events) {
984
+ const eventNames = events.split('|')
985
+ return input.split('|').map((label, index) => ({
986
+ label,
987
+ event: eventNames[index] // 如果没有提供事件名称,则使用默认值
988
+ }))
989
+ },
990
+ focusInput () {
991
+ if (this.attr.defaultFocus) {
992
+ this.$nextTick(h => {
993
+ const el = this.$refs[`${this.attr.model}input`]?.$el
994
+ let inputEl
995
+ if (el) {
996
+ if (el.tagName.toLowerCase() === 'input') {
997
+ inputEl = el
998
+ } else {
999
+ inputEl = el.querySelector('input')
1000
+ }
1001
+ }
1002
+ if (inputEl) {
1003
+ inputEl.focus()
1004
+ if (inputEl.type === 'number') {
1005
+ if (inputEl.valueAsNumber) {
1006
+ inputEl.setSelectionRange(0, inputEl.valueAsNumber.toString().length)
1007
+ }
1008
+ } else {
1009
+ if (inputEl.value) {
1010
+ inputEl.setSelectionRange(0, inputEl.value.length)
1011
+ }
1012
+ }
1013
+ }
1014
+ })
1015
+ }
1016
+ },
1017
+ // 更新人员下拉框数据
1018
+ async updateResOptions (type) {
1019
+ if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString()?.endsWith(`]联动${type}`)) {
1020
+ const startIndex = this.attr.keyName.indexOf('[') + 1
1021
+ const endIndex = this.attr.keyName.indexOf(']', startIndex)
1022
+ const fromModel = this.attr.keyName.substring(startIndex, endIndex).replace('.', '_')
1023
+ const formModelData = Array.isArray(this.form[fromModel])
1024
+ ? this.form[fromModel]
1025
+ : [this.form[fromModel]]
1026
+ if (fromModel?.length && formModelData?.length) {
1027
+ const searchData = { source: `获取${type}`, userid: this.currUser.id, filter: formModelData, filterType: fromModel.indexOf('org') > -1 ? 'org' : 'dep' }
1028
+ await searchToListOption(searchData, res => {
1029
+ this.getDataCallback(
1030
+ res.filter(h => {
1031
+ if (fromModel.indexOf('org') > -1) {
1032
+ return formModelData?.includes(h.orgid || h.f_organization_id || h.parentid)
1033
+ } else {
1034
+ return formModelData?.includes(h?.parentid)
1035
+ }
1036
+ }
1037
+ )
1038
+ )
1039
+ })
1040
+ }
1041
+ }
1042
+ },
1043
+ // js 函数作为数据源
1044
+ async updateOptions () {
1045
+ if (this.attr.keyName && (this.attr.keyName.indexOf('async ') !== -1 || this.attr.keyName.indexOf('function ') !== -1)) {
1046
+ this.optionForFunc = await executeStrFunctionByContext(this, this.attr.keyName, [this.form, runLogic, this.mode, getConfigByNameAsync])
1047
+ }
1048
+ },
1049
+ async dataChangeFunc () {
1050
+ if (this.attr.dataChangeFunc) {
1051
+ await executeStrFunctionByContext(this, this.attr.dataChangeFunc, [this.form, this.setForm, this.attr, util, this.mode, runLogic, getConfigByNameAsync])
1052
+ }
1053
+ },
1054
+ async showFormItemFunc () {
1055
+ if (this.attr.showFormItemFunc) {
1056
+ const obj = executeStrFunctionByContext(this, this.attr.showFormItemFunc, [this.form, this.setForm, this.attr, util, this.mode])
1057
+ // 判断是 bool 还是 obj 兼容
1058
+ if (typeof obj === 'boolean') {
1059
+ this.show = obj
1060
+ } else if (obj && typeof obj === 'object') {
1061
+ // obj 是一个对象,并且不是数组
1062
+ this.show = obj?.show
1063
+ this.readOnly = obj?.readOnly
1064
+ }
1065
+ } else {
1066
+ this.show = true
1067
+ }
1068
+ },
1069
+ async showQueryFormItemFunc () {
1070
+ if (this.attr.showQueryFormItemFunc) {
1071
+ const obj = executeStrFunctionByContext(this, this.attr.showQueryFormItemFunc, [this.form, this.setForm, this.attr, util, this.mode])
1072
+ // 判断是 bool 还是 obj 兼容
1073
+ if (typeof obj === 'boolean') {
1074
+ this.show = obj
1075
+ } else if (obj && typeof obj === 'object') {
1076
+ // obj 是一个对象,并且不是数组
1077
+ this.show = obj?.show
1078
+ this.readOnly = obj?.readOnly
1079
+ }
1080
+ } else {
1081
+ this.show = true
1082
+ }
1083
+ },
1084
+ init () {
1085
+ if (!this.attr.flex) {
1086
+ if (this.mode === '新增/修改') {
1087
+ if (['horizontal', 'vertical'].includes(this.layout) || ['textarea', 'file', 'image'].includes(this.attr.type)) {
1088
+ // 新增修改表单 horizontal 模式下默认为一行
1089
+ this.attr.flex = {
1090
+ xs: 24,
1091
+ sm: 24,
1092
+ md: 24,
1093
+ lg: 24,
1094
+ xl: 24,
1095
+ xxl: 24,
1096
+ fullWidth: true
1097
+ }
1098
+ } else {
1099
+ // 新增修改表单 vertical 模式下默认为1列
1100
+ this.attr.flex = {
1101
+ xs: 24,
1102
+ sm: 12,
1103
+ md: 8,
1104
+ lg: 8,
1105
+ xl: 6,
1106
+ xxl: 6
1107
+ }
1108
+ }
1109
+ } else {
1110
+ this.attr.flex = {
1111
+ xs: 24,
1112
+ sm: 24,
1113
+ md: 8,
1114
+ lg: 6,
1115
+ xl: 6,
1116
+ xxl: 6
1117
+ }
1118
+ }
1119
+ }
1120
+ if (this.attr.keyName && typeof this.attr.keyName === 'string') {
1121
+ if (this.attr.keyName.indexOf('logic@') !== -1) {
1122
+ this.getData({}, res => this.getDataCallback(res))
1123
+ } else if (this.attr.keyName.indexOf('search@') !== -1) {
1124
+ // `tool.getFullTree(this.getRights().where(row.getType()==$organization$))`
1125
+ // 判断是否根据角色查询
1126
+ let source = this.attr.keyName.substring(7)
1127
+ const userid = this.currUser.id
1128
+ let roleName = 'roleName'
1129
+ if (source.startsWith('根据角色[') && source.endsWith(']获取人员')) {
1130
+ const startIndex = source.indexOf('[') + 1
1131
+ const endIndex = source.indexOf(']', startIndex)
1132
+ roleName = source.substring(startIndex, endIndex)
1133
+ source = '根据角色获取人员'
1134
+ }
1135
+ const searchData = { source, userid, roleName }
1136
+ // 判断是否根据某个表单项联动 仅返回列表结构并筛选
1137
+ if (source.startsWith('根据表单项[') && source.endsWith(']联动人员')) {
1138
+ this.updateResOptions('人员')
1139
+ } else if (source.startsWith('根据表单项[') && source.endsWith(']联动部门')) {
1140
+ this.updateResOptions('部门')
1141
+ } else if (this.attr.type === 'select' || this.attr.type === 'checkbox') {
1142
+ // 仅获取最内层数据
1143
+ searchToListOption(searchData, res => this.getDataCallback(res))
1144
+ } else {
1145
+ // 其他资源通用逻辑
1146
+ searchToOption(searchData, res => this.getDataCallback(res))
1147
+ }
1148
+ } else if (this.attr.keyName.indexOf('config@') !== -1) {
1149
+ const configName = this.attr.keyName.substring(7)
1150
+ getConfigByName(configName, this.serviceName, res => {
1151
+ this.getDataCallback(res.value)
1152
+ }, this.env === 'dev')
1153
+ } else if (this.attr.keyName.indexOf('async ') !== -1 || this.attr.keyName.indexOf('function ') !== -1) {
1154
+ this.updateOptions()
1155
+ }
1156
+ } else if (this.attr.keys) {
1157
+ this.getDataCallback(this.attr.keys)
1158
+ }
1159
+ this.focusInput()
1160
+ },
1161
+ addressSearchComboboxSelect (data) {
1162
+ this.form = Object.assign(this.form, JSON.parse(data))
1163
+ },
1164
+ onDivisionsChange (data) {
1165
+ this.emitFunc('addressSearchComboboxSelect', {
1166
+ key: this.attr.model,
1167
+ value: data
1168
+ })
1169
+ },
1170
+ getDataCallback (res) {
1171
+ this.option = res
1172
+ if (this.attr.type === 'treeSelect') {
1173
+ this.$nextTick(() => {
1174
+ this.$refs.xTreeSelect.init({
1175
+ option: this.option,
1176
+ form: this.form,
1177
+ queryType: this.attr.queryType,
1178
+ name: this.attr.name,
1179
+ model: this.attr.model,
1180
+ mode: this.mode,
1181
+ disabled: this.disabled
1182
+ })
1183
+ })
1184
+ } else if (this.attr.type === 'radio' || ['radioGroup', 'clickChange'].includes(this.attr.showMode)) {
1185
+ this.initRadioValue()
1186
+ }
1187
+ },
1188
+ initRadioValue () {
1189
+ const model = this.attr.model
1190
+ if (this.mode === '新增/修改' && (this.form[model] === undefined || this.form[model] === null) && !this.attr.prop) {
1191
+ if (this.attr.keys && this.attr.keys.length > 1) {
1192
+ this.form[model] = this.attr.keys[0].value
1193
+ } else if (this.option.length > 1) {
1194
+ this.form[model] = this.option[0].value
1195
+ }
1196
+ }
1197
+ },
1198
+ // 文件框时设置上传组件的值
1199
+ setFiles (fileIds) {
1200
+ if (!this.form[this.attr.model]) {
1201
+ this.form[this.attr.model] = []
1202
+ }
1203
+ this.form[this.attr.model] = [...fileIds]
1204
+ },
1205
+ // 懒加载检索方法
1206
+ fetchFunction (value) {
1207
+ this.lastFetchId += 1
1208
+ const fetchId = this.lastFetchId
1209
+ this.option = []
1210
+ this.searching = true
1211
+ this.getData({
1212
+ word: value
1213
+ }, res => {
1214
+ if (fetchId !== this.lastFetchId) {
1215
+ return
1216
+ }
1217
+ this.option = res
1218
+ this.searching = false
1219
+ })
1220
+ },
1221
+ // 获取数据
1222
+ getData (value, callbackFun) {
1223
+ if (value !== '') {
1224
+ const logicName = this.attr.keyName
1225
+ const logic = logicName.substring(6)
1226
+ // 调用logic前设置参数
1227
+ if (this.getDataParams && this.getDataParams[this.attr.model]) {
1228
+ Object.assign(value, this.getDataParams[this.attr.model])
1229
+ }
1230
+ runLogic(logic, Object.assign(value, {
1231
+ orgId: this.currUser.orgid,
1232
+ userId: this.currUser.id
1233
+ }), this.serviceName, this.env === 'dev').then(res => {
1234
+ callbackFun(res)
1235
+ }).catch(e => {
1236
+ callbackFun([])
1237
+ console.error('获取数据失败:' + e)
1238
+ })
1239
+ }
1240
+ },
1241
+ filterOption (input, option) {
1242
+ const child = option.componentOptions.children[0]
1243
+ if (child.text) {
1244
+ return child.text.toLowerCase().indexOf(input.toLowerCase()) >= 0
1245
+ } else if (child.elm.innerText) {
1246
+ return child.elm.innerText.toLowerCase().indexOf(input.toLowerCase()) >= 0
1247
+ } else {
1248
+ return child.child.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
1249
+ }
1250
+ },
1251
+ // 表单项变更函数中调用 控制表单组中表单项组名为 groupName 的表单是否展示
1252
+ // func:x-form-show(显示)/x-form-no-show(不显示)
1253
+ emitShowFormFunc (func, groupName) {
1254
+ this.emitFunc(func, groupName)
1255
+ },
1256
+ emitFunc (func, data) {
1257
+ this.$emit('x-form-item-emit-func', func, data, data?.model ? this.form[data.model] : this.form)
1258
+ },
1259
+ itemMounted (h) {
1260
+ this.$emit('mounted', h)
1261
+ },
1262
+ rowChoose (rows) {
1263
+ this.$emit('rowChoose', rows, this.attr, this.closeRowChooseInput)
1264
+ },
1265
+ searchRowChooseData () {
1266
+ if (this.searching) {
1267
+ return
1268
+ }
1269
+ this.lastFetchId += 1
1270
+ const fetchId = this.lastFetchId
1271
+ this.searching = true
1272
+ if (fetchId !== this.lastFetchId) {
1273
+ return
1274
+ }
1275
+ this.rowChooseFixedQueryValue = []
1276
+ this.rowChooseFixedQueryValue[this.attr.model] = this.form[this.attr.model]
1277
+ this.$nextTick(() => {
1278
+ this.$refs.rowChooseTable.refresh(true)
1279
+ })
1280
+ },
1281
+ showCloseRowChooseInput () {
1282
+ this.rowChoosePopoverVisible = true
1283
+ },
1284
+ closeRowChooseInput () {
1285
+ this.rowChoosePopoverVisible = false
1286
+ },
1287
+ rowChooseSearchAfterQuery () {
1288
+ this.searching = false
1289
+ },
1290
+ // 获取 recording 转换后的数据
1291
+ getRecodingData () {
1292
+ return this.$refs.recording.getRecordingData()
1293
+ },
1294
+ recordingData (data) {
1295
+ this.emitFunc('recordingData', data)
1296
+ },
1297
+ getPopupContainer (triggerNode) {
1298
+ return document.body
1299
+ // return triggerNode.parentNode
1300
+ },
1301
+ }
1302
+ }
1303
+ </script>
1304
+
1305
+ <style lang="less" scoped>
1306
+ .custom-dropdown {
1307
+ position: absolute;
1308
+ z-index: 1050;
1309
+ }
1310
+ </style>