t20-common-lib 0.15.18 → 0.15.20
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
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
:key="item.value + items.prop"
|
|
24
24
|
:label="item.label | $l"
|
|
25
25
|
:value="item.value"
|
|
26
|
+
:disabled="isOptionDisabled(item)"
|
|
26
27
|
>
|
|
27
28
|
{{labelKey ? item._label : item.label | $l}}
|
|
28
29
|
</el-option>
|
|
@@ -57,6 +58,14 @@ export default {
|
|
|
57
58
|
return {};
|
|
58
59
|
},
|
|
59
60
|
},
|
|
61
|
+
formData: {
|
|
62
|
+
type: Object,
|
|
63
|
+
default: () => ({})
|
|
64
|
+
},
|
|
65
|
+
groupProp: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: ''
|
|
68
|
+
},
|
|
60
69
|
label: {
|
|
61
70
|
type: String,
|
|
62
71
|
defalut: "",
|
|
@@ -91,6 +100,9 @@ export default {
|
|
|
91
100
|
// 判断数据类型,格式化回显数据
|
|
92
101
|
valueType() {
|
|
93
102
|
return typeof this.value
|
|
103
|
+
},
|
|
104
|
+
optionDisableConfig() {
|
|
105
|
+
return this.items?.props?.optionDisable || {}
|
|
94
106
|
}
|
|
95
107
|
},
|
|
96
108
|
watch: {
|
|
@@ -193,6 +205,44 @@ export default {
|
|
|
193
205
|
clearFn() {
|
|
194
206
|
this.options = this.optionsCopy
|
|
195
207
|
},
|
|
208
|
+
/**
|
|
209
|
+
* 从 formData 读取控制字段值。
|
|
210
|
+
* 支持两种写法:
|
|
211
|
+
* - "group.field"(推荐)
|
|
212
|
+
* - "field"(默认读取当前 groupProp 下字段)
|
|
213
|
+
*/
|
|
214
|
+
getControlValue(controlField) {
|
|
215
|
+
if (!controlField || !this.formData) return undefined
|
|
216
|
+
const path = String(controlField).split('.')
|
|
217
|
+
if (path.length >= 2) {
|
|
218
|
+
let cur = this.formData
|
|
219
|
+
for (let i = 0; i < path.length; i++) {
|
|
220
|
+
if (cur == null) return undefined
|
|
221
|
+
cur = cur[path[i]]
|
|
222
|
+
}
|
|
223
|
+
return cur
|
|
224
|
+
}
|
|
225
|
+
return this.groupProp ? this.formData?.[this.groupProp]?.[controlField] : this.formData?.[controlField]
|
|
226
|
+
},
|
|
227
|
+
/**
|
|
228
|
+
* 下拉项禁用规则(声明式):
|
|
229
|
+
* items.props.optionDisable = {
|
|
230
|
+
* controlField: 'groupA.ctrlType' 或 'ctrlType',
|
|
231
|
+
* map: { 'A': ['v1', 'v2'], 'B': ['v3'] },
|
|
232
|
+
* defaultDisabledValues: []
|
|
233
|
+
* }
|
|
234
|
+
*/
|
|
235
|
+
isOptionDisabled(option) {
|
|
236
|
+
const cfg = this.optionDisableConfig
|
|
237
|
+
const controlField = cfg.controlField
|
|
238
|
+
const map = cfg.map || {}
|
|
239
|
+
const defaultDisabledValues = cfg.defaultDisabledValues || []
|
|
240
|
+
if (!controlField) return false
|
|
241
|
+
const controlValue = this.getControlValue(controlField)
|
|
242
|
+
const disabledValues = map[controlValue] || defaultDisabledValues
|
|
243
|
+
if (!Array.isArray(disabledValues)) return false
|
|
244
|
+
return disabledValues.some(v => String(v) === String(option?.value))
|
|
245
|
+
},
|
|
196
246
|
changVariable(val){
|
|
197
247
|
if (!val) {
|
|
198
248
|
return val || "";
|
|
@@ -217,15 +217,10 @@ export default {
|
|
|
217
217
|
deep: true,
|
|
218
218
|
handler() {
|
|
219
219
|
if (this.isApplyingLinkage) return
|
|
220
|
+
// 编辑场景下 value 可能由页面先行组装,等模板就绪后仅补齐缺失字段,不覆盖已传数据。
|
|
221
|
+
if (!this.formGroups.length) return
|
|
220
222
|
this.ensureFormDataShape()
|
|
221
223
|
}
|
|
222
|
-
},
|
|
223
|
-
formData: {
|
|
224
|
-
deep: true,
|
|
225
|
-
handler() {
|
|
226
|
-
if (this.isApplyingLinkage) return
|
|
227
|
-
this.applyFieldStates()
|
|
228
|
-
}
|
|
229
224
|
}
|
|
230
225
|
},
|
|
231
226
|
methods: {
|
|
@@ -355,14 +350,11 @@ export default {
|
|
|
355
350
|
},
|
|
356
351
|
setFieldValue(groupProp, fieldProp, value) {
|
|
357
352
|
const sourceFormData = this.formData && typeof this.formData === 'object' ? this.formData : {}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
groupData[fieldProp] = value
|
|
362
|
-
this.formData = {
|
|
363
|
-
...sourceFormData,
|
|
364
|
-
[groupProp]: groupData
|
|
353
|
+
if (!sourceFormData[groupProp] || typeof sourceFormData[groupProp] !== 'object' || Array.isArray(sourceFormData[groupProp])) {
|
|
354
|
+
this.$set(sourceFormData, groupProp, {})
|
|
365
355
|
}
|
|
356
|
+
this.$set(sourceFormData[groupProp], fieldProp, value)
|
|
357
|
+
this.$emit('input', sourceFormData)
|
|
366
358
|
},
|
|
367
359
|
/**
|
|
368
360
|
* 场景4:与 value 配套的展示字段(模板里的 nameProp),用于下拉等回显名称。
|