|
|
@@ -996,6 +996,24 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ const normalizeObjpResult = (result) => {
|
|
|
+ const normalized = [];
|
|
|
+ if (!result) return normalized;
|
|
|
+ if (Array.isArray(result)) {
|
|
|
+ result.forEach((item) => {
|
|
|
+ if (!item || typeof item !== "object") return;
|
|
|
+ const entry = Object.entries(item)[0];
|
|
|
+ if (!entry) return;
|
|
|
+ normalized.push({ label: entry[1], value: entry[0] });
|
|
|
+ });
|
|
|
+ return normalized;
|
|
|
+ }
|
|
|
+ Object.keys(result).forEach((key) => {
|
|
|
+ normalized.push({ label: result[key], value: key });
|
|
|
+ });
|
|
|
+ return normalized;
|
|
|
+ };
|
|
|
+
|
|
|
// 功能说明:封装 modelValue 变化后的联动逻辑,兼容用户点击和桥接 API 赋值 by xu 20260416
|
|
|
const handleModelValueChange = (newValue) => {
|
|
|
updateSelectItem();
|
|
|
@@ -1022,10 +1040,10 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
return;
|
|
|
}
|
|
|
if (response.data.result) {
|
|
|
- const keys = Object.keys(response.data.result);
|
|
|
- if (keys.length === 1) {
|
|
|
- let code = keys[0];
|
|
|
- let desc = response.data.result[keys[0]];
|
|
|
+ const normalizedResult = normalizeObjpResult(response.data.result);
|
|
|
+ if (normalizedResult.length === 1) {
|
|
|
+ let code = normalizedResult[0].value;
|
|
|
+ let desc = normalizedResult[0].label;
|
|
|
props.opt.length = 0;
|
|
|
props.opt.push({ label: desc, value: code });
|
|
|
updateSelectItem();
|
|
|
@@ -1105,10 +1123,10 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
}
|
|
|
|
|
|
if (response.data.result) {
|
|
|
- const keys = Object.keys(response.data.result);
|
|
|
- if (keys.length === 1) {
|
|
|
- let code = keys[0];
|
|
|
- let desc = response.data.result[keys[0]];
|
|
|
+ const normalizedResult = normalizeObjpResult(response.data.result);
|
|
|
+ if (normalizedResult.length === 1) {
|
|
|
+ let code = normalizedResult[0].value;
|
|
|
+ let desc = normalizedResult[0].label;
|
|
|
if (props.opt)
|
|
|
props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
|
|
|
else {
|
|
|
@@ -1251,15 +1269,12 @@ import { EVEN_VAR } from "./EventBus.js";
|
|
|
}
|
|
|
|
|
|
if (response.data.result) {
|
|
|
- const keys = Object.keys(response.data.result);
|
|
|
+ const normalizedResult = normalizeObjpResult(response.data.result);
|
|
|
// console.log("params:"+params+"@@response.data:"+JSON.stringify(response.data));
|
|
|
- if (keys.length > 0) {
|
|
|
- for (let k in response.data.result) {
|
|
|
- props.opt.push({
|
|
|
- label: response.data.result[k],
|
|
|
- value: k,
|
|
|
- });
|
|
|
- }
|
|
|
+ if (normalizedResult.length > 0) {
|
|
|
+ normalizedResult.forEach((option) => {
|
|
|
+ props.opt.push(option);
|
|
|
+ });
|
|
|
|
|
|
// console.log('###inpTxt:'+inpTxt+';');
|
|
|
if (
|