km-flow-guide.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div :class="$style.example">
  3. <a-spin tip="正在加载......" size="large" :spinning="spinning" />
  4. </div>
  5. </template>
  6. <script>
  7. import { Message, Modal } from 'ant-design-vue'
  8. import ManageConfigService from '@/guide/manage-config-service'
  9. import flowService from '@/webflow/flow-service'
  10. import PageService from '@/common/services/page-service'
  11. import components from './_import-components/km-flow-guide-import'
  12. export default {
  13. name: 'KmFlowGuide',
  14. metaInfo: {
  15. title: '业务类型选择',
  16. },
  17. components,
  18. props: {
  19. typeCode: {
  20. type: String,
  21. default: '',
  22. },
  23. },
  24. data() {
  25. return { spinning: true }
  26. },
  27. watch: {
  28. $route() {
  29. this.getFlowId()
  30. },
  31. },
  32. created() {
  33. this.getFlowId()
  34. },
  35. methods: {
  36. getFlowId() {
  37. // 有code优先用code,没有的话再看是不是知识库传了业务类型id
  38. if (this.$route.query.code) {
  39. const urlCode = this.$route.query.code
  40. this.getTypeByCode(urlCode)
  41. } else {
  42. // 为了不和后面实际获取到的业务类型id搞混,知识新建时的叫businessId
  43. const urlbusinessId = this.$route.query.businessId
  44. this.getTypeByBusinessId(urlbusinessId)
  45. }
  46. },
  47. // 定制这个方法主要是为了把km-flow-guide后面所有的参数都传到新建页面
  48. getTypeByCode(urlCode) {
  49. const params = {
  50. categoryCode: urlCode, // 链接取code区分不同业务类型数据
  51. }
  52. ManageConfigService.getTypeList(params)
  53. .then((res) => {
  54. if (res.status === 200) {
  55. this.typeData = res.data
  56. if (this.typeData.length === 1) {
  57. this.flowId = this.typeData[0].businessFlowId
  58. if (this.flowId) {
  59. const businessTypeObj = {
  60. businessTypeId: this.typeData[0].id,
  61. businessTypeName: this.typeData[0].businessTypeName,
  62. }
  63. Object.assign(businessTypeObj, this.$route.query)
  64. flowService.startProcess(this.flowId, businessTypeObj, {
  65. newWindow: false,
  66. })
  67. }
  68. } else {
  69. this.spinning = false
  70. // 弹出业务类型
  71. ManageConfigService.selectYwlx({ typeCode: urlCode, callback: true }).then((data) => {
  72. if (data) {
  73. const businessTypeObj = {
  74. businessTypeId: data.id,
  75. businessTypeName: data.businessTypeName,
  76. }
  77. Object.assign(businessTypeObj, this.$route.query)
  78. flowService.startProcess(data.businessFlowId, businessTypeObj, {
  79. newWindow: false,
  80. })
  81. }
  82. })
  83. }
  84. } else {
  85. Message.error(res.statusText)
  86. }
  87. })
  88. .catch((error) => {
  89. /* eslint-disable-next-line */
  90. console.log(error)
  91. })
  92. },
  93. // 暂时只考虑一个知识分类对应一个业务类型/流程,多个的以后再考虑
  94. getTypeByBusinessId(businessId) {
  95. const params = { id: businessId }
  96. PageService.get(params, 'base/businesstype/oaBaseBusinessType')
  97. .then((res) => {
  98. if (res.status === 200) {
  99. const status = res.data.pageFormData.pageFieldInfos.find((item) => {
  100. return item.name === 'status'
  101. })
  102. if (status.value === '1') {
  103. const businessTypeName = res.data.pageFormData.pageFieldInfos.find((item) => {
  104. return item.name === 'businessTypeName'
  105. })
  106. const businessTypeId = res.data.pageFormData.pageFieldInfos.find((item) => {
  107. return item.name === 'id'
  108. })
  109. const flowField = res.data.pageFormData.pageFieldInfos.find((item) => {
  110. return item.name === 'flowField'
  111. })
  112. const businessTypeObj = {
  113. businessTypeId: businessTypeId.value,
  114. businessTypeName: businessTypeName.value,
  115. }
  116. Object.assign(businessTypeObj, this.$route.query)
  117. flowService.startProcess(JSON.parse(flowField.value)[0].id, businessTypeObj, {
  118. newWindow: false,
  119. })
  120. } else {
  121. Modal.warning({
  122. title: '新建失败',
  123. content: '当前分类审批流程使用的业务类型已停用,请联系管理员。',
  124. onOk() {
  125. window.close()
  126. },
  127. })
  128. }
  129. } else {
  130. Message.error(res.statusText)
  131. }
  132. })
  133. .catch((error) => {
  134. /* eslint-disable-next-line */
  135. console.log(error)
  136. })
  137. },
  138. },
  139. }
  140. </script>
  141. <style module lang="scss">
  142. @use '@/common/design' as *;
  143. .example {
  144. position: relative;
  145. height: 100%;
  146. :global .ant-spin {
  147. position: absolute;
  148. top: 50%;
  149. left: 0;
  150. width: 100%;
  151. margin-top: -25px;
  152. .ant-spin-text {
  153. /* stylelint-disable-next-line */
  154. color: #000;
  155. }
  156. }
  157. }
  158. </style>