list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <div class="safety-platform-container">
  3. <header class="safety-platform-container__header">
  4. <el-tabs v-model="activeTab" @tab-change="handleTabChange">
  5. <el-tab-pane label="公共区域" :name="1" />
  6. <el-tab-pane label="非公共区域" :name="2" />
  7. </el-tabs>
  8. </header>
  9. <main class="safety-platform-container__main">
  10. <div class="search-form">
  11. <el-form :inline="true">
  12. <el-form-item label="功能名称">
  13. <el-input
  14. v-model="queryParams.queryParam.nameFunction"
  15. placeholder="搜索安全责任书名称"
  16. style="width: 170px"
  17. />
  18. </el-form-item>
  19. <el-form-item label="状态">
  20. <el-select v-model="queryParams.queryParam.status" clearable placeholder="状态" style="width: 170px">
  21. <el-option :value="1" label="正常" />
  22. <el-option :value="2" label="待确认" />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="安全责任部门">
  26. <el-cascader
  27. v-model="queryParams.queryParam.safetyResponsibleDepartmentId"
  28. style="width: 170px"
  29. ref="cascaderRef"
  30. :options="firstLevelDepts"
  31. :props="cascaderProp"
  32. :show-all-levels="false"
  33. placeholder="部门名称"
  34. filterable
  35. @change="handleChangeDept"
  36. />
  37. </el-form-item>
  38. <el-form-item label="安全具体责任人" prop="safetyResponsibleBuilding">
  39. <el-select
  40. v-model="queryParams.queryParam.safetySpecificPerson"
  41. placeholder="请选择"
  42. style="width: 170px"
  43. filterable
  44. >
  45. <el-option v-for="item in userOptions" :key="item.value" :label="item.label" :value="item.value" />
  46. </el-select>
  47. </el-form-item>
  48. </el-form>
  49. <div>
  50. <!-- <el-button @click="batchImportVisible = true">导入</el-button>
  51. <el-button type="primary" @click="handleDownload">导出</el-button> -->
  52. <el-button
  53. type="primary"
  54. @click="
  55. $router.push({
  56. name: 'addResponsibilities:nonPublic',
  57. })
  58. "
  59. >添加
  60. </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. <div 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: 'viewResponsibilities:nonPublic',
  107. query: {
  108. id: scope.row.id,
  109. },
  110. })
  111. "
  112. >查看</el-button
  113. >
  114. <el-button
  115. type="primary"
  116. link
  117. @click="
  118. $router.push({
  119. name: 'changeResponsibilities:nonPublic',
  120. query: {
  121. id: scope.row.id,
  122. },
  123. })
  124. "
  125. >变更</el-button
  126. >
  127. </div>
  128. <div v-if="scope.row.canChange === true">
  129. <el-button type="primary" link @click="handleAreaCheckListApprove(scope, 1)">确认</el-button>
  130. <el-button type="primary" link @click="handleAreaCheckListApprove(scope, 0)">拒绝</el-button>
  131. </div>
  132. <div v-if="scope.row.status === 3">
  133. <el-button type="primary" link>变更</el-button>
  134. <el-button type="primary" link>查看</el-button>
  135. </div>
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. </div>
  140. <div class="pagination-container" v-if="tableData.total > 0">
  141. <el-pagination
  142. background
  143. :current-page="queryParams.pageNumber"
  144. :page-size="queryParams.pageSize"
  145. :total="tableData.total"
  146. @size-change="handleSizeChange"
  147. @current-change="handleCurrentChange"
  148. />
  149. </div>
  150. </main>
  151. </div>
  152. <BatchImport
  153. :visible="batchImportVisible"
  154. :importApiUrl="importApiUrl"
  155. :templateUrl="templateUrl"
  156. :templateName="'责任清单-批量导入模版'"
  157. @close="() => (batchImportVisible = false)"
  158. @update="handleUpdate"
  159. />
  160. </template>
  161. <script lang="ts" setup>
  162. import { onMounted, ref, reactive } from 'vue';
  163. import { ElMessage } from 'element-plus';
  164. import { useRouter } from 'vue-router';
  165. import {
  166. areaCheckListQueryPage,
  167. areaCheckListApprove,
  168. areaCheckListDelete,
  169. areaCheckListExportArea,
  170. queryAvailableUserList,
  171. } from '@/api/production-safety/responsibility-implementation';
  172. import urlJoin from 'url-join';
  173. import { BatchImport } from '@/components/batch-import';
  174. import { unformatAttachment } from '@/components/UploadFiles/utils';
  175. import { downloadFile } from '@/views/disaster/utils';
  176. import { useGlobSetting } from '@/hooks/setting';
  177. import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
  178. import { getAllDepartments } from '@/api/auth/dept';
  179. const router = useRouter();
  180. const activeTab = ref(2);
  181. const queryParams = reactive<any>({
  182. pageNumber: 1,
  183. pageSize: 10,
  184. queryParam: {
  185. type: 2,
  186. nameFunction: '',
  187. status: '',
  188. safetyResponsibleDepartmentId: [],
  189. safetySpecificPerson: '',
  190. },
  191. });
  192. const cascaderRef = ref<any>(null);
  193. const firstLevelDepts = ref<any[]>([]);
  194. const cascaderProp = {
  195. expandTrigger: 'click',
  196. checkStrictly: true,
  197. // emitPath: false,
  198. value: 'id',
  199. label: 'deptName',
  200. };
  201. // 批量导入
  202. const batchImportVisible = ref(false);
  203. const { urlPrefix } = useGlobSetting();
  204. const importApiUrl = ref(urlJoin(urlPrefix, '/areaCheckList/importArea?type=2'));
  205. const templateUrl = ref('');
  206. const handleUpdate = () => {
  207. batchImportVisible.value = false;
  208. queryTableList();
  209. };
  210. const tableData = reactive({
  211. data: [],
  212. total: 0,
  213. });
  214. const userOptions = ref<any[]>([]);
  215. const handleChangeDept = () => {
  216. const deptInfo = cascaderRef.value?.getCheckedNodes();
  217. if (deptInfo?.[0]) {
  218. // queryParams.queryParam.department = deptInfo[0].label;
  219. queryParams.queryParam.safetyResponsibleDepartmentId = deptInfo[0].pathValues;
  220. }
  221. };
  222. const handleTabChange = (tab) => {
  223. if (tab === 1) {
  224. router.push({
  225. name: 'listResponsibilities:public',
  226. });
  227. } else if (tab === 2) {
  228. router.push({
  229. name: 'listResponsibilities:nonPublic',
  230. });
  231. }
  232. };
  233. const getDeptData = () => {
  234. getAllDepartments().then((res) => {
  235. firstLevelDepts.value = formatDeptTree(res);
  236. });
  237. };
  238. async function handleDownload() {
  239. // getQuery();
  240. try {
  241. const res = await areaCheckListExportArea(queryParams.queryParam);
  242. if (res.size === 0) return;
  243. const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
  244. const url = window.URL.createObjectURL(blob);
  245. downloadFile(url, '责任清单.xlsx');
  246. } catch (e) {
  247. ElMessage.error('下载失败');
  248. console.log(e);
  249. }
  250. }
  251. const handleAreaCheckListApprove = (scope, approveType) => {
  252. areaCheckListApprove({
  253. id: scope.row.id,
  254. approveType,
  255. refuseReason: null,
  256. }).then(() => {
  257. ElMessage.success('操作成功!');
  258. queryTableList();
  259. });
  260. };
  261. const handleQueryAvailableUserList = (deptName = '', realname = '') => {
  262. queryAvailableUserList({
  263. pageNumber: 1,
  264. pageSize: 200,
  265. queryParam: {
  266. deptName,
  267. realname,
  268. },
  269. }).then((res: any) => {
  270. userOptions.value = (res.records || []).map((u: any) => ({
  271. value: u.userId || u.id,
  272. label: u.realname,
  273. }));
  274. });
  275. };
  276. const handleSizeChange = (value) => {};
  277. const handleCurrentChange = (value) => {
  278. queryParams.pageNumber = value;
  279. queryTableList();
  280. };
  281. const handleConfirmDeleteRow = (scope) => {
  282. areaCheckListDelete(scope.row.id).then(() => {
  283. ElMessage.success('删除成功!');
  284. queryTableList();
  285. });
  286. };
  287. const queryTableList = () => {
  288. areaCheckListQueryPage(queryParams).then((res) => {
  289. tableData.data = res.records;
  290. tableData.total = res.totalRow;
  291. });
  292. };
  293. const handleRestParams = () => {
  294. Object.assign(queryParams, {
  295. pageNumber: 1,
  296. pageSize: 10,
  297. queryParam: {
  298. ...queryParams.queryParam,
  299. status: '',
  300. nameFunction: '',
  301. safetyResponsibleDepartmentId: [],
  302. safetySpecificPerson: '',
  303. },
  304. });
  305. queryTableList();
  306. };
  307. onMounted(async () => {
  308. await getDeptData();
  309. await handleQueryAvailableUserList();
  310. queryTableList();
  311. });
  312. </script>
  313. <style lang="scss" scoped>
  314. @use '@/styles/page-details-layout.scss' as *;
  315. @use '@/styles/page-main-layout.scss' as *;
  316. @use '@/styles/basic-table-action.scss' as *;
  317. :deep(.el-tabs__header) {
  318. margin: 0;
  319. }
  320. :deep(.el-tabs__item) {
  321. font-size: 14px !important;
  322. }
  323. :deep(.flexContent) {
  324. display: flex;
  325. }
  326. :deep(.breadcrumb .title) {
  327. margin-left: 0;
  328. }
  329. :deep(.el-form) {
  330. flex: 1;
  331. display: flex;
  332. row-gap: 15px;
  333. flex-wrap: wrap;
  334. }
  335. :deep(.el-form-item) {
  336. margin-bottom: 0;
  337. }
  338. :deep(main) {
  339. display: flex;
  340. flex-direction: column;
  341. }
  342. .search-form {
  343. min-width: 800px;
  344. display: flex;
  345. justify-content: space-between;
  346. align-items: center;
  347. margin-bottom: 20px;
  348. }
  349. .button-content {
  350. margin-bottom: 20px;
  351. }
  352. .table-content {
  353. flex: 1;
  354. overflow: hidden;
  355. overflow-y: auto;
  356. }
  357. .page-content {
  358. display: flex;
  359. justify-content: flex-end;
  360. }
  361. </style>