PageDrillPlanList.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="safety-platform-container">
  3. <header class="safety-platform-container__header">
  4. <div class="breadcrumb-title"> 演练计划 </div>
  5. </header>
  6. <main class="safety-platform-container__main">
  7. <div class="search-table-container">
  8. <header>
  9. <!-- 按钮 -->
  10. <el-button type="primary" class="search-table-container--button" :icon="Plus" @click="handleCreateDrillPlan">
  11. 创建演练计划
  12. </el-button>
  13. <!-- 搜索栏 -->
  14. <BasicSearch
  15. :searchConfig="DRILL_PLAN_LIST_SEARCH_CONFIG"
  16. :searchData="searchData"
  17. @update:searchData="handleSearch"
  18. ></BasicSearch>
  19. </header>
  20. <!-- 表格 -->
  21. <BasicTable
  22. :tableConfig="tableConfig"
  23. :tableData="tableData"
  24. @update:pageSize="handleSizeChange"
  25. @update:pageNumber="handleCurrentChange"
  26. >
  27. <template #action="scope">
  28. <div class="action-container--div">
  29. <ActionButton text="查看" @click="handleViewDrillPlan(scope.row.id)"></ActionButton>
  30. <ActionButton
  31. v-if="scope.row.status > 0 && scope.row.status <= 3"
  32. text="演练执行"
  33. @click=""
  34. ></ActionButton>
  35. <ActionButton v-else-if="scope.row.status < 6" text="演练记录" @click=""></ActionButton>
  36. <ActionButton
  37. text="删除"
  38. :popconfirm="{
  39. title: '确定要删除?',
  40. }"
  41. @confirm="handleDeleteDrillPlan(scope.row.id)"
  42. />
  43. </div>
  44. </template>
  45. </BasicTable>
  46. </div>
  47. </main>
  48. </div>
  49. </template>
  50. <script setup lang="ts">
  51. import { ElButton } from 'element-plus';
  52. import { Plus } from '@element-plus/icons-vue';
  53. import { reactive, ref, onMounted } from 'vue';
  54. import { useRouter } from 'vue-router';
  55. import BasicSearch from '@/components/BasicSearch.vue';
  56. import BasicTable from '@/components/BasicTable.vue';
  57. import ActionButton from '@/components/ActionButton.vue';
  58. import useTableConfig from '@/hooks/useTableConfigHook';
  59. import { DRILL_PLAN_LIST_SEARCH_CONFIG } from './configs/plan/search';
  60. import { TABLE_OPTIONS, DRILL_PLAN_LIST_TABLE_COLUMNS } from './configs/plan/table';
  61. import { DrillPlanListSearch, DrillPlanItem } from './types';
  62. import { queryEnergencyDrillPlanList, deleteEmergencyDrillPlan } from '@/api/emergency-drill/emergency-drill';
  63. import { EMERGENCY_DRILL_STATUS_DICT, EMERGENCY_DRILL_SCOPE_LABEL } from './constants';
  64. const router = useRouter();
  65. // 按钮操作
  66. function handleCreateDrillPlan() {
  67. router.push({
  68. name: 'emergency-drill-plan-item',
  69. query: {
  70. operate: 'create',
  71. },
  72. });
  73. }
  74. function handleViewDrillPlan(id: number) {
  75. router.push({
  76. name: 'emergency-drill-plan-view',
  77. query: {
  78. id: id,
  79. },
  80. });
  81. }
  82. function handleToExecute(id: number) {
  83. router.push({
  84. name: 'emergency-drill-plan-item',
  85. query: {
  86. id: id,
  87. operate: 'execute',
  88. },
  89. });
  90. }
  91. function handleToRecord(id: number) {
  92. router.push({
  93. name: 'emergency-drill-plan-item',
  94. query: {
  95. id: id,
  96. operate: 'record',
  97. },
  98. });
  99. }
  100. function handleDeleteDrillPlan(id: number) {
  101. deleteEmergencyDrillPlan(id).then(() => {
  102. getTabelData();
  103. });
  104. }
  105. // 搜索栏
  106. const searchData = reactive<DrillPlanListSearch>({});
  107. function handleSearch() {
  108. tabelQuery.value.queryParam = searchData;
  109. getTabelData();
  110. }
  111. // 表格
  112. const { tableConfig, pagination } = useTableConfig(DRILL_PLAN_LIST_TABLE_COLUMNS, TABLE_OPTIONS);
  113. const tabelQuery = ref({
  114. pageNumber: pagination.pageNumber,
  115. pageSize: pagination.pageSize,
  116. queryParam: {},
  117. });
  118. const tableData = ref<DrillPlanItem[]>([]);
  119. const handleSizeChange = (value: number) => {
  120. pagination.pageSize = value;
  121. tabelQuery.value.pageSize = value;
  122. getTabelData();
  123. };
  124. const handleCurrentChange = (value: number) => {
  125. pagination.pageNumber = value;
  126. tabelQuery.value.pageSize = value;
  127. getTabelData();
  128. };
  129. async function getTabelData() {
  130. tableConfig.loading = true;
  131. const res = await queryEnergencyDrillPlanList(tabelQuery.value);
  132. res.records.forEach((item) => {
  133. item.drillScope = EMERGENCY_DRILL_SCOPE_LABEL[item.drillScope];
  134. item.responsibleDeptNameList = item.responsibleDeptNameList.replace(/^\[|\]$/g, '');
  135. item.coordinateDeptNameList = item.coordinateDeptNameList?.replace(/^\[|\]$/g, '');
  136. item.statusLabel = EMERGENCY_DRILL_STATUS_DICT[item.status];
  137. });
  138. tableData.value = res.records;
  139. pagination.total = res.totalRow;
  140. tableConfig.loading = false;
  141. }
  142. // 初始化
  143. onMounted(() => {
  144. getTabelData();
  145. });
  146. </script>
  147. <style scoped lang="scss">
  148. @use '@/styles/page-details-layout.scss' as *;
  149. @use '@/styles/page-main-layout.scss' as *;
  150. @use '@/styles/basic-table-action.scss' as *;
  151. </style>