index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div>
  3. <a-dialog :title="title" v-model="drawer" @close="handleClose" :footer="false">
  4. <component
  5. :is="componentType"
  6. v-model="form"
  7. :disabled="disabled"
  8. :skipConditionShow="skipConditionShow"
  9. >
  10. <template v-slot:[key]="data" v-for="(item, key) in $slots">
  11. <slot :name="key" v-bind="data || {}"></slot>
  12. </template>
  13. </component>
  14. </a-dialog>
  15. </div>
  16. </template>
  17. <script setup lang="ts">
  18. import start from './start.vue'
  19. import between from './between.vue'
  20. import serial from './serial.vue'
  21. import parallel from './parallel.vue'
  22. import end from './end.vue'
  23. import skip from './skip.vue'
  24. const COMPONENT_LIST = {
  25. start,
  26. between,
  27. serial,
  28. parallel,
  29. end,
  30. skip
  31. }
  32. const props = defineProps({
  33. value: {
  34. type: Object,
  35. default() {
  36. return {}
  37. }
  38. },
  39. node: {
  40. type: Object,
  41. default() {
  42. return {}
  43. }
  44. },
  45. lf: {
  46. type: Object,
  47. default() {
  48. return null
  49. }
  50. },
  51. disabled: {
  52. // 是否禁止
  53. type: Boolean,
  54. default: false
  55. },
  56. skipConditionShow: {
  57. // 是否显示跳转条件
  58. type: Boolean,
  59. default: true
  60. }
  61. })
  62. const drawer = ref(false)
  63. const form = ref({})
  64. const objId = ref(undefined)
  65. const nodeCode = ref(null)
  66. const title = computed(() => {
  67. if (props.node && props.node.type === 'skip') {
  68. return '设置边属性'
  69. } else if (props.node && props.node.type === 'serial') {
  70. return '设置串行网关属性'
  71. } else if (props.node && props.node.type === 'parallel') {
  72. return '设置并行网关属性'
  73. } else if (props.node && props.node.type === 'start') {
  74. return '设置开始属性'
  75. } else if (props.node && props.node.type === 'end') {
  76. return '设置结束属性'
  77. }
  78. return '设置中间属性'
  79. })
  80. // 组件类型
  81. const componentType = computed(() => {
  82. if (!props.node || !props.node.type) return
  83. return COMPONENT_LIST[props.node.type]
  84. })
  85. watch(
  86. () => props.node,
  87. (n) => {
  88. if (n) {
  89. objId.value = n.id
  90. if (n.type === 'skip') {
  91. let skipCondition = n.properties.skipCondition
  92. let conditionSpl = skipCondition ? skipCondition.split('@@|') : []
  93. let conditionSplTwo = conditionSpl && conditionSpl.length > 0 ? conditionSpl[1] : []
  94. let condition,
  95. conditionType,
  96. conditionValue = ''
  97. if (conditionSpl && conditionSpl.length > 0 && conditionSpl[0] === '@@spel') {
  98. conditionType = 'spel'
  99. conditionValue = conditionSplTwo
  100. } else if (conditionSpl && conditionSpl.length > 0 && conditionSpl[0] !== '@@spel') {
  101. condition =
  102. conditionSplTwo && conditionSplTwo.length > 0 ? conditionSplTwo.split('@@')[0] : ''
  103. conditionType =
  104. conditionSplTwo && conditionSplTwo.length > 0 ? conditionSplTwo.split('@@')[1] : ''
  105. conditionValue =
  106. conditionSplTwo && conditionSplTwo.length > 0 ? conditionSplTwo.split('@@')[2] : ''
  107. }
  108. form.value = {
  109. nodeType: n.type,
  110. skipType: n.properties.skipType,
  111. skipName: n.text instanceof Object ? n.text.value : n.text,
  112. skipCondition: skipCondition,
  113. condition: condition,
  114. conditionType: conditionType,
  115. conditionValue: conditionValue
  116. }
  117. } else {
  118. const propertiesStr = JSON.stringify(n.properties)
  119. const permissionFlag = n.properties?.permissionFlag
  120. const listenerType = n.properties?.listenerType
  121. const nodeRatioNumber = Number(n.properties.nodeRatio)
  122. n.properties.formCustom = propertiesStr === '{}' ? '1' : n.properties.formCustom || ''
  123. form.value = {
  124. nodeType: n.type,
  125. nodeCode: n.id,
  126. ...n.properties,
  127. nodeName: n.text instanceof Object ? n.text.value : n.text,
  128. collaborativeWay: nodeRatioNumber == 0 ? '1' : nodeRatioNumber == 100 ? '3' : '2',
  129. permissionFlagArr: permissionFlag === '' ? [] : (permissionFlag?.split('@@') ?? []),
  130. listenerTypeArr: listenerType === '' ? [] : (listenerType?.split(',') ?? []),
  131. nodeRatioNumber
  132. }
  133. }
  134. }
  135. }
  136. )
  137. watch(
  138. () => form.value.nodeCode,
  139. (n) => {
  140. nodeCode.value = n
  141. }
  142. )
  143. watch(
  144. () => form.value.skipType,
  145. (n) => {
  146. // 监听跳转属性变化并更新
  147. props.lf.setProperties(objId.value, {
  148. skipType: n
  149. })
  150. }
  151. )
  152. watch(
  153. () => form.value.nodeName,
  154. (n) => {
  155. // 监听节点名称变化并更新
  156. props.lf.updateText(objId.value, n)
  157. // 监听节点名称变化并更新
  158. props.lf.setProperties(objId.value, {
  159. nodeName: n
  160. })
  161. }
  162. )
  163. watch(
  164. () => form.value.nodeRatioNumber,
  165. (n) => {
  166. // 监听节点属性变化并更新
  167. props.lf.setProperties(objId.value, {
  168. nodeRatio: n ? n.toString() : undefined
  169. })
  170. }
  171. )
  172. watch(
  173. () => form.value.permissionFlagArr,
  174. (n) => {
  175. if (n === undefined) {
  176. n = []
  177. }
  178. // 监听节点属性变化并更新
  179. props.lf.setProperties(objId.value, {
  180. permissionFlagArr: n,
  181. permissionFlag: n.join('@@')
  182. })
  183. }
  184. )
  185. watch(
  186. () => form.value.skipAnyNode,
  187. (n) => {
  188. // 监听跳转属性变化并更新
  189. props.lf.setProperties(objId.value, {
  190. skipAnyNode: n
  191. })
  192. }
  193. )
  194. watch(
  195. () => form.value.listenerTypeArr,
  196. (n) => {
  197. if (n === undefined) {
  198. n = []
  199. }
  200. // 监听监听器类型变化并更新
  201. props.lf.setProperties(objId.value, {
  202. listenerTypeArr: n,
  203. listenerType: n.join(',')
  204. })
  205. }
  206. )
  207. watch(
  208. () => form.value.listenerPath,
  209. (n) => {
  210. // 监听监听器路径变化并更新
  211. props.lf.setProperties(objId.value, {
  212. listenerPath: n
  213. })
  214. }
  215. )
  216. watch(
  217. () => form.value.formCustom,
  218. (n) => {
  219. props.lf.setProperties(objId.value, {
  220. formCustom: n || ''
  221. })
  222. }
  223. )
  224. watch(
  225. () => form.value.formPath,
  226. (n) => {
  227. props.lf.setProperties(objId.value, {
  228. formPath: n
  229. })
  230. }
  231. )
  232. watch(
  233. () => form.value.skipName,
  234. (n) => {
  235. if (['skip'].includes(props.node.type)) {
  236. // 监听跳转名称变化并更新
  237. props.lf.updateText(objId.value, n)
  238. // 监听跳转属性变化并更新
  239. props.lf.setProperties(objId.value, {
  240. skipName: n
  241. })
  242. }
  243. }
  244. )
  245. watch(
  246. () => form.value.skipCondition,
  247. (n) => {
  248. // 监听跳转属性变化并更新
  249. props.lf.setProperties(objId.value, {
  250. skipCondition: n
  251. })
  252. }
  253. )
  254. function show() {
  255. drawer.value = true
  256. }
  257. function handleClose() {
  258. // 监听节点编码变量并更新
  259. if (nodeCode.value && objId.value) {
  260. if (['skip'].includes(props.node?.type)) {
  261. if (!props.lf.getEdgeModelById(nodeCode.value)) {
  262. props.lf.changeEdgeId(objId.value, nodeCode.value)
  263. }
  264. } else {
  265. if (!props.lf.getNodeModelById(nodeCode.value)) {
  266. props.lf.changeNodeId(objId.value, nodeCode.value)
  267. }
  268. }
  269. }
  270. drawer.value = false
  271. }
  272. defineExpose({
  273. show,
  274. handleClose
  275. })
  276. </script>
  277. <style scoped>
  278. .el-drawer__container ::-webkit-scrollbar {
  279. display: none;
  280. }
  281. </style>