<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="物料编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wlbm">
              <a-input v-model="model.wlbm" placeholder="请输入物料编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="物料名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wlmc">
              <a-input v-model="model.wlmc" placeholder="请输入物料名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="规格型号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ggxh">
              <a-input v-model="model.ggxh" placeholder="请输入规格型号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="牌号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ph">
              <a-input v-model="model.ph" placeholder="请输入牌号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="详细技术规范" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xxjsgf">
              <a-input v-model="model.xxjsgf" placeholder="请输入详细技术规范"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="技术标准" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jsbz">
              <a-input v-model="model.jsbz" placeholder="请输入技术标准"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="质量等级" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zldj">
              <a-input v-model="model.zldj" placeholder="请输入质量等级"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="封装形式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fzxs">
              <a-input v-model="model.fzxs" placeholder="请输入封装形式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="生产厂家" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sccj">
              <a-input v-model="model.sccj" placeholder="请输入生产厂家"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="国产进口" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gcjk">
              <a-input v-model="model.gcjk" placeholder="请输入国产进口"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="采购单价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cgdj">
              <a-input-number v-model="model.cgdj" placeholder="请输入采购单价" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="内部单价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nbdj">
              <a-input-number v-model="model.nbdj" placeholder="请输入内部单价" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备料计划单据号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bljhdjh">
              <a-input v-model="model.bljhdjh" placeholder="请输入备料计划单据号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="行号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hh">
              <a-input v-model="model.hh" placeholder="请输入行号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="出库日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckrq">
              <a-input v-model="model.ckrq" placeholder="请输入出库日期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="实发主数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfzsl">
              <a-input-number v-model="model.sfzsl" placeholder="请输入实发主数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="应发主数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yfzsl">
              <a-input-number v-model="model.yfzsl" placeholder="请输入应发主数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="入库批次号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="rkpch">
              <a-input v-model="model.rkpch" placeholder="请输入入库批次号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="型号规格技术指标" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xhgljszb">
              <a-input v-model="model.xhgljszb" placeholder="请输入型号规格技术指标"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="工序单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gxdh">
              <a-input v-model="model.gxdh" placeholder="请输入工序单号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="DPA号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dpah">
              <a-input v-model="model.dpah" placeholder="请输入DPA号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="合格证上传情况" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hgzscqk">
              <a-input v-model="model.hgzscqk" placeholder="请输入合格证上传情况"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="质保有效期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zbyxq">
              <a-input v-model="model.zbyxq" placeholder="请输入质保有效期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="外观标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wgbs">
              <a-input v-model="model.wgbs" placeholder="请输入外观标识"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="供应商批次号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gyspch">
              <a-input v-model="model.gyspch" placeholder="请输入供应商批次号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="库位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="kwh">
              <a-input v-model="model.kwh" placeholder="请输入库位号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="质保单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zbdw">
              <a-input v-model="model.zbdw" placeholder="请输入质保单位"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="质保依据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zbyj">
              <a-input v-model="model.zbyj" placeholder="请输入质保依据"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="任务号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="rwh">
              <a-input v-model="model.rwh" placeholder="请输入任务号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="元器件分类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yqjfl">
              <a-input v-model="model.yqjfl" placeholder="请输入元器件分类"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="出库备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckbz">
              <a-input v-model="model.ckbz" placeholder="请输入出库备注"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="出库单表头主键" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckdbtzj">
              <a-input v-model="model.ckdbtzj" placeholder="请输入出库单表头主键"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="出库单表体主键" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckdbtizj">
              <a-input v-model="model.ckdbtizj" placeholder="请输入出库单表体主键"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="来源单据号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lydjh">
              <a-input v-model="model.lydjh" placeholder="请输入来源单据号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="来源单类型编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lydlxbm">
              <a-input v-model="model.lydlxbm" placeholder="请输入来源单类型编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="来源交易类型主键" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lyjylxzj">
              <a-input v-model="model.lyjylxzj" placeholder="请输入来源交易类型主键"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="件数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="js">
              <a-input v-model="model.js" placeholder="请输入件数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="条码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tm">
              <a-input v-model="model.tm" placeholder="请输入条码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="出库单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckdh">
              <a-input v-model="model.ckdh" placeholder="请输入出库单号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="复验单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fydw">
              <a-input v-model="model.fydw" placeholder="请输入复验单位"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="最新时间戳" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zxsjc">
              <a-input v-model="model.zxsjc" placeholder="请输入最新时间戳"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'WzOutboundOrderBForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/wzOutboundOrder/wzOutboundOrderB/add",
          edit: "/wzOutboundOrder/wzOutboundOrderB/edit",
          queryById: "/wzOutboundOrder/wzOutboundOrderB/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>