hiddenTroubleReviewManagement.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. <div style="position: relative">
  10. <!-- <el-button type="primary" class="search-table-container--button" @click="handleCreate">
  11. 新增
  12. </el-button> -->
  13. <!-- <el-button plain class="search-table-container--button" @click="handleImport"> 导入 </el-button> -->
  14. </div>
  15. <div class="act-search">
  16. <section class="select-box">
  17. <div class="select-box--item">
  18. <span>隐患问题:</span>
  19. <el-input
  20. v-model="tableQuery.queryParam.hazardDesc"
  21. placeholder="请输入隐患问题"
  22. class="act-search-input"
  23. />
  24. </div>
  25. <!-- <div class="select-box--item">
  26. <span>状态:</span>
  27. <el-select v-model="tableQuery.queryParam.statusType" placeholder="请选择状态" clearable>
  28. <el-option label="待审批" :value="1" />
  29. <el-option label="已审批" :value="2" />
  30. <el-option label="他人已审批" :value="4" />
  31. </el-select>
  32. </div> -->
  33. <div class="select-box--item">
  34. <span>提交类型:</span>
  35. <el-select v-model="tableQuery.queryParam.sourceTypeName" placeholder="请选择提交类型" clearable>
  36. <el-option label="员工提交" value="员工提交" />
  37. <el-option label="供应商提交" value="供应商提交" />
  38. <el-option label="第三方提交" value="第三方提交" />
  39. </el-select>
  40. </div>
  41. </section>
  42. <section class="search-btn">
  43. <el-button type="primary" @click="handleSearch">查询</el-button>
  44. <el-button @click="handleReset">重置</el-button>
  45. <el-button plain @click="handleDownload"> 导出 </el-button>
  46. </section>
  47. </div>
  48. </header>
  49. <div class="batch-table">
  50. <BasicTable
  51. ref="basicTableRef"
  52. :tableData="tableData"
  53. :tableConfig="tableConfig"
  54. @update:pageSize="handleSizeChange"
  55. @update:pageNumber="handleCurrentChange"
  56. >
  57. <template #status="scope">
  58. <span>
  59. {{ getStatusTypeName(scope.row.approvalStatus) }}
  60. </span>
  61. </template>
  62. <template #action="scope">
  63. <div class="action-container--div" style="justify-content: left">
  64. <!-- 待审核:显示审核和查看 -->
  65. <template v-if="scope.row.status === 1">
  66. <ActionButton text="审核" @click="handleApprove(scope.row.id)" v-if="scope.row.canApprove"/>
  67. <ActionButton text="查看" @click="handleView(scope.row.id)" />
  68. </template>
  69. <!-- 审核通过(需求部门通过或安全部门通过):显示查看和入账 -->
  70. <template v-else-if="scope.row.status === 2 || scope.row.status === 4">
  71. <ActionButton text="查看" @click="handleView(scope.row.id)" />
  72. <ActionButton text="入账" @click="handleAccount(scope.row.id)" />
  73. </template>
  74. <!-- 审核不通过(需求部门驳回或安全部门驳回):显示查看 -->
  75. <template v-else-if="scope.row.status === 3 || scope.row.status === 5">
  76. <ActionButton text="查看" @click="handleView(scope.row.id)" />
  77. </template>
  78. <!-- 其他状态:显示查看 -->
  79. <template v-else>
  80. <ActionButton text="查看" @click="handleView(scope.row.id)" />
  81. </template>
  82. </div>
  83. </template>
  84. </BasicTable>
  85. </div>
  86. </div>
  87. </main>
  88. <BatchImport
  89. v-if="batchImportVisible"
  90. :visible="batchImportVisible"
  91. :import-api-url="importApiUrl"
  92. :template-url="templateUrl"
  93. template-name="员工上报导入模版"
  94. :show-template="true"
  95. @close="batchImportVisible = false"
  96. @update="handleUpdate"
  97. />
  98. </div>
  99. </template>
  100. <script setup lang="ts">
  101. import { onMounted, reactive, ref } from 'vue';
  102. import { ElMessage } from 'element-plus';
  103. import BasicTable from '@/components/BasicTable.vue';
  104. import useTableConfig from '@/hooks/useTableConfigHook';
  105. import ActionButton from '@/components/ActionButton.vue';
  106. import { TABLE_OPTIONS, INVENTORY_TABLE_COLUMNS } from './configs/tables';
  107. import { useRouter } from 'vue-router';
  108. import type { QueryPageRequest } from '@/types/basic-query';
  109. import {
  110. queryEmployeeHazardReportPendingPage,
  111. exportHiddenDanger,
  112. accountEmployeeHazardReport,
  113. type QueryHiddenDangerReq,
  114. type HiddenDanger,
  115. } from '@/api/production-safety';
  116. import { downloadByData } from '@/utils/file/download';
  117. import BatchImport from '@/components/batch-import/BatchImport.vue';
  118. import { useGlobSetting } from '@/hooks/setting';
  119. import urlJoin from 'url-join';
  120. const router = useRouter();
  121. // 表格
  122. const basicTableRef = ref<InstanceType<typeof BasicTable>>();
  123. const { tableConfig, pagination } = useTableConfig(INVENTORY_TABLE_COLUMNS, TABLE_OPTIONS);
  124. const tableData = ref<HiddenDanger[]>([]);
  125. // 将 status (1-7) 转换为 statusType (1-3)
  126. const getStatusType = (status: number): number => {
  127. if (status === 1) return 1;
  128. if (status === 2 || status === 4 || status === 6) return 2;
  129. if (status === 3 || status === 5 || status === 7) return 3;
  130. return 0;
  131. };
  132. const getStatusTypeName = (statusType: number): string => {
  133. if (statusType === 1) return '待审批';
  134. if (statusType === 2) return '已审批';
  135. if (statusType === 4) return '他人已审批';
  136. return '-';
  137. };
  138. const tableQuery = reactive<QueryPageRequest<QueryHiddenDangerReq>>({
  139. pageNumber: pagination.pageNumber,
  140. pageSize: pagination.pageSize,
  141. queryParam: {
  142. hazardDesc: undefined,
  143. statusType: undefined,
  144. sourceTypeName: undefined,
  145. },
  146. });
  147. const handleSizeChange = (value: number) => {
  148. pagination.pageSize = value;
  149. tableQuery.pageSize = value;
  150. getTableData();
  151. };
  152. const handleCurrentChange = (value: number) => {
  153. pagination.pageNumber = value;
  154. tableQuery.pageNumber = value;
  155. getTableData();
  156. };
  157. async function getTableData() {
  158. tableConfig.loading = true;
  159. try {
  160. const res = await queryEmployeeHazardReportPendingPage(tableQuery);
  161. if (res) {
  162. tableData.value = res.records || [];
  163. pagination.total = res.totalRow || 0;
  164. }
  165. } catch (e) {
  166. console.error('获取隐患上报列表失败:', e);
  167. tableData.value = [];
  168. pagination.total = 0;
  169. } finally {
  170. tableConfig.loading = false;
  171. }
  172. }
  173. const handleSearch = () => {
  174. pagination.pageNumber = 1;
  175. tableQuery.pageNumber = 1;
  176. getTableData();
  177. };
  178. const handleReset = () => {
  179. tableQuery.queryParam.hazardDesc = undefined;
  180. tableQuery.queryParam.statusType = undefined;
  181. tableQuery.queryParam.sourceTypeName = undefined;
  182. handleSearch();
  183. };
  184. const batchImportVisible = ref(false);
  185. const { urlPrefix } = useGlobSetting();
  186. const importApiUrl = ref(urlJoin(urlPrefix, '/api/employeeHazardReport/importEmployeeHazardReport'));
  187. const templateUrl = ref('./skyeye-file-upload/sfysecurity/TEMPLATE/员工上报导入模版.xlsx');
  188. const handleImport = () => {
  189. batchImportVisible.value = true;
  190. };
  191. const handleUpdate = () => {
  192. batchImportVisible.value = false;
  193. getTableData();
  194. };
  195. const handleDownload = async () => {
  196. try {
  197. const exportParams: QueryHiddenDangerReq = {
  198. hazardDesc: tableQuery.queryParam.hazardDesc || undefined,
  199. statusType: tableQuery.queryParam.statusType,
  200. sourceTypeName: tableQuery.queryParam.sourceTypeName || undefined,
  201. };
  202. const response = await exportHiddenDanger(exportParams);
  203. if (response) {
  204. const fileName = `员工上报隐患管理_${new Date().toISOString().split('T')[0]}.xlsx`;
  205. downloadByData(response, fileName);
  206. ElMessage.success('导出成功');
  207. }
  208. } catch (e:any) {
  209. console.error('导出隐患上报失败:', e);
  210. ElMessage.error(e?.message || e?.data || '导出失败,请重试');
  211. }
  212. };
  213. const handleCreate = () => {
  214. router.push({
  215. name: 'hiddenTroubleReviewManagementItem',
  216. query: {
  217. operate: 'hidden-trouble-review-create',
  218. },
  219. });
  220. };
  221. const handleView = (id: number) => {
  222. router.push({
  223. name: 'hiddenTroubleReviewManagementItem',
  224. query: {
  225. id,
  226. operate: 'hidden-trouble-review-view',
  227. },
  228. });
  229. };
  230. const handleApprove = (id: number) => {
  231. router.push({
  232. name: 'hiddenTroubleReviewManagementItem',
  233. query: {
  234. id,
  235. operate: 'hidden-trouble-review-approve',
  236. },
  237. });
  238. };
  239. const handleAccount = async (hazardId: number) => {
  240. try {
  241. await accountEmployeeHazardReport(hazardId);
  242. ElMessage.success('入账成功');
  243. getTableData();
  244. } catch (e:any) {
  245. console.error('入账失败:', e);
  246. ElMessage.error(e?.message || e?.data || '入账失败,请重试');
  247. }
  248. };
  249. onMounted(() => {
  250. getTableData();
  251. });
  252. </script>
  253. <style scoped lang="scss">
  254. @use '@/styles/page-details-layout.scss' as *;
  255. @use '@/styles/page-main-layout.scss' as *;
  256. @use '@/styles/basic-table-action.scss' as *;
  257. @use '@/views/traffic/violation/style/act-search-table.scss' as *;
  258. </style>