|
@@ -1,3 +1,6 @@
|
|
|
+const PUB_STAMP_SIZE_WIDTH = 5 * 96 / 2.54; // 公章大小:宽度(5 CM)
|
|
|
+const PUB_STAMP_SIZE_HEIGHT = 5 * 96 / 2.54; // 公章大小:高度(5 CM)
|
|
|
+
|
|
|
function getScreenDPI() {
|
|
|
if (SCREEN_DPI.length === 0) {
|
|
|
if (window.screen.deviceXDPI != undefined) {
|
|
@@ -66,4 +69,169 @@ function dynamicLoadJs(url, type, callback) {
|
|
|
};
|
|
|
xhr.send();
|
|
|
});
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+function getProperSignatureArea(cell, control, JV = null) {
|
|
|
+ // 约定默认长宽比例是2:1,图片分辨率是600*300
|
|
|
+ const rst = [0, 0, 0, 0]; // left, top, right, bottom
|
|
|
+ if (JV) {
|
|
|
+ if (cell && cell[JV.PROP_AREA]) {
|
|
|
+ if (cell.hasOwnProperty('isOrgShow') && cell.isOrgShow) {
|
|
|
+ rst[JV.IDX_LEFT] = cell[JV.PROP_AREA][JV.PROP_LEFT];
|
|
|
+ rst[JV.IDX_TOP] = cell[JV.PROP_AREA][JV.PROP_TOP];
|
|
|
+ rst[JV.IDX_RIGHT] = cell[JV.PROP_AREA][JV.PROP_RIGHT];
|
|
|
+ rst[JV.IDX_BOTTOM] = cell[JV.PROP_AREA][JV.PROP_BOTTOM];
|
|
|
+ } else {
|
|
|
+ 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],
|
|
|
+ centerPh = (cell[JV.PROP_AREA][JV.PROP_RIGHT] + cell[JV.PROP_AREA][JV.PROP_LEFT]) / 2,
|
|
|
+ centerPv = (cell[JV.PROP_AREA][JV.PROP_BOTTOM] + cell[JV.PROP_AREA][JV.PROP_TOP]) / 2
|
|
|
+ ;
|
|
|
+ if (width > height * 2) {
|
|
|
+ width = height * 2;
|
|
|
+ } else {
|
|
|
+ height = width / 2;
|
|
|
+ }
|
|
|
+ switch (control[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
|
|
|
+ case 'left':
|
|
|
+ rst[JV.IDX_LEFT] = cell[JV.PROP_AREA][JV.PROP_LEFT];
|
|
|
+ rst[JV.IDX_RIGHT] = rst[0] + width;
|
|
|
+ break;
|
|
|
+ case 'right':
|
|
|
+ rst[JV.IDX_RIGHT] = cell[JV.PROP_AREA][JV.PROP_RIGHT];
|
|
|
+ rst[JV.IDX_LEFT] = rst[JV.IDX_RIGHT] - width;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ //center
|
|
|
+ rst[JV.IDX_LEFT] = centerPh - width / 2;
|
|
|
+ rst[JV.IDX_RIGHT] = centerPh + width / 2;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch (control[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
|
|
|
+ case 'top':
|
|
|
+ rst[JV.IDX_TOP] = cell[JV.PROP_AREA][JV.PROP_TOP];
|
|
|
+ rst[JV.IDX_BOTTOM] = rst[JV.IDX_TOP] + height;
|
|
|
+ break;
|
|
|
+ case 'bottom':
|
|
|
+ rst[JV.IDX_BOTTOM] = cell[JV.PROP_AREA][JV.PROP_BOTTOM];
|
|
|
+ rst[JV.IDX_TOP] = rst[JV.IDX_BOTTOM] - height;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ //center
|
|
|
+ rst[JV.IDX_TOP] = centerPv - height / 2;
|
|
|
+ rst[JV.IDX_BOTTOM] = centerPv + height / 2;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rst[0] = rst[0] + JpcCanvasOutput.offsetX;
|
|
|
+ rst[2] = rst[2] + JpcCanvasOutput.offsetX;
|
|
|
+ rst[1] = rst[1] + JpcCanvasOutput.offsetY;
|
|
|
+ rst[3] = rst[3] + JpcCanvasOutput.offsetY;
|
|
|
+ return rst;
|
|
|
+}
|
|
|
+
|
|
|
+function resetStampArea(ctrl, stampCell, JV, stampFeature = 'not found!') {
|
|
|
+ let pLeft = stampCell.orgArea.Left,
|
|
|
+ pTop = stampCell.orgArea.Top;
|
|
|
+ if (stampFeature !== 'not found!') {
|
|
|
+ let std_stamp_size_width = PUB_STAMP_SIZE_WIDTH, std_stamp_size_height = PUB_STAMP_SIZE_HEIGHT;
|
|
|
+ let widthRate = 1, heightRate = 1;
|
|
|
+ if (stampFeature) {
|
|
|
+ std_stamp_size_width = parseFloat(stampFeature.ImageWidth.value);
|
|
|
+ std_stamp_size_height = parseFloat(stampFeature.ImageHeight.value);
|
|
|
+ if (stampFeature.ImageWidth.value !== stampFeature.ImageHeight.value) {
|
|
|
+ //设置比例
|
|
|
+ if (std_stamp_size_width > std_stamp_size_height) {
|
|
|
+ heightRate = std_stamp_size_height / std_stamp_size_width;
|
|
|
+ } else {
|
|
|
+ widthRate = std_stamp_size_width / std_stamp_size_height;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (std_stamp_size_width > PUB_STAMP_SIZE_WIDTH || std_stamp_size_height > PUB_STAMP_SIZE_HEIGHT) {
|
|
|
+ if (widthRate === 1) {
|
|
|
+ std_stamp_size_width = Math.min(std_stamp_size_width, PUB_STAMP_SIZE_WIDTH);
|
|
|
+ std_stamp_size_height = std_stamp_size_width * heightRate;
|
|
|
+ } else {
|
|
|
+ std_stamp_size_height = Math.min(std_stamp_size_height, PUB_STAMP_SIZE_HEIGHT);
|
|
|
+ std_stamp_size_width = std_stamp_size_height * widthRate;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
|
|
|
+ case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
|
|
|
+ pLeft = stampCell.orgArea.Left;
|
|
|
+ break;
|
|
|
+ case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
|
|
|
+ pLeft = (stampCell.orgArea.Left + stampCell.orgArea.Right - std_stamp_size_width) / 2;
|
|
|
+ break;
|
|
|
+ case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
|
|
|
+ pLeft = stampCell.orgArea.Right - std_stamp_size_width;
|
|
|
+ break;
|
|
|
+ default:break;
|
|
|
+ }
|
|
|
+ switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
|
|
|
+ case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_TOP]:
|
|
|
+ pTop = stampCell.orgArea.Top;
|
|
|
+ break;
|
|
|
+ case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_CENTER]:
|
|
|
+ pTop = (stampCell.orgArea.Top + stampCell.orgArea.Bottom - std_stamp_size_height) / 2;
|
|
|
+ break;
|
|
|
+ case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_BOTTOM]:
|
|
|
+ pTop = stampCell.orgArea.Bottom - std_stamp_size_height;
|
|
|
+ break;
|
|
|
+ default:break;
|
|
|
+ }
|
|
|
+ stampCell.area.Left = pLeft;
|
|
|
+ stampCell.area.Top = pTop;
|
|
|
+ stampCell.area.Right = pLeft + std_stamp_size_width;
|
|
|
+ stampCell.area.Bottom = pTop + std_stamp_size_height;
|
|
|
+ // 最后一步,如超过报表范围,则要调整坐标
|
|
|
+ const maxRect = stampCell.maxRect;
|
|
|
+ if (stampCell.area.Left < maxRect[0]) {
|
|
|
+ const width = maxRect[0] - stampCell.area.Left;
|
|
|
+ stampCell.area.Left += width;
|
|
|
+ stampCell.area.Right += width;
|
|
|
+ }
|
|
|
+ if (stampCell.area.Top < maxRect[1]) {
|
|
|
+ const height = maxRect[1] - stampCell.area.Top;
|
|
|
+ stampCell.area.Top += height;
|
|
|
+ stampCell.area.Bottom += height;
|
|
|
+ }
|
|
|
+ if (stampCell.area.Right > maxRect[2]) {
|
|
|
+ const width = maxRect[2] - stampCell.area.Right; // 负
|
|
|
+ stampCell.area.Left += width;
|
|
|
+ stampCell.area.Right += width;
|
|
|
+ }
|
|
|
+ if (stampCell.area.Bottom > maxRect[3]) {
|
|
|
+ const height = maxRect[3] - stampCell.area.Bottom;
|
|
|
+ stampCell.area.Top += height;
|
|
|
+ stampCell.area.Bottom += height;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function getPicFeature(picPath) {
|
|
|
+ const rst = await getHttpBlobText(picPath + '?x-oss-process=image/info');
|
|
|
+ return rst;
|
|
|
+}
|
|
|
+
|
|
|
+function getHttpBlobText(url) {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
+
|
|
|
+ // let fullUrl = url + '?x-oss-process=image/info';
|
|
|
+ xhr.open('GET', url, true);
|
|
|
+ xhr.responseType = 'json';
|
|
|
+ xhr.onload = () => {
|
|
|
+ if (xhr.status === 200) {
|
|
|
+ resolve(xhr.response);
|
|
|
+ } else {
|
|
|
+ resolve('not found!');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ xhr.send();
|
|
|
+ });
|
|
|
+}
|