spring
2025-03-19 07a41ade45c962e93a9d449ce1be0eec52e66a6a
src/components/do/b1-inspect-order-plan/power-capacity.vue
@@ -2,28 +2,26 @@
  <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>
        <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>{{ currentInfo.model }}</td>
        <td style="font-size: 16px;background-color: #F0F1F5;">试验方法</td>
        <td>{{currentInfo.methodS}}</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-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 colspan="3" style="text-align: left;">{{ currentInfo.tell }}</td>
        <td style="font-size: 16px;background-color: #F0F1F5;">设备名称</td>
        <td>{{ currentInfo.equipName }}</td>
      </tr>
@@ -32,13 +30,15 @@
        <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>
      <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>
          <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>
          <el-input v-model="item.peakPower" placeholder="" size="small" @change="m => save(currentInfo)"
            :disabled="state > 1"></el-input>
        </td>
      </tr>
    </table>
@@ -47,17 +47,17 @@
<script>
export default {
  props:['insProduct','orderId','sampleId','state','isLook','num'],
  props: ['insProduct', 'orderId', 'sampleId', 'state', 'isLook', 'num'],
  data() {
    return {
      currentInfo:{},
      equipOptions:[],
      currentInfo: {},
      equipOptions: [],
    }
  },
  watch: {
    insProduct:{
      deep:true,
      handler(val){
    insProduct: {
      deep: true,
      handler(val) {
        this.init()
      }
    }
@@ -66,25 +66,25 @@
    this.init()
  },
  methods: {
    init(){
    init() {
      this.currentInfo = this.HaveJson(this.insProduct[0])
      if(!this.currentInfo.insProductResult){
      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})
        for (let i = 0; i < portNum; i++) {
          this.$set(this.currentInfo.list, i, { 'power': null, 'peakPower': null })
        }
      }else{
      } else {
        // 有检验时初始化
        this.$set(this.currentInfo, 'equipValue', this.currentInfo.insProductResult.equipValue)
        this.$set(this.currentInfo, 'equipName', this.currentInfo.insProductResult.equipName)
        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){
    async methodFocus(item) {
      this.equipOptions = await this.getEquipOptions(item)
    },
    // 获取设备选项 id:为检验项id
@@ -108,25 +108,26 @@
   * @param {any} m - 新的设备值
   * @param {Object} item - 设备对象
   */
    handleEquip(m,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.$set(item, 'equipName', this.equipOptions.find(m => m.value == item.equipValue).label)
      this.save(item)
    },
    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,
        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 => {
        headers: {
          'Content-Type': 'application/json'
        },
        noQs: true
      }).then(res => {
        if (res.code === 201) {
          this.$message.error('保存失败')
          return
@@ -141,24 +142,27 @@
</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;
  }
.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>