@tmagic/form 1.0.0-beta.8 → 1.0.0-rc.11

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.
@@ -0,0 +1,42 @@
1
+ import type { DefineComponent, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
2
+ import { ChildConfig, FormState } from '../schema';
3
+ declare const _default: DefineComponent<{
4
+ labelWidth: StringConstructor;
5
+ expandMore: BooleanConstructor;
6
+ span: NumberConstructor;
7
+ model: {
8
+ type: ObjectConstructor;
9
+ default: () => {};
10
+ };
11
+ config: {
12
+ type: PropType<ChildConfig>;
13
+ default: () => {};
14
+ };
15
+ prop: StringConstructor;
16
+ size: StringConstructor;
17
+ }, {
18
+ mForm: FormState | undefined;
19
+ display: ComputedRef<any>;
20
+ changeHandler: () => void;
21
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "change"[], "change", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
22
+ labelWidth: StringConstructor;
23
+ expandMore: BooleanConstructor;
24
+ span: NumberConstructor;
25
+ model: {
26
+ type: ObjectConstructor;
27
+ default: () => {};
28
+ };
29
+ config: {
30
+ type: PropType<ChildConfig>;
31
+ default: () => {};
32
+ };
33
+ prop: StringConstructor;
34
+ size: StringConstructor;
35
+ }>> & {
36
+ onChange?: ((...args: any[]) => any) | undefined;
37
+ }, {
38
+ config: ChildConfig;
39
+ model: Record<string, any>;
40
+ expandMore: boolean;
41
+ }>;
42
+ export default _default;
@@ -30,6 +30,7 @@ declare const _default: DefineComponent<{
30
30
  itemProp: ComputedRef<string>;
31
31
  items: ComputedRef<FormConfig>;
32
32
  display: ComputedRef<boolean>;
33
+ itemLabelWidth: ComputedRef<string | undefined>;
33
34
  tagName: ComputedRef<ConcreteComponent<{}, any, any, ComputedOptions, MethodOptions> | "m-fields-text">;
34
35
  rule: ComputedRef<Rule[]>;
35
36
  tooltip: ComputedRef<any>;
@@ -16,7 +16,6 @@ declare const _default: DefineComponent<{
16
16
  size: StringConstructor;
17
17
  }, {
18
18
  mForm: FormState | undefined;
19
- display(config: any): any;
20
19
  changeHandler: () => void;
21
20
  }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "change"[], "change", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
22
21
  labelWidth: StringConstructor;
@@ -23,8 +23,8 @@ declare const _default: DefineComponent<{
23
23
  initValues: ObjectConstructor;
24
24
  values: ObjectConstructor;
25
25
  }, {
26
- activeValue: ComputedRef<string | number | boolean>;
27
- inactiveValue: ComputedRef<string | number | boolean>;
26
+ activeValue: ComputedRef<string | number | boolean | undefined>;
27
+ inactiveValue: ComputedRef<string | number | boolean | undefined>;
28
28
  changeHandler(value: number | boolean): void;
29
29
  }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("change" | "input")[], "change" | "input", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
30
30
  config: {
@@ -34,10 +34,10 @@ declare const _default: DefineComponent<{
34
34
  }, {
35
35
  request: Function;
36
36
  fieldMap: {
37
- [x: string]: any;
37
+ [key: string]: any;
38
38
  };
39
39
  fieldLabelMap: {
40
- [x: string]: any;
40
+ [key: string]: any;
41
41
  };
42
42
  unwatch: WatchStopHandle;
43
43
  changeFieldMap: () => Promise<void>;
@@ -31,6 +31,6 @@ export { default as MSelect } from './fields/Select.vue';
31
31
  export { default as MCascader } from './fields/Cascader.vue';
32
32
  export { default as MDynamicField } from './fields/DynamicField.vue';
33
33
  declare const _default: {
34
- install: (app: App<any>, opt: any) => void;
34
+ install: (app: App, opt: any) => void;
35
35
  };
36
36
  export default _default;
@@ -92,6 +92,7 @@ export interface Rule {
92
92
  /** 整个表单的值 */
93
93
  formValue: FormValue;
94
94
  prop: string;
95
+ config: any;
95
96
  }, mForm: FormState | undefined) => void;
96
97
  }
97
98
  export interface Input {
@@ -107,12 +108,14 @@ declare type FilterFunction = (mForm: FormState | undefined, data: {
107
108
  parent?: Record<any, any>;
108
109
  formValue: Record<any, any>;
109
110
  prop: string;
111
+ config: any;
110
112
  }) => boolean;
111
113
  declare type OnChangeHandler = (mForm: FormState | undefined, value: any, data: {
112
114
  model: Record<any, any>;
113
115
  values: Record<any, any>;
114
116
  parent?: Record<any, any>;
115
117
  formValue: Record<any, any>;
118
+ config: any;
116
119
  }) => any;
117
120
  declare type DefaultValueFunction = (mForm: FormState | undefined) => any;
118
121
  /**
@@ -138,18 +141,22 @@ export interface SelectGroupOption {
138
141
  }
139
142
  declare type SelectOptionFunction = (mForm: FormState | undefined, data: {
140
143
  model: any;
144
+ prop?: string;
141
145
  formValues: any;
142
146
  formValue: any;
147
+ config: any;
143
148
  }) => SelectOption[] | SelectGroupOption[];
144
149
  declare type RemoteSelectOptionBodyFunction = (mForm: FormState | undefined, data: {
145
150
  model: any;
146
151
  formValue: any;
147
152
  formValues: any;
153
+ config: any;
148
154
  }) => Record<string, any>;
149
155
  declare type RemoteSelectOptionRequestFunction = (mForm: FormState | undefined, res: any, data: {
150
156
  model: any;
151
157
  formValue: any;
152
158
  formValues: any;
159
+ config: any;
153
160
  }) => any;
154
161
  declare type RemoteSelectOptionItemFunction = (optionsData: Record<string, any>) => SelectOption[];
155
162
  declare type SelectOptionValueFunction = (item: Record<string, any>) => any;
@@ -395,6 +402,7 @@ export interface TabPaneConfig {
395
402
  lazy?: boolean;
396
403
  labelWidth?: string;
397
404
  items: FormConfig;
405
+ [key: string]: any;
398
406
  }
399
407
  export interface TabConfig extends FormItem, ContainerCommonConfig {
400
408
  type: 'tab' | 'dynamic-tab';
@@ -432,6 +440,7 @@ export interface ColumnConfig extends FormItem, ContainerCommonConfig {
432
440
  label: string;
433
441
  width: string | number;
434
442
  sortable: boolean;
443
+ [key: string]: any;
435
444
  }
436
445
  /**
437
446
  * 表格容器
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
- "version": "1.0.0-beta.8",
2
+ "version": "1.0.0-rc.11",
3
3
  "name": "@tmagic/form",
4
- "sideEffects": false,
4
+ "sideEffects": [
5
+ "dist/*",
6
+ "src/theme/*"
7
+ ],
5
8
  "main": "dist/tmagic-form.umd.js",
6
9
  "module": "dist/tmagic-form.es.js",
7
10
  "style": "dist/style.css",
@@ -14,8 +17,10 @@
14
17
  "./dist/style.css": {
15
18
  "import": "./dist/style.css",
16
19
  "require": "./dist/style.css"
17
- }
20
+ },
21
+ "./*": "./*"
18
22
  },
23
+ "license": "Apache-2.0",
19
24
  "scripts": {
20
25
  "build": "vite build"
21
26
  },
@@ -28,26 +33,30 @@
28
33
  },
29
34
  "dependencies": {
30
35
  "@element-plus/icons": "0.0.11",
31
- "@tmagic/utils": "^1.0.0-beta.8",
32
- "element-plus": "^2.1.7",
36
+ "@tmagic/utils": "1.0.0-rc.11",
37
+ "element-plus": "^2.2.0",
33
38
  "lodash-es": "^4.17.21",
34
- "moment": "^2.29.1",
39
+ "moment": "^2.29.2",
35
40
  "sortablejs": "^1.14.0",
36
41
  "vue": "^3.2.0"
37
42
  },
43
+ "peerDependencies": {
44
+ "element-plus": "^2.2.0",
45
+ "vue": "^3.2.0"
46
+ },
38
47
  "devDependencies": {
48
+ "@babel/core": "^7.18.0",
39
49
  "@types/lodash-es": "^4.17.4",
40
50
  "@types/node": "^15.12.4",
41
51
  "@types/sortablejs": "^1.10.7",
42
52
  "@vitejs/plugin-vue": "^1.2.3",
43
53
  "@vitejs/plugin-vue-jsx": "^1.1.6",
44
54
  "@vue/compiler-sfc": "^3.2.0",
45
- "@vue/test-utils": "^2.0.0-rc.12",
55
+ "@vue/test-utils": "^2.0.0",
46
56
  "sass": "^1.35.1",
47
57
  "typescript": "^4.3.4",
48
58
  "vite": "^2.3.7",
49
59
  "vite-plugin-dts": "^0.9.6",
50
60
  "vue-tsc": "^0.0.24"
51
- },
52
- "gitHead": "ff8e32901775ecc145a82f906d6af6119652d61e"
61
+ }
53
62
  }
package/src/Form.vue CHANGED
@@ -86,7 +86,7 @@ export default defineComponent({
86
86
  },
87
87
 
88
88
  size: {
89
- type: String,
89
+ type: String as PropType<'small' | 'default' | 'large'>,
90
90
  },
91
91
 
92
92
  inline: {
@@ -177,7 +177,7 @@ export default defineComponent({
177
177
  submitForm: async (native?: boolean): Promise<any> => {
178
178
  try {
179
179
  await elForm.value?.validate();
180
- return native ? values.value : cloneDeep(values.value);
180
+ return native ? values.value : cloneDeep(toRaw(values.value));
181
181
  } catch (invalidFields: any) {
182
182
  const error: string[] = [];
183
183
 
@@ -78,7 +78,7 @@ export default defineComponent({
78
78
 
79
79
  labelWidth: [Number, String],
80
80
 
81
- size: String as PropType<'mini' | 'small' | 'medium'>,
81
+ size: String as PropType<'small' | 'default' | 'large'>,
82
82
 
83
83
  confirmText: {
84
84
  type: String,
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <el-col v-show="display && config.type !== 'hidden'" :span="span">
3
+ <m-form-container
4
+ :model="model"
5
+ :config="config"
6
+ :prop="prop"
7
+ :label-width="config.labelWidth || labelWidth"
8
+ :expand-more="expandMore"
9
+ :size="size"
10
+ @change="changeHandler"
11
+ ></m-form-container>
12
+ </el-col>
13
+ </template>
14
+
15
+ <script lang="ts">
16
+ import { computed, defineComponent, inject, PropType } from 'vue';
17
+
18
+ import { ChildConfig, FormState } from '../schema';
19
+ import { display as displayFunction } from '../utils/form';
20
+
21
+ export default defineComponent({
22
+ props: {
23
+ labelWidth: String,
24
+ expandMore: Boolean,
25
+ span: Number,
26
+
27
+ model: {
28
+ type: Object,
29
+ default: () => ({}),
30
+ },
31
+
32
+ config: {
33
+ type: Object as PropType<ChildConfig>,
34
+ default: () => ({}),
35
+ },
36
+
37
+ prop: String,
38
+
39
+ size: String,
40
+ },
41
+
42
+ emits: ['change'],
43
+
44
+ setup(props, { emit }) {
45
+ const mForm = inject<FormState | undefined>('mForm');
46
+
47
+ const changeHandler = () => emit('change', props.model);
48
+
49
+ return {
50
+ mForm,
51
+ display: computed(() => displayFunction(mForm, props.config.display, props)),
52
+ changeHandler,
53
+ };
54
+ },
55
+ });
56
+ </script>
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <div v-if="config" :style="config.tip ? 'display: flex' : ''" :class="config.className" class="m-form-container">
2
+ <div
3
+ v-if="config"
4
+ :style="config.tip ? 'display: flex;align-items: baseline;' : ''"
5
+ :class="config.className"
6
+ class="m-form-container"
7
+ >
3
8
  <m-fields-hidden
4
9
  v-if="type === 'hidden'"
5
10
  :model="model"
@@ -20,15 +25,16 @@
20
25
  :prop="itemProp"
21
26
  :step-active="stepActive"
22
27
  :expand-more="expand"
23
- :label-width="config.labelWidth || labelWidth"
28
+ :label-width="itemLabelWidth"
24
29
  @change="onChangeHandler"
25
30
  ></component>
26
31
 
27
32
  <template v-else-if="type && display">
28
33
  <el-form-item
29
34
  :style="config.tip ? 'flex: 1' : ''"
35
+ :class="{ hidden: `${itemLabelWidth}` === '0' || !config.text }"
30
36
  :prop="itemProp"
31
- :label-width="config.text ? config.labelWidth || labelWidth : '0'"
37
+ :label-width="itemLabelWidth"
32
38
  :rules="rule"
33
39
  >
34
40
  <template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
@@ -65,8 +71,8 @@
65
71
  <div v-if="extra" v-html="extra" class="m-form-tip"></div>
66
72
  </el-form-item>
67
73
 
68
- <el-tooltip v-if="config.tip" placement="top" style="line-height: 40px; margin-left: 5px">
69
- <i class="el-icon-warning"></i>
74
+ <el-tooltip v-if="config.tip" placement="left">
75
+ <el-icon style="line-height: 40px; margin-left: 5px"><warning-filled /></el-icon>
70
76
  <template #content>
71
77
  <div v-html="config.tip"></div>
72
78
  </template>
@@ -83,7 +89,7 @@
83
89
  :size="size"
84
90
  :step-active="stepActive"
85
91
  :expand-more="expand"
86
- :label-width="config.labelWidth || labelWidth"
92
+ :label-width="itemLabelWidth"
87
93
  :prop="itemProp"
88
94
  @change="onChangeHandler"
89
95
  ></m-form-container>
@@ -91,13 +97,14 @@
91
97
  </template>
92
98
 
93
99
  <div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
94
- <el-button type="text" @click="expandHandler">{{ expand ? '收起配置' : '展开更多配置' }}</el-button>
100
+ <el-button text @click="expandHandler">{{ expand ? '收起配置' : '展开更多配置' }}</el-button>
95
101
  </div>
96
102
  </div>
97
103
  </template>
98
104
 
99
105
  <script lang="ts">
100
106
  import { computed, defineComponent, inject, PropType, ref, resolveComponent, watchEffect } from 'vue';
107
+ import { WarningFilled } from '@element-plus/icons';
101
108
 
102
109
  import { ChildConfig, ContainerCommonConfig, FormState, FormValue } from '../schema';
103
110
  import { display as displayFunction, filterFunction, getRules } from '../utils/form';
@@ -105,6 +112,8 @@ import { display as displayFunction, filterFunction, getRules } from '../utils/f
105
112
  export default defineComponent({
106
113
  name: 'm-form-container',
107
114
 
115
+ components: { WarningFilled },
116
+
108
117
  props: {
109
118
  labelWidth: String,
110
119
  expandMore: Boolean,
@@ -145,7 +154,18 @@ export default defineComponent({
145
154
 
146
155
  const items = computed(() => (props.config as ContainerCommonConfig).items);
147
156
 
148
- const itemProp = computed(() => (name.value ? `${props.prop}${props.prop ? '.' : ''}${name.value}` : props.prop));
157
+ const itemProp = computed(() => {
158
+ let n: string | number = '';
159
+ const { names } = props.config as any;
160
+ if (names?.[0]) {
161
+ [n] = names;
162
+ } else if (name.value) {
163
+ n = name.value;
164
+ } else {
165
+ return props.prop;
166
+ }
167
+ return `${props.prop}${props.prop ? '.' : ''}${n}`;
168
+ });
149
169
 
150
170
  const tagName = computed(() => {
151
171
  const component = resolveComponent(`m-${items.value ? 'form' : 'fields'}-${type.value}`);
@@ -180,6 +200,8 @@ export default defineComponent({
180
200
  return displayFunction(mForm, props.config.display, props);
181
201
  });
182
202
 
203
+ const itemLabelWidth = computed(() => props.config.labelWidth || props.labelWidth);
204
+
183
205
  watchEffect(() => {
184
206
  expand.value = props.expandMore;
185
207
  });
@@ -195,6 +217,7 @@ export default defineComponent({
195
217
  values: mForm?.initValues,
196
218
  formValue: mForm?.values,
197
219
  prop: itemProp.value,
220
+ config: props.config,
198
221
  });
199
222
  }
200
223
 
@@ -212,6 +235,7 @@ export default defineComponent({
212
235
  values: mForm?.initValues,
213
236
  formValue: mForm?.values,
214
237
  prop: itemProp.value,
238
+ config: props.config,
215
239
  });
216
240
  }
217
241
  };
@@ -255,6 +279,7 @@ export default defineComponent({
255
279
  itemProp,
256
280
  items,
257
281
  display,
282
+ itemLabelWidth,
258
283
  tagName,
259
284
  rule,
260
285
  tooltip,
@@ -5,21 +5,21 @@
5
5
  ><caret-bottom v-if="expand" /><caret-right v-else
6
6
  /></el-icon>
7
7
 
8
- <el-button type="text" @click="expandHandler">{{ title }}</el-button>
8
+ <el-button text @click="expandHandler">{{ title }}</el-button>
9
9
 
10
10
  <el-button
11
11
  v-show="showDelete(parseInt(String(index)))"
12
- type="text"
12
+ text
13
13
  :icon="Delete"
14
14
  style="color: #f56c6c"
15
15
  @click="removeHandler"
16
16
  ></el-button>
17
17
 
18
18
  <template v-if="movable()">
19
- <el-button v-show="index !== 0" type="text" size="small" @click="changeOrder(-1)"
19
+ <el-button v-show="index !== 0" text size="small" @click="changeOrder(-1)"
20
20
  >上移<el-icon><CaretRight /></el-icon
21
21
  ></el-button>
22
- <el-button v-show="index !== length - 1" type="text" size="small" @click="changeOrder(1)"
22
+ <el-button v-show="index !== length - 1" text size="small" @click="changeOrder(1)"
23
23
  >下移<el-icon><CaretBottom /></el-icon
24
24
  ></el-button>
25
25
  </template>
@@ -1,21 +1,17 @@
1
1
  <template>
2
2
  <el-row :gutter="10">
3
- <el-col
3
+ <Col
4
4
  v-for="(col, index) in config.items"
5
- :style="!display(col) || col.type === 'hidden' ? 'display: none' : ''"
6
5
  :key="col[mForm?.keyProp || '__key'] ?? index"
7
6
  :span="col.span || config.span || 24 / config.items.length"
8
- >
9
- <m-form-container
10
- :model="name ? model[name] : model"
11
- :config="col"
12
- :prop="prop"
13
- :label-width="config.labelWidth || labelWidth"
14
- :expand-more="expandMore"
15
- :size="size"
16
- @change="changeHandler"
17
- ></m-form-container>
18
- </el-col>
7
+ :config="col"
8
+ :labelWidth="config.labelWidth || labelWidth"
9
+ :expandMore="expandMore"
10
+ :model="name ? model[name] : model"
11
+ :prop="prop"
12
+ :size="size"
13
+ @change="changeHandler"
14
+ />
19
15
  </el-row>
20
16
  </template>
21
17
 
@@ -23,11 +19,14 @@
23
19
  import { defineComponent, inject, PropType } from 'vue';
24
20
 
25
21
  import { FormState, RowConfig } from '../schema';
26
- import { display as displayFunction } from '../utils/form';
22
+
23
+ import Col from './Col.vue';
27
24
 
28
25
  export default defineComponent({
29
26
  name: 'm-form-row',
30
27
 
28
+ components: { Col },
29
+
31
30
  props: {
32
31
  labelWidth: String,
33
32
  expandMore: Boolean,
@@ -58,9 +57,6 @@ export default defineComponent({
58
57
 
59
58
  return {
60
59
  mForm,
61
- display(config: any) {
62
- return displayFunction(mForm, config.display, props);
63
- },
64
60
  changeHandler,
65
61
  };
66
62
  },
@@ -25,8 +25,8 @@
25
25
  <template v-slot="scope">
26
26
  <el-button
27
27
  v-show="showDelete(scope.$index + 1 + pagecontext * pagesize - 1)"
28
- style="color: #f56c6c"
29
- type="text"
28
+ type="danger"
29
+ text
30
30
  :icon="Delete"
31
31
  @click="removeHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
32
32
  ></el-button>
@@ -43,8 +43,9 @@
43
43
  <el-button
44
44
  plain
45
45
  size="small"
46
+ type="primary"
46
47
  :icon="ArrowUp"
47
- type="text"
48
+ text
48
49
  @click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
49
50
  @dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
50
51
  ></el-button>
@@ -57,8 +58,9 @@
57
58
  <el-button
58
59
  plain
59
60
  size="small"
61
+ type="primary"
60
62
  :icon="ArrowDown"
61
- type="text"
63
+ text
62
64
  @click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
63
65
  @dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
64
66
  ></el-button>
@@ -107,10 +109,16 @@
107
109
  </el-tooltip>
108
110
  <slot></slot>
109
111
  <el-button v-if="addable" size="small" type="primary" plain @click="newHandler()">添加</el-button> &nbsp;
110
- <el-button :icon="Grid" size="small" @click="toggleMode" v-if="enableToggleMode && !isFullscreen"
112
+ <el-button :icon="Grid" size="small" type="primary" @click="toggleMode" v-if="enableToggleMode && !isFullscreen"
111
113
  >展开配置</el-button
112
114
  >
113
- <el-button :icon="FullScreen" size="small" @click="toggleFullscreen" v-if="config.enableFullscreen !== false">
115
+ <el-button
116
+ :icon="FullScreen"
117
+ size="small"
118
+ type="primary"
119
+ @click="toggleFullscreen"
120
+ v-if="config.enableFullscreen !== false"
121
+ >
114
122
  {{ isFullscreen ? '退出全屏' : '全屏编辑' }}
115
123
  </el-button>
116
124
  <el-upload
@@ -468,7 +476,7 @@ export default defineComponent({
468
476
  }
469
477
  emit('select', selection, row);
470
478
  if (typeof props.config.onSelect === 'function') {
471
- props.config.onSelect(mForm, { selection, row });
479
+ props.config.onSelect(mForm, { selection, row, config: props.config });
472
480
  }
473
481
  },
474
482
 
@@ -59,12 +59,12 @@ const tabClickHandler = (mForm: FormState | undefined, tab: any, props: any) =>
59
59
  tab.name = tab.paneName;
60
60
 
61
61
  if (typeof config.onTabClick === 'function') {
62
- config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
62
+ config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop, config });
63
63
  }
64
64
 
65
65
  const tabConfig = config.items.find((item: TabPaneConfig) => tab.name === item.status);
66
66
  if (tabConfig && typeof tabConfig.onTabClick === 'function') {
67
- tabConfig.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
67
+ tabConfig.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop, config });
68
68
  }
69
69
  };
70
70
 
@@ -136,7 +136,11 @@ const Tab = defineComponent({
136
136
  if (!props.config.name) throw new Error('dynamic tab 必须配置name');
137
137
 
138
138
  if (typeof props.config.onTabAdd === 'function') {
139
- props.config.onTabAdd(mForm, { model: props.model });
139
+ props.config.onTabAdd(mForm, {
140
+ model: props.model,
141
+ prop: props.prop,
142
+ config: props.config,
143
+ });
140
144
  } else if (tabs.value.length > 0) {
141
145
  const newObj = cloneDeep(tabs.value[0]);
142
146
  newObj.title = `标签${tabs.value.length + 1}`;
@@ -150,7 +154,11 @@ const Tab = defineComponent({
150
154
  if (!props.config.name) throw new Error('dynamic tab 必须配置name');
151
155
 
152
156
  if (typeof props.config.onTabRemove === 'function') {
153
- props.config.onTabRemove(mForm, tabName, { model: props.model });
157
+ props.config.onTabRemove(mForm, tabName, {
158
+ model: props.model,
159
+ prop: props.prop,
160
+ config: props.config,
161
+ });
154
162
  } else {
155
163
  props.model[props.config.name].splice(+tabName, 1);
156
164
 
@@ -169,7 +177,7 @@ const Tab = defineComponent({
169
177
  changeHandler: () => {
170
178
  emit('change', props.model);
171
179
  if (typeof props.config.onChange === 'function') {
172
- props.config.onChange(mForm, { model: props.model });
180
+ props.config.onChange(mForm, { model: props.model, prop: props.prop, config: props.config });
173
181
  }
174
182
  },
175
183
  };
@@ -43,7 +43,7 @@ export default defineComponent({
43
43
  return props.config.activeValue;
44
44
  }
45
45
 
46
- return 'true';
46
+ return undefined;
47
47
  }),
48
48
 
49
49
  inactiveValue: computed(() => {
@@ -55,7 +55,7 @@ export default defineComponent({
55
55
  return props.config.inactiveValue;
56
56
  }
57
57
 
58
- return 'false';
58
+ return undefined;
59
59
  }),
60
60
 
61
61
  changeHandler(value: number | boolean) {
@@ -60,6 +60,14 @@ export default defineComponent({
60
60
  });
61
61
  } else if (props.model && props.name && v instanceof Date) {
62
62
  props.model[props.name] = datetimeFormatter(v.toString(), '');
63
+ } else if (names?.length) {
64
+ names.forEach((item) => {
65
+ if (props.model) {
66
+ props.model[item] = undefined;
67
+ }
68
+ });
69
+ } else if (props.name) {
70
+ props.model[props.name] = undefined;
63
71
  }
64
72
  };
65
73
 
@@ -2,7 +2,7 @@
2
2
  <a v-if="config.href && !disabled" target="_blank" :href="href" :style="config.css || {}">{{ displayText }}</a>
3
3
  <span v-else-if="config.href && disabled" :style="config.disabledCss || {}">{{ displayText }}</span>
4
4
  <div v-else class="m-fields-link">
5
- <el-button type="text" @click="editHandler">点击编辑</el-button>
5
+ <el-button text type="primary" @click="editHandler">点击编辑</el-button>
6
6
  <m-form-dialog
7
7
  ref="editor"
8
8
  :title="config.formTitle || '编辑扩展配置'"