list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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="80" />
  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="120" />
  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="changeReason" width="170" />
  56. <el-table-column label="状态" prop="statusName" width="100" />
  57. <el-table-column fixed="right" min-width="240" label="操作">
  58. <template #default="scope">
  59. <template v-if="scope.row.status === 1">
  60. <el-button
  61. type="primary"
  62. link
  63. @click="
  64. $router.push({
  65. name: 'areaEditResponsibilities:nonPublic',
  66. query: {
  67. id: scope.row.id,
  68. },
  69. })
  70. "
  71. >编辑
  72. </el-button>
  73. <el-popconfirm title="确定要删除吗?" @confirm="handleConfirmDeleteRow(scope)">
  74. <template #reference>
  75. <el-button type="primary" link>删除</el-button>
  76. </template>
  77. </el-popconfirm>
  78. <el-button
  79. type="primary"
  80. link
  81. @click="
  82. $router.push({
  83. name: 'areaChangeResponsibilities:nonPublic',
  84. query: {
  85. id: scope.row.id,
  86. },
  87. })
  88. "
  89. >变更</el-button
  90. >
  91. </template>
  92. <template v-if="scope.row.canChange === true">
  93. <el-button type="primary" link @click="handleAreaCheckListApprove(scope, 1)">确认</el-button>
  94. <el-button type="primary" link @click="handleAreaCheckListApprove(scope, 0)">拒绝</el-button>
  95. </template>
  96. <template v-if="scope.row.status === 3">
  97. <el-button type="primary" link>变更</el-button>
  98. </template>
  99. <el-button
  100. type="primary"
  101. link
  102. @click="
  103. $router.push({
  104. name: 'areaViewResponsibilities:nonPublic',
  105. query: {
  106. id: scope.row.id,
  107. },
  108. })
  109. "
  110. >查看</el-button
  111. >
  112. <el-button
  113. link
  114. type="primary"
  115. v-if="scope.row.creatBy === id && scope.row.status === 2"
  116. @click="handleAreaCheckListApprove(scope, 0)"
  117. >
  118. 撤回
  119. </el-button>
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. </div>
  124. <div class="pagination-container" v-if="tableData.total > 0">
  125. <el-pagination
  126. background
  127. layout="prev, pager, next, jumper,sizes, total"
  128. :current-page="queryParams.pageNumber"
  129. :page-size="queryParams.pageSize"
  130. :total="tableData.total"
  131. :page-sizes="[10, 20, 50, 100]"
  132. @size-change="handleSizeChange"
  133. @current-change="handleCurrentChange"
  134. />
  135. </div>
  136. </main>
  137. </div>
  138. <BatchImport
  139. :visible="batchImportVisible"
  140. :importApiUrl="importApiUrl"
  141. :templateUrl="templateUrl"
  142. :show-template="false"
  143. :templateName="'责任区域-批量导入模版'"
  144. @close="() => (batchImportVisible = false)"
  145. @update="handleUpdate"
  146. />
  147. </template>
  148. <script lang="ts" setup>
  149. import { onMounted, ref, reactive } from 'vue';
  150. import { ElMessage } from 'element-plus';
  151. import { useRouter } from 'vue-router';
  152. import {
  153. areaCheckListQueryPage,
  154. areaCheckListApprove,
  155. areaCheckListDelete,
  156. areaCheckListExportArea,
  157. } from '@/api/production-safety/responsibility-implementation';
  158. import urlJoin from 'url-join';
  159. import { BatchImport } from '@/components/batch-import';
  160. import { Plus } from '@element-plus/icons-vue';
  161. import { downloadFile } from '@/views/disaster/utils';
  162. import { useGlobSetting } from '@/hooks/setting';
  163. import { useUserInfoHook } from '@/views/disaster/hooks';
  164. import { downloadByData } from '@/utils/file/download';
  165. const router = useRouter();
  166. const activeTab = ref(2);
  167. const { id } = useUserInfoHook();
  168. const queryParams = reactive<any>({
  169. pageNumber: 1,
  170. pageSize: 10,
  171. queryParam: {
  172. type: 2,
  173. nameFunction: '',
  174. status: '',
  175. responsibilityPersonId: id,
  176. },
  177. });
  178. // 批量导入
  179. const batchImportVisible = ref(false);
  180. const { urlPrefix } = useGlobSetting();
  181. const importApiUrl = ref(urlJoin(urlPrefix, '/areaCheckList/importArea?type=2'));
  182. const templateUrl = ref('./skyeye-file-upload/sfysecurity/TEMPLATE/import-law-regulation-template.xlsx');
  183. const handleUpdate = () => {
  184. batchImportVisible.value = false;
  185. queryTableList();
  186. };
  187. const tableData = reactive({
  188. data: [],
  189. total: 0,
  190. });
  191. const handleTabChange = (tab) => {
  192. if (tab === 1) {
  193. router.push({
  194. name: 'areaResponsibilities:public',
  195. });
  196. } else if (tab === 2) {
  197. router.push({
  198. name: 'areaResponsibilities:nonPublic',
  199. });
  200. }
  201. };
  202. async function handleDownload() {
  203. try {
  204. const response = await areaCheckListExportArea(queryParams.queryParam);
  205. if (response) {
  206. const fileName = `责任区域(非区域执行人)_${new Date().toISOString().split('T')[0]}.xlsx`;
  207. downloadByData(response, fileName);
  208. ElMessage.success('导出成功');
  209. }
  210. } catch (e) {
  211. ElMessage.error('导出失败');
  212. console.log(e);
  213. }
  214. }
  215. const handleAreaCheckListApprove = (scope, approveType) => {
  216. areaCheckListApprove({
  217. id: scope.row.id,
  218. approveType,
  219. refuseReason: null,
  220. }).then(() => {
  221. if (approveType === 1) {
  222. ElMessage.success('请尽快修改该责任清单的安全责任所/中心、安全责任部门及相关负责人信息');
  223. } else {
  224. ElMessage.success('操作成功!');
  225. }
  226. queryTableList();
  227. });
  228. };
  229. const handleSizeChange = (value) => {
  230. queryParams.pageSize = value;
  231. queryTableList();
  232. };
  233. const handleCurrentChange = (value) => {
  234. queryParams.pageNumber = value;
  235. queryTableList();
  236. };
  237. const handleConfirmDeleteRow = (scope) => {
  238. areaCheckListDelete(scope.row.id).then(() => {
  239. ElMessage.success('删除成功!');
  240. queryTableList();
  241. });
  242. };
  243. const queryTableList = () => {
  244. areaCheckListQueryPage(queryParams).then((res) => {
  245. tableData.data = res.records;
  246. tableData.total = res.totalRow;
  247. });
  248. };
  249. const handleRestParams = () => {
  250. Object.assign(queryParams, {
  251. pageNumber: 1,
  252. pageSize: 10,
  253. queryParam: {
  254. ...queryParams.queryParam,
  255. status: '',
  256. nameFunction: '',
  257. },
  258. });
  259. queryTableList();
  260. };
  261. onMounted(() => {
  262. queryTableList();
  263. });
  264. </script>
  265. <style lang="scss" scoped>
  266. @use '@/styles/page-details-layout.scss' as *;
  267. @use '@/styles/page-main-layout.scss' as *;
  268. @use '@/styles/basic-table-action.scss' as *;
  269. :deep(.el-tabs__header) {
  270. margin: 0;
  271. }
  272. :deep(.el-tabs__item) {
  273. font-size: 14px !important;
  274. }
  275. :deep(.flexContent) {
  276. display: flex;
  277. }
  278. :deep(.breadcrumb .title) {
  279. margin-left: 0;
  280. }
  281. :deep(.el-form) {
  282. flex: 1;
  283. display: flex;
  284. row-gap: 15px;
  285. flex-wrap: wrap;
  286. }
  287. :deep(.el-form-item) {
  288. margin-bottom: 0;
  289. }
  290. :deep(main) {
  291. display: flex;
  292. flex-direction: column;
  293. }
  294. .search-form {
  295. min-width: 800px;
  296. display: flex;
  297. justify-content: space-between;
  298. align-items: flex-end;
  299. margin-bottom: 20px;
  300. }
  301. .button-content {
  302. margin-bottom: 20px;
  303. }
  304. .table-content {
  305. flex: 1;
  306. overflow: hidden;
  307. overflow-y: auto;
  308. }
  309. .page-content {
  310. display: flex;
  311. justify-content: flex-end;
  312. }
  313. .pagination-container {
  314. display: flex;
  315. justify-content: flex-end;
  316. }
  317. .pagination-container {
  318. margin-top: 20px;
  319. display: flex;
  320. justify-content: flex-end;
  321. }
  322. </style>