/** * Created by Tony on 2019/9/25. */ 'use strict' let rptSignatureHelper = { currentSelectedESignAccDom: null, currentSelectedESignAccName: null, originalRoleRelList: [], buildSelectableAccount: function () { //PRJ_ACCOUNT_LIST //1. 清理所有选择项 // $("#project_account_select_div").empty(); let accDiv = $('#project_account_select_div'); let accSelect = $('#project_account_select_dom'); //绑定成员 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]; let companyKey = prjAccount.company; let roleKey = prjAccount.role; if (companyKey === '') { companyKey = '其他单位'; } if (roleKey === '') { roleKey = '工程师'; } 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('
' + userName + '-' + ((userRole === '')?"工程师":userRole) + '
') }, pushDomElementByRole: function (elementsStrArr, roleName, userName) { elementsStrArr.push('' + roleName + '-' + userName + '
') }, 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); zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas); }, setupAfterSelectSignature: function () { //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); 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 === '')?'工程师':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('' + 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('' + acc.name + '-' + ((acc.role === '')?"工程师":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; }, mergeSignDate: function () { if (ROLE_REL_LIST && ROLE_REL_LIST.length > 0 && STAGE_AUDIT && STAGE_AUDIT.length > 0) { for (const role_rel of ROLE_REL_LIST) { 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; break; } } } } } } }