@tmagic/form 1.2.8 → 1.2.10

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.2.8",
2
+ "version": "1.2.10",
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.8",
40
- "@tmagic/utils": "1.2.8",
39
+ "@tmagic/design": "1.2.10",
40
+ "@tmagic/utils": "1.2.10",
41
41
  "lodash-es": "^4.17.21",
42
42
  "sortablejs": "^1.14.0",
43
43
  "vue": "^3.2.37"
@@ -48,6 +48,7 @@
48
48
  :size="size"
49
49
  :is="tagName"
50
50
  :model="model"
51
+ :last-values="lastValues"
51
52
  :config="config"
52
53
  :name="name"
53
54
  :disabled="disabled"
@@ -66,6 +67,7 @@
66
67
  :size="size"
67
68
  :is="tagName"
68
69
  :model="model"
70
+ :last-values="lastValues"
69
71
  :config="config"
70
72
  :name="name"
71
73
  :disabled="disabled"
@@ -193,7 +195,7 @@
193
195
  v-for="item in items"
194
196
  :key="key(item)"
195
197
  :model="name || name === 0 ? model[name] : model"
196
- :last-values="name || name === 0 ? lastValues[name] : lastValues"
198
+ :last-values="name || name === 0 ? lastValues[name] || {} : lastValues"
197
199
  :is-compare="isCompare"
198
200
  :config="item"
199
201
  :size="size"
@@ -258,7 +260,6 @@ const mForm = inject<FormState | undefined>('mForm');
258
260
  const expand = ref(false);
259
261
 
260
262
  const name = computed(() => props.config.name || '');
261
-
262
263
  // 是否展示两个版本的对比内容
263
264
  const showDiff = computed(() => {
264
265
  if (!props.isCompare) return false;
@@ -15,11 +15,10 @@
15
15
  :is="uiComponent.component"
16
16
  :key="tab[mForm?.keyProp || '__key'] ?? tabIndex"
17
17
  :name="filter(tab.status) || tabIndex.toString()"
18
- :label="filter(tab.title)"
19
18
  :lazy="tab.lazy || false"
20
19
  >
21
20
  <template #label>
22
- <span class="custom-tabs-label">
21
+ <span>
23
22
  {{ filter(tab.title)
24
23
  }}<el-badge :hidden="!diffCount[tabIndex]" :value="diffCount[tabIndex]" class="diff-count-badge"></el-badge>
25
24
  </span>
@@ -29,8 +28,26 @@
29
28
  :key="item[mForm?.keyProp || '__key']"
30
29
  :config="item"
31
30
  :disabled="disabled"
32
- :model="getValues(model, tabIndex, tab)"
33
- :last-values="getValues(lastValues, tabIndex, tab)"
31
+ :model="
32
+ config.dynamic
33
+ ? (name ? model[name] : model)[tabIndex]
34
+ : tab.name
35
+ ? (name ? model[name] : model)[tab.name]
36
+ : name
37
+ ? model[name]
38
+ : model
39
+ "
40
+ :last-values="
41
+ isEmpty(lastValues)
42
+ ? {}
43
+ : config.dynamic
44
+ ? (name ? lastValues[name] : lastValues)[tabIndex]
45
+ : tab.name
46
+ ? (name ? lastValues[name] : lastValues)[tab.name]
47
+ : name
48
+ ? lastValues[name]
49
+ : lastValues
50
+ "
34
51
  :is-compare="isCompare"
35
52
  :prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
36
53
  :size="size"
@@ -46,7 +63,7 @@
46
63
 
47
64
  <script setup lang="ts" name="MFormTabs">
48
65
  import { computed, inject, ref, watchEffect } from 'vue';
49
- import { cloneDeep } from 'lodash-es';
66
+ import { cloneDeep, isEmpty } from 'lodash-es';
50
67
 
51
68
  import { getConfig, TMagicTabs } from '@tmagic/design';
52
69
 
@@ -185,18 +202,6 @@ const changeHandler = () => {
185
202
  }
186
203
  };
187
204
 
188
- const getValues = (model: any, tabIndex: number, tab: any) => {
189
- const tabName = props.config.dynamic ? (model[props?.name] || model)[tabIndex] : tab.name;
190
- let propName = props.name;
191
- if (tabName) {
192
- propName = (model[props?.name] || model)[tab.name];
193
- }
194
- if (propName) {
195
- return model[props.name];
196
- }
197
- return model;
198
- };
199
-
200
205
  // 在tabs组件中收集事件触发次数,即该tab下的差异数
201
206
  const onAddDiffCount = (tabIndex: number) => {
202
207
  if (!diffCount.value[tabIndex]) {
@@ -1,15 +1,13 @@
1
1
  .magic-form-dynamic-tab {
2
2
  .el-tabs__header.is-top {
3
- display: flex;
4
- flex-direction: row-reverse;
5
3
  padding-right: 8px;
6
4
  .el-tabs__new-tab {
7
5
  margin-right: auto;
8
- min-width: 36px;
6
+ min-width: 50px;
9
7
  outline: none;
10
8
  border-color: #409eff;
11
9
  color: #409eff;
12
- width: 36px;
10
+ width: 10px;
13
11
  &::before {
14
12
  content: "添加";
15
13
  }