You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
5.4 KiB

4 months ago
<template>
<div class="container">
<!-- 顶部信息 -->
<div class="containertop">
<div class="topleft">
<img src="../../../assets/images/detailsicon/1.png" alt="">
<span>五要素模型信息</span>
4 months ago
</div>
3 months ago
<div class="topright" v-if="action === 'fill' || !action">
4 months ago
<el-button type="primary" size="medium" plain
3 months ago
style="border: none;background-color: rgba(43,98,241,0.1);color: #2B62F1;" @click="toggleEditAll">
<img src="../../../assets/images/detailsicon/icon-bj@2x.png" alt="编辑"
style="width: 0.6rem; height: 0.6rem; margin-right: 4px;">
3 months ago
{{ isEditingAll ? '保存' : '编辑' }}
</el-button>
</div>
</div>
<!-- 内容区 -->
<div class="content">
<div class="descriptionsdiv">
<div>
<table class="custom-table">
3 months ago
<tr v-for="(row, rowIndex) in form" :key="rowIndex" style="border: 1px solid #E5E5E5;">
<td class="left-column">{{ row.ysmc }}</td>
<td class="right-columns" v-for="(item, itemIndex) in row.list" :key="itemIndex">
<div v-if="item.isEditing">
<span class="label-color">{{ item.zdname }}</span>
<el-input v-model="item.zdinfor" size="small" style="width: 12rem;"></el-input>
</div>
<div v-else>
<span class="label-color">{{ item.zdname }}</span> {{ item.zdinfor || '无' }}
</div>
</td>
</tr>
</table>
</div>
4 months ago
</div>
</div>
</div>
</template>
<script>
export default {
3 months ago
name: "Models",
props: {
wysmxInfo: {
type: Array,
required: true,
3 months ago
},
action: {
type: String,
required: true
3 months ago
}
},
data() {
return {
3 months ago
isEditingAll: false,
form: []
};
},
3 months ago
watch: {
wysmxInfo: {
immediate: true,
handler(newVal) {
3 months ago
console.log('接收到的 wysmxInfo 数据:', newVal);
3 months ago
this.form = newVal.map(item => ({
3 months ago
id: item.id,
xmId: item.xmId,
3 months ago
ysmc: item.ysmc,
list: item.list.map(subItem => ({
zdname: subItem.zdname,
zdinfor: subItem.zdinfor,
isEditing: false
}))
}));
}
}
},
methods: {
toggleEditAll() {
3 months ago
if (this.isEditingAll) {
// 保存模式:过滤掉 isEditing 字段
const cleanedForm = this.form.map(row => ({
ysmc: row.ysmc,
id: row.id,
xmId: row.xmId,
list: row.list.map(item => ({
zdname: item.zdname,
zdinfor: item.zdinfor,
}))
}));
this.$emit('updata-data', cleanedForm); // 传递过滤后的数据
} else {
// 编辑模式:开启所有字段的编辑状态
this.form.forEach(row => {
row.list.forEach(item => {
item.isEditing = true;
});
3 months ago
});
3 months ago
}
this.isEditingAll = !this.isEditingAll;
3 months ago
}
},
created() {
3 months ago
console.log('wysmxInfo 内容:', this.wysmxInfo); // 初始化时打印数据
3 months ago
}
};
4 months ago
</script>
<style scoped>
.container {
display: flex;
flex-direction: column;
width: 100%;
background-color: #FFFFFF;
box-shadow: 0rem 0.13rem 0.63rem 0rem rgba(177, 177, 177, 0.1);
4 months ago
border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
}
.content {
padding: 1rem;
display: flex;
}
.containertop {
4 months ago
height: auto;
display: flex;
justify-content: space-between;
padding: .7rem 0;
padding: .5rem;
border-bottom: 1px solid #E5E5E5;
4 months ago
}
.topleft {
width: 8rem;
3 months ago
height: 2rem;
4 months ago
display: flex;
gap: 0.4rem;
align-items: center;
}
.topleft img {
4 months ago
width: 0.81rem;
height: 0.81rem;
}
.topleft span {
4 months ago
width: auto;
height: 0.88rem;
font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
font-weight: 500;
font-size: 0.88rem;
color: #3D424C;
line-height: 0.88rem;
text-align: right;
font-style: normal;
text-transform: none;
}
.picturediv {
width: 18.31rem;
height: 25.31rem;
background-color: lightblue;
}
.descriptionsdiv {
width: 100%;
margin-left: 1rem;
height: auto;
}
.two-row-item {
height: 20rem;
}
.custom-table {
width: 100%;
border-collapse: collapse;
border: 1px solid #E6EAF2;
}
.custom-table th,
.custom-table td {
padding: 8px;
text-align: left;
border-top: 1px solid #E6EAF2;
border-bottom: 1px solid #E6EAF2;
}
.left-column {
border-right: 1px solid #E6EAF2;
background-color: #F4F7FE;
}
.right-columns {
border-right: none;
}
3 months ago
.label-color {
color: #808080;
}
3 months ago
</style>