<template>
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">

<a-row :gutter="16">
    <a-col :span="24">
      <a-form-model-item label="审核状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shenheStatus">
        <a-radio-group v-model="model.shenheStatus" :disabled="formDisabled">
          <a-radio-button value="0">未审核</a-radio-button>
          <a-radio-button value="1">审核确认</a-radio-button>
          <a-radio-button value="2">审核拒绝</a-radio-button>
        </a-radio-group>
      </a-form-model-item>
    </a-col>
    <a-col :span="24" v-if="model.shenheStatus === '2'">
      <a-form-model-item label="拒绝理由" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shenheMsg">
        <a-textarea v-model="model.shenheMsg" placeholder="请输入拒绝理由" :disabled="formDisabled"></a-textarea>
      </a-form-model-item>
    </a-col>
   <a-col :span="24" v-else-if="model.shenheStatus === '1'">
      <a-form-model-item label="委托单编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="weituoNo">
        <a-textarea v-model="model.weituoNo" placeholder="请输入委托单编号" :disabled="formDisabled"></a-textarea>
      </a-form-model-item>
    </a-col>
  </a-row>
      </a-form-model>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'ItdmWeituoInfoForm',
    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: {
          weituoNo: [
            { min: 1, max: 12, message: "长度不超过12个字符", trigger: "blur" }
          ],
        },
        url: {
          add: "/weituo/itdmWeituoInfo/add",
          edit: "/weituo/itdmWeituoInfo/saveOrUpdateWeituo",
          queryById: "/weituo/itdmWeituoInfo/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;
            })
          }
         
        })
      },
      handleCategoryChange(value,backObj){
         this.model = Object.assign(this.model, backObj);
      }
    }
  }
</script>