<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="taskId">
              <a-input v-model="model.taskId" placeholder="请输入任务id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerNo">
              <a-input v-model="model.customerNo" placeholder="请输入客户编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerName">
              <a-input v-model="model.customerName" placeholder="请输入客户名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="服务号码（全）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="smsNumber">
              <a-input v-model="model.smsNumber" placeholder="请输入服务号码（全）"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="用户编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userNo">
              <a-input v-model="model.userNo" placeholder="请输入用户编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="入网时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="networkAccessTime">
              <a-input v-model="model.networkAccessTime" placeholder="请输入入网时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="用户状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userState">
              <a-input v-model="model.userState" placeholder="请输入用户状态"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="用户发展员工" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="staffInfo">
              <a-input v-model="model.staffInfo" placeholder="请输入用户发展员工"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="用户发展二级部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="staffDeptLevel2">
              <a-input v-model="model.staffDeptLevel2" placeholder="请输入用户发展二级部门"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="用户发展三级部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="staffDeptLevel3">
              <a-input v-model="model.staffDeptLevel3" placeholder="请输入用户发展三级部门"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="用户开通状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userOpenState">
              <a-input v-model="model.userOpenState" placeholder="请输入用户开通状态"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="码号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="smsNumberPrefix">
              <a-input v-model="model.smsNumberPrefix" placeholder="请输入码号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="号码详细用途" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="smsNumberUsage">
              <a-input v-model="model.smsNumberUsage" placeholder="请输入号码详细用途"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户经理" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountManager">
              <a-input v-model="model.accountManager" placeholder="请输入客户经理"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户经理手机号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountManagerPhone">
              <a-input v-model="model.accountManagerPhone" placeholder="请输入客户经理手机号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="码号使用单位联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerContacts">
              <a-input v-model="model.customerContacts" placeholder="请输入码号使用单位联系人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="码号使用单位联系人手机号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerContactsPhone">
              <a-input v-model="model.customerContactsPhone" placeholder="请输入码号使用单位联系人手机号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="合同到期时间（YYYY-MM-DD）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contractExpireTime">
              <j-date placeholder="请选择合同到期时间（YYYY-MM-DD）" v-model="model.contractExpireTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="码号证书到期时间（YYYY-MM-DD）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="smsNumberCertificateExpireTime">
              <j-date placeholder="请选择码号证书到期时间（YYYY-MM-DD）" v-model="model.smsNumberCertificateExpireTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="备案通知到期时间（YYYY-MM-DD）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="recordNoticeExpireTime">
              <j-date placeholder="请选择备案通知到期时间（YYYY-MM-DD）" v-model="model.recordNoticeExpireTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="增值业务许可证到期时间（YYYY-MM-DD）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="valueAddedLicenceExpireTime">
              <j-date placeholder="请选择增值业务许可证到期时间（YYYY-MM-DD）" v-model="model.valueAddedLicenceExpireTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="营业执照到期时间（YYYY-MM-DD）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessLicenceExpireTime">
              <j-date placeholder="请选择营业执照到期时间（YYYY-MM-DD）" v-model="model.businessLicenceExpireTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="合同签署主体与实际开通客户是否一致" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contractOpenCustomerSame">
              <a-input v-model="model.contractOpenCustomerSame" 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="dataComplete">
              <a-input v-model="model.dataComplete" placeholder="请输入资料是否完整"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否完成整改" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="rectifyReformOver">
              <a-input v-model="model.rectifyReformOver" placeholder="请输入是否完成整改"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description">
              <a-input v-model="model.description" placeholder="请输入描述"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="删除标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag">
              <a-input-number v-model="model.delFlag" placeholder="请输入删除标识" style="width: 100%" />
            </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: 'SmsCheckCustomerInfoForm',
    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: "/hi2/smsCheckCustomerInfo/add",
          edit: "/hi2/smsCheckCustomerInfo/edit",
          queryById: "/hi2/smsCheckCustomerInfo/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>