|
@@ -45,15 +45,17 @@
|
|
|
<template #default="{ row }">
|
|
|
<el-select
|
|
|
v-if="row.unitType !== '无'"
|
|
|
- v-model="row.unit"
|
|
|
+ v-model="row.unitDef"
|
|
|
placeholder="请选择"
|
|
|
+ :loading="moreOptionsLoading"
|
|
|
+ @focus="fetchUnitsForRow(row)"
|
|
|
class="full-width-select"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="option in row.unitoptions"
|
|
|
- :key="option.val"
|
|
|
- :label="option.tag"
|
|
|
- :value="option.val"
|
|
|
+ :key="option.utId"
|
|
|
+ :label="option.value"
|
|
|
+ :value="option.value"
|
|
|
/>
|
|
|
</el-select>
|
|
|
<div v-else>{{ row.unitType }}</div>
|
|
@@ -80,6 +82,11 @@ const tableSLData = ref([])
|
|
|
|
|
|
const runtype = ref('') // 用于分开不同求解运行
|
|
|
|
|
|
+// 单位选项缓存
|
|
|
+const unitOptionsCache = ref({});
|
|
|
+// 更多选项加载状态
|
|
|
+const moreOptionsLoading = ref(false);
|
|
|
+
|
|
|
let emit = defineEmits(['selectRunType']);
|
|
|
|
|
|
function openDialog(pid) {
|
|
@@ -91,6 +98,42 @@ function closeDialog() {
|
|
|
visible.value = false
|
|
|
}
|
|
|
|
|
|
+// 组件参数点击下拉框调用接口获取单位
|
|
|
+const fetchUnitsForRow = async (row) => {
|
|
|
+ if (unitOptionsCache.value[row.unitType]) {
|
|
|
+ row.unitoptions = unitOptionsCache.value[row.unitType]
|
|
|
+ if (!row.unitDef && row.unitOptions.length > 0) {
|
|
|
+ row.unitDef = row.unitOptions[0].value
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ moreOptionsLoading.value = true;
|
|
|
+
|
|
|
+ const params = {
|
|
|
+ transCode: "ES0019",
|
|
|
+ gutId: row.unitType
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const res = await request(params)
|
|
|
+ row.unitoptions = res.rows || []
|
|
|
+ console.log("单位选项获取成功", row.unitoptions );
|
|
|
+
|
|
|
+ unitOptionsCache.value[row.unitType] = row.unitoptions
|
|
|
+ if (!row.unitType && row.unitoptions .length > 0) {
|
|
|
+ row.unitDef = row.unitoptions [0].value
|
|
|
+ }
|
|
|
+ moreOptionsLoading.value = false;
|
|
|
+ } catch (err) {
|
|
|
+ moreOptionsLoading.value = false;
|
|
|
+ ElMessage.error(err.returnMsg || t("error.fetchFailed"))
|
|
|
+ row.unitoptions = []
|
|
|
+ unitOptionsCache.value[row.unitType] = []
|
|
|
+ } finally {
|
|
|
+ moreOptionsLoading.value = false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
const getSLData = async ( pid ) => {
|
|
|
const params = {
|
|
|
transCode: "ES0012",
|
|
@@ -101,7 +144,8 @@ const getSLData = async ( pid ) => {
|
|
|
const res = await request(params) // 使用 await 等待请求完成
|
|
|
tableSLData.value = res.rows.map((item) => ({
|
|
|
...item,
|
|
|
- isVisible: true // 默认所有行都可见
|
|
|
+ isVisible: true, // 默认所有行都可见
|
|
|
+ unitDef: item.unit || item.unitDef || ""
|
|
|
}))
|
|
|
console.log("tableSLData.value", tableSLData.value)
|
|
|
|
|
@@ -117,7 +161,7 @@ const getSLData = async ( pid ) => {
|
|
|
}
|
|
|
|
|
|
if (item.unitType !== "无") {
|
|
|
- promises.push(getlistopt(item, "unit"))
|
|
|
+ // promises.push(getlistopt(item, "unit"))
|
|
|
} else {
|
|
|
item.unit = "无"
|
|
|
}
|
|
@@ -143,7 +187,7 @@ const saveSLTabelDialog = () => {
|
|
|
.map((item) => {
|
|
|
const pcaId = item.pcaId ?? ""
|
|
|
const value = item.value ?? ""
|
|
|
- const unit = item.unit ?? ""
|
|
|
+ const unit = item.unitDef != '' ? item.unitDef : "无"
|
|
|
return `${pcaId},${value},${unit}`
|
|
|
})
|
|
|
.join(";")
|