<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="12">
            <a-form-model-item label="客户id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="infoId">
              <a-input v-model="model.infoId" placeholder="请输入客户id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="业务合同" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessContract">
              <a-input v-model="model.businessContract" placeholder="请输入业务合同"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="号码证书" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="smsNumberCertificate">
              <a-input v-model="model.smsNumberCertificate" placeholder="请输入号码证书"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="备案通知" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="recordNotice">
              <a-input v-model="model.recordNotice" placeholder="请输入备案通知"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="集团政企价格审批单" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="groupPriceApproval">
              <a-input v-model="model.groupPriceApproval" placeholder="请输入集团政企价格审批单"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="营业执照" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessLicence">
              <a-input v-model="model.businessLicence" placeholder="请输入营业执照"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户介绍信" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerIntroductionLetter">
              <a-input v-model="model.customerIntroductionLetter" placeholder="请输入客户介绍信"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="经办人身份复印件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="handlerIdNumberCopy">
              <a-input v-model="model.handlerIdNumberCopy" placeholder="请输入经办人身份复印件"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="CRM 没有行短业务截图" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="crmScreenshot">
              <a-input v-model="model.crmScreenshot" placeholder="请输入CRM 没有行短业务截图"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="增值业务许可证" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="valueAddedLicence">
              <a-input v-model="model.valueAddedLicence" placeholder="请输入增值业务许可证"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="员工id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="staffId">
              <a-input v-model="model.staffId" placeholder="请输入员工id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="员工编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="staffNo">
              <a-input v-model="model.staffNo" 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: 'SmsCheckCustomerDataForm',
    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: "/hi4/smsCheckCustomerData/add",
          edit: "/hi4/smsCheckCustomerData/edit",
          queryById: "/hi4/smsCheckCustomerData/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>