<template>
|
<div>
|
<table border="1" cellpadding="10" class="thermal-table" style="margin-bottom: 20px;">
|
<tr>
|
<td style="font-size: 18px;font-weight: 500;background-color: #F0F1F5;padding: 10px 0;box-sizing: border-box;"
|
colspan="6">{{ currentInfo.inspectionItemSubclass }}</td>
|
</tr>
|
<tr>
|
<td style="font-size: 16px;background-color: #F0F1F5;">规格型号</td>
|
<td>{{ currentInfo.model }}</td>
|
<td style="font-size: 16px;background-color: #F0F1F5;">试验方法</td>
|
<td>{{ currentInfo.methodS }}</td>
|
<td style="font-size: 16px;background-color: #F0F1F5;">设备编号</td>
|
<td>
|
<el-select v-model="currentInfo.equipValue" placeholder="请选择" size="small" :disabled="state > 1"
|
@focus="methodFocus(item)" @change="m => handleEquip(m, currentInfo)">
|
<el-option v-for="item in equipOptions" :key="item.value" :label="item.label" :value="item.value">
|
</el-option>
|
</el-select>
|
</td>
|
</tr>
|
<tr>
|
<td style="font-size: 16px;background-color: #F0F1F5;">试验要求</td>
|
<td colspan="3" style="text-align: left;">{{ currentInfo.tell }}</td>
|
<td style="font-size: 16px;background-color: #F0F1F5;">设备名称</td>
|
<td>{{ currentInfo.equipName }}</td>
|
</tr>
|
<tr>
|
<td style="font-size: 16px;background-color: #F0F1F5;">端口</td>
|
<td colspan="3" style="font-size: 16px;background-color: #F0F1F5;">平均功率容量(W)</td>
|
<td colspan="2" style="font-size: 16px;background-color: #F0F1F5;">峰值功率容量(W)</td>
|
</tr>
|
<tr v-for="(item, index) in currentInfo.list" :key="index">
|
<td>{{ index + 1 }}</td>
|
<td colspan="3">
|
<el-input v-model="item.power" placeholder="" size="small" @change="m => save(currentInfo)"
|
:disabled="state > 1"></el-input>
|
</td>
|
<td colspan="2">
|
<el-input v-model="item.peakPower" placeholder="" size="small" @change="m => save(currentInfo)"
|
:disabled="state > 1"></el-input>
|
</td>
|
</tr>
|
</table>
|
</div>
|
</template>
|
|
<script>
|
export default {
|
props: ['insProduct', 'orderId', 'sampleId', 'state', 'isLook', 'num'],
|
data() {
|
return {
|
currentInfo: {},
|
equipOptions: [],
|
}
|
},
|
watch: {
|
insProduct: {
|
deep: true,
|
handler(val) {
|
this.init()
|
}
|
}
|
},
|
mounted() {
|
this.init()
|
},
|
methods: {
|
init() {
|
this.currentInfo = this.HaveJson(this.insProduct[0])
|
if (!this.currentInfo.insProductResult) {
|
// 没有检验时初始化
|
this.$set(this.currentInfo, 'equipValue', '')
|
this.$set(this.currentInfo, 'equipName', '')
|
let portNum = Number(this.currentInfo.ask.split(':')[1])
|
this.$set(this.currentInfo, 'list', [])
|
for (let i = 0; i < portNum; i++) {
|
this.$set(this.currentInfo.list, i, { 'power': null, 'peakPower': null })
|
}
|
} else {
|
// 有检验时初始化
|
this.$set(this.currentInfo, 'equipValue', this.currentInfo.insProductResult.equipValue ? JSON.parse(this.currentInfo.insProductResult.equipValue)[0].v : '')
|
this.$set(this.currentInfo, 'equipName', this.currentInfo.insProductResult.equipName ? JSON.parse(this.currentInfo.insProductResult.equipName)[0].v : '')
|
this.currentInfo.list = JSON.parse(this.currentInfo.insProductResult.insValue)
|
}
|
},
|
async methodFocus(item) {
|
this.equipOptions = await this.getEquipOptions(item)
|
},
|
// 获取设备选项 id:为检验项id
|
async getEquipOptions(m) {
|
let arr = []
|
let res = await this.$axios.post(this.$api.deviceScope.selectDeviceByCategory, {
|
inspectionItem: m.inspectionItem,
|
inspectionItemSubclass: m.inspectionItemSubclass
|
})
|
if (res.code === 200 && res.data) {
|
arr = res.data.map(m => {
|
m.value = m.managementNumber
|
m.label = m.deviceName
|
return m
|
})
|
}
|
return arr
|
},/**
|
* 处理设备信息
|
*
|
* @param {any} m - 新的设备值
|
* @param {Object} item - 设备对象
|
*/
|
handleEquip(m, item) {
|
this.$delete(item, 'equipValue')
|
this.$set(item, 'equipValue', m)
|
this.$delete(item, 'equipName')
|
this.$set(item, 'equipName', this.equipOptions.find(m => m.value == item.equipValue).label)
|
this.save(item)
|
},
|
save(item) {
|
this.$axios.post(this.$api.insOrderPlan.saveInsContext3, {
|
insProductId: item.id,
|
insValue: JSON.stringify(item.list),
|
equipValue: item.equipValue,
|
equipName: item.equipName,
|
num: this.num,
|
}, {
|
headers: {
|
'Content-Type': 'application/json'
|
},
|
noQs: true
|
}).then(res => {
|
if (res.code === 201) {
|
this.$message.error('保存失败')
|
return
|
}
|
this.$message.success('已保存')
|
}).catch(err => {
|
console.log(err)
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="css" scoped>
|
.thermal-table {
|
min-width: calc(100% - 10px);
|
margin: 5px 5px 0;
|
table-layout: fixed;
|
}
|
|
.thermal-table td {
|
min-width: 70px;
|
text-align: center;
|
font-size: 14px;
|
word-wrap: break-word;
|
white-space: normal;
|
padding: 5px;
|
}
|
|
.thermal-table .el-input {
|
display: flex;
|
align-items: center;
|
}
|
|
>>>.el-input__inner {
|
text-align: center;
|
}
|
</style>
|