<script setup>
import { ref } from "vue";
import { ElMessage } from "element-plus";
import { ficcManageInterface, customInterence } from "@/api/api.js";

const props = defineProps({
  isShowDia: {
    type: Boolean,
    require: true,
  },
  item: {
    type: Object,
    require: true,
  },
  activeName: {
    type: Number,
  },
});

const emit = defineEmits(["success", "close"]);

/* 处理申请 */
async function dealApply() {
  let res;
  try {
    if (props.activeName > 1) {
      res = await customInterence.trialStatus({
        Id: props.item.Id,
      });
    } else {
      res = await ficcManageInterface.applyRecordDeal({
        ApplyRecordId: props.item.ApplyRecordId,
        UserId: props.item.UserId,
      });
    }

    if (res.Ret === 200) {
      ElMessage.success("标记处理完成");
      cancelHandle();
      emit("success");
    }
  } catch (err) {
    console.dir(err);
  }
}

function cancelHandle() {
  emit("close");
}
</script>
<template>
  <el-dialog
    draggable
    :model-value="isShowDia"
    :close-on-click-modal="false"
    :modal-append-to-body="false"
    :show-close="false"
    @close="cancelHandle"
    class="interview_dialog"
    center
    width="450px"
  >
    <template #header>
      <div style="position: relative">
        <span style="font-size: 16px">标记处理</span>
        <i
          class="el-icon-close"
          style="
            font-size: 24px;
            cursor: pointer;
            position: absolute;
            right: 20px;
            top: 50%;
            transform: translateY(-50%);
          "
          @click="cancelHandle"
        ></i>
      </div>
    </template>
    <!-- 申请弹窗 -->
    <div class="dialog_cont">
      <!-- 处理申请 -->
      <span>是否确认已处理该用户申请？</span>
    </div>
    <div style="display: flex; justify-content: center; margin: 40px 0">
      <template>
        <el-button
          type="primary"
          style="width: 80px; marginright: 24px"
          @click="dealApply"
          >确定</el-button
        >
        <el-button
          type="primary"
          plain
          style="width: 80px"
          @click="cancelHandle"
          >取消</el-button
        >
      </template>
    </div>
  </el-dialog>
</template>
<style scoped lang="scss">
.interview-dialog {
  .dialog_cont {
    padding: 0 10px;
    .node_name {
      font-size: 15px;
      margin-bottom: 20px;
    }
    .node_ipt {
      display: block;
      width: 100%;
      margin: 20px 0;
    }
  }
  .el-dialog__body {
    flex-direction: column;
  }
}
</style>
