|
@@ -51,15 +51,17 @@
|
|
|
<template #default="{ row }">
|
|
|
<el-select
|
|
|
v-if="row.unitType !== '无'"
|
|
|
- v-model="row.unit"
|
|
|
+ v-model="row.unitDef"
|
|
|
placeholder="请选择"
|
|
|
+ @focus="fetchUnitsForRow(row)"
|
|
|
+ :loading="moreOptionsLoading"
|
|
|
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-option>
|
|
|
</el-select>
|
|
@@ -327,6 +329,11 @@ const resultChartKey = ref(0) // 用于强制刷新图表
|
|
|
const resultxLabel = ref("时间(s)")
|
|
|
const resultyLabel = ref("")
|
|
|
|
|
|
+// 单位选项缓存
|
|
|
+const unitOptionsCache = ref({});
|
|
|
+// 更多选项加载状态
|
|
|
+const moreOptionsLoading = ref(false);
|
|
|
+
|
|
|
const closePanel = () => {
|
|
|
emit("close")
|
|
|
}
|
|
@@ -636,14 +643,18 @@ const savecomvalue = () => {
|
|
|
console.log("comdata:", comdata.value)
|
|
|
// dataType 为 -1 的数据
|
|
|
const validItems = comdata.value.filter((item) => item.dataType === -1)
|
|
|
+ console.log("validItemsddddddddddddd:", validItems);
|
|
|
+
|
|
|
const pcavals = validItems
|
|
|
.map((item) => {
|
|
|
const pcaId = item.pcaId ?? ""
|
|
|
const value = item.value ?? ""
|
|
|
- const unit = item.unit ?? ""
|
|
|
+ const unit = item.unitDef ?? ""
|
|
|
return `${pcaId},${value},${unit}`
|
|
|
})
|
|
|
- .join(";")
|
|
|
+ .join(";");
|
|
|
+ console.log("pcavals:ssssssssssss", pcavals);
|
|
|
+
|
|
|
const params = {
|
|
|
transCode: "ES0008",
|
|
|
pcavals: pcavals
|
|
@@ -948,6 +959,41 @@ const openresultline = (name, unit, coms) => {
|
|
|
resultlinedialog.value = true
|
|
|
}
|
|
|
|
|
|
+// 组件参数点击下拉框调用接口获取单位
|
|
|
+const fetchUnitsForRow = async (row) => {
|
|
|
+ if (unitOptionsCache.value[row.unitType]) {
|
|
|
+ row.unitoptions = unitOptionsCache.value[row.gutId]
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
defineExpose({
|
|
|
getcomdata,
|
|
|
getresultData
|