sign-agree-dept.vue 19 KB

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