gaoluyang
2025-03-18 18c2ed01fc7af3738fdc570aaa6ee97700fdb618
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<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>