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