vue2-client 1.4.43 → 1.4.45

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,440 +1,469 @@
1
- <template>
2
- <!-- 输入框 -->
3
- <x-form-col
4
- v-if="attr.type === 'input'"
5
- :xl="xl"
6
- :xxl="xxl">
7
- <a-form-model-item
8
- :ref="attr.model"
9
- :label="attr.name"
10
- :prop="attr.model">
11
- <a-input v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
12
- </a-form-model-item>
13
- </x-form-col>
14
- <!-- 下拉框 -->
15
- <x-form-col
16
- v-else-if="attr.type === 'select'"
17
- :xl="xl"
18
- :xxl="xxl">
19
- <a-form-model-item
20
- :ref="attr.model"
21
- :label="attr.name"
22
- :prop="attr.model">
23
- <a-select
24
- v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
25
- v-model="form[attr.model]"
26
- :disabled="disabled"
27
- :filter-option="filterOption"
28
- :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
29
- :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
30
- show-search
31
- >
32
- <a-select-option
33
- v-if="mode === '查询'"
34
- key="999999"
35
- value="全部">全部
36
- </a-select-option>
37
- <template v-if="attr.keys">
38
- <a-select-option
39
- v-for="(item,index) in attr.keys"
40
- :key="index"
41
- :value="item.value">
42
- {{ item.label }}
43
- </a-select-option>
44
- </template>
45
- <template v-else>
46
- <template v-if="attr.keyName.indexOf('logic@') !== -1">
47
- <a-select-option
48
- v-for="(item,index) in option"
49
- :key="index"
50
- :value="item.value">{{ item.label }}
51
- </a-select-option>
52
- </template>
53
- <template v-else>
54
- <a-select-option
55
- v-for="item in $appdata.getDictionaryList(attr.keyName)"
56
- :key="item.value"
57
- :value="item.value">
58
- <!-- 徽标(badge) -->
59
- <x-badge :badge-key="attr.keyName" :replaceText="item.text" :value="item.value"/>
60
- </a-select-option>
61
- </template>
62
- </template>
63
- </a-select>
64
- <a-select
65
- v-else
66
- v-model="form[attr.model]"
67
- :disabled="disabled"
68
- :filter-option="filterOption"
69
- :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
70
- :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
71
- show-search
72
- @search="fetchFunction"
73
- >
74
- <a-spin v-if="searching" slot="notFoundContent" size="small" />
75
- <a-select-option
76
- v-if="mode === '查询'"
77
- key="999999"
78
- value="全部">全部
79
- </a-select-option>
80
- <a-select-option
81
- v-for="(item,index) in option"
82
- :key="index"
83
- :value="item.value">{{ item.label }}
84
- </a-select-option>
85
- </a-select>
86
- </a-form-model-item>
87
- </x-form-col>
88
- <!-- 级联下拉框 -->
89
- <x-form-col
90
- v-else-if="attr.type === 'selects'"
91
- :xl="xl"
92
- :xxl="xxl">
93
- <a-form-model-item
94
- :ref="attr.model"
95
- :label="attr.name"
96
- :prop="attr.model">
97
- <a-select
98
- v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
99
- v-model="form[attr.model]"
100
- :disabled=" attr.groupIndex>1 && (disabled || !selectsArray[attr.group] || !selectsArray[attr.group][attr.groupIndex] || (selectsArray[attr.group][attr.groupIndex] && selectsArray[attr.group][attr.groupIndex].length === 0))"
101
- :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
102
- :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
103
- show-search
104
- @change="selectsItemCheck(attr.group, attr.groupIndex, form[attr.model])"
105
- >
106
- <template v-for="optionItem in selectsArray[attr.group][attr.groupIndex]" v-if="selectsArray[attr.group].length > 0 || selectsArray[attr.group][attr.groupIndex]">
107
- <a-select-option :key="optionItem.label" :value="optionItem.value">
108
- {{ optionItem.label }}
109
- </a-select-option>
110
- </template>
111
- </a-select>
112
- </a-form-model-item>
113
- </x-form-col>
114
- <!-- 多选框 -->
115
- <x-form-col
116
- v-else-if="attr.type === 'checkbox'"
117
- :xl="xl"
118
- :xxl="xxl">
119
- <a-form-model-item
120
- :ref="attr.model"
121
- :label="attr.name"
122
- :prop="attr.model">
123
- <a-select
124
- v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
125
- v-model="form[attr.model]"
126
- :disabled="disabled"
127
- :filter-option="filterOption"
128
- :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
129
- :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
130
- mode="multiple"
131
- show-search
132
- allowClear
133
- >
134
- <template v-if="attr.keys">
135
- <a-select-option
136
- v-for="(item,index) in attr.keys"
137
- :key="index"
138
- :value="item.value">
139
- {{ item.label }}
140
- </a-select-option>
141
- </template>
142
- <template v-else>
143
- <template v-if="attr.keyName.indexOf('logic@') !== -1">
144
- <a-select-option
145
- v-for="(item,index) in option"
146
- :key="index"
147
- :value="item.value">{{ item.label }}
148
- </a-select-option>
149
- </template>
150
- <template v-else>
151
- <a-select-option
152
- v-for="item in $appdata.getDictionaryList(attr.keyName)"
153
- :key="item.value"
154
- :value="item.value">{{ item.text }}
155
- </a-select-option>
156
- </template>
157
- </template>
158
- </a-select>
159
- <a-select
160
- v-else
161
- v-model="form[attr.model]"
162
- :disabled="disabled"
163
- :filter-option="filterOption"
164
- :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
165
- :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
166
- mode="multiple"
167
- show-search
168
- allowClear
169
- @search="fetchFunction"
170
- >
171
- <a-spin v-if="searching" slot="notFoundContent" size="small" />
172
- <a-select-option
173
- v-for="(item,index) in option"
174
- :key="index"
175
- :value="item.value">{{ item.label }}
176
- </a-select-option>
177
- </a-select>
178
- </a-form-model-item>
179
- </x-form-col>
180
- <!-- TODO 单选框 -->
181
- <!-- 日期范围选择器 -->
182
- <x-form-col
183
- v-else-if="attr.type === 'rangePicker'"
184
- :xl="xl"
185
- :xxl="xxl">
186
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
187
- <a-range-picker v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM-DD HH:mm:ss"/>
188
- </a-form-model-item>
189
- </x-form-col>
190
- <!-- 月份选择器 -->
191
- <x-form-col
192
- v-else-if="attr.type === 'monthPicker'"
193
- :xl="xl"
194
- :xxl="xxl">
195
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
196
- <a-month-picker v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM"/>
197
- </a-form-model-item>
198
- </x-form-col>
199
- <!-- 日期选择器 -->
200
- <x-form-col
201
- v-else-if="attr.type === 'datePicker'"
202
- :xl="xl"
203
- :xxl="xxl">
204
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
205
- <a-range-picker
206
- v-if="mode === '查询'"
207
- v-model="form[attr.model]"
208
- :disabled="disabled"
209
- :show-time="{ defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')] }"
210
- format="YYYY-MM-DD"
211
- valueFormat="YYYY-MM-DD HH:mm:ss" />
212
- <a-date-picker v-else v-model="form[attr.model]" :disabled="disabled" :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }" valueFormat="YYYY-MM-DD HH:mm:ss"/>
213
- </a-form-model-item>
214
- </x-form-col>
215
- <!-- 级联选择器 -->
216
- <x-form-col
217
- v-else-if="attr.type === 'cascader'"
218
- :xl="xl"
219
- :xxl="xxl">
220
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
221
- <a-cascader
222
- v-model="form[attr.model]"
223
- :disabled="disabled"
224
- :options="option"
225
- :placeholder="attr.placeholder ? attr.placeholder : '请选择'+attr.name.replace(/\s*/g, '')"
226
- :rows="4"
227
- change-on-select/>
228
- </a-form-model-item>
229
- </x-form-col>
230
- <!-- 文本域 -->
231
- <x-form-col
232
- v-else-if="attr.type === 'textarea'"
233
- :lg="24"
234
- :md="24"
235
- :sm="24"
236
- :xl="24"
237
- :xs="24"
238
- :xxl="24">
239
- <a-form-model-item
240
- :ref="attr.model"
241
- :label="attr.name"
242
- :prop="attr.model">
243
- <a-textarea v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')" :rows="4"/>
244
- </a-form-model-item>
245
- </x-form-col>
246
- <!-- 文件上传 -->
247
- <x-form-col
248
- v-else-if="attr.type === 'file' || attr.type === 'image'"
249
- :lg="24"
250
- :md="24"
251
- :sm="24"
252
- :xl="24"
253
- :xs="24"
254
- :xxl="24">
255
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
256
- <upload :files="files" :images="images" :model="attr" :service-name="serviceName" @setFiles="setFiles"></upload>
257
- </a-form-model-item>
258
- </x-form-col>
259
- <!-- 省市区选择框 -->
260
- <x-form-col
261
- v-else-if="attr.type === 'citySelect'"
262
- :xl="xl"
263
- :xxl="xxl">
264
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
265
- <citySelect v-model="form[attr.model]" ></citySelect>
266
- </a-form-model-item>
267
- </x-form-col>
268
- <!-- 地点搜索框 -->
269
- <x-form-col
270
- v-else-if="attr.type === 'addressSearch'"
271
- :xl="xl"
272
- :xxl="xxl">
273
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
274
- <address-search-combobox
275
- v-model="searchResult"
276
- :resultKeys="{ address: attr.model, coords: `${attr.model}_lng_lat` }"
277
- searchResultType="Object"
278
- @onSelect="form=Object.assign(form,JSON.parse(searchResult))"
279
- ></address-search-combobox>
280
- </a-form-model-item>
281
- </x-form-col>
282
- <!-- 人员选择框 -->
283
- <x-form-col
284
- v-else-if="attr.type === 'personSetting'"
285
- :xl="xl"
286
- :xxl="xxl">
287
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
288
- <PersonSetting v-model="form[attr.model]" ></PersonSetting>
289
- </a-form-model-item>
290
- </x-form-col>
291
- </template>
292
- <script>
293
-
294
- import { post } from '@vue2-client/services/api'
295
- import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
296
- import XFormCol from '@vue2-client/base-client/components/common/XFormCol'
297
- import XBadge from '@vue2-client/base-client/components/common/XBadge'
298
- import CitySelect from '@vue2-client/base-client/components/common/CitySelect'
299
- import PersonSetting from '@vue2-client/base-client/components/common/PersonSetting'
300
- import AddressSearchCombobox from '@vue2-client/base-client/components/common/AddressSearchCombobox'
301
- import Upload from '@vue2-client/base-client/components/common/Upload'
302
- import moment from 'moment'
303
-
304
- export default {
305
- name: 'XFormItem',
306
- components: {
307
- XFormCol,
308
- XBadge,
309
- CitySelect,
310
- PersonSetting,
311
- AddressSearchCombobox,
312
- Upload
313
- },
314
- data () {
315
- // 检索去抖
316
- this.fetchFunction = debounce(this.fetchFunction, 800)
317
- return {
318
- option: [],
319
- // 最后检索版本
320
- lastFetchId: 0,
321
- // 检索中
322
- searching: false,
323
- searchResult: '',
324
- // moment
325
- moment
326
- }
327
- },
328
- props: {
329
- attr: {
330
- type: Object,
331
- default: () => {
332
- return {}
333
- }
334
- },
335
- form: {
336
- type: Object,
337
- required: true
338
- },
339
- disabled: {
340
- type: Boolean,
341
- default: () => {
342
- return false
343
- }
344
- },
345
- mode: {
346
- type: String,
347
- default: () => {
348
- return '查询'
349
- }
350
- },
351
- xl: {
352
- type: Number,
353
- default: undefined
354
- },
355
- xxl: {
356
- type: Number,
357
- default: undefined
358
- },
359
- selectsArray: {
360
- type: Object,
361
- default: () => {
362
- return {}
363
- }
364
- },
365
- files: {
366
- type: Array,
367
- default: () => {
368
- return []
369
- }
370
- },
371
- images: {
372
- type: Array,
373
- default: () => {
374
- return []
375
- }
376
- },
377
- serviceName: {
378
- type: String,
379
- default: 'af-system'
380
- }
381
- },
382
- created () {
383
- if (this.attr.keyName && this.attr.keyName.indexOf('logic@') !== -1) {
384
- this.getData({}, res => {
385
- this.option = res
386
- })
387
- }
388
- },
389
- methods: {
390
- // 向父组件获取级联框的数据
391
- selectsItemCheck (groupName, index, value) {
392
- this.$emit('selectsItemCheck', val => { this.selectsArray = val }, groupName, index, value)
393
- },
394
- // 文件框时设置上传组件的值
395
- setFiles (fileIds) {
396
- if (!this.form[this.attr.model]) {
397
- this.form[this.attr.model] = []
398
- }
399
- this.form[this.attr.model] = [...fileIds]
400
- },
401
- // 懒加载检索方法
402
- fetchFunction (value) {
403
- this.lastFetchId += 1
404
- const fetchId = this.lastFetchId
405
- this.option = []
406
- this.searching = true
407
- this.getData({
408
- word: value
409
- }, res => {
410
- if (fetchId !== this.lastFetchId) {
411
- return
412
- }
413
- this.option = res
414
- this.searching = false
415
- })
416
- },
417
- // 获取数据
418
- getData (value, callback) {
419
- if (value !== '') {
420
- const logicName = this.attr.keyName
421
- const logic = logicName.substring(6)
422
- post('/api/' + this.serviceName + '/logic/' + logic, value).then(res => {
423
- callback(res)
424
- })
425
- }
426
- },
427
- filterOption (input, option) {
428
- if (option.componentOptions.children[0].text) {
429
- return (
430
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
431
- )
432
- } else {
433
- return (
434
- option.componentOptions.children[0].child.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
435
- )
436
- }
437
- }
438
- }
439
- }
440
- </script>
1
+ <template>
2
+ <!-- 输入框 -->
3
+ <x-form-col
4
+ v-if="attr.type === 'input'"
5
+ :xl="xl"
6
+ :xxl="xxl">
7
+ <a-form-model-item
8
+ :ref="attr.model"
9
+ :label="attr.name"
10
+ :prop="attr.model">
11
+ <a-input v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
12
+ </a-form-model-item>
13
+ </x-form-col>
14
+ <!-- 下拉框 -->
15
+ <x-form-col
16
+ v-else-if="attr.type === 'select'"
17
+ :xl="xl"
18
+ :xxl="xxl">
19
+ <a-form-model-item
20
+ :ref="attr.model"
21
+ :label="attr.name"
22
+ :prop="attr.model">
23
+ <a-select
24
+ v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
25
+ v-model="form[attr.model]"
26
+ :disabled="disabled"
27
+ :filter-option="filterOption"
28
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
29
+ :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
30
+ show-search
31
+ >
32
+ <a-select-option
33
+ v-if="mode === '查询'"
34
+ key="999999"
35
+ value="全部">全部
36
+ </a-select-option>
37
+ <template v-if="attr.keys">
38
+ <a-select-option
39
+ v-for="(item,index) in attr.keys"
40
+ :key="index"
41
+ :value="item.value">
42
+ {{ item.label }}
43
+ </a-select-option>
44
+ </template>
45
+ <template v-else>
46
+ <template v-if="attr.keyName.indexOf('logic@') !== -1">
47
+ <a-select-option
48
+ v-for="(item,index) in option"
49
+ :key="index"
50
+ :value="item.value">{{ item.label }}
51
+ </a-select-option>
52
+ </template>
53
+ <template v-else>
54
+ <a-select-option
55
+ v-for="item in $appdata.getDictionaryList(attr.keyName)"
56
+ :key="item.value"
57
+ :value="item.value">
58
+ <!-- 徽标(badge) -->
59
+ <x-badge :badge-key="attr.keyName" :replaceText="item.text" :value="item.value"/>
60
+ </a-select-option>
61
+ </template>
62
+ </template>
63
+ </a-select>
64
+ <a-select
65
+ v-else
66
+ v-model="form[attr.model]"
67
+ :disabled="disabled"
68
+ :filter-option="filterOption"
69
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
70
+ :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
71
+ show-search
72
+ @search="fetchFunction"
73
+ >
74
+ <a-spin v-if="searching" slot="notFoundContent" size="small" />
75
+ <a-select-option
76
+ v-if="mode === '查询'"
77
+ key="999999"
78
+ value="全部">全部
79
+ </a-select-option>
80
+ <a-select-option
81
+ v-for="(item,index) in option"
82
+ :key="index"
83
+ :value="item.value">{{ item.label }}
84
+ </a-select-option>
85
+ </a-select>
86
+ </a-form-model-item>
87
+ </x-form-col>
88
+ <!-- 级联下拉框 -->
89
+ <x-form-col
90
+ v-else-if="attr.type === 'selects'"
91
+ :xl="xl"
92
+ :xxl="xxl">
93
+ <a-form-model-item
94
+ :ref="attr.model"
95
+ :label="attr.name"
96
+ :prop="attr.model">
97
+ <a-select
98
+ v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
99
+ v-model="form[attr.model]"
100
+ :disabled=" attr.groupIndex>1 && (disabled || !selectsArray[attr.group] || !selectsArray[attr.group][attr.groupIndex] || (selectsArray[attr.group][attr.groupIndex] && selectsArray[attr.group][attr.groupIndex].length === 0))"
101
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
102
+ :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
103
+ show-search
104
+ @change="selectsItemCheck(attr.group, attr.groupIndex, form[attr.model])"
105
+ >
106
+ <template v-for="optionItem in selectsArray[attr.group][attr.groupIndex]" v-if="selectsArray[attr.group].length > 0 || selectsArray[attr.group][attr.groupIndex]">
107
+ <a-select-option :key="optionItem.label" :value="optionItem.value">
108
+ {{ optionItem.label }}
109
+ </a-select-option>
110
+ </template>
111
+ </a-select>
112
+ </a-form-model-item>
113
+ </x-form-col>
114
+ <!-- 多选框 -->
115
+ <x-form-col
116
+ v-else-if="attr.type === 'checkbox'"
117
+ :xl="xl"
118
+ :xxl="xxl">
119
+ <a-form-model-item
120
+ :ref="attr.model"
121
+ :label="attr.name"
122
+ :prop="attr.model">
123
+ <a-select
124
+ v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
125
+ v-model="form[attr.model]"
126
+ :disabled="disabled"
127
+ :filter-option="filterOption"
128
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
129
+ :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
130
+ mode="multiple"
131
+ show-search
132
+ allowClear
133
+ >
134
+ <template v-if="attr.keys">
135
+ <a-select-option
136
+ v-for="(item,index) in attr.keys"
137
+ :key="index"
138
+ :value="item.value">
139
+ {{ item.label }}
140
+ </a-select-option>
141
+ </template>
142
+ <template v-else>
143
+ <template v-if="attr.keyName.indexOf('logic@') !== -1">
144
+ <a-select-option
145
+ v-for="(item,index) in option"
146
+ :key="index"
147
+ :value="item.value">{{ item.label }}
148
+ </a-select-option>
149
+ </template>
150
+ <template v-else>
151
+ <a-select-option
152
+ v-for="item in $appdata.getDictionaryList(attr.keyName)"
153
+ :key="item.value"
154
+ :value="item.value">{{ item.text }}
155
+ </a-select-option>
156
+ </template>
157
+ </template>
158
+ </a-select>
159
+ <a-select
160
+ v-else
161
+ v-model="form[attr.model]"
162
+ :disabled="disabled"
163
+ :filter-option="filterOption"
164
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
165
+ :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
166
+ mode="multiple"
167
+ show-search
168
+ allowClear
169
+ @search="fetchFunction"
170
+ >
171
+ <a-spin v-if="searching" slot="notFoundContent" size="small" />
172
+ <a-select-option
173
+ v-for="(item,index) in option"
174
+ :key="index"
175
+ :value="item.value">{{ item.label }}
176
+ </a-select-option>
177
+ </a-select>
178
+ </a-form-model-item>
179
+ </x-form-col>
180
+ <!-- TODO 单选框 -->
181
+ <!-- 日期范围选择器 -->
182
+ <x-form-col
183
+ v-else-if="attr.type === 'rangePicker'"
184
+ :xl="xl"
185
+ :xxl="xxl">
186
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
187
+ <a-range-picker v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM-DD HH:mm:ss"/>
188
+ </a-form-model-item>
189
+ </x-form-col>
190
+ <!-- 月份选择器 -->
191
+ <x-form-col
192
+ v-else-if="attr.type === 'monthPicker'"
193
+ :xl="xl"
194
+ :xxl="xxl">
195
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
196
+ <a-month-picker v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM"/>
197
+ </a-form-model-item>
198
+ </x-form-col>
199
+ <!-- 年份选择器 -->
200
+ <x-form-col
201
+ v-else-if="attr.type === 'yearPicker'"
202
+ :xl="xl"
203
+ :xxl="xxl">
204
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
205
+ <a-date-picker
206
+ v-model="form[attr.model]"
207
+ :disabled="disabled"
208
+ format="YYYY"
209
+ mode="year"
210
+ v-decorator="['year']"
211
+ placeholder="请输入年份"
212
+ :open="yearShowOne"
213
+ @openChange="openChangeOne"
214
+ @panelChange="panelChangeOne"/>
215
+ </a-form-model-item>
216
+ </x-form-col>
217
+ <!-- 日期选择器 -->
218
+ <x-form-col
219
+ v-else-if="attr.type === 'datePicker'"
220
+ :xl="xl"
221
+ :xxl="xxl">
222
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
223
+ <a-range-picker
224
+ v-if="mode === '查询'"
225
+ v-model="form[attr.model]"
226
+ :disabled="disabled"
227
+ :show-time="{ defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')] }"
228
+ format="YYYY-MM-DD"
229
+ valueFormat="YYYY-MM-DD HH:mm:ss" />
230
+ <a-date-picker v-else v-model="form[attr.model]" :disabled="disabled" :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }" valueFormat="YYYY-MM-DD HH:mm:ss"/>
231
+ </a-form-model-item>
232
+ </x-form-col>
233
+ <!-- 级联选择器 -->
234
+ <x-form-col
235
+ v-else-if="attr.type === 'cascader'"
236
+ :xl="xl"
237
+ :xxl="xxl">
238
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
239
+ <a-cascader
240
+ v-model="form[attr.model]"
241
+ :disabled="disabled"
242
+ :options="option"
243
+ :placeholder="attr.placeholder ? attr.placeholder : '请选择'+attr.name.replace(/\s*/g, '')"
244
+ :rows="4"
245
+ change-on-select/>
246
+ </a-form-model-item>
247
+ </x-form-col>
248
+ <!-- 文本域 -->
249
+ <x-form-col
250
+ v-else-if="attr.type === 'textarea'"
251
+ :lg="24"
252
+ :md="24"
253
+ :sm="24"
254
+ :xl="24"
255
+ :xs="24"
256
+ :xxl="24">
257
+ <a-form-model-item
258
+ :ref="attr.model"
259
+ :label="attr.name"
260
+ :prop="attr.model">
261
+ <a-textarea v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')" :rows="4"/>
262
+ </a-form-model-item>
263
+ </x-form-col>
264
+ <!-- 文件上传 -->
265
+ <x-form-col
266
+ v-else-if="attr.type === 'file' || attr.type === 'image'"
267
+ :lg="24"
268
+ :md="24"
269
+ :sm="24"
270
+ :xl="24"
271
+ :xs="24"
272
+ :xxl="24">
273
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
274
+ <upload :files="files" :images="images" :model="attr" :service-name="serviceName" @setFiles="setFiles"></upload>
275
+ </a-form-model-item>
276
+ </x-form-col>
277
+ <!-- 省市区选择框 -->
278
+ <x-form-col
279
+ v-else-if="attr.type === 'citySelect'"
280
+ :xl="xl"
281
+ :xxl="xxl">
282
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
283
+ <citySelect v-model="form[attr.model]" ></citySelect>
284
+ </a-form-model-item>
285
+ </x-form-col>
286
+ <!-- 地点搜索框 -->
287
+ <x-form-col
288
+ v-else-if="attr.type === 'addressSearch'"
289
+ :xl="xl"
290
+ :xxl="xxl">
291
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
292
+ <address-search-combobox
293
+ v-model="searchResult"
294
+ :resultKeys="{ address: attr.model, coords: `${attr.model}_lng_lat` }"
295
+ searchResultType="Object"
296
+ @onSelect="form=Object.assign(form,JSON.parse(searchResult))"
297
+ ></address-search-combobox>
298
+ </a-form-model-item>
299
+ </x-form-col>
300
+ <!-- 人员选择框 -->
301
+ <x-form-col
302
+ v-else-if="attr.type === 'personSetting'"
303
+ :xl="xl"
304
+ :xxl="xxl">
305
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
306
+ <PersonSetting v-model="form[attr.model]" ></PersonSetting>
307
+ </a-form-model-item>
308
+ </x-form-col>
309
+ </template>
310
+ <script>
311
+
312
+ import { post } from '@vue2-client/services/api'
313
+ import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
314
+ import XFormCol from '@vue2-client/base-client/components/common/XFormCol'
315
+ import XBadge from '@vue2-client/base-client/components/common/XBadge'
316
+ import CitySelect from '@vue2-client/base-client/components/common/CitySelect'
317
+ import PersonSetting from '@vue2-client/base-client/components/common/PersonSetting'
318
+ import AddressSearchCombobox from '@vue2-client/base-client/components/common/AddressSearchCombobox'
319
+ import Upload from '@vue2-client/base-client/components/common/Upload'
320
+ import moment from 'moment'
321
+
322
+ export default {
323
+ name: 'XFormItem',
324
+ components: {
325
+ XFormCol,
326
+ XBadge,
327
+ CitySelect,
328
+ PersonSetting,
329
+ AddressSearchCombobox,
330
+ Upload
331
+ },
332
+ data () {
333
+ // 检索去抖
334
+ this.fetchFunction = debounce(this.fetchFunction, 800)
335
+ return {
336
+ option: [],
337
+ // 最后检索版本
338
+ lastFetchId: 0,
339
+ // 检索中
340
+ searching: false,
341
+ searchResult: '',
342
+ yearShowOne: false,
343
+ // moment
344
+ moment
345
+ }
346
+ },
347
+ props: {
348
+ attr: {
349
+ type: Object,
350
+ default: () => {
351
+ return {}
352
+ }
353
+ },
354
+ form: {
355
+ type: Object,
356
+ required: true
357
+ },
358
+ disabled: {
359
+ type: Boolean,
360
+ default: () => {
361
+ return false
362
+ }
363
+ },
364
+ mode: {
365
+ type: String,
366
+ default: () => {
367
+ return '查询'
368
+ }
369
+ },
370
+ xl: {
371
+ type: Number,
372
+ default: undefined
373
+ },
374
+ xxl: {
375
+ type: Number,
376
+ default: undefined
377
+ },
378
+ selectsArray: {
379
+ type: Object,
380
+ default: () => {
381
+ return {}
382
+ }
383
+ },
384
+ files: {
385
+ type: Array,
386
+ default: () => {
387
+ return []
388
+ }
389
+ },
390
+ images: {
391
+ type: Array,
392
+ default: () => {
393
+ return []
394
+ }
395
+ },
396
+ serviceName: {
397
+ type: String,
398
+ default: 'af-system'
399
+ }
400
+ },
401
+ created () {
402
+ if (this.attr.keyName && this.attr.keyName.indexOf('logic@') !== -1) {
403
+ this.getData({}, res => {
404
+ this.option = res
405
+ })
406
+ }
407
+ },
408
+ methods: {
409
+ openChangeOne (status) {
410
+ if (status) {
411
+ this.yearShowOne = true
412
+ }
413
+ },
414
+ // 得到年份选择器的值
415
+ panelChangeOne (value) {
416
+ this.yearShowOne = false
417
+ this.form[this.attr.model] = value
418
+ },
419
+ // 向父组件获取级联框的数据
420
+ selectsItemCheck (groupName, index, value) {
421
+ this.$emit('selectsItemCheck', val => { this.selectsArray = val }, groupName, index, value)
422
+ },
423
+ // 文件框时设置上传组件的值
424
+ setFiles (fileIds) {
425
+ if (!this.form[this.attr.model]) {
426
+ this.form[this.attr.model] = []
427
+ }
428
+ this.form[this.attr.model] = [...fileIds]
429
+ },
430
+ // 懒加载检索方法
431
+ fetchFunction (value) {
432
+ this.lastFetchId += 1
433
+ const fetchId = this.lastFetchId
434
+ this.option = []
435
+ this.searching = true
436
+ this.getData({
437
+ word: value
438
+ }, res => {
439
+ if (fetchId !== this.lastFetchId) {
440
+ return
441
+ }
442
+ this.option = res
443
+ this.searching = false
444
+ })
445
+ },
446
+ // 获取数据
447
+ getData (value, callback) {
448
+ if (value !== '') {
449
+ const logicName = this.attr.keyName
450
+ const logic = logicName.substring(6)
451
+ post('/api/' + this.serviceName + '/logic/' + logic, value).then(res => {
452
+ callback(res)
453
+ })
454
+ }
455
+ },
456
+ filterOption (input, option) {
457
+ if (option.componentOptions.children[0].text) {
458
+ return (
459
+ option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
460
+ )
461
+ } else {
462
+ return (
463
+ option.componentOptions.children[0].child.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
464
+ )
465
+ }
466
+ }
467
+ }
468
+ }
469
+ </script>