12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067 |
- /**
- * Created by Tony on 2021/4/2.
- */
- const A4_PIXEL_HEIGHT = 1122;
- const A4_PIXEL_WIDTH = 793;
- const A3_PIXEL_HEIGHT = 1586;
- const A3_PIXEL_WIDTH = A4_PIXEL_HEIGHT;
- let rptArchiveObj = {
- treeObj: null,
- currentNode: null,
- currentArchiveUuid: null,
- currentChildArchiveUuids: null,
- currentArchiveDateStr: null,
- currentEncryptionList: null,
- currentArchivePdfPath: null,
- iniPage: function() {
- //初始化页面的归档信息
- let me = rptArchiveObj;
- me.currentNode = null;
- me.currentArchiveUuid = null;
- me.currentChildArchiveUuids = null;
- me.currentArchiveDateStr = null;
- me.currentEncryptionList = null;
- me.currentArchivePdfPath = null;
- const archivedRptIds = [];
- for (let aItem of ARCHIVE_LIST) {
- archivedRptIds.push(parseInt(aItem.rpt_id));
- }
- let private_remove_hide_item = function (items, nlv) {
- if (items && items.length > 0) {
- for (let i = items.length - 1; i >= 0; i--) {
- if (!(items[i].released) && items[i].nodeType === 2) {
- items.splice(i, 1);
- } else {
- if (items[i].items && items[i].items.length > 0) {
- private_remove_hide_item(items[i].items, nlv + 1);
- if (items[i].items.length === 0 && nlv > 0) {
- items.splice(i, 1);
- }
- }
- }
- }
- }
- };
- const private_remove_un_archive_item = function(items, nlv) {
- if (items && items.length > 0) {
- for (let i = items.length - 1; i >= 0; i--) {
- if (items[i].nodeType === 2) {
- if (archivedRptIds.indexOf(items[i].refId) < 0) {
- items.splice(i, 1);
- }
- } else {
- if (items[i].items && items[i].items.length > 0) {
- private_remove_un_archive_item(items[i].items, nlv + 1);
- if (items[i].items.length === 0 && nlv > 0) {
- items.splice(i, 1);
- }
- } else {
- //items[i]是目录,但又没有items子项,
- items.splice(i, 1);
- }
- }
- }
- }
- };
- let nodeLv = 0;
- private_remove_hide_item(TOP_TREE_NODES, nodeLv);
- private_remove_un_archive_item(TOP_TREE_NODES, nodeLv);
- zTreeHelper.createTreeDirectly(TOP_TREE_NODES, rpt_prj_folder_setting, "rptTplTree", me);
- me.treeObj.expandAll(true);
- me.refreshNodes();
- rptArchiveObj._countChkedRptTpl();
- rptArchiveObj._buildeArchiveDateSelect();
- rptArchiveObj._iniArchiveItemForDeleteShow();
- rptArchiveObj._iniArchiveItemForDeleteShow();
- },
- toggleBtn: function (enabled) {
- if (current_stage_status === 3 && enabled) {
- $('#btnArchiveRpt').removeAttr('disabled');
- $('#btnArchiveList').removeAttr('disabled');
- $('#btnBatchArchiveRpt').removeAttr('disabled');
- } else {
- $('#btnArchiveRpt').attr('disabled', '');
- $('#btnArchiveList').attr('disabled', '');
- $('#btnBatchArchiveRpt').attr('disabled', '');
- }
- },
- refreshNodes: function() {
- let me = this;
- let private_setupIsParent = function(node){
- node.isParent = (node.nodeType === RT.NodeType.NODE || node.level === 0);
- if (node.items && node.items.length) {
- for (let i = 0; i < node.items.length; i++) {
- private_setupIsParent(node.items[i]);
- }
- }
- };
- let topNodes = me.treeObj.getNodes();
- for (let i = 0; i < topNodes.length; i++) {
- private_setupIsParent(topNodes[i]);
- }
- me.treeObj.refresh();
- },
- onCheck: function(event, treeId, treeNode) {
- rptArchiveObj._countChkedRptTpl();
- if (treeNode.isParent) {
- rptArchiveObj.treeObj.expandNode(treeNode, true, true, false);
- }
- },
- onClick: function(event,treeId,treeNode) {
- let me = rptArchiveObj;
- if (treeNode && treeNode.nodeType === TPL_TYPE_TEMPLATE && treeNode.refId > 0) {
- me.currentNode = treeNode;
- for (let aItem of ARCHIVE_LIST) {
- if (treeNode.refId === parseInt(aItem.rpt_id)) {
- me.currentArchiveUuid = null;
- me.currentArchiveDateStr = null;
- me.currentArchivePdfPath = null;
- if (aItem.items && aItem.items.length > 0) {
- // me.currentArchiveUuid = aItem.items[0].uuid;
- // me.currentArchiveDateStr = aItem.items[0].updateDate_time;
- const newItems = _.orderBy(aItem.items, ['updateDate_time'], ['desc']);
- me.currentArchiveUuid = newItems[0].uuid;
- me.currentChildArchiveUuids = newItems[0].childUuids;
- me.currentArchiveDateStr = '#' + (_.findIndex(aItem.items, { updateDate_time: newItems[0].updateDate_time})+1) + ' ' + newItems[0].updateDate_time;
- if (can_netcasign) {
- for (const [i,item] of aItem.items.entries()) {
- if (_.find(signLogList, { uuid: item.uuid })) {
- me.currentArchiveUuid = item.uuid;
- me.currentChildArchiveUuids = item.childUuids;
- me.currentArchiveDateStr = '#' + (i+1) + ' ' + item.updateDate_time;
- break;
- }
- }
- }
- }
- break;
- }
- }
- me._countChkedRptTpl();
- me._buildeArchiveDateSelect();
- me._requestArchiveReport();
- rptArchiveObj._iniArchiveItemForDeleteShow();
- }
- },
- batchArchive: function() {
- if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
- if (zTreeOprObj.checkedRptTplNodes.length <= 10) {
- indexDbOprObj.storeReportRequest(current_stage_id, zTreeOprObj.checkedRptTplNodes, indexDbOprObj.startRequestReport);
- } else {
- alert('批量归档上限为10,请勾选10张以内');
- }
- }
- },
- _requestArchiveReport: function () {
- let me = rptArchiveObj;
- if (me.currentNode && me.currentArchiveUuid) {
- try {
- if (can_netcasign) {
- let msgSign = _.find(ARCHIVE_ENCRYPTION_LIST, {rpt_id: me.currentNode.ID, uuid: me.currentArchiveUuid});
- if (!msgSign) {
- msgSign = _.find(ARCHIVE_ENCRYPTION_LIST, {rpt_id: me.currentNode.ID});
- }
- console.log(current_stage_id, msgSign, me.currentArchiveUuid);
- me.currentEncryptionList = msgSign;
- const uSignLogList = _.filter(signLogList, { uuid: me.currentArchiveUuid });
- let html = '';
- let pagetr = '';
- if (msgSign) {
- const rows = 12/msgSign.encryption.length < 3 ? 'col-3' : 'col-' + 12/msgSign.encryption.length;
- for (const [index,role] of msgSign.encryption.entries()) {
- const disablehtml = _.find(uSignLogList, { role: role.name }) ? ' disabled' : '';
- html += '<div class="'+ rows +'">\n' +
- ' <div class="custom-control custom-radio custom-control-inline">\n' +
- ' <input type="radio" value="'+ index +'" id="sign_role_'+ index +'"'+ disablehtml +' name="sign_role" class="custom-control-input">\n' +
- ' <label class="custom-control-label" for="sign_role_'+ index +'">'+ role.name +'</label>\n' +
- ' </div>\n' +
- ' </div>';
- }
- let uhtml = '';
- for (const us of uSignLogList) {
- uhtml += '<span class="text-success"><i class="fa fa-check"></i> '+ us.role +'('+ us.name +')</span>';
- }
- for (let i = 1; i <= msgSign.total_page; i++) {
- pagetr += '<tr><td>页'+ i +'</td><td>'+ me.currentNode.name +'</td><td>'+ uhtml +'</td></tr>';
- }
- }
- $('#dateStr').html(me.currentArchiveDateStr);
- $('#role-list').html(html);
- $('#page-list').html(pagetr);
- $('#sign_num').text(uSignLogList.length);
- const uHadSign = _.filter(uSignLogList, { uid: USER_ID});
- // 是否显示撤销按钮
- if(uHadSign && uHadSign.length > 0) {
- $('#show-removesign-modal-btn').show();
- } else {
- $('#show-removesign-modal-btn').hide();
- }
- postData('/tender/'+ TENDER_ID +'/signReport/post', {type: 'pdfIsExist', uuid: me.currentArchiveUuid}, function (result) {
- me.currentArchivePdfPath = result ? oss_path + '/sign/'+ me.currentArchiveUuid +'.PDF' + (uSignLogList.length !== 0 ? '?' + uSignLogList[uSignLogList.length-1].versionid : '') : oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
- $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="100%" width="100%" style="border: none;"></iframe>');
- }, function () {
- me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
- $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="100%" width="100%" style="border: none;"></iframe>');
- })
- } else {
- me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
- $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="100%" width="100%" style="border: none;"></iframe>');
- console.log(me.currentArchivePdfPath);
- }
- // let uuIdUrl = "/getArchivedFileByUUID/" + me.currentArchiveUuid + "/" + stringUtil.replaceAll(me.currentNode.name, "#", "_");
- // console.log(uuIdUrl);
- // $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + oss_path + '/'+ me.currentArchiveUuid +'.PDF" height="750px" width="100%" style="border: none;"></iframe>');
- // NetcaPDFSeal.openPDFWithUrl(window.location.href);
- // window.location = uuIdUrl;
- } catch (ex) {
- console.log(ex.toString());
- }
- }
- },
- _setChildUuidsByCurUuid: () => {
- let me = rptArchiveObj;
- me.currentChildArchiveUuids = null;
- if (me.currentNode && me.currentArchiveUuid) {
- for (let aItem of ARCHIVE_LIST) {
- if (me.currentNode.refId === parseInt(aItem.rpt_id)) {
- for (let [index,item] of aItem.items.entries()) {
- if (item.uuid === me.currentArchiveUuid) {
- me.currentChildArchiveUuids = item.childUuids;
- break;
- }
- }
- break;
- }
- }
- }
- },
- _changeArchiveDateSelect: function (dom, archiveIdx) {
- let me = rptArchiveObj;
- // me.currentArchiveUuid = dom.uuid; //在dom的onclick时已经设置过了
- me.currentArchiveDateStr = dom.innerHTML;
- me._setChildUuidsByCurUuid();
- if(can_netcasign) {
- postData('/tender/'+ TENDER_ID +'/signReport/post', {type: 'pdfIsExist', uuid: me.currentArchiveUuid}, function (result) {
- const uSignLogList = _.filter(signLogList, { uuid: me.currentArchiveUuid });
- me.currentArchivePdfPath = result ? oss_path + '/sign/'+ me.currentArchiveUuid +'.PDF' + (uSignLogList.length !== 0 ? '?' + uSignLogList[uSignLogList.length-1].versionid : '') : oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
- $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="100%" width="100%" style="border: none;"></iframe>');
- me._buildeArchiveDateSelect();
- }, function () {
- me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
- $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="100%" width="100%" style="border: none;"></iframe>');
- me._buildeArchiveDateSelect();
- });
- // me._updateSignHtmlAndFrame();
- me._requestArchiveReport();
- me._iniArchiveItemForDeleteShow();
- } else {
- me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
- $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="100%" width="100%" style="border: none;"></iframe>');
- me._buildeArchiveDateSelect();
- me._iniArchiveItemForDeleteShow();
- }
- },
- _buildeArchiveDateSelect: function () {
- let me = rptArchiveObj;
- let targetDom = document.getElementById("currentDrpArchiveSelect");
- targetDom.innerHTML = me.currentArchiveDateStr;
- let drpDom = $("#drpArchiveSelect");
- drpDom.empty();
- if (me.currentNode && me.currentArchiveUuid && me.currentArchiveDateStr) {
- for (let aItem of ARCHIVE_LIST) {
- if (me.currentNode.refId === parseInt(aItem.rpt_id)) {
- for (let [index,item] of aItem.items.entries()) {
- if (item.uuid !== me.currentArchiveUuid) {
- const str = `<a class="dropdown-item" href="javascript: void(0);" onclick="rptArchiveObj.currentArchiveUuid = '${item.uuid}'; rptArchiveObj._changeArchiveDateSelect(this)">#${index+1} ${item.updateDate_time}</a>`
- drpDom.append(str);
- }
- }
- }
- }
- }
- },
- _updateSignHtmlAndFrame: function (needFrame = false) {
- const me = rptArchiveObj;
- const uSignLogList = _.filter(signLogList, { uuid: me.currentArchiveUuid });
- for (let i = 0; i < $('#role-list div').length; i++) {
- if (_.find(uSignLogList, { role: $('#role-list div').eq(i).find('label').text() })) {
- $('#role-list div').eq(i).find('input').attr('disabled', true);
- } else {
- $('#role-list div').eq(i).find('input').removeAttr('disabled');
- }
- $('#role-list div').eq(i).find('input').prop('checked', false);
- }
- let uhtml = '';
- let pagetr = '';
- let msgSign = _.find(ARCHIVE_ENCRYPTION_LIST, {rpt_id: me.currentNode.ID, uuid: me.currentArchiveUuid});
- if (!msgSign) {
- msgSign = _.find(ARCHIVE_ENCRYPTION_LIST, {rpt_id: me.currentNode.ID});
- }
- for (const us of uSignLogList) {
- uhtml += '<span class="text-success"><i class="fa fa-check"></i> '+ us.role +'('+ us.name +')</span>';
- }
- for (let i = 1; i <= msgSign.total_page; i++) {
- pagetr += '<tr><td>页'+ i +'</td><td>'+ me.currentNode.name +'</td><td>'+ uhtml +'</td></tr>';
- }
- $('#page-list').html(pagetr);
- if (needFrame) {
- me.currentArchivePdfPath = uSignLogList.length > 0 ? oss_path + '/sign/'+ me.currentArchiveUuid +'.PDF' : oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
- $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + (uSignLogList.length !== 0 ? '?' + uSignLogList[uSignLogList.length-1].versionid : '') + '" height="100%" width="100%" style="border: none;"></iframe>');
- }
- $('#dateStr').html(me.currentArchiveDateStr);
- $('#sign_num').text(uSignLogList.length);
- const uHadSign = _.filter(uSignLogList, { uid: USER_ID});
- // 是否显示撤销按钮
- if(uHadSign && uHadSign.length > 0) {
- $('#show-removesign-modal-btn').show();
- } else {
- $('#show-removesign-modal-btn').hide();
- }
- },
- _countChkedRptTpl: function () {
- let me = rptArchiveObj;
- $('#delete_archive_btn').attr('disabled', '');
- if (me.treeObj) {
- me.checkedRptTplNodes = [];
- let chkNodes = me.treeObj.getCheckedNodes(true), cnt = 0, hasCurrentNode = false;
- for (let node of chkNodes) {
- if (node.nodeType === TPL_TYPE_TEMPLATE) {
- cnt++;
- me.checkedRptTplNodes.push(node);
- if (me.currentNode === node) hasCurrentNode = true;
- }
- }
- if (!hasCurrentNode && cnt === 0 && me.currentNode !== null) {
- //这里根据实际需求再做处理
- 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;
- });
- if (cnt) {
- $('#delete_archive_btn').removeAttr('disabled');
- }
- }
- },
- _iniArchiveItemForDeleteShow: function() {
- let me = rptArchiveObj;
- const dispArchInfoBody = $('#disp_archive_info_body');
- dispArchInfoBody.empty();
- let targetDom = document.getElementById("currentDrpArchiveSelect");
- let firstStr = `<h6>确认删除本张【${targetDom.innerText}】归档报表?</h6>`;
- let secondStr = `<h6>删除后,数据无法恢复,请谨慎操作。</h6>`;
- dispArchInfoBody.append(firstStr);
- dispArchInfoBody.append(secondStr);
- },
- showArchivedItem: function(currentNode) {
- //初始化当前报表已经归档的信息
- //ARCHIVE_LIST结构:[{rpt_id, items: [{uuid, update_time, is_common}...最多3个]}...] (当前项目、当前期的所有报表归档信息)
- if (currentNode) {
- //1. cardArchiveInfo
- let cardArchiveInfo = $('#cardArchiveInfo');
- cardArchiveInfo.empty();
- let auditDate = null;
- let achivedAmt = 0;
- let achivedItem = null;
- for (let item of ARCHIVE_LIST) {
- if (parseInt(item.rpt_id) === currentNode.refId) {
- if (LAST_AUDITOR.end_time) {
- auditDate = new Date(LAST_AUDITOR.end_time);
- } else {
- auditDate = new Date(LAST_AUDITOR.begin_time);
- }
- achivedAmt = item.items?item.items.length:0;
- achivedItem = item;
- break;
- }
- }
- if (auditDate) {
- cardArchiveInfo.append('<h6>第' + current_stage_order + '期,审批通过时间:' + auditDate.getFullYear() + '-' + (auditDate.getMonth() + 1) + '-' + auditDate.getDate() + '。</h6>');
- } else {
- cardArchiveInfo.append('<h6>第' + current_stage_order + '期');
- }
- cardArchiveInfo.append('<h6>本张报表第' + current_stage_order + '期,已归档' + achivedAmt + '份文件。</h6>');
- if (achivedItem && achivedItem.items && achivedItem.items.length === 3) {
- cardArchiveInfo.append('<h6>本次归档将会覆盖最旧那次归档。</h6>');
- }
- cardArchiveInfo.append('<div class="form-group" id="archived_frm_grp">');
- if (achivedAmt > 0) {
- for (let idx = 0; idx < achivedItem.items.length; idx++) {
- cardArchiveInfo.append('<div class="form-check">');
- // if (achivedAmt === 3) {
- // cardArchiveInfo.append('<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios' + idx + '" value="option' + idx + '" ' + ((idx === 0)?'checked':'') + '>');
- // }
- cardArchiveInfo.append('<label class="form-check-label" for="exampleRadios' + idx + '">');
- // let ad = new Date(achivedItem.items[idx].update_time);
- // cardArchiveInfo.append('#' + (idx + 1) + ' ' + ad.getFullYear() + '-' + (ad.getMonth() + 1) + '-' + ad.getDate() + ' 归档');
- cardArchiveInfo.append('#' + (idx + 1) + ' ' + achivedItem.items[idx].updateDate_time + ' 归档');
- cardArchiveInfo.append('</label>');
- cardArchiveInfo.append('</div>');
- }
- }
- cardArchiveInfo.append('</div>');
- //2. selectionArchiveInfo
- let selectionArchiveInfo = $('#selectionArchiveInfo');
- selectionArchiveInfo.empty();
- if (achivedAmt > 0) {
- for (let idx = 0; idx < achivedItem.items.length; idx++) {
- selectionArchiveInfo.append('<a class="dropdown-item" href="javascript: void(0);">#' + (idx + 1) + ' ' + achivedItem.items[idx].updateDate_time + '</a>');
- }
- }
- }
- },
- _getCurrentArchives: function (currentNode) {
- let rst = null;
- if (ARCHIVE_LIST.length > 0 && currentNode) {
- for (let aItem of ARCHIVE_LIST) {
- if (parseInt(aItem.rpt_id) === currentNode.refId) {
- rst = aItem;
- break;
- }
- }
- }
- return rst;
- },
- _chkIfFullArchives: function(currentNode) {
- let aItem = this._getCurrentArchives(currentNode);
- let rst = (aItem && aItem.items && aItem.items.length === 3);
- return rst;
- },
- _getPageSignatureInfo: function(pageData, pageSize, rpt_id) {
- // 因接口方是这样的单位:A4(297*210 -> pt 814.68 * 595.44),那么需要把像素转换成pt的系数,经过测试发现这个系数就是PDF_SCALE,不用再设置了
- let psInfo = [], psInfoStr = [];
- let offsetX = 0, offsetY = 0; //这个跟导出pdf一致,以防万一有变化
- let controls = pageData[JV.NODE_CONTROL_COLLECTION];
- let ptChkHeight = pageSize === 'A4' ? A4_PIXEL_HEIGHT : A3_PIXEL_HEIGHT;
- const _getAreasProperty = (srcArea) => {
- const width = (srcArea[JV.IDX_RIGHT] - srcArea[JV.IDX_LEFT]);
- const height = (srcArea[JV.IDX_BOTTOM] - srcArea[JV.IDX_TOP]);
- let rst = {
- Left: srcArea[JV.IDX_LEFT] + offsetX, Top: srcArea[JV.IDX_TOP] + offsetY, width, height,
- PtCenterX: +((srcArea[JV.IDX_LEFT] + offsetX + width / 2) * PDF_SCALE).toFixed(2),
- PtCenterY: +((ptChkHeight - (srcArea[JV.IDX_TOP] + offsetX + height / 2)) * PDF_SCALE).toFixed(2),
- PtWidth: +(width * PDF_SCALE).toFixed(2), PtHeight: +(height * PDF_SCALE).toFixed(2),
- pages: []
- };
- return rst;
- };
- const _getProperSignatureArea = function(cell, control) {
- // 约定默认长宽比例是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;
- };
- const _getStampArea = (stampCell) => {
- const rst = [0, 0, 0, 0];
- if (stampCell && stampCell[JV.PROP_AREA]) {
- const left = Math.round(stampCell[JV.PROP_AREA][JV.PROP_LEFT]);
- const right = Math.round(stampCell[JV.PROP_AREA][JV.PROP_RIGHT]);
- const top = Math.round(stampCell[JV.PROP_AREA][JV.PROP_TOP]);
- const bottom = Math.round(stampCell[JV.PROP_AREA][JV.PROP_BOTTOM]);
- let width = right - left,
- height = bottom - top;
- rst[0] = left;
- rst[1] = top;
- rst[2] = rst[0] + width;
- rst[3] = rst[1] + height;
- }
- rst[0] = rst[0] + offsetX;
- rst[2] = rst[2] + offsetX;
- rst[1] = rst[1] + offsetY;
- rst[3] = rst[3] + offsetY;
- return rst;
- };
- const _areaKeyCache = {
- normal: 'areas',
- company_stamp: 'company_stamp_areas',
- private_stamp: 'private_stamp_areas'
- };
- const _chkAndSetArea = (sCell, actSignArea, pageIdx, signNameKey) => {
- let idx = psInfoStr.indexOf(sCell[signNameKey]);
- const signType = sCell.signType || 'normal';
- const areaKey = _areaKeyCache[signType] || 'areas';
- if (idx < 0) {
- psInfoStr.push(sCell[signNameKey]);
- let newPsInfo = {'name': sCell[signNameKey], areas: [], company_stamp_areas: [], private_stamp_areas: [], order: psInfoStr.length};
- const area = _getAreasProperty(actSignArea);
- area.pages.push(pageIdx + 1);
- newPsInfo[areaKey].push(area);
- psInfo.push(newPsInfo);
- } else {
- let hasArea = false;
- for (let areaItem of psInfo[idx][areaKey]) {
- if (areaItem.Left === actSignArea[JV.IDX_LEFT] + offsetX && areaItem.Top === actSignArea[JV.IDX_TOP] + offsetX &&
- areaItem.width === actSignArea[JV.IDX_RIGHT] - actSignArea[JV.IDX_LEFT] && areaItem.height === actSignArea[JV.IDX_BOTTOM] - actSignArea[JV.IDX_TOP]) {
- areaItem.pages.push(pageIdx + 1);
- hasArea = true;
- break;
- }
- }
- if (!hasArea) {
- const area = _getAreasProperty(actSignArea);
- area.pages.push(pageIdx + 1);
- psInfo[idx][areaKey].push(area);
- }
- }
- };
- for(let i = 0; i < pageData.items.length; i++) {
- let page = pageData.items[i];
- if (i === 0) {
- let maxX = 0;
- let maxY = 0;
- page.cells.forEach(cell => {
- if (cell.area.Right > maxX) maxX = cell.area.Right;
- if (cell.area.Bottom > maxY) maxY = cell.area.Bottom;
- });
- if (maxX > maxY) ptChkHeight = A4_PIXEL_WIDTH;
- }
- for (let sCell of page.signature_cells) {
- // sCell.signature_name 草图不用加密
- if (sCell.signature_name.indexOf('dummy_pic') < 0) {
- let control = null;
- if (typeof sCell[JV.PROP_CONTROL] === "string") {
- control = controls[sCell[JV.PROP_CONTROL]];
- } else {
- control = sCell[JV.PROP_CONTROL];
- }
- let actSignArea = _getProperSignatureArea(sCell, control);
- _chkAndSetArea(sCell, actSignArea, i, 'signature_name');
- } else {
- let stampArea = _getStampArea(sCell);
- _chkAndSetArea(sCell, stampArea, i, 'signatureName'); // 注意:这里的判断不是signature_name(含dummy的),而是signatureName属性(之前的章信息设计导致)
- }
- }
- }
- return psInfo;
- },
- archiveCurrentReport: function (currentRptPageRst, currentNode, cb) {
- let picKeys = [], picCells = [], dupPicPath = [], dupPicCell = [];
- // 1. 找草图路径
- if (!PAGE_SHOW.closeArchiveSignature) {
- for (let pageIdx = 0; pageIdx < currentRptPageRst.items.length; pageIdx++) {
- // 每页
- for (let sCellIdx = 0; sCellIdx < currentRptPageRst.items[pageIdx].signature_cells.length; sCellIdx++) {
- let sCell = currentRptPageRst.items[pageIdx].signature_cells[sCellIdx];
- // if (sCell.signature_name === 'dummy_pic' && sCell.path.indexOf('/sign') < 0) {
- if (sCell.signature_name.indexOf('dummy_pic') >= 0) {
- //1. 草图就不考虑重复问题,重复就重复吧;
- //2. 如果是dummy_pic,也不用判断是否为签名了,因为有其他的逻辑直接选择审核人,不经过签名过程,就当草图一样放过去了
- let picIdx = picKeys.indexOf(sCell.path);
- if (picIdx < 0) {
- picKeys.push(sCell.path);
- picCells.push(sCell);
- } else {
- let dPicIdx = dupPicPath.indexOf(sCell.path);
- if (dPicIdx < 0) {
- dupPicPath.push(sCell.path);
- dupPicCell.push([]);
- dPicIdx = dupPicPath.length - 1;
- }
- dupPicCell[dPicIdx].push(sCell);
- }
- }
- }
- }
- }
- // 2. 下载草图,下载完毕后upload
- if (picCells.length > 0) {
- $.bootstrapLoading.start();
- let picAmt = picCells.length, picCnt = 0;
- let exceptionAmt = 0;
- for (let idx = 0; idx < picCells.length; idx++) {
- let dCell = picCells[idx];
- getBlob(picKeys[idx]).then(blob => {
- if (blob === 'not found!') {
- exceptionAmt++;
- if ((picCnt + exceptionAmt) === picAmt) {
- $.bootstrapLoading.end();
- rptArchiveObj._archiveCurrentReport(currentRptPageRst, currentNode, cb);
- }
- } else {
- let oFileReader = new FileReader();
- oFileReader.onloadend = function (e) {
- picCnt++;
- let base64 = e.target.result;
- picCells[idx].pic = base64;
- let pPathIdx = dupPicPath.indexOf(dCell.path);
- if (pPathIdx >= 0) {
- for (let dupCell of dupPicCell[pPathIdx]) {
- dupCell.pic = base64;
- }
- }
- if ((picCnt + exceptionAmt) === picAmt) {
- $.bootstrapLoading.end();
- rptArchiveObj._archiveCurrentReport(currentRptPageRst, currentNode, cb);
- }
- };
- oFileReader.readAsDataURL(blob);
- }
- });
- }
- } else {
- rptArchiveObj._archiveCurrentReport(currentRptPageRst, currentNode, cb);
- }
- },
- _archiveCurrentReport: function(currentRptPageRst, currentNode, cb) {
- // 归档当前报表
- if (currentRptPageRst !== null) {
- try {
- let signCells = [];
- let txtSignCells = [];
- let dummyTxtSignCells = [];
- const restoreCells = (srcCells, targetCellsStr) => {
- if (srcCells.length > 0) {
- currentRptPageRst.items.forEach((pageItem, pageIdx) => {
- srcCells[pageIdx].forEach((srcCell) => {
- pageItem[targetCellsStr].push(srcCell);
- });
- srcCells[pageIdx] = null;
- });
- }
- };
- if (PAGE_SHOW.isTextSignature) {
- // 如果是显示文本签名,需要把相关签名移除(草图不动),等创建完后再加回来
- // 批量归档的数据后台会处理(已经移除相关签名)
- currentRptPageRst.items.forEach((pageItem, pageIdx) => {
- const dtlSignCells = [];
- signCells.push(dtlSignCells);
- for (let sCellIdx = pageItem.signature_cells.length - 1; sCellIdx >= 0; sCellIdx--) {
- let sCell = pageItem.signature_cells[sCellIdx];
- if (sCell.signature_name.indexOf('dummy_pic') < 0) {
- dtlSignCells.push(sCell);
- pageItem.signature_cells.splice(sCellIdx, 1);
- } else if (PAGE_SHOW.closeArchiveSignature) {
- // 如果还有closeArchiveSignature标记,那么不显示文本文档(需要删除cells目录下的匹配cell(Value不为空串))
- for (let cIdx = pageItem.cells.length - 1; cIdx >= 0; cIdx--) {
- const cCell = pageItem.cells[cIdx];
- if (cCell.area.Left === sCell.orgArea.Left && cCell.area.Right === sCell.orgArea.Right &&
- cCell.area.Top === sCell.orgArea.Top && cCell.area.Bottom === sCell.orgArea.Bottom &&
- cCell.Value !== '') {
- txtSignCells.push({bkCell: cCell, bkValue: cCell.Value});
- cCell.Value = '';
- break;
- }
- }
- }
- }
- });
- } else if (PAGE_SHOW.closeArchiveSignature) {
- // 这里还有一个场景需要考虑:签名是图片且选择了签名,又不归档输出,
- const rrSigns = [];
- ROLE_REL_LIST.forEach(role_rel => {
- if (role_rel.sign_output && role_rel.sign_output.includes(NORMAL_SIGN_STR)) {
- rrSigns.push(role_rel.signature_name);
- }
- });
- if (rrSigns.length > 0) {
- currentRptPageRst.items.forEach((pageItem, pageIdx) => {
- const dtlSignCells = [];
- const dtlDummyCells = [];
- signCells.push(dtlSignCells);
- dummyTxtSignCells.push(dtlDummyCells);
- for (let sCellIdx = pageItem.signature_cells.length - 1; sCellIdx >= 0; sCellIdx--) {
- let sCell = pageItem.signature_cells[sCellIdx];
- if (rrSigns.includes(sCell.signature_name)) {
- dtlSignCells.push(sCell);
- pageItem.signature_cells.splice(sCellIdx, 1);
- // 还得加一个dummy cell,处理边框用的
- const newCell = {
- font: 'Footer',
- control: sCell.control,
- style: sCell.style,
- Value: '',
- area: { Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom },
- };
- dtlDummyCells.push(newCell);
- pageItem.cells.push(newCell);
- }
- }
- });
- }
- }
- const pageSize = rptControlObj.getCurrentPageSize();
- let doc = JpcJsPDFHelper._createPdf(currentRptPageRst, pageSize, ROLE_REL_LIST, STAGE_AUDIT);
- restoreCells(signCells, 'signature_cells');
- signCells = null;
- txtSignCells.forEach(txtCellBkObj => {
- txtCellBkObj.bkCell.Value = txtCellBkObj.bkValue;
- });
- txtSignCells = null;
- if (dummyTxtSignCells.length === currentRptPageRst.items.length) {
- currentRptPageRst.items.forEach((pageItem, pageIdx) => {
- dummyTxtSignCells[pageIdx].forEach((dummyCell) => {
- const idx = pageItem.cells.indexOf(dummyCell);
- if (idx >= 0) pageItem.cells.splice(idx, 1);
- });
- dummyTxtSignCells[pageIdx] = null;
- });
- dummyTxtSignCells = null;
- }
- let pageEncryptInfo = rptArchiveObj._getPageSignatureInfo(currentRptPageRst, pageSize, currentNode.refId);
- // console.log(pageEncryptInfo);
- let formData = new FormData();
- formData.append('file', doc.output('blob'), 'upload.pdf');
- // formData.append('size', pFile.size);
- if (currentRptPageRst.splitArcPages) {
- let docs = JpcJsPDFHelper.getChildrenDocs(currentRptPageRst, rptControlObj.getCurrentPageSize(), ROLE_REL_LIST, STAGE_AUDIT);
- for (let docIdx = 0; docIdx < docs.length; docIdx++) {
- let file = docs[docIdx].output('blob');
- formData.append('file', file, `upload_child_${docIdx}.pdf`);
- }
- }
- if (!rptArchiveObj._chkIfFullArchives(currentNode)) {
- let archiveUrl = `/tender/report_api/addArchive/${PROJECT_ID}/${current_stage_id}/${currentNode.refId}`;
- if (currentRptPageRst.splitArcPages && currentRptPageRst.splitArcPages.length > 0) {
- archiveUrl = `/tender/report_api/addParentChildrenArchive/${PROJECT_ID}/${current_stage_id}/${currentNode.refId}/${JSON.stringify(currentRptPageRst.splitArcPages)};${JSON.stringify(currentRptPageRst.splitArcPagesInfo)};${currentRptPageRst.items.length}`;
- }
- postDataWithFile(archiveUrl, formData, function (result) {
- // 成功后,更新当前页面
- //*
- if (result.updatedRst) {
- // console.log(result);
- ARCHIVE_LIST = result.updatedRst;
- rptArchiveObj.showArchivedItem(currentNode);
- zTreeOprObj.refreshNodes();
- //第二步:增加加密信息
- let params = {};
- params.prjId = PROJECT_ID;
- params.stgId = current_stage_id;
- params.rptId = currentNode.refId;
- params.ttlPgs = currentRptPageRst.items.length;
- params.content = pageEncryptInfo;
- params.uuid = result.uuid; //正确返回时,带着uuid回来
- params.childUuids = result.childUuids; //还有子uuid
- params.splitArcPages = currentRptPageRst.splitArcPages ? currentRptPageRst.splitArcPages : [];
- params.splitArcPagesInfo = currentRptPageRst.splitArcPagesInfo ? currentRptPageRst.splitArcPagesInfo : {};
- params.reportName = currentNode.name;
- CommonAjax.postXsrfEx("/tender/report_api/addArchiveEncryption", params, 10000, true, getCookie('csrfToken_j'),
- function(rst){
- if (cb) {
- cb(null, 'add archive encryption succeed!', params.uuid);
- }
- }, function(err){
- if (cb) {
- cb('err', 'add archive encryption err!', params.uuid);
- }
- }, function(ex){
- if (cb) {
- cb('err', 'add archive encryption err!', params.uuid);
- }
- }
- );
- } else {
- // 有冲突,需要删除
- CommonAjax.postXsrfEx('/tender/report_api/removeArchive/' + PROJECT_ID + '/' + current_stage_id + '/' + currentNode.refId + result.fileName, '', 3000, true, getCookie('csrfToken_j'),
- function(result){
- if (cb) {
- cb('err', 'add archive conflict!', null);
- }
- }
- );
- }
- //*/
- }, function (error){
- if (cb) {
- cb('err', 'add archive err!', null);
- }
- });
- } else {
- let aItem = this._getCurrentArchives(currentNode);
- if (aItem && aItem.items && aItem.items.length > 0) {
- let orgName = aItem.items[0].uuid;
- let compStr = aItem.items[0].updateDate_time;
- for (let idx = 1; idx < aItem.items.length; idx++) {
- if (aItem.items[idx].updateDate_time < compStr) {
- compStr = aItem.items[idx].updateDate_time;
- orgName = aItem.items[idx].uuid;
- }
- }
- let archiveUrl = `/tender/report_api/updateArchive/${PROJECT_ID}/${current_stage_id}/${currentNode.refId}/${orgName}`;
- if (currentRptPageRst.splitArcPages && currentRptPageRst.splitArcPages.length > 0) {
- // archiveUrl = `/tender/report_api/addParentChildrenArchive/${PROJECT_ID}/${current_stage_id}/${currentNode.refId}/${orgName}`;
- archiveUrl = `/tender/report_api/addParentChildrenArchive/${PROJECT_ID}/${current_stage_id}/${currentNode.refId}/${JSON.stringify(currentRptPageRst.splitArcPages)};${JSON.stringify(currentRptPageRst.splitArcPagesInfo)};${currentRptPageRst.items.length}`; // 分页方式不需要 orgName
- }
- postDataWithFile(archiveUrl, formData, function (result) {
- // postDataWithFile('/tender/report_api/updateArchive/' + PROJECT_ID + '/' + current_stage_id + '/' + currentNode.refId + '/' + orgName, formData, function (result) {
- // 成功后,更新当前页面
- if (result.updatedRst) {
- // console.log(result);
- ARCHIVE_LIST = result.updatedRst;
- rptArchiveObj.showArchivedItem(currentNode);
- zTreeOprObj.refreshNodes();
- //第二步:更新加密信息
- let params = {};
- params.prjId = PROJECT_ID;
- params.stgId = current_stage_id;
- params.rptId = currentNode.refId;
- params.ttlPgs = currentRptPageRst.items.length;
- params.content = pageEncryptInfo;
- params.childUuids = result.childUuids;
- params.removeUuid = result.removeUuid;
- params.splitArcPages = (currentRptPageRst.splitArcPages) ? currentRptPageRst.splitArcPages : [];
- // params.uuid = orgName;
- params.uuid = result.uuid;
- params.reportName = currentNode.name;
- CommonAjax.postXsrfEx("/tender/report_api/updateArchiveEncryption", params, 10000, true, getCookie('csrfToken_j'),
- function(result){
- if (cb) {
- cb(null, 'update archive succeed!', params.uuid);
- }
- }, function(err){
- if (cb) {
- cb('err', 'update archive err!', params.uuid);
- }
- }, function(ex){
- if (cb) {
- cb('err', 'update archive err!', params.uuid);
- }
- }
- );
- } else {
- // 有冲突,需要删除
- CommonAjax.postXsrfEx('/tender/report_api/removeArchive/' + PROJECT_ID + '/' + current_stage_id + '/' + currentNode.refId + result.fileName, '', 3000, true, getCookie('csrfToken'),
- function(result){
- if (cb) {
- cb('err', 'update archive conflict!', null);
- }
- }
- );
- }
- }, function (error){
- // alert(error);
- if (cb) {
- cb('err', 'update archive conflict!', null);
- }
- });
- }
- }
- } catch (ex) {
- console.log(ex);
- console.log(ex.toString());
- if (cb) {
- cb('err', 'has exception!', null);
- }
- }
- } else {
- alert('请选择打开一个报表!');
- }
- },
- _getOneValidLeafNode: function(node) {
- let rst = null;
- let me = rptArchiveObj;
- if (node) {
- const preNode = node.getPreNode();
- if (preNode) {
- rst = preNode;
- } else {
- const nodes = me.treeObj.getNodes();
- for (let dtlNode of nodes) {
- if (dtlNode !== node && dtlNode.nodeType === 2) {
- rst = dtlNode;
- break;
- }
- }
- }
- }
- return rst;
- },
- removeArchive: function() {
- let me = rptArchiveObj;
- const bkRefId = parseInt(me.currentNode.refId);
- const bkUuid = me.currentArchiveUuid;
- if (me.currentNode && me.currentArchiveUuid) {
- const url = `/tender/report_api/removeArchive/${PROJECT_ID}/${current_stage_id}/${me.currentNode.refId}/${me.currentArchiveUuid}`;
- CommonAjax.postXsrfEx(url, '', 3000, true, getCookie('csrfToken_j'),
- function(result){
- // console.log(result.data);
- let hasRemovedAll = false;
- for (let idx = ARCHIVE_LIST.length - 1; idx >= 0; idx--) {
- if (bkRefId === parseInt(ARCHIVE_LIST[idx].rpt_id)) {
- for (let dtIdx = ARCHIVE_LIST[idx].items.length - 1; dtIdx >= 0; dtIdx--) {
- if (ARCHIVE_LIST[idx].items[dtIdx].uuid === bkUuid) {
- ARCHIVE_LIST[idx].items.splice(dtIdx, 1);
- break;
- }
- }
- if (ARCHIVE_LIST[idx].items.length === 0) {
- ARCHIVE_LIST.splice(idx, 0);
- hasRemovedAll = true;
- break;
- }
- }
- }
- //要刷新当前归档
- if (hasRemovedAll) {
- const validNode = me._getOneValidLeafNode(me.currentNode);
- // me.iniPage();
- me.treeObj.removeNode(me.currentNode);
- if (validNode) {
- me.currentNode = validNode;
- me.onClick(null, null, me.currentNode);
- me.treeObj.selectNode(me.currentNode, false);
- me._iniArchiveItemForDeleteShow();
- }
- } else {
- me.currentArchiveUuid = null;
- me.currentArchiveDateStr = null;
- me.currentArchivePdfPath = null;
- me.onClick(null, null, me.currentNode);
- }
- }
- );
- }
- }
- };
- /**
- * 获取 blob
- * @param {String} url 目标文件地址
- * @return {Promise}
- */
- function getBlob(url) {
- return new Promise(resolve => {
- const xhr = new XMLHttpRequest();
- // let fullUrl = url + '?x-oss-process=image/info';
- xhr.open('GET', url, true);
- xhr.responseType = 'blob';
- xhr.onload = () => {
- if (xhr.status === 200) {
- resolve(xhr.response);
- } else {
- resolve('not found!');
- }
- };
- xhr.send();
- });
- }
- /**
- * pdf base64 转 blob
- * @param {String} dataUrl base64码
- * @return {Promise}
- */
- function convertBase64UrlToBlob(dataUrl) {
- //去掉url的头,并转换为byte
- var bytes = window.atob(dataUrl);
- //处理异常,将ascii码小于0的转换为大于0
- var ab = new Uint8Array(bytes.length);
- for (var i = 0; i < bytes.length; i++) {
- ab[i] = bytes.charCodeAt(i);
- }
- return new Blob([ab], { type: 'application/pdf' });
- }
- /**
- * 保存
- * @param {Blob} blob
- * @param {String} filename 想要保存的文件名称
- */
- function saveAs(blob, filename) {
- if (window.navigator.msSaveOrOpenBlob) {
- navigator.msSaveBlob(blob, filename);
- } else {
- const link = document.createElement('a');
- const body = document.querySelector('body');
- link.href = window.URL.createObjectURL(blob);
- link.download = filename;
- // fix Firefox
- link.style.display = 'none';
- body.appendChild(link);
- link.click();
- body.removeChild(link);
- window.URL.revokeObjectURL(link.href);
- }
- }
- /**
- * 下载
- * @param {String} url 目标文件地址
- * @param {String} filename 想要保存的文件名称
- */
- function download(url, filename) {
- getBlob(url).then(blob => {
- saveAs(blob, filename);
- });
- }
- $(function () {
- $('#download_file').click(function () {
- if (rptArchiveObj.currentArchiveUuid && rptArchiveObj.currentArchivePdfPath) {
- console.log(rptArchiveObj.currentArchivePdfPath);
- download(`${rptArchiveObj.currentArchivePdfPath}`, `${rptArchiveObj.currentNode.name} ${rptArchiveObj.currentArchiveDateStr}.pdf`);
- } else {
- alert('请选择打开一个报表!');
- }
- });
- $('#print_file').click(function () {
- if (rptArchiveObj.currentArchiveUuid) {
- $('#iframe_made iframe')[0].contentWindow.print();
- } else {
- alert('请选择打开一个报表!');
- }
- });
- $('#delete_file').click(function () {
- if (rptArchiveObj.currentArchiveUuid && rptArchiveObj.currentArchivePdfPath) {
- console.log(rptArchiveObj.currentArchivePdfPath);
- rptArchiveObj.removeArchive();
- } else {
- alert('请选择打开一个报表!');
- }
- });
- })
|