<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="暂无相关信息"  ></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="createTime">
              <a-input v-model="model.createTime" placeholder="暂无相关信息"  ></a-input>
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="12">
            <a-form-model-item label="客户资料id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataId">
              <a-input v-model="model.dataId" placeholder="暂无相关信息"  ></a-input>
            </a-form-model-item>
          </a-col>-->
          <a-col :span="12">
            <a-form-model-item label="基本信息稽核状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="basicCheckState">
              <a-input-number v-model="model.basicCheckState" placeholder="暂无相关信息" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="基本信息稽核结果" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="basicCheckNote">
              <a-input v-model="model.basicCheckNote" placeholder="暂无相关信息"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="规范信息稽核状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardCheckState">
              <a-input-number v-model="model.standardCheckState" placeholder="暂无相关信息" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="规范信息稽核结果" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="istandardCheckNote">
              <a-input v-model="model.istandardCheckNote" placeholder="暂无相关信息"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="附件资料稽核状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataCheckState">
              <a-input-number v-model="model.dataCheckState" placeholder="暂无相关信息" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="附件资料稽核结果" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataCheckNote">
              <a-input v-model="model.dataCheckNote" 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="暂无相关信息"  ></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: 'SmsCheckWorkLogForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          style: { width: '29%' },
          xs: { span: 26 },
          sm: { span: 5 },

        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/hi4/smsCheckWorkLog/add",
          edit: "/hi4/smsCheckWorkLog/edit",
          queryById: "/hi4/smsCheckWorkLog/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
     this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      modelHandle(){
        this.model.basicCheckState=this.checkState(this.model.basicCheckState);
        this.model.standardCheckState=this.checkState(this.model.standardCheckState);
        this.model.dataCheckState=this.checkState(this.model.dataCheckState);

      },
      checkState (text){
        if (text===0){
          return "未处理";
        }else if (text===1){
          return "未通过";
        }else if (text===2){
          return "通过";
        }
      },
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.modelHandle();
        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>