vue2-client 1.18.51 → 1.18.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -11
- package/package.json +1 -1
- package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +193 -152
- package/src/base-client/components/common/XForm/XForm.vue +0 -13
- package/src/base-client/components/common/XFormTable/XFormTable.vue +1 -4
- package/src/base-client/components/common/XTable/XTable.vue +12 -0
package/.eslintrc.js
CHANGED
|
@@ -12,17 +12,7 @@ module.exports = {
|
|
|
12
12
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
13
13
|
'generator-star-spacing': 'off',
|
|
14
14
|
'no-mixed-operators': 0,
|
|
15
|
-
'vue/max-attributes-per-line':
|
|
16
|
-
2,
|
|
17
|
-
{
|
|
18
|
-
singleline: {
|
|
19
|
-
max: 5
|
|
20
|
-
},
|
|
21
|
-
multiline: {
|
|
22
|
-
max: 1
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
],
|
|
15
|
+
'vue/max-attributes-per-line': 'off',
|
|
26
16
|
'vue/attribute-hyphenation': 0,
|
|
27
17
|
'vue/html-self-closing': 0,
|
|
28
18
|
'vue/component-name-in-template-casing': 0,
|
package/package.json
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="XAddNativeForm">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
:zIndex="1001"
|
|
7
|
-
:model="form"
|
|
8
|
-
v-bind="formItemLayoutGen"
|
|
9
|
-
:layout="layout">
|
|
3
|
+
<!-- 骨架屏 -->
|
|
4
|
+
<a-skeleton v-if="!loaded" active :paragraph="{ rows: 3 }" />
|
|
5
|
+
<a-form-model v-else ref="selectForm" :zIndex="1001" :model="form" v-bind="formItemLayoutGen" :layout="layout">
|
|
10
6
|
<template v-for="(item, key) in childTableData">
|
|
11
|
-
<a-row
|
|
12
|
-
v-if="childTablePriority"
|
|
13
|
-
:gutter="16"
|
|
14
|
-
:key="'childTableRow' + key">
|
|
7
|
+
<a-row v-if="childTablePriority" :gutter="16" :key="'childTableRow' + key">
|
|
15
8
|
<a-card :title="item.name" :bordered="false" size="small">
|
|
16
9
|
<x-form-table
|
|
17
10
|
:key="'childTable_' + item.model"
|
|
@@ -22,21 +15,14 @@
|
|
|
22
15
|
:service-name="serviceName"
|
|
23
16
|
@innerXFormTableEmit="innerXFormTableEmit"
|
|
24
17
|
@afterTableInit="childTableMounted(item)"
|
|
25
|
-
:ref="'childXFormTable_' + item.model"
|
|
26
|
-
|
|
18
|
+
:ref="'childXFormTable_' + item.model"
|
|
19
|
+
></x-form-table>
|
|
27
20
|
</a-card>
|
|
28
21
|
</a-row>
|
|
29
22
|
</template>
|
|
30
23
|
<template v-if="isSimpleInlineMode">
|
|
31
|
-
<a-row
|
|
32
|
-
v-for="(
|
|
33
|
-
:key="'simple-row-' + rowIndex"
|
|
34
|
-
:gutter="0"
|
|
35
|
-
type="flex">
|
|
36
|
-
<a-col
|
|
37
|
-
v-for="(item, itemIndex) in row.items"
|
|
38
|
-
:key="'simple-item-' + itemIndex"
|
|
39
|
-
:span="item.span">
|
|
24
|
+
<a-row v-for="(row, rowIndex) in simpleInlineRows" :key="'simple-row-' + rowIndex" :gutter="0" type="flex">
|
|
25
|
+
<a-col v-for="(item, itemIndex) in row.items" :key="'simple-item-' + itemIndex" :span="item.span">
|
|
40
26
|
<x-form-item
|
|
41
27
|
class="simple-inline-item"
|
|
42
28
|
:attr="item.formItem"
|
|
@@ -64,25 +50,26 @@
|
|
|
64
50
|
<a-col :span="3" v-if="!inXFormGroup && !(groups[0].groupName === DEFAULT_GROUP_NAME)">
|
|
65
51
|
<a-tabs tab-position="left" v-model="activeTab" @change="scrollToGroup">
|
|
66
52
|
<a-tab-pane
|
|
67
|
-
v-for="(groupsItem,groupsIndex) in groups"
|
|
53
|
+
v-for="(groupsItem, groupsIndex) in groups"
|
|
68
54
|
:tab="groupsItem.groupName"
|
|
69
|
-
:key="groupsIndex"
|
|
70
|
-
|
|
55
|
+
:key="groupsIndex"
|
|
56
|
+
></a-tab-pane>
|
|
71
57
|
</a-tabs>
|
|
72
58
|
</a-col>
|
|
73
|
-
<a-col
|
|
74
|
-
:
|
|
75
|
-
<a-row
|
|
76
|
-
:gutter="16"
|
|
77
|
-
type="flex"
|
|
78
|
-
:key="groupsIndex"
|
|
79
|
-
v-for="(groupsItem,groupsIndex) in groups"
|
|
80
|
-
>
|
|
59
|
+
<a-col :span="!inXFormGroup && !(groups[0].groupName === DEFAULT_GROUP_NAME) ? 21 : 24">
|
|
60
|
+
<a-row :gutter="16" type="flex" :key="groupsIndex" v-for="(groupsItem, groupsIndex) in groups">
|
|
81
61
|
<a-col
|
|
82
62
|
:span="24"
|
|
83
|
-
:style="{
|
|
84
|
-
|
|
85
|
-
|
|
63
|
+
:style="{
|
|
64
|
+
marginTop: groupsIndex === 0 ? '' : '8px',
|
|
65
|
+
fontSize: inXFormGroup ? '15px' : '14px',
|
|
66
|
+
marginLeft: '-5px'
|
|
67
|
+
}"
|
|
68
|
+
v-if="groupsItem.groupName !== DEFAULT_GROUP_NAME"
|
|
69
|
+
>
|
|
70
|
+
<span class="xFormGroupTitle" :ref="`group-title-${groupsIndex}`">
|
|
71
|
+
{{ groupsItem.groupName }}
|
|
72
|
+
</span>
|
|
86
73
|
</a-col>
|
|
87
74
|
<x-form-item
|
|
88
75
|
v-for="(item, index) in groupsItem.realJsonData"
|
|
@@ -92,7 +79,7 @@
|
|
|
92
79
|
:read-only="readonly(item)"
|
|
93
80
|
:files="files"
|
|
94
81
|
v-bind="formItemLayoutGen"
|
|
95
|
-
:style="layout === 'inline' ? { marginTop:'5px' } : undefined"
|
|
82
|
+
:style="layout === 'inline' ? { marginTop: '5px' } : undefined"
|
|
96
83
|
:form="form"
|
|
97
84
|
:images="images"
|
|
98
85
|
:enablePopupToBody="enablePopupToBody"
|
|
@@ -119,7 +106,7 @@
|
|
|
119
106
|
:readonly="readonly(item)"
|
|
120
107
|
:files="files"
|
|
121
108
|
v-bind="formItemLayoutGen"
|
|
122
|
-
:style="layout ==='inline'?{marginTop:'5px'}:undefined"
|
|
109
|
+
:style="layout === 'inline' ? { marginTop: '5px' } : undefined"
|
|
123
110
|
:form="form[groupItem.model]"
|
|
124
111
|
:images="images"
|
|
125
112
|
:service-name="serviceName"
|
|
@@ -137,7 +124,8 @@
|
|
|
137
124
|
:form="form"
|
|
138
125
|
:model="groupItem.model"
|
|
139
126
|
:rules="rules"
|
|
140
|
-
:modifyModelData="modifyModelData"
|
|
127
|
+
:modifyModelData="modifyModelData"
|
|
128
|
+
></slot>
|
|
141
129
|
</template>
|
|
142
130
|
</a-row>
|
|
143
131
|
<a-row :gutter="16" v-for="(item, key) in simpleFormJsonData" :key="'row' + key" v-if="!isSimpleInlineMode">
|
|
@@ -151,7 +139,7 @@
|
|
|
151
139
|
:files="files"
|
|
152
140
|
:enablePopupToBody="enablePopupToBody"
|
|
153
141
|
v-bind="formItemLayoutGen"
|
|
154
|
-
:style="layout ==='inline'?{marginTop:'5px'}:undefined"
|
|
142
|
+
:style="layout === 'inline' ? { marginTop: '5px' } : undefined"
|
|
155
143
|
:form="form[groupItem.model]"
|
|
156
144
|
:images="images"
|
|
157
145
|
:service-name="serviceName"
|
|
@@ -165,10 +153,7 @@
|
|
|
165
153
|
</a-card>
|
|
166
154
|
</a-row>
|
|
167
155
|
<template v-for="(item, key) in childTableData">
|
|
168
|
-
<a-row
|
|
169
|
-
v-if="!childTablePriority"
|
|
170
|
-
:gutter="16"
|
|
171
|
-
:key="'childTableRow' + key">
|
|
156
|
+
<a-row v-if="!childTablePriority" :gutter="16" :key="'childTableRow' + key">
|
|
172
157
|
<a-card :title="item.name" :bordered="false" size="small">
|
|
173
158
|
<x-form-table
|
|
174
159
|
:key="'childTable_' + item.model"
|
|
@@ -179,14 +164,16 @@
|
|
|
179
164
|
:fixed-query-form="childTableFixedQueryForm(item)"
|
|
180
165
|
:service-name="serviceName"
|
|
181
166
|
@afterTableInit="childTableMounted(item)"
|
|
182
|
-
:ref="'childXFormTable_' + item.model"
|
|
183
|
-
|
|
167
|
+
:ref="'childXFormTable_' + item.model"
|
|
168
|
+
></x-form-table>
|
|
184
169
|
</a-card>
|
|
185
170
|
</a-row>
|
|
186
171
|
</template>
|
|
187
|
-
<a-row type="flex" :justify="btnPlace" :style="{paddingLeft: '16px',paddingRight: '16px'}">
|
|
172
|
+
<a-row type="flex" :justify="btnPlace" :style="{ paddingLeft: '16px', paddingRight: '16px' }">
|
|
188
173
|
<slot name="footer" :loading="loading">
|
|
189
|
-
<a-button v-if="showSubmitBtn" :loading="loading" type="primary" @click="onSubmit()">
|
|
174
|
+
<a-button v-if="showSubmitBtn" :loading="loading" type="primary" @click="onSubmit()">
|
|
175
|
+
{{ btnName }}
|
|
176
|
+
</a-button>
|
|
190
177
|
</slot>
|
|
191
178
|
</a-row>
|
|
192
179
|
</a-form-model>
|
|
@@ -233,7 +220,7 @@ export default {
|
|
|
233
220
|
default: false
|
|
234
221
|
}
|
|
235
222
|
},
|
|
236
|
-
data
|
|
223
|
+
data() {
|
|
237
224
|
return {
|
|
238
225
|
DEFAULT_GROUP_NAME,
|
|
239
226
|
// 预览模式
|
|
@@ -290,18 +277,26 @@ export default {
|
|
|
290
277
|
computed: {
|
|
291
278
|
// 过滤出用于新增/修改场景的表单项
|
|
292
279
|
realJsonData: function () {
|
|
293
|
-
return this.formItems.filter(
|
|
294
|
-
return
|
|
280
|
+
return this.formItems.filter(item => {
|
|
281
|
+
return (
|
|
282
|
+
item.addOrEdit &&
|
|
283
|
+
item.addOrEdit !== 'no' &&
|
|
284
|
+
item.addOrEdit !== 'silenceAdd' &&
|
|
285
|
+
item.addOrEdit !== 'version' &&
|
|
286
|
+
!this.itemDisabled(item)
|
|
287
|
+
)
|
|
295
288
|
})
|
|
296
289
|
},
|
|
297
290
|
// 表单项组 / 不是 数据组
|
|
298
291
|
groups: function () {
|
|
299
292
|
if (!this.realJsonData || this.realJsonData.length === 0) {
|
|
300
|
-
return [
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
293
|
+
return [
|
|
294
|
+
{
|
|
295
|
+
groupName: DEFAULT_GROUP_NAME,
|
|
296
|
+
realJsonData: this.realJsonData,
|
|
297
|
+
xAddFormLayout: 'horizontal'
|
|
298
|
+
}
|
|
299
|
+
]
|
|
305
300
|
}
|
|
306
301
|
const uniqueGroups = new Set(this.realJsonData.map(item => item.group).filter(Boolean))
|
|
307
302
|
const allGroup = Array.from(uniqueGroups).map(group => {
|
|
@@ -315,46 +310,57 @@ export default {
|
|
|
315
310
|
if (allGroup.reduce((total, item) => total + item.realJsonData.length, 0) === this.realJsonData.length) {
|
|
316
311
|
return allGroup
|
|
317
312
|
} else {
|
|
318
|
-
return [
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
313
|
+
return [
|
|
314
|
+
{
|
|
315
|
+
groupName: DEFAULT_GROUP_NAME,
|
|
316
|
+
realJsonData: this.realJsonData,
|
|
317
|
+
xAddFormLayout: 'horizontal'
|
|
318
|
+
}
|
|
319
|
+
]
|
|
323
320
|
}
|
|
324
321
|
},
|
|
325
322
|
// 拥有自定义校验函数得表单项
|
|
326
323
|
customValidateItems: function () {
|
|
327
|
-
return this.formItems.filter(
|
|
324
|
+
return this.formItems.filter(item => {
|
|
328
325
|
return item?.rule?.type === 'customJs'
|
|
329
326
|
})
|
|
330
327
|
},
|
|
331
328
|
// 过滤出用于新增/修改场景的表单项
|
|
332
329
|
groupJsonData: function () {
|
|
333
|
-
return this.formItems
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
330
|
+
return this.formItems
|
|
331
|
+
.filter(item => {
|
|
332
|
+
return item.type === 'group'
|
|
333
|
+
})
|
|
334
|
+
.map(item => {
|
|
335
|
+
item.groupItems = item.groupItems
|
|
336
|
+
.filter(item => {
|
|
337
|
+
return (
|
|
338
|
+
item.addOrEdit &&
|
|
339
|
+
item.addOrEdit !== 'no' &&
|
|
340
|
+
item.addOrEdit !== 'silenceAdd' &&
|
|
341
|
+
item.addOrEdit !== 'version' &&
|
|
342
|
+
!this.itemDisabled(item)
|
|
343
|
+
)
|
|
344
|
+
})
|
|
345
|
+
.map(groupItem => {
|
|
346
|
+
// 只保留第一个下划线后面的内容
|
|
347
|
+
// 多层校验规则需要将prop设置为 key1.key2.....
|
|
348
|
+
groupItem.prop = `${item.model}.${groupItem.model.substring(groupItem.model.indexOf('_') + 1)}`
|
|
349
|
+
groupItem.model = groupItem.model.substring(groupItem.model.indexOf('_') + 1)
|
|
350
|
+
return groupItem
|
|
351
|
+
})
|
|
345
352
|
return item
|
|
346
|
-
}
|
|
347
|
-
)
|
|
353
|
+
})
|
|
348
354
|
},
|
|
349
355
|
// 过滤出用于子表数据新增/修改场景的表单项
|
|
350
356
|
childTableData: function () {
|
|
351
|
-
return this.formItems.filter(
|
|
357
|
+
return this.formItems.filter(item => {
|
|
352
358
|
return item.type === 'childTable'
|
|
353
359
|
})
|
|
354
360
|
},
|
|
355
361
|
// 过滤出用于form子表数据新增/修改场景的表单项
|
|
356
362
|
childFormData: function () {
|
|
357
|
-
return this.formItems.filter(
|
|
363
|
+
return this.formItems.filter(item => {
|
|
358
364
|
return item.type === 'rowEdit'
|
|
359
365
|
})
|
|
360
366
|
},
|
|
@@ -370,7 +376,7 @@ export default {
|
|
|
370
376
|
return item.addOrEdit === 'version'
|
|
371
377
|
})
|
|
372
378
|
},
|
|
373
|
-
formItemLayoutGen
|
|
379
|
+
formItemLayoutGen() {
|
|
374
380
|
if (this.layout === 'simple-inline') {
|
|
375
381
|
return {
|
|
376
382
|
labelCol: { span: 0 },
|
|
@@ -382,16 +388,16 @@ export default {
|
|
|
382
388
|
if (this.enableHorizontalCustom && this.formItemLayout) {
|
|
383
389
|
return {
|
|
384
390
|
labelCol: {
|
|
385
|
-
span:
|
|
386
|
-
offset:
|
|
391
|
+
span: this.formItemLayout.labelCol ?? 4,
|
|
392
|
+
offset: this.formItemLayout.offset ?? 2
|
|
387
393
|
},
|
|
388
|
-
wrapperCol: { span:
|
|
394
|
+
wrapperCol: { span: this.formItemLayout.wrapperCol ?? 14 }
|
|
389
395
|
}
|
|
390
396
|
}
|
|
391
397
|
// 默认配置
|
|
392
398
|
return {
|
|
393
399
|
labelCol: { span: 4, offset: 2 },
|
|
394
|
-
wrapperCol: { span: 14 }
|
|
400
|
+
wrapperCol: { span: 14 }
|
|
395
401
|
}
|
|
396
402
|
} else if (this.layout === 'vertical') {
|
|
397
403
|
return {}
|
|
@@ -399,35 +405,35 @@ export default {
|
|
|
399
405
|
if (!this.formItemLayout.labelCol || !this.formItemLayout.wrapperCol) {
|
|
400
406
|
return {
|
|
401
407
|
labelCol: { span: 8 },
|
|
402
|
-
wrapperCol: { span: 16 }
|
|
408
|
+
wrapperCol: { span: 16 }
|
|
403
409
|
}
|
|
404
410
|
}
|
|
405
411
|
return {
|
|
406
412
|
labelCol: { span: this.formItemLayout.labelCol },
|
|
407
|
-
wrapperCol: { span: this.formItemLayout.wrapperCol }
|
|
413
|
+
wrapperCol: { span: this.formItemLayout.wrapperCol }
|
|
408
414
|
}
|
|
409
415
|
}
|
|
410
416
|
},
|
|
411
417
|
// simple-inline模式判断
|
|
412
|
-
isSimpleInlineMode
|
|
418
|
+
isSimpleInlineMode() {
|
|
413
419
|
return this.layout === 'simple-inline' && this.simpleInline
|
|
414
420
|
},
|
|
415
421
|
// simple-inline布局行数据
|
|
416
|
-
simpleInlineRows
|
|
422
|
+
simpleInlineRows() {
|
|
417
423
|
if (!this.isSimpleInlineMode) return []
|
|
418
424
|
return this.simpleInline.rows.map(row => ({
|
|
419
425
|
...row,
|
|
420
|
-
items: row.items
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
f.model === item.key && f.name === item.title
|
|
424
|
-
)
|
|
425
|
-
|
|
426
|
+
items: row.items
|
|
427
|
+
.map(item => ({
|
|
428
|
+
...item,
|
|
429
|
+
formItem: this.realJsonData.find(f => f.model === item.key && f.name === item.title)
|
|
430
|
+
}))
|
|
431
|
+
.filter(item => item.formItem)
|
|
426
432
|
}))
|
|
427
433
|
},
|
|
428
434
|
...mapState('account', { currUser: 'user' })
|
|
429
435
|
},
|
|
430
|
-
provide
|
|
436
|
+
provide() {
|
|
431
437
|
return {
|
|
432
438
|
getComponentByName: this.getComponentByName,
|
|
433
439
|
registerComponent: this.registerComponent,
|
|
@@ -436,12 +442,12 @@ export default {
|
|
|
436
442
|
removeRequired: this.removeRequired,
|
|
437
443
|
// 设置必填项
|
|
438
444
|
setRequired: this.setRequired,
|
|
439
|
-
getSelf: () => this
|
|
445
|
+
getSelf: () => this
|
|
440
446
|
}
|
|
441
447
|
},
|
|
442
448
|
watch: {
|
|
443
449
|
form: {
|
|
444
|
-
handler
|
|
450
|
+
handler(val) {
|
|
445
451
|
if (this.formDataChange && typeof this.formDataChange === 'function') {
|
|
446
452
|
this.formDataChange(val)
|
|
447
453
|
}
|
|
@@ -490,7 +496,7 @@ export default {
|
|
|
490
496
|
runLogic,
|
|
491
497
|
getConfigByNameAsync,
|
|
492
498
|
getConfigByName,
|
|
493
|
-
init
|
|
499
|
+
init(params) {
|
|
494
500
|
const {
|
|
495
501
|
configName,
|
|
496
502
|
configContent,
|
|
@@ -600,25 +606,25 @@ export default {
|
|
|
600
606
|
}
|
|
601
607
|
this.loaded = true
|
|
602
608
|
},
|
|
603
|
-
scrollToGroup
|
|
609
|
+
scrollToGroup(index) {
|
|
604
610
|
const groupElement = this.$refs[`group-title-${index}`][0]
|
|
605
611
|
if (groupElement) {
|
|
606
612
|
groupElement.scrollIntoView({ behavior: 'smooth' })
|
|
607
613
|
}
|
|
608
614
|
},
|
|
609
|
-
registerComponent
|
|
615
|
+
registerComponent(componentName, component) {
|
|
610
616
|
console.log('内部注册', this.$options.name, componentName)
|
|
611
617
|
this.$refs[componentName] = component
|
|
612
618
|
console.log('内部注册完成', this.$refs)
|
|
613
619
|
},
|
|
614
620
|
// 根据名字从注册到组件中获取组件
|
|
615
|
-
getComponentByName
|
|
621
|
+
getComponentByName(componentName) {
|
|
616
622
|
console.log('内部取组件', this.$options.name, componentName)
|
|
617
623
|
console.log('内部组件内容', this.$refs)
|
|
618
624
|
return this.$refs[componentName]
|
|
619
625
|
},
|
|
620
626
|
// 兼容需要省略 传递 [formItems: res.formJson ] 可以使用 ...res 展开运算符 直接转递
|
|
621
|
-
getFromItem
|
|
627
|
+
getFromItem(formItems, formJson) {
|
|
622
628
|
const _formItems = formItems || formJson
|
|
623
629
|
if (typeof formItems === 'string') {
|
|
624
630
|
return JSON.parse(_formItems)
|
|
@@ -626,12 +632,12 @@ export default {
|
|
|
626
632
|
return JSON.parse(JSON.stringify(_formItems))
|
|
627
633
|
}
|
|
628
634
|
},
|
|
629
|
-
innerXFormTableEmit
|
|
635
|
+
innerXFormTableEmit(fun, record, id, actionType, index) {
|
|
630
636
|
this.$emit(fun, record, id, actionType, index)
|
|
631
637
|
},
|
|
632
638
|
// 时间组件赋默认值
|
|
633
639
|
// .type, item.formDefault
|
|
634
|
-
getDateRange
|
|
640
|
+
getDateRange({ type, formDefault: defaultValue, formValueFormat }) {
|
|
635
641
|
// const format = type === 'datePicker' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'
|
|
636
642
|
let format = 'YYYY-MM-DD HH:mm:ss'
|
|
637
643
|
if (formValueFormat) {
|
|
@@ -656,15 +662,22 @@ export default {
|
|
|
656
662
|
}
|
|
657
663
|
return start
|
|
658
664
|
},
|
|
659
|
-
setFormProps
|
|
665
|
+
setFormProps(formData, item, groupItem) {
|
|
660
666
|
const rulesKey = `${item.name}${item.model}`
|
|
661
667
|
if (formData[item.model] === undefined || formData[item.model] === null) {
|
|
662
668
|
formData[item.model] = undefined
|
|
663
669
|
}
|
|
664
670
|
if (!formData[item.model] && item.formDefault) {
|
|
665
|
-
if (
|
|
671
|
+
if (
|
|
672
|
+
['datePicker', 'rangePicker', 'yearPicker', 'monthPicker', 'yearRangePicker', 'monthRangePicker'].includes(
|
|
673
|
+
item.type
|
|
674
|
+
)
|
|
675
|
+
) {
|
|
666
676
|
formData[item.model] = this.getDateRange(item)
|
|
667
|
-
} else if (
|
|
677
|
+
} else if (
|
|
678
|
+
['treeSelect', 'select', 'checkbox'].includes(item.type) &&
|
|
679
|
+
['curOrgId', 'curDepId', 'curUserId'].includes(item.formDefault)
|
|
680
|
+
) {
|
|
668
681
|
if (item.formDefault === 'curOrgId') {
|
|
669
682
|
formData[item.model] = item.type === 'select' ? this.currUser.orgid : [this.currUser.orgid]
|
|
670
683
|
}
|
|
@@ -721,7 +734,7 @@ export default {
|
|
|
721
734
|
const minCount = Number(item.minAcceptCount)
|
|
722
735
|
this.rules[rulesArrayKey].push({
|
|
723
736
|
validator: (rule, value, callback) => {
|
|
724
|
-
const count = Array.isArray(value) ? value.length :
|
|
737
|
+
const count = Array.isArray(value) ? value.length : value ? 1 : 0
|
|
725
738
|
if ((required || count > 0) && count < minCount) {
|
|
726
739
|
callback(new Error(`请至少上传${minCount}个${item.name}`))
|
|
727
740
|
} else {
|
|
@@ -760,7 +773,7 @@ export default {
|
|
|
760
773
|
this.rules[rulesArrayKey].push({
|
|
761
774
|
type: item.rule.type,
|
|
762
775
|
message: item.name + '必须为' + message,
|
|
763
|
-
transform:
|
|
776
|
+
transform: value => {
|
|
764
777
|
if (value && value.length !== 0) {
|
|
765
778
|
return Number(value)
|
|
766
779
|
} else {
|
|
@@ -884,27 +897,38 @@ export default {
|
|
|
884
897
|
}
|
|
885
898
|
}
|
|
886
899
|
},
|
|
887
|
-
childTableMounted
|
|
900
|
+
childTableMounted(item) {
|
|
888
901
|
// 子表初始化时,设置表格数据
|
|
889
902
|
if (this.form[item.model] && this.form[item.model].length > 0) {
|
|
890
903
|
this.$refs[`childXFormTable_${item.model}`][0].setTableData(this.form[item.model])
|
|
891
904
|
}
|
|
892
905
|
},
|
|
893
|
-
customJsValidate
|
|
906
|
+
customJsValidate(rule, value, callback, item) {
|
|
894
907
|
if (item.rule.customValidatorFunc) {
|
|
895
|
-
executeStrFunctionByContext(this, item.rule.customValidatorFunc, [
|
|
908
|
+
executeStrFunctionByContext(this, item.rule.customValidatorFunc, [
|
|
909
|
+
rule,
|
|
910
|
+
value,
|
|
911
|
+
callback,
|
|
912
|
+
this.form,
|
|
913
|
+
item,
|
|
914
|
+
this.util,
|
|
915
|
+
runLogic,
|
|
916
|
+
getConfigByNameAsync
|
|
917
|
+
])
|
|
896
918
|
} else {
|
|
897
919
|
callback()
|
|
898
920
|
}
|
|
899
921
|
},
|
|
900
|
-
itemDisabled
|
|
901
|
-
return (
|
|
922
|
+
itemDisabled(value) {
|
|
923
|
+
return (
|
|
924
|
+
(this.businessType === '新增' && value.addOrEdit === 'edit') ||
|
|
902
925
|
(this.businessType === '修改' && value.addOrEdit === 'add')
|
|
926
|
+
)
|
|
903
927
|
},
|
|
904
|
-
readonly
|
|
928
|
+
readonly(value) {
|
|
905
929
|
return value.addOrEdit === 'readonly'
|
|
906
930
|
},
|
|
907
|
-
async onSubmit
|
|
931
|
+
async onSubmit() {
|
|
908
932
|
const valid = await this.validateForm()
|
|
909
933
|
if (!valid) return false
|
|
910
934
|
if (this.viewMode) {
|
|
@@ -964,7 +988,7 @@ export default {
|
|
|
964
988
|
}
|
|
965
989
|
},
|
|
966
990
|
|
|
967
|
-
async asyncSubmit
|
|
991
|
+
async asyncSubmit() {
|
|
968
992
|
return new Promise((resolve, reject) => {
|
|
969
993
|
this.$refs.selectForm.validate(async valid => {
|
|
970
994
|
if (!valid) {
|
|
@@ -987,13 +1011,13 @@ export default {
|
|
|
987
1011
|
})
|
|
988
1012
|
},
|
|
989
1013
|
|
|
990
|
-
validateForm
|
|
991
|
-
return new Promise(
|
|
1014
|
+
validateForm() {
|
|
1015
|
+
return new Promise(resolve => {
|
|
992
1016
|
this.$refs.selectForm.validate(valid => resolve(valid))
|
|
993
1017
|
})
|
|
994
1018
|
},
|
|
995
1019
|
|
|
996
|
-
childTableFixedQueryForm
|
|
1020
|
+
childTableFixedQueryForm(item) {
|
|
997
1021
|
if (this.modifyModelData?.primaryKeyData) {
|
|
998
1022
|
const fixedForm = {}
|
|
999
1023
|
fixedForm[item.childTableForeignKeyName] = Object.values(this.modifyModelData.primaryKeyData)[0]
|
|
@@ -1002,7 +1026,7 @@ export default {
|
|
|
1002
1026
|
return null
|
|
1003
1027
|
},
|
|
1004
1028
|
|
|
1005
|
-
prepareForm
|
|
1029
|
+
prepareForm() {
|
|
1006
1030
|
const form = { ...this.form }
|
|
1007
1031
|
for (const key of Object.keys(form)) {
|
|
1008
1032
|
const value = form[key]
|
|
@@ -1013,7 +1037,7 @@ export default {
|
|
|
1013
1037
|
return form
|
|
1014
1038
|
},
|
|
1015
1039
|
|
|
1016
|
-
async appendSilenceAddFields
|
|
1040
|
+
async appendSilenceAddFields(form) {
|
|
1017
1041
|
if (this.businessType === '新增') {
|
|
1018
1042
|
for (const item of this.silenceAddJsonData) {
|
|
1019
1043
|
switch (item.silencePurpose) {
|
|
@@ -1040,7 +1064,7 @@ export default {
|
|
|
1040
1064
|
break
|
|
1041
1065
|
}
|
|
1042
1066
|
}
|
|
1043
|
-
for (const item of this.silenceAddJsonData.filter(
|
|
1067
|
+
for (const item of this.silenceAddJsonData.filter(item => item.silencePurpose === 'customize')) {
|
|
1044
1068
|
const result = await runLogic(item.silenceSource, form, this.serviceName)
|
|
1045
1069
|
if (result) {
|
|
1046
1070
|
const keys = Object.keys(result)
|
|
@@ -1056,7 +1080,7 @@ export default {
|
|
|
1056
1080
|
}
|
|
1057
1081
|
},
|
|
1058
1082
|
|
|
1059
|
-
handleFormKeys
|
|
1083
|
+
handleFormKeys(form, mustHandleKey = false) {
|
|
1060
1084
|
const realForm = {}
|
|
1061
1085
|
for (const key of Object.keys(form)) {
|
|
1062
1086
|
const value = form[key]
|
|
@@ -1081,7 +1105,7 @@ export default {
|
|
|
1081
1105
|
return realForm
|
|
1082
1106
|
},
|
|
1083
1107
|
// 默认提交事件
|
|
1084
|
-
defaultSubmit
|
|
1108
|
+
defaultSubmit(realForm, callback) {
|
|
1085
1109
|
// 新增移除id
|
|
1086
1110
|
if (this.businessType === '新增') {
|
|
1087
1111
|
delete realForm.id
|
|
@@ -1094,21 +1118,28 @@ export default {
|
|
|
1094
1118
|
businessType: this.businessType,
|
|
1095
1119
|
operator: this.currUser.name
|
|
1096
1120
|
}
|
|
1097
|
-
addOrModify(requestParameters, this.serviceName, this.env === 'dev')
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1121
|
+
addOrModify(requestParameters, this.serviceName, this.env === 'dev')
|
|
1122
|
+
.then(data => {
|
|
1123
|
+
this.$message.success(this.businessType + '成功!')
|
|
1124
|
+
// commit
|
|
1125
|
+
this.$emit('afterSubmit', {
|
|
1126
|
+
type: this.businessType,
|
|
1127
|
+
id: data.id,
|
|
1128
|
+
data: data,
|
|
1129
|
+
form: requestParameters.form
|
|
1130
|
+
})
|
|
1131
|
+
this.loading = false
|
|
1132
|
+
if (callback) {
|
|
1133
|
+
callback()
|
|
1134
|
+
}
|
|
1135
|
+
})
|
|
1136
|
+
.catch(e => {
|
|
1137
|
+
this.loading = false
|
|
1138
|
+
this.$message.error(this.businessType + '失败:' + e)
|
|
1139
|
+
})
|
|
1109
1140
|
},
|
|
1110
1141
|
// 获取表单字段实际值
|
|
1111
|
-
getRealKey
|
|
1142
|
+
getRealKey(key, mustHandleKey = false) {
|
|
1112
1143
|
if (key === 'selected_id') return key
|
|
1113
1144
|
if (this.isHandleFormKey || mustHandleKey) {
|
|
1114
1145
|
return key.substring(key.indexOf('_') + 1)
|
|
@@ -1120,7 +1151,7 @@ export default {
|
|
|
1120
1151
|
* 获取被修改记录数据
|
|
1121
1152
|
* @param modifyModelData 被修改记录的数据
|
|
1122
1153
|
*/
|
|
1123
|
-
getModifyModelData
|
|
1154
|
+
getModifyModelData(modifyModelData) {
|
|
1124
1155
|
if (modifyModelData.primaryKeyData) {
|
|
1125
1156
|
this.form = Object.assign(this.form, modifyModelData.primaryKeyData)
|
|
1126
1157
|
}
|
|
@@ -1179,7 +1210,7 @@ export default {
|
|
|
1179
1210
|
}
|
|
1180
1211
|
}
|
|
1181
1212
|
},
|
|
1182
|
-
setForm
|
|
1213
|
+
setForm(obj) {
|
|
1183
1214
|
this.form = Object.assign(this.form, obj)
|
|
1184
1215
|
// 给子表赋外键条件
|
|
1185
1216
|
if (this.childFormData.length > 0) {
|
|
@@ -1190,7 +1221,9 @@ export default {
|
|
|
1190
1221
|
// 有主键,且主键有值,添加主键条件
|
|
1191
1222
|
if (this.primaryKey && this.form[this.primaryKey]) {
|
|
1192
1223
|
const foreignKey = item.foreignKey
|
|
1193
|
-
const fixedQueryForm = {
|
|
1224
|
+
const fixedQueryForm = {
|
|
1225
|
+
[alias + '_' + foreignKey]: this.form[this.primaryKey]
|
|
1226
|
+
}
|
|
1194
1227
|
if (!child.fixedQueryForm) {
|
|
1195
1228
|
child.fixedQueryForm = fixedQueryForm
|
|
1196
1229
|
} else {
|
|
@@ -1201,21 +1234,21 @@ export default {
|
|
|
1201
1234
|
}
|
|
1202
1235
|
}
|
|
1203
1236
|
},
|
|
1204
|
-
setFormWithKey
|
|
1237
|
+
setFormWithKey(obj) {
|
|
1205
1238
|
setDataByRealKey(this.form, obj)
|
|
1206
1239
|
},
|
|
1207
|
-
setFormWithNoKey
|
|
1240
|
+
setFormWithNoKey(obj) {
|
|
1208
1241
|
setDataByRealKey(this.form, obj)
|
|
1209
1242
|
},
|
|
1210
|
-
emitFunc
|
|
1243
|
+
emitFunc(func, data, value) {
|
|
1211
1244
|
this.$emit(func, data, value)
|
|
1212
1245
|
this.$emit('x-form-item-emit-func', func, data, value)
|
|
1213
1246
|
},
|
|
1214
1247
|
// 直接转发事件的函数
|
|
1215
|
-
emitEvent
|
|
1248
|
+
emitEvent(event, ...args) {
|
|
1216
1249
|
this.$emit(event, ...args)
|
|
1217
1250
|
},
|
|
1218
|
-
close
|
|
1251
|
+
close() {
|
|
1219
1252
|
this.loaded = false
|
|
1220
1253
|
},
|
|
1221
1254
|
/**
|
|
@@ -1223,13 +1256,21 @@ export default {
|
|
|
1223
1256
|
* @param row 选中行集合
|
|
1224
1257
|
* @param attr 表单项属性
|
|
1225
1258
|
*/
|
|
1226
|
-
async rowChoose
|
|
1259
|
+
async rowChoose(row, attr, callback) {
|
|
1227
1260
|
// 如果配置了自定义函数
|
|
1228
1261
|
if (attr.dataChangeFunc) {
|
|
1229
|
-
await executeStrFunction(attr.dataChangeFunc, [
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1262
|
+
await executeStrFunction(attr.dataChangeFunc, [
|
|
1263
|
+
this.form,
|
|
1264
|
+
this.setForm,
|
|
1265
|
+
{
|
|
1266
|
+
...attr,
|
|
1267
|
+
selectRows: row
|
|
1268
|
+
},
|
|
1269
|
+
util,
|
|
1270
|
+
this.mode,
|
|
1271
|
+
runLogic,
|
|
1272
|
+
getConfigByNameAsync
|
|
1273
|
+
])
|
|
1233
1274
|
} else {
|
|
1234
1275
|
// 默认填充选中行数据到当前表单
|
|
1235
1276
|
setDataByRealKey(this.form, row[0])
|
|
@@ -1237,13 +1278,13 @@ export default {
|
|
|
1237
1278
|
if (callback) {
|
|
1238
1279
|
callback()
|
|
1239
1280
|
}
|
|
1240
|
-
}
|
|
1281
|
+
}
|
|
1241
1282
|
}
|
|
1242
1283
|
}
|
|
1243
1284
|
</script>
|
|
1244
1285
|
|
|
1245
1286
|
<style scoped lang="less">
|
|
1246
|
-
:deep(.ant-form-inline .ant-form-item
|
|
1287
|
+
:deep(.ant-form-inline .ant-form-item) {
|
|
1247
1288
|
display: block !important;
|
|
1248
1289
|
}
|
|
1249
1290
|
|
|
@@ -516,19 +516,6 @@ export default {
|
|
|
516
516
|
},
|
|
517
517
|
setForm(obj) {
|
|
518
518
|
this.form = Object.assign(this.form, obj)
|
|
519
|
-
},
|
|
520
|
-
/**
|
|
521
|
-
* 主动触发表单提交
|
|
522
|
-
* 用于 queryTable 等场景,确保走相同的数据处理流程
|
|
523
|
-
* @param {Object} conditionParams - 额外的查询条件参数
|
|
524
|
-
*/
|
|
525
|
-
submitForm(conditionParams = {}) {
|
|
526
|
-
// 将外部参数合并到表单中
|
|
527
|
-
if (Object.keys(conditionParams).length > 0) {
|
|
528
|
-
this.form = Object.assign({}, this.form, conditionParams)
|
|
529
|
-
}
|
|
530
|
-
// 调用现有的 onSubmit 方法,触发 emit
|
|
531
|
-
this.onSubmit()
|
|
532
519
|
}
|
|
533
520
|
},
|
|
534
521
|
mounted() {
|
|
@@ -1032,10 +1032,7 @@ export default {
|
|
|
1032
1032
|
if (this.tableShowMode === 'popup') {
|
|
1033
1033
|
this.formQueryLoading = true
|
|
1034
1034
|
}
|
|
1035
|
-
|
|
1036
|
-
// 这会触发 emit 'onSubmit',然后走现有的 onSearchSubmit 逻辑
|
|
1037
|
-
// 最终通过 setQueryForm → refresh → loadData 进行数据处理
|
|
1038
|
-
this.$refs.xForm.submitForm(conditionParams)
|
|
1035
|
+
this.$refs.xTable.queryTable(conditionParams)
|
|
1039
1036
|
},
|
|
1040
1037
|
/**
|
|
1041
1038
|
* 向外暴露 resetForm 函数
|
|
@@ -1220,6 +1220,18 @@ export default {
|
|
|
1220
1220
|
// 如果要实质修改 form 需要在 x-form 中赋值
|
|
1221
1221
|
const _from = JSON.parse(JSON.stringify(this.form))
|
|
1222
1222
|
this.form = Object.assign(_from, conditionParams)
|
|
1223
|
+
for (const key of Object.keys(this.form)) {
|
|
1224
|
+
if (this.form[key] === null || this.form[key] === '') {
|
|
1225
|
+
this.form[key] = undefined
|
|
1226
|
+
}
|
|
1227
|
+
// 树形选择框重置后会重置为[undefined],查询时为[null]
|
|
1228
|
+
if (
|
|
1229
|
+
Array.isArray(this.form[key]) &&
|
|
1230
|
+
(this.form[key].length === 0 || this.form[key][0] === null || this.form[key][0] === undefined)
|
|
1231
|
+
) {
|
|
1232
|
+
this.form[key] = undefined
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1223
1235
|
await this.refresh(true)
|
|
1224
1236
|
this.form = _from
|
|
1225
1237
|
},
|