index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div>
  3. <section class="dingflow-design">
  4. <el-row>
  5. <el-col :span="20" />
  6. <el-col :span="4">
  7. <el-button type="primary" size="small" @click="test">保存(用于测试,还未完成)</el-button>
  8. </el-col>
  9. </el-row>
  10. <div class="box-scale">
  11. <div class="start-event-node">
  12. <div class="start-event-node-circle">开始</div>
  13. </div>
  14. <div class="start-event-node-line"></div>
  15. <nodeWrap v-model:nodeConfig="nodeConfig" :defaultFieldsPermission="defaultFieldsPermission" />
  16. <!-- <div class="end-node">
  17. <div class="end-node-circle"></div>
  18. <div class="end-node-text">流程结束</div>
  19. </div> -->
  20. <div class="end-event">
  21. <div class="end-event-circle">结束</div>
  22. </div>
  23. </div>
  24. </section>
  25. </div>
  26. <approverDrawer/>
  27. <copyerDrawer />
  28. </template>
  29. <script lang="ts" setup>
  30. import nodeWrap from '@/components/SimpleProcessDesigner/src/nodeWrap.vue'
  31. import approverDrawer from '@/components/SimpleProcessDesigner/src/drawer/approverDrawer.vue'
  32. import copyerDrawer from '@/components/SimpleProcessDesigner/src/drawer/copyerDrawer.vue'
  33. import { WorkFlowNode } from '@/components/SimpleProcessDesigner/src/consts'
  34. import { ref } from 'vue'
  35. import { saveBpmSimpleModel, getBpmSimpleModel } from '@/api/bpm/simple'
  36. import { getModel } from '@/api/bpm/model'
  37. import { getForm, FormVO } from '@/api/bpm/form'
  38. defineOptions({ name: 'SimpleWorkflowDesignEditor' })
  39. const uid = getCurrentInstance().uid
  40. const router = useRouter() // 路由
  41. const { query } = useRoute() // 路由的查询
  42. const modelId = query.modelId
  43. const message = useMessage() // 国际化
  44. const nodeConfig = ref<WorkFlowNode>({
  45. name: '发起人',
  46. type: 0,
  47. id: 'StartEvent_' + uid,
  48. childNode: undefined,
  49. attributes: undefined,
  50. conditionNodes: []
  51. })
  52. // 默认的表单字段权限
  53. const defaultFieldsPermission: any[] = []
  54. const test = async () => {
  55. if (!modelId) {
  56. message.error('缺少模型 modelId 编号')
  57. return
  58. }
  59. const test = nodeConfig.value
  60. console.log('test is ', test)
  61. console.log('nodeConfig.value ', nodeConfig.value)
  62. const data1 = {
  63. modelId: modelId,
  64. simpleModelBody: toRaw(nodeConfig.value)
  65. }
  66. const data = {
  67. modelId: modelId,
  68. simpleModelBody: nodeConfig.value
  69. }
  70. console.log('request json data1 is ', data1)
  71. const result = await saveBpmSimpleModel(data)
  72. console.log('save the result is ', result)
  73. if (result) {
  74. message.success('修改成功')
  75. close()
  76. } else {
  77. message.alert('修改失败')
  78. }
  79. }
  80. const close = () => {
  81. router.push({ path: '/bpm/manager/model' })
  82. }
  83. onMounted(async () => {
  84. const bpmnModel = await getModel(modelId)
  85. if (bpmnModel) {
  86. const formType = bpmnModel.formType
  87. if (formType === 10) {
  88. const bpmnForm = await getForm(bpmnModel.formId) as unknown as FormVO
  89. const formFields = bpmnForm?.fields
  90. if (formFields) {
  91. formFields.forEach((fieldStr: string) => {
  92. const { field, title } = JSON.parse(fieldStr)
  93. defaultFieldsPermission.push({
  94. field,
  95. title,
  96. permission: '2'
  97. })
  98. })
  99. }
  100. console.log('defaultFieldsPermissions', defaultFieldsPermission);
  101. }
  102. }
  103. console.log('the modelId is ', modelId)
  104. const result = await getBpmSimpleModel(modelId)
  105. if (result) {
  106. console.log('get the result is ', result)
  107. nodeConfig.value = result
  108. }
  109. })
  110. </script>
  111. <style>
  112. @import url('@/components/SimpleProcessDesigner/theme/workflow.css');
  113. .end-event {
  114. display: flex;
  115. direction: columns;
  116. justify-content: center;
  117. align-items: center;
  118. }
  119. .end-event-circle {
  120. display: flex;
  121. width: 40px;
  122. height: 40px;
  123. font-size: 14px;
  124. color: #f8f8fa;
  125. background-image: linear-gradient(-30deg, #bbbbc4, #d5d5de), linear-gradient(#bcbcc5, #bcbcc5);
  126. border-radius: 50%;
  127. justify-content: center;
  128. align-items: center;
  129. }
  130. /* .start-event-node {
  131. color: #191f2566;
  132. text-align: left;
  133. border-radius: 50%;
  134. } */
  135. .start-event-node {
  136. display: flex;
  137. direction: columns;
  138. justify-content: center;
  139. align-items: center;
  140. }
  141. .start-event-node-circle {
  142. display: flex;
  143. width: 40px;
  144. height: 40px;
  145. align-items: center;
  146. justify-content: center;
  147. font-size: 14px;
  148. color: #f8f8fa;
  149. background-image: linear-gradient(90deg, #ff6a00, #f78b3e), linear-gradient(#ff6a00, #ff6a00);
  150. border-radius: 50%;
  151. }
  152. .start-event-node-line::before {
  153. position: absolute;
  154. inset: 0;
  155. z-index: -1;
  156. width: 2px;
  157. height: 100%;
  158. margin: auto;
  159. background-color: #cacaca;
  160. content: '';
  161. }
  162. .start-event-node-line {
  163. position: relative;
  164. padding: 20px 0 32px;
  165. }
  166. </style>