sign-agree-dept.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <div class="safety-platform-container">
  3. <el-alert
  4. v-if="showAlertBar"
  5. title="您提交的反馈材料审核不通过,请尽快查看并修改,再次提交进行审核,谢谢!"
  6. type="warning"
  7. />
  8. <div class="back"><BreadcrumbBack /> 安全责任书签署 </div>
  9. <header class="safety-platform-container__header">
  10. <div class="breadcrumb-title">{{ formData?.responsibilityName }} </div>
  11. <div class="detail-content">
  12. <span>类别名称:{{ formData?.departmentName }} </span>
  13. <span>创建人:{{ formData?.createdByName }} </span>
  14. <span>创建时间:{{ formData?.createdAt }} </span>
  15. </div>
  16. </header>
  17. <main class="safety-platform-container__main">
  18. <el-form ref="formRef" label-width="auto" :model="formData" :rules="rules">
  19. <h4>基本信息</h4>
  20. <div class="detail-ct">
  21. <div class="row">
  22. <div class="col">
  23. <div class="label">责任书名称:</div>
  24. <div class="value">{{ formData.responsibilityName }}</div>
  25. </div>
  26. <div class="col">
  27. <div class="label">状态:</div>
  28. <div class="value">{{ formData.statusName }}</div>
  29. </div>
  30. </div>
  31. <div class="row">
  32. <div class="col">
  33. <div class="label">签署人数:</div>
  34. <div class="value">{{ formData.signedQuantity }}</div>
  35. </div>
  36. <!-- <div class="col">
  37. <div class="label">下发对象:</div>
  38. <div class="value">{{ formData.userGroupName }}</div>
  39. </div> -->
  40. </div>
  41. <div class="row">
  42. <div class="col">
  43. <div class="label">计划开始日期:</div>
  44. <div class="value">{{ formData.planStartTime }}</div>
  45. </div>
  46. <div class="col">
  47. <div class="label">计划结束日期:</div>
  48. <div class="value">{{ formData.planEndTime }}</div>
  49. </div>
  50. </div>
  51. </div>
  52. <h4>责任书内容</h4>
  53. <div class="detail-ct">
  54. <div class="row">
  55. <div class="col">
  56. <div class="label">责任书文档:</div>
  57. <div class="value value-s1">
  58. <div class="file-list">
  59. <div class="file-item" v-for="item in formData.attachment" :key="item.fileId">
  60. <span class="file-item--name">{{ item.fileName }}</span>
  61. <div class="file-item--footer">
  62. <!-- <div class="info">
  63. <span>{{ item.fileSize }}</span>
  64. </div> -->
  65. <el-button link type="primary" @click="previewOnline(item.fileUrl, item.fileType)"
  66. >预览</el-button
  67. >
  68. <el-button link type="primary" @click.stop="downloadFile(item.fileUrl, item.fileName)"
  69. >下载</el-button
  70. >
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <template v-if="signRecords.level1.length">
  79. <h4 v-if="currentDepartmentKey === 'A'"> 副院长签署 </h4>
  80. <h4 v-if="currentDepartmentKey === 'B'"> 负责人签署 </h4>
  81. <h4 v-if="currentDepartmentKey === 'C'"> 负责人签署 </h4>
  82. <h4 v-if="currentDepartmentKey === 'D'"> 科室负责人签署 </h4>
  83. <div class="detail-ct">
  84. <div class="row" v-for="item in signRecords.level1" :key="item.id">
  85. <div class="col">
  86. <div class="label">签名:</div>
  87. <div class="value value-s1">
  88. <el-form-item>
  89. <UploadFiles
  90. :disabled="!item.signFlag"
  91. accept=".jpeg,.jpg,.png,.svg"
  92. label="上传文件"
  93. :fileList="item.attachment"
  94. @upload-success="(fileList) => handleUploadSignsUploadSuccess(item, fileList)"
  95. />
  96. </el-form-item>
  97. <div class="file-list">
  98. <div class="file-item" v-for="file in item.attachment" :key="file.fileId">
  99. <span class="file-item--name">{{ file.fileName }}</span>
  100. <div class="file-item--footer">
  101. <el-button link type="primary" @click="previewOnline(file.fileUrl, file.fileType)"
  102. >预览</el-button
  103. >
  104. <el-button link type="primary" @click.stop="downloadFile(file.fileUrl, file.fileName)"
  105. >下载</el-button
  106. >
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </template>
  115. <template v-if="signRecords.level2.length">
  116. <h4 v-if="currentDepartmentKey === 'A'"> 党委书记签署 </h4>
  117. <h4 v-if="currentDepartmentKey === 'B'"> 党委书记签署 </h4>
  118. <h4 v-if="currentDepartmentKey === 'C'"> 党委书记签署</h4>
  119. <h4 v-if="currentDepartmentKey === 'D'"> 部门负责人签署 </h4>
  120. <div class="detail-ct">
  121. <div class="row" v-for="item in signRecords.level2" :key="item.id">
  122. <div class="col">
  123. <div class="label">签名:</div>
  124. <div class="value value-s1">
  125. <el-form-item>
  126. <UploadFiles
  127. :disabled="!item.signFlag"
  128. accept=".jpeg,.jpg,.png,.svg"
  129. label="上传文件"
  130. :fileList="item.attachment"
  131. @upload-success="(fileList) => handleUploadSignsUploadSuccess(item, fileList)"
  132. />
  133. </el-form-item>
  134. <div class="file-list">
  135. <div class="file-item" v-for="file in item.attachment" :key="file.fileId">
  136. <span class="file-item--name">{{ file.fileName }}</span>
  137. <div class="file-item--footer">
  138. <el-button link type="primary" @click="previewOnline(file.fileUrl, file.fileType)"
  139. >预览</el-button
  140. >
  141. <el-button link type="primary" @click.stop="downloadFile(file.fileUrl, file.fileName)"
  142. >下载</el-button
  143. >
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </template>
  152. <template v-if="signRecords.level3.length">
  153. <h4 v-if="currentDepartmentKey === 'A'"> 院长签署 </h4>
  154. <h4 v-if="currentDepartmentKey === 'B'"> 院长签署 </h4>
  155. <h4 v-if="currentDepartmentKey === 'C'"> 所长签署 </h4>
  156. <div class="detail-ct">
  157. <div class="row" v-for="item in signRecords.level3" :key="item.id">
  158. <div class="col">
  159. <div class="label">签名:</div>
  160. <div class="value value-s1">
  161. <el-form-item>
  162. <UploadFiles
  163. :disabled="!item.signFlag"
  164. accept=".jpeg,.jpg,.png,.svg"
  165. label="上传文件"
  166. :fileList="item.attachment"
  167. @upload-success="(fileList) => handleUploadSignsUploadSuccess(item, fileList)"
  168. />
  169. </el-form-item>
  170. <div class="file-list">
  171. <div class="file-item" v-for="file in item.attachment" :key="file.fileId">
  172. <span class="file-item--name">{{ file.fileName }}</span>
  173. <div class="file-item--footer">
  174. <el-button link type="primary" @click="previewOnline(file.fileUrl, file.fileType)"
  175. >预览</el-button
  176. >
  177. <el-button link type="primary" @click.stop="downloadFile(file.fileUrl, file.fileName)"
  178. >下载</el-button
  179. >
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. </template>
  188. </el-form>
  189. </main>
  190. <footer class="safety-platform-container__footer">
  191. <el-button @click="back">返回</el-button>
  192. <el-button type="primary" @click="handleSubmit" :loading="submiting">提交</el-button>
  193. </footer>
  194. </div>
  195. <PreviewOnline ref="previewOnlineRef" />
  196. <el-dialog v-model="dialogVisible" title="下一节点签署人" width="500">
  197. <el-form-item :label="currentLabel">
  198. <el-select v-model="signerId" placeholder="请选择" size="large" style="width: 100%" filterable remote :remote-method="remoteMethod">
  199. <el-option v-for="item in userOptions" :key="item.value" :label="item.label" :value="item.value" />
  200. </el-select>
  201. </el-form-item>
  202. <template #footer>
  203. <div class="dialog-footer">
  204. <el-button @click="handleDialogCancel">取消</el-button>
  205. <el-button type="primary" @click="handleDialogConfirm"> 确认 </el-button>
  206. </div>
  207. </template>
  208. </el-dialog>
  209. </template>
  210. <script lang="ts" setup>
  211. import { onMounted, ref, computed, reactive } from 'vue';
  212. import { ElMessage } from 'element-plus';
  213. import '@wangeditor/editor/dist/css/style.css';
  214. import { useRouter, useRoute } from 'vue-router';
  215. import { downloadFile } from '@/views/disaster/utils';
  216. import UploadFiles from '@/components/UploadFiles/UploadFiles.vue';
  217. import {
  218. safetyResponsibilityDeptQueryDetail,
  219. // safetyResponsibilityDeptSignOrFeedback,
  220. safetyResponsibilityDeptBatchSign,
  221. safetyResponsibilityDeptSaveSign,
  222. queryAvailableUserList,
  223. } from '@/api/production-safety/responsibility-implementation';
  224. import { unformatAttachment, formatAttachmentList } from '@/components/UploadFiles/utils';
  225. import PreviewOnline from '@/views/disaster/components/PreviewOnline.vue';
  226. const uploadImagesRef = ref<InstanceType<typeof UploadFiles>>();
  227. const router = useRouter();
  228. const route = useRoute();
  229. const formRef = ref<any>(null);
  230. const submiting = ref(false);
  231. const dialogVisible = ref(false);
  232. const formData = reactive<any>({
  233. departmentName: '',
  234. createdByName: '',
  235. createdAt: '',
  236. attachment: [],
  237. feedback: [],
  238. signsUpload: [],
  239. responsibilityName: '',
  240. statusName: '',
  241. signedQuantity: '',
  242. userGroupName: '',
  243. planStartTime: null,
  244. planEndTime: null,
  245. rejection: '',
  246. signRecords: [],
  247. });
  248. const rules = reactive({
  249. signsUpload: [
  250. {
  251. required: true,
  252. message: '请上传签署材料',
  253. },
  254. ],
  255. });
  256. const signRecords = computed(() => {
  257. return {
  258. level1: formData.signRecords.filter((item) => item.signLevel === 1),
  259. level2: formData.signRecords.filter((item) => item.signLevel === 2),
  260. level3: formData.signRecords.filter((item) => item.signLevel === 3),
  261. };
  262. });
  263. const currentDepartmentKey = computed(() => {
  264. switch (formData.departmentName.trim()) {
  265. case '院领导':
  266. return 'A';
  267. case '所/中心/职能部门/直属研究部/分公司':
  268. return 'B';
  269. case '所/中心级部门':
  270. return 'C';
  271. case '科室':
  272. return 'D';
  273. case '员工':
  274. case '常驻供应商':
  275. return 'E';
  276. default:
  277. return '';
  278. }
  279. });
  280. const userOptions = ref<any[]>([]);
  281. const showAlertBar = computed(() => {
  282. if (!formData.rejection) {
  283. return false;
  284. }
  285. return route.query.status === '3' && formData.rejection !== null;
  286. });
  287. const previewOnlineRef = ref<InstanceType<typeof PreviewOnline>>();
  288. const signerId = ref('');
  289. const currentLabel = ref('');
  290. const previewOnline = (url: string | undefined, type) => {
  291. if (url) {
  292. previewOnlineRef.value?.open(url, type);
  293. }
  294. };
  295. const handleUploadSignsUploadSuccess = async (item, fileList) => {
  296. const attachment = await formatAttachmentList(fileList);
  297. item.attachment = attachment;
  298. formData.signRecords = [...signRecords.value.level1, ...signRecords.value.level2, ...signRecords.value.level3];
  299. };
  300. const back = () => {
  301. router.push({
  302. name: 'responsibilityAgreeManageDept',
  303. });
  304. };
  305. const handleSubmit = () => {
  306. formRef.value?.validate(async (valid) => {
  307. if (valid) {
  308. const fullAttachment = formData.signRecords.every((item) => item.attachment || item.attachment?.length > 0);
  309. const signList = formData.signRecords.filter((item) => item.signFlag && item.signStatus === 0);
  310. const firstSignItem = signList?.[0] ?? {};
  311. const lastSignItem = signList?.[signList.length - 1] ?? {};
  312. const isEmptyAttachment = !firstSignItem?.attachment || firstSignItem?.attachment?.length === 0;
  313. const currentLevel = lastSignItem?.signLevel;
  314. const currentOrder = lastSignItem?.signOrder;
  315. const nextLevel = Math.min(currentLevel + 1, 3);
  316. const nextOrder = currentOrder + 1;
  317. //需要弹框选择用户的部门类型(C和D)
  318. const specialDeptKey = /C|D/.test(currentDepartmentKey.value);
  319. if (specialDeptKey) {
  320. if (!fullAttachment || isEmptyAttachment) {
  321. ElMessage.warning('请上传签署材料');
  322. return;
  323. }
  324. // if (signerId.value) {
  325. // // handleSubmitSign(firstSignItem).then(() => {
  326. // // handleSafetyResponsibilityDeptSaveSign(signerId.value, nextLevel, nextOrder);
  327. // // });
  328. // } else
  329. if (currentLevel === 2 && currentDepartmentKey.value === 'D') {
  330. handleSubmitSign(firstSignItem);
  331. } else if (currentLevel === 3 && currentDepartmentKey.value === 'C') {
  332. handleSubmitSign(firstSignItem);
  333. } else {
  334. // if (isEmptyAttachment) {
  335. // ElMessage.warning('请上传签署材料');
  336. // return;
  337. // }
  338. if (currentDepartmentKey.value === 'C' && currentLevel < 3) {
  339. currentLabel.value = currentLevel === 1 ? '党委书记' : '所长';
  340. }
  341. if (currentDepartmentKey.value === 'D' && currentLevel < 2) {
  342. currentLabel.value = '部门负责人';
  343. }
  344. dialogVisible.value = true;
  345. }
  346. }
  347. // 非C和D的部门类型
  348. else {
  349. if (isEmptyAttachment) {
  350. ElMessage.warning('请上传签署材料');
  351. return;
  352. }
  353. handleSubmitSign(firstSignItem);
  354. }
  355. }
  356. });
  357. };
  358. const handleSafetyResponsibilityDeptSaveSign = (signerId, nextLevel, nextOrder) => {
  359. submiting.value = true;
  360. const params = {
  361. signStatus: 0,
  362. signLevel: nextLevel,
  363. contractId: route.query.id,
  364. signerId,
  365. signOrder: nextOrder,
  366. };
  367. return safetyResponsibilityDeptSaveSign(params)
  368. .then(() => {})
  369. .catch(() => {})
  370. .finally(() => {
  371. submiting.value = false;
  372. });
  373. };
  374. const handleSubmitSign = (firstItem) => {
  375. submiting.value = true;
  376. const params = {
  377. ids: [route.query.id],
  378. attachment: JSON.stringify(firstItem?.attachment),
  379. };
  380. return safetyResponsibilityDeptBatchSign(params)
  381. .then((res) => {
  382. router.push({
  383. name: 'responsibilityAgreeManageDept',
  384. });
  385. ElMessage.success('责任书签署成功');
  386. })
  387. .finally(() => {
  388. submiting.value = false;
  389. });
  390. };
  391. // 下一节点签署人 保存
  392. const handleDialogConfirm = async () => {
  393. const fullAttachment = formData.signRecords.every((item) => item.attachment || item.attachment?.length > 0);
  394. const signList = formData.signRecords.filter((item) => item.signFlag && item.signStatus === 0);
  395. const firstSignItem = signList?.[0] ?? {};
  396. const lastSignItem = signList?.[signList.length - 1] ?? {};
  397. const isEmptyAttachment = !firstSignItem?.attachment || firstSignItem?.attachment?.length === 0;
  398. const currentLevel = lastSignItem?.signLevel;
  399. const currentOrder = lastSignItem?.signOrder;
  400. const nextLevel = Math.min(currentLevel + 1, 3);
  401. const nextOrder = currentOrder + 1;
  402. if (signerId.value) {
  403. const params = {
  404. sign:{
  405. signStatus: 0,
  406. signLevel: nextLevel,
  407. contractId: route.query.id,
  408. signOrder: nextOrder,
  409. },
  410. signerId: signerId.value || null,
  411. ids: [route.query.id],
  412. attachment: JSON.stringify(firstSignItem?.attachment),
  413. };
  414. safetyResponsibilityDeptBatchSign(params).then(()=>{
  415. ElMessage.success('责任书签署成功');
  416. router.push({
  417. name: 'responsibilityAgreeManageDept',
  418. });
  419. }).finally(() => {
  420. submiting.value = false;
  421. });
  422. dialogVisible.value = false;
  423. } else {
  424. ElMessage.warning('请选择签署人');
  425. }
  426. };
  427. const handleDialogCancel = () => {
  428. dialogVisible.value = false;
  429. signerId.value = '';
  430. };
  431. const handleQueryDetail = () => {
  432. safetyResponsibilityDeptQueryDetail({
  433. id: route.query.id,
  434. }).then((res) => {
  435. Object.keys(formData).forEach((name) => {
  436. if (name in res) {
  437. Object.assign(formData, {
  438. [name]: res[name],
  439. attachment: unformatAttachment(res.attachment),
  440. signsUpload: unformatAttachment(res.signsUpload),
  441. feedback: unformatAttachment(res.feedback),
  442. signRecords: res.signRecords?.map((item) => ({
  443. ...item,
  444. attachment: unformatAttachment(item.attachment),
  445. })),
  446. });
  447. }
  448. });
  449. });
  450. };
  451. const remoteMethod = async (value) => {
  452. await getUserData(value);
  453. };
  454. const getUserData = (realname = '') => {
  455. queryAvailableUserList({
  456. pageNumber: 1,
  457. pageSize: 300,
  458. queryParam: { realname },
  459. }).then((res: any) => {
  460. userOptions.value = (res.records || [])?.map((u: any) => ({
  461. value: u.id,
  462. label: u.realname,
  463. }));
  464. });
  465. };
  466. onMounted(async () => {
  467. await getUserData('');
  468. handleQueryDetail();
  469. });
  470. </script>
  471. <style lang="scss" scoped>
  472. @use '@/styles/page-main-layout.scss' as *;
  473. @use '@/styles/page-details-layout.scss' as *;
  474. @use '@/styles/basic-table-action.scss' as *;
  475. h4 {
  476. margin-bottom: 10px;
  477. }
  478. .detail-content {
  479. display: flex;
  480. gap: 30px;
  481. margin: 10px 0;
  482. font-size: 14px;
  483. }
  484. .detail-ct {
  485. display: flex;
  486. flex-direction: column;
  487. border: 1px solid rgb(220, 223, 230);
  488. font-size: 14px;
  489. margin-bottom: 25px;
  490. .row {
  491. display: flex;
  492. border-bottom: 1px solid rgb(220, 223, 230);
  493. }
  494. .row:last-child {
  495. border-bottom: none;
  496. }
  497. .col {
  498. display: flex;
  499. flex: 1;
  500. min-height: 40px;
  501. align-items: stretch;
  502. .label {
  503. display: flex;
  504. align-items: center;
  505. justify-content: flex-end;
  506. width: 160px;
  507. background-color: rgb(245, 247, 250);
  508. border-right: 1px solid rgb(220, 223, 230);
  509. }
  510. .value {
  511. display: flex;
  512. justify-content: space-between;
  513. flex: 1;
  514. padding: 10px 20px;
  515. align-items: center;
  516. border-right: 1px solid rgb(220, 223, 230);
  517. }
  518. .value-s1 {
  519. min-height: 60px;
  520. }
  521. .value:nth-child(2) {
  522. border-right: 0;
  523. }
  524. }
  525. .col:nth-child(2) .label {
  526. border-left: 1px solid rgb(220, 223, 230);
  527. }
  528. }
  529. .table {
  530. display: flex;
  531. align-items: stretch;
  532. border: 1px solid rgb(220, 223, 230);
  533. border-width: 1px 1px 0 1px;
  534. }
  535. .table .value {
  536. display: flex;
  537. align-items: center;
  538. // (:deep).el-form-item {
  539. // margin-bottom: 0;
  540. // }
  541. }
  542. .table .label {
  543. display: flex;
  544. align-items: center;
  545. border-right: 1px solid rgb(220, 223, 230);
  546. background-color: rgb(245, 247, 250);
  547. }
  548. .back{
  549. display: flex;
  550. align-items: center;
  551. gap: 16px;
  552. background-color: white;
  553. padding: 16px 22px;
  554. font-size: 20px;
  555. font-weight: 600;
  556. color: rgba(0, 0, 0, 0.85);
  557. }
  558. // :deep(.breadcrumb .title) {
  559. // margin-left: 0;
  560. // }
  561. // .main {
  562. // display: flex;
  563. // flex-direction: column;
  564. // padding: 20px;
  565. // flex: 1;
  566. // overflow: hidden;
  567. // background-color: #fff;
  568. // }
  569. // .button-content {
  570. // margin-bottom: 20px;
  571. // }
  572. // .page-content {
  573. // display: flex;
  574. // justify-content: flex-end;
  575. // }
  576. // // :deep(.el-form) {
  577. // // flex: 1;
  578. // // overflow: hidden;
  579. // // overflow-y: auto;
  580. // // }
  581. </style>