|
@@ -21,7 +21,7 @@ let rptTplObj = {
|
|
|
zTreeOprObj.getReportTemplateTree();
|
|
|
zTreeOprObj.selectedPrjIDs = [];
|
|
|
me.hasInitialized = true;
|
|
|
- // let canvas = document.getElementById("rptCanvas");
|
|
|
+ zTreeOprObj.canvas = document.getElementById("rptCanvas");
|
|
|
// canvas.onclick = canvasOprObj.canvasOnClick;
|
|
|
// canvas.onmousemove = canvasOprObj.canvasOnMouseMove;
|
|
|
}
|
|
@@ -32,11 +32,14 @@ let zTreeOprObj = {
|
|
|
treeObj: null,
|
|
|
prjFolderTreeObj: null,
|
|
|
currentNode: null,
|
|
|
+ currentSelectedESignAccDom: null,
|
|
|
+ currentSelectedESignAccName: null,
|
|
|
checkedRptTplNodes: null,
|
|
|
currentRptPageRst: null,
|
|
|
defReportPageCfg: null,
|
|
|
currentPage: 1,
|
|
|
maxPages: 0,
|
|
|
+ canvas: null,
|
|
|
selectedPrjIDs: [],
|
|
|
countChkedRptTpl: function () {
|
|
|
let me = zTreeOprObj;
|
|
@@ -55,6 +58,9 @@ let zTreeOprObj = {
|
|
|
cnt++;
|
|
|
me.checkedRptTplNodes.push(me.currentNode);
|
|
|
}
|
|
|
+ $("#print_div").find("span").each(function(cIdx,elementSpan){
|
|
|
+ elementSpan.innerText = cnt;
|
|
|
+ });
|
|
|
$("#export_div").find("span").each(function(cIdx,elementSpan){
|
|
|
elementSpan.innerText = cnt;
|
|
|
});
|
|
@@ -237,7 +243,7 @@ let zTreeOprObj = {
|
|
|
function(result){
|
|
|
// hintBox.unWaitBox();
|
|
|
let pageRst = result.data;
|
|
|
- let canvas = document.getElementById("rptCanvas");
|
|
|
+ let canvas = zTreeOprObj.canvas;
|
|
|
if (pageRst && pageRst.items && pageRst.items.length > 0) {
|
|
|
me.resetAfter(pageRst);
|
|
|
me.currentRptPageRst = pageRst;
|
|
@@ -251,6 +257,8 @@ let zTreeOprObj = {
|
|
|
} else {
|
|
|
canvas.height = size[1] + 50;
|
|
|
}
|
|
|
+ me.resetESignature(pageRst);
|
|
|
+ me.buildSelectableAccount();
|
|
|
me.showPage(1, canvas);
|
|
|
} else {
|
|
|
//返回了无数据表
|
|
@@ -264,9 +272,124 @@ let zTreeOprObj = {
|
|
|
}
|
|
|
);
|
|
|
},
|
|
|
+ resetESignature: function (pageRst) {
|
|
|
+ let body = $('#eSignatureBodyDiv');
|
|
|
+ body.empty();
|
|
|
+ const signature_cells = [];
|
|
|
+ const singatureNameArr = [];
|
|
|
+ for (const page of pageRst.items) {
|
|
|
+ if (page.signature_cells) {
|
|
|
+ for (const sCell of page.signature_cells) {
|
|
|
+ if (singatureNameArr.indexOf(sCell.signature_name) < 0) {
|
|
|
+ signature_cells.push(sCell);
|
|
|
+ singatureNameArr.push(sCell.signature_name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (signature_cells.length > 0) {
|
|
|
+ const elementsStrArr = [];
|
|
|
+ for (const sCell of signature_cells) {
|
|
|
+ elementsStrArr.push('<div class="form-group row">');
|
|
|
+ elementsStrArr.push('<label for="staticEmail" class="col-sm-3 col-form-label pr-0">' + sCell.signature_name + '</label>');
|
|
|
+ elementsStrArr.push('<div class="col-sm-9">');
|
|
|
+ elementsStrArr.push('<ul class="list-group">');
|
|
|
+ elementsStrArr.push('<li class="list-group-item">');
|
|
|
+ if (sCell.path || sCell.pic) {
|
|
|
+ //
|
|
|
+ } else {
|
|
|
+ elementsStrArr.push('<a href="#add-sign" onclick="zTreeOprObj.currentSelectedESignAccDom = this; zTreeOprObj.currentSelectedESignAccName = \'' + sCell.signature_name + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签名</a>');
|
|
|
+ }
|
|
|
+ elementsStrArr.push('</li>');
|
|
|
+ elementsStrArr.push('</ul>');
|
|
|
+ elementsStrArr.push('</div>');
|
|
|
+ elementsStrArr.push('</div>');
|
|
|
+ }
|
|
|
+ body.append(elementsStrArr.join(' '));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ buildSelectableAccount: function () {
|
|
|
+ //PRJ_ACCOUNT_LIST
|
|
|
+ //1. 清理所有选择项
|
|
|
+ // $("#project_account_select_div").empty();
|
|
|
+ let accDiv = $('#project_account_select_div');
|
|
|
+ accDiv.empty();
|
|
|
+ //2. 一个个加可选用户项
|
|
|
+ const prj_accounts = [];
|
|
|
+ const acc_role_keys = [];
|
|
|
+ for (const prjAccount of PRJ_ACCOUNT_LIST) {
|
|
|
+ let companyKey = prjAccount.company;
|
|
|
+ let roleKey = prjAccount.role;
|
|
|
+ if (companyKey === '') {
|
|
|
+ companyKey = '其他单位';
|
|
|
+ }
|
|
|
+ if (roleKey === '') {
|
|
|
+ roleKey = '工程师';
|
|
|
+ }
|
|
|
+ let keyIdx = acc_role_keys.indexOf(companyKey);
|
|
|
+ if (keyIdx < 0) {
|
|
|
+ acc_role_keys.push(companyKey);
|
|
|
+ prj_accounts.push([]);
|
|
|
+ keyIdx = prj_accounts.length - 1;
|
|
|
+ //这里先push一些 html prefix,在后面统一在push html suffix
|
|
|
+ prj_accounts[keyIdx].push('<ul class="list-group">');
|
|
|
+ prj_accounts[keyIdx].push('<li class="px-2 text-muted"><i class="fa fa-caret-down"></i> ' + companyKey + '</li>');
|
|
|
+ }
|
|
|
+ //push item
|
|
|
+ prj_accounts[keyIdx].push('<li class="add-sign-list-item"><a onclick="zTreeOprObj.drawEsignature(' + keyIdx + ')" class="btn-link pull-right" title="添加" data-dismiss="modal"><i class="fa fa-plus"></i></a>' +
|
|
|
+ prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
|
|
|
+ }
|
|
|
+ for (const prjAccList of prj_accounts) {
|
|
|
+ prjAccList.push('</ul>');
|
|
|
+ }
|
|
|
+ for (let idx = 0; idx < prj_accounts.length; idx++) {
|
|
|
+ prj_accounts[idx] = prj_accounts[idx].join('');
|
|
|
+ }
|
|
|
+ accDiv.append(prj_accounts.join(''));
|
|
|
+ },
|
|
|
+ drawEsignature: function (accIdx) {
|
|
|
+ let dftSignSrc = '/public/images/user-sign.PNG';
|
|
|
+ if (PRJ_ACCOUNT_LIST[accIdx].sign_path !== '') {
|
|
|
+ dftSignSrc = PRJ_ACCOUNT_LIST[accIdx].sign_path;
|
|
|
+ }
|
|
|
+ //找到相关签名地方,stamp!
|
|
|
+ if (zTreeOprObj.currentSelectedESignAccName !== null) {
|
|
|
+ for (const page of zTreeOprObj.currentRptPageRst.items) {
|
|
|
+ if (page.signature_cells) {
|
|
|
+ for (const sCell of page.signature_cells) {
|
|
|
+ if (sCell.signature_name === zTreeOprObj.currentSelectedESignAccName) {
|
|
|
+ sCell.path = dftSignSrc;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 1. 删除不需要的child dom
|
|
|
+ let list = zTreeOprObj.currentSelectedESignAccDom.childNodes;
|
|
|
+ if (list && list.length > 0) {
|
|
|
+ for (let domIdx = list.length - 1; domIdx >= 0; domIdx--) {
|
|
|
+ zTreeOprObj.currentSelectedESignAccDom.removeChild(list[domIdx]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2. 创建已选择签名相关 dom
|
|
|
+ // let newDomArr = [];
|
|
|
+ // 2.1 canvas
|
|
|
+ let canvasNode = document.createElement("CANVAS");
|
|
|
+ canvasNode.height = "30";
|
|
|
+ canvasNode.style = "width: 100%";
|
|
|
+ //newDomArr.push('<canvas height="30" style="width: 100%"></canvas>');
|
|
|
+ zTreeOprObj.currentSelectedESignAccDom.appendChild(canvasNode);
|
|
|
+ let imgObj = new Image();
|
|
|
+ imgObj.src = dftSignSrc;
|
|
|
+ imgObj.onload = function(){
|
|
|
+ let ctx = canvasNode.getContext('2d');
|
|
|
+ ctx.drawImage(this, 0, 0, 60, 30);
|
|
|
+ }
|
|
|
+ // 2.2 date-picker
|
|
|
+ }
|
|
|
+ },
|
|
|
scaleReport: function (accScale) {
|
|
|
let me = zTreeOprObj;
|
|
|
- let canvas = document.getElementById("rptCanvas");
|
|
|
+ let canvas = zTreeOprObj.canvas;
|
|
|
if (accScale !== 0) {
|
|
|
JpcCanvasOutput.scaleFactor += accScale;
|
|
|
if (JpcCanvasOutput.scaleFactor < 0.5) JpcCanvasOutput.scaleFactor = 0.5;
|
|
@@ -278,197 +401,7 @@ let zTreeOprObj = {
|
|
|
me.showPage(me.currentPage, canvas);
|
|
|
},
|
|
|
requestPrjFolderCommon: function () {
|
|
|
- // let me = zTreeOprObj;
|
|
|
- // hintBox.waitBox();
|
|
|
- // $.ajax({
|
|
|
- // type:"POST",
|
|
|
- // url: '/pm/api/getProjects',
|
|
|
- // data: {'data': JSON.stringify({"user_id": userID, "compilation": projectObj.project.projectInfo.compilation})},
|
|
|
- // dataType: 'json',
|
|
|
- // cache: false,
|
|
|
- // timeout: 15000,
|
|
|
- // success: function(result){
|
|
|
- // hintBox.unWaitBox();
|
|
|
- // if (result.error === 0) {
|
|
|
- // //console.log(result.data);
|
|
|
- // let currPrjParentID = projectObj.project.projectInfo.ParentID;
|
|
|
- // let selectedProjects = [];
|
|
|
- // for (let prj of result.data) {
|
|
|
- // if (currPrjParentID === prj.ParentID) {
|
|
|
- // selectedProjects.push({name: prj.name, ID: prj.ID});
|
|
|
- // }
|
|
|
- // }
|
|
|
- // $("#show_project_folder").trigger("click");
|
|
|
- // me.prjFolderTreeObj = $.fn.zTree.init($("#prjFolderTree"), rpt_prj_folder_setting, selectedProjects);
|
|
|
- // me.prjFolderTreeObj.expandAll(true);
|
|
|
- // } else {
|
|
|
- // alert('error: ' + result.message);
|
|
|
- // }
|
|
|
- // },
|
|
|
- // error: function(jqXHR, textStatus, errorThrown){
|
|
|
- // hintBox.unWaitBox();
|
|
|
- // alert('error ' + textStatus + " " + errorThrown);
|
|
|
- // }
|
|
|
- // });
|
|
|
- },
|
|
|
- requestBillsSummaryRpt: function () {
|
|
|
- let me = zTreeOprObj;
|
|
|
- let nodes = me.prjFolderTreeObj.getCheckedNodes(true);
|
|
|
- if (nodes.length > 0) {
|
|
|
- hintBox.waitBox();
|
|
|
- let params = {};
|
|
|
- params.pageSize = rptControlObj.getCurrentPageSize();
|
|
|
- params.rpt_tpl_id = me.currentNode.refId;
|
|
|
- params.custCfg = CUST_CFG;
|
|
|
- params.prjIds = [];
|
|
|
- me.selectedPrjIDs = [];
|
|
|
- for (let node of nodes) {
|
|
|
- params.prjIds.push(node.ID);
|
|
|
- me.selectedPrjIDs.push(node.ID);
|
|
|
- }
|
|
|
- CommonAjax.postEx("report_api/getBillsSummaryReport", params, 26000, true,
|
|
|
- function(result){
|
|
|
- hintBox.unWaitBox();
|
|
|
- let pageRst = result;
|
|
|
- let canvas = document.getElementById("rptCanvas");
|
|
|
- if (pageRst && pageRst.items && pageRst.items.length > 0) {
|
|
|
- me.resetAfter(pageRst);
|
|
|
- me.currentRptPageRst = pageRst;
|
|
|
- me.maxPages = pageRst.items.length;
|
|
|
- me.currentPage = 1;
|
|
|
- me.displayPageValue();
|
|
|
- let size = JpcCanvasOutput.getReportSizeInPixel(me.currentRptPageRst, getScreenDPI());
|
|
|
- canvas.width = size[0] + 20;
|
|
|
- if (size[1] > size[0]) {
|
|
|
- canvas.height = size[1] + 100;
|
|
|
- } else {
|
|
|
- canvas.height = size[1] + 50;
|
|
|
- }
|
|
|
- me.showPage(1, canvas);
|
|
|
- } else {
|
|
|
- //返回了无数据表
|
|
|
- JpcCanvasOutput.cleanCanvas(canvas);
|
|
|
- JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
|
|
|
- }
|
|
|
- }, function(err){
|
|
|
- hintBox.unWaitBox();
|
|
|
- }, function(ex){
|
|
|
- hintBox.unWaitBox();
|
|
|
- }
|
|
|
- );
|
|
|
- }
|
|
|
- },
|
|
|
- requestGljSummaryRpt: function () {
|
|
|
- let me = zTreeOprObj;
|
|
|
- let nodes = me.prjFolderTreeObj.getCheckedNodes(true);
|
|
|
- if (nodes.length > 0) {
|
|
|
- hintBox.waitBox();
|
|
|
- let params = {};
|
|
|
- params.pageSize = rptControlObj.getCurrentPageSize();
|
|
|
- params.rpt_tpl_id = me.currentNode.refId;
|
|
|
- params.custCfg = CUST_CFG;
|
|
|
- params.prjIds = [];
|
|
|
- zTreeOprObj.selectedPrjIDs = [];
|
|
|
- for (let node of nodes) {
|
|
|
- params.prjIds.push(node.ID);
|
|
|
- zTreeOprObj.selectedPrjIDs.push(node.ID);
|
|
|
- }
|
|
|
- CommonAjax.postEx("report_api/getGljSummaryReport", params, 26000, true,
|
|
|
- function(result){
|
|
|
- hintBox.unWaitBox();
|
|
|
- let pageRst = result;
|
|
|
- let canvas = document.getElementById("rptCanvas");
|
|
|
- if (pageRst && pageRst.items && pageRst.items.length > 0) {
|
|
|
- me.resetAfter(pageRst);
|
|
|
- me.currentRptPageRst = pageRst;
|
|
|
- me.maxPages = pageRst.items.length;
|
|
|
- me.currentPage = 1;
|
|
|
- me.displayPageValue();
|
|
|
- let size = JpcCanvasOutput.getReportSizeInPixel(me.currentRptPageRst, getScreenDPI());
|
|
|
- canvas.width = size[0] + 20;
|
|
|
- if (size[1] > size[0]) {
|
|
|
- canvas.height = size[1] + 100;
|
|
|
- } else {
|
|
|
- canvas.height = size[1] + 50;
|
|
|
- }
|
|
|
- me.showPage(1, canvas);
|
|
|
- } else {
|
|
|
- //返回了无数据表
|
|
|
- JpcCanvasOutput.cleanCanvas(canvas);
|
|
|
- JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
|
|
|
- }
|
|
|
- }, function(err){
|
|
|
- hintBox.unWaitBox();
|
|
|
- }, function(ex){
|
|
|
- hintBox.unWaitBox();
|
|
|
- }
|
|
|
- );
|
|
|
- }
|
|
|
- },
|
|
|
- requestSumAndNormalRptForPDF: function () {
|
|
|
- let rpt_names = [], bill_rpt_names = [], glj_rpt_names = [];
|
|
|
- let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
|
|
|
- rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, rpt_names, bill_rpt_names, glj_rpt_names);
|
|
|
- let params = rptControlObj.creatCommonExportParam(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
|
|
|
- params.sum_rpt_names = bill_rpt_names.concat(glj_rpt_names);
|
|
|
- params.rpt_names = rpt_names;
|
|
|
- params.isOneSheet = true;
|
|
|
-
|
|
|
- CommonAjax.postEx("report_api/createPdfFiles", params, WAIT_TIME_EXPORT, true, function(result){
|
|
|
- if (result) {
|
|
|
- let uuIdUrls = [];
|
|
|
- for (let uuIdObj of result) {
|
|
|
- let uuIdUrl = "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/pdf";
|
|
|
- uuIdUrls.push(uuIdUrl);
|
|
|
- }
|
|
|
- downloadReport(uuIdUrls);
|
|
|
- } else {
|
|
|
- //
|
|
|
- }
|
|
|
- }, null, null
|
|
|
- );
|
|
|
- },
|
|
|
- requestSumAndNormalRptForMultiExcel: function () {
|
|
|
- let rpt_names = [], bill_rpt_names = [], glj_rpt_names = [];
|
|
|
- let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
|
|
|
- rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, rpt_names, bill_rpt_names, glj_rpt_names);
|
|
|
- let params = rptControlObj.creatCommonExportParam(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
|
|
|
- params.sum_rpt_names = bill_rpt_names.concat(glj_rpt_names);
|
|
|
- params.rpt_names = rpt_names;
|
|
|
- params.isOneSheet = true;
|
|
|
-
|
|
|
- CommonAjax.postEx("report_api/createExcelFiles", params, WAIT_TIME_EXPORT, true, function(result){
|
|
|
- if (result) {
|
|
|
- let uuIdUrls = [];
|
|
|
- for (let uuIdObj of result) {
|
|
|
- let uuIdUrl = "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/xlsx";
|
|
|
- uuIdUrls.push(uuIdUrl);
|
|
|
- }
|
|
|
- downloadReport(uuIdUrls);
|
|
|
- } else {
|
|
|
- //
|
|
|
- }
|
|
|
- }, null, null
|
|
|
- );
|
|
|
- },
|
|
|
- requestSumAndNormalRptForAllInOneExcel: function () {
|
|
|
- let orgRptName = projectObj.project.projectInfo.name;
|
|
|
- let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
|
|
|
- rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, null, null, null);
|
|
|
- let params = rptControlObj.creatCommonExportParam(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
|
|
|
- params.rptName = orgRptName;
|
|
|
-
|
|
|
- CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, WAIT_TIME_EXPORT, true, function(result){
|
|
|
- if (result) {
|
|
|
- let uuIdUrls = [];
|
|
|
- let uuIdUrl = "/report_api/getFileByUUID/" + result.uuid + "/" + stringUtil.replaceAll(result.reportName, "#", "_") + "/xlsx";
|
|
|
- uuIdUrls.push(uuIdUrl);
|
|
|
- downloadReport(uuIdUrls);
|
|
|
- } else {
|
|
|
- //
|
|
|
- }
|
|
|
- }, null, null
|
|
|
- );
|
|
|
+ //
|
|
|
},
|
|
|
showPage: function (pageNum, canvas) {
|
|
|
let me = zTreeOprObj;
|
|
@@ -790,21 +723,17 @@ let rptControlObj = {
|
|
|
}
|
|
|
},
|
|
|
firstPage: function(dom) {
|
|
|
- let canvas = document.getElementById("rptCanvas");
|
|
|
- zTreeOprObj.showPage(1, canvas);
|
|
|
+ zTreeOprObj.showPage(1, zTreeOprObj.canvas);
|
|
|
},
|
|
|
prePage: function(dom) {
|
|
|
- let canvas = document.getElementById("rptCanvas");
|
|
|
- zTreeOprObj.showPage(zTreeOprObj.currentPage - 1, canvas);
|
|
|
+ zTreeOprObj.showPage(zTreeOprObj.currentPage - 1, zTreeOprObj.canvas);
|
|
|
},
|
|
|
nextPage: function(dom) {
|
|
|
- let canvas = document.getElementById("rptCanvas");
|
|
|
- zTreeOprObj.showPage(zTreeOprObj.currentPage + 1, canvas);
|
|
|
+ zTreeOprObj.showPage(zTreeOprObj.currentPage + 1, zTreeOprObj.canvas);
|
|
|
},
|
|
|
lastPage: function(dom) {
|
|
|
let me = zTreeOprObj;
|
|
|
- let canvas = document.getElementById("rptCanvas");
|
|
|
- zTreeOprObj.showPage(me.maxPages, canvas);
|
|
|
+ zTreeOprObj.showPage(me.maxPages, zTreeOprObj.canvas);
|
|
|
},
|
|
|
onKeydown: function (event, dom) {
|
|
|
let me = zTreeOprObj, keyPressed = null;
|
|
@@ -820,13 +749,12 @@ let rptControlObj = {
|
|
|
} catch (e) {
|
|
|
pageNum = 1;
|
|
|
}
|
|
|
- let canvas = document.getElementById("rptCanvas");
|
|
|
if (pageNum < 1) {
|
|
|
pageNum = 1;
|
|
|
} else if (pageNum > me.maxPages) {
|
|
|
pageNum = me.maxPages;
|
|
|
}
|
|
|
- zTreeOprObj.showPage(pageNum, canvas);
|
|
|
+ zTreeOprObj.showPage(pageNum, zTreeOprObj.canvas);
|
|
|
return false;
|
|
|
}
|
|
|
},
|