<script setup lang="ts">
import { reactive, ref } from "vue";
import { ElForm } from "element-plus";

const emit = defineEmits(["changeStatus"]);

const formData = reactive({
  return_type: "",
  status: "",
  remark: ""
});

const rules = reactive({
  return_type: [
    {
      required: true,
      trigger: "change",
      message: "退票方式"
    }
  ],
  status: [
    {
      required: true,
      trigger: "change",
      message: "选择审核状态"
    }
  ],
  remark: [
    {
      required: true,
      trigger: "change",
      message: "请输入备注"
    }
  ]
});

const formRef = ref<InstanceType<typeof ElForm>>(null);

const handlePaymentReceipt = () => {
  formRef.value.validate(isValid => isValid && emit("changeStatus", formData));
};
</script>

<template>
  <el-form
    ref="formRef"
    label-width="100px"
    size="small"
    :model="formData"
    :rules="rules"
  >
    <el-form-item label="审批状态" prop="status" w-400px>
      <el-select w-400px v-model="formData.status">
        <el-option label="通过" value="1" />
        <el-option label="不通过" value="3" />
      </el-select>
    </el-form-item>

    <el-form-item label="退票方式" prop="return_type">
      <el-select w-300px v-model="formData.return_type">
        <el-option value="1" label="金税" />
        <el-option value="2" label="线下" />
      </el-select>
    </el-form-item>

    <el-form-item label="备注" prop="remark" w-400px>
      <el-input type="textarea" v-model="formData.remark" />
    </el-form-item>

    <el-form-item w-full flex justify-end>
      <el-button type="primary" @click="handlePaymentReceipt">保存</el-button>
    </el-form-item>
  </el-form>
</template>

<style lang="scss">
.upload {
  width: 178px;
  height: 178px;
  display: block;
  border: 1px dashed var(--el-border-color);

  .text {
    font-size: 20px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    text-align: center;
    line-height: 178px;
  }

  &:hover {
    border-color: var(--el-color-primary);
  }

  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
}
</style>
