<template>
  <el-dialog v-model="visible" title="查看流程图" width="1200px">
    <el-steps
      :active="fnGetStatus()"
      :process-status="fnGetProcessStatus()"
      align-center
      finish-status="success"
    >
      <el-step title="盲板抽堵作业提交">
        <template #description>
          <div>{{ fnGetProcessMessage().title }}</div>
          <div>{{ fnGetProcessMessage().USER_NAME }}</div>
          <div>{{ fnGetProcessMessage().OPERATTIME }}</div>
        </template>
      </el-step>
      <el-step title="作业负责人意见">
        <template #description>
          <div>{{ info.CONSTRUCTION_USER_NAME }}</div>
          <div>{{ info.CONSTRUCTION_USER_SIGNER_TIME }}</div>
        </template>
      </el-step>
      <el-step title="所在单位意见">
        <template #description>
          <div>{{ info.LEADER_USER_NAME }}</div>
          <div>{{ info.LEADER_USER_SIGNER_TIME }}</div>
        </template>
      </el-step>
      <el-step title="完成验收">
        <template #description>
          <div>{{ info.ACCEPT_USER_NAME }}</div>
          <div>{{ info.ACCEPT_USER_SIGNER_TIME }}</div>
        </template>
      </el-step>
      <el-step title="验收归档">
        <template #description>
          <div>{{ info.ACCEPT_USER_NAME }}</div>
          <div>{{ info.ACCEPT_USER_SIGNER_TIME }}</div>
        </template>
      </el-step>
    </el-steps>
    <div
      style="
        margin: 60px 60px 0 60px;
        display: flex;
        justify-content: space-between;
      "
    >
      <div v-if="info.GUARDIAN_USER_SIGNER_TIME">
        <div class="el-step__title is-success">
          监护人：{{ info.GUARDIAN_USER_NAME }}已签字
        </div>
      </div>
      <div v-if="!info.GUARDIAN_USER_SIGNER_TIME">
        <div class="el-step__title is-error">
          监护人：{{ info.GUARDIAN_USER_NAME }}未签字
        </div>
      </div>
      <div v-if="info.CONFESS_USER_SIGNER_TIME">
        <div class="el-step__title is-success">
          安全交底人：{{ info.CONFESS_USER_NAME }}已签字
        </div>
      </div>
      <div v-if="!info.CONFESS_USER_SIGNER_TIME">
        <div class="el-step__title is-error">
          安全交底人：{{ info.CONFESS_USER_NAME }}未签字
        </div>
      </div>
      <div v-if="info.ACCEPT_CONFESS_USER_SIGNER_TIME">
        <div class="el-step__title is-success">
          接受交底人：{{ info.ACCEPT_CONFESS_USER_NAME }}已签字
        </div>
      </div>
      <div v-if="!info.ACCEPT_CONFESS_USER_SIGNER_TIME">
        <div class="el-step__title is-error">
          接受交底人：{{ info.ACCEPT_CONFESS_USER_NAME }}未签字
        </div>
      </div>
    </div>
    <template #footer>
      <el-button @click="visible = false">关闭</el-button>
    </template>
  </el-dialog>
</template>

<script setup>
import { useVModel } from "@vueuse/core";

const props = defineProps({
  visible: {
    type: Boolean,
    required: true,
    default: false,
  },
  info: {
    type: Object,
    required: true,
    default: () => {},
  },
});
const emits = defineEmits(["update:visible"]);
const visible = useVModel(props, "visible", emits);
const fnGetStatus = () => {
  const result = {
    1: 1,
    4: 2,
    5: 3,
    6: 5,
  };
  return result[props.info.APPLY_STATUS] || 0;
};
const fnGetProcessStatus = () => {
  if (props.info.APPLY_STATUS < "0") return "error";
  else return "process";
};
const fnGetProcessMessage = () => {
  const info = props.info;
  const result = {
    "-2": {
      title: "作业负责人审核打回",
      USER_NAME: info.CONSTRUCTION_USER_NAME,
      OPERATTIME: info.OPERATTIME,
    },
    "-5": {
      title: "所在单位审核打回",
      USER_NAME: info.LEADER_USER_NAME,
      OPERATTIME: info.OPERATTIME,
    },
    "-6": {
      title: "验收打回",
      USER_NAME: info.ACCEPT_USER_NAME,
      OPERATTIME: info.OPERATTIME,
    },
  };
  return (
    result[props.info.APPLY_STATUS] || {
      title: "",
      USER_NAME: info.APPLY_USER_NAME,
      OPERATTIME: info.CREATTIME,
    }
  );
};
</script>

<style scoped lang="scss"></style>
