design.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <div class="design">
  3. <el-dialog v-model="visible" width="100%" fullscreen :title="title">
  4. <div class="modeler">
  5. <bpmn-design ref="bpmnDesignRef" @save-call-back="saveCallBack"></bpmn-design>
  6. </div>
  7. </el-dialog>
  8. </div>
  9. </template>
  10. <script lang="ts" setup name="Design">
  11. import { getInfo, editModelXml } from '@/api/workflow/model';
  12. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  13. import { ModelForm } from '@/api/workflow/model/types';
  14. import BpmnDesign from '@/components/BpmnDesign';
  15. import useDialog from '@/hooks/useDialog';
  16. const bpmnDesignRef = ref<InstanceType<typeof BpmnDesign>>();
  17. const modelForm = ref<ModelForm>();
  18. const emit = defineEmits(['closeCallBack']);
  19. const { visible, title } = useDialog({
  20. title: '编辑流程'
  21. });
  22. const modelId = ref('');
  23. const open = async (id) => {
  24. visible.value = true;
  25. modelId.value = id;
  26. const { data } = await getInfo(id);
  27. modelForm.value = data;
  28. bpmnDesignRef.value.initDiagram(modelForm.value.xml);
  29. };
  30. //保存模型
  31. const saveCallBack = async (data) => {
  32. await proxy?.$modal.confirm('是否确认保存?');
  33. modelForm.value.id = modelId.value;
  34. modelForm.value.xml = data.xml;
  35. modelForm.value.svg = data.svg;
  36. modelForm.value.key = data.key;
  37. modelForm.value.name = data.name;
  38. editModelXml(modelForm.value).then((res) => {
  39. if (res.code === 200) {
  40. visible.value = false;
  41. proxy?.$modal.msgSuccess('保存成功');
  42. emit('closeCallBack', data);
  43. }
  44. });
  45. };
  46. /**
  47. * 对外暴露子组件方法
  48. */
  49. defineExpose({
  50. open
  51. });
  52. </script>
  53. <style lang="scss" scoped>
  54. .design {
  55. :deep(.el-dialog .el-dialog__body) {
  56. max-height: 100% !important;
  57. min-height: calc(100vh - 50px);
  58. }
  59. }
  60. </style>