From 54a24ed07773600817ef271fbdce74670566a5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=86=E4=B8=AA=E7=99=BD?= <543593352@qq.com> Date: Mon, 23 Sep 2024 15:33:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AE=BE=E8=AE=A1=EF=BC=9A?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E6=A2=B3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 8 + src/renderer/src/api/classTask/index.js | 96 +++++ .../components/Flowchart/FlowContentMenu.vue | 100 +++++ .../src/components/Flowchart/FlowDrawer.vue | 91 ++++ .../src/components/Flowchart/FlowLibrary.vue | 235 +++++++++++ .../src/components/Flowchart/config/index.js | 333 +++++++++++++++ .../src/components/Flowchart/index.vue | 391 ++++++++++++++++++ .../container/newTask/taskTypeView.vue | 391 +++++++++++++----- 8 files changed, 1545 insertions(+), 100 deletions(-) create mode 100644 src/renderer/src/components/Flowchart/FlowContentMenu.vue create mode 100644 src/renderer/src/components/Flowchart/FlowDrawer.vue create mode 100644 src/renderer/src/components/Flowchart/FlowLibrary.vue create mode 100644 src/renderer/src/components/Flowchart/config/index.js create mode 100644 src/renderer/src/components/Flowchart/index.vue diff --git a/package.json b/package.json index 825ea85..9f245d7 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,14 @@ "@electron/remote": "^2.1.2", "@element-plus/icons-vue": "^2.3.1", "@vitejs/plugin-vue-jsx": "^4.0.0", + "@antv/x6": "^2.18.1", + "@antv/x6-plugin-clipboard": "^2.1.6", + "@antv/x6-plugin-dnd": "^2.1.1", + "@antv/x6-plugin-export": "^2.1.6", + "@antv/x6-plugin-keyboard": "^2.2.3", + "@antv/x6-plugin-selection": "^2.2.2", + "@antv/x6-plugin-snapline": "^2.1.7", + "@antv/x6-plugin-transform": "^2.1.8", "@vue-office/docx": "^1.6.2", "@vue-office/excel": "^1.7.11", "@vue-office/pdf": "^2.0.2", diff --git a/src/renderer/src/api/classTask/index.js b/src/renderer/src/api/classTask/index.js index 9f2c110..8f8672b 100644 --- a/src/renderer/src/api/classTask/index.js +++ b/src/renderer/src/api/classTask/index.js @@ -71,3 +71,99 @@ export function updateClasswork(data) { data: data }) } + + + +// 查询evaluationclue列表 +export function listEvaluationclue(query) { + return request({ + url: '/education/evaluationclue/list', + method: 'get', + params: query + }) +} + +// 查询evaluationclue详细 +export function getEvaluationclue(id) { + return request({ + url: '/education/evaluationclue/' + id, + method: 'get' + }) +} + +// 新增evaluationclue +export function addEvaluationclueReturnId(data) { + return request({ + url: '/education/evaluationclue/addReturnId', + method: 'post', + data: data + }) +} + +// 新增evaluationclue +export function addEvaluationclue(data) { + return request({ + url: '/education/evaluationclue', + method: 'post', + data: data + }) +} + +// 修改evaluationclue +export function updateEvaluationclue(data) { + return request({ + url: '/education/evaluationclue', + method: 'put', + data: data + }) +} + +// 删除evaluationclue +export function delEvaluationclue(id) { + return request({ + url: '/education/evaluationclue/' + id, + method: 'delete' + }) +} + +// 新增evaluationclue,保存base64图片 +export function saveBase64File(data) { + return request({ + url: '/education/evaluationclue/saveBase64File', + method: 'post', + data: data + }) +} + +// 新增evaluationclue,上传 +export function saveEvaluationClueUploadFile(data) { + return request({ + url: '/education/evaluationclue/saveUploadFile', + method: 'post', + data: data + }) +} + +// 读取文件内容 +export function readFile(data) { + return fetch(import.meta.env.VITE_APP_RES_FILE_PATH + data.cluelink, { + method: "get", + headers: { + 'Content-Type': 'text/plain', // 请求头设置为纯文本 + 'Accept': 'text/plain' // 接受头设置为纯文本 + }, + }) + .then(response => response.text()) + .then(text => { + return Promise.resolve(text); + }) + .catch(error => { + console.error('读取文件出错:', error); + return Promise.reject(); + }); + /*return request({ + url: '/education/evaluationclue/readFile', + method: 'post', + data: data + })*/ +} diff --git a/src/renderer/src/components/Flowchart/FlowContentMenu.vue b/src/renderer/src/components/Flowchart/FlowContentMenu.vue new file mode 100644 index 0000000..f2b6da8 --- /dev/null +++ b/src/renderer/src/components/Flowchart/FlowContentMenu.vue @@ -0,0 +1,100 @@ + + + + + + \ No newline at end of file diff --git a/src/renderer/src/components/Flowchart/FlowDrawer.vue b/src/renderer/src/components/Flowchart/FlowDrawer.vue new file mode 100644 index 0000000..ff0f67e --- /dev/null +++ b/src/renderer/src/components/Flowchart/FlowDrawer.vue @@ -0,0 +1,91 @@ + + + + + \ No newline at end of file diff --git a/src/renderer/src/components/Flowchart/FlowLibrary.vue b/src/renderer/src/components/Flowchart/FlowLibrary.vue new file mode 100644 index 0000000..5359e6b --- /dev/null +++ b/src/renderer/src/components/Flowchart/FlowLibrary.vue @@ -0,0 +1,235 @@ + + + + \ No newline at end of file diff --git a/src/renderer/src/components/Flowchart/config/index.js b/src/renderer/src/components/Flowchart/config/index.js new file mode 100644 index 0000000..cb4f29a --- /dev/null +++ b/src/renderer/src/components/Flowchart/config/index.js @@ -0,0 +1,333 @@ + +import { Shape } from '@antv/x6' +/** + * @desc 初始化面板配置 + * @param check 查看模式 + */ +export const graphOptions = (check = false) => { + return { + container: document.getElementById('flow-container'), + // 定制节点和边的交互行为 ==> boolean 节点或边是否可交互 + interacting: check + ? { + nodeMovable: false, + edgeMovable: false, + magnetConnectable: false, + vertexDeletable: false + } + : true, + // 对齐线 + snapline: true, + // 显示网格 // 'dot' | 'fixedDot' | 'mesh' + grid: { + visible: true, + size: 20, // 网格大小 + type: 'mesh', + args: { + color: '#e9e9e9', + thickness: 2 // 网格线宽度/网格点大小 + } + }, + // 平移 + panning: true, + // 滚轮缩放 MouseWheel + mousewheel: { + enabled: true, + zoomAtMousePosition: true, + modifiers: ['ctrl', 'meta'], + maxScale: 3, + minScale: 0.3 + }, + // 连线规则 + connecting: { + // 路由类型 + router: { + // 连线类型在此修改 + // 曼哈顿路由 'manhattan' 路由是正交路由 'orth' 的智能版本,该路由由水平或垂直的正交线段组成,并自动避开路径上的其他节点(障碍)。 + name: 'manhattan', + args: { + padding: 1 + } + }, + // 圆角连接器,将起点、路由点、终点通过直线按顺序连接,并在线段连接处通过圆弧连接(倒圆角)。 + connector: { + name: 'rounded', + args: { + radius: 8 + } + }, + anchor: 'center', + connectionPoint: 'anchor', + // 是否允许连接到画布空白位置的点,默认为 true。 + allowBlank: false, + // 距离节点或者连接桩 20px 时会触发自动吸附 + snap: { + radius: 20 + }, + // 拽出新的边 + createEdge() { + return new Shape.Edge({ + // markup: [ + // { + // tagName: 'path', + // selector: 'stroke' + // } + // ], + // connector: { name: 'rounded' }, + // attrs: { + // stroke: { + // fill: 'none', + // connection: true, + // strokeWidth: 4, + // strokeLinecap: 'round', + // stroke: '#666' + // } + // }, + attrs: { + line: { + stroke: '#A2B1C3', + strokeWidth: 3, + targetMarker: { + name: 'block', + width: 12, + height: 8, + }, + }, + }, + zIndex: 0 + }) + }, + validateConnection({ targetMagnet }) { + return !!targetMagnet + } + }, + // 连线高亮 + highlighting: { + // 连线过程中,自动吸附到链接桩时被使用。 + magnetAdsorbed: { + name: 'stroke', + args: { + attrs: { + width: 12, + r: 6, + magnet: true, + stroke: '#008CFF', + strokeWidth: 2, + fill: '#0F67FF' + } + } + } + }, + rotating: false, // 不能旋转 + keyboard: !check, // 按键操作 + clipboard: true, // 剪切板 + autoResize: true, + onToolItemCreated({ tool }) { + const options = tool.options + if (options && options.index % 2 === 1) { + tool.setAttrs({ fill: 'red' }) + } + } + } +} + +// 链接桩样式 +export const portStyle = { + // width: 12, + // r: 6, // 半径 + // // 当 magnet 属性为 true 时,表示该元素可以被链接,即在连线过程中可以被当做连线的起点或终点,与链接桩类似。 + // magnet: true, + // stroke: '#008CFF', + // strokeWidth: 2, + // fill: '#fff', + // zIndex: 1, + // style: { + // visibility: 'hidden', + // }, + r: 6, + magnet: true, + stroke: '#5F95FF', + strokeWidth: 2, + fill: '#fff', + style: { + visibility: 'hidden', + }, +} + +// 链接桩配置 +export const ports = { + // 设置链接桩分组 + groups: { + top: { + // 定义连接柱的位置,如果不配置,将显示为默认样式 + position: 'top', + // 定义连接柱的样式 + attrs: { + circle: { + ...portStyle + } + } + }, + right: { + position: 'right', + attrs: { + circle: { + ...portStyle + } + } + }, + bottom: { + position: 'bottom', + attrs: { + circle: { + ...portStyle + } + } + }, + left: { + position: 'left', + attrs: { + circle: { + ...portStyle + } + } + }, + absolute: { + position: 'absolute', + attrs: { + circle: { + r: 6, + magnet: true, + stroke: '#008CFF', + strokeWidth: 2, + fill: '#fff' + } + } + } + }, + // 链接桩 + items: [ + { + group: 'top' + }, + { + group: 'right' + }, + { + group: 'bottom' + }, + { + group: 'left' + } + ] +} + +// 动态计算宽高比 +export const transformToPercent = (target, sum, font) => { + // https://x6.antv.vision/zh/docs/tutorial/intermediate/attrs + // 相对节点的大小 + const percent = (target / sum).toFixed(2) * 100 + return `${percent}${font ? 'px' : '%'}` +} + +// 注册节点配置信息 注册以后就可以像使用内置节点那样使用该节点 +export const registerNodeOpeions = { + 'custom-rect': { + inherit: 'rect', + width: 70, + height: 40, + attrs: { + body: { + strokeWidth: 1, + stroke: '#5F95FF', + fill: '#EFF4FF', + }, + text: { + fontSize: 12, + fill: '#262626', + }, + }, + ports: { ...ports }, + }, + 'custom-polygon' : { + inherit: 'polygon', + width: 70, + height: 40, + attrs: { + body: { + strokeWidth: 1, + stroke: '#5F95FF', + fill: '#EFF4FF', + }, + text: { + fontSize: 12, + fill: '#262626', + }, + }, + ports: { + ...ports, + items: [ + { + group: 'top', + }, + { + group: 'bottom', + }, + ], + }, + }, + 'custom-circle' : { + inherit: 'circle', + width: 50, + height: 50, + attrs: { + body: { + strokeWidth: 1, + stroke: '#5F95FF', + fill: '#EFF4FF', + }, + text: { + fontSize: 12, + fill: '#262626', + }, + }, + ports: { ...ports }, + }, +} + +// 图形变换配置 +export const transFormOptions = { + // 调整尺寸 + resizing: { + enabled: true, + minWidth: 1, + maxWidth: 200, + minHeight: 1, + maxHeight: 150, + restrict: false, + preserveAspectRatio: false, + }, + // 调整角度---旋转 + rotating: { + enabled: true, + } +} + +// 拖动添加节点样式配置 +export const addNodeAttrStyle = { + '可选过程': { + rx: 6, + ry: 6, + }, + '开始': { + rx: 20, + ry: 26, + }, + '决策': { + refPoints: '0,10 10,0 20,10 10,20', + }, + '数据': { + refPoints: '10,0 40,0 30,20 0,20', + } + +} \ No newline at end of file diff --git a/src/renderer/src/components/Flowchart/index.vue b/src/renderer/src/components/Flowchart/index.vue new file mode 100644 index 0000000..d808786 --- /dev/null +++ b/src/renderer/src/components/Flowchart/index.vue @@ -0,0 +1,391 @@ + + + + + \ No newline at end of file diff --git a/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue b/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue index a2b83bf..2765b7c 100644 --- a/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue +++ b/src/renderer/src/views/classTask/container/newTask/taskTypeView.vue @@ -19,6 +19,7 @@ +
@@ -114,37 +115,38 @@ @pagination="getPaginationList" />
--> - +
-