list.vue 16 KB

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