|
@@ -349,9 +349,7 @@ function buildCellSvg(cell, fonts, styles, controls, pageMergeBorder, rptMergeBo
|
|
|
return rst.join("");
|
|
|
}
|
|
|
|
|
|
-function buildImage(destRst, cell, control, offsetX, offsetY, HtoVStr, orgSize = false, offsetArea) {
|
|
|
- let href = '';
|
|
|
- const area = getProperSignatureArea(cell, control, offsetX, offsetY);
|
|
|
+function _resetArea(area, orgSize, offsetArea, offsetX, offsetY) {
|
|
|
if (orgSize) {
|
|
|
area[0] = cell[JV.PROP_AREA][JV.PROP_LEFT] + offsetX; // Left
|
|
|
area[1] = cell[JV.PROP_AREA][JV.PROP_TOP] + offsetY; // Top
|
|
@@ -364,13 +362,31 @@ function buildImage(destRst, cell, control, offsetX, offsetY, HtoVStr, orgSize =
|
|
|
area[2] = area[2] - offsetArea[2]; // Right
|
|
|
area[3] = area[3] - offsetArea[3]; // Bottom
|
|
|
}
|
|
|
+}
|
|
|
+function buildImage(destRst, cell, control, offsetX, offsetY, HtoVStr, orgSize = false, offsetArea) {
|
|
|
+ let href = '';
|
|
|
+ let area = getProperSignatureArea(cell, control, offsetX, offsetY, JV);
|
|
|
+ _resetArea(area, orgSize, offsetArea, offsetX, offsetY);
|
|
|
if (cell.pic) {
|
|
|
href = 'href="' + cell.pic +'"';
|
|
|
destRst.push('<image x="' + area[0] + '" y="' + area[1] + '" width="' + (area[2] - area[0]) + '" height="' + (area[3] - area[1]) + '" ');
|
|
|
destRst.push(href + HtoVStr + ' />');
|
|
|
} else {
|
|
|
let paths = cell.path.split('!;!');
|
|
|
- for (let dtlPath of paths) {
|
|
|
+ for (let dtlPathIdx = 0; dtlPathIdx < paths.length; dtlPathIdx++) {
|
|
|
+ let dtlPath = paths[dtlPathIdx];
|
|
|
+ if (cell.picFeatures && cell.picFeatures.length === paths.length) {
|
|
|
+ if (dtlPathIdx === 0) {
|
|
|
+ cell.area = JSON.parse(JSON.stringify(cell.orgArea));
|
|
|
+ cell.isOrgShow = false;
|
|
|
+ } else {
|
|
|
+ // 重新设置cell area
|
|
|
+ resetStampArea(control, cell, JV, cell.picFeatures[dtlPathIdx]);
|
|
|
+ cell.isOrgShow = true;
|
|
|
+ }
|
|
|
+ area = getProperSignatureArea(cell, control, offsetX, offsetY, JV);
|
|
|
+ _resetArea(area, orgSize, offsetArea, offsetX, offsetY);
|
|
|
+ }
|
|
|
if (typeof dtlPath === 'string' && dtlPath.length > 10) {
|
|
|
let imgSrc = dtlPath;
|
|
|
if (dtlPath.indexOf(OSS_PATH) < 0 && dtlPath[0] !== '/') {
|
|
@@ -386,46 +402,6 @@ function buildImage(destRst, cell, control, offsetX, offsetY, HtoVStr, orgSize =
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function getProperSignatureArea(cell, control, offsetX, offsetY) {
|
|
|
- // 约定默认长宽比例是2:1,图片分辨率是600*300
|
|
|
- const rst = [0, 0, 0, 0]; // left, top, right, bottom
|
|
|
- if (cell && cell[JV.PROP_AREA]) {
|
|
|
- let width = cell[JV.PROP_AREA][JV.PROP_RIGHT] - cell[JV.PROP_AREA][JV.PROP_LEFT],
|
|
|
- height = cell[JV.PROP_AREA][JV.PROP_BOTTOM] - cell[JV.PROP_AREA][JV.PROP_TOP];
|
|
|
- if (width > height * 2) {
|
|
|
- width = height * 2;
|
|
|
- } else {
|
|
|
- height = width / 2;
|
|
|
- }
|
|
|
- switch (control[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
|
|
|
- case 'left':
|
|
|
- rst[0] = cell[JV.PROP_AREA][JV.PROP_LEFT];
|
|
|
- rst[1] = cell[JV.PROP_AREA][JV.PROP_TOP];
|
|
|
- rst[2] = rst[0] + width;
|
|
|
- rst[3] = rst[1] + height;
|
|
|
- break;
|
|
|
- case 'right':
|
|
|
- rst[2] = cell[JV.PROP_AREA][JV.PROP_RIGHT];
|
|
|
- rst[3] = cell[JV.PROP_AREA][JV.PROP_BOTTOM];
|
|
|
- rst[0] = rst[2] - width;
|
|
|
- rst[1] = rst[3] - height;
|
|
|
- break;
|
|
|
- default:
|
|
|
- //center
|
|
|
- rst[0] = (cell[JV.PROP_AREA][JV.PROP_LEFT] + cell[JV.PROP_AREA][JV.PROP_RIGHT] - width) / 2;
|
|
|
- rst[1] = cell[JV.PROP_AREA][JV.PROP_TOP];
|
|
|
- rst[2] = rst[0] + width;
|
|
|
- rst[3] = rst[1] + height;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- rst[0] = rst[0] + offsetX;
|
|
|
- rst[2] = rst[2] + offsetX;
|
|
|
- rst[1] = rst[1] + offsetY;
|
|
|
- rst[3] = rst[3] + offsetY;
|
|
|
- return rst;
|
|
|
-}
|
|
|
-
|
|
|
function strReplaceAll(targetStr, FindText, RepText) {
|
|
|
let regExp = new RegExp(FindText, "gm");
|
|
|
return targetStr.replace(regExp, RepText);
|