PageApproval.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. <BasicSearch
  10. :searchConfig="EMERGENCY_PLAN_APPROVAL_SEARCH_CONFIG"
  11. :searchData="searchData"
  12. @update:searchData="handleSearch"
  13. />
  14. </header>
  15. <BasicTable
  16. :tableData="tableData"
  17. :tableConfig="tableConfig"
  18. @update:pageSize="handleSizeChange"
  19. @update:pageNumber="handleCurrentChange"
  20. >
  21. <template #planType="scope">
  22. <span>{{ getPlanType(scope.row.planType) }}</span>
  23. </template>
  24. <template #eventType="scope">
  25. <span>{{ getEmergencyEvent(scope.row.eventType) }}</span>
  26. </template>
  27. <template #approvalStatus="scope">
  28. <span>{{ getEmergencyPlanApproStatusLabel(scope.row.approvalStatus) }}</span>
  29. </template>
  30. <template #appendix="scope">
  31. <span class="appendix" v-if="scope.row.appendix" @click="handlePreviewScript(scope.row.appendix)">
  32. 预览
  33. </span>
  34. <span v-else>--</span>
  35. </template>
  36. <template #action="scope">
  37. <div class="action-container--div">
  38. <ActionButton
  39. v-if="scope.row.approvalStatus === APPROVAL_STATUS.PENDING"
  40. text="审批"
  41. @click="handleApproval(scope.row.id, scope.row.approvalOrder)"
  42. />
  43. <span v-else>--</span>
  44. </div>
  45. </template>
  46. </BasicTable>
  47. </div>
  48. </div>
  49. <PreviewOnline ref="previewOnlineRef" />
  50. </div>
  51. <BasicDialog ref="basicDialogRef" title="审批" @refresh="closeDialog">
  52. <template #form>
  53. <el-form ref="formRef" :model="formData" style="width: 100%">
  54. <el-form-item label="审批:" prop="approvalStatus" :rules="[{ required: true, message: '请选择审批状态' }]">
  55. <el-radio-group v-model="formData.approvalStatus">
  56. <el-radio :value="APPROVAL_STATUS.APPROVED">通过</el-radio>
  57. <el-radio :value="APPROVAL_STATUS.REJECTED">退回</el-radio>
  58. </el-radio-group>
  59. </el-form-item>
  60. <el-form-item
  61. v-if="formData.approvalStatus === APPROVAL_STATUS.REJECTED"
  62. label="退回原因:"
  63. prop="rejectReason"
  64. :rules="[{ required: true, message: '请输入退回原因' }]"
  65. >
  66. <el-input v-model="formData.rejectReason" placeholder="请输入退回原因" />
  67. </el-form-item>
  68. </el-form>
  69. </template>
  70. <template #footer>
  71. <el-button type="primary" @click="handleApprovalSubmit">提交</el-button>
  72. <el-button @click="basicDialogRef?.closeDialog">返回</el-button>
  73. </template>
  74. </BasicDialog>
  75. </template>
  76. <script setup lang="ts">
  77. import { ref, reactive, onMounted } from 'vue';
  78. import { ElMessage, type ElForm } from 'element-plus';
  79. import BasicSearch from '@/components/BasicSearch.vue';
  80. import BasicTable from '@/components/BasicTable.vue';
  81. import BasicDialog from '@/components/BasicDialog.vue';
  82. import ActionButton from '@/components/ActionButton.vue';
  83. import PreviewOnline from '@/views/disaster/components/PreviewOnline.vue';
  84. import useTableConfig from '@/hooks/useTableConfigHook';
  85. import { useEmergencyHook } from '../src/hoos';
  86. import { useEmergencyPlanHook } from './src/hook';
  87. import type { QueryPageRequest } from '@/types/basic-query';
  88. import type { PlanApprovalListQuery, PlanApprovalListResponse } from '@/types/emergency-plan';
  89. import { getEmergencyApprovalList, submitApproval } from '@/api/emergency-plan';
  90. import {
  91. EMERGENCY_PLAN_APPROVAL_SEARCH_CONFIG,
  92. EMERGENCY_PLAN_APPROVAL_TABLE_OPTIONS,
  93. EMERGENCY_PLAN_APPROVAL_TABLE_COLUMNS,
  94. } from './src/config';
  95. import { APPROVAL_STATUS } from './src/constant';
  96. import { FILE_TYPE_ICON } from '@/views/disaster/constant';
  97. const { tableConfig, pagination } = useTableConfig(
  98. EMERGENCY_PLAN_APPROVAL_TABLE_COLUMNS,
  99. EMERGENCY_PLAN_APPROVAL_TABLE_OPTIONS,
  100. );
  101. const { getEmergencyEventDict, getEmergencyEvent } = useEmergencyHook();
  102. const { getPlanTypeDict, getPlanType, getEmergencyPlanApproStatusLabel } = useEmergencyPlanHook();
  103. let planApprovalListQuery: QueryPageRequest<PlanApprovalListQuery> = {
  104. pageNumber: pagination.pageNumber,
  105. pageSize: pagination.pageSize,
  106. queryParam: {},
  107. };
  108. const tableData = ref<PlanApprovalListResponse[]>([]);
  109. const searchData = reactive({
  110. approvalStatus: null,
  111. });
  112. const formData = reactive({
  113. approvalStatus: APPROVAL_STATUS.APPROVED,
  114. rejectReason: '',
  115. });
  116. const previewOnlineRef = ref<InstanceType<typeof PreviewOnline>>();
  117. const basicDialogRef = ref<InstanceType<typeof BasicDialog>>();
  118. const formRef = ref<InstanceType<typeof ElForm>>();
  119. const handleSearch = () => {
  120. planApprovalListQuery.queryParam = {};
  121. if (searchData.approvalStatus) {
  122. planApprovalListQuery.queryParam.approvalStatus = searchData.approvalStatus;
  123. }
  124. getTableData();
  125. };
  126. const getTableData = async () => {
  127. tableConfig.loading = true;
  128. const res = await getEmergencyApprovalList(planApprovalListQuery);
  129. tableData.value = res.records;
  130. pagination.total = res.totalRow;
  131. tableConfig.loading = false;
  132. };
  133. const handleSizeChange = (value: number) => {
  134. pagination.pageSize = value;
  135. planApprovalListQuery.pageSize = value;
  136. getTableData();
  137. };
  138. const handleCurrentChange = (value: number) => {
  139. pagination.pageNumber = value;
  140. planApprovalListQuery.pageNumber = value;
  141. getTableData();
  142. };
  143. const handlePreviewScript = (appendix: string) => {
  144. const file = JSON.parse(appendix)[0];
  145. previewOnlineRef.value?.open(file.fileUrl, file.fileType as keyof typeof FILE_TYPE_ICON);
  146. };
  147. const currentId = ref<number>();
  148. const currentOrder = ref<number>();
  149. const handleApproval = (id: number, approvalOrder: number) => {
  150. currentId.value = id;
  151. currentOrder.value = approvalOrder;
  152. basicDialogRef.value?.openDialog();
  153. };
  154. const closeDialog = () => {
  155. formRef.value?.resetFields();
  156. basicDialogRef.value?.closeDialog();
  157. };
  158. const handleApprovalSubmit = () => {
  159. formRef.value?.validate(async (valid) => {
  160. if (valid) {
  161. if (!currentId.value || !currentOrder.value) return;
  162. await submitApproval({
  163. planId: currentId.value,
  164. approvalOrder: currentOrder.value,
  165. approvalStatus: formData.approvalStatus,
  166. returnReason: formData.rejectReason,
  167. });
  168. ElMessage.success('审批成功');
  169. basicDialogRef.value?.closeDialog();
  170. getTableData();
  171. }
  172. });
  173. };
  174. onMounted(() => {
  175. getPlanTypeDict();
  176. getEmergencyEventDict();
  177. getTableData();
  178. });
  179. </script>
  180. <style scoped lang="scss">
  181. @use '@/styles/page-details-layout.scss' as *;
  182. @use '@/styles/page-main-layout.scss' as *;
  183. @use '@/styles/basic-table-action.scss' as *;
  184. .appendix {
  185. cursor: pointer;
  186. color: $primary-color;
  187. }
  188. </style>