<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_CheckTimeXS" >
        <el-date-picker
          v-model="ruleForm.F_CheckTimeXS"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetime"
          class="form_date"
          placeholder="请选择退款时间">
        </el-date-picker>
      </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 { afterSaleRefundOperation } from "@/api/customerServiceManagement/orderListCustomerService";

export default {
  name: "Merge",
  props: {
    rowid: {
      type: String,
      default: ""
    },
    layerid: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      ruleForm: {
        F_Id: '', //售后编号ID
        F_CheckTimeXS: '', //退款时间
        F_State: 1,
      },
      rules: {
        F_CheckTimeXS: [{
          required: true,
          trigger: 'blur',
          message: '请输入退款时间',
        }],
      },
      loading: false
    };
  },
  created() {
    Promise.all([
    ]).then(() => {
      if (this.rowid) {
        this.ruleForm.F_Id = this.rowid
      }
    });
  },
  methods: {
    submitForm(state) {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          this.loading = true;
          //添加
          afterSaleRefundOperation(this.ruleForm).then(response => {
            this.loading = false
            if (response.state.toLowerCase() === 'success') {
              this.$parent.$layer.close(this.layerid)
              this.$parent.getList() // 重新加载父级数据
              this.$message.success('恭喜你，添加成功!')
            }
          }).catch(() => {
            this.loading = false
          })
          return
        } else {
          this.$message.error("请输入有效的必填项信息!");
          return false;
        }
      });
    },
  }
};
</script>

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