af-mobile-client-vue3 1.4.74 → 1.4.76
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
|
@@ -173,10 +173,9 @@ function triggerCamera() {
|
|
|
173
173
|
handlePhotoUpload(result.data)
|
|
174
174
|
}
|
|
175
175
|
else if (result.status === 'error') {
|
|
176
|
-
console.error('拍照异常原因:', result.message)
|
|
177
176
|
showDialog({
|
|
178
177
|
title: '拍照异常',
|
|
179
|
-
message: '拍照失败,请重试',
|
|
178
|
+
message: result.message || '拍照失败,请重试',
|
|
180
179
|
})
|
|
181
180
|
}
|
|
182
181
|
},
|
|
@@ -363,6 +363,11 @@ function emitFunc(func: any, data: any, value: any) {
|
|
|
363
363
|
emit(func, data, value)
|
|
364
364
|
emit('xFormItemEmitFunc', func, data, value)
|
|
365
365
|
}
|
|
366
|
+
|
|
367
|
+
// 处理 值/标签/值和标签 变化
|
|
368
|
+
function setForm(form) {
|
|
369
|
+
Object.assign(conditionParams.value, form)
|
|
370
|
+
}
|
|
366
371
|
</script>
|
|
367
372
|
|
|
368
373
|
<template>
|
|
@@ -473,6 +478,7 @@ function emitFunc(func: any, data: any, value: any) {
|
|
|
473
478
|
:service-name="props.serviceName"
|
|
474
479
|
:show-label="false"
|
|
475
480
|
@x-form-item-emit-func="emitFunc"
|
|
481
|
+
@set-form="setForm"
|
|
476
482
|
/>
|
|
477
483
|
</template>
|
|
478
484
|
</div>
|
|
@@ -6,6 +6,7 @@ import XGridDropOption from '@af-mobile-client-vue3/components/core/XGridDropOpt
|
|
|
6
6
|
import XMultiSelect from '@af-mobile-client-vue3/components/core/XMultiSelect/index.vue'
|
|
7
7
|
import XSelect from '@af-mobile-client-vue3/components/core/XSelect/index.vue'
|
|
8
8
|
import XLocationPicker from '@af-mobile-client-vue3/components/data/XOlMap/XLocationPicker/index.vue'
|
|
9
|
+
import { createSelectValueTypeHandler } from '@af-mobile-client-vue3/plugins/selectValueTypeHelper'
|
|
9
10
|
import { getConfigByNameAsync, runLogic } from '@af-mobile-client-vue3/services/api/common'
|
|
10
11
|
import { post } from '@af-mobile-client-vue3/services/restTools'
|
|
11
12
|
import { searchToListOption, searchToOption } from '@af-mobile-client-vue3/services/v3Api'
|
|
@@ -38,7 +39,17 @@ import {
|
|
|
38
39
|
Switch as VanSwitch,
|
|
39
40
|
TimePicker as VanTimePicker,
|
|
40
41
|
} from 'vant'
|
|
41
|
-
import {
|
|
42
|
+
import {
|
|
43
|
+
computed,
|
|
44
|
+
defineEmits,
|
|
45
|
+
defineModel,
|
|
46
|
+
defineProps,
|
|
47
|
+
getCurrentInstance,
|
|
48
|
+
nextTick,
|
|
49
|
+
onBeforeMount,
|
|
50
|
+
ref,
|
|
51
|
+
watch,
|
|
52
|
+
} from 'vue'
|
|
42
53
|
|
|
43
54
|
const props = defineProps({
|
|
44
55
|
attr: {
|
|
@@ -124,6 +135,8 @@ let debouncedUserLinkFunc: (() => void) | null = null
|
|
|
124
135
|
let debouncedDepLinkFunc: (() => void) | null = null
|
|
125
136
|
let debouncedUpdateOptions: (() => void) | null = null
|
|
126
137
|
|
|
138
|
+
const selectValueTypeHandler = createSelectValueTypeHandler()
|
|
139
|
+
|
|
127
140
|
const { attr, form, mode, serviceName, getDataParams, columnsField } = props
|
|
128
141
|
// 配置的表单值格式(仅针对 datePicker 生效)
|
|
129
142
|
// 作用:统一控制日期值的格式化输入/输出与选择器展示粒度
|
|
@@ -677,7 +690,8 @@ function onCalendarConfirm(values) {
|
|
|
677
690
|
// js 函数作为数据源
|
|
678
691
|
async function updateOptions() {
|
|
679
692
|
if (attr.keyName && (attr.keyName.toString().includes('async ') || attr.keyName.toString().includes('function '))) {
|
|
680
|
-
|
|
693
|
+
const res = await executeStrFunctionByContext(currInst, attr.keyName, [props.form, runLogic, props.mode, getConfigByNameAsync, post, userState.f.resources])
|
|
694
|
+
option.value = selectValueTypeHandler.processOptions(res, attr.selectValueType)
|
|
681
695
|
}
|
|
682
696
|
}
|
|
683
697
|
|
|
@@ -685,7 +699,7 @@ function init() {
|
|
|
685
699
|
if (attr.keyName && typeof attr.keyName === 'string') {
|
|
686
700
|
if (attr.keyName && attr.keyName.includes('logic@')) {
|
|
687
701
|
getData({}, (res) => {
|
|
688
|
-
option.value = res
|
|
702
|
+
option.value = selectValueTypeHandler.processOptions(res, attr.selectValueType)
|
|
689
703
|
initRadioValue()
|
|
690
704
|
})
|
|
691
705
|
}
|
|
@@ -693,7 +707,7 @@ function init() {
|
|
|
693
707
|
const configName = attr.keyName.substring(7)
|
|
694
708
|
getDict(configName, (result) => {
|
|
695
709
|
if (result)
|
|
696
|
-
option.value = result
|
|
710
|
+
option.value = selectValueTypeHandler.processOptions(result, attr.selectValueType)
|
|
697
711
|
}, serviceName)
|
|
698
712
|
}
|
|
699
713
|
else if (attr.keyName && attr.keyName.includes('search@')) {
|
|
@@ -725,8 +739,14 @@ function init() {
|
|
|
725
739
|
}
|
|
726
740
|
}
|
|
727
741
|
|
|
742
|
+
// 根据selectValueType预处理options数据
|
|
743
|
+
function processOptionsForValueType(options) {
|
|
744
|
+
return selectValueTypeHandler.processOptions(options, attr.selectValueType)
|
|
745
|
+
}
|
|
746
|
+
|
|
728
747
|
function getDataCallback(res) {
|
|
729
|
-
|
|
748
|
+
// 预处理options数据
|
|
749
|
+
option.value = processOptionsForValueType(res)
|
|
730
750
|
if (attr.type === 'radio')
|
|
731
751
|
initRadioValue()
|
|
732
752
|
}
|
|
@@ -951,6 +971,7 @@ function onTreeSelectFinish({ selectedOptions }) {
|
|
|
951
971
|
else {
|
|
952
972
|
modelData.value = selectedOptions[index].value
|
|
953
973
|
}
|
|
974
|
+
commChange()
|
|
954
975
|
showTreeSelect.value = false
|
|
955
976
|
}
|
|
956
977
|
|
|
@@ -1120,6 +1141,43 @@ function scanCodeOrNfc(attr) {
|
|
|
1120
1141
|
})
|
|
1121
1142
|
}
|
|
1122
1143
|
}
|
|
1144
|
+
// 统一的表单项change处理逻辑
|
|
1145
|
+
function handleFormItemChange() {
|
|
1146
|
+
// 处理both模式
|
|
1147
|
+
const options = option.value
|
|
1148
|
+
if (attr.selectValueType === 'both') {
|
|
1149
|
+
nextTick(() => {
|
|
1150
|
+
selectValueTypeHandler.processBothMode(
|
|
1151
|
+
form,
|
|
1152
|
+
attr.model,
|
|
1153
|
+
form[attr.model],
|
|
1154
|
+
options,
|
|
1155
|
+
)
|
|
1156
|
+
})
|
|
1157
|
+
}
|
|
1158
|
+
// 处理label模式
|
|
1159
|
+
if (attr.selectValueType === 'label') {
|
|
1160
|
+
nextTick(() => {
|
|
1161
|
+
selectValueTypeHandler.processLabelMode(
|
|
1162
|
+
form,
|
|
1163
|
+
attr.model,
|
|
1164
|
+
form[attr.model],
|
|
1165
|
+
options,
|
|
1166
|
+
)
|
|
1167
|
+
})
|
|
1168
|
+
}
|
|
1169
|
+
// 处理原有的dataChangeFunc
|
|
1170
|
+
if (attr.dataChangeFunc) {
|
|
1171
|
+
// this.debouncedDataChangeFunc()
|
|
1172
|
+
dataChangeFuncdebounce()
|
|
1173
|
+
}
|
|
1174
|
+
emits('setForm', form)
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
// 需要选择的表单项变化时触发
|
|
1178
|
+
function commChange() {
|
|
1179
|
+
handleFormItemChange()
|
|
1180
|
+
}
|
|
1123
1181
|
</script>
|
|
1124
1182
|
|
|
1125
1183
|
<template>
|
|
@@ -1154,7 +1212,7 @@ function scanCodeOrNfc(attr) {
|
|
|
1154
1212
|
<template v-if="attr.type === 'checkbox' && showItem">
|
|
1155
1213
|
<!-- 勾选 -->
|
|
1156
1214
|
<VanField
|
|
1157
|
-
v-if="
|
|
1215
|
+
v-if="mode !== '查询'"
|
|
1158
1216
|
name="checkboxGroup"
|
|
1159
1217
|
:label="labelData"
|
|
1160
1218
|
:label-align="labelAlign"
|
|
@@ -1163,7 +1221,13 @@ function scanCodeOrNfc(attr) {
|
|
|
1163
1221
|
:required="attr.rule.required === 'true'"
|
|
1164
1222
|
>
|
|
1165
1223
|
<template #input>
|
|
1166
|
-
<van-checkbox-group
|
|
1224
|
+
<van-checkbox-group
|
|
1225
|
+
v-model="modelData as any[]"
|
|
1226
|
+
direction="horizontal"
|
|
1227
|
+
shape="square"
|
|
1228
|
+
:disabled="readonly"
|
|
1229
|
+
@change="commChange"
|
|
1230
|
+
>
|
|
1167
1231
|
<VanCheckbox v-for="(item, index) in option" :key="index" style="padding: 2px" :name="item[columnsField.value]" :shape="rules?.[attr.model].shape" :value="item[columnsField.value]">
|
|
1168
1232
|
{{ item[columnsField.text] }}
|
|
1169
1233
|
</VanCheckbox>
|
|
@@ -1184,6 +1248,7 @@ function scanCodeOrNfc(attr) {
|
|
|
1184
1248
|
:column-num="labelData ? 3 : 4"
|
|
1185
1249
|
:multiple="true"
|
|
1186
1250
|
:columns="option"
|
|
1251
|
+
@change="commChange"
|
|
1187
1252
|
/>
|
|
1188
1253
|
</template>
|
|
1189
1254
|
</VanField>
|
|
@@ -1201,6 +1266,7 @@ function scanCodeOrNfc(attr) {
|
|
|
1201
1266
|
:required="attr.rule.required === 'true'"
|
|
1202
1267
|
:lazy-load="attr.lazyLoad"
|
|
1203
1268
|
:on-search="attr.lazyLoad ? handleLazySearch : null"
|
|
1269
|
+
@confirm="commChange"
|
|
1204
1270
|
/>
|
|
1205
1271
|
</template>
|
|
1206
1272
|
|
|
@@ -1217,7 +1283,7 @@ function scanCodeOrNfc(attr) {
|
|
|
1217
1283
|
:required="attr.rule.required === 'true'"
|
|
1218
1284
|
>
|
|
1219
1285
|
<template #input>
|
|
1220
|
-
<VanRadioGroup v-model="modelData" direction="horizontal" :disabled="readonly">
|
|
1286
|
+
<VanRadioGroup v-model="modelData" direction="horizontal" :disabled="readonly" @change="commChange">
|
|
1221
1287
|
<VanRadio v-for="(item, index) in option" :key="index" style="padding: 2px" :name="item[columnsField.value]" :value="item[columnsField.value]">
|
|
1222
1288
|
{{ item[columnsField.text] }}
|
|
1223
1289
|
</VanRadio>
|
|
@@ -1240,6 +1306,7 @@ function scanCodeOrNfc(attr) {
|
|
|
1240
1306
|
v-model="(modelData as string)"
|
|
1241
1307
|
:column-num="labelData ? 3 : 4"
|
|
1242
1308
|
:columns="option"
|
|
1309
|
+
@change="commChange"
|
|
1243
1310
|
/>
|
|
1244
1311
|
</template>
|
|
1245
1312
|
</VanField>
|
|
@@ -1516,6 +1583,7 @@ function scanCodeOrNfc(attr) {
|
|
|
1516
1583
|
:required="attr.rule.required === 'true'"
|
|
1517
1584
|
:lazy-load="attr.lazyLoad"
|
|
1518
1585
|
:on-search="attr.lazyLoad ? handleLazySearch : null"
|
|
1586
|
+
@confirm="commChange"
|
|
1519
1587
|
/>
|
|
1520
1588
|
|
|
1521
1589
|
<!-- 文本区域 -->
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* selectValueType 功能辅助工具
|
|
3
|
+
* 用于处理表单选择组件的值存储模式转换
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 根据selectValueType预处理options数据
|
|
8
|
+
* @param {Array} options - 原始选项数据
|
|
9
|
+
* @param {string} selectValueType - 值存储类型:'value' | 'label' | 'both'
|
|
10
|
+
* @returns {Array} 处理后的选项数据
|
|
11
|
+
*/
|
|
12
|
+
export function processOptionsForValueType(options, selectValueType = 'value') {
|
|
13
|
+
// value模式:不做任何改变,保持现有逻辑
|
|
14
|
+
if (selectValueType === 'value') {
|
|
15
|
+
return options
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// label模式:交换value和label,保存原始value到originValue
|
|
19
|
+
if (selectValueType === 'label') {
|
|
20
|
+
return processOptionsForLabelType(options)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// both模式:不处理options
|
|
24
|
+
return options
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 处理label模式的options数据转换
|
|
29
|
+
* @param {Array} options - 原始选项数据
|
|
30
|
+
* @returns {Array} 转换后的选项数据
|
|
31
|
+
*/
|
|
32
|
+
export function processOptionsForLabelType(options) {
|
|
33
|
+
if (!Array.isArray(options)) {
|
|
34
|
+
return options
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return options.map((item) => {
|
|
38
|
+
// 先创建基础的转换对象
|
|
39
|
+
const transformedItem = { ...item }
|
|
40
|
+
|
|
41
|
+
// 处理各种数据格式的属性转换
|
|
42
|
+
if (item.value !== undefined && item.label !== undefined) {
|
|
43
|
+
// 标准格式 {value, label}
|
|
44
|
+
transformedItem.originValue = item.value
|
|
45
|
+
transformedItem.value = item.label
|
|
46
|
+
}
|
|
47
|
+
else if (item.key !== undefined && item.title !== undefined) {
|
|
48
|
+
// 兼容格式 {key, title}
|
|
49
|
+
transformedItem.originValue = item.key
|
|
50
|
+
transformedItem.value = item.title
|
|
51
|
+
transformedItem.label = item.title
|
|
52
|
+
}
|
|
53
|
+
else if (item.value !== undefined && item.text !== undefined) {
|
|
54
|
+
// 字典格式 {value, text}
|
|
55
|
+
transformedItem.originValue = item.value
|
|
56
|
+
transformedItem.value = item.text
|
|
57
|
+
transformedItem.label = item.text
|
|
58
|
+
}
|
|
59
|
+
else if (item.value !== undefined) {
|
|
60
|
+
// 其他情况,尝试从多个可能的标签字段获取
|
|
61
|
+
const labelValue = item.label || item.title || item.text
|
|
62
|
+
if (labelValue !== undefined) {
|
|
63
|
+
transformedItem.originValue = item.value
|
|
64
|
+
transformedItem.value = labelValue
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 处理树形结构(递归处理children)
|
|
69
|
+
if (item.children && Array.isArray(item.children)) {
|
|
70
|
+
transformedItem.children = processOptionsForLabelType(item.children)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return transformedItem
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 根据value查找对应的label(支持单选和多选)
|
|
79
|
+
* @param {any} value - 要查找的值
|
|
80
|
+
* @param {Array} options - 选项数据
|
|
81
|
+
* @returns {string | Array | null} 对应的label值,找不到时返回null
|
|
82
|
+
*/
|
|
83
|
+
export function findLabelByValue(value, options) {
|
|
84
|
+
if (value === undefined || value === null) {
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 多选情况:value是数组
|
|
89
|
+
if (Array.isArray(value)) {
|
|
90
|
+
const labels = []
|
|
91
|
+
for (const val of value) {
|
|
92
|
+
const label = findSingleLabelByValue(val, options)
|
|
93
|
+
if (label !== null) {
|
|
94
|
+
labels.push(label)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return labels.length > 0 ? labels : null
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 单选情况:value是单个值
|
|
101
|
+
return findSingleLabelByValue(value, options)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 在选项数据中查找单个value对应的label(支持树形结构递归查找)
|
|
106
|
+
* @param {any} value - 要查找的值
|
|
107
|
+
* @param {Array} options - 选项数据
|
|
108
|
+
* @returns {string} 对应的label值,找不到时返回String(value)作为fallback
|
|
109
|
+
*/
|
|
110
|
+
export function findSingleLabelByValue(value, options) {
|
|
111
|
+
if (!Array.isArray(options)) {
|
|
112
|
+
return String(value)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
for (const item of options) {
|
|
116
|
+
// 处理标准格式 {value, label}
|
|
117
|
+
if (item.value !== undefined && String(item.value) === String(value)) {
|
|
118
|
+
return item.label || item.title || item.text || String(value)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 处理兼容格式 {key, title}
|
|
122
|
+
if (item.key !== undefined && String(item.key) === String(value)) {
|
|
123
|
+
return item.title || item.label || item.text || String(value)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// 递归查找树形结构
|
|
127
|
+
if (item.children && Array.isArray(item.children)) {
|
|
128
|
+
const childLabel = findSingleLabelByValue(value, item.children)
|
|
129
|
+
// 只有找到真正匹配项时才返回(不是fallback的String(value))
|
|
130
|
+
if (childLabel !== String(value)) {
|
|
131
|
+
return childLabel
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// 如果找不到对应的label,降级返回原值
|
|
137
|
+
return String(value)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 处理 label 模式数据存储
|
|
142
|
+
* @param {object} form - 表单对象
|
|
143
|
+
* @param {string} fieldName - 字段名
|
|
144
|
+
* @param {any} currentValue - 当前值
|
|
145
|
+
* @param {Array} options - 选项数据
|
|
146
|
+
*/
|
|
147
|
+
export function processLabelModeData(form, fieldName, currentValue, options) {
|
|
148
|
+
// 确保 originData 对象存在
|
|
149
|
+
if (!form.originData) {
|
|
150
|
+
form.originData = {}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// 获取当前值对应的原始值
|
|
154
|
+
const originValue = getOriginValue(currentValue, options)
|
|
155
|
+
|
|
156
|
+
// 存储原始值到 originData 中
|
|
157
|
+
form.originData[fieldName] = originValue
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 处理 both 模式数据存储
|
|
162
|
+
* @param {object} form - 表单对象
|
|
163
|
+
* @param {string} fieldName - 字段名
|
|
164
|
+
* @param {any} currentValue - 当前值
|
|
165
|
+
* @param {Array} options - 选项数据
|
|
166
|
+
*/
|
|
167
|
+
export function processBothModeData(form, fieldName, currentValue, options) {
|
|
168
|
+
// 确保 labelData 对象存在
|
|
169
|
+
if (!form.labelData) {
|
|
170
|
+
form.labelData = {}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 获取当前值对应的标签值
|
|
174
|
+
const labelValue = findLabelByValue(currentValue, options)
|
|
175
|
+
|
|
176
|
+
// 存储标签值到 labelData 中
|
|
177
|
+
if (labelValue !== null && labelValue !== undefined) {
|
|
178
|
+
form.labelData[fieldName] = labelValue
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 获取原始值(用于label模式时获取originValue)
|
|
184
|
+
* @param {any} currentValue - 当前值
|
|
185
|
+
* @param {Array} options - 选项数据
|
|
186
|
+
* @returns {any} 原始值,找不到时返回currentValue作为fallback
|
|
187
|
+
*/
|
|
188
|
+
export function getOriginValue(currentValue, options) {
|
|
189
|
+
console.log('getOriginValue', options)
|
|
190
|
+
if (!Array.isArray(options) || currentValue === undefined || currentValue === null) {
|
|
191
|
+
return currentValue
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// 多选情况
|
|
195
|
+
if (Array.isArray(currentValue)) {
|
|
196
|
+
const originValues = []
|
|
197
|
+
for (const val of currentValue) {
|
|
198
|
+
const originVal = findOriginValueByLabel(val, options)
|
|
199
|
+
// 只有找到真正的原始值时才使用originVal(不是fallback值)
|
|
200
|
+
if (originVal !== val) {
|
|
201
|
+
originValues.push(originVal)
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
// 如果没找到原始值,保留当前值
|
|
205
|
+
originValues.push(val)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return originValues
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 单选情况
|
|
212
|
+
return findOriginValueByLabel(currentValue, options)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 根据label查找原始value值
|
|
217
|
+
* @param {any} label - 标签值
|
|
218
|
+
* @param {Array} options - 选项数据
|
|
219
|
+
* @returns {any} 原始值,找不到时返回label作为fallback
|
|
220
|
+
*/
|
|
221
|
+
function findOriginValueByLabel(label, options) {
|
|
222
|
+
for (const item of options) {
|
|
223
|
+
// 如果有originValue,说明是经过label模式转换的
|
|
224
|
+
if (item.originValue !== undefined && String(item.value) === String(label)) {
|
|
225
|
+
return item.originValue
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// 递归查找树形结构
|
|
229
|
+
if (item.children && Array.isArray(item.children) && item.children.length > 0) {
|
|
230
|
+
const childOriginValue = findOriginValueByLabel(label, item.children)
|
|
231
|
+
// 只有当找到真正的匹配项时才返回(不等于传入的label)
|
|
232
|
+
if (childOriginValue !== label) {
|
|
233
|
+
return childOriginValue
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return label // 如果找不到,返回原值
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 创建selectValueType处理器的工厂函数
|
|
243
|
+
* @returns {object} 处理器对象
|
|
244
|
+
*/
|
|
245
|
+
export function createSelectValueTypeHandler() {
|
|
246
|
+
return {
|
|
247
|
+
// 预处理options数据
|
|
248
|
+
processOptions(options, selectValueType) {
|
|
249
|
+
return processOptionsForValueType(options, selectValueType)
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
// 查找label值
|
|
253
|
+
findLabel(value, options) {
|
|
254
|
+
return findLabelByValue(value, options)
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
// 处理both模式数据
|
|
258
|
+
processBothMode(form, fieldName, currentValue, options) {
|
|
259
|
+
return processBothModeData(form, fieldName, currentValue, options)
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
// 处理label模式数据
|
|
263
|
+
processLabelMode(form, fieldName, currentValue, options) {
|
|
264
|
+
return processLabelModeData(form, fieldName, currentValue, options)
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
// 获取原始值
|
|
268
|
+
getOriginValue(currentValue, options) {
|
|
269
|
+
return getOriginValue(currentValue, options)
|
|
270
|
+
},
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export default {
|
|
275
|
+
processOptionsForValueType,
|
|
276
|
+
processOptionsForLabelType,
|
|
277
|
+
findLabelByValue,
|
|
278
|
+
findSingleLabelByValue,
|
|
279
|
+
processLabelModeData,
|
|
280
|
+
processBothModeData,
|
|
281
|
+
getOriginValue,
|
|
282
|
+
createSelectValueTypeHandler,
|
|
283
|
+
}
|