<template>
  <el-dialog
      v-model="props.visible"
      title="日志详情"

      width="700"
      :close-on-click-modal="false"
      :before-close="dialogClose"
  >
  <el-descriptions  column="2">
    <el-descriptions-item label="任务名称:">{{formData.jobName}}</el-descriptions-item>
    <el-descriptions-item label="任务组名:">{{formData.jobGroup}}</el-descriptions-item>
    <el-descriptions-item label="任务触发器:">{{formData.jobTrigger}}</el-descriptions-item>
    <el-descriptions-item label="任务信息:">{{formData.jobMessage}}</el-descriptions-item>
    <el-descriptions-item label="cron执行表达式:">{{formData.cronExpression}}</el-descriptions-item>
    <el-descriptions-item label="任务开始时间:">{{formData.startTime}}</el-descriptions-item>
    <el-descriptions-item label="任务结束时间:">{{formData.endTime}}</el-descriptions-item>
</el-descriptions>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogClose">关闭</el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script lang="ts" setup>
import {getJobLogDetail} from "@/api/monitor/job";
import {onMounted, reactive, shallowRef} from "vue";

const formData = reactive({
  id: "",
  jobName: "",
  jobGroup:'',
  jobTrigger:'',
  jobMessage:'',
  cronExpression:'',
  startTime:'',
  endTime:''
});

const emit = defineEmits(["update:visible"]);

const props = defineProps({
  visible: {
    type: Boolean,
    required: true,
    default: false
  },
  logId: {
    type: Number,
    required: true,
    default: 0
  }
});


const dialogClose = () => {
  emit("update:visible", false);
};

const setFormData = async () => {
  const data = await getJobLogDetail(props.logId);
  for (const key in formData) {
    if (data[key] != null && data[key] != undefined) {
      //@ts-ignore
      formData[key] = data[key];
    }
  }
};
const getReviceType =(type)=>{
  let typeText = ''
    switch (type) {
      case 1:
        typeText='系统用户'
        break;
      case 2:
        typeText='会员用户'
        break;
      case 3:
        typeText='其他'
        break;
      default:
        break
    }
    return typeText 
}
const getTyepText =(type)=>{
  let typeText = ''
    switch (type) {
      case 1:
          typeText='登录'
          break;
        case 2:
          typeText='注册'
          break;
        case 3:
          typeText='找回密码'
          break;
        case 4:
          typeText='业务'
          break;
        case 5:
          typeText='其他'
          break;
      default:
        break
    }
    return typeText 
}

onMounted(() => {
  if (props.logId) {
    setFormData();
  }
});

</script>
