| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297 | /** * Created by Tony on 2019/9/25. */'use strict'const DFT_ROLE_NAME = '';const NORMAL_SIGN_STR = 'normal_sign';const COMPANY_SIGN_STR = 'company_stamp';const PRIVATE_SIGN_STR = 'private_stamp';const STD_STAMP_SIZE_WIDTH = 5 * 96 / 2.54;   // 公章大小:宽度(5 CM)const STD_STAMP_SIZE_HEIGHT = 5 * 96 / 2.54;  // 公章大小:高度(5 CM)let rptSignatureHelper = {    currentSelectedESignAccDom: null,    currentSelectedESignAccIdx: -1,    currentSelectedESignAccName: null,    currentSelectedESignParentDivId: '',    originalRoleRelList: [],    collapseExpandTreeNode: (dom, isDblClick = false) => {        const classMap = {            'fa fa-caret-down': ['fa fa-caret-right', 'none'],            'fa fa-caret-right': ['fa fa-caret-down', ''],        };        const curPicDom = isDblClick ? $(dom).children()[0] : dom;        const doms = $($(curPicDom).parent()).nextAll();        for (let idx = 0; idx < doms.length; idx++) {            doms[idx].style.display = classMap[curPicDom.className][1];        }        curPicDom.className = classMap[curPicDom.className][0];    },    buildSelectableAccount: function () {        //PRJ_ACCOUNT_LIST        //1. 清理所有选择项        // $("#project_account_select_div").empty();        let accDiv = $('#project_account_select_div');        let accSelect = $('#project_account_select_dom'); //绑定成员        let searchInput = $('#search_account').val();        accDiv.empty();        accSelect.empty();        //2. 一个个加可选用户项        const prj_accounts = [];        const prj_sel_option_accounts = [];        const acc_role_keys = [];        for (let accIdx = 0; accIdx < PRJ_ACCOUNT_LIST.length; accIdx++) {            const prjAccount = PRJ_ACCOUNT_LIST[accIdx];            if (searchInput === '' || (searchInput !== '' && prjAccount.name.indexOf(searchInput) !== -1)) {                let companyKey = prjAccount.account_group;                let roleKey = prjAccount.role;                if (companyKey === '') {                    companyKey = '其他单位';                }                if (roleKey === '') {                    roleKey = DFT_ROLE_NAME;                }                let keyIdx = acc_role_keys.indexOf(companyKey);                if (keyIdx < 0) {                    acc_role_keys.push(companyKey);                    prj_accounts.push([]);                    prj_sel_option_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" ondblclick="rptSignatureHelper.collapseExpandTreeNode(this, true)"><i class="fa fa-caret-down" onclick="rptSignatureHelper.collapseExpandTreeNode(this)"></i> ' + companyKey + '</li>');                    prj_sel_option_accounts[keyIdx].push('<optgroup label=" ' + companyKey + '">');                }                //push item                // prj_accounts[keyIdx].push('<li class="add-sign-list-item"><a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByAccIdx(' + accIdx + ')" 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>');                prj_accounts[keyIdx].push(`<a class="dropdown-item" href="javascript: void(0)" onclick="rptSignatureHelper.createEsignatureByAccIdx('${accIdx}')" data-dismiss="modal">${prjAccount.name}-<small class="text-muted">${roleKey}</small></a>`);                prj_sel_option_accounts[keyIdx].push('<option value="' + accIdx + '">' + prjAccount.name + '-' + roleKey + '</option>');            }        }        for (const prjAccList of prj_accounts) {            prjAccList.push('</ul>');        }        for (const prjAccList of prj_sel_option_accounts) {            prjAccList.push('</optgroup>');        }        for (let idx = 0; idx < prj_accounts.length; idx++) {            prj_accounts[idx] = prj_accounts[idx].join('');            prj_sel_option_accounts[idx] = prj_sel_option_accounts[idx].join('');        }        accDiv.append(prj_accounts.join(''));        accSelect.append(prj_sel_option_accounts.join(''));    },    buildSelectableAccountUsed: function () {        //PRJ_ACCOUNT_LIST        //1. 清理所有选择项        // $("#project_account_select_div").empty();        let accDiv = $('#account_used_select_div');        accDiv.empty();        //2. 一个个加可选用户项        const prj_accounts = [];        for (let uidx = 0; uidx < USED_LIST.length; uidx++) {            const accIdx = PRJ_ACCOUNT_LIST.findIndex(function(item) {                return item.id === USED_LIST[uidx].uid;            });            if (accIdx === -1 || accIdx === undefined) {                continue;            }            const prjAccount = PRJ_ACCOUNT_LIST[accIdx];            let roleKey = prjAccount.role;            if (roleKey === '') {                roleKey = DFT_ROLE_NAME;            }            //push item            // prj_accounts.push('<li class="add-sign-list-item"><a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByAccIdx(' + accIdx + ')" 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>');            prj_accounts.push(`<a class="dropdown-item" href="javascript: void(0)" onclick="rptSignatureHelper.createEsignatureByAccIdx('${accIdx}')" data-dismiss="modal">${prjAccount.name}-<small class="text-muted">${roleKey}</small></a>`);                    }        accDiv.append(prj_accounts.join(''));    },    createEsignatureByAccIdx: function (accIdx) {        rptSignatureHelper.createPreSelectedSignature(PRJ_ACCOUNT_LIST[accIdx], null);    },    createEsignatureByRoleIdx: function (roleIdx) {        rptSignatureHelper.createPreSelectedSignature(null, ROLE_LIST[roleIdx]);    },    createPreSelectedSignature: function (directAcc, roleAcc) {        let dftSignSrc = '/public/upload/sign/user-sign.PNG';        let userAcc = directAcc;        if (roleAcc) {            userAcc = rptSignatureHelper.getUserAccount(roleAcc.bind_acc_id);        }        if (userAcc.sign_path !== '') {            dftSignSrc = '/public/upload/sign/' + userAcc.sign_path;        }        if (rptSignatureHelper.currentSelectedESignAccName !== null) {            for (const page of zTreeOprObj.currentRptPageRst.items) {                if (page.signature_cells) {                    for (const sCell of page.signature_cells) {                        if (sCell.signature_name === rptSignatureHelper.currentSelectedESignAccName) {                            sCell.pre_path = dftSignSrc;                        }                    }                }            }            // 1. 删除不需要的child dom            $(rptSignatureHelper.currentSelectedESignAccDom).empty();            // 2. 创建已选择签名相关 dom            rptSignatureHelper.cleanOldSignature(rptSignatureHelper.currentSelectedESignAccName);            // 2.1 dom element            const elementsStrArr = [];            let dftDate = _getSignDateByAllScenarios(userAcc.id);            if (dftDate !== '' && dftDate.length >= 10) {                dftDate = new Date(dftDate); // 不Format,保留时分秒            } else if (dftDate === '') {                if (STAGE_ID <= -300 && STAGE_ID > -400 && BGL_OBJ && BGL_OBJ.currentBz && BGL_OBJ.currentBz.status === 3) {                    if (STAGE_AUDIT && STAGE_AUDIT.length > 0) {                        dftDate = new Date(STAGE_AUDIT[STAGE_AUDIT.length - 1].end_time);                    } else {                        dftDate = new Date();                    }                } else {                    dftDate = new Date();                }            }            let roleRel = null;            if (directAcc) {                rptSignatureHelper.pushDomElementByUser(elementsStrArr, userAcc.name, userAcc.role);                // 还有ROLE_REL_LIST                let roleRelObj = {};                roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;                roleRelObj.sign_path = dftSignSrc;                // roleRelObj.sign_date = '';                roleRelObj.sign_date = dftDate;                roleRelObj.sign_date_format = 'yyyy年M月d日';                roleRelObj.user_name = userAcc.name;                roleRelObj.acc_id = userAcc.id;                roleRelObj.type = '用户';                roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)                roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(directAcc.company);                roleRelObj.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(roleRelObj,userAcc);                roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;                ROLE_REL_LIST.push(roleRelObj);                roleRel = roleRelObj;            } else if (roleAcc) {                // 创建相关dom元素                rptSignatureHelper.pushDomElementByRole(elementsStrArr, roleAcc.name, userAcc.name);                // 还有ROLE_REL_LIST                let roleRelObj = {};                roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;                roleRelObj.sign_path = dftSignSrc;                // roleRelObj.sign_date = '';                roleRelObj.sign_date = dftDate;                roleRelObj.sign_date_format = 'yyyy年M月d日';                roleRelObj.user_name = userAcc.name;                roleRelObj.acc_id = userAcc.id;                roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)                roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);                roleRelObj.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(roleRelObj,userAcc);                roleRelObj.type = '角色';                roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;                roleRelObj.role_name = roleAcc.name;                ROLE_REL_LIST.push(roleRelObj);                roleRel = roleRelObj;            }            // elementsStrArr.push('');            rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, roleRel, 0);            $(rptSignatureHelper.currentSelectedESignAccDom).append(elementsStrArr.join(' '));            //.appendChild(pNode);            //*/            // 2.2 date-picker            // 更新最近使用名单            const params = {};            params.uid = userAcc.id;            params.prj_id = PROJECT_ID;            params.tender_id = TENDER_ID;            CommonAjax.postXsrfEx("/tender/report_api/updateSignatureUsed", params, 10000, true, getCookie('csrfToken_j'),                function(result){                    console.log(result);                    USED_LIST = result.data;                    $('#search_account').val('');                    rptSignatureHelper.buildSelectableAccount();                    rptSignatureHelper.buildSelectableAccountUsed();                }, function(err){                    // hintBox.unWaitBox();                }, function(ex){                    // hintBox.unWaitBox();                }            );        }    },    cleanOldSignature: function (signature_name) {        // 清掉ROLE_REL_LIST原有的签名        for (let idx = ROLE_REL_LIST.length - 1; idx >= 0 ; idx--) {            if (ROLE_REL_LIST[idx].signature_name === signature_name) {                ROLE_REL_LIST.splice(idx, 1);            }        }    },    resetESignature: function (pageRst, signatureDivId) {        // let body = $('#eSignatureBodyDiv');        if (pageRst !== null) {            let body = $('#' + signatureDivId);            rptSignatureHelper.currentSelectedESignParentDivId = signatureDivId;            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 (sCell.signature_name !== null && sCell.signature_name !== undefined && sCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0) {                            if (singatureNameArr.indexOf(sCell.signature_name) < 0) {                                signature_cells.push(sCell);                                singatureNameArr.push(sCell.signature_name);                            }                        }                    }                }            }            if (signature_cells.length > 0) {                const elementsStrArr = [];                const elementsDateStrArr = [];                for (let scIdx = 0; scIdx < signature_cells.length; scIdx++) {                    const sCell = signature_cells[scIdx];                    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">');                    let hasPic = false;                    //新需求中,即使没有审核,也可以设置签名                    for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {                        const role_rel = ROLE_REL_LIST[idx];                        if (role_rel.signature_name === sCell.signature_name) {                            if (role_rel.type === '用户') {                                rptSignatureHelper.pushDomElementByUser(elementsStrArr, role_rel.user_name, role_rel.role);                            } else {                                //角色                                rptSignatureHelper.pushDomElementByRole(elementsStrArr, role_rel.role_name, role_rel.user_name);                            }                            const userAcc = rptSignatureHelper.getUserAccount(role_rel.acc_id);                            if (userAcc) {                                role_rel.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(role_rel,userAcc);                                role_rel.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);                            }                                                rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, role_rel, idx);                            hasPic = true;                            break;                        }                    }                    if (!hasPic) {                        // 在交互操作中,有可能实际上是没有                        elementsStrArr.push('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.currentSelectedESignAccName = \'' + sCell.signature_name + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签字</a>');                    }                    // if (sCell.path || sCell.pic) {                    // } else {                    //     elementsStrArr.push('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.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(' '));            }        }    },    checkAndShowCrossTendersESignature: function (fujianOssPath) {        rptSignatureHelper.fujianOssPath=fujianOssPath;        let btnDom = $('#btn_cross_tender')[0];        if (zTreeOprObj.currentNode) {            if (btnDom) btnDom.style.display = '';        } else {            if (btnDom) btnDom.style.display = 'none';        }    },    pushDomElementByUser: function (elementsStrArr, userName, userRole) {        elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span>' + userName +            '-<small class="text-muted">' + ((userRole === '')?DFT_ROLE_NAME:userRole) +            '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');    },    pushDomElementByRole: function (elementsStrArr, roleName, userName) {        elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span><i class="fa fa-user" title="角色"> ' + roleName +            '</i>-<small class="text-muted">' + userName +            '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');    },    pushDatePickerDom: function (elementsStrArr, userAcc, role_rel, seq = 0) {        const dateIdSuffixStr = 'dtp_' + role_rel.signature_name + '_' + rptSignatureHelper.currentSelectedESignParentDivId;        let milliSec = (new Date()).getMilliseconds();        const idSuffixStr = `dtp_${seq}_${milliSec}_${rptSignatureHelper.currentSelectedESignParentDivId}`;        elementsStrArr.push('<div class="mt-3">');        elementsStrArr.push('<div class="row">');        //-------------------------------------------------        if (!Array.isArray(role_rel.sign_output)) {            role_rel.sign_output = [NORMAL_SIGN_STR];        }        const normalSignChkStr = (role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) ? 'checked' : '';        const companySignChkStr = (role_rel.sign_output.indexOf(COMPANY_SIGN_STR) >= 0) ? 'checked' : '';        const privateSignChkStr = (role_rel.sign_output.indexOf(PRIVATE_SIGN_STR) >= 0) ? 'checked' : '';        // 1. 签章类型:签字 单位章 个人章....        elementsStrArr.push('<div class="col-8">');        elementsStrArr.push('   <div class="form-control form-control-sm d-inline pt-2">');        elementsStrArr.push('       <div class="form-check form-check-inline px-2">');        elementsStrArr.push(`           <input class="form-check-input" type="checkbox" id="${idSuffixStr}_sign1" value="option1" ${normalSignChkStr} onchange="rptSignatureHelper._changeSignType(this, '${role_rel.signature_name}', '${NORMAL_SIGN_STR}')" >`);        elementsStrArr.push(`           <label class="form-check-label" for="${idSuffixStr}_sign1">签字</label>`);        elementsStrArr.push('       </div>');        const hasIndividualStamp = (userAcc && userAcc.stamp_path && userAcc.stamp_path !== ''); //用户账号的stamp_path是属于用户自己的私章,不是公司章        // let chkType = hasIndividualStamp ? `radio` : 'checkbox';        const chkType = 'checkbox';        let rdoNameStr = `dtp_${role_rel.signature_name}_${rptSignatureHelper.currentSelectedESignParentDivId}`;        // 个人章列表        const stampPathList=userAcc&&userAcc.stamp_path?userAcc.stamp_path.split('!;!'):[];        if (hasIndividualStamp) {            elementsStrArr.push('       <div class="form-check form-check-inline mx-1">');            elementsStrArr.push('           <div class="form-group">');            elementsStrArr.push('               <div class="form-check form-check-inline px-1">');            elementsStrArr.push(`                   <input class="form-check-input" type="${chkType}" id="${idSuffixStr}_sign2" value="companyStamp" name="${rdoNameStr}" onchange="rptSignatureHelper._changeSignType(this, '${role_rel.signature_name}', '${COMPANY_SIGN_STR}')" ${companySignChkStr}>`);            elementsStrArr.push(`                   <label class="form-check-label" for="${idSuffixStr}_sign2">单位章</label>`);            elementsStrArr.push('               </div>');            elementsStrArr.push('               <div class="form-check form-check-inline">');            elementsStrArr.push(`                   <input class="form-check-input" type="${chkType}" id="${idSuffixStr}_sign3" value="individualStamp" name="${rdoNameStr}" onchange="rptSignatureHelper._changeSignType(this, '${role_rel.signature_name}', '${PRIVATE_SIGN_STR}','${userAcc.stamp_path}')" ${privateSignChkStr}>`);            elementsStrArr.push(`                   <label class="form-check-label" for="${idSuffixStr}_sign3">个人章</label>`);            if(stampPathList.length>1){            elementsStrArr.push(`                   <a class="pl-2" href="#chose-private-stamp-path" data-toggle="modal" data-target="#chose-private-stamp-path" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode;rptSignatureHelper.initChosePrivateStampPath('${userAcc.stamp_path}','${role_rel.signature_name}') ">选择个人章</a>`);            }             elementsStrArr.push('               </div>');            elementsStrArr.push('           </div>');            elementsStrArr.push('       </div>');        } else {            elementsStrArr.push('       <div class="form-check form-check-inline px-2">');            elementsStrArr.push(`           <input class="form-check-input" type="${chkType}" id="${idSuffixStr}_sign10" value="option2" onchange="rptSignatureHelper._changeSignType(this, '${role_rel.signature_name}', '${COMPANY_SIGN_STR}')" ${companySignChkStr}>`);            elementsStrArr.push(`           <label class="form-check-label" for="${idSuffixStr}_sign10">单位章</label>`);            elementsStrArr.push('       </div>');        }        elementsStrArr.push('   </div>');        elementsStrArr.push('</div>');        // 2. 日期        elementsStrArr.push('<div class="col-4">');        let dftDate = '';        if (role_rel.sign_date !== '' && role_rel.sign_date.length > 20) {            dftDate = (new Date(role_rel.sign_date)).Format('yyyy-MM-dd');        } else if (role_rel.sign_date instanceof Date){            dftDate = role_rel.sign_date.Format('yyyy-MM-dd');        } else {            if (userAcc) dftDate = _getSignDateByAllScenarios(userAcc.id);            if (dftDate !== '' && dftDate.length > 20) {                dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');            }        }        elementsStrArr.push('<div class="input-group input-group-sm margin-inputbox">');        elementsStrArr.push('   <div class="input-group-prepend">');        elementsStrArr.push('       <span class="input-group-text height-inputbox" id="inputGroup-sizing-sm"><i class="fa fa-calendar" title="添加签名日期"></i></span>');        elementsStrArr.push('   </div>');        if (dftDate !== '') {            elementsStrArr.push(`<input id="${dateIdSuffixStr}" type="text" class="form-control datepicker-here height-inputbox" aria-label="Small" aria-describedby="inputGroup-sizing-sm" data-language="zh" value="${dftDate}"></input>`);        } else {            elementsStrArr.push(`<input id="${dateIdSuffixStr}" type="text" class="form-control datepicker-here height-inputbox" aria-label="Small" aria-describedby="inputGroup-sizing-sm" data-language="zh"></input>`);        }        elementsStrArr.push('</div>');        //-------------------------------------------------        elementsStrArr.push('</div>');        elementsStrArr.push('</div>');    },    removeSignature: function (dom) {        let accTxtName = $(dom.parentNode.parentNode.parentNode.parentNode.parentNode).find('label')[0].innerText;        let jDom = $(dom.parentNode.parentNode);        jDom.empty();        jDom.append('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.currentSelectedESignAccName = \'' +            accTxtName + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签字</a>');        // 要记得清空相关pre_path属性        for (const page of zTreeOprObj.currentRptPageRst.items) {            if (page.signature_cells) {                for (const sCell of page.signature_cells) {                    if (sCell.signature_name === accTxtName) {                        sCell.pre_path = '';                    }                }            }        }        // 还有ROLE_REL_LIST        rptSignatureHelper.cleanOldSignature(accTxtName);    },    removeSelectSignature: function () {        for (const page of zTreeOprObj.currentRptPageRst.items) {            if (page.signature_cells) {                for (const sCell of page.signature_cells) {                    if (sCell.hasOwnProperty('pre_path')) {                        delete sCell.pre_path;                    }                }            }        }        // ROLE_REL_LIST = [];        // ROLE_REL_LIST = ROLE_REL_LIST.concat(rptSignatureHelper.originalRoleRelList);        ROLE_REL_LIST = JSON.parse(JSON.stringify(rptSignatureHelper.originalRoleRelList));        if (PAGE_SHOW.isTextSignature) {            // resetTextSignature(zTreeOprObj.currentRptPageRst);            resetTextSignature(zTreeOprObj.currentRptPageRst, getStageStatus() !== 3);        }        zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);    },    resetSignAudit: function () {        rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT);    },    resetSignDate: function(signatureDivId) {        for (const page of zTreeOprObj.currentRptPageRst.items) {            // 调整了下次序,无论有没有签名时间显示,签名对象的sign_date必须得更新及保存            for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {                const role_rel = ROLE_REL_LIST[idx];                const idSuffixStr = 'dtp_' + role_rel.signature_name + '_' + signatureDivId;                // let dtDom = $('#' + idSuffixStr);                let dtDom = document.getElementById(idSuffixStr); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象                if (dtDom) {                    const dtStr = dtDom.value;                    if (dtStr && dtStr !== '' && dtStr.length >= 8 && dtStr.length <= 10) {                        role_rel.sign_date = new Date(dtStr);                    } else {                        role_rel.sign_date = '';                    }                    // 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)                    if (page.signature_date_cells) {                        for (const sCell of page.signature_date_cells) {                            if (sCell.signature_name === role_rel.signature_name + '_签字日期') {                                sCell.Value = _getSignDateDftName();                                if (role_rel.sign_date !== '') {                                    sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);                                }                            }                        }                    }                }            }        }    },    setupAfterSelectMultiTenders: function (selectedTenders, signatureDivId) {        //跨标段选择,有不少要注意的交互:        //0. 签名日期        rptSignatureHelper.resetSignDate(signatureDivId);        rptSignatureHelper.resetSignAudit();        //1. 重刷page        if (getStageStatus() === 3) {            for (const page of zTreeOprObj.currentRptPageRst.items) {                if (page.signature_cells) {                    for (const sCell of page.signature_cells) {                        if (sCell.hasOwnProperty('pre_path')) {                            sCell.path = sCell.pre_path;                            delete sCell.pre_path;                        }                    }                }            }            if (PAGE_SHOW.isTextSignature) {                resetTextSignature(zTreeOprObj.currentRptPageRst, getStageStatus() !== 3);            }            zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);        }        //2. 集中请求        let params = {};        params.id = CURRENT_ROLE_REL_ID;        params.tender_id = TENDER_ID;        params.stage_id = getStageId();        params.business_id = BUSINESS_ID;        params.source_type = SOURCE_TYPE;        params.rpt_id = zTreeOprObj.currentNode.refId;        params.rel_content = ROLE_REL_LIST;        params.selectedTenders = selectedTenders;        rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));        $.bootstrapLoading.start();        CommonAjax.postXsrfEx("/tender/report_api/updateMultiRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),            function(result){                // console.log(result);                $.bootstrapLoading.end();                if (result.data && result.data.insertId > 0) {                    CURRENT_ROLE_REL_ID = result.data.insertId;                }            }, function(err){                // hintBox.unWaitBox();                $.bootstrapLoading.end();            }, function(ex){                // hintBox.unWaitBox();                $.bootstrapLoading.end();            }        );    },    _parseRoleRelList: function(org_rel_content) {        const rst = JSON.parse(org_rel_content);        for (const role_rel of rst) {            if (role_rel.sign_date !== null && role_rel.sign_date !== undefined && role_rel.sign_date.length >= 8) {                role_rel.sign_date = new Date(role_rel.sign_date);            }        }        return rst;    },    setupAfterSelectSignature: async function (signatureDivId) {        //0. 签名日期        let me = rptSignatureHelper;        rptSignatureHelper.resetSignDate(signatureDivId);        rptSignatureHelper.resetSignAudit();        //1. 重刷page        // let hasStamp = false;        for (const page of zTreeOprObj.currentRptPageRst.items) {            if (page.signature_cells) {                for (let cIdx = page.signature_cells.length - 1; cIdx >= 0; cIdx--) {                    const sCell = page.signature_cells[cIdx];                    if (sCell.isStamp) {                        page.signature_cells.splice(cIdx);                        // hasStamp = true;                    } else if (sCell.hasOwnProperty('pre_path')) {                        sCell.path = sCell.pre_path;                        delete sCell.pre_path;                    }                    for (let role of ROLE_REL_LIST) {                    }                }            }        }        resetStampSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3);        if (PAGE_SHOW.isTextSignature) {            resetTextSignature(zTreeOprObj.currentRptPageRst, getStageStatus() !== 3);        }        zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);        //2. 更新数据        const params = {};        params.id = CURRENT_ROLE_REL_ID;        params.tender_id = TENDER_ID;        params.stage_id = getStageId();        params.business_id = BUSINESS_ID;        params.source_type = SOURCE_TYPE;        params.rpt_id = zTreeOprObj.currentNode.refId;        params.rel_content = ROLE_REL_LIST;        params.rel_content = [];        ROLE_REL_LIST.forEach((role) => {            if (role.signature_name.indexOf('dummy_pic') < 0) {                params.rel_content.push(role);            }        });        // rptSignatureHelper.originalRoleRelList = [];        // rptSignatureHelper.originalRoleRelList = rptSignatureHelper.originalRoleRelList.concat(ROLE_REL_LIST);        rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(params.rel_content));        $.bootstrapLoading.start();        CommonAjax.postXsrfEx("/tender/report_api/updateRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),            async function(result){                // console.log(result);                $.bootstrapLoading.end();                if (result.data && result.data.insertId > 0) {                    CURRENT_ROLE_REL_ID = result.data.insertId;                }                if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {                    // CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;                    ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);                    rptSignatureHelper.originalRoleRelList = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);                    rptSignatureHelper.mergeSignDate(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);                    rptSignatureHelper.mergeSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);                    await rptSignatureHelper.resetDummySignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3); // 这里重新整理签章坐标信息(因签章大小在后台暂时获取不到,挪到前端处理)                    rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT, getStageStatus() !== 3);                    zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);                } else {                    // CURRENT_ROLE_REL_ID = -1;                    ROLE_REL_LIST = [];                }            }, function(err){                // hintBox.unWaitBox();                $.bootstrapLoading.end();            }, function(ex){                // hintBox.unWaitBox();                $.bootstrapLoading.end();            }        );    },    switchAddRoleDiv: function (dom) {        if (dom.nextElementSibling.children[0].style.display === 'none') {            dom.nextElementSibling.children[0].style.display = '';        } else {            dom.nextElementSibling.children[0].style.display = 'none';        }    },    createNewRole: function (dom) {        if ($('#acc_role_name')[0].value !== '') {            const params = {};            params.name = $('#acc_role_name')[0].value;            const selectedAcc = PRJ_ACCOUNT_LIST[$('#project_account_select_dom')[0].selectedOptions[0].value];            const roleName = (selectedAcc.role === '')?DFT_ROLE_NAME:selectedAcc.role;            params.bind_acc_id = selectedAcc.id;            params.prj_id = PROJECT_ID;            params.tender_id = TENDER_ID;            CommonAjax.postXsrfEx("/tender/report_api/createSignatureRole", params, 10000, true, getCookie('csrfToken_j'),                function(result){                    console.log(result);                    const newRole = {};                    newRole.name = params.name;                    newRole.bind_acc_id = selectedAcc.id;                    newRole.prj_id = PROJECT_ID;                    newRole.tender_id = TENDER_ID;                    ROLE_LIST.push(newRole);                    const domArr = [];                    domArr.push('<li class="add-sign-list-item">');                    //1. apply签名                    domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + (ROLE_LIST.length - 1) +')" class="btn-link pull-right" title="添加" data-dismiss="modal">');                    domArr.push('<i class="fa fa-plus"></i>');                    domArr.push('</a>');                    //2. 编辑角色(暂缓处理click事件)                    domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');                    domArr.push('<i class="fa fa-pencil-square-o"></i>');                    domArr.push('</a>');                    //3. 显示名称                    domArr.push('<i class="fa fa-user"></i> ' + $('#acc_role_name')[0].value + '<p>' + selectedAcc.name + '-<small class="text-muted">' + roleName + '</small></p>');                    $('#existed_roles_ul').append(domArr.join(' '));                }, function(err){                    // hintBox.unWaitBox();                }, function(ex){                    // hintBox.unWaitBox();                }            );        } else {            alert('请输入合适的名称!');        }    },    buildRoleDom: function (roleList) {        const ulDom = $('#existed_roles_ul');        ulDom.empty();        for (let domIdx = 0; domIdx < roleList.length; domIdx++) {            const role = roleList[domIdx];            const domArr = [];            domArr.push('<li class="add-sign-list-item">');            //1. apply签名            domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + domIdx + ')" class="btn-link pull-right" title="添加" data-dismiss="modal">');            domArr.push('<i class="fa fa-plus"></i>');            domArr.push('</a>');            //2. 编辑角色(暂缓)            domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');            domArr.push('<i class="fa fa-pencil-square-o"></i>');            domArr.push('</a>');            //3. 显示名称            let acc = rptSignatureHelper.getUserAccount(role.bind_acc_id);            if (acc) domArr.push('<i class="fa fa-user"></i> ' + role.name + '<p>' + acc.name + '-<small class="text-muted">' + ((acc.role === '')?DFT_ROLE_NAME:acc.role) + '</small></p>');            ulDom.append(domArr.join(' '));        }    },    getUserAccount: function (accId) {        let rst = null;        for (const acc of PRJ_ACCOUNT_LIST) {            if (acc.id === accId) {                rst = acc;                break;            }        }        return rst;    },    _getCompanySign: function(companyName) {        let rst = '';        for (const cUnit of CONSTRUCT_UNIT_LIST) {            if (cUnit.name === companyName) {                rst = cUnit.sign_path;                break;            }        }        return rst;    },    mergeSignature: function (pageData, currRoleRelList, setPic = false, checkAudit = false) {        for (const page of pageData.items) {            if (page.signature_cells) {                const adHocScells = [];                for (const sCell of page.signature_cells) {                    if (sCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0) {                        sCell.path = null;                        sCell.pre_path = null;                        sCell.pic = null;                    }                    for (const role_rel of currRoleRelList) {                        if (!checkAudit || checkAudit && rptSignatureHelper._chkIfAudit(role_rel)) {                            // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示                            if (role_rel.signature_name === sCell.signature_name) {                                // 处理签章                                if (!Array.isArray(role_rel.sign_output)) {                                    role_rel.sign_output = [];                                    role_rel.sign_output.push(NORMAL_SIGN_STR);                                }                                for (const signType of role_rel.sign_output) {                                    switch (signType) {                                        case NORMAL_SIGN_STR:                                            sCell.path = role_rel.sign_path;                                            sCell.pre_path = role_rel.sign_path;                                            if (setPic) {                                                sCell.pic = role_rel.sign_pic; // 有些场景(如:批量归档)需要直接设置签名数据                                            }                                            break;                                        case COMPANY_SIGN_STR:                                        case PRIVATE_SIGN_STR:                                            /*                                            const stampPath = (signType === COMPANY_SIGN_STR) ? role_rel.company_stamp_path : role_rel.private_stamp_path;                                            // 生成一个新的dummy cell(类似草图)                                            const newStampCell = _createDummyCell();                                            newStampCell.signature_name = JV.SIGNATURE_NAME_DUMMY;                                            newStampCell.path = OSS_PATH + stampPath;                                            newStampCell.control = sCell.control;                                            newStampCell.style = sCell.style;                                            newStampCell.isStamp = true; // 这个标记纯属为了刷新用,其他sign cell是没有的                                            // 设置坐标                                            rptSignatureHelper._resetStampPos(sCell, newStampCell, pageData[JV.NODE_CONTROL_COLLECTION]);                                            // 加到cells去                                            adHocScells.push(newStampCell);                                            //*/                                        break;                                        default:                                        break;                                    }                                }                                break;                            }                        }                    }                }                page.signature_cells = page.signature_cells.concat(adHocScells);            }        }    },    resetDummySignature: async function(pageData, roleRel, ifPushRoleRel = false, checkAudit = false) {        // 备注:计算草图等其他图形需要额外做些处理        let dummySignIdx = 0;        const stampPicKeys = [], stampPicFeatures = [];        for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {            const page = pageData.items[pageIdx];            if (page[JV.PROP_SIGNATURE_CELLS] && page[JV.PROP_SIGNATURE_CELLS].length > 0) {                for (const signatureCell of page[JV.PROP_SIGNATURE_CELLS]) {                    if (signatureCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {                        let passAuditChk = true;                        if (checkAudit) {                            passAuditChk = false;                            if (roleRel) {                                for (const role_rel of roleRel) {                                    if (role_rel.signature_name === signatureCell.signatureName) {                                        // signatureName(非signature_name)是印章cell特意给的属性,还有isStamp属性                                        if (rptSignatureHelper._chkIfAudit(role_rel)) {                                            passAuditChk = true;                                            break;                                        }                                    }                                }                            }                        }                        if (passAuditChk) {                            // 表示这是一个其他类型的非原生电子签名图,只是借用signature的处理机制,每个图都是唯一的,所以需要重新给个唯一的新signature_name                            // signatureCell.signature_name = signatureCell.signature_name + '_' + pageIdx + '_' + dummySignIdx;                            signatureCell.signature_name = signatureCell.signature_name + '_' + page.page_seq + '_' + dummySignIdx; // page_seq在分页后都不会变动                            dummySignIdx++;                            const roleRelItem = { type: '用户', sign_path: signatureCell.path, signature_name: signatureCell.signature_name };                            if (signatureCell.isStamp) {                                let stmpIdx = stampPicKeys.indexOf(signatureCell.path);                                if (stampPicKeys.indexOf(signatureCell.path) < 0) {                                    stampPicKeys.push(signatureCell.path);                                    stmpIdx = stampPicKeys.length - 1;                                    const picRes = await getHttpBlobText(signatureCell.path + '?x-oss-process=image/info');                                    stampPicFeatures.push(picRes);                                }                                // { "FileSize": {"value": "2514"}, "Format": {"value": "png"}, "ImageHeight": {"value": "94"}, "ImageWidth": {"value": "94"} }                                roleRelItem.stampFeature = stampPicFeatures[stmpIdx];                                // 重新处理cell坐标                                // 如果签章信息中存在位置信息,则不执行该方法                                if(!signatureCell.isSaveSignature) _resetStampArea(pageData[JV.NODE_CONTROL_COLLECTION][signatureCell[JV.PROP_CONTROL]], signatureCell, roleRelItem);                            }                            if (ifPushRoleRel) roleRel.push(roleRelItem);                        }                    }                }            }        }    },    mergeSignAudit: function (pageData, currRoleRelList, currAuditList, checkAudit = false) {        for (const page of pageData.items) {            if (page.signature_audit_cells) {                for (const sCell of page.signature_audit_cells) {                    sCell.Value = ''; // 这里要先清除原有信息                    for (const role_rel of currRoleRelList) {                        if (!checkAudit || checkAudit && rptSignatureHelper._chkIfAudit(role_rel)) {                            // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示                            if (sCell.signature_name === role_rel.signature_name + '_审核意见') {                                let preDate = '';                                sCell.Value = '同意'; // 只有选择了签名的,才需要初始化一个默认的意见(之前的逻辑在有多个签名,哪怕只选择了一个,其他的意见都会有默认意见)                                for (const audit_rel of currAuditList) {                                    if (role_rel.acc_id === audit_rel.aid) {                                        if (audit_rel.end_time > preDate && audit_rel.status === 3) {                                            sCell.Value = audit_rel.opinion;                                            preDate = audit_rel.end_time;                                        }                                        //不能break,实际会有多个审核意见,以最后一个为准                                    }                                }                                break;                            }                        }                    }                }            }        }    },    mergeSignDate: function (pageData, currRoleRelList, isMergeOrgAlso, checkAudit = false) {        if (currRoleRelList && currRoleRelList.length > 0 && STAGE_AUDIT && STAGE_AUDIT.length > 0) {            for (let rridx = 0; rridx < currRoleRelList.length; rridx++) {                const role_rel = currRoleRelList[rridx];                if (role_rel.sign_date === undefined || role_rel.sign_date ===  null || role_rel.sign_date ===  '') {                    let dftDate = _getSignDateByAllScenarios(role_rel.acc_id);                    if (dftDate !== '' && dftDate.length >= 10) {                        dftDate = new Date(dftDate); // 不Format,保留时分秒                    } else if (dftDate === '') {                        if (STAGE_ID <= -300 && STAGE_ID > -400 && BGL_OBJ && BGL_OBJ.currentBz && BGL_OBJ.currentBz.status === 3) {                            if (STAGE_AUDIT && STAGE_AUDIT.length > 0) {                                dftDate = new Date(STAGE_AUDIT[STAGE_AUDIT.length - 1].end_time);                            } else {                                dftDate = new Date();                            }                        } else {                            dftDate = new Date();                        }                    }                    role_rel.sign_date = dftDate;                    if (isMergeOrgAlso) {                        rptSignatureHelper.originalRoleRelList[rridx].sign_date = dftDate;                        //备注:在多选导出的情况下,originalRoleRelList不需要merge                    }                }            }        }        for (const page of pageData.items) {            if (page.signature_date_cells) {                for (const sCell of page.signature_date_cells) {                    if (sCell.Value === undefined || sCell.Value === null && sCell.Value === '') {                        sCell.Value = _getSignDateDftName();                    }                    for (const role_rel of currRoleRelList) {                        if (sCell.signature_name === role_rel.signature_name + '_签字日期') {                            if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {                                // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示                                if (role_rel.sign_date !== '') {                                    if (typeof role_rel.sign_date === 'string') {                                        role_rel.sign_date = new Date(role_rel.sign_date);                                    }                                    sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);                                }                            }                            break;                        }                    }                }            }        }    },    _chkIfAudit: function(role_rel) {        // 检测是否在审核列表中        let rst = false;        for (const stg_audit of STAGE_AUDIT) {            if (role_rel.acc_id === stg_audit.aid) {                if (stg_audit.status === 3) {                    rst = true;                } else {                    rst = false;                }                // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准            }        }        if (!rst) {            // 还有原报需要检测            for (const stg_ort_rpt of STAGE_LIST) {                if (role_rel.acc_id === stg_ort_rpt.user_id) {                    if (stg_ort_rpt.status !== 1 && stg_ort_rpt.status !== 4) {                        // 只要不是待上报(1)、退回审批(4) 状态,都需要显示                        rst = true;                    } else {                        rst = false;                    }                    // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准                }            }        }        // rst = true; //测试,未来将屏蔽        return rst;    },    _chkIfOrgRpt: function(role_rel) {        // 检测是否原报        let rst = false;        for (const stg of STAGE_LIST) {            if (stg.id === current_stage_id) {                if (stg.user_id === role_rel.acc_id) {                    rst = true;                }                break;            }        }        return rst;    },    _changeSignType: function(dom, signature_name, chkStr, userStamp) {        for (const roleRel of ROLE_REL_LIST) {            if (roleRel.signature_name === signature_name) {                if (dom.checked) {                    if (roleRel.sign_output.indexOf(chkStr) < 0) {                        roleRel.sign_output.push(chkStr);                    }                    if(chkStr==='private_stamp'&&!roleRel.private_stamp_path && userStamp){                        roleRel.private_stamp_path = userStamp.split('!;!')[0] ;                        console.log(roleRel.private_stamp_path);                    }                } else {                    let idx = roleRel.sign_output.indexOf(chkStr);                    if (idx >= 0) {                        roleRel.sign_output.splice(idx, 1);                    }                }                break;            }        }    },    _resetStampPos: function(orgCell, targetCell, controls) {        const ctrl = controls[orgCell.control];        let pLeft = orgCell.area.Left, pTop = orgCell.area.Top;        switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {            case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:                 pLeft = orgCell.area.Left;            break;            case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:                 pLeft = (orgCell.area.Left + orgCell.area.Right - STD_STAMP_SIZE_WIDTH) / 2 ;            break;            case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:                 pLeft = orgCell.area.Right - STD_STAMP_SIZE_WIDTH;            break;        }        switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {            case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_TOP]:                 pTop = orgCell.area.Top;            break;            case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_CENTER]:                 pTop = (orgCell.area.Top + orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT) / 2 ;            break;            case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_BOTTOM]:                 pTop = orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT;            break;        }        targetCell.area.Left = pLeft;        targetCell.area.Top = pTop;        targetCell.area.Right = pLeft + STD_STAMP_SIZE_WIDTH;        targetCell.area.Bottom = pTop + STD_STAMP_SIZE_HEIGHT;    },    initChosePrivateStampPath:function(stampPathList,signature_name){        let currentStamp='';        const targetNode= ROLE_REL_LIST.find(item=>item.signature_name===signature_name);        if(targetNode) currentStamp=targetNode.private_stamp_path        let content=`<div class='row justify-content-md-center'>`;        stampPathList.split('!;!').forEach(item=>{            content+=`<div class="card col-3 p-2 m-3 d-flex ${currentStamp===item?'card-gk-active':''} stamp-img">                            <div class="p-0 private-stamp-img">                                <div  class="sel-width check-state ${currentStamp===item?'sel-blue':''} "></div>                                <img src="${rptSignatureHelper.fujianOssPath}${item}" data-src='${item}' class="img-fluid" alt="...">                            </div>                        </div>`;        })                for(let i=0;i<stampPathList.length%3;i++){            content+=`<div class="col-3 p-2 m-3"></div>`;        }        content+=` </div><div class='privateStampRoleName' data-name='${signature_name}'></div>`;        $('#chose-private-stamp-path .modal-body').empty().append(content);        $('.stamp-img').on('click',(e)=>{            $('.stamp-img').removeClass('card-gk-active');            $('.stamp-img').find('.sel-width').removeClass('sel-blue');            $(e.currentTarget).addClass('card-gk-active');            $(e.currentTarget).find('.sel-width').addClass('sel-blue');        })    },    setPrivateStamp(e){        const imgSrc= $('.stamp-img.card-gk-active').find('.img-fluid').data('src');        const privateStampRoleName=$('.privateStampRoleName').data('name');        const targetNode= ROLE_REL_LIST.find(item=>item.signature_name==privateStampRoleName);        targetNode.private_stamp_path=imgSrc;        $('#chose-private-stamp-path').modal('hide');    },    _get_newPrivate_stamp_path(roleRelObj,userAcc){        if(!roleRelObj.private_stamp_path){            if(!userAcc.stamp_path) return '';            if(userAcc.stamp_path.split('!;!').length===1){                return userAcc.stamp_path;            }else{                return userAcc.stamp_path.split('!;!')[0];            }        }        return roleRelObj.private_stamp_path;    }}function _getSignDateByAllScenarios(userAccId) {    let rst = '';    let hasAudit = false;    for (const stg_audit of STAGE_AUDIT) {        if (stg_audit.aid === userAccId) {            hasAudit = true;            if (stg_audit.status === 3) {                rst = stg_audit.end_time;            } else {                rst = '';            }            // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准        }    }    let isOrgRpt = false;    for (const stg of STAGE_LIST) {        if (stg.id === current_stage_id) {            if (stg.user_id === userAccId) {                isOrgRpt = true;            }            break;        }    }    if (isOrgRpt && !hasAudit && STAGE_AUDIT_ORG && STAGE_AUDIT_ORG.length > 0) {        if (STAGE_AUDIT_ORG[0].begin_time && STAGE_AUDIT_ORG[0].begin_time !== '' && STAGE_AUDIT_ORG[0].begin_time.length > 20) {            rst = STAGE_AUDIT_ORG[0].begin_time;        }    }    if (!isOrgRpt && !hasAudit) {        //非审批流程人员以及非原报,则显示期截至时间        for (const stg of STAGE_LIST) {            if (stg.id === current_stage_id && stg.period) {                const period = stg.period.split(' ~ ');                if (period.length === 2) {                    rst = period[1];                }            }        }    }    return rst;}function _getSignDateDftName() {    return '    年  月  日';}function _createDummyCell() {    const rst = {        font: 'Footer',        control: 'Footer',        style: 'Default_None',        Value: '',        area: { Left: 0, Right: 0, Top: 0, Bottom: 0 },    };    return rst;}function resetStampSignature(pageData, roleRelList, checkAudit = false) {    const dupPicPaths = [];    const _getMaxRect = function(page) {        const rect = [100000000, 100000000, 0, 0];        for (const cell of page.cells) {            if (rect[0] > cell.area.Left) {                rect[0] = cell.area.Left;            }            if (rect[1] > cell.area.Top) {                rect[1] = cell.area.Top;            }            if (rect[2] < cell.area.Right) {                rect[2] = cell.area.Right;            }            if (rect[3] < cell.area.Bottom) {                rect[3] = cell.area.Bottom;            }        }        return rect;    };    for (const page of pageData.items) {        const maxRect = _getMaxRect(page);        if (page.signature_cells) {            const newStampCells = [];            for (let scIdx = 0; scIdx < page.signature_cells.length; scIdx++) {                const sCell = page.signature_cells[scIdx];                for (const role_rel of roleRelList) {                    if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {                        if (sCell.signature_name === role_rel.signature_name) {                            if (Array.isArray(role_rel.sign_output) && role_rel.sign_output.length > 0) {                                for (const signType of role_rel.sign_output) {                                    switch (signType) {                                        case COMPANY_SIGN_STR:                                        case PRIVATE_SIGN_STR:                                            // 创建一个新的cell                                            let stampPath = (signType === COMPANY_SIGN_STR) ? role_rel.company_stamp_path : role_rel.private_stamp_path;                                            stampPath = OSS_PATH + stampPath;                                            if (dupPicPaths.indexOf(stampPath) < 0) {                                                dupPicPaths.push(stampPath);                                            }                                            // 签字信息中如果有签章位置信息,则直接用位置信息                                            let signatureArea;                                            if(role_rel.areaData&&role_rel.areaData[signType]){                                                signatureArea =  role_rel.areaData[signType]                                            }                                            const newStampCell = {                                                signature_name: JV.SIGNATURE_NAME_DUMMY,                                                control: sCell.control,                                                style: sCell.style,                                                path: stampPath,                                                isStamp: true,                                                maxRect,                                                orgArea: sCell.area,                                                area: signatureArea || {Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom},                                                signatureName: role_rel.signature_name, // 节点名称                                                signType, // 签章信息                                                isSaveSignature: !!signatureArea, // 是否有签章位置信息                                            };                                            newStampCells.push(newStampCell);                                            break;                                        default: break;                                    }                                }                            }                        }                    }                }            }            if (newStampCells.length > 0) {                page.signature_cells = page.signature_cells.concat(newStampCells);            }        }    }}function resetTextSignature(pageData, checkAudit = false) {    for (const page of pageData.items) {        for (let sCell of page.signature_cells) {            if (!sCell.isStamp) {                let fitCell = null;                for (let idx = page.cells.length - 1; idx >= 0; idx--) {                    const cell = page.cells[idx];                    if (sCell.area.Left === cell.area.Left && sCell.area.Right === cell.area.Right && sCell.area.Top === cell.area.Top && sCell.area.Bottom === cell.area.Bottom) {                        fitCell = cell;                        break;                    }                }                if (fitCell) {                    fitCell.Value = '';                    for (let role of ROLE_REL_LIST) {                        if (!checkAudit || rptSignatureHelper._chkIfAudit(role)) {                            if (sCell.signature_name === role.signature_name) {                                if (role.sign_output && role.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {                                    fitCell.Value = role.user_name;                                } else {                                    fitCell.Value = '';                                }                                break;                            }                        }                    }                } else {                    // 要创建新的文本签名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 },                    };                    if (ROLE_REL_LIST) {                        for (let role of ROLE_REL_LIST) {                            if (!checkAudit || rptSignatureHelper._chkIfAudit(role)) {                                if (sCell.signature_name === role.signature_name && role.sign_output && role.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {                                    newCell.Value = role.user_name;                                    break;                                }                            }                        }                    }                    page.cells.push(newCell); // 怎么也要有这个,哪怕没有文本也要输出,补边框用的                }            }        }    }}function _resetStampArea(ctrl, stampCell, roleRelItem) {    let pLeft = stampCell.orgArea.Left,        pTop = stampCell.orgArea.Top;    if (roleRelItem.stampFeature !== 'not found!') {        let std_stamp_size_width = STD_STAMP_SIZE_WIDTH, std_stamp_size_height = STD_STAMP_SIZE_HEIGHT;        let widthRate = 1, heightRate = 1;        if (roleRelItem.stampFeature) {            std_stamp_size_width = parseFloat(roleRelItem.stampFeature.ImageWidth.value);            std_stamp_size_height = parseFloat(roleRelItem.stampFeature.ImageHeight.value);            if (roleRelItem.stampFeature.ImageWidth.value !== roleRelItem.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 > STD_STAMP_SIZE_WIDTH || std_stamp_size_height > STD_STAMP_SIZE_HEIGHT) {                if (widthRate === 1) {                    std_stamp_size_width = Math.min(std_stamp_size_width, STD_STAMP_SIZE_WIDTH);                    std_stamp_size_height = std_stamp_size_width * heightRate;                } else {                    std_stamp_size_height = Math.min(std_stamp_size_height, STD_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;        }    }}
 |