list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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. >添加
  20. </el-button>
  21. </div>
  22. <div class="search-form">
  23. <el-form :inline="true">
  24. <el-form-item label="区域名称">
  25. <el-input v-model="queryParams.queryParam.nameFunction" placeholder="搜索功能名称" style="width: 170px" />
  26. </el-form-item>
  27. <el-form-item label="状态">
  28. <el-select v-model="queryParams.queryParam.status" clearable placeholder="状态" style="width: 170px">
  29. <el-option :value="1" label="正常" />
  30. <el-option :value="2" label="待确认" />
  31. <el-option :value="3" label="已拒绝" />
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="安全责任部门">
  35. <el-cascader
  36. v-model="queryParams.queryParam.safetyResponsibleDepartmentId"
  37. style="width: 170px"
  38. ref="cascaderRef"
  39. :options="firstLevelDepts"
  40. :props="cascaderProp"
  41. :show-all-levels="false"
  42. placeholder="部门名称"
  43. filterable
  44. @change="handleChangeDept"
  45. />
  46. </el-form-item>
  47. <el-form-item label="安全具体责任人" prop="safetyResponsibleBuilding">
  48. <el-select
  49. v-model="queryParams.queryParam.safetySpecificPerson"
  50. placeholder="请选择"
  51. style="width: 170px"
  52. filterable
  53. >
  54. <el-option v-for="item in userOptions" :key="item.value" :label="item.label" :value="item.value" />
  55. </el-select>
  56. </el-form-item>
  57. </el-form>
  58. <div>
  59. <!-- <el-button @click="batchImportVisible = true">导入</el-button>
  60. <el-button type="primary" @click="handleDownload">导出</el-button> -->
  61. <el-button type="primary" @click="queryTableList">查询</el-button>
  62. <el-button @click="handleRestParams">重置</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. const { id } = useUserInfoHook();
  190. const router = useRouter();
  191. const activeTab = ref(2);
  192. const queryParams = reactive<any>({
  193. pageNumber: 1,
  194. pageSize: 10,
  195. queryParam: {
  196. type: 2,
  197. nameFunction: '',
  198. status: '',
  199. safetyResponsibleDepartmentId: [],
  200. safetySpecificPerson: '',
  201. },
  202. });
  203. const cascaderRef = ref<any>(null);
  204. const firstLevelDepts = ref<any[]>([]);
  205. const cascaderProp = {
  206. expandTrigger: 'click',
  207. checkStrictly: true,
  208. // emitPath: false,
  209. value: 'id',
  210. label: 'deptName',
  211. };
  212. // 批量导入
  213. const batchImportVisible = ref(false);
  214. const { urlPrefix } = useGlobSetting();
  215. const importApiUrl = ref(urlJoin(urlPrefix, '/areaCheckList/importArea?type=2'));
  216. const templateUrl = ref('');
  217. const handleUpdate = () => {
  218. batchImportVisible.value = false;
  219. queryTableList();
  220. };
  221. const tableData = reactive({
  222. data: [],
  223. total: 0,
  224. });
  225. const userOptions = ref<any[]>([]);
  226. const handleChangeDept = () => {
  227. const deptInfo = cascaderRef.value?.getCheckedNodes();
  228. if (deptInfo?.[0]) {
  229. // queryParams.queryParam.department = deptInfo[0].label;
  230. queryParams.queryParam.safetyResponsibleDepartmentId = deptInfo[0].pathValues;
  231. }
  232. };
  233. const handleTabChange = (tab) => {
  234. if (tab === 1) {
  235. router.push({
  236. name: 'listResponsibilities:public',
  237. });
  238. } else if (tab === 2) {
  239. router.push({
  240. name: 'listResponsibilities:nonPublic',
  241. });
  242. }
  243. };
  244. const getDeptData = () => {
  245. getAllDepartments().then((res) => {
  246. firstLevelDepts.value = formatDeptTree(res);
  247. });
  248. };
  249. async function handleDownload() {
  250. // getQuery();
  251. try {
  252. const res = await areaCheckListExportArea(queryParams.queryParam);
  253. if (res.size === 0) return;
  254. const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
  255. const url = window.URL.createObjectURL(blob);
  256. downloadFile(url, '责任清单.xlsx');
  257. } catch (e) {
  258. ElMessage.error('下载失败');
  259. console.log(e);
  260. }
  261. }
  262. const handleAreaCheckListApprove = (scope, approveType) => {
  263. areaCheckListApprove({
  264. id: scope.row.id,
  265. approveType,
  266. refuseReason: null,
  267. }).then(() => {
  268. if (approveType === 1) {
  269. ElMessage.success('请尽快修改该责任清单的安全责任所/中心、安全责任部门及相关负责人信息');
  270. } else {
  271. ElMessage.success('操作成功!');
  272. }
  273. queryTableList();
  274. });
  275. };
  276. const handleQueryAvailableUserList = (deptName = '', realname = '') => {
  277. queryAvailableUserList({
  278. pageNumber: 1,
  279. pageSize: 200,
  280. queryParam: {
  281. deptName,
  282. realname,
  283. },
  284. }).then((res: any) => {
  285. userOptions.value = (res.records || []).map((u: any) => ({
  286. value: u.userId || u.id,
  287. label: u.realname,
  288. }));
  289. });
  290. };
  291. const handleSizeChange = (value) => {
  292. queryParams.pageSize = value;
  293. queryTableList();
  294. };
  295. const handleCurrentChange = (value) => {
  296. queryParams.pageNumber = value;
  297. queryTableList();
  298. };
  299. const handleConfirmDeleteRow = (scope) => {
  300. areaCheckListDelete(scope.row.id).then(() => {
  301. ElMessage.success('删除成功!');
  302. queryTableList();
  303. });
  304. };
  305. const queryTableList = () => {
  306. areaCheckListQueryPage(queryParams).then((res) => {
  307. tableData.data = res.records;
  308. tableData.total = res.totalRow;
  309. });
  310. };
  311. const handleRestParams = () => {
  312. Object.assign(queryParams, {
  313. pageNumber: 1,
  314. pageSize: 10,
  315. queryParam: {
  316. ...queryParams.queryParam,
  317. status: '',
  318. nameFunction: '',
  319. safetyResponsibleDepartmentId: [],
  320. safetySpecificPerson: '',
  321. },
  322. });
  323. queryTableList();
  324. };
  325. onMounted(async () => {
  326. await getDeptData();
  327. await handleQueryAvailableUserList();
  328. queryTableList();
  329. });
  330. </script>
  331. <style lang="scss" scoped>
  332. @use '@/styles/page-details-layout.scss' as *;
  333. @use '@/styles/page-main-layout.scss' as *;
  334. @use '@/styles/basic-table-action.scss' as *;
  335. :deep(.el-tabs__header) {
  336. margin: 0;
  337. }
  338. :deep(.el-tabs__item) {
  339. font-size: 14px !important;
  340. }
  341. :deep(.flexContent) {
  342. display: flex;
  343. }
  344. :deep(.breadcrumb .title) {
  345. margin-left: 0;
  346. }
  347. :deep(.el-form) {
  348. flex: 1;
  349. display: flex;
  350. row-gap: 15px;
  351. flex-wrap: wrap;
  352. }
  353. :deep(.el-form-item) {
  354. margin-bottom: 0;
  355. }
  356. :deep(main) {
  357. display: flex;
  358. flex-direction: column;
  359. }
  360. .search-form {
  361. min-width: 800px;
  362. display: flex;
  363. justify-content: space-between;
  364. align-items: flex-end;
  365. margin-bottom: 20px;
  366. }
  367. .button-content {
  368. margin-bottom: 20px;
  369. }
  370. .table-content {
  371. flex: 1;
  372. overflow: hidden;
  373. overflow-y: auto;
  374. }
  375. .page-content {
  376. display: flex;
  377. justify-content: flex-end;
  378. }
  379. .pagination-container {
  380. margin-top: 20px;
  381. display: flex;
  382. justify-content: flex-end;
  383. }
  384. </style>