<template>
  <Card simple class="jyh-card mt-3">
    <div class="card-title">组织预警通知列表</div>
    <div class="mb-3">
      <d-table class="jyh-table jyh-table-2" :header-bg="true" :data="licenseTableData">
        <d-column field="code" header="时间"></d-column>
        <d-column field="name" header="标题">
          <template #default="scope">
            <a @click="openWarningDetail(scope.row)">{{ scope.row.name }}</a>
          </template>
        </d-column>
        <d-column field="detail" header="详情"></d-column>
        <d-column field="owner" header="订阅人"></d-column>
        <d-column field="level" header="级别">
          <template #default="scope, text">
            <d-status v-if="scope.row.level === 4" type="error">危险</d-status>
            <d-status v-if="scope.row.level === 3" type="warning">严重</d-status>
            <d-status v-if="scope.row.level === 2" class="yellow-status">一般</d-status>
            <d-status v-if="scope.row.level === 1" type="running">提示</d-status>
          </template>
        </d-column>
        <d-column field="status" header="状态">
          <template #default="scope, text">
            <d-tag v-if="scope.row.status === 1" type="danger" size="sm">未读</d-tag>
            <d-tag v-if="scope.row.status === 2" type="success" size="sm">已读</d-tag>
          </template>
        </d-column>
      </d-table>
    </div>
  </Card>

  <d-modal class="warning-modal" v-model="warningModalVisable" title="">
    <EarlyWarningDetail @close="colseWarningDetail" :warningData="currentWarning" type="user"></EarlyWarningDetail>
  </d-modal>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import EarlyWarningDetail from '@/views/Jyh/PersonalCenter/Detail/EarlyWarningDetail.vue';

const licenseTableData = ref([
  { code: '05822156', name: 'MIT License', detail: 'integer', owner: 'admin', level: 4, status: 1 },
  { code: '05822156', name: 'MIT License', detail: 'integer', owner: 'admin', level: 3, status: 2 },
  { code: '05822156', name: 'MIT License', detail: 'integer', owner: 'admin', level: 2, status: 2 },
  { code: '05822156', name: 'MIT License', detail: 'integer', owner: 'admin', level: 1, status: 2 }
]);

const warningModalVisable = ref(false);
const currentWarning = ref();
const openWarningDetail = (row) => {
  warningModalVisable.value = true;
  currentWarning.value = row;
};
const colseWarningDetail = () => {
  warningModalVisable.value = false;
};
</script>

<style scoped lang="scss">
@import 'devui-theme/styles-var/devui-var.scss';
</style>
