Commit 2a00e476 authored by 邓超's avatar 邓超

fix: 流程中心生成图片优化

parent 14dfe865
Pipeline #68430 passed with stages
This diff was suppressed by a .gitattributes entry.
...@@ -443,14 +443,18 @@ const WorkflowHomePage = () => { ...@@ -443,14 +443,18 @@ const WorkflowHomePage = () => {
{/* <DeleteOutlined onClick={e => delFlow(ele, e)} /> */} {/* <DeleteOutlined onClick={e => delFlow(ele, e)} /> */}
</div> </div>
</div> </div>
{ele.PreviewImage ? (
<img <img
src={`${ src={`${
window.location.origin window.location.origin
}/PandaOMS/OMS/FileCenter/DownLoadFiles?filePath=${ }/PandaOMS/OMS/FileCenter/DownLoadFiles?filePath=${ele.PreviewImage}`}
ele.PreviewImage
}&v=${new Date().getTime()}`}
alt=""
/> />
) : (
<img
className={styles.noDataImg}
src={require('../../../../assets/images/common/noData.png')}
/>
)}
</div> </div>
<div className={styles.bottom}> <div className={styles.bottom}>
<div className={styles.left}>{ele.CreateUser || ''}</div> <div className={styles.left}>{ele.CreateUser || ''}</div>
......
...@@ -318,7 +318,11 @@ ...@@ -318,7 +318,11 @@
overflow: hidden; overflow: hidden;
img { img {
width: 320px; width: 270px;
}
.noDataImg {
width: 120px;
height: 112px;
} }
} }
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
DeleteFlowNodes, DeleteFlowNodes,
SaveWorkFlowImage, SaveWorkFlowImage,
} from '@/services/workflow/workflow'; } from '@/services/workflow/workflow';
import { compress } from '@/utils/utils';
import { ExclamationCircleOutlined, TrophyOutlined } from '@ant-design/icons'; import { ExclamationCircleOutlined, TrophyOutlined } from '@ant-design/icons';
import * as go from 'gojs'; import * as go from 'gojs';
import styles from './FlowBoard.less'; import styles from './FlowBoard.less';
...@@ -968,12 +968,18 @@ const FlowChart = props => { ...@@ -968,12 +968,18 @@ const FlowChart = props => {
); );
}; };
const nodeCallBack = () => { const nodeCallBack = () => {
SaveWorkFlowImage({ compress(
flowName: flowData.flowName, diagram.makeImageData({
base64Data: diagram.makeImageData({
background: 'rgb(239, 248, 250)', background: 'rgb(239, 248, 250)',
maxSize: new go.Size(1260, 500), // maxSize: new go.Size(1260, 500), // 固定区域
scale: 1, // 有效区域
}), }),
1.2, // 压缩比例
base64 => {
console.log(base64);
SaveWorkFlowImage({
flowName: flowData.flowName,
base64Data: base64,
}).then(response => { }).then(response => {
if (response.code === 0) { if (response.code === 0) {
FlowNodeSave({ FlowNodeSave({
...@@ -991,7 +997,11 @@ const FlowChart = props => { ...@@ -991,7 +997,11 @@ const FlowChart = props => {
'FlowTimerList', 'FlowTimerList',
res.data.FlowTimerList, res.data.FlowTimerList,
); );
diagram.model.setDataProperty(currentNode.current, 'ActivityId', res.data.ActivityId); diagram.model.setDataProperty(
currentNode.current,
'ActivityId',
res.data.ActivityId,
);
diagram.model.setDataProperty( diagram.model.setDataProperty(
currentNode.current, currentNode.current,
'FlowNodeExtendId', 'FlowNodeExtendId',
...@@ -1004,6 +1014,8 @@ const FlowChart = props => { ...@@ -1004,6 +1014,8 @@ const FlowChart = props => {
}); });
} }
}); });
},
);
}; };
// 关闭时进行数据比对看数据是否改变 // 关闭时进行数据比对看数据是否改变
const leaveTip = () => { const leaveTip = () => {
...@@ -1126,12 +1138,18 @@ const FlowChart = props => { ...@@ -1126,12 +1138,18 @@ const FlowChart = props => {
return; return;
} }
setButtonLoading(true); setButtonLoading(true);
SaveWorkFlowImage({ compress(
flowName: flowData.flowName, diagram.makeImageData({
base64Data: diagram.makeImageData({
background: 'rgb(239, 248, 250)', background: 'rgb(239, 248, 250)',
maxSize: new go.Size(1260, 500), // maxSize: new go.Size(1260, 500), // 固定区域
scale: 1, // 有效区域
}), }),
1.2, // 压缩比例
base64 => {
console.log(base64);
SaveWorkFlowImage({
flowName: flowData.flowName,
base64Data: base64,
}).then(val => { }).then(val => {
if (val.code === 0) { if (val.code === 0) {
SaveNodeChange({ SaveNodeChange({
...@@ -1163,6 +1181,8 @@ const FlowChart = props => { ...@@ -1163,6 +1181,8 @@ const FlowChart = props => {
}); });
} }
}); });
},
);
}; };
const treeChange = newValue => { const treeChange = newValue => {
setSelectValue(newValue); setSelectValue(newValue);
......
export function compress(
base64, // 源图片
rate, // 缩放比例
callback, // 回调
) {
//处理缩放,转格式
var _img = new Image();
_img.src = base64;
_img.onload = function() {
var _canvas = document.createElement('canvas');
var w = this.width / rate;
var h = this.height / rate;
_canvas.setAttribute('width', w);
_canvas.setAttribute('height', h);
_canvas.getContext('2d').drawImage(this, 0, 0, w, h);
var base64 = _canvas.toDataURL('image/jpeg');
_canvas.toBlob(function(blob) {
if (blob.size > 750 * 1334) {
//如果还大,继续压缩
compress(base64, rate, callback);
} else {
callback(base64);
}
}, 'image/jpeg');
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment