list.vue 16 KB

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