|
@@ -11,7 +11,7 @@
|
|
|
<el-tab-pane label="数据" name="data" style="height: 100%">
|
|
|
<Splitpanes horizontal>
|
|
|
<Pane min-size="20" size="50" max-size="80">
|
|
|
- <el-table :data="comdata" border class="datatable">
|
|
|
+ <el-table :data="filteredData" border class="datatable">
|
|
|
<el-table-column type="index" width="40" label="" />
|
|
|
<el-table-column prop="name" label="属性"> </el-table-column>
|
|
|
<el-table-column prop="value" label="值">
|
|
@@ -21,6 +21,7 @@
|
|
|
v-model="row.value"
|
|
|
placeholder="请选择"
|
|
|
class="full-width-select"
|
|
|
+ @change="(val) => handleShapeChange(row, val)"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="option in row.options"
|
|
@@ -224,12 +225,7 @@
|
|
|
<h4 :id="titleId" :class="titleClass">{{ dialogname }}</h4>
|
|
|
</div>
|
|
|
</template>
|
|
|
- <el-table
|
|
|
- :data="tableKVData"
|
|
|
- border
|
|
|
- height="300"
|
|
|
- style="width: 100%"
|
|
|
- >
|
|
|
+ <el-table :data="tableKVData" border height="300" style="width: 100%">
|
|
|
<el-table-column type="index" label="编号" width="60"></el-table-column>
|
|
|
<el-table-column prop="property" label="属性"></el-table-column>
|
|
|
<el-table-column prop="value" label="值">
|
|
@@ -286,8 +282,68 @@ const closePanel = () => {
|
|
|
emit("close")
|
|
|
}
|
|
|
|
|
|
+const filteredData = computed(() => {
|
|
|
+ return comdata.value ? comdata.value.filter((item) => item.isVisible) : []
|
|
|
+})
|
|
|
+
|
|
|
+// 定义形状与隐藏字段的映射
|
|
|
+const SHAPE_HIDDEN_FIELDS = {
|
|
|
+ 0: [
|
|
|
+ "SideLength",
|
|
|
+ "Width",
|
|
|
+ "Height",
|
|
|
+ "InnerWallThickness",
|
|
|
+ "OuterWallThickness",
|
|
|
+ "Inside",
|
|
|
+ "Outside"
|
|
|
+ ],
|
|
|
+ 1: [
|
|
|
+ "Diameter",
|
|
|
+ "Width",
|
|
|
+ "Height",
|
|
|
+ "InnerWallThickness",
|
|
|
+ "OuterWallThickness",
|
|
|
+ "Inside",
|
|
|
+ "Outside"
|
|
|
+ ],
|
|
|
+ 2: [
|
|
|
+ "Diameter",
|
|
|
+ "SideLength",
|
|
|
+ "InnerWallThickness",
|
|
|
+ "OuterWallThickness",
|
|
|
+ "Inside",
|
|
|
+ "Outside"
|
|
|
+ ],
|
|
|
+ 3: [
|
|
|
+ "Diameter",
|
|
|
+ "Width",
|
|
|
+ "Height",
|
|
|
+ "InnerWallThickness",
|
|
|
+ "OuterWallThickness",
|
|
|
+ "Inside",
|
|
|
+ "Outside"
|
|
|
+ ],
|
|
|
+ 4: ["Diameter", "SideLength", "Width", "Height", "PipeThickness"]
|
|
|
+}
|
|
|
+
|
|
|
+const handleShapeChange = (row, val) => {
|
|
|
+ if (row.code === "CrossSectionalShape") {
|
|
|
+ // 先重置所有行可见
|
|
|
+ comdata.value.forEach((item) => {
|
|
|
+ item.isVisible = true
|
|
|
+ })
|
|
|
+
|
|
|
+ // 隐藏对应形状不需要的字段
|
|
|
+ const fieldsToHide = SHAPE_HIDDEN_FIELDS[val] || []
|
|
|
+ comdata.value.forEach((item) => {
|
|
|
+ if (fieldsToHide.includes(item.code)) {
|
|
|
+ item.isVisible = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const getcomdata = async (pcId) => {
|
|
|
- // 改为 async 函数
|
|
|
const params = {
|
|
|
transCode: "ES0009",
|
|
|
pcId: pcId
|
|
@@ -296,7 +352,10 @@ const getcomdata = async (pcId) => {
|
|
|
try {
|
|
|
const res = await request(params) // 使用 await 等待请求完成
|
|
|
titlename.value = `${res.name}${res.idCode}${res.ser}`
|
|
|
- comdata.value = res.rows
|
|
|
+ comdata.value = res.rows.map((item) => ({
|
|
|
+ ...item,
|
|
|
+ isVisible: true // 默认所有行都可见
|
|
|
+ }))
|
|
|
console.log("comdata.value", comdata.value)
|
|
|
|
|
|
// 使用 for...of 循环以便使用 await
|
|
@@ -321,6 +380,13 @@ const getcomdata = async (pcId) => {
|
|
|
}
|
|
|
|
|
|
console.log("所有数据初始化完成")
|
|
|
+
|
|
|
+ // 查找截面形状行并触发初始处理
|
|
|
+ const shapeRow = comdata.value.find(item => item.code === "CrossSectionalShape")
|
|
|
+ if (shapeRow && shapeRow.value !== undefined) {
|
|
|
+ console.log("形状")
|
|
|
+ handleShapeChange(shapeRow, shapeRow.value)
|
|
|
+ }
|
|
|
} catch (err) {
|
|
|
console.error("初始化失败:", err)
|
|
|
ElMessage.error("初始化失败")
|
|
@@ -396,14 +462,14 @@ const getbtnvalue = (pcaId, dataType) => {
|
|
|
// 处理属性-值对形式
|
|
|
const kvData = []
|
|
|
// 记录行号
|
|
|
- let rowCount = 0;
|
|
|
+ let rowCount = 0
|
|
|
|
|
|
res.headers?.forEach((header) => {
|
|
|
// 找到对应的数据项
|
|
|
const dataItem = res.datas?.find(
|
|
|
(item) => item.cdvId === header.cdvId
|
|
|
)
|
|
|
- rowCount++;
|
|
|
+ rowCount++
|
|
|
|
|
|
kvData.push({
|
|
|
cdvId: header.cdvId,
|
|
@@ -420,7 +486,7 @@ const getbtnvalue = (pcaId, dataType) => {
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.error('err',err)
|
|
|
+ console.error("err", err)
|
|
|
ElMessage.error("值初始化失败")
|
|
|
})
|
|
|
}
|
|
@@ -636,8 +702,8 @@ const handleUnitChange = (column, newUnit) => {
|
|
|
const saveTabelDialog = () => {
|
|
|
// 检查表格数据是否为空
|
|
|
if (!tableData.value || tableData.value.length === 0) {
|
|
|
- ElMessage.warning("请设置正确的数据");
|
|
|
- return;
|
|
|
+ ElMessage.warning("请设置正确的数据")
|
|
|
+ return
|
|
|
}
|
|
|
console.log("表格数据:", tableData.value)
|
|
|
// 收集所有行数据
|
|
@@ -681,20 +747,27 @@ const saveTabelDialog = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-//
|
|
|
+//
|
|
|
// 关于KV表格弹窗的操作
|
|
|
//
|
|
|
const saveKVTabelDialog = () => {
|
|
|
// 检查表格数据是否为空
|
|
|
if (!tableKVData.value || tableKVData.value.length === 0) {
|
|
|
- ElMessage.warning("请设置正确的数据");
|
|
|
- return;
|
|
|
+ ElMessage.warning("请设置正确的数据")
|
|
|
+ return
|
|
|
}
|
|
|
- console.log('表格数据:',tableKVData.value)
|
|
|
- const result = tableKVData.value.map((item)=>{
|
|
|
- return [item.cdvId, item.pcadgId, item.pcadId, item.value, item.unit].join(',')
|
|
|
- }).join(";");
|
|
|
+ console.log("表格数据:", tableKVData.value)
|
|
|
+ const result = tableKVData.value
|
|
|
+ .map((item) => {
|
|
|
+ return [
|
|
|
+ item.cdvId,
|
|
|
+ item.pcadgId,
|
|
|
+ item.pcadId,
|
|
|
+ item.value,
|
|
|
+ item.unit
|
|
|
+ ].join(",")
|
|
|
+ })
|
|
|
+ .join(";")
|
|
|
// console.log('格式化后的字符串:', result);
|
|
|
const params = {
|
|
|
transCode: "ES0011",
|
|
@@ -712,7 +785,6 @@ const saveKVTabelDialog = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
defineExpose({
|
|
|
getcomdata
|
|
|
})
|