cuikaidong
21 小时以前 1c1000a93a88b5af5eabbf410aa264b0911dbee4
src/views/tms/modules/outBound/OutboundDetailSelectList.vue
@@ -16,21 +16,31 @@
        <template v-for="col in columns" :slot="col.dataIndex" slot-scope="text, record, index">
        <div :key="col.dataIndex">
          <a-input-number
            v-if="col.dataIndex === 'ratedLife'"
            :disabled="record.accuracyClass != '1'"
            :disabled="record.accuracyClass !== '1'"
            :value="text"
            @change="(e) => handleChange(e, record.key, col, index)"
            :min="1"
          />
          <div v-if="col.dataIndex === 'ratedLife' && record.accuracyClass === '1' && isFieldEmpty(record.ratedLife)"
               style="color: #ff4d4f; font-size: 12px;">
            必填
          </div>
          <a-input-number
            v-if="col.dataIndex === 'useLife'"
            :disabled="record.accuracyClass != '1'"
            :disabled="record.accuracyClass !== '1'"
            :value="text"
            @change="(e) => handleChange(e, record.key, col, index)"
            :min="1"
          />
          <div v-if="col.dataIndex === 'useLife' && record.accuracyClass === '1' && isFieldEmpty(record.useLife)"
               style="color: #ff4d4f; font-size: 12px;">
            必填
          </div>
        </div>
      </template>
@@ -208,6 +218,9 @@
      }
    },
    methods: {
      isFieldEmpty(value) {
        return value === undefined || value === null || value === '';
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
@@ -219,15 +232,19 @@
        this.ipagination.current = 1
      },
      handleOutbound(record) {
        console.log(this.mainId)
        console.log(record)
        // 先进行必填校验
        const errors = this.validateRequiredFields(record);
        if (errors.length > 0) {
          this.$message.error(errors.join(','));
          return;
        }
        const params = [
          {
            outBoundOrderId: this.mainId,
            outboundDetailId: record.id,
            outboundQuantity: record.outboundQuantity,
            ratedLife:record.ratedLife,
            useLife:record.useLife
            ratedLife: record.ratedLife,
            useLife: record.useLife
          }
        ]
        postAction(this.url.outbound, params).then(res=>{
@@ -249,8 +266,19 @@
          this.dataSource = temp
        }
      },
      validateRequiredFields(record) {
        const errors = [];
        // 只有在不禁用状态下才需要校验必填
        if (record.accuracyClass === '1') {
          if (this.isFieldEmpty(record.ratedLife)) {
            errors.push('额定寿命为必填项');
          }
          if (this.isFieldEmpty(record.useLife)) {
            errors.push('使用寿命为必填项');
          }
        }
        return errors;
      }
    }
  }
</script>