responsibility-agree-manage.vue 15 KB

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