cpm-check-notice-form.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <sd-webflow ref="webflow">
  3. <template v-slot:form="{ model, FlowData }">
  4. <sd-form-by-builder
  5. ref="builderform"
  6. :form-data="FlowData.processFormData"
  7. @changedClick="changebj"
  8. />
  9. </template>
  10. </sd-webflow>
  11. </template>
  12. <script>
  13. import CpmService from '../../cpm-service'
  14. import components from './_import-components/cpm-check-notice-form-import'
  15. export default {
  16. name: 'CpmCheckNoticeForm',
  17. metaInfo: {
  18. title: 'CpmCheckNoticeForm',
  19. },
  20. components,
  21. data() {
  22. return {
  23. projectId: '',
  24. flag: true,
  25. }
  26. },
  27. mounted() {
  28. if (this.$route.query.extParams) {
  29. const ep = JSON.parse(this.$route.query.extParams)
  30. if (ep.SUB_PROJECT_ID !== '1') {
  31. this.initData(ep.SUB_PROJECT_ID, true, false)
  32. } else {
  33. this.initData(ep.PROJECT_ID, true, true)
  34. }
  35. } else {
  36. setTimeout(() => {
  37. const projectId = this.$refs.webflow.getFieldValue('PROJECT_ID')
  38. const subprojectId = this.$refs.webflow.getFieldValue('SUB_PROJECT_ID')
  39. if (subprojectId !== null && subprojectId !== '1') {
  40. this.initData(subprojectId, false, false)
  41. } else {
  42. this.initData(projectId, false, true)
  43. }
  44. }, 2000)
  45. }
  46. },
  47. methods: {
  48. // 初始化项目信息
  49. initData(projectId, flag, flagz) {
  50. const org = []
  51. if (projectId) {
  52. // 获取项目信息
  53. CpmService.getProjectData(projectId, flagz).then((res) => {
  54. const checkdeptnames = res.data[0].checkedDeptNames
  55. let checkdeptcodes = []
  56. if (res.data[0].checkedDeptCodes) {
  57. checkdeptcodes = res.data[0].checkedDeptCodes
  58. } else {
  59. checkdeptcodes = res.data[0].checkedDeptIds
  60. }
  61. const title = res.data[0].title
  62. const code = res.data[0].currentNumber
  63. const names = checkdeptnames.split(',')
  64. const codes = checkdeptcodes.split(',')
  65. if (flag) this.$refs.webflow.setFieldValue('PROJECT_NAME', title)
  66. if (flag) this.$refs.webflow.setFieldValue('CPM_PROJECT_CODE', code)
  67. const orgfw = []
  68. names.forEach((n, index) => {
  69. orgfw.push({
  70. type: 'Group',
  71. name: n,
  72. code: codes[index],
  73. })
  74. })
  75. this.$refs.webflow.setFieldValue('CHECKED_DEPT_FW', orgfw)
  76. if (flag) {
  77. if (names.length > 1) {
  78. this.$refs.webflow.setFieldValue('CHECKED_DEPT', org)
  79. } else {
  80. names.forEach((n, index) => {
  81. org.push({
  82. type: 'Group',
  83. name: n,
  84. code: codes[index],
  85. })
  86. })
  87. this.$refs.webflow.setFieldValue('CHECKED_DEPT', org)
  88. }
  89. }
  90. })
  91. }
  92. },
  93. changebj() {
  94. console.log('---change')
  95. },
  96. },
  97. }
  98. </script>
  99. <style module lang="scss">
  100. @use '@/common/design' as *;
  101. </style>