list.vue 14 KB

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