list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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: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="120" />
  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="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:nonPublic',
  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:nonPublic',
  107. query: {
  108. id: scope.row.id,
  109. },
  110. })
  111. "
  112. >变更</el-button
  113. >
  114. </template>
  115. <template v-if="scope.row.canChange === true">
  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. <!-- <template v-if="scope.row.status === 3">
  120. <el-button type="primary" link>变更</el-button>
  121. </template> -->
  122. <el-button
  123. type="primary"
  124. link
  125. @click="
  126. $router.push({
  127. name: 'viewResponsibilities:nonPublic',
  128. query: {
  129. id: scope.row.id,
  130. },
  131. })
  132. "
  133. >查看</el-button
  134. >
  135. <el-button
  136. link
  137. type="primary"
  138. v-if="scope.row.creatBy === id && scope.row.status === 2"
  139. @click="handleAreaCheckListApprove(scope, 0)"
  140. >
  141. 撤回
  142. </el-button>
  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. </div>
  161. <BatchImport
  162. :visible="batchImportVisible"
  163. :importApiUrl="importApiUrl"
  164. :templateUrl="templateUrl"
  165. :templateName="'责任清单(非区域管理员)-批量导入模版'"
  166. @close="() => (batchImportVisible = false)"
  167. @update="handleUpdate"
  168. />
  169. </template>
  170. <script lang="ts" setup>
  171. import { onMounted, ref, reactive } from 'vue';
  172. import { ElMessage } from 'element-plus';
  173. import { useRouter } from 'vue-router';
  174. import {
  175. areaCheckListQueryPage,
  176. areaCheckListApprove,
  177. areaCheckListDelete,
  178. areaCheckListExportArea,
  179. queryAvailableUserList,
  180. } from '@/api/production-safety/responsibility-implementation';
  181. import urlJoin from 'url-join';
  182. import { BatchImport } from '@/components/batch-import';
  183. import { unformatAttachment } from '@/components/UploadFiles/utils';
  184. import { downloadFile } from '@/views/disaster/utils';
  185. import { useGlobSetting } from '@/hooks/setting';
  186. import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
  187. import { getAllDepartments } from '@/api/auth/dept';
  188. import { useUserInfoHook } from '@/views/disaster/hooks';
  189. import { downloadByData } from '@/utils/file/download';
  190. import { Plus } from '@element-plus/icons-vue';
  191. const { id } = useUserInfoHook();
  192. const router = useRouter();
  193. const activeTab = ref(2);
  194. const queryParams = reactive<any>({
  195. pageNumber: 1,
  196. pageSize: 10,
  197. queryParam: {
  198. type: 2,
  199. nameFunction: '',
  200. status: '',
  201. safetyResponsibleDepartmentId: [],
  202. safetySpecificPerson: '',
  203. },
  204. });
  205. const cascaderRef = ref<any>(null);
  206. const firstLevelDepts = ref<any[]>([]);
  207. const cascaderProp = {
  208. expandTrigger: 'click',
  209. checkStrictly: true,
  210. // emitPath: false,
  211. value: 'id',
  212. label: 'deptName',
  213. };
  214. // 批量导入
  215. const batchImportVisible = ref(false);
  216. const { urlPrefix } = useGlobSetting();
  217. const importApiUrl = ref(urlJoin(urlPrefix, '/areaCheckList/importArea?type=2'));
  218. const templateUrl = ref('');
  219. const handleUpdate = () => {
  220. batchImportVisible.value = false;
  221. queryTableList();
  222. };
  223. const tableData = reactive({
  224. data: [],
  225. total: 0,
  226. });
  227. const userOptions = ref<any[]>([]);
  228. const handleChangeDept = () => {
  229. const deptInfo = cascaderRef.value?.getCheckedNodes();
  230. if (deptInfo?.[0]) {
  231. // queryParams.queryParam.department = deptInfo[0].label;
  232. queryParams.queryParam.safetyResponsibleDepartmentId = deptInfo[0].pathValues;
  233. }
  234. };
  235. const handleTabChange = (tab) => {
  236. if (tab === 1) {
  237. router.push({
  238. name: 'listResponsibilities:public',
  239. });
  240. } else if (tab === 2) {
  241. router.push({
  242. name: 'listResponsibilities:nonPublic',
  243. });
  244. }
  245. };
  246. const getDeptData = () => {
  247. getAllDepartments().then((res) => {
  248. firstLevelDepts.value = formatDeptTree(res);
  249. });
  250. };
  251. async function handleDownload() {
  252. try {
  253. const response = await areaCheckListExportArea(queryParams.queryParam);
  254. if (response) {
  255. const fileName = `责任清单(非区域管理员)_${new Date().toISOString().split('T')[0]}.xlsx`;
  256. downloadByData(response, fileName);
  257. ElMessage.success('导出成功');
  258. }
  259. } catch (e) {
  260. ElMessage.error('下载失败');
  261. console.log(e);
  262. }
  263. }
  264. const handleAreaCheckListApprove = (scope, approveType) => {
  265. areaCheckListApprove({
  266. id: scope.row.id,
  267. approveType,
  268. refuseReason: null,
  269. }).then(() => {
  270. if (approveType === 1) {
  271. ElMessage.success('请尽快修改该责任清单的安全责任所/中心、安全责任部门及相关负责人信息');
  272. } else {
  273. ElMessage.success('操作成功!');
  274. }
  275. queryTableList();
  276. });
  277. };
  278. const handleQueryAvailableUserList = (deptName = '', realname = '') => {
  279. queryAvailableUserList({
  280. pageNumber: 1,
  281. pageSize: 200,
  282. queryParam: {
  283. deptName,
  284. realname,
  285. },
  286. }).then((res: any) => {
  287. userOptions.value = (res.records || []).map((u: any) => ({
  288. value: u.userId || u.id,
  289. label: u.realname,
  290. }));
  291. });
  292. };
  293. const handleSizeChange = (value) => {
  294. queryParams.pageSize = value;
  295. queryTableList();
  296. };
  297. const handleCurrentChange = (value) => {
  298. queryParams.pageNumber = value;
  299. queryTableList();
  300. };
  301. const handleConfirmDeleteRow = (scope) => {
  302. areaCheckListDelete(scope.row.id).then(() => {
  303. ElMessage.success('删除成功!');
  304. queryTableList();
  305. });
  306. };
  307. const queryTableList = () => {
  308. areaCheckListQueryPage(queryParams).then((res) => {
  309. tableData.data = res.records;
  310. tableData.total = res.totalRow;
  311. });
  312. };
  313. const handleRestParams = () => {
  314. Object.assign(queryParams, {
  315. pageNumber: 1,
  316. pageSize: 10,
  317. queryParam: {
  318. ...queryParams.queryParam,
  319. status: '',
  320. nameFunction: '',
  321. safetyResponsibleDepartmentId: [],
  322. safetySpecificPerson: '',
  323. },
  324. });
  325. queryTableList();
  326. };
  327. onMounted(async () => {
  328. await getDeptData();
  329. await handleQueryAvailableUserList();
  330. queryTableList();
  331. });
  332. </script>
  333. <style lang="scss" scoped>
  334. @use '@/styles/page-details-layout.scss' as *;
  335. @use '@/styles/page-main-layout.scss' as *;
  336. @use '@/styles/basic-table-action.scss' as *;
  337. :deep(.el-tabs__header) {
  338. margin: 0;
  339. }
  340. :deep(.el-tabs__item) {
  341. font-size: 14px !important;
  342. }
  343. :deep(.flexContent) {
  344. display: flex;
  345. }
  346. :deep(.breadcrumb .title) {
  347. margin-left: 0;
  348. }
  349. :deep(.el-form) {
  350. flex: 1;
  351. display: flex;
  352. row-gap: 15px;
  353. flex-wrap: wrap;
  354. }
  355. :deep(.el-form-item) {
  356. margin-bottom: 0;
  357. }
  358. :deep(main) {
  359. display: flex;
  360. flex-direction: column;
  361. }
  362. .search-form {
  363. min-width: 800px;
  364. display: flex;
  365. justify-content: space-between;
  366. align-items: flex-end;
  367. margin-bottom: 20px;
  368. }
  369. .button-content {
  370. margin-bottom: 20px;
  371. }
  372. .table-content {
  373. flex: 1;
  374. overflow: hidden;
  375. overflow-y: auto;
  376. }
  377. .page-content {
  378. display: flex;
  379. justify-content: flex-end;
  380. }
  381. .pagination-container {
  382. margin-top: 20px;
  383. display: flex;
  384. justify-content: flex-end;
  385. }
  386. </style>