<template>
  <div v-loading="loading">
    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="150px" class="order_form">
      <el-form-item label="付款金额" prop="F_Money">
        <el-input v-model.number="ruleForm.F_Money" placeholder="请输入付款金额"/>
      </el-form-item>
      <el-form-item label="备注" prop="F_RemarkKF">
        <el-input :autosize="{ minRows: 4}" v-model="ruleForm.F_RemarkKF" type="textarea" placeholder="请输入备注"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm()">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getDictionaryValueList } from '@/api/commonAPI'
import { userOrderPaymentReview } from '@/api/customerServiceManagement/orderListCustomerService'

export default {
  name: "CheckOrderMoney",
  props: {
    rowid: {
      type: String,
      default: ""
    },
    layerid: {
      type: String,
      default: ""
    },
    state: {
      type: Number,
      default: ""
    },
    orderId: {
      type: String,
      default: ""
    },
    money: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      payTypeList: [], //支付方式
      ruleForm: {
        F_Id: '', //申请id
        F_Money: '', //付款金额
        F_RemarkKF: '', //备注
        F_State: '', // 1-审核通过 2-审核不通过
      },
      rules: {
        F_Money: [{
          required: true,
          trigger: 'blur',
          message: '请输入付款金额'
        },{
          type: 'number',
          message: '付款金额必须为数字'
        }],
      },
      loading: false
    };
  },
  created() {
    Promise.all([
    ]).then(() => {
      if (this.rowid) {
        this.ruleForm.F_Id = this.rowid
        this.ruleForm.F_State = this.state
        this.ruleForm.F_Money = this.money
      }
    });
  },
  methods: {
    submitForm() {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          this.loading = true;
          this.ruleForm.F_Money = this.ruleForm.F_Money == '' ? 0 : this.ruleForm.F_Money
          userOrderPaymentReview(this.ruleForm).then(response => {
            this.loading = false
            if (response.state.toLowerCase() === 'success') {
              this.$parent.$layer.close(this.layerid)
              this.$parent.getOrderPaymentReviewList(this.orderId) // 重新加载父级数据
              this.$message.success('恭喜你，保存成功!')
            }
          }).catch(() => {
            this.loading = false
          })
          return
        } else {
          this.$message.error("请输入有效的必填项信息!");
          return false;
        }
      });
    },
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.order_form {
  .form_select {
    width: 100%;
  }
  .form_date {
    width: 100%;
  }
}
</style>
