123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743 |
- /**
- * Created by Tony on 2019/9/25.
- */
- 'use strict'
- const DFT_ROLE_NAME = '';
- let rptSignatureHelper = {
- currentSelectedESignAccDom: null,
- currentSelectedESignAccIdx: -1,
- currentSelectedESignAccName: null,
- currentSelectedESignParentDivId: '',
- originalRoleRelList: [],
- 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"><i class="fa fa-caret-down"></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_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>');
- }
- 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 > 20) {
- dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');
- }
- 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.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
- ROLE_REL_LIST.push(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.type = '角色';
- roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
- roleRelObj.role_name = roleAcc.name;
- ROLE_REL_LIST.push(roleRelObj);
- }
- // elementsStrArr.push('');
- rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc.id);
- $(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 !== 'dummy_pic') {
- 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 idSuffixStr = 'dtp_' + role_rel.signature_name + '_' + signatureDivId;
- elementsStrArr.push('<div class="">');
- if (role_rel.sign_date !== '') {
- const dt = new Date(role_rel.sign_date);
- const dtVal = dt.Format('yyyy-MM-dd');
- //elementsStrArr.push('<input class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" value="' + (new Date(role_rel.sign_date)).Format('yyyy-M-d') + '">');
- // elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" readonly="true" value="' + dtVal + '"');
- elementsStrArr.push('<input id="' + idSuffixStr + '" class="form-control form-control-sm mt-0" placeholder="选择签名日期" type="date" value="' + dtVal + '"');
- } else {
- // elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" readonly="true"');
- elementsStrArr.push('<input id="' + idSuffixStr + '" class="form-control form-control-sm mt-0" placeholder="选择签名日期" type="date"');
- }
- 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 () {
- let btnDom = $('#btn_cross_tender')[0];
- if (zTreeOprObj.currentNode) {
- btnDom.style.display = '';
- } else {
- 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>');
- // rptSignatureHelper.pushDatePickerDom(elementsStrArr);
- },
- 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>');
- // rptSignatureHelper.pushDatePickerDom(elementsStrArr);
- },
- pushDatePickerDom: function (elementsStrArr, userAccId) {
- let idSuffixStr = 'dtp_' + rptSignatureHelper.currentSelectedESignAccName + '_' + rptSignatureHelper.currentSelectedESignParentDivId;
- elementsStrArr.push('<div class="">');
- // 日期控件存在页面高度不过高无法选中bug,先不用
- // elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" data-position="right bottom" type="text" readonly="true"');
- //*
- let dftDate = _getSignDateByAllScenarios(userAccId);
- if (dftDate !== '' && dftDate.length > 20) {
- dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');
- }
- /*/
- let dftDate = '';
- let hasAudit = false;
- if (STAGE_AUDIT && STAGE_AUDIT.length > 0) {
- for (const stga of STAGE_AUDIT) {
- if (stga.aid === userAccId) {
- hasAudit = true;
- if (stga.status === 3 && stga.end_time && stga.end_time !== '' && stga.end_time.length > 20) {
- //只有在审批人通过后才获取审批时间
- // let dt = new Date(stga.end_time);
- dftDate = (new Date(stga.end_time)).Format('yyyy-MM-dd');
- } else {
- dftDate = '';
- }
- // 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) {
- dftDate = (new Date(STAGE_AUDIT_ORG[0].begin_time)).Format('yyyy-MM-dd');
- }
- }
- 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) {
- dftDate = period[1];
- }
- }
- }
- }
- //*/
- if (dftDate !== '') {
- elementsStrArr.push('<input id="' + idSuffixStr + '" class="form-control form-control-sm mt-0" placeholder="选择签名日期" type="date" value="' + dftDate + '"');
- } else {
- elementsStrArr.push('<input id="' + idSuffixStr + '" class="form-control form-control-sm mt-0" placeholder="选择签名日期" type="date"');
- }
- 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));
- 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) {
- if (page.signature_date_cells) {
- for (const sCell of page.signature_date_cells) {
- sCell.Value = _getSignDateDftName();
- 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);
- if (dtDom.length === 1) {
- const dtStr = dtDom[0].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 (sCell.signature_name === role_rel.signature_name + '_签字日期') {
- 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 (current_stage_status === 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;
- }
- }
- }
- }
- 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.rpt_id = zTreeOprObj.currentNode.refId;
- params.rel_content = ROLE_REL_LIST;
- params.selectedTenders = selectedTenders;
- rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
- CommonAjax.postXsrfEx("/tender/report_api/updateMultiRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
- function(result){
- console.log(result);
- if (result.data && result.data.insertId > 0) {
- CURRENT_ROLE_REL_ID = result.data.insertId;
- }
- }, function(err){
- // hintBox.unWaitBox();
- }, function(ex){
- // hintBox.unWaitBox();
- }
- );
- },
- setupAfterSelectSignature: function (signatureDivId) {
- //0. 签名日期
- rptSignatureHelper.resetSignDate(signatureDivId);
- rptSignatureHelper.resetSignAudit();
- if (current_stage_status === 3) {
- //1. 重刷page
- 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;
- }
- }
- }
- }
- 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.rpt_id = zTreeOprObj.currentNode.refId;
- params.rel_content = ROLE_REL_LIST;
- // rptSignatureHelper.originalRoleRelList = [];
- // rptSignatureHelper.originalRoleRelList = rptSignatureHelper.originalRoleRelList.concat(ROLE_REL_LIST);
- rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
- CommonAjax.postXsrfEx("/tender/report_api/updateRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
- function(result){
- console.log(result);
- if (result.data && result.data.insertId > 0) {
- CURRENT_ROLE_REL_ID = result.data.insertId;
- }
- }, function(err){
- // hintBox.unWaitBox();
- }, function(ex){
- // hintBox.unWaitBox();
- }
- );
- },
- 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);
- 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;
- },
- mergeSignature: function (pageData, currRoleRelList) {
- for (const page of pageData.items) {
- if (page.signature_cells) {
- for (const sCell of page.signature_cells) {
- for (const role_rel of currRoleRelList) {
- if (role_rel.signature_name === sCell.signature_name) {
- sCell.path = role_rel.sign_path;
- sCell.pre_path = role_rel.sign_path;
- }
- }
- }
- }
- }
- },
- mergeSignAudit: function (pageData, currRoleRelList, currAuditList) {
- 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 (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) {
- 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);
- role_rel.sign_date = dftDate;
- if (isMergeOrgAlso) {
- rptSignatureHelper.originalRoleRelList[rridx].sign_date = dftDate;
- //备注:在多选导出的情况下,originalRoleRelList不需要merge
- }
- /*/
- let hasAudit = false;
- for (const stg_audit of STAGE_AUDIT) {
- if (role_rel.acc_id === stg_audit.aid) {
- hasAudit = true;
- if (stg_audit.status === 3) {
- role_rel.sign_date = stg_audit.end_time;
- rptSignatureHelper.originalRoleRelList[rridx].sign_date = stg_audit.end_time;
- } else {
- role_rel.sign_date = '';
- rptSignatureHelper.originalRoleRelList[rridx].sign_date = '';
- }
- // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
- }
- }
- let isOrgRpt = false;
- for (const stg of STAGE_LIST) {
- if (stg.id === current_stage_id) {
- if (stg.user_id === role_rel.acc_id) {
- 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) {
- role_rel.sign_date = STAGE_AUDIT_ORG[0].begin_time;
- rptSignatureHelper.originalRoleRelList[rridx].sign_date = 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) {
- role_rel.sign_date = period[1];
- rptSignatureHelper.originalRoleRelList[rridx].sign_date = period[1];
- }
- }
- }
- }
- //*/
- }
- }
- }
- 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 (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;
- }
- }
- }
- }
- }
- }
- }
- 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 ' 年 月 日';
- }
|