responsibility-agree-manage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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">
  6. <el-tab-pane label="全部" name="" key="all" />
  7. <el-tab-pane label="院领导" name="院领导" key="a" />
  8. <el-tab-pane label="所/中心/职能部门/直属研究部/分公司" name="所/中心/职能部门/直属研究部/分公司" key="b" />
  9. <el-tab-pane label="所/中心级部门" name="所/中心级部门" key="c" />
  10. <el-tab-pane label="科室" name="科室" key="d" />
  11. <el-tab-pane label="员工" name="员工" key="e" />
  12. <el-tab-pane label="常驻供应商" name="常驻供应商" key="f" />
  13. </el-tabs>
  14. </header>
  15. <main class="safety-platform-container__main">
  16. <div style="margin-bottom: 20px">
  17. <el-button
  18. type="primary"
  19. @click="
  20. $router.push({
  21. name: 'createResponsibilityAgree',
  22. })
  23. "
  24. >添加责任书
  25. </el-button>
  26. </div>
  27. <div class="search-form">
  28. <el-form :inline="true">
  29. <el-form-item label="责任书名称">
  30. <el-input
  31. v-model="queryParams.queryParam.responsibilityName"
  32. placeholder="搜索安全责任书名称"
  33. style="width: 170px"
  34. />
  35. </el-form-item>
  36. <!-- <el-form-item label="状态">
  37. <el-select v-model="queryParams.queryParam.status" clearable placeholder="状态" style="width: 170px">
  38. <el-option :value="1" label="未下发" />
  39. <el-option :value="2" label="待签署" />
  40. <el-option :value="3" label="待反馈材料" />
  41. <el-option :value="4" label="待审核" />
  42. <el-option :value="5" label="已完成" />
  43. <el-option :value="6" label="已作废" />
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item v-if="!activeTab" label="类别名称">
  47. <el-select
  48. v-model="queryParams.queryParam.departmentName"
  49. clearable
  50. placeholder="类别名称"
  51. style="width: 170px"
  52. >
  53. <el-option value="院领导">院领导</el-option>
  54. <el-option value="所/中心/职能部门/直属研究部/分公司"> 所/中心/职能部门/直属研究部/分公司</el-option>
  55. <el-option value="所/中心级部门">所/中心级部门</el-option>
  56. <el-option value="科室">科室</el-option>
  57. <el-option value="员工">员工</el-option>
  58. <el-option value="常驻供应商">常驻供应商</el-option>
  59. </el-select>
  60. </el-form-item> -->
  61. <el-form-item label="计划日期">
  62. <el-date-picker
  63. v-model="queryParams.queryParam.date"
  64. clearable
  65. type="daterange"
  66. start-placeholder="开始时间"
  67. end-placeholder="结束时间"
  68. style="width: 230px"
  69. />
  70. </el-form-item>
  71. </el-form>
  72. <div>
  73. <el-button type="primary" @click="queryTableList">查询</el-button>
  74. <el-button @click="handleRestParams">重置</el-button>
  75. </div>
  76. </div>
  77. <div class="table-content">
  78. <el-table :data="tableData.data">
  79. <el-table-column label="责任书名称" prop="responsibilityName" width="180" />
  80. <el-table-column label="状态" prop="statusName" width="100" />
  81. <el-table-column label="类别名称" prop="departmentName" width="180" />
  82. <el-table-column label="下发数" prop="issuedQuantity" width="120" >
  83. <template #default="scope">
  84. {{ scope.row.status == 1 ? '-' : scope.row.issuedQuantity }}
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="签署人数" prop="signedQuantity" width="120">
  88. <template #default="scope">
  89. {{ scope.row.status == 1 ? '-' : scope.row.signedQuantity }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="签署比例" prop="signedRatio" width="120">
  93. <template #default="scope">
  94. {{ scope.row.status == 1 ? '-' : scope.row.signedRatio }}
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="分组名称" prop="userGroupName" width="150">
  98. <template #default="scope">
  99. {{ scope.row.status == 1 ? '-' : scope.row.userGroupName }}
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="计划完成时间" prop="planEndTime" width="150">
  103. <template #default="scope">
  104. {{ scope.row.status == 1 ? '-' : scope.row.planEndTime }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column fixed="right" min-width="300" label="操作">
  108. <template #default="scope">
  109. <el-button
  110. v-if="scope.row.status === 1 || scope.row.status === 2 || scope.row.status === 3"
  111. type="primary"
  112. link
  113. @click="
  114. $router.push({
  115. name: 'editResponsibilityAgree',
  116. query: {
  117. id: scope.row.id,
  118. },
  119. })
  120. "
  121. >
  122. 编辑
  123. </el-button>
  124. <!-- <el-button v-if="scope.row.status === 4">审核</el-button> -->
  125. <el-popconfirm
  126. v-if="scope.row.status === 1 || scope.row.status === 6"
  127. title="确定要删除吗?"
  128. @confirm="handleConfirmDeleteRow(scope)"
  129. >
  130. <template #reference>
  131. <el-button type="primary" link>删除</el-button>
  132. </template>
  133. </el-popconfirm>
  134. <el-button
  135. v-if="scope.row.status === 1 || scope.row.status === 2"
  136. type="primary"
  137. link
  138. @click="handleIssueSafetyResponsibility(scope)"
  139. >下发
  140. </el-button>
  141. <!-- <el-popconfirm v-if="scope.row.status === 4">
  142. <el-button type="primary" link @click="handleScrap">作废</el-button>
  143. </el-popconfirm> -->
  144. <el-button
  145. v-if="scope.row.status !== 1"
  146. type="primary"
  147. link
  148. @click="
  149. $router.push({
  150. name: 'viewRecipients',
  151. query: {
  152. id: scope.row.id,
  153. status: scope.row.status,
  154. },
  155. })
  156. "
  157. >下发对象</el-button
  158. >
  159. <el-button type="primary" link @click="handleDownloadLink(scope)">下载</el-button>
  160. </template>
  161. </el-table-column>
  162. </el-table>
  163. </div>
  164. <div class="pagination-container" v-if="tableData.total > 0">
  165. <el-pagination
  166. background
  167. layout="prev, pager, next, jumper,sizes, total"
  168. :current-page="queryParams.pageNumber"
  169. :page-size="queryParams.pageSize"
  170. :total="tableData.total"
  171. :page-sizes="[10, 20, 50, 100]"
  172. @size-change="handleSizeChange"
  173. @current-change="handleCurrentChange"
  174. />
  175. </div>
  176. </main>
  177. </div>
  178. <IssueSafetyResponsibility
  179. v-if="dialogOpen"
  180. v-model.visible="dialogOpen"
  181. :groupList="groupList"
  182. :currentDepartmentKey="currentDepartmentKey"
  183. :departmentOptions="departmentOptions"
  184. :currentRowData="currentRowData"
  185. @submit="handleSubmit"
  186. />
  187. </template>
  188. <script lang="ts" setup>
  189. import { onMounted, ref, reactive, computed, watch } from 'vue';
  190. import dayjs from 'dayjs';
  191. import { ElMessage } from 'element-plus';
  192. import { useRouter } from 'vue-router';
  193. import {
  194. safetyResponsibilityAdminqueryPage,
  195. safetyResponsibilityAdminDelete,
  196. safetyResponsibilityAdminIssuedSafety,
  197. } from '@/api/production-safety/responsibility-implementation';
  198. import { omit } from 'lodash-es';
  199. import { queryUserGroupPage } from '@/api/system/person-group';
  200. import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
  201. import { getAllDepartments } from '@/api/auth/dept';
  202. import { unformatAttachment } from '@/components/UploadFiles/utils';
  203. import { downloadFile } from '@/views/disaster/utils';
  204. import IssueSafetyResponsibility from './components/IssueSafetyResponsibility.vue';
  205. const router = useRouter();
  206. const dialogOpen = ref(false);
  207. const issueSafetyResponsibilityRef = ref<any>(null);
  208. const currentRowData = ref<any>(null);
  209. const activeTab = ref('');
  210. const groupList = ref<any[]>([]);
  211. const queryParams = reactive<any>({
  212. pageNumber: 1,
  213. pageSize: 10,
  214. queryParam: {
  215. responsibilityName: '',
  216. departmentName: '',
  217. status: '',
  218. date: '',
  219. responsibilityPersonId: '',
  220. },
  221. });
  222. const tableData = reactive({
  223. data: [],
  224. total: 0,
  225. });
  226. const deptsOptions = ref<any[]>([]);
  227. const filterDeptsByLevel = (data, maxLevel, level = 1) => {
  228. if (!data || !Array.isArray(data)) return [];
  229. return data.map((item) => {
  230. const { children, ...rest } = item;
  231. if (level < maxLevel && children.length > 0) {
  232. return {
  233. ...item,
  234. children: filterDeptsByLevel(children, maxLevel, level + 1),
  235. };
  236. }
  237. if (level < maxLevel) {
  238. return { ...rest, disabled: true };
  239. }
  240. return rest;
  241. });
  242. };
  243. const currentDepartmentKey = computed(() => {
  244. switch (currentRowData.value.departmentName) {
  245. case '院领导':
  246. return 'A';
  247. case '所/中心/职能部门/直属研究部/分公司':
  248. return 'B';
  249. case '所/中心级部门':
  250. return 'C';
  251. case '科室':
  252. return 'D';
  253. case '员工':
  254. case '常驻供应商':
  255. return 'E';
  256. default:
  257. return 'default';
  258. }
  259. });
  260. const departmentOptions = computed(() => {
  261. switch (currentDepartmentKey.value) {
  262. // 院领导: A
  263. case 'B': // 所/中心/职能部门/直属研究部/分公司
  264. return filterDeptsByLevel(deptsOptions.value, 1);
  265. case 'C': //所/中心级部门
  266. return filterDeptsByLevel(deptsOptions.value, 2);
  267. case 'D': // 科室
  268. return filterDeptsByLevel(deptsOptions.value, 3);
  269. case 'E': // 员工、常驻供应商
  270. return filterDeptsByLevel(deptsOptions.value, 4);
  271. default:
  272. return deptsOptions.value;
  273. }
  274. });
  275. const handleQueryUserGroupPage = () => {
  276. return queryUserGroupPage({
  277. pageNumber: 1,
  278. pageSize: 500,
  279. }).then((res) => {
  280. groupList.value = res.records;
  281. });
  282. };
  283. const getDeptData = () => {
  284. return getAllDepartments().then((res) => {
  285. deptsOptions.value = formatDeptTree(res);
  286. });
  287. };
  288. const handleIssueSafetyResponsibility = (scope) => {
  289. currentRowData.value = scope.row;
  290. dialogOpen.value = true;
  291. };
  292. const handleSizeChange = (value) => {
  293. queryParams.pageSize = value;
  294. queryTableList();
  295. };
  296. const handleCurrentChange = (value) => {
  297. queryParams.pageNumber = value;
  298. queryTableList();
  299. };
  300. const handleDownloadLink = (scope) => {
  301. const attachment = unformatAttachment(scope.row.attachment);
  302. attachment?.forEach((item: any) => {
  303. downloadFile(item.fileUrl, item.fileName);
  304. });
  305. };
  306. const handleConfirmDeleteRow = (scope) => {
  307. safetyResponsibilityAdminDelete(scope.row.id).then(() => {
  308. ElMessage.success('删除成功!');
  309. queryTableList();
  310. });
  311. };
  312. const queryTableList = () => {
  313. safetyResponsibilityAdminqueryPage({
  314. ...queryParams,
  315. queryParam: {
  316. ...omit(queryParams.queryParam, 'date'),
  317. startTime: queryParams.queryParam.date?.[0]
  318. ? dayjs(queryParams.queryParam.date?.[0]).format('YYYY-MM-DD')
  319. : undefined,
  320. endTime: queryParams.queryParam.date?.[1]
  321. ? dayjs(queryParams.queryParam.date?.[1]).format('YYYY-MM-DD')
  322. : undefined,
  323. },
  324. }).then((res) => {
  325. res.records.forEach(item=>{
  326. // 未下发
  327. if(item.status === 1){
  328. item.issuedQuantity = '-'
  329. item.signedQuantity = '-'
  330. item.signedRatio = '-'
  331. }
  332. })
  333. tableData.data = res.records;
  334. tableData.total = res.totalRow;
  335. });
  336. };
  337. const handleRestParams = () => {
  338. Object.assign(queryParams, {
  339. pageNumber: 1,
  340. pageSize: 10,
  341. queryParam: {
  342. responsibilityName: '',
  343. departmentName: '',
  344. status: '',
  345. date: '',
  346. responsibilityPersonId: '',
  347. },
  348. });
  349. queryTableList();
  350. };
  351. const handleSubmit = (formData, submitLoading) => {
  352. submitLoading.value = true;
  353. safetyResponsibilityAdminIssuedSafety({
  354. ...formData,
  355. adminId: currentRowData.value.id,
  356. userGroupId: formData?.userGroupId?.join(',') ?? undefined,
  357. deptId: JSON.stringify(formData.deptId),
  358. signPerson: Array.isArray(formData.signPerson) ? formData.signPerson.join(',') : undefined,
  359. departmentId: formData.deptId.map((item) => (Array.isArray(item) ? item[item.length - 1] : item)).join(','),
  360. })
  361. .then(() => {
  362. queryTableList();
  363. dialogOpen.value = false;
  364. currentRowData.value = {};
  365. })
  366. .finally(() => {
  367. submitLoading.value = false;
  368. });
  369. };
  370. watch(
  371. () => activeTab.value,
  372. (a) => {
  373. queryParams.queryParam.departmentName = a;
  374. queryTableList();
  375. },
  376. );
  377. onMounted(() => {
  378. Promise.all([getDeptData(), handleQueryUserGroupPage()]).then(() => {
  379. queryTableList();
  380. });
  381. });
  382. </script>
  383. <style lang="scss" scoped>
  384. @use '@/styles/page-details-layout.scss' as *;
  385. @use '@/styles/page-main-layout.scss' as *;
  386. @use '@/styles/basic-table-action.scss' as *;
  387. :deep(.el-tabs__header) {
  388. margin: 0;
  389. }
  390. :deep(.el-tabs__item) {
  391. font-size: 14px !important;
  392. }
  393. :deep(.flexContent) {
  394. display: flex;
  395. }
  396. :deep(.breadcrumb .title) {
  397. margin-left: 0;
  398. }
  399. :deep(.el-form) {
  400. flex: 1;
  401. display: flex;
  402. row-gap: 15px;
  403. flex-wrap: wrap;
  404. }
  405. :deep(.el-form-item) {
  406. margin-bottom: 0;
  407. }
  408. :deep(main) {
  409. display: flex;
  410. flex-direction: column;
  411. }
  412. .search-form {
  413. min-width: 800px;
  414. display: flex;
  415. justify-content: space-between;
  416. align-items: flex-end;
  417. margin-bottom: 20px;
  418. }
  419. .button-content {
  420. margin-bottom: 20px;
  421. }
  422. .table-content {
  423. flex: 1;
  424. overflow: hidden;
  425. overflow-y: auto;
  426. }
  427. .page-content {
  428. display: flex;
  429. justify-content: flex-end;
  430. }
  431. .pagination-container {
  432. margin-top: 20px;
  433. display: flex;
  434. justify-content: flex-end;
  435. }
  436. </style>