list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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>
  8. <el-button class="search-table-container--button" type="primary" @click="$router.push({ name: 'riskManageAdd' })">添加 </el-button>
  9. <el-button plain class="search-table-container--button" @click="handleImport">
  10. 导入
  11. </el-button>
  12. </div>
  13. <div class="search-form">
  14. <el-form :inline="true">
  15. <el-form-item label="搜索">
  16. <el-input
  17. v-model="queryParams.queryParam.mergeFiled"
  18. placeholder="搜索楼号/楼宇/楼层/房间"
  19. style="width: 170px"
  20. />
  21. </el-form-item>
  22. <el-form-item label="状态">
  23. <el-select v-model="queryParams.queryParam.status" clearable placeholder="状态" style="width: 170px">
  24. <el-option :value="1" label="正常" />
  25. <el-option :value="2" label="待确认" />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="部门名称">
  29. <el-cascader
  30. v-model="queryParams.queryParam.responsibleDepartmentId"
  31. style="width: 170px"
  32. ref="cascaderRef"
  33. :options="firstLevelDepts"
  34. :props="cascaderProp"
  35. :show-all-levels="false"
  36. placeholder="部门名称"
  37. filterable
  38. @change="handleChangeDept"
  39. />
  40. </el-form-item>
  41. <el-form-item label="风险类型">
  42. <el-select
  43. v-model="queryParams.queryParam.riskCategory"
  44. clearable
  45. placeholder="风险类型"
  46. style="width: 170px"
  47. >
  48. <el-option :value="1" label="III级危险点" />
  49. <el-option :value="2" label="II级危险点" />
  50. <el-option :value="3" label="I级危险点" />
  51. <el-option :value="4" label="UPS" />
  52. <el-option :value="5" label="电力设施(强电)" />
  53. <el-option :value="6" label="高低温气体液体、高压气体" />
  54. <el-option :value="7" label="试验设施设备" />
  55. <el-option :value="8" label="特种设备" />
  56. <el-option :value="9" label="危化品、易燃易爆固液气体" />
  57. <el-option :value="10" label="有限空间" />
  58. </el-select>
  59. </el-form-item>
  60. <el-form-item label="风险级别">
  61. <el-select v-model="queryParams.queryParam.riskLevel" clearable placeholder="风险类型" style="width: 170px">
  62. <el-option :value="1" label="B" />
  63. <el-option :value="2" label="C" />
  64. </el-select>
  65. </el-form-item>
  66. </el-form>
  67. <div>
  68. <el-button type="primary" @click="queryTableList">查询</el-button>
  69. <el-button @click="handleRestParams">重置</el-button>
  70. <el-button plain @click="handleDownload">
  71. 导出
  72. </el-button>
  73. </div>
  74. </div>
  75. <div class="table-content">
  76. <el-table :data="tableData.data">
  77. <el-table-column type="index" label="序号" width="80" />
  78. <el-table-column label="楼号/区域" prop="buildingArea" width="180" />
  79. <el-table-column label="楼宇名称" prop="buildingName" width="180" />
  80. <el-table-column label="楼层/位置" prop="floorLocation" width="180" />
  81. <el-table-column label="房间号(名称)" prop="roomName" width="180" />
  82. <el-table-column label="安全责任人" prop="roomSafetyResponsibleName" width="180" />
  83. <el-table-column label="是否存在风险点" prop="hasRiskPointName" width="180" />
  84. <el-table-column label="风险点类别" prop="riskCategoryName" width="180" />
  85. <el-table-column label="变更原因" prop="changeReason" width="170" />
  86. <el-table-column label="状态" prop="statusName" width="100" />
  87. <el-table-column fixed="right" min-width="240" label="操作">
  88. <template #default="scope">
  89. <div v-if="(id === scope.row.createdBy && id !== scope.row.roomSafetyResponsible) && scope.row.status === 1">
  90. <el-button
  91. type="primary"
  92. link
  93. @click="$router.push({ name: 'riskManageEdit', query: { id: scope.row.id } })"
  94. >编辑</el-button>
  95. <el-button type="primary" link @click="handleConfirmDeleteRow(scope)">删除</el-button>
  96. <el-button type="primary" link @click="handleView(scope.row.id)">查看</el-button>
  97. </div>
  98. <div v-if="(id === scope.row.roomSafetyResponsible && id !==scope.row.createdBy) && scope.row.status === 1">
  99. <el-button
  100. type="primary"
  101. link
  102. @click="$router.push({ name: 'riskManageChange', query: { id: scope.row.id } })"
  103. >变更</el-button>
  104. <el-button type="primary" link @click="handleView(scope.row.id)">查看</el-button>
  105. </div>
  106. <div v-if="(id===scope.row.roomSafetyResponsible && id === scope.row.createdBy) && scope.row.status === 1">
  107. <el-button
  108. type="primary"
  109. link
  110. @click="$router.push({ name: 'riskManageEdit', query: { id: scope.row.id } })"
  111. >编辑</el-button>
  112. <el-button type="primary" link @click="handleConfirmDeleteRow(scope)">删除</el-button>
  113. <el-button type="primary" link @click="handleView(scope.row.id)">查看</el-button>
  114. <el-button
  115. type="primary"
  116. link
  117. @click="$router.push({ name: 'riskManageChange', query: { id: scope.row.id } })"
  118. >变更</el-button>
  119. </div>
  120. <div v-if="(id===scope.row.applyBy)&&scope.row.status === 2">
  121. <el-button type="primary" link @click="handleApprove(scope, 0)">撤回</el-button>
  122. <el-button type="primary" link @click="handleView(scope.row.id)">查看</el-button>
  123. </div>
  124. <div v-if="(id === scope.row.roomSafetyResponsibleTodo)&& scope.row.status===2">
  125. <el-button type="primary" link @click="handleApprove(scope, 1)">确认</el-button>
  126. <el-button type="primary" link @click="handleApprove(scope, 0)">拒绝</el-button>
  127. <el-button type="primary" link @click="handleView(scope.row.id)">查看</el-button>
  128. </div>
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. </div>
  133. <div class="pagination-container" v-if="tableData.total > 0">
  134. <el-pagination
  135. background
  136. :current-page="queryParams.pageNumber"
  137. :page-size="queryParams.pageSize"
  138. :total="tableData.total"
  139. @size-change="handleSizeChange"
  140. @current-change="handleCurrentChange"
  141. />
  142. </div>
  143. </main>
  144. <BatchImport
  145. v-if="batchImportVisible"
  146. :visible="batchImportVisible"
  147. :import-api-url="importApiUrl"
  148. :template-url="templateUrl"
  149. template-name="下载模板"
  150. :show-template="false"
  151. @close="batchImportVisible = false"
  152. @update="handleUpdate"
  153. />
  154. </div>
  155. </template>
  156. <script lang="ts" setup>
  157. import { onMounted, reactive, ref } from 'vue';
  158. import dayjs from 'dayjs';
  159. import { ElMessage } from 'element-plus';
  160. import { useRouter } from 'vue-router';
  161. import {
  162. safetyRiskListQueryPage,
  163. safetyRiskListDelete,
  164. safetyRiskListApprove,
  165. exportRiskList,
  166. } from '@/api/production-safety/responsibility-implementation';
  167. import { omit } from 'lodash-es';
  168. import { useUserInfoHook } from '@/hooks/useUserInfoHook';
  169. import { unformatAttachment } from '@/components/UploadFiles/utils';
  170. import { downloadFile } from '@/views/disaster/utils';
  171. import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
  172. import { getAllDepartments } from '@/api/auth/dept';
  173. import BatchImport from '@/components/batch-import/BatchImport.vue';
  174. import { useGlobSetting } from '@/hooks/setting';
  175. import urlJoin from 'url-join';
  176. import { downloadByData } from '@/utils/file/download';
  177. const router = useRouter();
  178. const { id } = useUserInfoHook();
  179. const firstLevelDepts = ref<any[]>([]);
  180. const cascaderProp = {
  181. expandTrigger: 'click',
  182. checkStrictly: true,
  183. // emitPath: false,
  184. value: 'id',
  185. label: 'deptName',
  186. };
  187. const queryParams = reactive<any>({
  188. pageNumber: 1,
  189. pageSize: 10,
  190. queryParam: {
  191. mergeFiled: '',
  192. status: '',
  193. responsibleDepartment: '',
  194. riskCategory: '',
  195. riskLevel: '',
  196. userId: id,
  197. responsibleDepartmentId: [],
  198. },
  199. });
  200. const cascaderRef = ref();
  201. const tableData = reactive({
  202. data: [],
  203. total: 0,
  204. });
  205. const handleSizeChange = (value) => {};
  206. const handleCurrentChange = (value) => {
  207. queryParams.pageNumber = value;
  208. queryTableList();
  209. };
  210. const getDeptData = () => {
  211. getAllDepartments().then((res) => {
  212. firstLevelDepts.value = formatDeptTree(res);
  213. });
  214. };
  215. const handleChangeDept = () => {
  216. const deptInfo = cascaderRef.value?.getCheckedNodes();
  217. if (deptInfo?.[0]) {
  218. queryParams.queryParam.responsibleDepartment = deptInfo[0].label;
  219. }
  220. };
  221. const handleView = (id)=>{
  222. router.push({ name: 'riskManageView', query: { id} })
  223. }
  224. const handleApprove = (scope, approveType) => {
  225. safetyRiskListApprove({
  226. id: scope.row.id,
  227. approveType,
  228. }).then(() => {
  229. ElMessage.success('操作成功!');
  230. queryTableList();
  231. });
  232. };
  233. const handleDownloadLink = (scope) => {
  234. const attachment = unformatAttachment(scope.row.attachment);
  235. attachment?.forEach((item: any) => {
  236. downloadFile(item.fileUrl, item.fileName);
  237. });
  238. };
  239. const handleConfirmDeleteRow = (scope) => {
  240. safetyRiskListDelete(scope.row.id).then(() => {
  241. ElMessage.success('删除成功!');
  242. queryTableList();
  243. });
  244. };
  245. const queryTableList = () => {
  246. safetyRiskListQueryPage({
  247. ...queryParams,
  248. queryParam: {
  249. ...omit(queryParams.queryParam, 'responsibleDepartmentId'),
  250. },
  251. }).then((res) => {
  252. tableData.data = res.records;
  253. tableData.total = res.totalRow;
  254. });
  255. };
  256. const handleRestParams = () => {
  257. Object.assign(queryParams, {
  258. pageNumber: 1,
  259. pageSize: 10,
  260. queryParam: {
  261. ...queryParams.queryParam,
  262. mergeFiled: '',
  263. status: '',
  264. responsibleDepartment: '',
  265. riskCategory: '',
  266. riskLevel: '',
  267. responsibleDepartmentId: [],
  268. },
  269. });
  270. queryTableList();
  271. };
  272. // 批量导入
  273. const batchImportVisible = ref(false);
  274. const { urlPrefix } = useGlobSetting();
  275. // /productionSafety/academyFile/import
  276. const importApiUrl = ref(urlJoin(urlPrefix, '/safetyRisk/list/importRiskList'));
  277. const templateUrl = ref('./skyeye-file-upload/sfysecurity/TEMPLATE/import-academy-file-template.xlsx');
  278. const handleImport = () => {
  279. batchImportVisible.value = true;
  280. };
  281. const handleUpdate = () => {
  282. batchImportVisible.value = false;
  283. // getTableData();
  284. };
  285. const handleDownload = async () => {
  286. try {
  287. const response = await exportRiskList(queryParams.queryParam);
  288. if (response) {
  289. const fileName = `风险清单管理_${new Date().toISOString().split('T')[0]}.xlsx`;
  290. downloadByData(response, fileName);
  291. ElMessage.success('导出成功');
  292. }
  293. } catch (e) {
  294. console.error('导出院级文件失败:', e);
  295. ElMessage.error('导出失败,请重试');
  296. }
  297. };
  298. onMounted(async () => {
  299. await getDeptData();
  300. queryTableList();
  301. });
  302. </script>
  303. <style lang="scss" scoped>
  304. @use '@/styles/page-details-layout.scss' as *;
  305. @use '@/styles/page-main-layout.scss' as *;
  306. @use '@/styles/basic-table-action.scss' as *;
  307. :deep(.el-tabs__header) {
  308. margin: 0;
  309. }
  310. :deep(.el-tabs__item) {
  311. font-size: 14px !important;
  312. }
  313. :deep(.flexContent) {
  314. display: flex;
  315. }
  316. :deep(.breadcrumb .title) {
  317. margin-left: 0;
  318. }
  319. :deep(.el-form) {
  320. flex: 1;
  321. display: flex;
  322. row-gap: 15px;
  323. flex-wrap: wrap;
  324. }
  325. :deep(.el-form-item) {
  326. margin-bottom: 0;
  327. }
  328. :deep(main) {
  329. display: flex;
  330. flex-direction: column;
  331. }
  332. .search-form {
  333. min-width: 800px;
  334. display: flex;
  335. justify-content: space-between;
  336. align-items: flex-end;
  337. margin-bottom: 20px;
  338. }
  339. .button-content {
  340. margin-bottom: 20px;
  341. }
  342. .table-content {
  343. flex: 1;
  344. overflow: hidden;
  345. overflow-y: auto;
  346. }
  347. .page-content {
  348. display: flex;
  349. justify-content: flex-end;
  350. }
  351. </style>