PageManagement.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="safety-platform-container">
  3. <div class="safety-platform-container__header">
  4. <div class="breadcrumb-title">预案管理</div>
  5. </div>
  6. <div class="safety-platform-container__main">
  7. <div class="search-table-container">
  8. <header class="disaster-precaution__header">
  9. <el-button
  10. type="primary"
  11. class="search-table-container--button"
  12. :icon="Plus"
  13. v-if="planManagementPremissions"
  14. @click="handleAdd"
  15. >添加预案
  16. </el-button>
  17. <BasicSearch
  18. :searchConfig="EMERGENCY_PLAN_MANAGEMENT_SEARCH_CONFIG"
  19. :searchData="searchData"
  20. @update:searchData="handleSearch"
  21. >
  22. <template #planType>
  23. <el-select v-model="searchData.planType" placeholder="请输入预案类型" filterable>
  24. <el-option
  25. v-for="item in planTypeDice"
  26. :key="item.itemCode"
  27. :label="item.itemValue"
  28. :value="item.itemCode"
  29. />
  30. </el-select>
  31. </template>
  32. <template #eventType>
  33. <el-select v-model="searchData.eventType" placeholder="请选择事件类型" filterable>
  34. <el-option
  35. v-for="item in emergencyEventDice"
  36. :key="item.itemCode"
  37. :label="item.itemValue"
  38. :value="item.itemCode"
  39. />
  40. </el-select>
  41. </template>
  42. </BasicSearch>
  43. </header>
  44. <BasicTable
  45. :tableData="tableData"
  46. :tableConfig="tableConfig"
  47. @update:pageSize="handleSizeChange"
  48. @update:pageNumber="handleCurrentChange"
  49. >
  50. <template #planType="scope">
  51. <span>{{ getPlanType(scope.row.planType) }}</span>
  52. </template>
  53. <template #eventType="scope">
  54. <span>{{ getEmergencyEvent(scope.row.eventType) }}</span>
  55. </template>
  56. <template #status="scope">
  57. <span
  58. :class="
  59. scope.row.status === EMERGENCY_PLAN_STATUS.APPROVAL_IN_PROGRESS ||
  60. scope.row.status === EMERGENCY_PLAN_STATUS.RETURNED
  61. ? 'highlight-text'
  62. : ''
  63. "
  64. @click="handleViewApprovalProcess(scope.row)"
  65. >{{ getEmergencyPlanStatusLabel(scope.row.status) }}</span
  66. >
  67. </template>
  68. <template #action="scope">
  69. <div class="action-container--div">
  70. <ActionButton text="查看" @click="handleView(scope.row.id)" />
  71. <ActionButton
  72. v-if="planManagementPremissions && scope.row.status !== EMERGENCY_PLAN_STATUS.APPROVAL_IN_PROGRESS"
  73. text="编辑"
  74. @click="handleEdit(scope.row.id)"
  75. />
  76. <ActionButton
  77. v-if="planManagementPremissions && scope.row.status !== EMERGENCY_PLAN_STATUS.APPROVAL_IN_PROGRESS"
  78. text="删除"
  79. :popconfirm="{ title: '确认删除' }"
  80. @confirm="handleDelete(scope.row.id)"
  81. />
  82. </div>
  83. </template>
  84. </BasicTable>
  85. </div>
  86. </div>
  87. </div>
  88. <BasicDialog ref="basicDialogRef" title="审批流程" width="1000">
  89. <template #form>
  90. <BasicTable :tableData="approvalProcessData" :tableConfig="approvalProcessConfig">
  91. <template #approvalType="scope">
  92. <span>{{ APPROVAL_TYPE_MAP[scope.row.approvalType] }}</span>
  93. </template>
  94. <template #approvalStatus="scope">
  95. <span>{{ APPROVAL_STATUS_MAP[scope.row.approvalStatus] }}</span>
  96. </template>
  97. </BasicTable>
  98. </template>
  99. </BasicDialog>
  100. </template>
  101. <script setup lang="ts">
  102. import { useRouter } from 'vue-router';
  103. import { ref, reactive, onMounted } from 'vue';
  104. import { Plus } from '@element-plus/icons-vue';
  105. import { ElMessage } from 'element-plus';
  106. import BasicSearch from '@/components/BasicSearch.vue';
  107. import BasicTable from '@/components/BasicTable.vue';
  108. import BasicDialog from '@/components/BasicDialog.vue';
  109. import ActionButton from '@/components/ActionButton.vue';
  110. import useTableConfig from '@/hooks/useTableConfigHook';
  111. import { useEmergencyHook } from '../src/hoos';
  112. import { useEmergencyPlanHook } from './src/hook';
  113. import { useUserInfoHook } from '@/hooks/useUserInfoHook';
  114. import type { QueryPageRequest } from '@/types/basic-query';
  115. import type {
  116. PlanEmergencyListQuery,
  117. PlanEmergencyListResponse,
  118. ApprovalProcessList,
  119. ApprovalProcessResponse,
  120. ProcessInfoListType,
  121. } from '@/types/emergency-plan';
  122. import { getEmergencyPlanList, deleteEmergencyPlan, queryApprovalProcess } from '@/api/emergency-plan';
  123. import {
  124. EMERGENCY_PLAN_MANAGEMENT_SEARCH_CONFIG,
  125. EMERGENCY_PLAN_MANAGEMENT_TABLE_OPTIONS,
  126. EMERGENCY_PLAN_MANAGEMENT_TABLE_COLUMNS,
  127. TABLE_MAX_HEIGHT_DEFAULT,
  128. TABLE_MAX_HEIGHT_PERMISSION,
  129. APPROVAL_PROCESS_TABLE_COLUMNS,
  130. } from './src/config';
  131. import { EMERGENCY_PERMISSIONS } from '@/views/emergency/src/constant';
  132. import { EMERGENCY_PLAN_STATUS, APPROVAL_TYPE_MAP,APPROVAL_STATUS_MAP } from './src/constant';
  133. const router = useRouter();
  134. const planManagementPremissions = ref<boolean>(false);
  135. const { tableConfig, pagination } = useTableConfig(
  136. EMERGENCY_PLAN_MANAGEMENT_TABLE_COLUMNS,
  137. EMERGENCY_PLAN_MANAGEMENT_TABLE_OPTIONS,
  138. );
  139. const { tableConfig: approvalProcessConfig } = useTableConfig(APPROVAL_PROCESS_TABLE_COLUMNS, {}, false);
  140. const { emergencyEventDice, getEmergencyEventDict, getEmergencyEvent } = useEmergencyHook();
  141. const { planTypeDice, getPlanTypeDict, getPlanType, getEmergencyPlanStatusLabel } = useEmergencyPlanHook();
  142. const { permissions } = useUserInfoHook();
  143. let planManagementListQuery: QueryPageRequest<PlanEmergencyListQuery> = {
  144. pageNumber: pagination.pageNumber,
  145. pageSize: pagination.pageSize,
  146. queryParam: {},
  147. };
  148. const tableData = ref<PlanEmergencyListResponse[]>([]);
  149. const searchData = reactive({
  150. planName: null,
  151. planType: null,
  152. eventType: null,
  153. status: null,
  154. });
  155. const handleSearch = () => {
  156. planManagementListQuery.queryParam = {};
  157. if (searchData.planName) {
  158. planManagementListQuery.queryParam.planName = searchData.planName;
  159. }
  160. if (searchData.planType) {
  161. planManagementListQuery.queryParam.planType = searchData.planType;
  162. }
  163. if (searchData.eventType) {
  164. planManagementListQuery.queryParam.eventType = searchData.eventType;
  165. }
  166. if (searchData.status !== null) {
  167. planManagementListQuery.queryParam.status = searchData.status;
  168. }
  169. getTableData();
  170. };
  171. const getTableData = async () => {
  172. tableConfig.loading = true;
  173. const res = await getEmergencyPlanList(planManagementListQuery);
  174. tableData.value = res.records;
  175. pagination.total = res.totalRow;
  176. tableConfig.loading = false;
  177. };
  178. const handleSizeChange = (value: number) => {
  179. pagination.pageSize = value;
  180. planManagementListQuery.pageSize = value;
  181. getTableData();
  182. };
  183. const handleCurrentChange = (value: number) => {
  184. pagination.pageNumber = value;
  185. planManagementListQuery.pageNumber = value;
  186. getTableData();
  187. };
  188. const defaultName = 'plan-management-detail';
  189. const handleAdd = () => {
  190. router.push({
  191. name: defaultName,
  192. query: {
  193. type: 'add',
  194. },
  195. });
  196. };
  197. const handleEdit = (id: number) => {
  198. router.push({
  199. name: defaultName,
  200. query: {
  201. id,
  202. type: 'edit',
  203. },
  204. });
  205. };
  206. const handleView = (id: number) => {
  207. router.push({
  208. name: defaultName,
  209. query: {
  210. id,
  211. type: 'view',
  212. },
  213. });
  214. };
  215. const handleDelete = async (id: number) => {
  216. await deleteEmergencyPlan(id);
  217. ElMessage.success('删除成功');
  218. await getTableData();
  219. };
  220. const basicDialogRef = ref<InstanceType<typeof BasicDialog>>();
  221. const approvalProcessData = ref<ApprovalProcessList[]>([]);
  222. const handleViewApprovalProcess = async (row: PlanEmergencyListResponse) => {
  223. if (row.status !== EMERGENCY_PLAN_STATUS.APPROVAL_IN_PROGRESS && row.status !== EMERGENCY_PLAN_STATUS.RETURNED)
  224. return;
  225. const res = await queryApprovalProcess(row.approvalTemplateId, row.id);
  226. // 处理审批流程数据
  227. approvalProcessData.value = [];
  228. res.forEach((item: ApprovalProcessResponse) => {
  229. if (item.processInfoList && item.processInfoList.length > 0) {
  230. item.processInfoList.forEach((process: ProcessInfoListType) => {
  231. approvalProcessData.value.push({
  232. approvalOrder: item.approvalOrder,
  233. nodeDescription: item.nodeDescription,
  234. approvalType: process.approvalType,
  235. approverName: process.approverName,
  236. approvalContent: process.approvalContent,
  237. approvalStatus: process.approvalStatus,
  238. approvalTime: process.approvalTime,
  239. });
  240. });
  241. }
  242. });
  243. basicDialogRef.value?.openDialog();
  244. };
  245. onMounted(() => {
  246. getPlanTypeDict();
  247. getEmergencyEventDict();
  248. getTableData();
  249. planManagementPremissions.value = Boolean(
  250. permissions.find((item: { code: string }) => item.code === EMERGENCY_PERMISSIONS.PLANE_MANAGEMENT),
  251. );
  252. tableConfig.maxHeight = planManagementPremissions.value ? TABLE_MAX_HEIGHT_PERMISSION : TABLE_MAX_HEIGHT_DEFAULT;
  253. });
  254. </script>
  255. <style scoped lang="scss">
  256. @use '@/styles/page-details-layout.scss' as *;
  257. @use '@/styles/page-main-layout.scss' as *;
  258. @use '@/styles/basic-table-action.scss' as *;
  259. .highlight-text {
  260. cursor: pointer;
  261. color: $primary-color;
  262. }
  263. </style>