audit-notice-form.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div>
  3. <sd-webflow
  4. ref="flow"
  5. :removed-tabs="['sdRelatedDoc']"
  6. :validate-form="validForm"
  7. @saveproject="saveproject"
  8. >
  9. <template v-slot:form="{ model, fields, FlowData }">
  10. <table>
  11. <tr v-if="model.flowState === '结束'">
  12. <sd-form-item-td name="fileTitle" />
  13. <sd-form-item-td name="fileCode" />
  14. </tr>
  15. <tr v-else>
  16. <!-- 文件标题 -->
  17. <!-- <td v-if="savecontent()" class="ant-form-item-label">
  18. <label class="ant-form-item-required">文件标题</label>
  19. </td>
  20. <td>
  21. <span> {{ model.fileTitle }}</span>
  22. </td> -->
  23. <sd-form-item-td v-if="savecontent()" name="fileTitle" />
  24. <!-- 文件编号 -->
  25. <sd-form-item-td name="fileCode">
  26. <template v-slot:read-and-edit="{ editable }">
  27. <a-input
  28. v-if="editable"
  29. v-model="model.fileCode"
  30. placeholder="自动生成"
  31. read-only
  32. ></a-input>
  33. <span v-else>{{ model.fileCode }}</span>
  34. </template>
  35. </sd-form-item-td>
  36. </tr>
  37. <tr>
  38. <!-- 被审计单位 -->
  39. <sd-form-item-td name="auditedUnitMember"> </sd-form-item-td>
  40. <!-- 文书编号 -->
  41. <sd-form-item-td name="docNum" />
  42. <sd-form-item-td name="projectId" :hidden="true" />
  43. </tr>
  44. <tr>
  45. <!-- 说明 -->
  46. <sd-form-item-td name="noticeExplain" :colspan="3">
  47. <a-textarea v-model="model.noticeExplain" :rows="3" />
  48. </sd-form-item-td>
  49. </tr>
  50. <tr>
  51. <!-- 审计通知书 -->
  52. <sd-form-item-td name="noticeId" :colspan="3">
  53. <template v-slot:read-and-edit="{ editable }">
  54. <sd-attachment-ex
  55. :key="noticeAttachmentKey"
  56. ref="noticeAttachment"
  57. v-model="model.noticeId"
  58. :group-id="JSON.parse(fields.noticeId.value).value"
  59. :read-only="!editable"
  60. :uploadable="false"
  61. :temtype="temtype"
  62. :temdataurl="temdataurl"
  63. :is-open-file="false"
  64. :clean-copy="FlowData.attrs && FlowData.attrs['we-doc$cleanCopy']"
  65. :custom-select-template-fun="selectTemplate"
  66. />
  67. </template>
  68. </sd-form-item-td>
  69. </tr>
  70. <!-- <tr v-if="false">
  71. <sd-form-item-td name="isEmail" />
  72. <sd-form-item-td v-if="model.isEmail !== '1'" name="emailAddr" />
  73. <td v-if="model.isEmail === '1'" class="ant-form-item-label">
  74. <label class="ant-form-item-required">邮件通知地址</label>
  75. </td>
  76. <td v-if="model.isEmail === '1'">
  77. <a-form-model-item
  78. :rules="[
  79. {
  80. required: true,
  81. trigger: ['change', 'blur'],
  82. },
  83. ]"
  84. prop="emailAddr"
  85. name="emailAddr"
  86. >
  87. <a-input v-model.trim="model.emailAddr" />
  88. </a-form-model-item>
  89. </td>
  90. </tr> -->
  91. <tr v-if="false">
  92. <!-- 邮件通知 -->
  93. <sd-form-item-td name="isEmail" />
  94. <!-- 邮件通知地址 -->
  95. <sd-form-item-td name="emailAddr" />
  96. </tr>
  97. <tr>
  98. <!-- 附件 -->
  99. <sd-form-item-td v-if="initparams(model)" name="attachment" :colspan="3" />
  100. </tr>
  101. <tr>
  102. <!-- 编制人员 -->
  103. <sd-form-item-td name="creatorName" />
  104. <!-- 编制日期 -->
  105. <sd-form-item-td name="creationTime" />
  106. </tr>
  107. </table>
  108. </template>
  109. </sd-webflow>
  110. <a-modal
  111. :visible="visible"
  112. destroy-on-close
  113. width="800px"
  114. title="选择模板"
  115. @cancel="hiddenModal"
  116. @ok="autoTaoDaFile"
  117. >
  118. <iam-audit-notice-template-select
  119. ref="templateSelect"
  120. :project-id="projectId + ''"
  121. :template-list="templateList"
  122. ></iam-audit-notice-template-select>
  123. </a-modal>
  124. </div>
  125. </template>
  126. <script>
  127. import loginService from '@/login/login-service'
  128. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  129. import moment from 'moment'
  130. import { Message } from 'ant-design-vue'
  131. import axios from '@/common/services/axios-instance'
  132. import iamAuditNoticeTemplateSelect from './iam-audit-notice-template-select.vue'
  133. import components from './_import-components/audit-notice-form-import'
  134. export default {
  135. name: 'AuditNoticeForm',
  136. metaInfo: {
  137. title: '审计通知书',
  138. },
  139. components: {
  140. iamAuditNoticeTemplateSelect,
  141. ...components,
  142. },
  143. data() {
  144. return {
  145. temtype: '03',
  146. // projectId: this.$route.query.projectId ? this.$route.query.projectId : null,
  147. projectId: '',
  148. temdataurl: '',
  149. auditedUnitMember: [],
  150. fileTitle: '',
  151. flag: true,
  152. visible: false,
  153. noticeAttachmentKey: 0,
  154. templateList: [],
  155. projectInfo: null, // 项目信息
  156. // mode: null,
  157. // recodeId: this.$route.query.record ? parseInt(this.$route.query.record) : null,
  158. }
  159. },
  160. created() {
  161. // 获取模板列表
  162. // if (this.$route.query.projectId) {
  163. // this.projectId = this.$route.query.projectId
  164. // 获取模板列表
  165. if (this.$route.query.extParams) {
  166. this.projectId = JSON.parse(this.$route.query.extParams).projectId
  167. const ini = setInterval(() => {
  168. if (this.$refs.flow) {
  169. this.$refs.flow.setFieldValue('projectId', this.projectId)
  170. clearInterval(ini)
  171. }
  172. })
  173. } else {
  174. return
  175. }
  176. this.temdataurl =
  177. `api/xcoa-mobile/v1/iamtemplate/findTemplate?projectId=` +
  178. this.projectId +
  179. `&templateType=` +
  180. this.temtype
  181. // 获取模板列表
  182. axios.get(this.temdataurl).then((res) => {
  183. this.templateList = res.data
  184. })
  185. // 获取项目信息
  186. axios({
  187. url: 'api/xcoa-mobile/v1/page/wp/audit/project/iamAuditProject?id=' + this.projectId,
  188. method: 'get',
  189. }).then((res) => {
  190. this.projectInfo = res.data.pageFormData.pageFieldInfos
  191. })
  192. },
  193. methods: {
  194. // 页面加载完成后
  195. // sdFormReady() {
  196. // this.mode = this.$refs.flow.formData.pageFormData.pageFieldInfos.find(
  197. // (item) => item.name === 'noticeExplain'
  198. // ).readonly
  199. // ? 'VIEW'
  200. // : 'EDIT'
  201. // },
  202. // // 保存
  203. // saveForm() {
  204. // this.$refs.flow.saveBtnClick()
  205. // },
  206. // saved() {
  207. // Message.success('保存成功', 1).then((res) => {
  208. // this.close(true)
  209. // })
  210. // },
  211. // close(flag) {
  212. // crossWindowWatcher.notifyChange(this.$route.fullPath, flag)
  213. // window.close()
  214. // },
  215. getTemplate() {
  216. // 获取模板列表
  217. // if (this.$route.query.projectId) {
  218. // this.projectId = this.$route.query.projectId
  219. if (this.$route.query.extParams) {
  220. this.projectId = JSON.parse(this.$route.query.extParams).projectId
  221. this.$refs.flow.setFieldValue('projectId', this.projectId)
  222. } else {
  223. this.projectId = this.$refs.flow.getFieldValue('projectId')
  224. }
  225. this.temdataurl =
  226. `api/xcoa-mobile/v1/iamtemplate/findTemplate?projectId=` +
  227. this.projectId +
  228. `&templateType=` +
  229. this.temtype
  230. // 获取模板列表
  231. axios.get(this.temdataurl).then((res) => {
  232. this.templateList = res.data
  233. })
  234. // 获取项目信息
  235. axios({
  236. url: 'api/xcoa-mobile/v1/page/wp/audit/project/iamAuditProject?id=' + this.projectId,
  237. method: 'get',
  238. }).then((res) => {
  239. this.projectInfo = res.data.pageFormData.pageFieldInfos
  240. })
  241. return true
  242. },
  243. savecontent() {
  244. if (this.fileTitle !== '') {
  245. this.$refs.flow.setFieldValue('fileTitle', this.fileTitle)
  246. }
  247. return true
  248. },
  249. validForm() {
  250. // 自定义校验,适用于多个字段联合校验,支持promise
  251. this.$refs.flow.setFieldValue('fileTitle', this.fileTitle)
  252. return Promise.resolve(true)
  253. },
  254. initparams(model) {
  255. if (this.flag) {
  256. this.setAuditUnit(model)
  257. this.setFileTitle(model)
  258. this.flag = false
  259. }
  260. return true
  261. },
  262. // 获取被审计单位
  263. setAuditUnit(model) {
  264. const params = {
  265. projectId: this.projectId,
  266. }
  267. const auditedUnitMember = model.auditedUnitMember
  268. if (
  269. auditedUnitMember === null ||
  270. auditedUnitMember === '' ||
  271. auditedUnitMember === undefined
  272. ) {
  273. if (this.projectId) {
  274. axios({
  275. url: 'api/xcoa-mobile/v1/iamauditnotice/findAuditUnit',
  276. method: 'post',
  277. params,
  278. }).then((res) => {
  279. model.auditedUnitMember = res.data
  280. })
  281. }
  282. }
  283. },
  284. // 获取文件标题 “项目名称”+“审计通知书”
  285. setFileTitle(model) {
  286. const params = {
  287. projectId: this.projectId,
  288. }
  289. const fileTitle = model.fileTitle
  290. if (fileTitle === null || fileTitle === '' || fileTitle === undefined) {
  291. if (this.projectId) {
  292. axios({
  293. url: 'api/xcoa-mobile/v1/iamauditnotice/findFileTitle',
  294. method: 'post',
  295. params,
  296. }).then((res) => {
  297. this.fileTitle = res.data
  298. })
  299. }
  300. } else {
  301. this.fileTitle = model.fileTitle
  302. }
  303. },
  304. saveproject(formdata) {
  305. const selectedKeys = formdata.processFormData.processFormPropertyValues
  306. selectedKeys.forEach((item) => {
  307. if (item.name === 'fileCode') {
  308. this.$refs.flow.setFieldValue('fileCode', item.value)
  309. }
  310. })
  311. },
  312. // 展示选择模板窗口
  313. selectTemplate() {
  314. // 获取模板列表
  315. // if (this.$route.query.projectId) {
  316. // this.projectId = this.$route.query.projectId
  317. if (this.$route.query.extParams) {
  318. this.projectId = JSON.parse(this.$route.query.extParams).projectId
  319. } else {
  320. this.projectId = this.$refs.flow.getFieldValue('projectId')
  321. }
  322. // 获取项目信息
  323. axios({
  324. url: 'api/xcoa-mobile/v1/page/wp/audit/project/iamAuditProject?id=' + this.projectId,
  325. method: 'get',
  326. }).then((res) => {
  327. this.projectInfo = res.data.pageFormData.pageFieldInfos
  328. })
  329. // 获取模板列表
  330. this.temdataurl =
  331. `api/xcoa-mobile/v1/iamtemplate/findTemplate?projectId=` +
  332. this.projectId +
  333. `&templateType=` +
  334. this.temtype
  335. axios.get(this.temdataurl).then((res) => {
  336. this.templateList = res.data
  337. this.visible = true
  338. })
  339. },
  340. // 隐藏选择模板窗口
  341. hiddenModal() {
  342. this.$refs.noticeAttachment.copyLoading = false
  343. this.visible = false
  344. },
  345. // 自动套打文档内容
  346. autoTaoDaFile() {
  347. debugger
  348. let tmpName = null
  349. const selectTmp = this.$refs.templateSelect.checkedTemp
  350. if (!selectTmp.id) {
  351. Message.info('请选择模板', 1)
  352. } else {
  353. // 设置加载中状态
  354. this.$refs.templateSelect.spinning = true
  355. axios
  356. .get(`api/xcoa-mobile/v1/attachment-extend/attachments-info-perm/${selectTmp.attachment}`)
  357. .then((res) => {
  358. tmpName = res.data[0].name
  359. axios
  360. .post(
  361. `api/xcoa-mobile/v1/attachment-extend/attachment-copy/${res.data[0].code}/${this.$refs.noticeAttachment.groupId}?catNum=-1&fromTemplate=1`
  362. )
  363. .then((res) => {
  364. // 执行套打
  365. this.taodafile(tmpName)
  366. })
  367. })
  368. }
  369. },
  370. taodafile(fileName) {
  371. debugger
  372. const indiDocX = this.$refs.noticeAttachment
  373. // 计算套打内容
  374. const auditedUnit = this.$refs.flow.getFieldValue('auditedUnitMember')
  375. let auditedText = ''
  376. auditedUnit.forEach((item) => {
  377. auditedText += item.name
  378. })
  379. // 项目名称
  380. // const projectTitle = this.projectInfo.find((item) => {
  381. // return item.name === 'projectTitle'
  382. // })
  383. // 找到组长及组员
  384. const userListJson = this.projectInfo.find((item) => {
  385. return item.name === 'iamProjectUserList'
  386. })
  387. const zzuser = []
  388. const fzzuser = []
  389. const zyuser = ['']
  390. const userList = JSON.parse(userListJson.value)
  391. userList.forEach((item) => {
  392. // 组长
  393. if (item.userType === '05') {
  394. zzuser.push(item.userName)
  395. }
  396. // 副组长
  397. if (item.userType === '01') {
  398. fzzuser.push(item.userName)
  399. }
  400. // 主审
  401. if (item.userType === '02') {
  402. zyuser.splice(0, 1, item.userName)
  403. }
  404. // 成员
  405. if (item.userType === '03') {
  406. zyuser.push(item.userName)
  407. }
  408. })
  409. // 审计机关
  410. const auditUnit = this.projectInfo.find((item) => {
  411. return item.name === 'unitName'
  412. })
  413. // 被审计人员
  414. const auditedUser = this.projectInfo.find((item) => {
  415. return item.name === 'auditedUser'
  416. })
  417. // 计划年度
  418. const planYear = this.projectInfo.find((item) => {
  419. return item.name === 'planYear'
  420. })
  421. // 审计期间开始
  422. const auditperiodStart = this.projectInfo.find((item) => {
  423. return item.name === 'auditperiodStart'
  424. })
  425. // 审计期间结束
  426. const auditperiodEnd = this.projectInfo.find((item) => {
  427. return item.name === 'auditperiodEnd'
  428. })
  429. console.log('---更新完')
  430. // 更新完附件列表之后,才自动套打
  431. indiDocX.getFileList().then((res) => {
  432. var userFile = indiDocX.slCtl.Content.Control.getFileByName(fileName)
  433. // userFile.code = userFile.Unid
  434. loginService.updateRefreshToken().then(() => {
  435. indiDocX.markBusy(fileName)
  436. indiDocX.updateActivedAtt?.(userFile.code, true)
  437. indiDocX.slCtl.Content.Control.UpdateRegion(
  438. fileName,
  439. {
  440. 审计期间开始: moment(auditperiodStart.value).format('YYYY年MM月DD日'),
  441. 审计期间开始1: moment(auditperiodStart.value).format('YYYY年MM月DD日'),
  442. 审计期间结束: moment(auditperiodEnd.value).format('YYYY年MM月DD日'),
  443. 被审计单位: auditedText,
  444. 被审计单位1: auditedText,
  445. 计划年度: planYear.value,
  446. 被审计人员: auditedUser.value,
  447. 被审计人员1: auditedUser.value,
  448. 被审计人员2: auditedUser.value,
  449. 审计组长: zzuser.join(','),
  450. 审计副组长: fzzuser.join(','),
  451. 审计组员: zyuser.join(','),
  452. 编制日期: moment().format('YYYY年MM月DD日'),
  453. },
  454. '',
  455. {
  456. IsMaximization: 'false',
  457. Status: '-1',
  458. WaterMark: indiDocX.waterMark(userFile, 'UpdateRegion'),
  459. },
  460. indiDocX.pluginInfo()
  461. )
  462. ?.finally(() => {
  463. indiDocX.updateActivedAtt?.(userFile.code, false)
  464. this.hiddenModal()
  465. setTimeout(() => {
  466. indiDocX.getFileList()
  467. }, 0)
  468. indiDocX.markBusy(fileName, false)
  469. })
  470. .catch(() => {
  471. indiDocX.markBusy(userFile, false)
  472. })
  473. })
  474. })
  475. },
  476. },
  477. }
  478. </script>
  479. <style module lang="scss">
  480. @use '@/common/design' as *;
  481. // @import '@/webflow/sd-flow-form.scss';
  482. // .first-tr {
  483. // td {
  484. // background: #fff !important;
  485. // border: none !important;
  486. // }
  487. // }
  488. // .lawapply {
  489. // :global(.buttons_sd-attachment-ex_common > .ant-btn-primary) {
  490. // display: none;
  491. // }
  492. // }
  493. </style>