<template>
  <app-dialog v-model="visible" :loading="loading" :title="title" append-to-body class="detail-dialog" @cancel="onCancel" width="60%" :hideFooter="true">
    <el-form ref="form" :model="form" label-width="120px">
      <el-divider content-position="left"><i class="el-icon-document" style="color: rgb(24, 144, 255)" /><span class="divider-top">作业信息</span></el-divider>
      <el-descriptions :column="2" border labelClassName="label-w">
        <el-descriptions-item label="作业名称">{{ form.jobName || '-' }}</el-descriptions-item>
        <el-descriptions-item label="作业ID">{{ form.jobId || '-' }}</el-descriptions-item>
        <el-descriptions-item label="作业执行开始时间">{{ form.jobStartTime || '-' }}</el-descriptions-item>
        <el-descriptions-item label="作业执行结束时间">{{ form.jobEndTime || '-' }} </el-descriptions-item>
        <el-descriptions-item label="作业执行时长">{{ form.jobDuration ? form.jobDuration + '秒' : '-' }}</el-descriptions-item>
        <el-descriptions-item label="作业日志记录时间">{{ form.logTime || '-' }}</el-descriptions-item>
        <el-descriptions-item label="作业执行状态" :span="2">{{ dictEscape(dictJobStatus, form.jobStatus) || '-' }} </el-descriptions-item>
      </el-descriptions>

      <el-divider content-position="left"
        ><i class="el-icon-document" style="color: rgb(24, 144, 255)" /><span class="divider-top">调度任务信息</span></el-divider
      >
      <el-descriptions :column="2" border labelClassName="label-w">
        <el-descriptions-item label="任务ID">{{ form.taskId || '-' }}</el-descriptions-item>
        <el-descriptions-item label="任务状态">{{ dictEscape(dictTaskStatus, form.taskStatus) || '-' }} </el-descriptions-item>
        <el-descriptions-item label="任务开始时间">{{ form.taskStartTime || '-' }}</el-descriptions-item>
        <el-descriptions-item label="任务结束时间">{{ form.startTime || '-' }}</el-descriptions-item>
        <el-descriptions-item label="任务执行时长">{{ form.taskDuration ? form.taskDuration + '秒' : '-' }}</el-descriptions-item>
        <el-descriptions-item label="任务类型">{{ dictEscape(dictTaskMode, form.taskMode) || '-' }}</el-descriptions-item>
        <el-descriptions-item label="任务执行参数">{{ form.taskParam || '-' }}</el-descriptions-item>
        <el-descriptions-item label="日志详情" :span="2">{{ form.logDetail || '-' }} </el-descriptions-item>
      </el-descriptions>
    </el-form>
  </app-dialog>
</template>

<script>
import dialogMixin from '@/mixins/dialog.js';
export default {
  name: 'detailDialog',
  mixins: [dialogMixin],
  props: {},
  data() {
    return {
      form: {},
      loading: false,
      dictTaskStatus: [
        {
          name: '成功',
          value: 1,
        },
        {
          name: '失败',
          value: 0,
        },
      ],
      dictJobStatus: [
        {
          name: '成功',
          value: 1,
        },
        {
          name: '失败',
          value: 0,
        },
      ],
      dictTaskMode: [
        {
          name: 'Java程序采集',
          value: 1,
        },
        {
          name: 'Kettle采集',
          value: 2,
        },
        {
          name: 'Shell采集',
          value: 3,
        },
        {
          name: '平台ETL抽取',
          value: 4,
        },
        {
          name: '平台ODS抽取',
          value: 5,
        },
      ],
    };
  },
  mounted() {},
  methods: {
    dictEscape(dictKey, value) {
      const item =
        dictKey.find((i) => {
          const dictionaryValue = i.value; // 字典值
          let condition = dictionaryValue === value; // 返回条件
          return condition;
        }) || {};
      return item.name || '';
    },
    /**
     * @description: dialog每次显示时触发的init方法
     * @param {*} data 传入data
     * @return {*}
     */
    initData(data) {
      const orgForm = this.$options.data().form;
      this.form = { ...orgForm, ...data };
    },

    onCancel() {
      this.visible = false;
      this.loading = false;
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-descriptions-row .label-w {
  width: 140px;
  background-color: #f7faff;
}
::v-deep .el-descriptions-row .label-w2 {
  width: 160px;
  background-color: #f7faff;
}
</style>
