index.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 '@/bpmn/index.vue';
  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. data.loading.value = true;
  34. modelForm.value.id = modelId.value;
  35. modelForm.value.xml = data.xml;
  36. modelForm.value.svg = data.svg;
  37. modelForm.value.key = data.key;
  38. modelForm.value.name = data.name;
  39. editModelXml(modelForm.value).then((res) => {
  40. if (res.code === 200) {
  41. visible.value = false;
  42. proxy?.$modal.msgSuccess('保存成功');
  43. emit('closeCallBack', data);
  44. }
  45. });
  46. data.loading.value = false;
  47. };
  48. /**
  49. * 对外暴露子组件方法
  50. */
  51. defineExpose({
  52. open
  53. });
  54. </script>
  55. <style lang="scss" scoped>
  56. .design {
  57. :deep(.el-dialog .el-dialog__body) {
  58. max-height: 100% !important;
  59. min-height: calc(100vh - 80px);
  60. padding: 10px 0 10px 0 !important;
  61. }
  62. :deep(.el-dialog__header) {
  63. padding: 0 0 5px 0 !important;
  64. }
  65. }
  66. </style>