cuilei
23 小时以前 67fc2b4afea13210f74f50e42c294ede18cb499f
申请单出库页面增加额定寿命、使用寿命必填校验
已修改2个文件
64 ■■■■ 文件已修改
src/views/tms/modules/outBound/OutboundDetailSelectList.vue 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tms/modules/outBound/OutboundOrderSelectList.vue 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
src/views/tms/modules/outBound/OutboundOrderSelectList.vue
@@ -252,6 +252,24 @@
          this.$message.warning("请选择明细后再出库!")
          return
        }
        // 先验证所有选中项
        const validationErrors = [];
        for (let i = 0; i < this.selectionRows.length; i++) {
          const item = this.selectionRows[i];
          // 检查必填字段
          if (item.accuracyClass === '1') { // 只有在不禁用状态下才需要校验必填
            if (this.$refs.outboundDetailSelectList.isFieldEmpty(item.ratedLife)) {
              validationErrors.push(`明细第${i+1}行:额定寿命为必填项`);
            }
            if (this.$refs.outboundDetailSelectList.isFieldEmpty(item.useLife)) {
              validationErrors.push(`明细第${i+1}行:使用寿命为必填项`);
            }
          }
        }
        if (validationErrors.length > 0) {
          this.$message.error(validationErrors.join(';'));
          return;
        }
        const params = this.selectionRows.map((item) => {
          return {
            outBoundOrderId: this.selectedMainId,