PageDefenseNotice.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="disaster-precaution-container">
  3. <header class="disaster-precaution-container__header">
  4. <span class="disaster-precaution-container__title">防御通知管理列表</span>
  5. </header>
  6. <main class="disaster-precaution-container__main">
  7. <div class="disaster-precaution">
  8. <header class="disaster-precaution__header">
  9. <el-button
  10. type="primary"
  11. class="disaster-precaution__header--button"
  12. :icon="Plus"
  13. @click="handleCreateDefenseNotice"
  14. >创建灾害防御通知
  15. </el-button>
  16. <Search
  17. :searchConfig="DEFENSE_NOTICE_SEARCH_CONFIG"
  18. :searchData="searchData"
  19. @update:searchData="handleSearch"
  20. />
  21. </header>
  22. <BasicTable
  23. :tableConfig="tableConfig"
  24. :tableData="tableData"
  25. @update:pageSize="handleSizeChange"
  26. @update:pageNumber="handleCurrentChange"
  27. >
  28. <template #activeStatus="scope">
  29. <div class="active-status--div">
  30. <div
  31. class="dot"
  32. :style="{ backgroundColor: ACTIVE_STATUS_COLOR[scope.row.activeStatus as ACTIVE_STATUS] }"
  33. />
  34. <span>{{ ACTIVE_STATUS_MAP[scope.row.activeStatus] }}</span>
  35. </div>
  36. </template>
  37. <template #pushStatus="scope">
  38. <span :style="{ color: scope.row.pushStatus === PUSH_STATUS.PUSHED ? '' : '#ff4d4f' }">
  39. {{ PUSH_STATUS_MAP[scope.row.pushStatus as PUSH_STATUS] }}
  40. </span>
  41. </template>
  42. <template #action="scope">
  43. <ActionButton
  44. text="编辑"
  45. v-if="scope.row.activeStatus === ACTIVE_STATUS.NOT_EFFECTIVE"
  46. @click="handleEditDefenseNotice(scope.row.id)"
  47. />
  48. <ActionButton text="查看" @click="handleViewDefenseNotice(scope.row.id)" />
  49. <ActionButton
  50. text="发布"
  51. :popconfirm="{
  52. title: '确定要发布?',
  53. }"
  54. v-if="scope.row.activeStatus === ACTIVE_STATUS.NOT_EFFECTIVE"
  55. />
  56. <ActionButton
  57. text="撤回"
  58. :popconfirm="{
  59. title: '确定要撤回?',
  60. }"
  61. v-else-if="scope.row.activeStatus === ACTIVE_STATUS.ACTIVE"
  62. />
  63. <ActionButton
  64. text="删除"
  65. :popconfirm="{
  66. title: '确定要删除?',
  67. }"
  68. />
  69. </template>
  70. </BasicTable>
  71. </div>
  72. </main>
  73. </div>
  74. </template>
  75. <script lang="ts" setup>
  76. import { ref, onMounted, reactive } from 'vue';
  77. import { Plus } from '@element-plus/icons-vue';
  78. import Search from '@/views/disaster/components/Search.vue';
  79. import BasicTable from '@/components/BasicTable.vue';
  80. import ActionButton from '@/components/ActionButton.vue';
  81. import useTableConfig from '@/hooks/useTableConfigHook';
  82. import { getDefenseNoticeList } from '@/api/disaster-warning';
  83. import type { DefenseNoticeListResponse } from '@/types/disaster-warning';
  84. import { ACTIVE_STATUS, ACTIVE_STATUS_COLOR, ACTIVE_STATUS_MAP } from '@/views/disaster/constant';
  85. import { PUSH_STATUS_MAP, PUSH_STATUS } from './src/constant';
  86. import { DEFENSE_NOTICE_SEARCH_CONFIG, TABLE_OPTIONS, DEFENSE_NOTICE_TABLE_COLUMNS } from './src/config';
  87. import { useRouter } from 'vue-router';
  88. const tableData = ref<DefenseNoticeListResponse[]>([]);
  89. const router = useRouter();
  90. const defaultPath = '/disaster-prevention/disaster-warning/defense-notice-item';
  91. const handleEditDefenseNotice = (id: number) => {
  92. router.push({
  93. path: defaultPath,
  94. query: { id, operate: 'edit' },
  95. });
  96. };
  97. const handleCreateDefenseNotice = () => {
  98. router.push({
  99. path: defaultPath,
  100. query: {
  101. operate: 'create',
  102. },
  103. });
  104. };
  105. const handleViewDefenseNotice = (id: number) => {
  106. router.push({
  107. path: defaultPath,
  108. query: { id },
  109. });
  110. };
  111. const searchData = reactive({
  112. disasterType: '',
  113. disasterLevel: '',
  114. activeStatus: '',
  115. });
  116. const handleSearch = (data: any) => {
  117. console.log(data);
  118. getTableData();
  119. };
  120. const { tableConfig, pagination } = useTableConfig(DEFENSE_NOTICE_TABLE_COLUMNS, TABLE_OPTIONS);
  121. const handleSizeChange = (value: number) => {
  122. pagination.pageSize = value;
  123. getTableData();
  124. };
  125. const handleCurrentChange = (value: number) => {
  126. pagination.pageNumber = value;
  127. getTableData();
  128. };
  129. const getTableData = async () => {
  130. tableConfig.loading = true;
  131. const res = await getDefenseNoticeList();
  132. tableData.value = res;
  133. pagination.total = tableData.value.length;
  134. tableConfig.loading = false;
  135. };
  136. onMounted(() => {
  137. getTableData();
  138. });
  139. </script>
  140. <style lang="scss" scoped>
  141. @use '../style/disaster.scss' as *;
  142. @use './src/common.scss' as *;
  143. </style>