t20-common-lib 0.15.19 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "t20-common-lib",
3
- "version": "0.15.19",
3
+ "version": "0.15.20",
4
4
  "description": "T20",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -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 || "";