ReceiveU8WarehouseModal.vue 4.56 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="0">
            <a-form-model-item>
              <a-input placeholder="" v-model="model.ids" id="ids" disabled="disabled"/>
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="24">
          <a-form-model-item label="账套" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyCode">
            <a-input v-model="model.companyCode" placeholder="" style="width: 100%"/>

          </a-form-model-item>

          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="U8仓库" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="uwarehouseCode">
            <a-select @change=""  placeholder="请选择U8仓库" v-model="model.uwarehouseCode">
              <a-select-option v-for="d in uWarehouseList" :key="d.uwarehouseCode" :value="d.uwarehouseCode">
                {{ d.uwarehouseName }}
              </a-select-option>
            </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import {checkWarehouse, getWarehouse} from "@api/api";

  export default {
    name: "ReceiveU8WarehouseModal",
    components: {
    },
    props:{
      mainId:{
        type:String,
        required:false,
        default:''
      }
    },
    data () {
      return {
        title:"操作",
        width:800,
        visible: false,
        materialList: {},
        companyList: [],
        querySource: {},
        uWarehouseList: [],
        companyCode:'',
        ids:'',
        model:{
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules: {
          uWarehouseList: [
            {required: true, message: '请选择U8仓库!'},
          ],

        },
        url: {
          add: "/receipt/receiveHeader/addReceiveDetail",
          edit: "/receipt/receiveHeader/editReceiveDetail",
        }

      }
    },
    created () {
    //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));

    },
    methods: {
      add () {
        let record={inventoryStatus:'good'}
        this.edit(record);
      },
      edit (record) {
        // this.model = Object.assign({}, record);
        this.visible = true;
        var ids = "";
        for (var a = 0; a < record.length; a++) {
          ids += record[a].id + ",";
        }
        this.model.ids=ids;
        this.model.companyCode=record[0].companyCode;
        this.getWarehouse(this.model.companyCode);
      },
      getWarehouse (companyCode) {
        console.log(companyCode)
        let data={
          "uCompanyCode":companyCode,
        }
        getWarehouse(data).then((res) => {
          if (res.success) {
            this.uWarehouseList=res.result;
          } else {
            this.$message.warning(res.message);
          }
        }).finally(() => {

        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },

      loadFrom() {
        getCompanyList().then((res) => {
          if (res.success) {
            this.companyList = res.result
          }
        });
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            this.model['receiveId'] = this.mainId
            checkWarehouse(this.model).then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.$emit('ok');
                that.model.containerCode = '';
              } else {
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false
          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>