cpm-confirm-detail-form.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <audit-form-top-banner
  3. :handel-save-form="saveForm"
  4. :form-data="readOnly ? 'VIEW' : ''"
  5. @handelSaveForm="saveForm"
  6. >
  7. <sd-detail-form
  8. ref="docform"
  9. :page-id="this.$route.query.pageId ? this.$route.query.pageId : null"
  10. :record-id="this.id ? this.id : null"
  11. :read-only="readOnly"
  12. :class="[$style.form]"
  13. @close="close(true)"
  14. @saved="saved"
  15. >
  16. <template v-slot="{ formData, model, fields }">
  17. <table :class="$style.detailForm">
  18. <tr>
  19. <td colspan="4" style="border:none">
  20. <sd-form-by-builder
  21. v-show="showflag"
  22. :form-data="formData.pageFormData"
  23. ></sd-form-by-builder>
  24. </td>
  25. </tr>
  26. </table>
  27. </template>
  28. </sd-detail-form>
  29. </audit-form-top-banner>
  30. </template>
  31. <script>
  32. import { message } from '@/common/one-ui'
  33. import auditFormTopBanner from '@product/iam/components/audit-form-top-banner'
  34. import CpmService from '../../cpm-service'
  35. import components from './_import-components/cpm-confirm-detail-form-import'
  36. export default {
  37. name: 'CpmConfirmDetailForm',
  38. metaInfo: {
  39. title: '问题清单确认',
  40. },
  41. components: {
  42. ...components,
  43. auditFormTopBanner,
  44. },
  45. data() {
  46. return {
  47. initialled: false,
  48. id: this.$route.query.id ? this.$route.query.id : '',
  49. flag: true,
  50. readOnly: false,
  51. showflag: false,
  52. }
  53. },
  54. mounted() {
  55. if (this.$route.query.projectId) {
  56. const ep = this.$route.query.projectId
  57. const groupId = this.$route.query.groupId
  58. setTimeout(() => {
  59. if (groupId !== '1') {
  60. this.initData(groupId, true, false)
  61. } else {
  62. this.initData(ep, true, true)
  63. }
  64. }, 2000)
  65. } else {
  66. setTimeout(() => {
  67. const projectId = this.$refs.docform.getFieldValue('PROJECT_ID')
  68. const subprojectId = this.$refs.docform.getFieldValue('SUB_PROJECT_ID')
  69. if (subprojectId !== null && subprojectId !== '1') {
  70. this.initData(subprojectId, false, false)
  71. } else {
  72. this.initData(projectId, false, true)
  73. }
  74. }, 2000)
  75. }
  76. this.setReadOnly()
  77. },
  78. methods: {
  79. saved(t) {
  80. const idobj = t.pageFormData.pageFieldInfos.find((i) => i.name === 'id').value
  81. this.id = idobj
  82. const id = this.$route.params.id ? this.$route.params.id : this.$route.query.id
  83. if (id === null || id === undefined || id === '') {
  84. let path = this.$route.fullPath
  85. path = path.replace('?id=&pageId', '?id=' + this.id + '&pageId')
  86. window.location.href = '#' + path
  87. }
  88. message.success({ content: '保存成功!' }, 1).then(() => {})
  89. },
  90. // 保存
  91. saveForm() {
  92. this.$refs.docform.saveBtnClick()
  93. },
  94. close(flag) {
  95. window.close()
  96. },
  97. // 初始化项目信息
  98. initData(projectId, flag, flagz) {
  99. const org = []
  100. if (projectId) {
  101. // 获取项目信息
  102. CpmService.getProjectData(projectId, flagz).then((res) => {
  103. const id = this.$refs.docform.getFieldValue('id')
  104. if (!id) {
  105. const configCode = this.$refs.docform.getFieldValue('currentNumber')
  106. this.$refs.docform.setFieldValue('FIND_CODE', res.data[0].currentNumber + configCode)
  107. }
  108. const title = res.data[0].title
  109. if (flag) this.$refs.docform.setFieldValue('PROJECT_NAME', title)
  110. if (flag) this.$refs.docform.setFieldValue('PROJECT_ID', this.$route.query.projectId)
  111. if (flag) this.$refs.docform.setFieldValue('SUB_PROJECT_ID', this.$route.query.groupId)
  112. const checkdeptnames = res.data[0].checkedDeptNames
  113. let checkdeptcodes = []
  114. if (res.data[0].checkedDeptCodes) {
  115. checkdeptcodes = res.data[0].checkedDeptCodes
  116. } else {
  117. checkdeptcodes = res.data[0].checkedDeptIds
  118. }
  119. const names = checkdeptnames.split(',')
  120. const codes = checkdeptcodes.split(',')
  121. const orgfw = []
  122. names.forEach((n, index) => {
  123. orgfw.push({
  124. type: 'Group',
  125. name: n,
  126. code: codes[index],
  127. })
  128. })
  129. this.$refs.docform.setFieldValue('CHECKED_DEPT_FW', orgfw)
  130. if (flag) {
  131. if (names.length > 1) {
  132. this.$refs.docform.setFieldValue('CHECKED_DEPT', org)
  133. } else {
  134. names.forEach((n, index) => {
  135. org.push({
  136. type: 'GROUP',
  137. name: n,
  138. code: codes[index],
  139. })
  140. })
  141. this.$refs.docform.setFieldValue('CHECKED_DEPT', org)
  142. }
  143. }
  144. })
  145. }
  146. this.showflag = true
  147. },
  148. setReadOnly() {
  149. const ini = setInterval(() => {
  150. if (
  151. this.$refs.docform &&
  152. (this.$refs.docform.$refs.form || this.$refs.docform.$refs.sdForm)
  153. ) {
  154. clearInterval(ini)
  155. // 工作底稿生成单据不可编辑
  156. const findfrom = this.$refs.docform.getFieldValue('FIND_FROM') // 问题来源
  157. if (findfrom === '2' || findfrom === '1') {
  158. this.readOnly = true
  159. }
  160. }
  161. }, 100)
  162. },
  163. },
  164. }
  165. </script>
  166. <style module lang="scss">
  167. @use '@/common/design' as *;
  168. @import '@/webflow/sd-flow-form.scss';
  169. .detailForm {
  170. width: 100% !important;
  171. margin: 0px;
  172. :global(.sd-form-table) {
  173. width: 100% !important;
  174. }
  175. }
  176. </style>