list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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. :icon="Plus"
  20. >添加
  21. </el-button>
  22. <el-button @click="batchImportVisible = true">导入</el-button>
  23. </div>
  24. <div class="search-form">
  25. <el-form :inline="true">
  26. <el-form-item label="区域名称">
  27. <el-input v-model="queryParams.queryParam.nameFunction" placeholder="搜索功能名称" style="width: 170px" />
  28. </el-form-item>
  29. <el-form-item label="状态">
  30. <el-select v-model="queryParams.queryParam.status" clearable placeholder="状态" style="width: 170px">
  31. <el-option :value="1" label="正常" />
  32. <el-option :value="2" label="待确认" />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="安全责任部门">
  36. <el-cascader
  37. v-model="queryParams.queryParam.safetyResponsibleDepartmentId"
  38. style="width: 170px"
  39. ref="cascaderRef"
  40. :options="firstLevelDepts"
  41. :props="cascaderProp"
  42. :show-all-levels="false"
  43. placeholder="部门名称"
  44. filterable
  45. @change="handleChangeDept"
  46. />
  47. </el-form-item>
  48. <el-form-item label="安全具体责任人" prop="safetyResponsibleBuilding">
  49. <el-select
  50. v-model="queryParams.queryParam.safetySpecificPerson"
  51. placeholder="请选择"
  52. style="width: 170px"
  53. filterable
  54. >
  55. <el-option v-for="item in userOptions" :key="item.value" :label="item.label" :value="item.value" />
  56. </el-select>
  57. </el-form-item>
  58. </el-form>
  59. <div>
  60. <el-button type="primary" @click="queryTableList">查询</el-button>
  61. <el-button @click="handleRestParams">重置</el-button>
  62. <el-button @click="handleDownload">导出</el-button>
  63. </div>
  64. </div>
  65. <div class="table-content">
  66. <el-table :data="tableData.data">
  67. <el-table-column type="index" label="序号" width="80" />
  68. <el-table-column label="楼宇/区域" prop="buildingArea" width="160" />
  69. <el-table-column label="楼层/房号" prop="floorRoomNo" width="160" />
  70. <el-table-column label="名称/功能" prop="nameFunction" width="160" />
  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="changed" width="220" />
  78. <el-table-column label="变更原因" show-overflow-tooltip prop="changeReason" width="170" />
  79. <el-table-column label="状态" prop="statusName" width="100" />
  80. <el-table-column fixed="right" min-width="240" label="操作">
  81. <template #default="scope">
  82. <template v-if="scope.row.status === 1">
  83. <el-button
  84. type="primary"
  85. link
  86. @click="
  87. $router.push({
  88. name: 'editResponsibilities:public',
  89. query: {
  90. id: scope.row.id,
  91. },
  92. })
  93. "
  94. >编辑
  95. </el-button>
  96. <el-popconfirm title="确定要删除吗?" @confirm="handleConfirmDeleteRow(scope)">
  97. <template #reference>
  98. <el-button type="primary" link>删除</el-button>
  99. </template>
  100. </el-popconfirm>
  101. <el-button
  102. type="primary"
  103. link
  104. @click="
  105. $router.push({
  106. name: 'changeResponsibilities:public',
  107. query: {
  108. id: scope.row.id,
  109. },
  110. })
  111. "
  112. >变更</el-button
  113. >
  114. </template>
  115. <template v-if="scope.row.status === 2 && scope.row.safetySpecificPersonTodo === id">
  116. <el-button type="primary" link @click="handleAreaCheckListApprove(scope, 1)">确认</el-button>
  117. <el-button type="primary" link @click="handleAreaCheckListApprove(scope, 0)">拒绝</el-button>
  118. </template>
  119. <el-button
  120. type="primary"
  121. link
  122. @click="
  123. $router.push({
  124. name: 'viewResponsibilities:public',
  125. query: {
  126. id: scope.row.id,
  127. },
  128. })
  129. "
  130. >查看</el-button
  131. >
  132. <el-button
  133. link
  134. type="primary"
  135. v-if="scope.row.creatBy === id && scope.row.status === 2"
  136. @click="handleAreaCheckListApprove(scope, 0)"
  137. >
  138. 撤回
  139. </el-button>
  140. <template v-if="scope.row.changed === '是'">
  141. <el-button type="primary" link @click="changedList(scope.row)">变更记录</el-button>
  142. </template>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. </div>
  147. <div class="pagination-container" v-if="tableData.total > 0">
  148. <el-pagination
  149. background
  150. layout="prev, pager, next, jumper,sizes, total"
  151. :current-page="queryParams.pageNumber"
  152. :page-size="queryParams.pageSize"
  153. :total="tableData.total"
  154. :page-sizes="[10, 20, 50, 100]"
  155. @size-change="handleSizeChange"
  156. @current-change="handleCurrentChange"
  157. />
  158. </div>
  159. </main>
  160. <!-- 变更记录 -->
  161. <el-dialog width="70%" v-model="changedVisible" title="公共区域变更记录">
  162. <div class="table-content">
  163. <h4>当前信息(变更后)</h4>
  164. <el-table :data="changedListData.currentRecord">
  165. <el-table-column type="index" label="编号" width="80" />
  166. <el-table-column label="楼宇/区域" prop="buildingArea" width="180" />
  167. <el-table-column label="楼层/房号" prop="floorRoomNo" width="180" />
  168. <el-table-column label="名称/功能" prop="nameFunction" width="180" />
  169. <el-table-column label="安全责任所/中心" prop="safetyResponsibleCenter" width="210" />
  170. <el-table-column label="安全责任所/中心负责人" prop="safetyCenterManagerName" width="200" />
  171. <el-table-column label="安全责任部门" prop="safetyResponsibleDepartment" width="210" />
  172. <el-table-column label="安全责任部门负责人" prop="safetyDepartmentManagerName" width="180" />
  173. <el-table-column label="安全具体责任人" prop="safetySpecificPersonName" width="180" />
  174. <el-table-column label="安全具体责任人联系方式" prop="safetyPersonContact" width="230" />
  175. <el-table-column label="是否进行过责任人变更" prop="changed" width="220" />
  176. <el-table-column label="变更原因" show-overflow-tooltip prop="changeReason" width="170" />
  177. <el-table-column label="状态" prop="statusName" width="100" />
  178. </el-table>
  179. </div>
  180. <div class="table-content">
  181. <h4>历史记录(变更前)</h4>
  182. <el-table :data="changedListData.historiesRecords.records">
  183. <el-table-column type="index" label="编号" width="80" />
  184. <el-table-column label="变更时间" prop="createdAt" width="180" />
  185. <el-table-column label="变更人" prop="safetySpecificPersonName" width="180" />
  186. <el-table-column label="楼宇/区域" prop="buildingArea" width="180" />
  187. <el-table-column label="楼层/房号" prop="floorRoomNo" width="180" />
  188. <el-table-column label="名称/功能" prop="nameFunction" width="180" />
  189. <el-table-column label="安全责任所/中心" prop="safetyResponsibleCenter" width="210" />
  190. <el-table-column label="安全责任所/中心负责人" prop="safetyCenterManagerName" width="200" />
  191. <el-table-column label="安全责任部门" prop="safetyResponsibleDepartment" width="210" />
  192. <el-table-column label="安全责任部门负责人" prop="safetyDepartmentManagerName" width="180" />
  193. <el-table-column label="安全具体责任人" prop="safetySpecificPersonName" width="180" />
  194. <el-table-column label="安全具体责任人联系方式" prop="safetyPersonContact" width="230" />
  195. <el-table-column label="是否进行过责任人变更" prop="changed" width="220" />
  196. <el-table-column label="变更原因" show-overflow-tooltip prop="changeReason" width="170" />
  197. <el-table-column label="状态" prop="statusName" width="100" />
  198. </el-table>
  199. <div class="pagination-container" v-if="changedListData.historiesRecords.totalRow > 0">
  200. <el-pagination
  201. background
  202. layout="prev, pager, next, jumper,sizes, total"
  203. :current-page="queryParams.pageNumber"
  204. :page-size="queryParams.pageSize"
  205. :total="changedListData.historiesRecords.totalRow"
  206. :page-sizes="[10, 20, 50, 100]"
  207. @size-change="handleSizeChange2"
  208. @current-change="handleCurrentChange2"
  209. />
  210. </div>
  211. </div>
  212. </el-dialog>
  213. <!-- 确认弹窗 -->
  214. <confirmChange :visible="changedDialogState" :params="changedParams" @confirm="handleConfirmChange" @cancel="handleCancelChange" />
  215. </div>
  216. <BatchImport
  217. :visible="batchImportVisible"
  218. :importApiUrl="importApiUrl"
  219. :templateUrl="templateUrl"
  220. :show-template="true"
  221. :templateName="'责任清单-批量导入模版'"
  222. @close="() => (batchImportVisible = false)"
  223. @update="handleUpdate"
  224. />
  225. </template>
  226. <script lang="ts" setup>
  227. import { onMounted, ref, reactive } from 'vue';
  228. import { ElMessage } from 'element-plus';
  229. import { useRouter } from 'vue-router';
  230. import {
  231. areaCheckListQueryPage,
  232. areaCheckListApprove,
  233. areaCheckListDelete,
  234. areaCheckListExportArea,
  235. queryAvailableUserList,
  236. queryChangedList,
  237. } from '@/api/production-safety/responsibility-implementation';
  238. import urlJoin from 'url-join';
  239. import { BatchImport } from '@/components/batch-import';
  240. import { Plus } from '@element-plus/icons-vue';
  241. import confirmChange from './confirmChange.vue';
  242. import { downloadFile } from '@/views/disaster/utils';
  243. import { useGlobSetting } from '@/hooks/setting';
  244. import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
  245. import { getAllDepartments } from '@/api/auth/dept';
  246. import { useUserInfoHook } from '@/views/disaster/hooks';
  247. import { downloadByData } from '@/utils/file/download';
  248. const { id } = useUserInfoHook();
  249. const router = useRouter();
  250. const activeTab = ref(1);
  251. const queryParams = reactive<any>({
  252. pageNumber: 1,
  253. pageSize: 10,
  254. queryParam: {
  255. type: 1,
  256. nameFunction: '',
  257. status: '',
  258. safetyResponsibleDepartmentId: [],
  259. safetySpecificPerson: '',
  260. },
  261. });
  262. const changedVisible = ref(false)
  263. const cascaderRef = ref<any>(null);
  264. const firstLevelDepts = ref<any[]>([]);
  265. const cascaderProp = {
  266. expandTrigger: 'click',
  267. checkStrictly: true,
  268. // emitPath: false,
  269. value: 'id',
  270. label: 'deptName',
  271. };
  272. // 批量导入
  273. const batchImportVisible = ref(false);
  274. const { urlPrefix } = useGlobSetting();
  275. const importApiUrl = ref(urlJoin(urlPrefix, '/areaCheckList/importArea?type=1'));
  276. const templateUrl = ref('./skyeye-file-upload/sfysecurity/TEMPLATE/责任清单-公共区域导入模版.xlsx');
  277. const handleUpdate = () => {
  278. batchImportVisible.value = false;
  279. queryTableList();
  280. };
  281. const userOptions = ref<any[]>([]);
  282. const tableData = reactive({
  283. data: [],
  284. total: 0,
  285. });
  286. const handleChangeDept = () => {
  287. const deptInfo = cascaderRef.value?.getCheckedNodes();
  288. if (deptInfo?.[0]) {
  289. // queryParams.queryParam.department = deptInfo[0].label;
  290. queryParams.queryParam.safetyResponsibleDepartmentId = deptInfo[0].pathValues;
  291. }
  292. };
  293. const changedListData = reactive({
  294. currentRecord:[],
  295. historiesRecords: {
  296. maxPageSize: 0,
  297. optimizeCountQuery: true,
  298. pageNumber: 1,
  299. pageSize: 10,
  300. records: [],
  301. totalPage: 1,
  302. totalRow: 1
  303. }
  304. })
  305. const fetchParams = reactive({
  306. pageNumber: 1,
  307. pageSize: 10,
  308. queryParam: {
  309. id:''
  310. }
  311. })
  312. const changedList = async(item)=>{
  313. fetchParams.queryParam.id = item.id
  314. await fetchTableList()
  315. changedVisible.value = true
  316. }
  317. const fetchTableList = async ()=>{
  318. let res = await queryChangedList(fetchParams)
  319. if(!res){ return }
  320. Object.assign(changedListData, {
  321. currentRecord: res.currentRecord || [],
  322. historiesRecords: res.historiesRecords
  323. })
  324. }
  325. const handleTabChange = (tab) => {
  326. if (tab === 1) {
  327. router.push({
  328. name: 'listResponsibilities:public',
  329. });
  330. } else if (tab === 2) {
  331. router.push({
  332. name: 'listResponsibilities:nonPublic',
  333. });
  334. }
  335. };
  336. async function handleDownload() {
  337. try {
  338. const response = await areaCheckListExportArea(queryParams.queryParam);
  339. if (response) {
  340. const fileName = `责任清单_${new Date().toISOString().split('T')[0]}.xlsx`;
  341. downloadByData(response, fileName);
  342. ElMessage.success('导出成功');
  343. }
  344. } catch (e) {
  345. ElMessage.error('下载失败');
  346. console.log(e);
  347. }
  348. }
  349. const handleQueryAvailableUserList = (deptName = '', realname = '') => {
  350. queryAvailableUserList({
  351. pageNumber: 1,
  352. pageSize: 200,
  353. queryParam: {
  354. deptName,
  355. realname,
  356. },
  357. }).then((res: any) => {
  358. userOptions.value = (res.records || []).map((u: any) => ({
  359. value: u.userId || u.id,
  360. label: u.realname,
  361. }));
  362. });
  363. };
  364. const changedDialogState = ref(false)
  365. const changedParams = reactive({})
  366. // 弹出弹窗,修改必填项
  367. const handleAreaCheckListApprove = (scope, approveType) => {
  368. if(approveType===1){
  369. changedDialogState.value = true
  370. Object.assign(changedParams, {
  371. id: scope.row.id,
  372. approveType
  373. })
  374. return
  375. }
  376. areaCheckListApprove({
  377. id: scope.row.id,
  378. approveType,
  379. refuseReason: null,
  380. }).then((res) => {
  381. ElMessage.success('操作成功!');
  382. queryTableList();
  383. });
  384. };
  385. // 确认回调
  386. const handleConfirmChange = ()=>{
  387. changedDialogState.value = false
  388. queryTableList();
  389. }
  390. const handleCancelChange = ()=>{
  391. changedDialogState.value = false
  392. }
  393. const handleSizeChange = (value) => {
  394. queryParams.pageSize = value;
  395. queryTableList();
  396. };
  397. const handleCurrentChange = (value) => {
  398. queryParams.pageNumber = value;
  399. queryTableList();
  400. };
  401. const handleSizeChange2 = (value) => {
  402. fetchParams.pageSize = value;
  403. fetchTableList()
  404. };
  405. const handleCurrentChange2 = (value) => {
  406. fetchParams.pageNumber = value;
  407. fetchTableList()
  408. };
  409. const handleConfirmDeleteRow = (scope) => {
  410. areaCheckListDelete(scope.row.id).then(() => {
  411. ElMessage.success('删除成功!');
  412. queryTableList();
  413. });
  414. };
  415. const queryTableList = () => {
  416. let params = {
  417. pageNumber: queryParams.pageNumber,
  418. pageSize: queryParams.pageSize,
  419. queryParam:{
  420. ...queryParams.queryParam,
  421. safetyResponsibleDepartmentId: JSON.stringify(queryParams.queryParam.safetyResponsibleDepartmentId)
  422. }
  423. }
  424. areaCheckListQueryPage(params).then((res) => {
  425. tableData.data = res.records;
  426. tableData.total = res.totalRow;
  427. });
  428. };
  429. const handleRestParams = () => {
  430. Object.assign(queryParams, {
  431. pageNumber: 1,
  432. pageSize: 10,
  433. queryParam: {
  434. ...queryParams.queryParam,
  435. status: '',
  436. nameFunction: '',
  437. safetyResponsibleDepartmentId: [],
  438. safetySpecificPerson: '',
  439. },
  440. });
  441. queryTableList();
  442. };
  443. const getDeptData = () => {
  444. getAllDepartments().then((res) => {
  445. firstLevelDepts.value = formatDeptTree(res);
  446. });
  447. };
  448. onMounted(async () => {
  449. await getDeptData();
  450. await handleQueryAvailableUserList();
  451. queryTableList();
  452. });
  453. </script>
  454. <style lang="scss" scoped>
  455. @use '@/styles/page-details-layout.scss' as *;
  456. @use '@/styles/page-main-layout.scss' as *;
  457. @use '@/styles/basic-table-action.scss' as *;
  458. :deep(.el-tabs__header) {
  459. margin: 0;
  460. }
  461. :deep(.el-tabs__item) {
  462. font-size: 14px !important;
  463. }
  464. :deep(.flexContent) {
  465. display: flex;
  466. }
  467. :deep(.breadcrumb .title) {
  468. margin-left: 0;
  469. }
  470. :deep(.el-form) {
  471. flex: 1;
  472. display: flex;
  473. row-gap: 15px;
  474. flex-wrap: wrap;
  475. }
  476. :deep(.el-form-item) {
  477. margin-bottom: 0;
  478. }
  479. :deep(main) {
  480. display: flex;
  481. flex-direction: column;
  482. }
  483. .search-form {
  484. min-width: 800px;
  485. display: flex;
  486. justify-content: space-between;
  487. align-items: flex-end;
  488. margin-bottom: 20px;
  489. }
  490. .button-content {
  491. margin-bottom: 20px;
  492. }
  493. .table-content {
  494. flex: 1;
  495. overflow: hidden;
  496. overflow-y: auto;
  497. }
  498. .page-content {
  499. display: flex;
  500. justify-content: flex-end;
  501. }
  502. .pagination-container {
  503. margin-top: 20px;
  504. display: flex;
  505. justify-content: flex-end;
  506. }
  507. .table-content h4 {
  508. margin: 18px 0 12px 0;
  509. color: #409eff;
  510. }
  511. </style>