QuickShipmentModal.vue 2.88 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, selectOutPort, shipmentInventoryHeader} from '@/api/api'

export default {
  name: 'QuickShipmentModel',
  components: { },
  data() {
    return {
      title: '操作',
      width: 400,
      portList: [],
      inventoryHeaderList: [],
      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.inventoryHeaderList = record;
      this.getPortList();
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.$refs.form.clearValidate()
    },
    getPortList() {
      this.querySource.containerCode = this.model.containerCode
      selectOutPort(this.querySource).then(res => {
        if (res.success) {
          this.portList = res.result;
          this.visible = true;
        }
      })
    },
    handleOk() {
      if (this.model.outPortCode === ''){
        this.$message.warning('请选择出库口');
      }
      this.inventoryHeaderList.forEach(x=>{
        x["toPortCode"]=this.model.outPortCode;
      })
      shipmentInventoryHeader(this.inventoryHeaderList).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>