<template>
  <div>
    <el-form ref="ruleForm" :model="ruleForm" label-width :rules="rules">
      <el-form-item label="售后审核类型" prop="F_CheckStateKG">
        <el-select
          v-model="ruleForm.F_CheckStateKG"
          class="form_select"
          filterable
          clearable
          placeholder="请选择售后审核类型"
        >
          <el-option label="收到货" value="1"></el-option>
          <el-option label="货物不符" value="2"></el-option>
          <el-option label="未收到货" value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm()">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { getAfterSaleListCustodianReview } from "@/api/afterSaleManagement/afterSaleList";
export default {
  props: {
    rowid: {
      type: String,
      default: "",
    },
    layerid: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      ruleForm: {
        F_Id: "", //订单编号
        F_CheckStateKG: "", //订单状态 —— 3 通过
      },
      rules: {
        F_CheckStateKG: [
          { required: true, message: "请选择售后审核类型", trigger: "change" },
        ],
      },
    };
  },
  created() {
    if (this.rowid) {
      this.ruleForm.F_Id = this.rowid;
    }
  },
  methods: {
    submitForm() {
      this.$refs.ruleForm.validate((validate) => {
        if (validate) {
          getAfterSaleListCustodianReview(this.ruleForm)
            .then((response) => {
              if (response.state.toLowerCase() === "success") {
                this.$parent.$layer.close(this.layerid);
                this.$parent.getList(); // 重新加载父级数据
                this.$message.success("恭喜你，售后审核成功!");
              }
            })
            .catch(() => {
              this.loading = false;
            });
        }else{
          this.$message.error("请输入有效的必填项信息!");
          return false;
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.form_select {
  width: 100%;
}
</style>