PageDrillPlanList.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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:search-data="handleSearch"
  18. >
  19. <template #drillScope>
  20. <el-select v-model="searchData.drillScope" placeholder="全部" filterable>
  21. <el-option
  22. v-for="item in [{ itemCode: undefined, itemValue: '全部' }, ...drillScopeDice]"
  23. :key="item.itemCode"
  24. :label="item.itemValue"
  25. :value="item.itemCode"
  26. />
  27. </el-select>
  28. </template>
  29. </BasicSearch>
  30. </header>
  31. <!-- 表格 -->
  32. <BasicTable
  33. :tableConfig="tableConfig"
  34. :tableData="tableData"
  35. @update:page-size="handleSizeChange"
  36. @update:page-number="handleCurrentChange"
  37. >
  38. <template #drillScope="scope">
  39. <div>{{ decodeScope(scope.row.drillScope) }}</div>
  40. </template>
  41. <template #status="scope">
  42. <div>{{ decodeStatus(scope.row.status) }}</div>
  43. </template>
  44. <template #action="scope">
  45. <div class="action-container--div">
  46. <ActionButton text="查看" @click="handleViewDrillPlan(scope.row.id)" />
  47. <ActionButton
  48. v-if="scope.row.status > 0 && scope.row.status <= 3"
  49. text="演练执行"
  50. @click="handleToExecute(scope.row.id)"
  51. />
  52. <ActionButton v-else-if="scope.row.status < 7" text="演练记录" @click="handleToRecord(scope.row)" />
  53. <ActionButton
  54. text="删除"
  55. :popconfirm="{
  56. title: '确定要删除?',
  57. }"
  58. @confirm="handleDeleteDrillPlan(scope.row.id)"
  59. />
  60. </div>
  61. </template>
  62. </BasicTable>
  63. </div>
  64. </main>
  65. </div>
  66. </template>
  67. <script setup lang="ts">
  68. import { ElButton } from 'element-plus';
  69. import { Plus } from '@element-plus/icons-vue';
  70. import { reactive, ref, onMounted } from 'vue';
  71. import { useRouter } from 'vue-router';
  72. import BasicSearch from '@/components/BasicSearch.vue';
  73. import BasicTable from '@/components/BasicTable.vue';
  74. import ActionButton from '@/components/ActionButton.vue';
  75. import useTableConfig from '@/hooks/useTableConfigHook';
  76. import { queryEnergencyDrillPlanList, deleteEmergencyDrillPlan } from '@/api/emergency-drill/emergency-drill';
  77. import { DRILL_PLAN_LIST_SEARCH_CONFIG } from './configs/plan/search';
  78. import { TABLE_OPTIONS, DRILL_PLAN_LIST_TABLE_COLUMNS } from './configs/plan/table';
  79. import { DrillPlanListSearch, DrillPlanItem } from './types';
  80. import { EMERGENCY_DRILL_STATUS_DICT } from './constants';
  81. import { useEmergencyDrillHook } from './hook';
  82. import { QueryPageRequest } from '@/types/basic-query';
  83. const router = useRouter();
  84. function handleDeleteDrillPlan(id: number) {
  85. deleteEmergencyDrillPlan(id).then(() => {
  86. getTableData();
  87. });
  88. }
  89. // 搜索栏
  90. const searchData = reactive<DrillPlanListSearch>({});
  91. function handleSearch() {
  92. tableQuery.queryParam = {};
  93. if (searchData.daterange) {
  94. tableQuery.queryParam.dueCompleteTimeStart = searchData.daterange[0];
  95. tableQuery.queryParam.dueCompleteTimeEnd = searchData.daterange[1];
  96. }
  97. if (searchData.drillScope) tableQuery.queryParam.drillScope = searchData.drillScope;
  98. if (searchData.drillContent) tableQuery.queryParam.drillContent = searchData.drillContent;
  99. if (searchData.responsibleDept) tableQuery.queryParam.responsibleDept = searchData.responsibleDept;
  100. if (searchData.status) tableQuery.queryParam.status = searchData.status;
  101. getTableData();
  102. }
  103. // 表格
  104. const { tableConfig, pagination } = useTableConfig(DRILL_PLAN_LIST_TABLE_COLUMNS, TABLE_OPTIONS);
  105. const tableQuery = reactive<QueryPageRequest<DrillPlanListSearch>>({
  106. pageNumber: pagination.pageNumber,
  107. pageSize: pagination.pageSize,
  108. queryParam: {},
  109. });
  110. const tableData = ref<DrillPlanItem[]>([]);
  111. const handleSizeChange = (value: number) => {
  112. pagination.pageSize = value;
  113. tableQuery.pageSize = value;
  114. getTableData();
  115. };
  116. const handleCurrentChange = (value: number) => {
  117. pagination.pageNumber = value;
  118. tableQuery.pageNumber = value;
  119. getTableData();
  120. };
  121. // 解析演练规模字典
  122. const { drillScopeDice, getDrillScopeDict } = useEmergencyDrillHook();
  123. function decodeScope(code: string) {
  124. return drillScopeDice.value.find((x) => x.itemCode === code)?.itemValue;
  125. }
  126. // 解析演练状态
  127. function decodeStatus(status: number) {
  128. return EMERGENCY_DRILL_STATUS_DICT[status];
  129. }
  130. async function getTableData() {
  131. tableConfig.loading = true;
  132. const res = await queryEnergencyDrillPlanList(tableQuery);
  133. res.records.forEach((item) => {
  134. item.responsibleDeptNameList = item.responsibleDeptNameList.replace(/^\[|\]$/g, '');
  135. item.coordinateDeptNameList = item.coordinateDeptNameList?.replace(/^\[|\]$/g, '');
  136. });
  137. tableData.value = res.records;
  138. pagination.total = res.totalRow;
  139. tableConfig.loading = false;
  140. }
  141. // 初始化
  142. onMounted(async () => {
  143. await getDrillScopeDict();
  144. getTableData();
  145. });
  146. // 按钮操作
  147. function handleCreateDrillPlan() {
  148. router.push({
  149. name: 'emergency-drill-plan-item',
  150. query: {
  151. operate: 'create',
  152. },
  153. });
  154. }
  155. function handleViewDrillPlan(id: number) {
  156. router.push({
  157. name: 'emergency-drill-plan-view',
  158. query: {
  159. id: id,
  160. },
  161. });
  162. }
  163. function handleToExecute(id: number) {
  164. router.push({
  165. name: 'emergency-drill-plan-item',
  166. query: {
  167. id: id,
  168. operate: 'execute',
  169. },
  170. });
  171. }
  172. function handleToRecord(row: DrillPlanItem) {
  173. router.push({
  174. name: 'emergency-drill-plan-item',
  175. query: {
  176. planId: row.id,
  177. approvalId: row.approvalTemplateId,
  178. operate: 'record',
  179. },
  180. });
  181. }
  182. </script>
  183. <style scoped lang="scss">
  184. @use '@/styles/page-details-layout.scss' as *;
  185. @use '@/styles/page-main-layout.scss' as *;
  186. @use '@/styles/basic-table-action.scss' as *;
  187. </style>