<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="qzr">
              <a-input v-model="model.qzr" placeholder="请输入签字人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="制单人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zdr">
              <a-input v-model="model.zdr" placeholder="请输入制单人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="领料员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lly">
              <a-input v-model="model.lly" placeholder="请输入领料员"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="领用部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lybm">
              <a-input v-model="model.lybm" placeholder="请输入领用部门"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="仓库" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ck">
              <a-input v-model="model.ck" placeholder="请输入仓库"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="库管员编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khybm">
              <a-input v-model="model.khybm" placeholder="请输入库管员编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="库管员名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="kgymc">
              <a-input v-model="model.kgymc" placeholder="请输入库管员名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="制单日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zdrq">
              <a-input v-model="model.zdrq" placeholder="请输入制单日期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="单据状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="djzt">
              <a-input v-model="model.djzt" placeholder="请输入单据状态"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="总数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zsl">
              <a-input v-model="model.zsl" placeholder="请输入总数量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="签字日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qzrq">
              <a-input v-model="model.qzrq" 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="ptzlh">
              <a-input v-model="model.ptzlh" 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="gcxh">
              <a-input v-model="model.gcxh" 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="bh">
              <a-input v-model="model.bh" placeholder="请输入板号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="设备名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sbmc">
              <a-input v-model="model.sbmc" placeholder="请输入设备名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="任务阶段" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="rwjd">
              <a-input v-model="model.rwjd" placeholder="请输入任务阶段"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="打印次数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dycs">
              <a-input v-model="model.dycs" placeholder="请输入打印次数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="出库单主键" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckdzj">
              <a-input v-model="model.ckdzj" 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: 'WzOutboundOrderHForm',
    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/wzOutboundOrderH/add",
          edit: "/wzOutboundOrder/wzOutboundOrderH/edit",
          queryById: "/wzOutboundOrder/wzOutboundOrderH/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>