<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="8">
            <a-form-model-item label="物流公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="logistics">
              <a-input v-model.trim="model.logistics" placeholder="请输入物流公司"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="driverName">
              <a-input v-model.trim="model.driverName" placeholder="请输入姓名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="身份证" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="driverIdCard">
              <a-input v-model.trim="model.driverIdCard" placeholder="请输入身份证"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="driverTel">
              <a-input v-model.trim="model.driverTel" placeholder="请输入电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="预计到达" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="etaTime">
              <j-date v-model="model.etaTime" placeholder="请选择时间" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%;"></j-date>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="进厂门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="enterFactoryDoor">
              <a-input v-model.trim="model.enterFactoryDoor" placeholder="请输入进厂门"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="出厂门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="exitFactoryDoor">
              <a-input v-model.trim="model.exitFactoryDoor" 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: 'TakeForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        driverInfoList:[],
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 18 },
        },
        confirmLoading: false,
        validatorRules: {
          vdNo :[{required: true, message: '请选择用车需求编号!'}],
          shipType :[{required: true, message: '请选择发货类型!'}],
          carType :[{required: true, message: '请选择车型!'}],
          carLong :[{required: true, message: '请选择车长!'}],
          pickUpHub :[{required: true, message: '请选择取货仓库!'}],
          deliveryAddress :[{required: true, message: '请选择送货地点!'}],
          supplierCode :[{required: true, message: '请选择供应商编码!'}],
          carNum :[{required: true, message: '请输入车牌号!'}],
          logistics :[{required: true, message: '请输入物流公司!'}],
          driverName :[{required: true, message: '请输入司机姓名!'}],
          driverTel :[{required: true, message: '请输入电话!'}],
          etaTime :[{required: true, message: '请选择时间!'}],
          
        },
        url: {
          add: "/vehicledemandcount/vehicleDemandCount/add",
          take: "/vehicleinout/vehicleInOut/take",
          queryById: "/vehicledemandcount/vehicleDemandCount/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) {
            // 入厂类型: 送货
            this.model.efType = '0';
            httpAction(this.url.take,this.model,'post').then((res)=>{
              if(res.success){
                // that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>