<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="24">
            <a-form-model-item label="备注说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="info">
              <a-textarea v-model="model.info" placeholder="请输入备注说明"  ></a-textarea>
            </a-form-model-item>
          </a-col>


          <a-col :span="24">
            <a-form-model-item label="提现审核 0未审核 1已审核 2已打款 3审核未通过" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="state">
              <j-dict-select-tag type="list" v-model="model.state" dictCode="rec_state" placeholder="请选择提现审核 0未审核 1已审核 2已打款 3审核未通过" />
            </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: 'MerRechargeInfoLogForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
            isPay:0,
            delFlag:0,
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
           money: [
              { required: true, message: '请输入金额!'},
           ],
           userMoney: [
              { required: true, message: '请输入用户原本金额!'},
           ],
           isPay: [
              { required: true, message: '请输入是否支付 0否 1是!'},
           ],
           delFlag: [
              { required: true, message: '请输入是否删除 0否 1是!'},
           ],
           type: [
              { required: true, message: '请输入类型 0支出  1支入!'},
           ],
        },
        url: {
          add: "rechargeInfoLog/tbRechargeInfoLog/add",
          edit: "rechargeInfoLog/tbRechargeInfoLog/edit",
          queryById: "rechargeInfoLog/tbRechargeInfoLog/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>