cpm-check-plan-form.vue 2.8 KB

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