@tmagic/form 1.5.0-beta.14 → 1.5.0-beta.16

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.0-beta.14",
2
+ "version": "1.5.0-beta.16",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -32,11 +32,13 @@
32
32
  "node": ">=18"
33
33
  },
34
34
  "repository": {
35
+ "directory": "packages/form",
35
36
  "type": "git",
36
37
  "url": "https://github.com/Tencent/tmagic-editor.git"
37
38
  },
38
39
  "dependencies": {
39
40
  "@element-plus/icons-vue": "^2.3.1",
41
+ "@popperjs/core": "^2.11.8",
40
42
  "dayjs": "^1.11.11",
41
43
  "lodash-es": "^4.17.21",
42
44
  "sortablejs": "^1.15.2"
@@ -46,17 +48,17 @@
46
48
  "@types/node": "^18.19.0",
47
49
  "@types/sortablejs": "^1.15.8",
48
50
  "@vitejs/plugin-vue": "^5.1.3",
49
- "@vue/compiler-sfc": "^3.5.0",
51
+ "@vue/compiler-sfc": "^3.5.12",
50
52
  "@vue/test-utils": "^2.4.6",
51
53
  "rimraf": "^3.0.2",
52
54
  "sass": "^1.78.0",
53
- "vite": "^5.4.3"
55
+ "vite": "^5.4.10"
54
56
  },
55
57
  "peerDependencies": {
56
- "vue": "^3.5.0",
58
+ "vue": ">=3.5.0",
57
59
  "typescript": "*",
58
- "@tmagic/design": "1.5.0-beta.14",
59
- "@tmagic/utils": "1.5.0-beta.14"
60
+ "@tmagic/utils": "1.5.0-beta.16",
61
+ "@tmagic/design": "1.5.0-beta.16"
60
62
  },
61
63
  "peerDependenciesMeta": {
62
64
  "typescript": {
package/src/Form.vue CHANGED
@@ -28,15 +28,15 @@
28
28
  </template>
29
29
 
30
30
  <script setup lang="ts">
31
- import { provide, reactive, ref, toRaw, watch, watchEffect } from 'vue';
31
+ import { provide, reactive, ref, shallowRef, toRaw, watch, watchEffect } from 'vue';
32
32
  import { cloneDeep, isEqual } from 'lodash-es';
33
33
 
34
- import { TMagicForm } from '@tmagic/design';
34
+ import { TMagicForm, tMagicMessage, tMagicMessageBox } from '@tmagic/design';
35
35
 
36
36
  import Container from './containers/Container.vue';
37
37
  import { getConfig } from './utils/config';
38
38
  import { initValue } from './utils/form';
39
- import type { FormConfig, FormState, FormValue, ValidateError } from './schema';
39
+ import type { ChangeRecord, ContainerChangeEventData, FormConfig, FormState, FormValue, ValidateError } from './schema';
40
40
 
41
41
  defineOptions({
42
42
  name: 'MForm',
@@ -81,7 +81,7 @@ const props = withDefaults(
81
81
  },
82
82
  );
83
83
 
84
- const emit = defineEmits(['change', 'error', 'field-input', 'field-change']);
84
+ const emit = defineEmits(['change', 'error', 'field-input', 'field-change', 'update:stepActive']);
85
85
 
86
86
  const tMagicForm = ref<InstanceType<typeof TMagicForm>>();
87
87
  const initialized = ref(false);
@@ -106,6 +106,8 @@ const formState: FormState = reactive<FormState>({
106
106
  setField: (prop: string, field: any) => fields.set(prop, field),
107
107
  getField: (prop: string) => fields.get(prop),
108
108
  deleteField: (prop: string) => fields.delete(prop),
109
+ $messageBox: tMagicMessageBox,
110
+ $message: tMagicMessage,
109
111
  post: (options: any) => {
110
112
  if (requestFuc) {
111
113
  return requestFuc({
@@ -135,9 +137,13 @@ watchEffect(async () => {
135
137
 
136
138
  provide('mForm', formState);
137
139
 
140
+ const changeRecords = shallowRef<ChangeRecord[]>([]);
141
+
138
142
  watch(
139
143
  [() => props.config, () => props.initValues],
140
144
  ([config], [preConfig]) => {
145
+ changeRecords.value = [];
146
+
141
147
  if (!isEqual(toRaw(config), toRaw(preConfig))) {
142
148
  initialized.value = false;
143
149
  }
@@ -165,8 +171,11 @@ watch(
165
171
  { immediate: true },
166
172
  );
167
173
 
168
- const changeHandler = () => {
169
- emit('change', values.value);
174
+ const changeHandler = (v: FormValue, eventData: ContainerChangeEventData) => {
175
+ if (eventData.changeRecords?.length) {
176
+ changeRecords.value.push(...eventData.changeRecords);
177
+ }
178
+ emit('change', values.value, eventData);
170
179
  };
171
180
 
172
181
  const submitHandler = (e: SubmitEvent) => {
@@ -180,10 +189,14 @@ defineExpose({
180
189
  lastValuesProcessed,
181
190
  formState,
182
191
  initialized,
192
+ changeRecords,
183
193
 
184
194
  changeHandler,
185
195
 
186
- resetForm: () => tMagicForm.value?.resetFields(),
196
+ resetForm: () => {
197
+ tMagicForm.value?.resetFields();
198
+ changeRecords.value = [];
199
+ },
187
200
 
188
201
  submitForm: async (native?: boolean): Promise<any> => {
189
202
  try {
package/src/FormBox.vue CHANGED
@@ -40,7 +40,7 @@ import { computed, ref, watchEffect } from 'vue';
40
40
  import { TMagicButton, TMagicScrollbar } from '@tmagic/design';
41
41
 
42
42
  import Form from './Form.vue';
43
- import type { FormConfig } from './schema';
43
+ import type { ContainerChangeEventData, FormConfig, FormValue } from './schema';
44
44
 
45
45
  defineOptions({
46
46
  name: 'MFormBox',
@@ -68,7 +68,11 @@ const props = withDefaults(
68
68
  },
69
69
  );
70
70
 
71
- const emit = defineEmits(['submit', 'change', 'error']);
71
+ const emit = defineEmits<{
72
+ change: [v: any, eventData: ContainerChangeEventData];
73
+ submit: [v: any, eventData: ContainerChangeEventData];
74
+ error: [e: any];
75
+ }>();
72
76
 
73
77
  const footerHeight = 60;
74
78
 
@@ -98,14 +102,14 @@ watchEffect(() => {
98
102
  const submitHandler = async () => {
99
103
  try {
100
104
  const values = await form.value?.submitForm();
101
- emit('submit', values);
105
+ emit('submit', values, { changeRecords: form.value?.changeRecords });
102
106
  } catch (e) {
103
107
  emit('error', e);
104
108
  }
105
109
  };
106
110
 
107
- const changeHandler = (value: any) => {
108
- emit('change', value);
111
+ const changeHandler = (value: FormValue, eventData: ContainerChangeEventData) => {
112
+ emit('change', value, eventData);
109
113
  };
110
114
 
111
115
  const show = () => {};
@@ -65,7 +65,7 @@ import { computed, ref } from 'vue';
65
65
  import { TMagicButton, TMagicCol, TMagicDialog, TMagicRow } from '@tmagic/design';
66
66
 
67
67
  import Form from './Form.vue';
68
- import { FormConfig, StepConfig } from './schema';
68
+ import { ContainerChangeEventData, FormConfig, FormValue, StepConfig } from './schema';
69
69
 
70
70
  defineOptions({
71
71
  name: 'MFormDialog',
@@ -132,7 +132,7 @@ const closeHandler = () => {
132
132
  const save = async () => {
133
133
  try {
134
134
  const values = await form.value?.submitForm();
135
- emit('submit', values);
135
+ emit('submit', values, { changeRecords: form.value?.changeRecords });
136
136
  } catch (e) {
137
137
  emit('error', e);
138
138
  }
@@ -146,8 +146,8 @@ const nextStep = () => {
146
146
  stepActive.value += 1;
147
147
  };
148
148
 
149
- const changeHandler = (value: any) => {
150
- emit('change', value);
149
+ const changeHandler = (value: FormValue, eventData: ContainerChangeEventData) => {
150
+ emit('change', value, eventData);
151
151
  };
152
152
 
153
153
  const show = () => {
@@ -59,7 +59,7 @@ import { ref, watchEffect } from 'vue';
59
59
  import { TMagicButton, TMagicCol, TMagicDrawer, TMagicRow } from '@tmagic/design';
60
60
 
61
61
  import Form from './Form.vue';
62
- import type { FormConfig } from './schema';
62
+ import type { ContainerChangeEventData, FormConfig, FormValue } from './schema';
63
63
 
64
64
  defineOptions({
65
65
  name: 'MFormDialog',
@@ -110,14 +110,14 @@ watchEffect(() => {
110
110
  const submitHandler = async () => {
111
111
  try {
112
112
  const values = await form.value?.submitForm();
113
- emit('submit', values);
113
+ emit('submit', values, { changeRecords: form.value?.changeRecords });
114
114
  } catch (e) {
115
115
  emit('error', e);
116
116
  }
117
117
  };
118
118
 
119
- const changeHandler = (value: any) => {
120
- emit('change', value);
119
+ const changeHandler = (value: FormValue, eventData: ContainerChangeEventData) => {
120
+ emit('change', value, eventData);
121
121
  };
122
122
 
123
123
  const openHandler = () => {
@@ -21,7 +21,7 @@ import { computed, inject } from 'vue';
21
21
 
22
22
  import { TMagicCol } from '@tmagic/design';
23
23
 
24
- import { ChildConfig, FormState } from '../schema';
24
+ import type { ChildConfig, ContainerChangeEventData, FormState } from '../schema';
25
25
  import { display as displayFunction } from '../utils/form';
26
26
 
27
27
  import Container from './Container.vue';
@@ -43,10 +43,13 @@ const props = defineProps<{
43
43
  disabled?: boolean;
44
44
  }>();
45
45
 
46
- const emit = defineEmits(['change', 'addDiffCount']);
46
+ const emit = defineEmits<{
47
+ change: [v: any, eventData: ContainerChangeEventData];
48
+ addDiffCount: [];
49
+ }>();
47
50
 
48
51
  const mForm = inject<FormState | undefined>('mForm');
49
52
  const display = computed(() => displayFunction(mForm, props.config.display, props));
50
- const changeHandler = () => emit('change', props.model);
53
+ const changeHandler = (v: any, eventData: ContainerChangeEventData) => emit('change', v, eventData);
51
54
  const onAddDiffCount = () => emit('addDiffCount');
52
55
  </script>
@@ -191,12 +191,12 @@
191
191
  </template>
192
192
 
193
193
  <template v-else-if="items && display">
194
- <template v-if="name || name === 0 ? model[name] : model">
194
+ <template v-if="isValidName() ? model[name] : model">
195
195
  <Container
196
196
  v-for="item in items"
197
197
  :key="key(item)"
198
- :model="name || name === 0 ? model[name] : model"
199
- :last-values="name || name === 0 ? lastValues[name] || {} : lastValues"
198
+ :model="isValidName() ? model[name] : model"
199
+ :last-values="isValidName() ? lastValues[name] || {} : lastValues"
200
200
  :is-compare="isCompare"
201
201
  :config="item"
202
202
  :size="size"
@@ -220,13 +220,20 @@
220
220
  </template>
221
221
 
222
222
  <script setup lang="ts">
223
- import { computed, inject, ref, watch, watchEffect } from 'vue';
223
+ import { computed, inject, ref, toRaw, watch, watchEffect } from 'vue';
224
224
  import { WarningFilled } from '@element-plus/icons-vue';
225
225
  import { isEqual } from 'lodash-es';
226
226
 
227
227
  import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from '@tmagic/design';
228
228
 
229
- import { ChildConfig, ContainerCommonConfig, FormState, FormValue, TypeFunction } from '../schema';
229
+ import type {
230
+ ChildConfig,
231
+ ContainerChangeEventData,
232
+ ContainerCommonConfig,
233
+ FormState,
234
+ FormValue,
235
+ TypeFunction,
236
+ } from '../schema';
230
237
  import { display as displayFunction, filterFunction, getRules } from '../utils/form';
231
238
 
232
239
  defineOptions({
@@ -258,7 +265,10 @@ const props = withDefaults(
258
265
  },
259
266
  );
260
267
 
261
- const emit = defineEmits(['change', 'addDiffCount']);
268
+ const emit = defineEmits<{
269
+ change: [v: any, eventData: ContainerChangeEventData];
270
+ addDiffCount: [];
271
+ }>();
262
272
 
263
273
  const mForm = inject<FormState | undefined>('mForm');
264
274
 
@@ -285,7 +295,12 @@ const itemProp = computed(() => {
285
295
  } else {
286
296
  return props.prop;
287
297
  }
288
- return `${props.prop}${props.prop ? '.' : ''}${n}`;
298
+
299
+ if (typeof props.prop !== 'undefined' && props.prop !== '') {
300
+ return `${props.prop}.${n}`;
301
+ }
302
+
303
+ return `${n}`;
289
304
  });
290
305
 
291
306
  const tagName = computed(() => `m-${items.value ? 'form' : 'fields'}-${type.value}`);
@@ -360,18 +375,6 @@ const filterHandler = (filter: any, value: FormValue | number | string) => {
360
375
  return value;
361
376
  };
362
377
 
363
- const changeHandler = (onChange: any, value: FormValue | number | string) => {
364
- if (typeof onChange === 'function') {
365
- return onChange(mForm, value, {
366
- model: props.model,
367
- values: mForm?.initValues,
368
- formValue: mForm?.values,
369
- prop: itemProp.value,
370
- config: props.config,
371
- });
372
- }
373
- };
374
-
375
378
  const trimHandler = (trim: any, value: FormValue | number | string) => {
376
379
  if (typeof value === 'string' && trim) {
377
380
  return value.replace(/^\s*/, '').replace(/\s*$/, '');
@@ -381,28 +384,80 @@ const trimHandler = (trim: any, value: FormValue | number | string) => {
381
384
  // 继续抛出给更高层级的组件
382
385
  const onAddDiffCount = () => emit('addDiffCount');
383
386
 
384
- const onChangeHandler = async function (v: FormValue, key?: string) {
385
- const { filter, onChange, trim, name, dynamicKey } = props.config as any;
386
- let value: FormValue | number | string = v;
387
+ const hasModifyKey = (eventDataItem: ContainerChangeEventData) =>
388
+ typeof eventDataItem?.modifyKey !== 'undefined' && eventDataItem.modifyKey !== '';
389
+
390
+ const isValidName = () => {
391
+ const valueType = typeof name.value;
392
+ if (valueType !== 'string' && valueType !== 'symbol' && valueType !== 'number') {
393
+ return false;
394
+ }
395
+
396
+ if (name.value === '') {
397
+ return false;
398
+ }
399
+
400
+ if (typeof name.value === 'number') {
401
+ return name.value >= 0;
402
+ }
403
+
404
+ return true;
405
+ };
406
+
407
+ const onChangeHandler = async function (v: any, eventData: ContainerChangeEventData = {}) {
408
+ const { filter, onChange, trim, dynamicKey } = props.config as any;
409
+ let value: FormValue | number | string | any[] = toRaw(v);
410
+ const changeRecords = eventData.changeRecords || [];
411
+ const newChangeRecords = [...changeRecords];
387
412
 
388
413
  try {
389
414
  value = filterHandler(filter, v);
390
- value = (await changeHandler(onChange, value)) ?? value;
415
+
416
+ if (typeof onChange === 'function') {
417
+ value =
418
+ (await onChange(mForm, value, {
419
+ model: props.model,
420
+ values: mForm?.initValues,
421
+ formValue: mForm?.values,
422
+ prop: itemProp.value,
423
+ config: props.config,
424
+ changeRecords: newChangeRecords,
425
+ })) ?? value;
426
+ }
391
427
  value = trimHandler(trim, value) ?? value;
392
428
  } catch (e) {
393
429
  console.error(e);
394
430
  }
395
431
 
396
- // field内容下包含field-link时,model===value, 这里避免循环引用
397
- if ((name || name === 0) && props.model !== value && (v !== value || props.model[name] !== value)) {
432
+ let valueProp = itemProp.value;
433
+
434
+ if (hasModifyKey(eventData)) {
435
+ if (dynamicKey) {
436
+ props.model[eventData.modifyKey!] = value;
437
+ } else if (isValidName()) {
438
+ props.model[name.value][eventData.modifyKey!] = value;
439
+ }
440
+
441
+ valueProp = valueProp ? `${valueProp}.${eventData.modifyKey}` : eventData.modifyKey!;
442
+
443
+ // 需要清除掉modifyKey,不然往上层抛出后还会被认为需要修改
444
+ delete eventData.modifyKey;
445
+ } else if (isValidName() && props.model !== value && (v !== value || props.model[name.value] !== value)) {
446
+ // field内容下包含field-link时,model===value, 这里避免循环引用
398
447
  // eslint-disable-next-line vue/no-mutating-props
399
- props.model[name] = value;
448
+ props.model[name.value] = value;
400
449
  }
401
- // 动态表单类型,根据value和key参数,直接修改model
402
- if (key !== undefined && dynamicKey) {
403
- // eslint-disable-next-line vue/no-mutating-props
404
- props.model[key] = value;
450
+
451
+ if (changeRecords.length === 0) {
452
+ newChangeRecords.push({
453
+ propPath: valueProp,
454
+ value,
455
+ });
405
456
  }
406
- emit('change', props.model);
457
+
458
+ emit('change', props.model, {
459
+ ...eventData,
460
+ changeRecords: newChangeRecords,
461
+ });
407
462
  };
408
463
  </script>
@@ -6,7 +6,7 @@
6
6
  :prop="`${prop}${prop ? '.' : ''}${config.name}.value`"
7
7
  :true-value="1"
8
8
  :false-value="0"
9
- @update:modelValue="change"
9
+ @update:modelValue="valueChangeHandler"
10
10
  ><span v-html="config.legend"></span><span v-if="config.extra" v-html="config.extra" class="m-form-tip"></span
11
11
  ></TMagicCheckbox>
12
12
  </component>
@@ -29,7 +29,7 @@
29
29
  :disabled="disabled"
30
30
  :labelWidth="lWidth"
31
31
  :size="size"
32
- @change="change"
32
+ @change="changeHandler"
33
33
  @add-diff-count="onAddDiffCount()"
34
34
  ></Container>
35
35
  </div>
@@ -50,7 +50,7 @@
50
50
  :labelWidth="lWidth"
51
51
  :size="size"
52
52
  :disabled="disabled"
53
- @change="change"
53
+ @change="changeHandler"
54
54
  @addDiffCount="onAddDiffCount()"
55
55
  ></Container>
56
56
  </template>
@@ -62,7 +62,7 @@ import { computed, inject } from 'vue';
62
62
 
63
63
  import { TMagicCheckbox } from '@tmagic/design';
64
64
 
65
- import { FieldsetConfig, FormState } from '../schema';
65
+ import { ContainerChangeEventData, FieldsetConfig, FormState } from '../schema';
66
66
 
67
67
  import Container from './Container.vue';
68
68
 
@@ -90,7 +90,10 @@ const props = withDefaults(
90
90
  },
91
91
  );
92
92
 
93
- const emit = defineEmits(['change', 'addDiffCount']);
93
+ const emit = defineEmits<{
94
+ change: [v: any, eventData: ContainerChangeEventData];
95
+ addDiffCount: [];
96
+ }>();
94
97
 
95
98
  const mForm = inject<FormState | undefined>('mForm');
96
99
 
@@ -110,10 +113,12 @@ const lWidth = computed(() => {
110
113
  return props.config.labelWidth || props.labelWidth || (props.config.text ? undefined : '0');
111
114
  });
112
115
 
113
- const change = () => {
114
- emit('change', props.model);
116
+ const valueChangeHandler = (value: number | boolean) => {
117
+ emit('change', value, { modifyKey: 'value' });
115
118
  };
116
119
 
120
+ const changeHandler = (v: any, eventData: ContainerChangeEventData) => emit('change', v, eventData);
121
+
117
122
  const key = (item: any, index: number) => item[mForm?.keyProp || '__key'] ?? index;
118
123
 
119
124
  const onAddDiffCount = () => emit('addDiffCount');
@@ -25,7 +25,14 @@
25
25
  @addDiffCount="onAddDiffCount()"
26
26
  ></MFieldsGroupListItem>
27
27
 
28
- <TMagicButton @click="addHandler" type="primary" :disabled="disabled" v-if="addable">新增</TMagicButton>
28
+ <TMagicButton
29
+ v-if="addable"
30
+ type="primary"
31
+ :size="config.enableToggleMode ? 'small' : 'default'"
32
+ :disabled="disabled"
33
+ @click="addHandler"
34
+ >新增</TMagicButton
35
+ >
29
36
 
30
37
  <TMagicButton :icon="Grid" size="small" @click="toggleMode" v-if="config.enableToggleMode">切换为表格</TMagicButton>
31
38
  </div>
@@ -37,7 +44,7 @@ import { Grid } from '@element-plus/icons-vue';
37
44
 
38
45
  import { TMagicButton } from '@tmagic/design';
39
46
 
40
- import { FormState, GroupListConfig } from '../schema';
47
+ import type { ContainerChangeEventData, FormState, GroupListConfig } from '../schema';
41
48
  import { initValue } from '../utils/form';
42
49
 
43
50
  import MFieldsGroupListItem from './GroupListItem.vue';
@@ -58,7 +65,10 @@ const props = defineProps<{
58
65
  disabled?: boolean;
59
66
  }>();
60
67
 
61
- const emit = defineEmits(['change', 'addDiffCount']);
68
+ const emit = defineEmits<{
69
+ change: [v: any, eventData?: ContainerChangeEventData];
70
+ addDiffCount: [];
71
+ }>();
62
72
 
63
73
  const mForm = inject<FormState | undefined>('mForm');
64
74
 
@@ -77,10 +87,8 @@ const addable = computed(() => {
77
87
  return typeof props.config.addable === 'undefined' ? true : props.config.addable;
78
88
  });
79
89
 
80
- const changeHandler = () => {
81
- if (!props.name) return false;
82
-
83
- emit('change', props.model[props.name]);
90
+ const changeHandler = (v: any, eventData: ContainerChangeEventData) => {
91
+ emit('change', props.model, eventData);
84
92
  };
85
93
 
86
94
  const addHandler = async () => {
@@ -105,14 +113,22 @@ const addHandler = async () => {
105
113
  });
106
114
 
107
115
  props.model[props.name].push(groupValue);
108
- changeHandler();
116
+
117
+ emit('change', props.model[props.name], {
118
+ changeRecords: [
119
+ {
120
+ propPath: `${props.prop}.${props.model[props.name].length - 1}`,
121
+ value: groupValue,
122
+ },
123
+ ],
124
+ });
109
125
  };
110
126
 
111
127
  const removeHandler = (index: number) => {
112
128
  if (!props.name) return false;
113
129
 
114
130
  props.model[props.name].splice(index, 1);
115
- changeHandler();
131
+ emit('change', props.model[props.name]);
116
132
  };
117
133
 
118
134
  const swapHandler = (idx1: number, idx2: number) => {
@@ -120,7 +136,7 @@ const swapHandler = (idx1: number, idx2: number) => {
120
136
 
121
137
  const [currRow] = props.model[props.name].splice(idx1, 1);
122
138
  props.model[props.name].splice(idx2, 0, currRow);
123
- changeHandler();
139
+ emit('change', props.model[props.name]);
124
140
  };
125
141
 
126
142
  const toggleMode = () => {
@@ -48,7 +48,7 @@ import { CaretBottom, CaretRight, CaretTop, Delete } from '@element-plus/icons-v
48
48
 
49
49
  import { TMagicButton, TMagicIcon } from '@tmagic/design';
50
50
 
51
- import { FormState, GroupListConfig } from '../schema';
51
+ import type { ContainerChangeEventData, FormState, GroupListConfig } from '../schema';
52
52
  import { filterFunction } from '../utils/form';
53
53
 
54
54
  import Container from './Container.vue';
@@ -103,7 +103,9 @@ const itemExtra = computed(() => filterFunction(mForm, props.config.itemExtra, p
103
103
 
104
104
  const removeHandler = () => emit('remove-item', props.index);
105
105
 
106
- const changeHandler = () => emit('change');
106
+ const changeHandler = (v: any, eventData: ContainerChangeEventData) => {
107
+ emit('change', props.model, eventData);
108
+ };
107
109
 
108
110
  const expandHandler = () => {
109
111
  expand.value = !expand.value;
@@ -63,7 +63,7 @@ import { CaretBottom, CaretRight } from '@element-plus/icons-vue';
63
63
 
64
64
  import { TMagicButton, TMagicCard } from '@tmagic/design';
65
65
 
66
- import { FormState, PanelConfig } from '../schema';
66
+ import type { ContainerChangeEventData, FormState, PanelConfig } from '../schema';
67
67
  import { filterFunction } from '../utils/form';
68
68
 
69
69
  import Container from './Container.vue';
@@ -84,7 +84,10 @@ const props = defineProps<{
84
84
  disabled?: boolean;
85
85
  }>();
86
86
 
87
- const emit = defineEmits(['change', 'addDiffCount']);
87
+ const emit = defineEmits<{
88
+ change: [v: any, eventData: ContainerChangeEventData];
89
+ addDiffCount: [];
90
+ }>();
88
91
 
89
92
  const mForm = inject<FormState | undefined>('mForm');
90
93
 
@@ -94,6 +97,8 @@ const items = computed(() => props.config.items);
94
97
 
95
98
  const filter = (config: any) => filterFunction(mForm, config, props);
96
99
 
97
- const changeHandler = () => emit('change', props.model);
100
+ const changeHandler = (v: any, eventData: ContainerChangeEventData) => {
101
+ emit('change', props.model, eventData);
102
+ };
98
103
  const onAddDiffCount = () => emit('addDiffCount');
99
104
  </script>
@@ -24,7 +24,7 @@ import { inject } from 'vue';
24
24
 
25
25
  import { TMagicRow } from '@tmagic/design';
26
26
 
27
- import { FormState, RowConfig } from '../schema';
27
+ import type { ContainerChangeEventData, FormState, RowConfig } from '../schema';
28
28
 
29
29
  import Col from './Col.vue';
30
30
 
@@ -45,10 +45,15 @@ const props = defineProps<{
45
45
  disabled?: boolean;
46
46
  }>();
47
47
 
48
- const emit = defineEmits(['change', 'addDiffCount']);
48
+ const emit = defineEmits<{
49
+ change: [v: any, eventData: ContainerChangeEventData];
50
+ addDiffCount: [];
51
+ }>();
49
52
 
50
53
  const mForm = inject<FormState | undefined>('mForm');
51
54
 
52
- const changeHandler = () => emit('change', props.name ? props.model[props.name] : props.model);
55
+ const changeHandler = (v: any, eventData: ContainerChangeEventData) => {
56
+ emit('change', props.name ? props.model[props.name] : props.model, eventData);
57
+ };
53
58
  const onAddDiffCount = () => emit('addDiffCount');
54
59
  </script>