QualityInventoryDetailModal.vue 3.07 KB
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="出库口" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outPortCode">
              <a-select
                show-search
                placeholder="请选择出库口"
                option-filter-prop="children"
                v-model="model.outPortCode"
              >
                <a-select-option v-for="item in portList" :key="item.name" :value="item.code">
                  {{ item.name }}
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
import { getZoneList, selectPickPort, shipmentInventoryDetail, qualityInventoryDetail } from '@/api/api'

export default {
  name: 'QualityInventoryDetailModal',
  components: {},
  data() {
    return {
      title: '操作',
      width: 400,
      portList: [],
      inventoryDetailList: [],
      querySource: {},
      visible: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      // 选择用户查询条件配置
      selectUserQueryConfig: [],
      confirmLoading: false,
      validatorRules: {
        outPortCode: [{ required: true, message: '请选择出库口!' }]
      }
    }
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
  },
  methods: {
    add() {
      this.edit(this.modelDefault)
    },
    edit(record) {
      this.visible = true
      this.model.containerCode = record[0].containerCode
      this.inventoryDetailList = record
      this.getPortList()
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.$refs.form.clearValidate()
    },
    getPortList() {
      this.querySource.containerCode = this.model.containerCode
      selectPickPort(this.querySource).then(res => {
        if (res.success) {
          this.portList = res.result
          if (this.portList.length == 1) {
            this.model.outPortCode = this.portList[0].code;
          }
        }
      })
    },
    handleOk() {
      if (this.model.outPortCode === '') {
        this.$message.warning('请选择出库口')
      }
      this.inventoryDetailList.forEach(x => {
        x['toPortCode'] = this.model.outPortCode
      })
      qualityInventoryDetail(this.inventoryDetailList).then(res => {
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
      })
      this.$emit('ok', this.model.outPortCode)
      this.close()
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>