');
//还有签名日期(用不用得上不管,先放上去再说)
}
body.append(elementsStrArr.join(' '));
}
},
pushDomElementByUser: function (elementsStrArr, userName, userRole) {
elementsStrArr.push('
');
// rptSignatureHelper.pushDatePickerDom(elementsStrArr);
},
pushDomElementByRole: function (elementsStrArr, roleName, userName) {
elementsStrArr.push('
');
// rptSignatureHelper.pushDatePickerDom(elementsStrArr);
},
pushDatePickerDom: function (elementsStrArr) {
let idSuffixStr = 'dtp_' + rptSignatureHelper.currentSelectedESignAccName;
elementsStrArr.push('
');
elementsStrArr.push('
');
},
removeSignature: function (dom) {
let accTxtName = $(dom.parentNode.parentNode.parentNode.parentNode.parentNode).find('label')[0].innerText;
let jDom = $(dom.parentNode.parentNode);
jDom.empty();
jDom.append('
添加签名');
// 要记得清空相关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);
},
resetSignDate: function() {
for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
const role_rel = ROLE_REL_LIST[idx];
const idSuffixStr = 'dtp_' + role_rel.signature_name;
let dtDom = $('#' + idSuffixStr);
if (dtDom.length === 1) {
const dtStr = dtDom[0].value;
if (dtStr && dtStr !== '' && dtStr.length === 10) {
const year = parseInt(dtStr.slice(0, 4));
const month = parseInt(dtStr.slice(5, 7)) - 1;
const dt = parseInt(dtStr.slice(8, 10));
role_rel.sign_date = new Date(year, month, dt);
} else {
role_rel.sign_date = '';
}
// 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)
for (const page of zTreeOprObj.currentRptPageRst.items) {
if (page.signature_date_cells) {
for (const sCell of page.signature_date_cells) {
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);
} else {
sCell.Value = '';
}
}
}
}
}
}
}
// 还有ROLE_REL_LIST
// rptSignatureHelper.cleanOldSignature(accTxtName);
},
setupAfterSelectSignature: function () {
//0. 签名日期
rptSignatureHelper.resetSignDate();
//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.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'),
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'),
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('
');
//1. apply签名
domArr.push('');
domArr.push('');
domArr.push('');
//2. 编辑角色(暂缓处理click事件)
domArr.push('');
domArr.push('');
domArr.push('');
//3. 显示名称
domArr.push(' ' + $('#acc_role_name')[0].value + '' + selectedAcc.name + '-' + roleName + '
');
$('#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('');
//1. apply签名
domArr.push('');
domArr.push('');
domArr.push('');
//2. 编辑角色(暂缓)
domArr.push('');
domArr.push('');
domArr.push('');
//3. 显示名称
let acc = rptSignatureHelper.getUserAccount(role.bind_acc_id);
domArr.push(' ' + role.name + '' + acc.name + '-' + ((acc.role === '')?DFT_ROLE_NAME:acc.role) + '
');
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) {
for (const page of pageData.items) {
if (page.signature_cells) {
for (const sCell of page.signature_cells) {
for (const role_rel of ROLE_REL_LIST) {
if (role_rel.signature_name === sCell.signature_name) {
sCell.path = role_rel.sign_path;
sCell.pre_path = role_rel.sign_path;
}
}
}
}
}
},
mergeSignDate: function () {
if (ROLE_REL_LIST && ROLE_REL_LIST.length > 0 && STAGE_AUDIT && STAGE_AUDIT.length > 0) {
for (let rridx = 0; rridx < ROLE_REL_LIST.length; rridx++) {
const role_rel = ROLE_REL_LIST[rridx];
if (role_rel.sign_date === undefined || role_rel.sign_date === null || role_rel.sign_date === '') {
for (const stg_audit of STAGE_AUDIT) {
if (role_rel.acc_id === stg_audit.aid) {
role_rel.sign_date = stg_audit.end_time;
rptSignatureHelper.originalRoleRelList[rridx].sign_date = stg_audit.end_time;
break;
}
}
}
}
}
}
}