@tmagic/form 1.2.6 → 1.2.7
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/dist/style.css +29 -0
- package/dist/tmagic-form.js +357 -64
- package/dist/tmagic-form.js.map +1 -1
- package/dist/tmagic-form.umd.cjs +360 -67
- package/dist/tmagic-form.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/Form.vue +31 -2
- package/src/containers/Col.vue +7 -1
- package/src/containers/Container.vue +147 -3
- package/src/containers/Fieldset.vue +12 -1
- package/src/containers/GroupList.vue +9 -1
- package/src/containers/GroupListItem.vue +7 -1
- package/src/containers/Panel.vue +10 -1
- package/src/containers/Row.vue +7 -1
- package/src/containers/Step.vue +7 -1
- package/src/containers/Table.vue +20 -1
- package/src/containers/Tabs.vue +58 -21
- package/src/schema.ts +2 -0
- package/src/theme/index.scss +1 -0
- package/src/theme/tabs.scss +4 -0
- package/types/Form.vue.d.ts +19 -0
- package/types/FormDialog.vue.d.ts +111 -3
- package/types/containers/Col.vue.d.ts +6 -1
- package/types/containers/Container.vue.d.ts +18 -1
- package/types/containers/Fieldset.vue.d.ts +12 -1
- package/types/containers/GroupList.vue.d.ts +6 -1
- package/types/containers/GroupListItem.vue.d.ts +6 -1
- package/types/containers/Panel.vue.d.ts +15 -3
- package/types/containers/Row.vue.d.ts +6 -1
- package/types/containers/Step.vue.d.ts +6 -1
- package/types/containers/Table.vue.d.ts +30 -4
- package/types/containers/Tabs.vue.d.ts +22 -3
- package/types/schema.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.7",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@element-plus/icons-vue": "^2.0.9",
|
|
39
|
-
"@tmagic/design": "1.2.
|
|
40
|
-
"@tmagic/utils": "1.2.
|
|
39
|
+
"@tmagic/design": "1.2.7",
|
|
40
|
+
"@tmagic/utils": "1.2.7",
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
42
|
"sortablejs": "^1.14.0",
|
|
43
43
|
"vue": "^3.2.37"
|
package/src/Form.vue
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
:key="item[keyProp] ?? index"
|
|
16
16
|
:config="item"
|
|
17
17
|
:model="values"
|
|
18
|
+
:last-values="lastValuesProcessed"
|
|
19
|
+
:is-compare="isCompare"
|
|
18
20
|
:label-width="item.labelWidth || labelWidth"
|
|
19
21
|
:step-active="stepActive"
|
|
20
22
|
:size="size"
|
|
@@ -26,8 +28,8 @@
|
|
|
26
28
|
|
|
27
29
|
<script setup lang="ts" name="MForm">
|
|
28
30
|
import { provide, reactive, ref, toRaw, watch, watchEffect } from 'vue';
|
|
31
|
+
import { isEqual } from 'lodash-es';
|
|
29
32
|
import cloneDeep from 'lodash-es/cloneDeep';
|
|
30
|
-
import isEqual from 'lodash-es/isEqual';
|
|
31
33
|
|
|
32
34
|
import { TMagicForm } from '@tmagic/design';
|
|
33
35
|
|
|
@@ -38,8 +40,14 @@ import type { FormConfig, FormState, FormValue, ValidateError } from './schema';
|
|
|
38
40
|
|
|
39
41
|
const props = withDefaults(
|
|
40
42
|
defineProps<{
|
|
43
|
+
/** 表单配置 */
|
|
41
44
|
config: FormConfig;
|
|
45
|
+
/** 表单值 */
|
|
42
46
|
initValues: Object;
|
|
47
|
+
/** 需对比的值(开启对比模式时传入) */
|
|
48
|
+
lastValues?: Object;
|
|
49
|
+
/** 是否开启对比模式 */
|
|
50
|
+
isCompare?: boolean;
|
|
43
51
|
parentValues?: Object;
|
|
44
52
|
labelWidth?: string;
|
|
45
53
|
disabled?: boolean;
|
|
@@ -54,6 +62,8 @@ const props = withDefaults(
|
|
|
54
62
|
{
|
|
55
63
|
config: () => [],
|
|
56
64
|
initValues: () => ({}),
|
|
65
|
+
lastValues: () => ({}),
|
|
66
|
+
isCompare: false,
|
|
57
67
|
parentValues: () => ({}),
|
|
58
68
|
labelWidth: '200px',
|
|
59
69
|
disabled: false,
|
|
@@ -70,6 +80,7 @@ const emit = defineEmits(['change', 'field-input', 'field-change']);
|
|
|
70
80
|
const tMagicForm = ref<InstanceType<typeof TMagicForm>>();
|
|
71
81
|
const initialized = ref(false);
|
|
72
82
|
const values = ref<FormValue>({});
|
|
83
|
+
const lastValuesProcessed = ref<FormValue>({});
|
|
73
84
|
const fields = new Map<string, any>();
|
|
74
85
|
|
|
75
86
|
const requestFuc = getConfig('request') as Function;
|
|
@@ -79,8 +90,11 @@ const formState: FormState = reactive<FormState>({
|
|
|
79
90
|
popperClass: props.popperClass,
|
|
80
91
|
config: props.config,
|
|
81
92
|
initValues: props.initValues,
|
|
93
|
+
isCompare: props.isCompare,
|
|
94
|
+
lastValues: props.lastValues,
|
|
82
95
|
parentValues: props.parentValues,
|
|
83
96
|
values,
|
|
97
|
+
lastValuesProcessed,
|
|
84
98
|
$emit: emit as (event: string, ...args: any[]) => void,
|
|
85
99
|
fields,
|
|
86
100
|
setField: (prop: string, field: any) => fields.set(prop, field),
|
|
@@ -98,6 +112,8 @@ const formState: FormState = reactive<FormState>({
|
|
|
98
112
|
|
|
99
113
|
watchEffect(() => {
|
|
100
114
|
formState.initValues = props.initValues;
|
|
115
|
+
formState.lastValues = props.lastValues;
|
|
116
|
+
formState.isCompare = props.isCompare;
|
|
101
117
|
formState.config = props.config;
|
|
102
118
|
formState.keyProp = props.keyProp;
|
|
103
119
|
formState.popperClass = props.popperClass;
|
|
@@ -118,8 +134,20 @@ watch(
|
|
|
118
134
|
config: props.config,
|
|
119
135
|
}).then((value) => {
|
|
120
136
|
values.value = value;
|
|
121
|
-
|
|
137
|
+
// 非对比模式,初始化完成
|
|
138
|
+
initialized.value = !props.isCompare;
|
|
122
139
|
});
|
|
140
|
+
|
|
141
|
+
if (props.isCompare) {
|
|
142
|
+
// 对比模式下初始化待对比的表单值
|
|
143
|
+
initValue(formState, {
|
|
144
|
+
initValues: props.lastValues,
|
|
145
|
+
config: props.config,
|
|
146
|
+
}).then((value) => {
|
|
147
|
+
lastValuesProcessed.value = value;
|
|
148
|
+
initialized.value = true;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
123
151
|
},
|
|
124
152
|
{ immediate: true },
|
|
125
153
|
);
|
|
@@ -130,6 +158,7 @@ const changeHandler = () => {
|
|
|
130
158
|
|
|
131
159
|
defineExpose({
|
|
132
160
|
values,
|
|
161
|
+
lastValuesProcessed,
|
|
133
162
|
formState,
|
|
134
163
|
initialized,
|
|
135
164
|
|
package/src/containers/Col.vue
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
<TMagicCol v-show="display && config.type !== 'hidden'" :span="span">
|
|
3
3
|
<Container
|
|
4
4
|
:model="model"
|
|
5
|
+
:lastValues="lastValues"
|
|
6
|
+
:is-compare="isCompare"
|
|
5
7
|
:config="config"
|
|
6
8
|
:prop="prop"
|
|
7
9
|
:label-width="config.labelWidth || labelWidth"
|
|
@@ -9,6 +11,7 @@
|
|
|
9
11
|
:size="size"
|
|
10
12
|
:disabled="disabled"
|
|
11
13
|
@change="changeHandler"
|
|
14
|
+
@add-diff-count="onAddDiffCount"
|
|
12
15
|
></Container>
|
|
13
16
|
</TMagicCol>
|
|
14
17
|
</template>
|
|
@@ -25,6 +28,8 @@ import Container from './Container.vue';
|
|
|
25
28
|
|
|
26
29
|
const props = defineProps<{
|
|
27
30
|
model: any;
|
|
31
|
+
lastValues?: any;
|
|
32
|
+
isCompare?: boolean;
|
|
28
33
|
config: ChildConfig;
|
|
29
34
|
labelWidth?: string;
|
|
30
35
|
expandMore?: boolean;
|
|
@@ -34,9 +39,10 @@ const props = defineProps<{
|
|
|
34
39
|
disabled?: boolean;
|
|
35
40
|
}>();
|
|
36
41
|
|
|
37
|
-
const emit = defineEmits(['change']);
|
|
42
|
+
const emit = defineEmits(['change', 'addDiffCount']);
|
|
38
43
|
|
|
39
44
|
const mForm = inject<FormState | undefined>('mForm');
|
|
40
45
|
const display = computed(() => displayFunction(mForm, props.config.display, props));
|
|
41
46
|
const changeHandler = () => emit('change', props.model);
|
|
47
|
+
const onAddDiffCount = () => emit('addDiffCount');
|
|
42
48
|
</script>
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
:size="size"
|
|
21
21
|
:is="tagName"
|
|
22
22
|
:model="model"
|
|
23
|
+
:last-values="lastValues"
|
|
24
|
+
:is-compare="isCompare"
|
|
23
25
|
:config="config"
|
|
24
26
|
:disabled="disabled"
|
|
25
27
|
:name="name"
|
|
@@ -28,15 +30,120 @@
|
|
|
28
30
|
:expand-more="expand"
|
|
29
31
|
:label-width="itemLabelWidth"
|
|
30
32
|
@change="onChangeHandler"
|
|
33
|
+
@addDiffCount="onAddDiffCount"
|
|
31
34
|
></component>
|
|
32
35
|
|
|
33
|
-
<template v-else-if="type && display">
|
|
36
|
+
<template v-else-if="type && display && !showDiff">
|
|
34
37
|
<TMagicFormItem
|
|
35
38
|
:style="config.tip ? 'flex: 1' : ''"
|
|
36
39
|
:class="{ hidden: `${itemLabelWidth}` === '0' || !config.text }"
|
|
37
40
|
:prop="itemProp"
|
|
38
41
|
:label-width="itemLabelWidth"
|
|
39
42
|
:rules="rule"
|
|
43
|
+
>
|
|
44
|
+
<template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
|
|
45
|
+
<TMagicTooltip v-if="tooltip">
|
|
46
|
+
<component
|
|
47
|
+
:key="key(config)"
|
|
48
|
+
:size="size"
|
|
49
|
+
:is="tagName"
|
|
50
|
+
:model="model"
|
|
51
|
+
:config="config"
|
|
52
|
+
:name="name"
|
|
53
|
+
:disabled="disabled"
|
|
54
|
+
:prop="itemProp"
|
|
55
|
+
@change="onChangeHandler"
|
|
56
|
+
@addDiffCount="onAddDiffCount"
|
|
57
|
+
></component>
|
|
58
|
+
<template #content>
|
|
59
|
+
<div v-html="tooltip"></div>
|
|
60
|
+
</template>
|
|
61
|
+
</TMagicTooltip>
|
|
62
|
+
|
|
63
|
+
<component
|
|
64
|
+
v-else
|
|
65
|
+
:key="key(config)"
|
|
66
|
+
:size="size"
|
|
67
|
+
:is="tagName"
|
|
68
|
+
:model="model"
|
|
69
|
+
:config="config"
|
|
70
|
+
:name="name"
|
|
71
|
+
:disabled="disabled"
|
|
72
|
+
:prop="itemProp"
|
|
73
|
+
@change="onChangeHandler"
|
|
74
|
+
@addDiffCount="onAddDiffCount"
|
|
75
|
+
></component>
|
|
76
|
+
|
|
77
|
+
<div v-if="extra" v-html="extra" class="m-form-tip"></div>
|
|
78
|
+
</TMagicFormItem>
|
|
79
|
+
|
|
80
|
+
<TMagicTooltip v-if="config.tip" placement="left">
|
|
81
|
+
<TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
|
|
82
|
+
<template #content>
|
|
83
|
+
<div v-html="config.tip"></div>
|
|
84
|
+
</template>
|
|
85
|
+
</TMagicTooltip>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<!-- 对比 -->
|
|
89
|
+
<template v-else-if="type && display && showDiff">
|
|
90
|
+
<!-- 上次内容 -->
|
|
91
|
+
<TMagicFormItem
|
|
92
|
+
:style="config.tip ? 'flex: 1' : ''"
|
|
93
|
+
:class="{ hidden: `${itemLabelWidth}` === '0' || !config.text }"
|
|
94
|
+
:prop="itemProp"
|
|
95
|
+
:label-width="itemLabelWidth"
|
|
96
|
+
:rules="rule"
|
|
97
|
+
style="background: #f7dadd"
|
|
98
|
+
>
|
|
99
|
+
<template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
|
|
100
|
+
<TMagicTooltip v-if="tooltip">
|
|
101
|
+
<component
|
|
102
|
+
:key="key(config)"
|
|
103
|
+
:size="size"
|
|
104
|
+
:is="tagName"
|
|
105
|
+
:model="lastValues"
|
|
106
|
+
:config="config"
|
|
107
|
+
:name="name"
|
|
108
|
+
:disabled="disabled"
|
|
109
|
+
:prop="itemProp"
|
|
110
|
+
@change="onChangeHandler"
|
|
111
|
+
></component>
|
|
112
|
+
<template #content>
|
|
113
|
+
<div v-html="tooltip"></div>
|
|
114
|
+
</template>
|
|
115
|
+
</TMagicTooltip>
|
|
116
|
+
|
|
117
|
+
<component
|
|
118
|
+
v-else
|
|
119
|
+
:key="key(config)"
|
|
120
|
+
:size="size"
|
|
121
|
+
:is="tagName"
|
|
122
|
+
:model="lastValues"
|
|
123
|
+
:config="config"
|
|
124
|
+
:name="name"
|
|
125
|
+
:disabled="disabled"
|
|
126
|
+
:prop="itemProp"
|
|
127
|
+
@change="onChangeHandler"
|
|
128
|
+
></component>
|
|
129
|
+
|
|
130
|
+
<div v-if="extra" v-html="extra" class="m-form-tip"></div>
|
|
131
|
+
</TMagicFormItem>
|
|
132
|
+
|
|
133
|
+
<TMagicTooltip v-if="config.tip" placement="left">
|
|
134
|
+
<TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
|
|
135
|
+
<template #content>
|
|
136
|
+
<div v-html="config.tip"></div>
|
|
137
|
+
</template>
|
|
138
|
+
</TMagicTooltip>
|
|
139
|
+
<!-- 当前内容 -->
|
|
140
|
+
<TMagicFormItem
|
|
141
|
+
:style="config.tip ? 'flex: 1' : ''"
|
|
142
|
+
:class="{ hidden: `${itemLabelWidth}` === '0' || !config.text }"
|
|
143
|
+
:prop="itemProp"
|
|
144
|
+
:label-width="itemLabelWidth"
|
|
145
|
+
:rules="rule"
|
|
146
|
+
style="background: #def7da"
|
|
40
147
|
>
|
|
41
148
|
<template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
|
|
42
149
|
<TMagicTooltip v-if="tooltip">
|
|
@@ -86,6 +193,8 @@
|
|
|
86
193
|
v-for="item in items"
|
|
87
194
|
:key="key(item)"
|
|
88
195
|
:model="name || name === 0 ? model[name] : model"
|
|
196
|
+
:last-values="name || name === 0 ? lastValues[name] : lastValues"
|
|
197
|
+
:is-compare="isCompare"
|
|
89
198
|
:config="item"
|
|
90
199
|
:size="size"
|
|
91
200
|
:disabled="disabled"
|
|
@@ -94,6 +203,7 @@
|
|
|
94
203
|
:label-width="itemLabelWidth"
|
|
95
204
|
:prop="itemProp"
|
|
96
205
|
@change="onChangeHandler"
|
|
206
|
+
@addDiffCount="onAddDiffCount"
|
|
97
207
|
></Container>
|
|
98
208
|
</template>
|
|
99
209
|
</template>
|
|
@@ -107,8 +217,9 @@
|
|
|
107
217
|
</template>
|
|
108
218
|
|
|
109
219
|
<script setup lang="ts" name="MFormContainer">
|
|
110
|
-
import { computed, inject, ref, resolveComponent, watchEffect } from 'vue';
|
|
220
|
+
import { computed, inject, ref, resolveComponent, watch, watchEffect } from 'vue';
|
|
111
221
|
import { WarningFilled } from '@element-plus/icons-vue';
|
|
222
|
+
import { isEqual } from 'lodash-es';
|
|
112
223
|
|
|
113
224
|
import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from '@tmagic/design';
|
|
114
225
|
|
|
@@ -117,7 +228,10 @@ import { display as displayFunction, filterFunction, getRules } from '../utils/f
|
|
|
117
228
|
|
|
118
229
|
const props = withDefaults(
|
|
119
230
|
defineProps<{
|
|
231
|
+
/** 表单值 */
|
|
120
232
|
model: FormValue;
|
|
233
|
+
/** 需对比的值(开启对比模式时传入) */
|
|
234
|
+
lastValues?: FormValue;
|
|
121
235
|
config: ChildConfig;
|
|
122
236
|
prop?: string;
|
|
123
237
|
disabled?: boolean;
|
|
@@ -125,15 +239,19 @@ const props = withDefaults(
|
|
|
125
239
|
expandMore?: boolean;
|
|
126
240
|
stepActive?: string | number;
|
|
127
241
|
size?: string;
|
|
242
|
+
/** 是否开启对比模式 */
|
|
243
|
+
isCompare?: boolean;
|
|
128
244
|
}>(),
|
|
129
245
|
{
|
|
130
246
|
prop: '',
|
|
131
247
|
size: 'small',
|
|
132
248
|
expandMore: false,
|
|
249
|
+
lastValues: () => ({}),
|
|
250
|
+
isCompare: false,
|
|
133
251
|
},
|
|
134
252
|
);
|
|
135
253
|
|
|
136
|
-
const emit = defineEmits(['change']);
|
|
254
|
+
const emit = defineEmits(['change', 'addDiffCount']);
|
|
137
255
|
|
|
138
256
|
const mForm = inject<FormState | undefined>('mForm');
|
|
139
257
|
|
|
@@ -141,6 +259,14 @@ const expand = ref(false);
|
|
|
141
259
|
|
|
142
260
|
const name = computed(() => props.config.name || '');
|
|
143
261
|
|
|
262
|
+
// 是否展示两个版本的对比内容
|
|
263
|
+
const showDiff = computed(() => {
|
|
264
|
+
if (!props.isCompare) return false;
|
|
265
|
+
const curValue = name.value ? props.model[name.value] : props.model;
|
|
266
|
+
const lastValue = name.value ? props.lastValues[name.value] : props.lastValues;
|
|
267
|
+
return !isEqual(curValue, lastValue);
|
|
268
|
+
});
|
|
269
|
+
|
|
144
270
|
const items = computed(() => (props.config as ContainerCommonConfig).items);
|
|
145
271
|
|
|
146
272
|
const itemProp = computed(() => {
|
|
@@ -196,6 +322,21 @@ watchEffect(() => {
|
|
|
196
322
|
expand.value = props.expandMore;
|
|
197
323
|
});
|
|
198
324
|
|
|
325
|
+
// 监听是否展示对比内容,如果出现差异项则触发差异数计数事件
|
|
326
|
+
watch(
|
|
327
|
+
showDiff,
|
|
328
|
+
(showDiff) => {
|
|
329
|
+
if (type.value === 'hidden') return;
|
|
330
|
+
if (items.value && !props.config.text && type.value && display.value) return;
|
|
331
|
+
if (display.value && showDiff && type.value) {
|
|
332
|
+
emit('addDiffCount');
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
immediate: true,
|
|
337
|
+
},
|
|
338
|
+
);
|
|
339
|
+
|
|
199
340
|
const expandHandler = () => (expand.value = !expand.value);
|
|
200
341
|
|
|
201
342
|
const key = (config: any) => config[mForm?.keyProps];
|
|
@@ -236,6 +377,9 @@ const trimHandler = (trim: any, value: FormValue | number | string) => {
|
|
|
236
377
|
}
|
|
237
378
|
};
|
|
238
379
|
|
|
380
|
+
// 继续抛出给更高层级的组件
|
|
381
|
+
const onAddDiffCount = () => emit('addDiffCount');
|
|
382
|
+
|
|
239
383
|
const onChangeHandler = async function (v: FormValue, key?: string) {
|
|
240
384
|
const { filter, onChange, trim, name, dynamicKey } = props.config as any;
|
|
241
385
|
let value: FormValue | number | string = v;
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
v-for="(item, index) in config.items"
|
|
25
25
|
:key="key(item, index)"
|
|
26
26
|
:model="name ? model[name] : model"
|
|
27
|
+
:lastValues="name ? lastValues[name] : lastValues"
|
|
28
|
+
:is-compare="isCompare"
|
|
27
29
|
:rules="name ? rules[name] : []"
|
|
28
30
|
:config="item"
|
|
29
31
|
:prop="prop"
|
|
@@ -31,6 +33,7 @@
|
|
|
31
33
|
:labelWidth="lWidth"
|
|
32
34
|
:size="size"
|
|
33
35
|
@change="change"
|
|
36
|
+
@add-diff-count="onAddDiffCount()"
|
|
34
37
|
></Container>
|
|
35
38
|
</div>
|
|
36
39
|
|
|
@@ -42,6 +45,8 @@
|
|
|
42
45
|
v-for="(item, index) in config.items"
|
|
43
46
|
:key="key(item, index)"
|
|
44
47
|
:model="name ? model[name] : model"
|
|
48
|
+
:lastValues="name ? lastValues[name] : lastValues"
|
|
49
|
+
:is-compare="isCompare"
|
|
45
50
|
:rules="name ? rules[name] : []"
|
|
46
51
|
:config="item"
|
|
47
52
|
:prop="prop"
|
|
@@ -49,6 +54,7 @@
|
|
|
49
54
|
:size="size"
|
|
50
55
|
:disabled="disabled"
|
|
51
56
|
@change="change"
|
|
57
|
+
@addDiffCount="onAddDiffCount()"
|
|
52
58
|
></Container>
|
|
53
59
|
</template>
|
|
54
60
|
</fieldset>
|
|
@@ -69,6 +75,8 @@ const props = withDefaults(
|
|
|
69
75
|
prop: string;
|
|
70
76
|
size?: string;
|
|
71
77
|
model: Record<string, any>;
|
|
78
|
+
lastValues?: Record<string, any>;
|
|
79
|
+
isCompare?: boolean;
|
|
72
80
|
config: FieldsetConfig;
|
|
73
81
|
rules?: any;
|
|
74
82
|
disabled?: boolean;
|
|
@@ -76,10 +84,12 @@ const props = withDefaults(
|
|
|
76
84
|
{
|
|
77
85
|
rules: {},
|
|
78
86
|
prop: '',
|
|
87
|
+
lastValues: () => ({}),
|
|
88
|
+
isCompare: false,
|
|
79
89
|
},
|
|
80
90
|
);
|
|
81
91
|
|
|
82
|
-
const emit = defineEmits(['change']);
|
|
92
|
+
const emit = defineEmits(['change', 'addDiffCount']);
|
|
83
93
|
|
|
84
94
|
const mForm = inject<FormState | undefined>('mForm');
|
|
85
95
|
|
|
@@ -113,4 +123,5 @@ if (props.config.checkbox && name.value) {
|
|
|
113
123
|
},
|
|
114
124
|
);
|
|
115
125
|
}
|
|
126
|
+
const onAddDiffCount = () => emit('addDiffCount');
|
|
116
127
|
</script>
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
v-for="(item, index) in model[name]"
|
|
11
11
|
:key="index"
|
|
12
12
|
:model="item"
|
|
13
|
+
:lastValues="getLastValues(lastValues[name], index)"
|
|
14
|
+
:is-compare="isCompare"
|
|
13
15
|
:config="config"
|
|
14
16
|
:prop="prop"
|
|
15
17
|
:index="index"
|
|
@@ -20,6 +22,7 @@
|
|
|
20
22
|
@remove-item="removeHandler"
|
|
21
23
|
@swap-item="swapHandler"
|
|
22
24
|
@change="changeHandler"
|
|
25
|
+
@addDiffCount="onAddDiffCount()"
|
|
23
26
|
></MFieldsGroupListItem>
|
|
24
27
|
|
|
25
28
|
<TMagicButton @click="addHandler" size="small" :disabled="disabled" v-if="addable">添加组</TMagicButton>
|
|
@@ -41,6 +44,8 @@ import MFieldsGroupListItem from './GroupListItem.vue';
|
|
|
41
44
|
|
|
42
45
|
const props = defineProps<{
|
|
43
46
|
model: any;
|
|
47
|
+
lastValues?: any;
|
|
48
|
+
isCompare?: boolean;
|
|
44
49
|
config: GroupListConfig;
|
|
45
50
|
name: string;
|
|
46
51
|
labelWidth?: string;
|
|
@@ -49,7 +54,7 @@ const props = defineProps<{
|
|
|
49
54
|
disabled?: boolean;
|
|
50
55
|
}>();
|
|
51
56
|
|
|
52
|
-
const emit = defineEmits(['change']);
|
|
57
|
+
const emit = defineEmits(['change', 'addDiffCount']);
|
|
53
58
|
|
|
54
59
|
const mForm = inject<FormState | undefined>('mForm');
|
|
55
60
|
|
|
@@ -123,4 +128,7 @@ const toggleMode = () => {
|
|
|
123
128
|
text: null,
|
|
124
129
|
}))) as any;
|
|
125
130
|
};
|
|
131
|
+
const onAddDiffCount = () => emit('addDiffCount');
|
|
132
|
+
|
|
133
|
+
const getLastValues = (item: any, index: number) => item?.[index] || {};
|
|
126
134
|
</script>
|
|
@@ -32,11 +32,14 @@
|
|
|
32
32
|
v-if="expand"
|
|
33
33
|
:config="rowConfig"
|
|
34
34
|
:model="model"
|
|
35
|
+
:lastValues="lastValues"
|
|
36
|
+
:is-compare="isCompare"
|
|
35
37
|
:labelWidth="labelWidth"
|
|
36
38
|
:prop="`${prop}${prop ? '.' : ''}${String(index)}`"
|
|
37
39
|
:size="size"
|
|
38
40
|
:disabled="disabled"
|
|
39
41
|
@change="changeHandler"
|
|
42
|
+
@addDiffCount="onAddDiffCount()"
|
|
40
43
|
></Container>
|
|
41
44
|
</div>
|
|
42
45
|
</template>
|
|
@@ -54,6 +57,8 @@ import Container from './Container.vue';
|
|
|
54
57
|
|
|
55
58
|
const props = defineProps<{
|
|
56
59
|
model: any;
|
|
60
|
+
lastValues: any;
|
|
61
|
+
isCompare?: boolean;
|
|
57
62
|
groupModel: any[];
|
|
58
63
|
config: GroupListConfig;
|
|
59
64
|
labelWidth?: string;
|
|
@@ -63,7 +68,7 @@ const props = defineProps<{
|
|
|
63
68
|
disabled?: boolean;
|
|
64
69
|
}>();
|
|
65
70
|
|
|
66
|
-
const emit = defineEmits(['swap-item', 'remove-item', 'change']);
|
|
71
|
+
const emit = defineEmits(['swap-item', 'remove-item', 'change', 'addDiffCount']);
|
|
67
72
|
|
|
68
73
|
const mForm = inject<FormState | undefined>('mForm');
|
|
69
74
|
const expand = ref(false);
|
|
@@ -122,4 +127,5 @@ const movable = () => {
|
|
|
122
127
|
}
|
|
123
128
|
return movable;
|
|
124
129
|
};
|
|
130
|
+
const onAddDiffCount = () => emit('addDiffCount');
|
|
125
131
|
</script>
|
package/src/containers/Panel.vue
CHANGED
|
@@ -23,11 +23,14 @@
|
|
|
23
23
|
:key="item[mForm?.keyProp || '__key'] ?? index"
|
|
24
24
|
:config="item"
|
|
25
25
|
:model="name ? model[name] : model"
|
|
26
|
+
:lastValues="name ? lastValues[name] : lastValues"
|
|
27
|
+
:is-compare="isCompare"
|
|
26
28
|
:prop="prop"
|
|
27
29
|
:size="size"
|
|
28
30
|
:disabled="disabled"
|
|
29
31
|
:label-width="config.labelWidth || labelWidth"
|
|
30
32
|
@change="changeHandler"
|
|
33
|
+
@addDiffCount="onAddDiffCount()"
|
|
31
34
|
></Container>
|
|
32
35
|
</div>
|
|
33
36
|
|
|
@@ -40,11 +43,14 @@
|
|
|
40
43
|
:key="item[mForm?.keyProp || '__key'] ?? index"
|
|
41
44
|
:config="item"
|
|
42
45
|
:model="name ? model[name] : model"
|
|
46
|
+
:lastValues="name ? lastValues[name] : lastValues"
|
|
47
|
+
:is-compare="isCompare"
|
|
43
48
|
:prop="prop"
|
|
44
49
|
:size="size"
|
|
45
50
|
:disabled="disabled"
|
|
46
51
|
:label-width="config.labelWidth || labelWidth"
|
|
47
52
|
@change="changeHandler"
|
|
53
|
+
@addDiffCount="onAddDiffCount()"
|
|
48
54
|
></Container>
|
|
49
55
|
</template>
|
|
50
56
|
</div>
|
|
@@ -64,6 +70,8 @@ import Container from './Container.vue';
|
|
|
64
70
|
|
|
65
71
|
const props = defineProps<{
|
|
66
72
|
model: any;
|
|
73
|
+
lastValues?: any;
|
|
74
|
+
isCompare?: boolean;
|
|
67
75
|
config: PanelConfig;
|
|
68
76
|
name: string;
|
|
69
77
|
labelWidth?: string;
|
|
@@ -72,7 +80,7 @@ const props = defineProps<{
|
|
|
72
80
|
disabled?: boolean;
|
|
73
81
|
}>();
|
|
74
82
|
|
|
75
|
-
const emit = defineEmits(['change']);
|
|
83
|
+
const emit = defineEmits(['change', 'addDiffCount']);
|
|
76
84
|
|
|
77
85
|
const mForm = inject<FormState | undefined>('mForm');
|
|
78
86
|
|
|
@@ -83,4 +91,5 @@ const items = computed(() => props.config.items);
|
|
|
83
91
|
const filter = (config: any) => filterFunction(mForm, config, props);
|
|
84
92
|
|
|
85
93
|
const changeHandler = () => emit('change', props.model);
|
|
94
|
+
const onAddDiffCount = () => emit('addDiffCount');
|
|
86
95
|
</script>
|
package/src/containers/Row.vue
CHANGED
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
:labelWidth="config.labelWidth || labelWidth"
|
|
9
9
|
:expandMore="expandMore"
|
|
10
10
|
:model="name ? model[name] : model"
|
|
11
|
+
:lastValues="name ? lastValues[name] : lastValues"
|
|
12
|
+
:is-compare="isCompare"
|
|
11
13
|
:prop="prop"
|
|
12
14
|
:size="size"
|
|
13
15
|
:disabled="disabled"
|
|
14
16
|
@change="changeHandler"
|
|
17
|
+
@add-diff-count="onAddDiffCount"
|
|
15
18
|
/>
|
|
16
19
|
</TMagicRow>
|
|
17
20
|
</template>
|
|
@@ -27,6 +30,8 @@ import Col from './Col.vue';
|
|
|
27
30
|
|
|
28
31
|
const props = defineProps<{
|
|
29
32
|
model: any;
|
|
33
|
+
lastValues?: any;
|
|
34
|
+
isCompare?: boolean;
|
|
30
35
|
config: RowConfig;
|
|
31
36
|
name: string;
|
|
32
37
|
labelWidth?: string;
|
|
@@ -36,9 +41,10 @@ const props = defineProps<{
|
|
|
36
41
|
disabled?: boolean;
|
|
37
42
|
}>();
|
|
38
43
|
|
|
39
|
-
const emit = defineEmits(['change']);
|
|
44
|
+
const emit = defineEmits(['change', 'addDiffCount']);
|
|
40
45
|
|
|
41
46
|
const mForm = inject<FormState | undefined>('mForm');
|
|
42
47
|
|
|
43
48
|
const changeHandler = () => emit('change', props.name ? props.model[props.name] : props.model);
|
|
49
|
+
const onAddDiffCount = () => emit('addDiffCount');
|
|
44
50
|
</script>
|
package/src/containers/Step.vue
CHANGED
|
@@ -18,11 +18,14 @@
|
|
|
18
18
|
:key="item[mForm?.keyProp || '__key']"
|
|
19
19
|
:config="item"
|
|
20
20
|
:model="step.name ? model[step.name] : model"
|
|
21
|
+
:lastValues="step.name ? lastValues[step.name] : lastValues"
|
|
22
|
+
:is-compare="isCompare"
|
|
21
23
|
:prop="`${step.name}`"
|
|
22
24
|
:size="size"
|
|
23
25
|
:disabled="disabled"
|
|
24
26
|
:label-width="config.labelWidth || labelWidth"
|
|
25
27
|
@change="changeHandler"
|
|
28
|
+
@addDiffCount="onAddDiffCount()"
|
|
26
29
|
></Container>
|
|
27
30
|
</template>
|
|
28
31
|
</template>
|
|
@@ -41,6 +44,8 @@ import Container from './Container.vue';
|
|
|
41
44
|
const props = withDefaults(
|
|
42
45
|
defineProps<{
|
|
43
46
|
model: any;
|
|
47
|
+
lastValues?: any;
|
|
48
|
+
isCompare?: boolean;
|
|
44
49
|
config: StepConfig;
|
|
45
50
|
stepActive?: number;
|
|
46
51
|
labelWidth?: string;
|
|
@@ -52,7 +57,7 @@ const props = withDefaults(
|
|
|
52
57
|
},
|
|
53
58
|
);
|
|
54
59
|
|
|
55
|
-
const emit = defineEmits(['change']);
|
|
60
|
+
const emit = defineEmits(['change', 'addDiffCount']);
|
|
56
61
|
|
|
57
62
|
const mForm = inject<FormState | undefined>('mForm');
|
|
58
63
|
const active = ref(1);
|
|
@@ -69,4 +74,5 @@ const stepClick = (index: number) => {
|
|
|
69
74
|
const changeHandler = () => {
|
|
70
75
|
emit('change', props.model);
|
|
71
76
|
};
|
|
77
|
+
const onAddDiffCount = () => emit('addDiffCount');
|
|
72
78
|
</script>
|