diff --git a/admin/.vscode/settings.json b/admin/.vscode/settings.json index 1b50e37..2a24d8a 100644 --- a/admin/.vscode/settings.json +++ b/admin/.vscode/settings.json @@ -3,8 +3,8 @@ "editor.tabSize": 4, "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true - }, + "source.fixAll.eslint": "explicit" +}, "css.validate": false, "less.validate": false, "scss.validate": false diff --git a/admin/package.json b/admin/package.json index b2a3d31..bc449f9 100644 --- a/admin/package.json +++ b/admin/package.json @@ -13,6 +13,8 @@ "dependencies": { "@element-plus/icons-vue": "^2.3.1", "@highlightjs/vue-plugin": "^2.1.0", + "@logicflow/core": "^1.2.18", + "@logicflow/extension": "^1.2.19", "@vue/shared": "^3.3.9", "@vueuse/core": "^10.6.1", "@wangeditor/editor": "^5.1.23", @@ -27,6 +29,7 @@ "lodash-es": "^4.17.21", "nprogress": "^0.2.0", "pinia": "^2.1.7", + "vform3-builds": "^3.0.10", "vue": "^3.3.9", "vue-clipboard3": "^2.0.0", "vue-echarts": "^6.6.1", diff --git a/admin/src/components/flow/AdvancedSetting/index.vue b/admin/src/components/flow/AdvancedSetting/index.vue new file mode 100644 index 0000000..f92df81 --- /dev/null +++ b/admin/src/components/flow/AdvancedSetting/index.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/admin/src/components/flow/Approver.vue b/admin/src/components/flow/Approver.vue new file mode 100644 index 0000000..0cdddcc --- /dev/null +++ b/admin/src/components/flow/Approver.vue @@ -0,0 +1,303 @@ + + + + + diff --git a/admin/src/components/flow/BasicSetting/index.vue b/admin/src/components/flow/BasicSetting/index.vue new file mode 100644 index 0000000..f01cabf --- /dev/null +++ b/admin/src/components/flow/BasicSetting/index.vue @@ -0,0 +1,166 @@ + + + + + diff --git a/admin/src/components/flow/XForm/index.vue b/admin/src/components/flow/XForm/index.vue new file mode 100644 index 0000000..41779f6 --- /dev/null +++ b/admin/src/components/flow/XForm/index.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/admin/src/components/flow/flowEdit/Diagram.vue b/admin/src/components/flow/flowEdit/Diagram.vue new file mode 100644 index 0000000..2de1a01 --- /dev/null +++ b/admin/src/components/flow/flowEdit/Diagram.vue @@ -0,0 +1,292 @@ + + + + + diff --git a/admin/src/components/flow/flowEdit/DiagramSidebar.vue b/admin/src/components/flow/flowEdit/DiagramSidebar.vue new file mode 100644 index 0000000..394b6a4 --- /dev/null +++ b/admin/src/components/flow/flowEdit/DiagramSidebar.vue @@ -0,0 +1,135 @@ + + + + + diff --git a/admin/src/components/flow/flowEdit/DiagramToolbar.vue b/admin/src/components/flow/flowEdit/DiagramToolbar.vue new file mode 100644 index 0000000..8b8f63a --- /dev/null +++ b/admin/src/components/flow/flowEdit/DiagramToolbar.vue @@ -0,0 +1,181 @@ + + + + + diff --git a/admin/src/components/flow/flowEdit/PropertyPanel.vue b/admin/src/components/flow/flowEdit/PropertyPanel.vue new file mode 100644 index 0000000..56c30b9 --- /dev/null +++ b/admin/src/components/flow/flowEdit/PropertyPanel.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/admin/src/components/flow/flowEdit/config.js b/admin/src/components/flow/flowEdit/config.js new file mode 100644 index 0000000..c36ba60 --- /dev/null +++ b/admin/src/components/flow/flowEdit/config.js @@ -0,0 +1,12 @@ +// 元素属性右侧面板默认属性 +export const defatuleStyle = { + backgroundColor: '', // 填充色 + gradientColor: '', // 渐变色 + borderType: 0, // 边框类型 + borderColor: '', // 填充颜色 + borderWidth: 1, // 边框宽度 + borderStyle: '', // 边框类型 + fontSize: 12, // 文本大小 + fontColor: '', // 文本颜色 + fontWeight: '' // 文本加粗 +} diff --git a/admin/src/components/flow/flowEdit/constant/index.js b/admin/src/components/flow/flowEdit/constant/index.js new file mode 100644 index 0000000..710a725 --- /dev/null +++ b/admin/src/components/flow/flowEdit/constant/index.js @@ -0,0 +1,69 @@ +export const shortStyles = [ + { + backgroundColor: 'rgb(255, 255, 255)', + borderWidth: '1px', + borderColor: 'rgb(42, 42, 42)' + }, + { + backgroundColor: 'rgb(245, 245, 245)', + borderWidth: '1px', + borderColor: 'rgb(102, 102, 102)' + }, + { + backgroundColor: 'rgb(218, 232, 252)', + borderWidth: '1px', + borderColor: 'rgb(108, 142, 191)' + }, + { + backgroundColor: 'rgb(213, 232, 212)', + borderWidth: '1px', + borderColor: 'rgb(130, 179, 102)' + }, + { + backgroundColor: 'rgb(255, 230, 204)', + borderWidth: '1px', + borderColor: 'rgb(215, 155, 0)' + }, + { + backgroundColor: 'rgb(255, 242, 204)', + borderWidth: '1px', + borderColor: 'rgb(214, 182, 86)' + }, + { + backgroundColor: 'rgb(248, 206, 204)', + borderWidth: '1px', + borderColor: 'rgb(184, 84, 80)' + }, + { + backgroundColor: 'rgb(220, 210, 230)', + borderWidth: '1px', + borderColor: 'rgb(150, 115, 166)' + } +] + +export const borderStyles = [ + { + value: 'solid' + }, + { + value: 'dashed' + }, + { + value: 'dotted' + } +] + +export const fontFamilies = [ + { + value: 'Arial' + }, + { + value: 'Verdana' + }, + { + value: 'Georgia' + }, + { + value: 'Times New Roman' + } +] diff --git a/admin/src/components/flow/flowEdit/icon/Actor.vue b/admin/src/components/flow/flowEdit/icon/Actor.vue new file mode 100644 index 0000000..c0db67d --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Actor.vue @@ -0,0 +1,38 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/AreaSelect.vue b/admin/src/components/flow/flowEdit/icon/AreaSelect.vue new file mode 100644 index 0000000..165fd41 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/AreaSelect.vue @@ -0,0 +1,17 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Blod.vue b/admin/src/components/flow/flowEdit/icon/Blod.vue new file mode 100644 index 0000000..e00200e --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Blod.vue @@ -0,0 +1,16 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Circle.vue b/admin/src/components/flow/flowEdit/icon/Circle.vue new file mode 100644 index 0000000..c53dc6d --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Circle.vue @@ -0,0 +1,31 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/ColorFill.vue b/admin/src/components/flow/flowEdit/icon/ColorFill.vue new file mode 100644 index 0000000..88b31d9 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/ColorFill.vue @@ -0,0 +1,16 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/ColorText.vue b/admin/src/components/flow/flowEdit/icon/ColorText.vue new file mode 100644 index 0000000..eb3e7e8 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/ColorText.vue @@ -0,0 +1,15 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Cross.vue b/admin/src/components/flow/flowEdit/icon/Cross.vue new file mode 100644 index 0000000..98b2c39 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Cross.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/Cylinde.vue b/admin/src/components/flow/flowEdit/icon/Cylinde.vue new file mode 100644 index 0000000..10e9e9c --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Cylinde.vue @@ -0,0 +1,27 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Diamond.vue b/admin/src/components/flow/flowEdit/icon/Diamond.vue new file mode 100644 index 0000000..9a3df13 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Diamond.vue @@ -0,0 +1,19 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Divide.vue b/admin/src/components/flow/flowEdit/icon/Divide.vue new file mode 100644 index 0000000..b5fdbaf --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Divide.vue @@ -0,0 +1,37 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/DownArrow.vue b/admin/src/components/flow/flowEdit/icon/DownArrow.vue new file mode 100644 index 0000000..092df74 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/DownArrow.vue @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/Ellipse.vue b/admin/src/components/flow/flowEdit/icon/Ellipse.vue new file mode 100644 index 0000000..cc7e867 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Ellipse.vue @@ -0,0 +1,21 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Font.vue b/admin/src/components/flow/flowEdit/icon/Font.vue new file mode 100644 index 0000000..ccdc7e7 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Font.vue @@ -0,0 +1,16 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Heptagon.vue b/admin/src/components/flow/flowEdit/icon/Heptagon.vue new file mode 100644 index 0000000..c7e1da6 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Heptagon.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/Hexagon.vue b/admin/src/components/flow/flowEdit/icon/Hexagon.vue new file mode 100644 index 0000000..22d482d --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Hexagon.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/HorizontalArrow.vue b/admin/src/components/flow/flowEdit/icon/HorizontalArrow.vue new file mode 100644 index 0000000..51da2ff --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/HorizontalArrow.vue @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/LeftArrow.vue b/admin/src/components/flow/flowEdit/icon/LeftArrow.vue new file mode 100644 index 0000000..a4f3c84 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/LeftArrow.vue @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/Line.vue b/admin/src/components/flow/flowEdit/icon/Line.vue new file mode 100644 index 0000000..47ff3d1 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Line.vue @@ -0,0 +1,16 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Minus.vue b/admin/src/components/flow/flowEdit/icon/Minus.vue new file mode 100644 index 0000000..45c0897 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Minus.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/Parallelogram.vue b/admin/src/components/flow/flowEdit/icon/Parallelogram.vue new file mode 100644 index 0000000..cb0f995 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Parallelogram.vue @@ -0,0 +1,19 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Pentagon.vue b/admin/src/components/flow/flowEdit/icon/Pentagon.vue new file mode 100644 index 0000000..e94987b --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Pentagon.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/Rect.vue b/admin/src/components/flow/flowEdit/icon/Rect.vue new file mode 100644 index 0000000..edb4a66 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Rect.vue @@ -0,0 +1,31 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/RectRadius.vue b/admin/src/components/flow/flowEdit/icon/RectRadius.vue new file mode 100644 index 0000000..9f6ab3c --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/RectRadius.vue @@ -0,0 +1,23 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/RightArrow.vue b/admin/src/components/flow/flowEdit/icon/RightArrow.vue new file mode 100644 index 0000000..df2c4ee --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/RightArrow.vue @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/Septagon.vue b/admin/src/components/flow/flowEdit/icon/Septagon.vue new file mode 100644 index 0000000..0b7aeab --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Septagon.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/StepBack.vue b/admin/src/components/flow/flowEdit/icon/StepBack.vue new file mode 100644 index 0000000..d7af789 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/StepBack.vue @@ -0,0 +1,18 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/StepFoward.vue b/admin/src/components/flow/flowEdit/icon/StepFoward.vue new file mode 100644 index 0000000..9a222f9 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/StepFoward.vue @@ -0,0 +1,18 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Table.vue b/admin/src/components/flow/flowEdit/icon/Table.vue new file mode 100644 index 0000000..e4739d3 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Table.vue @@ -0,0 +1,158 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Text.vue b/admin/src/components/flow/flowEdit/icon/Text.vue new file mode 100644 index 0000000..ae02184 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Text.vue @@ -0,0 +1,46 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/Times.vue b/admin/src/components/flow/flowEdit/icon/Times.vue new file mode 100644 index 0000000..f081988 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Times.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/Trapezoid.vue b/admin/src/components/flow/flowEdit/icon/Trapezoid.vue new file mode 100644 index 0000000..2788061 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Trapezoid.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/Triangle.vue b/admin/src/components/flow/flowEdit/icon/Triangle.vue new file mode 100644 index 0000000..5bc4087 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/Triangle.vue @@ -0,0 +1,19 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/UpArrow.vue b/admin/src/components/flow/flowEdit/icon/UpArrow.vue new file mode 100644 index 0000000..35a4f39 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/UpArrow.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/VerticalArrow.vue b/admin/src/components/flow/flowEdit/icon/VerticalArrow.vue new file mode 100644 index 0000000..9a68b2b --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/VerticalArrow.vue @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/icon/ZoomIn.vue b/admin/src/components/flow/flowEdit/icon/ZoomIn.vue new file mode 100644 index 0000000..b19f643 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/ZoomIn.vue @@ -0,0 +1,18 @@ + + + diff --git a/admin/src/components/flow/flowEdit/icon/ZoomOut.vue b/admin/src/components/flow/flowEdit/icon/ZoomOut.vue new file mode 100644 index 0000000..6ed2fe4 --- /dev/null +++ b/admin/src/components/flow/flowEdit/icon/ZoomOut.vue @@ -0,0 +1,18 @@ + + + diff --git a/admin/src/components/flow/flowEdit/node/arrow/DownArrowNode.js b/admin/src/components/flow/flowEdit/node/arrow/DownArrowNode.js new file mode 100644 index 0000000..fbfd7a2 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/arrow/DownArrowNode.js @@ -0,0 +1,49 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' + +// 下箭头 + +class DownArrowModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 50 + this.height = 80 + } +} +class DownArrowView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const ArrowWidth = 1/3 * width; + const upY = y - 1/2 * height; + const downY = y + 1/2 * height; + const downY2 = y + 1/5 * height; + const attrs = { + ...style, + x, + y, + width, + height, + points: [ + [x - 1/2 * ArrowWidth, downY2], + [x - 1/2 * width, downY2], + [x, downY], + [x + 1/2 * width, downY2], + [x + 1/2 * ArrowWidth, downY2], + [x + 1/2 * ArrowWidth, upY], + [x - 1/2 * ArrowWidth, upY], + ] + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ] + ); + } +} + +export default { + type: 'down-arrow', + view: DownArrowView, + model: DownArrowModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/arrow/HorizontalArrowNode.js b/admin/src/components/flow/flowEdit/node/arrow/HorizontalArrowNode.js new file mode 100644 index 0000000..c048447 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/arrow/HorizontalArrowNode.js @@ -0,0 +1,56 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' + +// 水平双箭头 + +class HorizontalArrowModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 40 + } +} + +class HorizontalArrowView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const ArrowHeight = 1/3 * height; + const leftX = x - 1/2 * width; + const leftX2 = x - 1/5 * width; + const rightX = x + 1/2 * width; + const rightX2 = x + 1/5 * width; + const attrs = { + ...style, + x, + y, + width, + height, + points: [ + // 右箭头 + [rightX2, y - 1/2 * ArrowHeight], + [rightX2, y - 1/2 * height], + [rightX, y], + [rightX2, y + 1/2 * height], + [rightX2, y + 1/2 * ArrowHeight], + // 左箭头 + [leftX2, y + 1/2 * ArrowHeight], + [leftX2, y + 1/2 * height], + [leftX, y], + [leftX2, y - 1/2 * height], + [leftX2, y - 1/2 * ArrowHeight], + ] + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ] + ); + } +} + +export default { + type: 'horizontal-arrow', + view: HorizontalArrowView, + model: HorizontalArrowModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/arrow/LeftArrow.js b/admin/src/components/flow/flowEdit/node/arrow/LeftArrow.js new file mode 100644 index 0000000..d8a2786 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/arrow/LeftArrow.js @@ -0,0 +1,48 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' + +// 左箭头 +class LeftArrowModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 50 + } +} +class LeftArrowView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const ArrowHeight = 1/3 * height; + const leftX = x - 1/2 * width; + const leftX2 = x - 1/5 * width; + const rightX = x + 1/2 * width; + const attrs = { + ...style, + x, + y, + width, + height, + points: [ + [leftX2, y - 1/2 * ArrowHeight], + [leftX2, y - 1/2 * height], + [leftX, y], + [leftX2, y + 1/2 * height], + [leftX2, y + 1/2 * ArrowHeight], + [rightX, y + 1/2 * ArrowHeight], + [rightX, y - 1/2 * ArrowHeight], + ] + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ] + ); + } +} + +export default { + type: 'left-arrow', + view: LeftArrowView, + model: LeftArrowModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/arrow/RightArrow.js b/admin/src/components/flow/flowEdit/node/arrow/RightArrow.js new file mode 100644 index 0000000..be5f65d --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/arrow/RightArrow.js @@ -0,0 +1,50 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' + +// 右箭头 + +class RightArrowModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 50 + } +} + +class RightArrowView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const ArrowHeight = 1/3 * height; + const leftX = x - 1/2 * width; + const rightX = x + 1/2 * width; + const rightX2 = x + 1/5 * width; + const attrs = { + ...style, + x, + y, + width, + height, + points: [ + [rightX2, y - 1/2 * ArrowHeight], + [rightX2, y - 1/2 * height], + [rightX, y], + [rightX2, y + 1/2 * height], + [rightX2, y + 1/2 * ArrowHeight], + [leftX, y + 1/2 * ArrowHeight], + [leftX, y - 1/2 * ArrowHeight], + ] + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ] + ); + } +} + +export default { + type: 'right-arrow', + view: RightArrowView, + model: RightArrowModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/arrow/UpArrowNode.js b/admin/src/components/flow/flowEdit/node/arrow/UpArrowNode.js new file mode 100644 index 0000000..0fe19e7 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/arrow/UpArrowNode.js @@ -0,0 +1,49 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' + +// 上箭头 +class UpArrowModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 50 + this.height = 80 + } +} + +class UpArrowView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const ArrowWidth = 1/3 * width; + const upY = y - 1/2 * height; + const upY2 = y - 1/5 * height; + const downY = y + 1/2 * height; + const attrs = { + ...style, + x, + y, + width, + height, + points: [ + [x - 1/2 * ArrowWidth, upY2], + [x - 1/2 * width, upY2], + [x, upY], + [x + 1/2 * width, upY2], + [x + 1/2 * ArrowWidth, upY2], + [x + 1/2 * ArrowWidth, downY], + [x - 1/2 * ArrowWidth, downY], + ] + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ] + ); + } +} + +export default { + type: 'up-arrow', + view: UpArrowView, + model: UpArrowModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/arrow/VerticalArrowNode.js b/admin/src/components/flow/flowEdit/node/arrow/VerticalArrowNode.js new file mode 100644 index 0000000..b4d84aa --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/arrow/VerticalArrowNode.js @@ -0,0 +1,56 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' + +// 竖直箭头 + +class VerticalArrowModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 40 + this.height = 80 + } +} + +class VerticalArrowView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const ArrowWidth = 1/3 * width; + const upY = y - 1/2 * height; + const upY2 = y - 1/5 * height; + const downY = y + 1/2 * height; + const downY2 = y + 1/5 * height; + const attrs = { + ...style, + x, + y, + width, + height, + points: [ + // 上箭头 + [x - 1/2 * ArrowWidth, upY2], + [x - 1/2 * width, upY2], + [x, upY], + [x + 1/2 * width, upY2], + [x + 1/2 * ArrowWidth, upY2], + // 下箭头 + [x + 1/2 * ArrowWidth, downY2], + [x + 1/2 * width, downY2], + [x , downY], + [x - 1/2 * width, downY2], + [x - 1/2 * ArrowWidth, downY2], + ] + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ] + ); + } +} + +export default { + type: 'vertical-arrow', + view: VerticalArrowView, + model: VerticalArrowModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/basic/BaseNode.js b/admin/src/components/flow/flowEdit/node/basic/BaseNode.js new file mode 100644 index 0000000..8887521 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/basic/BaseNode.js @@ -0,0 +1,16 @@ +import { BaseNode, BaseNodeModel } from '@logicflow/core' + +class BaseNewNode extends BaseNode { +} + +class BaseNewModel extends BaseNodeModel { + setAttributes () { + this.fill = 'red' + } +} + +export default { + type: 'BaseNode', + view: BaseNewNode, + model: BaseNewModel +} diff --git a/admin/src/components/flow/flowEdit/node/basic/CircleNode.js b/admin/src/components/flow/flowEdit/node/basic/CircleNode.js new file mode 100644 index 0000000..83e9f63 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/basic/CircleNode.js @@ -0,0 +1,33 @@ +import { EllipseResize } from '@logicflow/extension' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 圆形 +class CircleNewModel extends EllipseResize.model { + initNodeData(data) { + super.initNodeData(data) + this.rx = 35 + this.ry = 35 + } + + setToBottom () { + this.zIndex = 0 + } + + getNodeStyle () { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle () { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +export default { + type: 'pro-circle', + view: EllipseResize.view, + model: CircleNewModel +} diff --git a/admin/src/components/flow/flowEdit/node/basic/DiamondNode.js b/admin/src/components/flow/flowEdit/node/basic/DiamondNode.js new file mode 100644 index 0000000..9cd1408 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/basic/DiamondNode.js @@ -0,0 +1,35 @@ +import { DiamondResize } from '@logicflow/extension' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 菱形 +/** + * model控制初始化的值 + */ +class DiamondModel extends DiamondResize.model { + initNodeData(data) { + super.initNodeData(data) + this.rx = 35 + this.ry = 35 + } + getNodeStyle () { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle () { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } + + setToBottom () { + this.zIndex = 0 + } +} + +export default { + type: 'pro-diamond', + view: DiamondResize.view, + model: DiamondModel +} diff --git a/admin/src/components/flow/flowEdit/node/basic/EllipseNode.js b/admin/src/components/flow/flowEdit/node/basic/EllipseNode.js new file mode 100644 index 0000000..3042335 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/basic/EllipseNode.js @@ -0,0 +1,19 @@ +import CircleNode from './CircleNode' + +// 椭圆 +class EllipseNewModel extends CircleNode.model { + initNodeData(data) { + super.initNodeData(data) + this.rx = 60 + this.ry = 30 + } + getNodeStyle() { + const style = super.getNodeStyle() + return {...style} + } +} +export default { + type: 'pro-ellipse', + view: CircleNode.view, + model: EllipseNewModel +} diff --git a/admin/src/components/flow/flowEdit/node/basic/RectNode.js b/admin/src/components/flow/flowEdit/node/basic/RectNode.js new file mode 100644 index 0000000..8e119ec --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/basic/RectNode.js @@ -0,0 +1,28 @@ +import { RectResize } from '@logicflow/extension' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 矩形 +class RectNewModel extends RectResize.model { + + setToBottom () { + this.zIndex = 0 + } + + getNodeStyle () { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle () { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +export default { + type: 'pro-rect', + view: RectResize.view, + model: RectNewModel +} diff --git a/admin/src/components/flow/flowEdit/node/basic/RectRadiusNode.js b/admin/src/components/flow/flowEdit/node/basic/RectRadiusNode.js new file mode 100644 index 0000000..996f75c --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/basic/RectRadiusNode.js @@ -0,0 +1,14 @@ +import RectNode from './RectNode' + +// 带圆角的矩形 +class RectRadiusModel extends RectNode.model { + setAttributes () { + super.setAttributes() + this.radius = 20 + } +} +export default { + type: 'rect-radius', + view: RectNode.view, + model: RectRadiusModel +} diff --git a/admin/src/components/flow/flowEdit/node/basic/TextNode.js b/admin/src/components/flow/flowEdit/node/basic/TextNode.js new file mode 100644 index 0000000..56226c4 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/basic/TextNode.js @@ -0,0 +1,39 @@ +import { TextNodeModel, TextNode } from '@logicflow/core' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 文本节点 +class TextNewNode extends TextNode { +} +class TextNewModel extends TextNodeModel { + getNodeStyle () { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle () { + const style = super.getTextStyle() + const properties = this.getProperties() + style.color = '#000' + if (properties.backgroundColor) { + + style.backgroundStyle = { + fill: properties.backgroundColor + } + } + return getTextStyleFunction(style, properties) + } + + setAttributes () { + super.setAttributes() + if (!this.text.value) { + this.text.value = 'text' + } + } +} + +export default { + type: 'pro-text', + view: TextNewNode, + model: TextNewModel +} diff --git a/admin/src/components/flow/flowEdit/node/edge/Bezier.js b/admin/src/components/flow/flowEdit/node/edge/Bezier.js new file mode 100644 index 0000000..da34552 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/edge/Bezier.js @@ -0,0 +1,27 @@ +import { BezierEdge, BezierEdgeModel } from '@logicflow/core' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 贝塞尔曲线 +class Model extends BezierEdgeModel { + constructor (data, graphModel) { + super(data, graphModel) + this.strokeWidth = 1 + } + getTextStyle () { + const style = super.getTextStyle() + return getTextStyleFunction(style, this.properties) + } + + getEdgeStyle () { + const attributes = super.getEdgeStyle() + const properties = this.properties; + const style = getShapeStyleFuction(attributes, properties) + style.stroke = 'rgb(24, 125, 255)' + return { ...style, fill: 'none' } + } +} +export default { + type: 'pro-bezier', + view: BezierEdge, + model: Model +} diff --git a/admin/src/components/flow/flowEdit/node/edge/Line.js b/admin/src/components/flow/flowEdit/node/edge/Line.js new file mode 100644 index 0000000..bea98ce --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/edge/Line.js @@ -0,0 +1,27 @@ +import { LineEdge, LineEdgeModel } from '@logicflow/core' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 直线 +class Model extends LineEdgeModel { + constructor (data, graphModel) { + super(data, graphModel) + this.strokeWidth = 1 + } + getTextStyle () { + const style = super.getTextStyle() + return getTextStyleFunction(style, this.properties) + } + + getEdgeStyle () { + const attributes = super.getEdgeStyle() + const properties = this.properties; + const style = getShapeStyleFuction(attributes, properties) + style.stroke = 'rgb(24, 125, 255)' + return { ...style, fill: 'none' } + } +} +export default { + type: 'pro-line', + view: LineEdge, + model: Model +} diff --git a/admin/src/components/flow/flowEdit/node/edge/Polyline.js b/admin/src/components/flow/flowEdit/node/edge/Polyline.js new file mode 100644 index 0000000..17b155c --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/edge/Polyline.js @@ -0,0 +1,37 @@ +import { PolylineEdge, PolylineEdgeModel } from '@logicflow/core' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + + // 折线 +class Model extends PolylineEdgeModel { + constructor (data, graphModel) { + super(data, graphModel) + this.strokeWidth = 1 + } + setAttributes() { + this.isAnimation = true; + } + getEdgeAnimationStyle() { + const style = super.getEdgeAnimationStyle(); + style.strokeDasharray = "50 5"; + style.animationDuration = "10s"; + style.stroke = 'rgb(24, 125, 255)' + return style; + } + getTextStyle () { + const style = super.getTextStyle() + return getTextStyleFunction(style, this.properties) + } + + getEdgeStyle () { + const attributes = super.getEdgeStyle() + const properties = this.properties; + const style = getShapeStyleFuction(attributes, properties) + style.stroke = 'rgb(24, 125, 255)' + return { ...style, fill: 'none' } + } +} +export default { + type: 'pro-polyline', + view: PolylineEdge, + model: Model +} diff --git a/admin/src/components/flow/flowEdit/node/getShapeStyleUtil.js b/admin/src/components/flow/flowEdit/node/getShapeStyleUtil.js new file mode 100644 index 0000000..9df8175 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/getShapeStyleUtil.js @@ -0,0 +1,61 @@ +export const getShapeStyleFuction = (style, properties) => { + if (properties.backgroundColor) { + style.fill = properties.backgroundColor + } + if (properties.gradientColor && style.fill !== properties.gradientColor) { + style.fillGradient = properties.gradientColor + } + if (properties.borderColor) { + style.stroke = properties.borderColor + } + if (properties.borderWidth) { + style.strokeWidth = properties.borderWidth + } + if (properties.borderStyle) { + if (properties.borderStyle === 'solid') { + style.strokeDashArray = '0' + // nodeResize里的bug导致的,array小写了 + style.strokeDasharray = '0' + } + if (properties.borderStyle === 'dashed') { + style.strokeDashArray = '3 3' + style.strokeDasharray = '3 3' + } + if (properties.borderStyle === 'dotted') { + style.strokeDashArray = '1 1' + style.strokeDasharray = '1 1' + } + if (properties.borderStyle === 'hidden') { + style.stroke = style.fill + } + } + return style +} + +export const getTextStyleFunction = (style = {}, properties) => { + if (properties.fontColor) { + style.color = properties.fontColor + } + if (properties.fontSize) { + style.fontSize = properties.fontSize + } + if (properties.fontFamily) { + style.fontFamily = properties.fontFamily + } + if (properties.lineHeight) { + style.lineHeight = properties.lineHeight + } + if (properties.textAlign) { + style.textAlign = properties.textAlign + } + if (properties.fontWeight) { + style.fontWeight = properties.fontWeight + } + if (properties.textDecoration) { + style.textDecoration = properties.textDecoration + } + if (properties.fontStyle) { + style.fontStyle = properties.fontStyle + } + return style +} diff --git a/admin/src/components/flow/flowEdit/node/icon/IconNode.js b/admin/src/components/flow/flowEdit/node/icon/IconNode.js new file mode 100644 index 0000000..a08715f --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/icon/IconNode.js @@ -0,0 +1,44 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' + +// 左上角带ICON的节点 +class IconNode extends RectNode.view { + getImageHref () { + return; + } + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const href = this.getImageHref() + const iconAttrs = { + x: x - 1/2 * width + 5, + y: y - 1/2 * height + 5, // icon在左上角 + width: 25, + height: 18, + href, + // 根据宽高缩放 + preserveAspectRatio: 'none meet' + } + const rectAttrs = { + ...style, + strokeWidth: 1, + rx: 5, + ry: 5, + x: x- 1/2 * width, + y: y - 1/2 * height, + width, + height, + } + return h('g', {}, [ + h('rect', { ...rectAttrs }), + h('image', { ...iconAttrs }) + ] + ); + } +} + +export default { + type: 'image-node', + view: IconNode, + model: RectNode.model +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/icon/Message.js b/admin/src/components/flow/flowEdit/node/icon/Message.js new file mode 100644 index 0000000..128c939 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/icon/Message.js @@ -0,0 +1,15 @@ +import IconNode from './IconNode' + +// 左上角ICON为消息的节点 +class MessageNode extends IconNode.view { + getImageHref () { + return 'https://dpubstatic.udache.com/static/dpubimg/1TZgBoaq8G/message.png'; + } +} + + +export default { + type: 'icon-message', + view: MessageNode, + model: IconNode.model +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/index.js b/admin/src/components/flow/flowEdit/node/index.js new file mode 100644 index 0000000..da43deb --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/index.js @@ -0,0 +1,103 @@ +// 基础图形 +import CircleNode from "./basic/CircleNode"; +import RectNode from "./basic/RectNode"; +import RectRadiusNode from "./basic/RectRadiusNode"; +import EllipseNode from "./basic/EllipseNode"; +import TextNode from "./basic/TextNode"; +import DiamondNode from "./basic/DiamondNode"; +// // path绘制的个性化图形 +// import CylindeNode from './path/CylindeNode' +// import TriangleNode from './path/TriangleNode' +// import ParallelogramNode from './path/ParallelogramNode' +// import ActorNode from './path/ActorNode' +// import StarNode from './path/Star' +// import PentagonNode from './path/PentagonNode' +// import HexagonNode from './path/HexagonNode' +// import SeptagonNode from './path/SeptagonNode' +// import HeptagonNode from './path/HeptagonNode' +// import TrapezoidNode from './path/TrapezoidNode' +// import CrossNode from './path/CrossNode' +// import MinusNode from './path/MinusNode' +// import TimesNode from './path/TimesNode' +// import DivideNode from './path/DivideNode' +// // 多边形绘制的箭头 +// import LeftArrow from './arrow/LeftArrow' +// import RightArrow from './arrow/RightArrow' +// import HorizontalArrow from './arrow/HorizontalArrowNode' +// import UpArrow from './arrow/UpArrowNode' +// import DownArrow from './arrow/DownArrowNode' +// import VerticalArrow from './arrow/VerticalArrowNode' + +// image绘制左上角icon节点 +// import IconMessage from './icon/Message' +// 注册边 +import Ployline from "./edge/Polyline"; +import Line from "./edge/Line"; +import Bezier from "./edge/Bezier"; + +export const List = [ + // office_network, + // firewall, + // router, + // coreSwitch, +]; +console.log(List); +export const registerCustomElement = (lf) => { + // 注册基础图形 + // lf.register(CircleNode); + // lf.register(RectNode); + // lf.register(RectRadiusNode); + // lf.register(EllipseNode); + // lf.register(DiamondNode); + // lf.register(TextNode); + + + // lf.register(status_error); + + List.forEach((item) => { + lf.register({ + type: item.type, + view: item.view, + model: item.model, + }); + }); + + // // 注册path绘制的个性化图形 + // lf.register(CylindeNode) + // lf.register(TriangleNode) + // lf.register(ParallelogramNode) + // lf.register(ActorNode) + // lf.register(StarNode) + // lf.register(PentagonNode) + // lf.register(HexagonNode) + // lf.register(SeptagonNode) + // lf.register(HeptagonNode) + // lf.register(TrapezoidNode) + // lf.register(CrossNode) + // lf.register(MinusNode) + // lf.register(TimesNode) + // lf.register(DivideNode) + // // 注册多边形绘制的箭头 + // lf.register(LeftArrow) + // lf.register(RightArrow) + // lf.register(HorizontalArrow) + // lf.register(UpArrow) + // lf.register(DownArrow) + // lf.register(VerticalArrow) + // // 注册image绘制图片节点 + // lf.register(firewall) + // lf.register(ImageUser) + // lf.register(office_network) + + // lf.register(status_success) + // lf.register(status_error) + + // lf.register(router) + + // // 注册image绘制左上角icon节点 + // lf.register(IconMessage) + // // 注册边 + lf.register(Ployline); + lf.register(Line); + lf.register(Bezier); +}; diff --git a/admin/src/components/flow/flowEdit/node/path/ActorNode.js b/admin/src/components/flow/flowEdit/node/path/ActorNode.js new file mode 100644 index 0000000..87406e8 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/ActorNode.js @@ -0,0 +1,95 @@ +import { h } from '@logicflow/core' +import { RectResize } from '@logicflow/extension' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' +// 人物 +class ActorModel extends RectResize.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 40; + this.height = 80; + } + + getNodeStyle () { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle () { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class ActorView extends RectResize.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + // 人物头部圆形 + const ellipseAttrs = { + ...style, + cx: x, + cy: y - 3/8 * height, + rx: 1/4 * width, + ry: 1/8 * height, + width, + height + } + // 人物肩膀横线 + const pathAAttrs = { + ...style, + d: `M ${x - 1/2 * width} ${y - 1/8 * height} L ${x + 1/2 * width} ${y - 1/8 * height}` + } + // 人物身体躯干竖线 + const pathBAttrs = { + ...style, + d: `M ${x} ${y - 1/4 * height} L ${x} ${y + 1/5 * height}` + } + // 人物左腿斜线 + const pathCAttrs = { + ...style, + d: `M ${x} ${y + 1/5 * height} L ${x - 1/2 * width} ${y + 1/2 * height}` + } + // 人物右腿斜线 + const pathDAttrs = { + ...style, + d: `M ${x} ${y + 1/5 * height} L ${x + 1/2 * width} ${y + 1/2 * height}` + } + // 人物透明背景板 + const bgAttrs = { + x: x - 1/5 * width, + y: y - 1/2 * height, + width: 2/5 * width, + height, + style: 'fill: transparent' + } + return h('g', {}, [ + h('ellipse', { + ...ellipseAttrs, + }), + h('path', { + ...pathAAttrs, + }), + h('path', { + ...pathBAttrs + }), + h('path', { + ...pathCAttrs + }), + h('path', { + ...pathDAttrs + }), + h('rect', { + ...bgAttrs + }) + ] + ); + } +} + +export default { + type: 'actor', + view: ActorView, + model: ActorModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/CrossNode.js b/admin/src/components/flow/flowEdit/node/path/CrossNode.js new file mode 100644 index 0000000..ad8360a --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/CrossNode.js @@ -0,0 +1,66 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 加号 +class CrossModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 80 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class CrossView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const pointList = [ + [x - 1/2 * width, y - 1/6 * height], + [x - 1/6 * width, y - 1/6 * height], + [x - 1/6 * width, y - 1/2 * height], + [x + 1/6 * width, y - 1/2 * height], + [x + 1/6 * width, y - 1/6 * height], + [x + 1/2 * width, y - 1/6 * height], + [x + 1/2 * width, y + 1/6 * height], + [x + 1/6 * width, y + 1/6 * height], + [x + 1/6 * width, y + 1/2 * height], + [x - 1/6 * width, y + 1/2 * height], + [x - 1/6 * width, y + 1/6 * height], + [x - 1/2 * width, y + 1/6 * height], + ] + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + const attrs = { + ...style, + x, + y, + width, + height, + points: points.join(' ') + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ]) + } + +} + +export default { + type: 'cross', + view: CrossView, + model: CrossModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/CylindeNode.js b/admin/src/components/flow/flowEdit/node/path/CylindeNode.js new file mode 100644 index 0000000..c3d6033 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/CylindeNode.js @@ -0,0 +1,92 @@ +import { h } from '@logicflow/core' +import { RectResize } from '@logicflow/extension' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 圆柱体 +class CylindeModel extends RectResize.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 60 + this.height = 80 + } + getNodeStyle () { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle () { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class CylindeView extends RectResize.view { + getResizeShape () { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + // 圆柱体顶部椭圆 + const ellipseAAttrs = { + ...style, + cx: x, + cy: y - 1/3 * height, + rx: 1/2 * width, + ry: 1/6 * height, + width, + height + } + // 圆柱体左直线 + const pathAAttrs = { + ...style, + d: `M ${x - 1/2 * width} ${y - 1/3 * height} L ${x - 1/2 * width} ${y + 1/3 * height}` + } + // 圆柱体右直线 + const pathBAttrs = { + ...style, + d: `M ${x + 1/2 * width} ${y - 1/3 * height} L ${x + 1/2 * width} ${y + 1/3 * height}` + } + // 圆柱体下椭圆 + const ellipseBAttrs = { + ...style, + cx: x, + cy: y + 1/3 * height, + rx: 1/2 * width, + ry: 1/6 * height, + width, + height + } + // 圆柱体中间填充部分 + const rectAttrs = { + ...style, + x: x - 1/2 * width, + y: y - 1/3 * height, + width, + height: 2/3 * height, + stroke: 'transparent' + } + return h('g', {}, [ + h('ellipse', { + ...ellipseBAttrs + }), + h('rect', { + ...rectAttrs + }), + h('path', { + ...pathAAttrs + }), + h('path', { + ...pathBAttrs + }), + h('ellipse', { + ...ellipseAAttrs + }) + ]) + } +} + +export default { + type: 'cylinde', + model: CylindeModel, + view: CylindeView +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/DivideNode.js b/admin/src/components/flow/flowEdit/node/path/DivideNode.js new file mode 100644 index 0000000..6bf7e3e --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/DivideNode.js @@ -0,0 +1,84 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 除号 +class DivideModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 80 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class DivideView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const pointList = [ + [x - 1/2 * width, y - 1/8 * height], + [x + 1/2 * width, y - 1/8 * height], + [x + 1/2 * width, y + 1/8 * height], + [x - 1/2 * width, y + 1/8 * height], + ] + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + + const attrs = { + ...style, + x, + y, + width, + height, + } + + // 除号中间横线 + const lineAttrs = { + ...attrs, + points: points.join(' ') + } + + // 除号上圆点 + const upEllipseAttrs = { + ...attrs, + cy: y - 3/8 * height, + cx: x, + rx: 1/8* width, + ry: 1/8 * height + } + + // 除号下圆点 + const downEllipseAttrs = { + ...attrs, + cy: y + 3/8 * height, + cx: x, + rx: 1/8 * width, + ry: 1/8 * height + } + + return h('g', {}, [ + h('polygon', { ...lineAttrs }), + h('ellipse', { ...upEllipseAttrs }), + h('ellipse', { ...downEllipseAttrs }) + ]) + } + +} + +export default { + type: 'divide', + view: DivideView, + model: DivideModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/HeptagonNode.js b/admin/src/components/flow/flowEdit/node/path/HeptagonNode.js new file mode 100644 index 0000000..da18a6e --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/HeptagonNode.js @@ -0,0 +1,62 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 五边形 +class HeptagonModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 80 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class HeptagonView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const pointList = [ + [x - 0.205 * width, y - 0.5 * height], + [x + 0.205 * width, y - 0.5 * height], + [x + 0.5 * width, y - 0.205 * height], + [x + 0.5 * width, y + 0.205 * height], + [x + 0.205 * width, y + 0.5 * height], + [x - 0.205 * width, y + 0.5 * height], + [x - 0.5 * width, y + 0.205 * height], + [x - 0.5 * width, y - 0.205 * height] + ] + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + const attrs = { + ...style, + x, + y, + width, + height, + points: points.join(' ') + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ]) + } + +} + +export default { + type: 'heptagon', + view: HeptagonView, + model: HeptagonModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/HexagonNode.js b/admin/src/components/flow/flowEdit/node/path/HexagonNode.js new file mode 100644 index 0000000..f8b85ce --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/HexagonNode.js @@ -0,0 +1,60 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 六边形 +class HexagonModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 80 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class HexagonView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const pointList = [ + [x - 0.28 * width, y - 0.5 * height], + [x + 0.28 * width, y - 0.5 * height], + [x + 0.5 * width, y], + [x + 0.28 * width, y + 0.5 * height], + [x - 0.28 * width, y + 0.5 * height], + [x - 0.5 * width, y] + ] + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + const attrs = { + ...style, + x, + y, + width, + height, + points: points.join(' ') + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ]) + } + +} + +export default { + type: 'hexagon', + view: HexagonView, + model: HexagonModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/MinusNode.js b/admin/src/components/flow/flowEdit/node/path/MinusNode.js new file mode 100644 index 0000000..5a1fa29 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/MinusNode.js @@ -0,0 +1,58 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 减号 +class MinusModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 20 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class MinusView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const pointList = [ + [x - 1/2 * width, y - 1/2 * height], + [x + 1/2 * width, y - 1/2 * height], + [x + 1/2 * width, y + 1/2 * height], + [x - 1/2 * width, y + 1/2 * height], + ] + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + const attrs = { + ...style, + x, + y, + width, + height, + points: points.join(' ') + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ]) + } + +} + +export default { + type: 'minus', + view: MinusView, + model: MinusModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/ParallelogramNode.js b/admin/src/components/flow/flowEdit/node/path/ParallelogramNode.js new file mode 100644 index 0000000..0aa51af --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/ParallelogramNode.js @@ -0,0 +1,57 @@ +import { h } from '@logicflow/core' +import { RectResize } from '@logicflow/extension' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 平行四边形 +class ParallelogramModel extends RectResize.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 100 + this.height = 60 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class ParallelogramView extends RectResize.view { + getResizeShape() { + const { x, y, width, height } = this.props.model; + const style = this.props.model.getNodeStyle(); + const pointList = [ + [x - width / 2, y + height/2], + [x - width / 5, y - height/2], + [x + width / 2, y - height/2], + [x + width / 5, y + height/2] + ]; + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + const attrs = { + ...style, + x, + y, + width, + height, + points: points.join(' ') + } + return h('g', {}, [ + h('polygon', { ...attrs }) + ] + ) + } +} + +export default { + type: 'parallelogram', + view: ParallelogramView, + model: ParallelogramModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/PentagonNode.js b/admin/src/components/flow/flowEdit/node/path/PentagonNode.js new file mode 100644 index 0000000..f78365b --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/PentagonNode.js @@ -0,0 +1,59 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 八边形 +class PentagonModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 80 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class PentagonView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const pointList = [ + [x - 0.5 * width, y], + [x, y - 0.5 * height], + [x + 0.5 * width, y], + [x + 0.3 * width, y + 0.5 * height], + [x - 0.3 * width, y + 0.5 * height] + ] + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + const attrs = { + ...style, + x, + y, + width, + height, + points: points.join(' ') + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ]) + } + +} + +export default { + type: 'pentagon', + view: PentagonView, + model: PentagonModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/SeptagonNode.js b/admin/src/components/flow/flowEdit/node/path/SeptagonNode.js new file mode 100644 index 0000000..23ce999 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/SeptagonNode.js @@ -0,0 +1,61 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 七边形 +class SeptagonModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 80 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class SeptagonView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const pointList = [ + [x, y - 0.5 * height], + [x + 0.395 * width, y - 0.3 * height], + [x + 0.5 * width, y + 0.145 * height], + [x + 0.225 * width, y + 0.5 * height], + [x - 0.225 * width, y + 0.5 * height], + [x - 0.5 * width, y + 0.145 * height], + [x - 0.395 * width, y - 0.3 * height] + ] + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + const attrs = { + ...style, + x, + y, + width, + height, + points: points.join(' ') + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ]) + } + +} + +export default { + type: 'septagon', + view: SeptagonView, + model: SeptagonModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/Star.js b/admin/src/components/flow/flowEdit/node/path/Star.js new file mode 100644 index 0000000..f8af749 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/Star.js @@ -0,0 +1,40 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' + +// 五角星 +class StarModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80; + this.height = 80; + } +} + +class StarView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const svgAttr = { + x: x - 1/2 * width, + y: y - 1/2 * height, + width, + height, + } + const pathAAttrs = { + ...style, + d: 'm0.36922,13.46587l12.98695,0l4.01307,-13.36885l4.01307,13.36885l12.98694,0l-10.50664,8.26231l4.01327,13.36885l-10.50665,-8.26253l-10.50664,8.26253l4.01327,-13.36885l-10.50665,-8.26231l0,0z' + } + + return h('svg', { ...svgAttr, viewBox: '0 0 37 37' }, [ + h('path', { + ...pathAAttrs, + }) + ]) + } +} + +export default { + type: 'star', + view: StarView, + model: StarModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/TimesNode.js b/admin/src/components/flow/flowEdit/node/path/TimesNode.js new file mode 100644 index 0000000..ae60656 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/TimesNode.js @@ -0,0 +1,66 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 乘号 +class TimesModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 80 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class TimesView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const pointList = [ + [x - 1/2 * width, y - 1/3 * height], + [x - 1/3 * width, y - 1/2 * height], + [x, y - 1/6 * height], + [x + 1/3 * width, y - 1/2 * height], + [x + 1/2 * width, y - 1/3 * height], + [x + 1/6 * width, y], + [x + 1/2 * width, y + 1/3 * height], + [x + 1/3 * width, y + 1/2 * height], + [x, y + 1/6 * height], + [x - 1/3 * width, y + 1/2 * height], + [x - 1/2 * width, y + 1/3 * height], + [x - 1/6 * width, y], + ] + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + const attrs = { + ...style, + x, + y, + width, + height, + points: points.join(' ') + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ]) + } + +} + +export default { + type: 'times', + view: TimesView, + model: TimesModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/TrapezoidNode.js b/admin/src/components/flow/flowEdit/node/path/TrapezoidNode.js new file mode 100644 index 0000000..e9a0c5c --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/TrapezoidNode.js @@ -0,0 +1,58 @@ +import { h } from '@logicflow/core' +import RectNode from '../basic/RectNode' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 五边形 +class TrapezoidModel extends RectNode.model { + initNodeData(data) { + super.initNodeData(data) + this.width = 80 + this.height = 80 + } + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class TrapezoidView extends RectNode.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const pointList = [ + [x - 0.31 * width, y - 0.5 * height], + [x + 0.31 * width, y - 0.5 * height], + [x + 0.5 * width, y + 0.5 * height], + [x - 0.5 * width, y + 0.5 * height] + ] + const points = pointList.map(item => { + return `${item[0]},${item[1]}` + }) + const attrs = { + ...style, + x, + y, + width, + height, + points: points.join(' ') + } + + return h('g', {}, [ + h('polygon', { ...attrs }) + ]) + } + +} + +export default { + type: 'trapezoid', + view: TrapezoidView, + model: TrapezoidModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/node/path/TriangleNode.js b/admin/src/components/flow/flowEdit/node/path/TriangleNode.js new file mode 100644 index 0000000..9657fd5 --- /dev/null +++ b/admin/src/components/flow/flowEdit/node/path/TriangleNode.js @@ -0,0 +1,47 @@ +import { h } from '@logicflow/core' +import { RectResize } from '@logicflow/extension' +import { getShapeStyleFuction, getTextStyleFunction } from '../getShapeStyleUtil' + +// 三角形 +class TriangleModel extends RectResize.model { + getNodeStyle() { + const style = super.getNodeStyle() + const properties = this.getProperties() + return getShapeStyleFuction(style, properties) + } + + getTextStyle() { + const style = super.getTextStyle() + const properties = this.getProperties() + return getTextStyleFunction(style, properties) + } +} + +class TriangleView extends RectResize.view { + getResizeShape() { + const { x, y, width, height } = this.props.model + const style = this.props.model.getNodeStyle() + const attrs = { + ...style, + x, + y, + width, + height, + points: [ + [x - width / 2, y + height / 2], + [x - width / 2, y - height / 2], + [x + width / 2, y] + ] + } + return h('g', {}, [ + h('polygon', { ...attrs }) + ] + ) + } +} + +export default { + type: 'triangle', + view: TriangleView, + model: TriangleModel +} \ No newline at end of file diff --git a/admin/src/components/flow/flowEdit/view.vue b/admin/src/components/flow/flowEdit/view.vue new file mode 100644 index 0000000..a82ae2b --- /dev/null +++ b/admin/src/components/flow/flowEdit/view.vue @@ -0,0 +1,227 @@ + + + + + diff --git a/admin/src/install/plugins/element.ts b/admin/src/install/plugins/element.ts index aa44861..10ec7a3 100644 --- a/admin/src/install/plugins/element.ts +++ b/admin/src/install/plugins/element.ts @@ -1,7 +1,7 @@ import * as ElementPlusIcons from '@element-plus/icons-vue' import type { App } from 'vue' //https://github.com/element-plus/element-plus/issues/7293 -import 'element-plus/es/components/dialog/style/css' +// import 'element-plus/es/components/dialog/style/css' export default (app: App) => { // 全局注册ElementPlus图标 diff --git a/admin/src/layout/default/components/header/multiple-tabs.vue b/admin/src/layout/default/components/header/multiple-tabs.vue index 16a5d48..b90df52 100644 --- a/admin/src/layout/default/components/header/multiple-tabs.vue +++ b/admin/src/layout/default/components/header/multiple-tabs.vue @@ -59,7 +59,9 @@ const handleCommand = (command: any) => {