');
//还有签名日期(用不用得上不管,先放上去再说)
}
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, userAccId) {
let idSuffixStr = 'dtp_' + rptSignatureHelper.currentSelectedESignAccName;
elementsStrArr.push('
');
// 日期控件存在页面高度不过高无法选中bug,先不用
// elementsStrArr.push('
0) {
for (const stga of STAGE_AUDIT) {
if (stga.aid === userAccId) {
hasAudit = true;
if (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');
}
break;
}
}
}
if (!hasAudit && STAGE_FLOW && STAGE_FLOW.length > 0 && STAGE_FLOW[0].aid === userAccId) {
if (STAGE_FLOW[0].begin_time && STAGE_FLOW[0].begin_time !== '' && STAGE_FLOW[0].begin_time.length > 20) {
dftDate = (new Date(STAGE_FLOW[0].begin_time)).Format('yyyy-MM-dd');
}
// 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('
');
},
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 >= 8 && dtStr.length <= 10) {
// // const tmpDt = new Date(dtStr);
// // const year = parseInt(tmpDt.getFullYear());
// // const month = parseInt(tmpDt.getMonth());
// // const dt = parseInt(tmpDt.getDate());
// // role_rel.sign_date = new Date(year, month, dt);
// role_rel.sign_date = new Date(dtStr);
// } 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) {
// sCell.Value = _getSignDateDftName();
// 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 {
// }
// }
// }
// }
// }
// }
// }
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;
let dtDom = $('#' + idSuffixStr);
if (dtDom.length === 1) {
const dtStr = dtDom[0].value;
if (dtStr && dtStr !== '' && dtStr.length >= 8 && dtStr.length <= 10) {
// const tmpDt = new Date(dtStr);
// const year = parseInt(tmpDt.getFullYear());
// const month = parseInt(tmpDt.getMonth());
// const dt = parseInt(tmpDt.getDate());
// role_rel.sign_date = new Date(year, month, dt);
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);
}
}
}
}
}
}
}
},
setupAfterSelectSignature: function () {
//0. 签名日期
rptSignatureHelper.resetSignDate();
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'),
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, 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;
}
}
}
}
}
},
mergeSignDate: function (pageData, currRoleRelList) {
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 === '') {
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;
}
}
}
}
}
for (const page of pageData.items) {
if (page.signature_date_cells) {
for (const sCell of page.signature_date_cells) {
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 _getSignDateDftName() {
return ' 年 月 日';
}