employeeReportHiddenTroubleManagement.vue 9.9 KB

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