list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div class="safety-platform-container">
  3. <header class="safety-platform-container__header">
  4. <div class="breadcrumb-title">{{ $route.meta.title }}</div>
  5. <el-tabs v-model="activeTab" @tab-change="handleTabChange">
  6. <el-tab-pane label="公共区域" :name="1" />
  7. <el-tab-pane label="非公共区域" :name="2" />
  8. </el-tabs>
  9. </header>
  10. <main class="safety-platform-container__main">
  11. <div style="margin-bottom: 20px">
  12. <el-button
  13. type="primary"
  14. @click="
  15. $router.push({
  16. name: 'addResponsibilities:public',
  17. })
  18. "
  19. >添加
  20. </el-button>
  21. <el-button @click="batchImportVisible = true">导入</el-button>
  22. </div>
  23. <div class="search-form">
  24. <el-form :inline="true">
  25. <el-form-item label="区域名称">
  26. <el-input v-model="queryParams.queryParam.nameFunction" placeholder="搜索功能名称" style="width: 170px" />
  27. </el-form-item>
  28. <el-form-item label="状态">
  29. <el-select v-model="queryParams.queryParam.status" clearable placeholder="状态" style="width: 170px">
  30. <el-option :value="1" label="正常" />
  31. <el-option :value="2" label="待确认" />
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="安全责任部门">
  35. <el-cascader
  36. v-model="queryParams.queryParam.safetyResponsibleDepartmentId"
  37. style="width: 170px"
  38. ref="cascaderRef"
  39. :options="firstLevelDepts"
  40. :props="cascaderProp"
  41. :show-all-levels="false"
  42. placeholder="部门名称"
  43. filterable
  44. @change="handleChangeDept"
  45. />
  46. </el-form-item>
  47. <el-form-item label="安全具体责任人" prop="safetyResponsibleBuilding">
  48. <el-select
  49. v-model="queryParams.queryParam.safetySpecificPerson"
  50. placeholder="请选择"
  51. style="width: 170px"
  52. filterable
  53. >
  54. <el-option v-for="item in userOptions" :key="item.value" :label="item.label" :value="item.value" />
  55. </el-select>
  56. </el-form-item>
  57. </el-form>
  58. <div>
  59. <el-button type="primary" @click="queryTableList">查询</el-button>
  60. <el-button @click="handleRestParams">重置</el-button>
  61. <el-button @click="handleDownload">导出</el-button>
  62. </div>
  63. </div>
  64. <div class="table-content">
  65. <el-table :data="tableData.data">
  66. <el-table-column type="index" label="序号" width="80" />
  67. <!-- <el-table-column label="楼号" prop="buildingNo" width="80" /> -->
  68. <el-table-column label="楼宇/区域" prop="buildingArea" width="120" />
  69. <el-table-column label="楼层/房号" prop="floorRoomNo" width="180" />
  70. <el-table-column label="名称/功能" prop="nameFunction" width="120" />
  71. <el-table-column label="安全责任所/中心" prop="safetyResponsibleCenter" width="200" />
  72. <el-table-column label="安全责任所/中心负责人" prop="safetyCenterManagerName" width="200" />
  73. <el-table-column label="安全责任部门" prop="safetyResponsibleDepartment" width="180" />
  74. <el-table-column label="安全责任部门负责人" prop="safetyDepartmentManagerName" width="180" />
  75. <el-table-column label="安全具体责任人" prop="safetySpecificPersonName" width="180" />
  76. <el-table-column label="安全具体责任人联系方式" prop="safetyPersonContact" width="230" />
  77. <el-table-column label="变更原因" prop="changeReason" width="170" />
  78. <el-table-column label="状态" prop="statusName" width="100" />
  79. <el-table-column fixed="right" min-width="240" label="操作">
  80. <template #default="scope">
  81. <template v-if="scope.row.status === 1">
  82. <el-button
  83. type="primary"
  84. link
  85. @click="
  86. $router.push({
  87. name: 'editResponsibilities:public',
  88. query: {
  89. id: scope.row.id,
  90. },
  91. })
  92. "
  93. >编辑
  94. </el-button>
  95. <el-popconfirm title="确定要删除吗?" @confirm="handleConfirmDeleteRow(scope)">
  96. <template #reference>
  97. <el-button type="primary" link>删除</el-button>
  98. </template>
  99. </el-popconfirm>
  100. <el-button
  101. type="primary"
  102. link
  103. @click="
  104. $router.push({
  105. name: 'changeResponsibilities:public',
  106. query: {
  107. id: scope.row.id,
  108. },
  109. })
  110. "
  111. >变更</el-button
  112. >
  113. </template>
  114. <template v-if="scope.row.canChange === true">
  115. <el-button type="primary" link @click="handleAreaCheckListApprove(scope, 1)">确认</el-button>
  116. <el-button type="primary" link @click="handleAreaCheckListApprove(scope, 0)">拒绝</el-button>
  117. </template>
  118. <!-- <template v-if="scope.row.status === 3">
  119. <el-button type="primary" link>变更</el-button>
  120. </template> -->
  121. <el-button
  122. type="primary"
  123. link
  124. @click="
  125. $router.push({
  126. name: 'viewResponsibilities:public',
  127. query: {
  128. id: scope.row.id,
  129. },
  130. })
  131. "
  132. >查看</el-button
  133. >
  134. <el-button
  135. link
  136. type="primary"
  137. v-if="scope.row.creatBy === id && scope.row.status === 2"
  138. @click="handleAreaCheckListApprove(scope, 0)"
  139. >
  140. 撤回
  141. </el-button>
  142. </template>
  143. </el-table-column>
  144. </el-table>
  145. </div>
  146. <div class="pagination-container" v-if="tableData.total > 0">
  147. <el-pagination
  148. background
  149. layout="prev, pager, next, jumper,sizes, total"
  150. :current-page="queryParams.pageNumber"
  151. :page-size="queryParams.pageSize"
  152. :total="tableData.total"
  153. :page-sizes="[10, 20, 50, 100]"
  154. @size-change="handleSizeChange"
  155. @current-change="handleCurrentChange"
  156. />
  157. </div>
  158. </main>
  159. </div>
  160. <BatchImport
  161. :visible="batchImportVisible"
  162. :importApiUrl="importApiUrl"
  163. :templateUrl="templateUrl"
  164. :templateName="'责任清单-批量导入模版'"
  165. @close="() => (batchImportVisible = false)"
  166. @update="handleUpdate"
  167. />
  168. </template>
  169. <script lang="ts" setup>
  170. import { onMounted, ref, reactive } from 'vue';
  171. import { ElMessage } from 'element-plus';
  172. import { useRouter } from 'vue-router';
  173. import {
  174. areaCheckListQueryPage,
  175. areaCheckListApprove,
  176. areaCheckListDelete,
  177. areaCheckListExportArea,
  178. queryAvailableUserList,
  179. } from '@/api/production-safety/responsibility-implementation';
  180. import urlJoin from 'url-join';
  181. import { BatchImport } from '@/components/batch-import';
  182. import { downloadFile } from '@/views/disaster/utils';
  183. import { useGlobSetting } from '@/hooks/setting';
  184. import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
  185. import { getAllDepartments } from '@/api/auth/dept';
  186. import { useUserInfoHook } from '@/views/disaster/hooks';
  187. import { downloadByData } from '@/utils/file/download';
  188. const { id } = useUserInfoHook();
  189. const router = useRouter();
  190. const activeTab = ref(1);
  191. const queryParams = reactive<any>({
  192. pageNumber: 1,
  193. pageSize: 10,
  194. queryParam: {
  195. type: 1,
  196. nameFunction: '',
  197. status: '',
  198. safetyResponsibleDepartmentId: [],
  199. safetySpecificPerson: '',
  200. },
  201. });
  202. const cascaderRef = ref<any>(null);
  203. const firstLevelDepts = ref<any[]>([]);
  204. const cascaderProp = {
  205. expandTrigger: 'click',
  206. checkStrictly: true,
  207. // emitPath: false,
  208. value: 'id',
  209. label: 'deptName',
  210. };
  211. // 批量导入
  212. const batchImportVisible = ref(false);
  213. const { urlPrefix } = useGlobSetting();
  214. const importApiUrl = ref(urlJoin(urlPrefix, '/areaCheckList/importArea?type=1'));
  215. const templateUrl = ref('');
  216. const handleUpdate = () => {
  217. batchImportVisible.value = false;
  218. queryTableList();
  219. };
  220. const userOptions = ref<any[]>([]);
  221. const tableData = reactive({
  222. data: [],
  223. total: 0,
  224. });
  225. const handleChangeDept = () => {
  226. const deptInfo = cascaderRef.value?.getCheckedNodes();
  227. if (deptInfo?.[0]) {
  228. // queryParams.queryParam.department = deptInfo[0].label;
  229. queryParams.queryParam.safetyResponsibleDepartmentId = deptInfo[0].pathValues;
  230. }
  231. };
  232. const handleTabChange = (tab) => {
  233. if (tab === 1) {
  234. router.push({
  235. name: 'listResponsibilities:public',
  236. });
  237. } else if (tab === 2) {
  238. router.push({
  239. name: 'listResponsibilities:nonPublic',
  240. });
  241. }
  242. };
  243. async function handleDownload() {
  244. try {
  245. const response = await areaCheckListExportArea(queryParams.queryParam);
  246. if (response) {
  247. const fileName = `责任清单_${new Date().toISOString().split('T')[0]}.xlsx`;
  248. downloadByData(response, fileName);
  249. ElMessage.success('导出成功');
  250. }
  251. } catch (e) {
  252. ElMessage.error('下载失败');
  253. console.log(e);
  254. }
  255. }
  256. const handleQueryAvailableUserList = (deptName = '', realname = '') => {
  257. queryAvailableUserList({
  258. pageNumber: 1,
  259. pageSize: 200,
  260. queryParam: {
  261. deptName,
  262. realname,
  263. },
  264. }).then((res: any) => {
  265. userOptions.value = (res.records || []).map((u: any) => ({
  266. value: u.userId || u.id,
  267. label: u.realname,
  268. }));
  269. });
  270. };
  271. const handleAreaCheckListApprove = (scope, approveType) => {
  272. areaCheckListApprove({
  273. id: scope.row.id,
  274. approveType,
  275. refuseReason: null,
  276. }).then(() => {
  277. if (approveType === 1) {
  278. ElMessage.success('请尽快修改该责任清单的安全责任所/中心、安全责任部门及相关负责人信息');
  279. } else {
  280. ElMessage.success('操作成功!');
  281. }
  282. queryTableList();
  283. });
  284. };
  285. const handleSizeChange = (value) => {
  286. queryParams.pageSize = value;
  287. queryTableList();
  288. };
  289. const handleCurrentChange = (value) => {
  290. queryParams.pageNumber = value;
  291. queryTableList();
  292. };
  293. const handleConfirmDeleteRow = (scope) => {
  294. areaCheckListDelete(scope.row.id).then(() => {
  295. ElMessage.success('删除成功!');
  296. queryTableList();
  297. });
  298. };
  299. const queryTableList = () => {
  300. let params = {
  301. pageNumber: queryParams.pageNumber,
  302. pageSize: queryParams.pageSize,
  303. queryParam:{
  304. ...queryParams.queryParam,
  305. safetyResponsibleDepartmentId: JSON.stringify(queryParams.queryParam.safetyResponsibleDepartmentId)
  306. }
  307. }
  308. areaCheckListQueryPage(params).then((res) => {
  309. tableData.data = res.records;
  310. tableData.total = res.totalRow;
  311. });
  312. };
  313. const handleRestParams = () => {
  314. Object.assign(queryParams, {
  315. pageNumber: 1,
  316. pageSize: 10,
  317. queryParam: {
  318. ...queryParams.queryParam,
  319. status: '',
  320. nameFunction: '',
  321. safetyResponsibleDepartmentId: [],
  322. safetySpecificPerson: '',
  323. },
  324. });
  325. queryTableList();
  326. };
  327. const getDeptData = () => {
  328. getAllDepartments().then((res) => {
  329. firstLevelDepts.value = formatDeptTree(res);
  330. });
  331. };
  332. onMounted(async () => {
  333. await getDeptData();
  334. await handleQueryAvailableUserList();
  335. queryTableList();
  336. });
  337. </script>
  338. <style lang="scss" scoped>
  339. @use '@/styles/page-details-layout.scss' as *;
  340. @use '@/styles/page-main-layout.scss' as *;
  341. @use '@/styles/basic-table-action.scss' as *;
  342. :deep(.el-tabs__header) {
  343. margin: 0;
  344. }
  345. :deep(.el-tabs__item) {
  346. font-size: 14px !important;
  347. }
  348. :deep(.flexContent) {
  349. display: flex;
  350. }
  351. :deep(.breadcrumb .title) {
  352. margin-left: 0;
  353. }
  354. :deep(.el-form) {
  355. flex: 1;
  356. display: flex;
  357. row-gap: 15px;
  358. flex-wrap: wrap;
  359. }
  360. :deep(.el-form-item) {
  361. margin-bottom: 0;
  362. }
  363. :deep(main) {
  364. display: flex;
  365. flex-direction: column;
  366. }
  367. .search-form {
  368. min-width: 800px;
  369. display: flex;
  370. justify-content: space-between;
  371. align-items: flex-end;
  372. margin-bottom: 20px;
  373. }
  374. .button-content {
  375. margin-bottom: 20px;
  376. }
  377. .table-content {
  378. flex: 1;
  379. overflow: hidden;
  380. overflow-y: auto;
  381. }
  382. .page-content {
  383. display: flex;
  384. justify-content: flex-end;
  385. }
  386. .pagination-container {
  387. margin-top: 20px;
  388. display: flex;
  389. justify-content: flex-end;
  390. }
  391. </style>