PageDrillPlanList.vue 6.1 KB

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