rpt_signature.js 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687
  1. /**
  2. * Created by Tony on 2019/9/25.
  3. */
  4. 'use strict'
  5. const DFT_ROLE_NAME = '';
  6. const NORMAL_SIGN_STR = 'normal_sign';
  7. const COMPANY_SIGN_STR = 'company_stamp';
  8. const PRIVATE_SIGN_STR = 'private_stamp';
  9. const STD_STAMP_SIZE_WIDTH = 5 * 96 / 2.54; // 公章大小:宽度(5 CM)
  10. const STD_STAMP_SIZE_HEIGHT = 5 * 96 / 2.54; // 公章大小:高度(5 CM)
  11. let rptSignatureHelper = {
  12. currentSelectedESignAccDom: null,
  13. currentSelectedESignAccIdx: -1,
  14. currentSelectedESignAccName: null,
  15. currentSelectedESignParentDivId: '',
  16. originalRoleRelList: [],
  17. collapseExpandTreeNode: (dom, isDblClick = false) => {
  18. const classMap = {
  19. 'fa fa-caret-down': ['fa fa-caret-right', 'none'],
  20. 'fa fa-caret-right': ['fa fa-caret-down', ''],
  21. };
  22. const curPicDom = isDblClick ? $(dom).children()[0] : dom;
  23. const doms = $($(curPicDom).parent()).nextAll();
  24. for (let idx = 0; idx < doms.length; idx++) {
  25. doms[idx].style.display = classMap[curPicDom.className][1];
  26. }
  27. curPicDom.className = classMap[curPicDom.className][0];
  28. },
  29. buildFlowAccount: function() {
  30. // 显示:显示当前期(或材差、预付款等)的审核流程里面审批类型为协同的流程
  31. // 1. 清理所有选择项
  32. const accDiv = $('#assistant_audit_account_div');
  33. accDiv.empty();
  34. // 2. 获取STAG_FLOW的审核信息(如一审、二审等)
  35. const collectedSf = [];
  36. STAGE_FLOW.forEach(sf => {
  37. // audit_type === 4 // 4是协审
  38. if (sf.audit_type === 4) {
  39. collectedSf.push(sf);
  40. }
  41. });
  42. if (collectedSf.length > 0) {
  43. const cacheObj = {};
  44. collectedSf.forEach(sf => {
  45. const chnStr = `${transFormToChinese(sf.audit_order)}审`;
  46. if (!cacheObj[chnStr]) {
  47. cacheObj[chnStr] = { order: sf.audit_order };
  48. }
  49. // cacheObj[chnStr].push(sf);
  50. });
  51. const htmls = ['<ul class="list-group">'];
  52. // htmls.push('<optgroup label="审批流程">');
  53. htmls.push('<li class="px-2 text-muted"><i class="fa fa-caret-down"></i>审批流程</li>');
  54. for (let key in cacheObj) {
  55. // cacheObj[key]
  56. // htmls.push(`<a class="dropdown-item" href="javascript: void(0)" data-dismiss="modal">${key}(协同)</a>`);
  57. htmls.push(`<a class="dropdown-item" href="javascript: void(0)" onclick="rptSignatureHelper.createEsignatureByAssistantFlow('${key}', ${cacheObj[key].order})" data-dismiss="modal">${key}(协同)</a>`);
  58. }
  59. // htmls.push('</optgroup>');
  60. htmls.push('</ul>')
  61. accDiv.append(htmls.join(''));
  62. } else {
  63. // 隐藏这里的div/button?
  64. }
  65. },
  66. buildSelectableAccount: function () {
  67. //PRJ_ACCOUNT_LIST
  68. //1. 清理所有选择项
  69. // $("#project_account_select_div").empty();
  70. let accDiv = $('#project_account_select_div');
  71. let accSelect = $('#project_account_select_dom'); //绑定成员
  72. let searchInput = $('#search_account').val();
  73. accDiv.empty();
  74. accSelect.empty();
  75. //2. 一个个加可选用户项
  76. const prj_accounts = [];
  77. const prj_sel_option_accounts = [];
  78. const acc_role_keys = [];
  79. for (let accIdx = 0; accIdx < PRJ_ACCOUNT_LIST.length; accIdx++) {
  80. const prjAccount = PRJ_ACCOUNT_LIST[accIdx];
  81. if (searchInput === '' || (searchInput !== '' && prjAccount.name.indexOf(searchInput) !== -1)) {
  82. let companyKey = prjAccount.account_group;
  83. let roleKey = prjAccount.role;
  84. if (companyKey === '') {
  85. companyKey = '其他单位';
  86. }
  87. if (roleKey === '') {
  88. roleKey = DFT_ROLE_NAME;
  89. }
  90. let keyIdx = acc_role_keys.indexOf(companyKey);
  91. if (keyIdx < 0) {
  92. acc_role_keys.push(companyKey);
  93. prj_accounts.push([]);
  94. prj_sel_option_accounts.push([]);
  95. keyIdx = prj_accounts.length - 1;
  96. //这里先push一些 html prefix,在后面统一在push html suffix
  97. prj_accounts[keyIdx].push('<ul class="list-group">');
  98. 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>');
  99. prj_sel_option_accounts[keyIdx].push('<optgroup label=" ' + companyKey + '">');
  100. }
  101. //push item
  102. // 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>' +
  103. // prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
  104. 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>`);
  105. prj_sel_option_accounts[keyIdx].push('<option value="' + accIdx + '">' + prjAccount.name + '-' + roleKey + '</option>');
  106. }
  107. }
  108. for (const prjAccList of prj_accounts) {
  109. prjAccList.push('</ul>');
  110. }
  111. for (const prjAccList of prj_sel_option_accounts) {
  112. prjAccList.push('</optgroup>');
  113. }
  114. for (let idx = 0; idx < prj_accounts.length; idx++) {
  115. prj_accounts[idx] = prj_accounts[idx].join('');
  116. prj_sel_option_accounts[idx] = prj_sel_option_accounts[idx].join('');
  117. }
  118. accDiv.append(prj_accounts.join(''));
  119. accSelect.append(prj_sel_option_accounts.join(''));
  120. },
  121. buildSelectableAccountUsed: function () {
  122. //PRJ_ACCOUNT_LIST
  123. //1. 清理所有选择项
  124. // $("#project_account_select_div").empty();
  125. let accDiv = $('#account_used_select_div');
  126. accDiv.empty();
  127. //2. 一个个加可选用户项
  128. const prj_accounts = [];
  129. for (let uidx = 0; uidx < USED_LIST.length; uidx++) {
  130. const accIdx = PRJ_ACCOUNT_LIST.findIndex(function(item) {
  131. return item.id === USED_LIST[uidx].uid;
  132. });
  133. if (accIdx === -1 || accIdx === undefined) {
  134. continue;
  135. }
  136. const prjAccount = PRJ_ACCOUNT_LIST[accIdx];
  137. let roleKey = prjAccount.role;
  138. if (roleKey === '') {
  139. roleKey = DFT_ROLE_NAME;
  140. }
  141. //push item
  142. // 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>' +
  143. // prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
  144. 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>`);
  145. }
  146. accDiv.append(prj_accounts.join(''));
  147. },
  148. createEsignatureByAssistantFlow: function(assName, order) {
  149. const dftSignSrc = '/public/upload/sign/user-sign.PNG';
  150. if (rptSignatureHelper.currentSelectedESignAccName !== null) {
  151. for (const page of zTreeOprObj.currentRptPageRst.items) {
  152. if (page.signature_cells) {
  153. for (const sCell of page.signature_cells) {
  154. if (sCell.signature_name === rptSignatureHelper.currentSelectedESignAccName) {
  155. sCell.pre_path = dftSignSrc;
  156. }
  157. }
  158. }
  159. }
  160. // 1. 删除不需要的child dom
  161. $(rptSignatureHelper.currentSelectedESignAccDom).empty();
  162. // 2. 创建已选择签名相关 dom
  163. rptSignatureHelper.cleanOldSignature(rptSignatureHelper.currentSelectedESignAccName);
  164. const elementsStrArr = [];
  165. rptSignatureHelper.pushDomElementByFlow(elementsStrArr, `${assName}(协同)`, rptSignatureHelper.currentSelectedESignAccName);
  166. let roleRelObj = {};
  167. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  168. roleRelObj.type = '流程';
  169. roleRelObj.flowOrder = order;
  170. roleRelObj.flow_name = `${assName}(协同)`;
  171. roleRelObj.assFlowInfos = []; // 这里动态记录流程的协审信息(含:人名、单位、职位、签字签章、签字日期, 其实相当于另一个完整的roleRel对象)
  172. roleRelObj.sign_output = [];
  173. ROLE_REL_LIST.push(roleRelObj);
  174. STAGE_FLOW.forEach(sf => {
  175. if (sf.audit_order === order) {
  176. const userAcc = rptSignatureHelper.getUserAccount(sf.aid);
  177. let dftDate = '';
  178. const status = _getStatusByUserId(userAcc.id);
  179. if (status === 3) dftDate = _getSignDateByAllScenarios(userAcc.id);
  180. const newRoleRel = {
  181. signature_name: rptSignatureHelper.currentSelectedESignAccName,
  182. acc_id: sf.aid,
  183. user_name: sf.name,
  184. company: sf.company,
  185. role: sf.role,
  186. sign_date: dftDate,
  187. sign_date_format: 'yyyy年M月d日',
  188. sign_output: [NORMAL_SIGN_STR], // , PRIVATE_SIGN_STR, COMPANY_SIGN_STR
  189. company_stamp_path: rptSignatureHelper._getCompanySign(sf.company),
  190. status, // 记录一下吧,没坏处
  191. }
  192. newRoleRel.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(newRoleRel, userAcc); // 个人章从PRJ_ACCOUNT_LIST中获取
  193. let dftSignSrc = userAcc.sign_path;
  194. if (userAcc.sign_path !== '') {
  195. dftSignSrc = '/public/upload/sign/' + userAcc.sign_path;
  196. }
  197. newRoleRel.sign_path = dftSignSrc;
  198. roleRelObj.assFlowInfos.push(newRoleRel);
  199. }
  200. });
  201. $(rptSignatureHelper.currentSelectedESignAccDom).append(elementsStrArr.join(' '));
  202. }
  203. },
  204. getFlowRoleRel(signature_name) {
  205. let rst = null;
  206. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  207. if (ROLE_REL_LIST[idx].signature_name === signature_name) {
  208. rst = ROLE_REL_LIST[idx];
  209. break;
  210. }
  211. }
  212. return rst;
  213. },
  214. iniAssFlowDialog(roleRelObj) {
  215. if (roleRelObj.type !== '流程') return;
  216. // 初始化协同人信息
  217. const assFlowDialog = $('#assistant-flow-setting-table')
  218. assFlowDialog.empty();
  219. const assFlowElements = [];
  220. assFlowElements.push('<tr class="text-center"><th width="60px">协同人</th><th>单位</th><th>职位</th><th width="100px">签字</th><th width="100px">个人章</th><th width="100px">公司章</th><th width="120px">签字日期</th></tr>');
  221. roleRelObj.assFlowInfos.forEach((flowRoleRel, index) => {
  222. const userAcc = rptSignatureHelper.getUserAccount(flowRoleRel.acc_id);
  223. assFlowElements.push('<tr class="text-center">');
  224. // 栏头
  225. assFlowElements.push(`<td>${flowRoleRel.user_name}</td><td>${flowRoleRel.company}</td><td>${flowRoleRel.role}</td>`);
  226. // 签字
  227. const normalChk = flowRoleRel.sign_output.includes(NORMAL_SIGN_STR) ? 'checked' : '';
  228. assFlowElements.push(`<td><input type="checkbox" ${normalChk} onchange="rptSignatureHelper._changeSignType(this, '${roleRelObj.signature_name}', '${NORMAL_SIGN_STR}', '${userAcc.stamp_path || ''}', ${index})" ></td>`);
  229. //
  230. // 个人章
  231. if (flowRoleRel.private_stamp_path && flowRoleRel.private_stamp_path !== '') {
  232. const privateChk = flowRoleRel.sign_output.includes(PRIVATE_SIGN_STR) ? 'checked' : '';
  233. const pathList = (userAcc.stamp_path || '').split(';');
  234. let privateSignSelection = '个人章';
  235. if (pathList.length > 1) {
  236. privateSignSelection = `<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}','${roleRelObj.signature_name}', ${index}) ">选择个人章</a>`;
  237. }
  238. assFlowElements.push(`<td><input type="checkbox" ${privateChk} onchange="rptSignatureHelper._changeSignType(this, '${roleRelObj.signature_name}', '${PRIVATE_SIGN_STR}', '${userAcc.stamp_path || ''}', ${index})" >
  239. ${privateSignSelection}</td>`);
  240. } else {
  241. assFlowElements.push(`<td></td>`);
  242. }
  243. // 公司章 + 签字日期
  244. const dateIdSuffixStr = `flowdtp_${roleRelObj.signature_name}_${index}`;
  245. if (flowRoleRel.company_stamp_path && flowRoleRel.company_stamp_path !== '') {
  246. let dftDate = '';
  247. if (flowRoleRel.sign_date !== '' && flowRoleRel.sign_date.length >= 10) {
  248. dftDate = (new Date(flowRoleRel.sign_date)).Format('yyyy-MM-dd');
  249. } else if (flowRoleRel.sign_date instanceof Date){
  250. dftDate = flowRoleRel.sign_date.Format('yyyy-MM-dd');
  251. }
  252. const companyChk = flowRoleRel.sign_output.includes(COMPANY_SIGN_STR) ? 'checked' : '';
  253. assFlowElements.push(`<td><input type="checkbox" ${companyChk} onchange="rptSignatureHelper._changeSignType(this, '${roleRelObj.signature_name}', '${COMPANY_SIGN_STR}', '${userAcc.stamp_path || ''}', ${index})" ></td>`);
  254. assFlowElements.push(`<td><input type="text" class="form-control form-control-sm datepicker-here height-inputbox" aria-label="Small" aria-describedby="inputGroup-sizing-sm" data-language="zh"
  255. id="${dateIdSuffixStr}" value="${dftDate || ''}"></td>`);
  256. // 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>`);
  257. } else {
  258. assFlowElements.push(`<td></td>`);
  259. }
  260. // 收尾
  261. assFlowElements.push('</tr>');
  262. });
  263. rptSignatureHelper.currentSelectedESignAccName = roleRelObj.signature_name;
  264. assFlowDialog.append(assFlowElements.join(' '));
  265. },
  266. createEsignatureByAccIdx: function (accIdx) {
  267. rptSignatureHelper.createPreSelectedSignature(PRJ_ACCOUNT_LIST[accIdx], null);
  268. },
  269. createEsignatureByRoleIdx: function (roleIdx) {
  270. rptSignatureHelper.createPreSelectedSignature(null, ROLE_LIST[roleIdx]);
  271. },
  272. createPreSelectedSignature: function (directAcc, roleAcc) {
  273. let dftSignSrc = '/public/upload/sign/user-sign.PNG';
  274. let userAcc = directAcc;
  275. if (roleAcc) {
  276. userAcc = rptSignatureHelper.getUserAccount(roleAcc.bind_acc_id);
  277. }
  278. if (userAcc.sign_path !== '') {
  279. dftSignSrc = '/public/upload/sign/' + userAcc.sign_path;
  280. }
  281. if (rptSignatureHelper.currentSelectedESignAccName !== null) {
  282. for (const page of zTreeOprObj.currentRptPageRst.items) {
  283. if (page.signature_cells) {
  284. for (const sCell of page.signature_cells) {
  285. if (sCell.signature_name === rptSignatureHelper.currentSelectedESignAccName) {
  286. sCell.pre_path = dftSignSrc;
  287. }
  288. }
  289. }
  290. }
  291. // 1. 删除不需要的child dom
  292. $(rptSignatureHelper.currentSelectedESignAccDom).empty();
  293. // 2. 创建已选择签名相关 dom
  294. rptSignatureHelper.cleanOldSignature(rptSignatureHelper.currentSelectedESignAccName);
  295. // 2.1 dom element
  296. const elementsStrArr = [];
  297. let dftDate = _getSignDateByAllScenarios(userAcc.id);
  298. if (dftDate !== '' && dftDate.length >= 10) {
  299. dftDate = new Date(dftDate); // 不Format,保留时分秒
  300. } else if (dftDate === '') {
  301. if (current_stage_id <= -300 && current_stage_id > -400 && BGL_OBJ && BGL_OBJ.currentBz && BGL_OBJ.currentBz.status === 3) {
  302. if (STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  303. dftDate = new Date(STAGE_AUDIT[STAGE_AUDIT.length - 1].end_time);
  304. } else {
  305. dftDate = new Date();
  306. }
  307. } else {
  308. dftDate = new Date();
  309. }
  310. }
  311. let roleRel = null;
  312. if (directAcc) {
  313. rptSignatureHelper.pushDomElementByUser(elementsStrArr, userAcc.name, userAcc.role);
  314. // 还有ROLE_REL_LIST
  315. let roleRelObj = {};
  316. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  317. roleRelObj.sign_path = dftSignSrc;
  318. // roleRelObj.sign_date = '';
  319. roleRelObj.sign_date = dftDate;
  320. roleRelObj.sign_date_format = 'yyyy年M月d日';
  321. roleRelObj.user_name = userAcc.name;
  322. roleRelObj.acc_id = userAcc.id;
  323. roleRelObj.type = '用户';
  324. roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)
  325. roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(directAcc.company);
  326. roleRelObj.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(roleRelObj,userAcc);
  327. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  328. ROLE_REL_LIST.push(roleRelObj);
  329. roleRel = roleRelObj;
  330. } else if (roleAcc) {
  331. // 创建相关dom元素
  332. rptSignatureHelper.pushDomElementByRole(elementsStrArr, roleAcc.name, userAcc.name);
  333. // 还有ROLE_REL_LIST
  334. let roleRelObj = {};
  335. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  336. roleRelObj.sign_path = dftSignSrc;
  337. // roleRelObj.sign_date = '';
  338. roleRelObj.sign_date = dftDate;
  339. roleRelObj.sign_date_format = 'yyyy年M月d日';
  340. roleRelObj.user_name = userAcc.name;
  341. roleRelObj.acc_id = userAcc.id;
  342. roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)
  343. roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  344. roleRelObj.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(roleRelObj,userAcc);
  345. roleRelObj.type = '角色';
  346. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  347. roleRelObj.role_name = roleAcc.name;
  348. ROLE_REL_LIST.push(roleRelObj);
  349. roleRel = roleRelObj;
  350. }
  351. // elementsStrArr.push('');
  352. rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, roleRel, 0);
  353. $(rptSignatureHelper.currentSelectedESignAccDom).append(elementsStrArr.join(' '));
  354. //.appendChild(pNode);
  355. //*/
  356. // 2.2 date-picker
  357. // 更新最近使用名单
  358. const params = {};
  359. params.uid = userAcc.id;
  360. params.prj_id = PROJECT_ID;
  361. params.tender_id = TENDER_ID;
  362. CommonAjax.postXsrfEx("/tender/report_api/updateSignatureUsed", params, 10000, true, getCookie('csrfToken_j'),
  363. function(result){
  364. console.log(result);
  365. USED_LIST = result.data;
  366. $('#search_account').val('');
  367. rptSignatureHelper.buildFlowAccount();
  368. rptSignatureHelper.buildSelectableAccount();
  369. rptSignatureHelper.buildSelectableAccountUsed();
  370. }, function(err){
  371. // hintBox.unWaitBox();
  372. }, function(ex){
  373. // hintBox.unWaitBox();
  374. }
  375. );
  376. }
  377. },
  378. cleanOldSignature: function (signature_name) {
  379. // 清掉ROLE_REL_LIST原有的签名
  380. for (let idx = ROLE_REL_LIST.length - 1; idx >= 0 ; idx--) {
  381. if (ROLE_REL_LIST[idx].signature_name === signature_name) {
  382. ROLE_REL_LIST.splice(idx, 1);
  383. }
  384. }
  385. },
  386. resetESignature: function (pageRst, signatureDivId, cleanSignDate = false) {
  387. // let body = $('#eSignatureBodyDiv');
  388. if (pageRst !== null) {
  389. let body = $('#' + signatureDivId);
  390. rptSignatureHelper.currentSelectedESignParentDivId = signatureDivId;
  391. body.empty();
  392. const signature_cells = [];
  393. const singatureNameArr = [];
  394. for (const page of pageRst.items) {
  395. if (page.signature_cells) {
  396. for (const sCell of page.signature_cells) {
  397. if (sCell.signature_name !== null && sCell.signature_name !== undefined && sCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0) {
  398. if (singatureNameArr.indexOf(sCell.signature_name) < 0) {
  399. signature_cells.push(sCell);
  400. singatureNameArr.push(sCell.signature_name);
  401. }
  402. }
  403. }
  404. }
  405. }
  406. if (signature_cells.length > 0) {
  407. const elementsStrArr = [];
  408. const elementsDateStrArr = [];
  409. for (let scIdx = 0; scIdx < signature_cells.length; scIdx++) {
  410. const sCell = signature_cells[scIdx];
  411. elementsStrArr.push('<div class="form-group row">');
  412. elementsStrArr.push('<label for="staticEmail" class="col-sm-2 col-form-label pr-0">' + sCell.signature_name + '</label>');
  413. elementsStrArr.push('<div class="col-sm-10">');
  414. elementsStrArr.push('<ul class="list-group">');
  415. elementsStrArr.push('<li class="list-group-item">');
  416. let hasPic = false;
  417. //新需求中,即使没有审核,也可以设置签名
  418. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  419. const role_rel = ROLE_REL_LIST[idx];
  420. if (role_rel.signature_name === sCell.signature_name) {
  421. if (role_rel.type === '用户') {
  422. rptSignatureHelper.pushDomElementByUser(elementsStrArr, role_rel.user_name, role_rel.role);
  423. } else if (role_rel.type === '角色') {
  424. rptSignatureHelper.pushDomElementByRole(elementsStrArr, role_rel.role_name, role_rel.user_name);
  425. } else {
  426. // 流程
  427. rptSignatureHelper.pushDomElementByFlow(elementsStrArr, role_rel.flow_name, role_rel.signature_name);
  428. }
  429. if (role_rel.type === '流程') {
  430. role_rel.assFlowInfos.forEach(sf => {
  431. const userAcc = rptSignatureHelper.getUserAccount(sf.acc_id);
  432. if (userAcc) {
  433. sf.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(sf, userAcc);
  434. sf.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  435. }
  436. });
  437. } else {
  438. const userAcc = rptSignatureHelper.getUserAccount(role_rel.acc_id);
  439. if (userAcc) {
  440. role_rel.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(role_rel,userAcc);
  441. role_rel.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  442. }
  443. rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, role_rel, idx);
  444. }
  445. hasPic = true;
  446. break;
  447. }
  448. }
  449. if (!hasPic) {
  450. // 在交互操作中,有可能实际上是没有
  451. 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>');
  452. }
  453. // if (sCell.path || sCell.pic) {
  454. // } else {
  455. // 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>');
  456. // }
  457. elementsStrArr.push('</li>');
  458. elementsStrArr.push('</ul>');
  459. elementsStrArr.push('</div>');
  460. elementsStrArr.push('</div>');
  461. //还有签名日期(用不用得上不管,先放上去再说)
  462. }
  463. body.append(elementsStrArr.join(' '));
  464. }
  465. }
  466. },
  467. checkAndShowCrossTendersESignature: function (fujianOssPath) {
  468. rptSignatureHelper.fujianOssPath=fujianOssPath;
  469. let btnDom = $('#btn_cross_tender')[0];
  470. if (zTreeOprObj.currentNode) {
  471. if (btnDom) btnDom.style.display = '';
  472. } else {
  473. if (btnDom) btnDom.style.display = 'none';
  474. }
  475. },
  476. pushDomElementByUser: function (elementsStrArr, userName, userRole) {
  477. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span>' + userName +
  478. '-<small class="text-muted">' + ((userRole === '')?DFT_ROLE_NAME:userRole) +
  479. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  480. },
  481. pushDomElementByRole: function (elementsStrArr, roleName, userName) {
  482. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span><i class="fa fa-user" title="角色"> ' + roleName +
  483. '</i>-<small class="text-muted">' + userName +
  484. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  485. },
  486. pushDomElementByFlow: function (elementsStrArr, flowName, signature_name) {
  487. elementsStrArr.push(`<p class=" d-flex justify-content-between m-0"><span>${flowName}<a href="#add-liucheng" data-toggle="modal" data-target="#add-liucheng"
  488. onclick="rptSignatureHelper.iniAssFlowDialog(rptSignatureHelper.getFlowRoleRel('${signature_name}'))">(设置签字签章)</a>
  489. </span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>`);
  490. },
  491. pushDatePickerDom: function (elementsStrArr, userAcc, role_rel, seq = 0) {
  492. if (role_rel.type === '流程') return;
  493. const dateIdSuffixStr = 'dtp_' + role_rel.signature_name + '_' + rptSignatureHelper.currentSelectedESignParentDivId;
  494. let milliSec = (new Date()).getMilliseconds();
  495. const idSuffixStr = `dtp_${seq}_${milliSec}_${rptSignatureHelper.currentSelectedESignParentDivId}`;
  496. elementsStrArr.push('<div class="mt-3">');
  497. elementsStrArr.push('<div class="row">');
  498. //-------------------------------------------------
  499. if (!Array.isArray(role_rel.sign_output)) {
  500. role_rel.sign_output = [NORMAL_SIGN_STR];
  501. }
  502. const normalSignChkStr = (role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) ? 'checked' : '';
  503. const companySignChkStr = (role_rel.sign_output.indexOf(COMPANY_SIGN_STR) >= 0) ? 'checked' : '';
  504. const privateSignChkStr = (role_rel.sign_output.indexOf(PRIVATE_SIGN_STR) >= 0) ? 'checked' : '';
  505. // 1. 签章类型:签字 单位章 个人章....
  506. elementsStrArr.push('<div class="col-8">');
  507. elementsStrArr.push(' <div class="form-control form-control-sm d-inline pt-2">');
  508. elementsStrArr.push(' <div class="form-check form-check-inline px-2">');
  509. 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}')" >`);
  510. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign1">签字</label>`);
  511. elementsStrArr.push(' </div>');
  512. const hasIndividualStamp = (userAcc && userAcc.stamp_path && userAcc.stamp_path !== ''); //用户账号的stamp_path是属于用户自己的私章,不是公司章
  513. // let chkType = hasIndividualStamp ? `radio` : 'checkbox';
  514. const chkType = 'checkbox';
  515. let rdoNameStr = `dtp_${role_rel.signature_name}_${rptSignatureHelper.currentSelectedESignParentDivId}`;
  516. // 个人章列表
  517. const stampPathList=userAcc&&userAcc.stamp_path?userAcc.stamp_path.split('!;!'):[];
  518. if (hasIndividualStamp) {
  519. elementsStrArr.push(' <div class="form-check form-check-inline mx-1">');
  520. elementsStrArr.push(' <div class="form-group">');
  521. elementsStrArr.push(' <div class="form-check form-check-inline px-1">');
  522. 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}>`);
  523. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign2">单位章</label>`);
  524. elementsStrArr.push(' </div>');
  525. elementsStrArr.push(' <div class="form-check form-check-inline">');
  526. 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}>`);
  527. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign3">个人章</label>`);
  528. if(stampPathList.length>1){
  529. 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>`);
  530. }
  531. elementsStrArr.push(' </div>');
  532. elementsStrArr.push(' </div>');
  533. elementsStrArr.push(' </div>');
  534. } else {
  535. elementsStrArr.push(' <div class="form-check form-check-inline px-2">');
  536. 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}>`);
  537. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign10">单位章</label>`);
  538. elementsStrArr.push(' </div>');
  539. }
  540. elementsStrArr.push(' </div>');
  541. elementsStrArr.push('</div>');
  542. // 2. 日期
  543. elementsStrArr.push('<div class="col-4">');
  544. let dftDate = '';
  545. if (role_rel.sign_date !== '' && role_rel.sign_date.length >= 10) {
  546. dftDate = (new Date(role_rel.sign_date)).Format('yyyy-MM-dd');
  547. } else if (role_rel.sign_date instanceof Date){
  548. dftDate = role_rel.sign_date.Format('yyyy-MM-dd');
  549. } else {
  550. if (userAcc) dftDate = _getSignDateByAllScenarios(userAcc.id);
  551. if (dftDate !== '' && dftDate.length >= 10) {
  552. dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');
  553. }
  554. }
  555. elementsStrArr.push('<div class="input-group input-group-sm margin-inputbox">');
  556. elementsStrArr.push(' <div class="input-group-prepend">');
  557. elementsStrArr.push(' <span class="input-group-text height-inputbox" id="inputGroup-sizing-sm"><i class="fa fa-calendar" title="添加签名日期"></i></span>');
  558. elementsStrArr.push(' </div>');
  559. if (dftDate !== '') {
  560. 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>`);
  561. } else {
  562. 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>`);
  563. }
  564. elementsStrArr.push('</div>');
  565. //-------------------------------------------------
  566. elementsStrArr.push('</div>');
  567. elementsStrArr.push('</div>');
  568. },
  569. removeSignature: function (dom) {
  570. let accTxtName = $(dom.parentNode.parentNode.parentNode.parentNode.parentNode).find('label')[0].innerText;
  571. let jDom = $(dom.parentNode.parentNode);
  572. jDom.empty();
  573. jDom.append('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.currentSelectedESignAccName = \'' +
  574. accTxtName + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签字</a>');
  575. // 要记得清空相关pre_path属性
  576. for (const page of zTreeOprObj.currentRptPageRst.items) {
  577. if (page.signature_cells) {
  578. for (const sCell of page.signature_cells) {
  579. if (sCell.signature_name === accTxtName) {
  580. sCell.pre_path = '';
  581. }
  582. }
  583. }
  584. }
  585. // 还有ROLE_REL_LIST
  586. rptSignatureHelper.cleanOldSignature(accTxtName);
  587. },
  588. removeSelectSignature: function () {
  589. for (const page of zTreeOprObj.currentRptPageRst.items) {
  590. if (page.signature_cells) {
  591. for (const sCell of page.signature_cells) {
  592. if (sCell.hasOwnProperty('pre_path')) {
  593. delete sCell.pre_path;
  594. }
  595. }
  596. }
  597. }
  598. // ROLE_REL_LIST = [];
  599. // ROLE_REL_LIST = ROLE_REL_LIST.concat(rptSignatureHelper.originalRoleRelList);
  600. ROLE_REL_LIST = JSON.parse(JSON.stringify(rptSignatureHelper.originalRoleRelList));
  601. if (PAGE_SHOW.isTextSignature) {
  602. // resetTextSignature(zTreeOprObj.currentRptPageRst);
  603. resetTextSignature(zTreeOprObj.currentRptPageRst, getStageStatus() !== 3);
  604. }
  605. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  606. },
  607. resetSignAudit: function () {
  608. rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT);
  609. },
  610. resetSignDate: function(signatureDivId) {
  611. for (const page of zTreeOprObj.currentRptPageRst.items) {
  612. // 调整了下次序,无论有没有签名时间显示,签名对象的sign_date必须得更新及保存
  613. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  614. const role_rel = ROLE_REL_LIST[idx];
  615. if (role_rel.type !== '流程') {
  616. const idSuffixStr = 'dtp_' + role_rel.signature_name + '_' + signatureDivId;
  617. let dtDom = document.getElementById(idSuffixStr); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象
  618. if (dtDom) {
  619. const dtStr = dtDom.value;
  620. if (dtStr && dtStr !== '' && dtStr.length >= 8 && dtStr.length <= 10) {
  621. role_rel.sign_date = new Date(dtStr);
  622. } else {
  623. role_rel.sign_date = '';
  624. }
  625. // 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)
  626. if (page.signature_date_cells) {
  627. for (const sCell of page.signature_date_cells) {
  628. // 在重设之前要先清空旧的日期
  629. sCell.Value = '';
  630. }
  631. for (const sCell of page.signature_date_cells) {
  632. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  633. sCell.Value = _getSignDateDftName();
  634. if (role_rel.sign_date !== '') {
  635. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  636. }
  637. }
  638. }
  639. }
  640. }
  641. } else {
  642. // 流程的处理不一样
  643. }
  644. }
  645. }
  646. },
  647. _commonRefreshAfterSelectSignature: async function(signatureDivId) {
  648. //0. 签名日期
  649. rptSignatureHelper.resetSignDate(signatureDivId);
  650. rptSignatureHelper.resetSignAudit();
  651. //1. 重刷page(不用考虑审核状态)
  652. for (const page of zTreeOprObj.currentRptPageRst.items) {
  653. if (page.signature_cells) {
  654. for (let cIdx = page.signature_cells.length - 1; cIdx >= 0; cIdx--) {
  655. const sCell = page.signature_cells[cIdx];
  656. if (sCell.isStamp) {
  657. page.signature_cells.splice(cIdx);
  658. } else if (sCell.hasOwnProperty('pre_path')) {
  659. sCell.path = sCell.pre_path;
  660. delete sCell.pre_path;
  661. }
  662. }
  663. }
  664. }
  665. resetStampSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3, STAGE_AUDIT, LEDGER_LIST);
  666. rptSignatureHelper.mergeSignDate(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
  667. rptSignatureHelper.mergeSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
  668. await rptSignatureHelper.resetDummySignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3);
  669. // rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT, getStageStatus() !== 3);
  670. if (PAGE_SHOW.isTextSignature) {
  671. resetTextSignature(zTreeOprObj.currentRptPageRst, getStageStatus() !== 3);
  672. }
  673. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  674. },
  675. _getCommonParams: function() {
  676. const params = {};
  677. params.id = CURRENT_ROLE_REL_ID;
  678. params.tender_id = TENDER_ID;
  679. params.stage_id = getStageId();
  680. params.business_id = BUSINESS_ID;
  681. params.source_type = SOURCE_TYPE;
  682. params.rpt_id = zTreeOprObj.currentNode.refId;
  683. // params.rel_content = ROLE_REL_LIST;
  684. params.rel_content = [];
  685. ROLE_REL_LIST.forEach(role_rel => {
  686. if (role_rel.signature_name.indexOf('dummy_pic') < 0) {
  687. params.rel_content.push(role_rel);
  688. }
  689. });
  690. return params;
  691. },
  692. setupAfterSelectMultiChanges: async function (selectedChanges, signatureDivId) {
  693. // 多变更令选择
  694. await this._commonRefreshAfterSelectSignature(signatureDivId);
  695. const params = this._getCommonParams();
  696. params.selectedChanges = selectedChanges;
  697. const new_ROLE_REL_LIST = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  698. new_ROLE_REL_LIST.forEach(nrole => {
  699. nrole.sign_pic = null;
  700. });
  701. params.rel_content = new_ROLE_REL_LIST;
  702. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  703. CommonAjax.postXsrfEx("/tender/report_api/updateMultiChangesRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  704. function(result){
  705. $.bootstrapLoading.end();
  706. if (result.data && result.data.insertId > 0) {
  707. CURRENT_ROLE_REL_ID = result.data.insertId;
  708. }
  709. }, function(err){
  710. $.bootstrapLoading.end();
  711. }, function(ex){
  712. $.bootstrapLoading.end();
  713. }
  714. );
  715. },
  716. setupAfterSelectMultiOther: async function (selectedOther, signatureDivId) {
  717. // 多变更令选择
  718. await this._commonRefreshAfterSelectSignature(signatureDivId);
  719. const params = this._getCommonParams();
  720. params.stg_id = STAGE_ID;
  721. params.selected = selectedOther;
  722. const new_ROLE_REL_LIST = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  723. new_ROLE_REL_LIST.forEach(nrole => {
  724. nrole.sign_pic = null;
  725. });
  726. params.rel_content = new_ROLE_REL_LIST;
  727. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  728. CommonAjax.postXsrfEx("/tender/report_api/updateMultiOtherRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  729. function(result){
  730. $.bootstrapLoading.end();
  731. if (result.data && result.data.insertId > 0) {
  732. CURRENT_ROLE_REL_ID = result.data.insertId;
  733. }
  734. }, function(err){
  735. $.bootstrapLoading.end();
  736. }, function(ex){
  737. $.bootstrapLoading.end();
  738. }
  739. );
  740. },
  741. setupAfterSelectMultiTenders: async function (selectedTenders, signatureDivId) {
  742. // 跨标段选择,有不少要注意的交互:
  743. await this._commonRefreshAfterSelectSignature(signatureDivId);
  744. //2. 集中请求
  745. const params = this._getCommonParams();
  746. params.selectedTenders = selectedTenders;
  747. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  748. $.bootstrapLoading.start();
  749. CommonAjax.postXsrfEx("/tender/report_api/updateMultiRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  750. function(result){
  751. $.bootstrapLoading.end();
  752. if (result.data && result.data.insertId > 0) {
  753. CURRENT_ROLE_REL_ID = result.data.insertId;
  754. }
  755. }, function(err){
  756. $.bootstrapLoading.end();
  757. }, function(ex){
  758. $.bootstrapLoading.end();
  759. }
  760. );
  761. },
  762. _parseRoleRelList: function(org_rel_content) {
  763. const rst = JSON.parse(org_rel_content);
  764. for (const role_rel of rst) {
  765. if (role_rel.sign_date !== null && role_rel.sign_date !== undefined && role_rel.sign_date.length >= 8) {
  766. role_rel.sign_date = new Date(role_rel.sign_date);
  767. }
  768. }
  769. return rst;
  770. },
  771. setupAfterSelectSignature: async function (signatureDivId) {
  772. //0. 签名日期
  773. let me = rptSignatureHelper;
  774. await this._commonRefreshAfterSelectSignature(signatureDivId);
  775. //2. 更新数据
  776. const params = this._getCommonParams();
  777. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(params.rel_content));
  778. $.bootstrapLoading.start();
  779. CommonAjax.postXsrfEx("/tender/report_api/updateRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  780. async function(result){
  781. // console.log(result);
  782. $.bootstrapLoading.end();
  783. if (result.data && result.data.insertId > 0) {
  784. CURRENT_ROLE_REL_ID = result.data.insertId;
  785. }
  786. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  787. CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  788. ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  789. // 原本要刷新的,但在前面的_commonRefreshAfterSelectSignature方法中已经处理好了,无需重复
  790. } else {
  791. // CURRENT_ROLE_REL_ID = -1;
  792. ROLE_REL_LIST = [];
  793. }
  794. }, function(err){
  795. // hintBox.unWaitBox();
  796. $.bootstrapLoading.end();
  797. }, function(ex){
  798. // hintBox.unWaitBox();
  799. $.bootstrapLoading.end();
  800. }
  801. );
  802. },
  803. switchAddRoleDiv: function (dom) {
  804. if (dom.nextElementSibling.children[0].style.display === 'none') {
  805. dom.nextElementSibling.children[0].style.display = '';
  806. } else {
  807. dom.nextElementSibling.children[0].style.display = 'none';
  808. }
  809. },
  810. createNewRole: function (dom) {
  811. if ($('#acc_role_name')[0].value !== '') {
  812. const params = {};
  813. params.name = $('#acc_role_name')[0].value;
  814. const selectedAcc = PRJ_ACCOUNT_LIST[$('#project_account_select_dom')[0].selectedOptions[0].value];
  815. const roleName = (selectedAcc.role === '')?DFT_ROLE_NAME:selectedAcc.role;
  816. params.bind_acc_id = selectedAcc.id;
  817. params.prj_id = PROJECT_ID;
  818. params.tender_id = TENDER_ID;
  819. CommonAjax.postXsrfEx("/tender/report_api/createSignatureRole", params, 10000, true, getCookie('csrfToken_j'),
  820. function(result){
  821. console.log(result);
  822. const newRole = {};
  823. newRole.name = params.name;
  824. newRole.bind_acc_id = selectedAcc.id;
  825. newRole.prj_id = PROJECT_ID;
  826. newRole.tender_id = TENDER_ID;
  827. ROLE_LIST.push(newRole);
  828. const domArr = [];
  829. domArr.push('<li class="add-sign-list-item">');
  830. //1. apply签名
  831. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + (ROLE_LIST.length - 1) +')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  832. domArr.push('<i class="fa fa-plus"></i>');
  833. domArr.push('</a>');
  834. //2. 编辑角色(暂缓处理click事件)
  835. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  836. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  837. domArr.push('</a>');
  838. //3. 显示名称
  839. domArr.push('<i class="fa fa-user"></i> ' + $('#acc_role_name')[0].value + '<p>' + selectedAcc.name + '-<small class="text-muted">' + roleName + '</small></p>');
  840. $('#existed_roles_ul').append(domArr.join(' '));
  841. }, function(err){
  842. // hintBox.unWaitBox();
  843. }, function(ex){
  844. // hintBox.unWaitBox();
  845. }
  846. );
  847. } else {
  848. alert('请输入合适的名称!');
  849. }
  850. },
  851. buildRoleDom: function (roleList) {
  852. const ulDom = $('#existed_roles_ul');
  853. ulDom.empty();
  854. for (let domIdx = 0; domIdx < roleList.length; domIdx++) {
  855. const role = roleList[domIdx];
  856. const domArr = [];
  857. domArr.push('<li class="add-sign-list-item">');
  858. //1. apply签名
  859. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + domIdx + ')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  860. domArr.push('<i class="fa fa-plus"></i>');
  861. domArr.push('</a>');
  862. //2. 编辑角色(暂缓)
  863. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  864. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  865. domArr.push('</a>');
  866. //3. 显示名称
  867. let acc = rptSignatureHelper.getUserAccount(role.bind_acc_id);
  868. 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>');
  869. ulDom.append(domArr.join(' '));
  870. }
  871. },
  872. getUserAccount: function (accId) {
  873. let rst = null;
  874. for (const acc of PRJ_ACCOUNT_LIST) {
  875. if (acc.id === accId) {
  876. rst = acc;
  877. break;
  878. }
  879. }
  880. return rst;
  881. },
  882. _getCompanySign: function(companyName) {
  883. let rst = '';
  884. for (const cUnit of CONSTRUCT_UNIT_LIST) {
  885. if (cUnit.name === companyName) {
  886. rst = cUnit.sign_path;
  887. break;
  888. }
  889. }
  890. return rst;
  891. },
  892. mergeSignature: function (pageData, currRoleRelList, setPic = false, checkAudit = false) {
  893. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  894. const page = pageData.items[pageIdx];
  895. if (page.signature_cells) {
  896. // const adHocScells = [];
  897. for (const sCell of page.signature_cells) {
  898. if (sCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0) {
  899. sCell.path = null;
  900. sCell.pre_path = null;
  901. sCell.pic = null;
  902. }
  903. for (const role of currRoleRelList) {
  904. const role_rel = getTheRightRole(role, pageIdx);
  905. if (!checkAudit || checkAudit && rptSignatureHelper._chkIfAudit(role_rel)) {
  906. // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示
  907. if (role_rel.signature_name === sCell.signature_name) {
  908. // 处理签章
  909. if (!Array.isArray(role_rel.sign_output)) {
  910. role_rel.sign_output = [];
  911. role_rel.sign_output.push(NORMAL_SIGN_STR);
  912. }
  913. for (const signType of role_rel.sign_output) {
  914. switch (signType) {
  915. case NORMAL_SIGN_STR:
  916. sCell.path = role_rel.sign_path;
  917. sCell.pre_path = role_rel.sign_path;
  918. if (setPic) {
  919. sCell.pic = role_rel.sign_pic; // 有些场景(如:批量归档)需要直接设置签名数据
  920. }
  921. break;
  922. case COMPANY_SIGN_STR:
  923. case PRIVATE_SIGN_STR:
  924. // 搬到了mergetStamp方法那去处理了
  925. break;
  926. default:
  927. break;
  928. }
  929. }
  930. break;
  931. }
  932. }
  933. }
  934. }
  935. // page.signature_cells = page.signature_cells.concat(adHocScells);
  936. }
  937. }
  938. },
  939. resetDummySignature: async function(pageData, roleRels, ifPushRoleRel = false, checkAudit = false) {
  940. // 备注:计算草图等其他图形需要额外做些处理
  941. let dummySignIdx = 0;
  942. const stampPicKeys = [], stampPicFeatures = [];
  943. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  944. const page = pageData.items[pageIdx];
  945. if (page[JV.PROP_SIGNATURE_CELLS] && page[JV.PROP_SIGNATURE_CELLS].length > 0) {
  946. for (const signatureCell of page[JV.PROP_SIGNATURE_CELLS]) {
  947. if (signatureCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
  948. let passAuditChk = true;
  949. if (checkAudit) {
  950. passAuditChk = false;
  951. if (roleRels) {
  952. for (const role of roleRels) {
  953. const role_rel = getTheRightRole(role, pageIdx);
  954. if (role_rel.signature_name === signatureCell.signatureName) {
  955. // signatureName(非signature_name)是印章cell特意给的属性,还有isStamp属性
  956. if (rptSignatureHelper._chkIfAudit(role_rel)) {
  957. passAuditChk = true;
  958. break;
  959. }
  960. }
  961. }
  962. }
  963. }
  964. if (passAuditChk) {
  965. // 表示这是一个其他类型的非原生电子签名图,只是借用signature的处理机制,每个图都是唯一的,所以需要重新给个唯一的新signature_name
  966. // signatureCell.signature_name = signatureCell.signature_name + '_' + pageIdx + '_' + dummySignIdx;
  967. signatureCell.signature_name = signatureCell.signature_name + '_' + page.page_seq + '_' + dummySignIdx; // page_seq在分页后都不会变动
  968. dummySignIdx++;
  969. const roleRelItem = { type: '用户', sign_path: signatureCell.path, signature_name: signatureCell.signature_name };
  970. if (signatureCell.isStamp) {
  971. let stmpIdx = stampPicKeys.indexOf(signatureCell.path);
  972. if (stampPicKeys.indexOf(signatureCell.path) < 0) {
  973. stampPicKeys.push(signatureCell.path);
  974. stmpIdx = stampPicKeys.length - 1;
  975. const picRes = await getHttpBlobText(signatureCell.path + '?x-oss-process=image/info');
  976. stampPicFeatures.push(picRes);
  977. }
  978. // { "FileSize": {"value": "2514"}, "Format": {"value": "png"}, "ImageHeight": {"value": "94"}, "ImageWidth": {"value": "94"} }
  979. roleRelItem.stampFeature = stampPicFeatures[stmpIdx];
  980. // 重新处理cell坐标
  981. // 如果签章信息中存在位置信息,则不执行该方法
  982. if(!signatureCell.isSaveSignature) _resetStampArea(pageData[JV.NODE_CONTROL_COLLECTION][signatureCell[JV.PROP_CONTROL]], signatureCell, roleRelItem);
  983. }
  984. if (ifPushRoleRel) roleRels.push(roleRelItem);
  985. }
  986. }
  987. }
  988. }
  989. }
  990. },
  991. mergeSignAudit: function (pageData, currRoleRelList, currAuditList, checkAudit = false) {
  992. const reg1 = new RegExp('\n\r', 'g');
  993. const reg2 = new RegExp('\r\n', 'g');
  994. const reg3 = new RegExp('\n', 'g');
  995. const reg4 = new RegExp('\r', 'g');
  996. const reg5 = new RegExp('<br/>', 'g');
  997. const reg6 = new RegExp('<br>', 'g');
  998. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  999. const page = pageData.items[pageIdx];
  1000. if (page.signature_audit_cells) {
  1001. for (const sCell of page.signature_audit_cells) {
  1002. sCell.Value = ''; // 这里要先清除原有信息
  1003. for (const role of currRoleRelList) {
  1004. const role_rel = getTheRightRole(role, pageIdx);
  1005. if (!checkAudit || checkAudit && rptSignatureHelper._chkIfAudit(role_rel)) {
  1006. // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示
  1007. if (sCell.signature_name === role_rel.signature_name + '_审核意见') {
  1008. let preDate = '';
  1009. sCell.Value = '同意'; // 只有选择了签名的,才需要初始化一个默认的意见(之前的逻辑在有多个签名,哪怕只选择了一个,其他的意见都会有默认意见)
  1010. for (const audit_rel of currAuditList) {
  1011. if (role_rel.acc_id === audit_rel.aid) {
  1012. const isOrAudit = this._chkOrAudit(role_rel.acc_id);
  1013. if (audit_rel.end_time > preDate && audit_rel.status === 3 || isOrAudit) {
  1014. sCell.Value = audit_rel.opinion;
  1015. if (typeof sCell.Value === 'string') {
  1016. sCell.Value = sCell.Value.replace(reg1, '|').replace(reg2, '|').replace(reg3, '|').replace(reg4, '|').replace(reg5, '|').replace(reg6, '|');
  1017. }
  1018. sCell.Value = (sCell.Value === '' && isOrAudit) ? '同意' : sCell.Value;
  1019. preDate = audit_rel.end_time;
  1020. } else {
  1021. sCell.Value = ''; // 如有匹配,但又不能输出,则需要清空
  1022. }
  1023. //不能break,实际会有多个审核意见,以最后一个为准
  1024. }
  1025. }
  1026. break;
  1027. }
  1028. }
  1029. }
  1030. }
  1031. }
  1032. }
  1033. },
  1034. _setDftDate: function (role_rel, isMergeOrgAlso = false) {
  1035. if (role_rel.acc_id && (role_rel.sign_date === undefined || role_rel.sign_date === null || role_rel.sign_date === '')) {
  1036. let dftDate = _getSignDateByAllScenarios(role_rel.acc_id);
  1037. if (dftDate !== '' && dftDate.length >= 10) {
  1038. dftDate = new Date(dftDate); // 不Format,保留时分秒
  1039. } else if (dftDate === '') {
  1040. if (current_stage_id <= -300 && current_stage_id > -400 && BGL_OBJ && BGL_OBJ.currentBz && BGL_OBJ.currentBz.status === 3) {
  1041. if (STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  1042. dftDate = new Date(STAGE_AUDIT[STAGE_AUDIT.length - 1].end_time);
  1043. } else {
  1044. dftDate = new Date();
  1045. }
  1046. } else {
  1047. dftDate = new Date();
  1048. }
  1049. }
  1050. role_rel.sign_date = dftDate;
  1051. if (isMergeOrgAlso) {
  1052. for (const orgRR of rptSignatureHelper.originalRoleRelList) {
  1053. if (orgRR.signature_name === role_rel.signature_name) {
  1054. orgRR.sign_date = dftDate;
  1055. break;
  1056. }
  1057. }
  1058. // rptSignatureHelper.originalRoleRelList[rridx].sign_date = dftDate; // 这个在实际情况下originalRoleRelList不一定与currRoleRelList一致
  1059. //备注:在多选导出的情况下,originalRoleRelList不需要merge
  1060. }
  1061. }
  1062. },
  1063. mergeSignDate: function (pageData, currRoleRelList, isMergeOrgAlso, checkAudit = false) {
  1064. if (currRoleRelList && currRoleRelList.length > 0 && STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  1065. for (let rridx = 0; rridx < currRoleRelList.length; rridx++) {
  1066. const role_rel = currRoleRelList[rridx];
  1067. if (role_rel.type !== '流程') {
  1068. rptSignatureHelper._setDftDate(role_rel, isMergeOrgAlso);
  1069. }
  1070. }
  1071. }
  1072. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1073. const page = pageData.items[pageIdx];
  1074. if (page.signature_date_cells) {
  1075. for (const sCell of page.signature_date_cells) {
  1076. if (typeof sCell.Value === 'string' && sCell.Value.replace(/ /g, '') === '年月日') {
  1077. sCell.Value = _getSignDateDftName();
  1078. } else {
  1079. sCell.Value = '';
  1080. }
  1081. for (const role of currRoleRelList) {
  1082. const role_rel = getTheRightRole(role, pageIdx);
  1083. // if (role.type === '流程') rptSignatureHelper._setDftDate(role_rel, false);
  1084. if (role.type === '流程') {
  1085. if (role.flowAccList[pageIdx] < 0) continue; // 没有合适的,则判断下一个
  1086. rptSignatureHelper._setDftDate(role_rel, false);
  1087. }
  1088. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  1089. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1090. // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示
  1091. if (!!role_rel.sign_date && role_rel.sign_date !== '') {
  1092. if (typeof role_rel.sign_date === 'string') {
  1093. role_rel.sign_date = new Date(role_rel.sign_date);
  1094. }
  1095. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  1096. }
  1097. }
  1098. break;
  1099. }
  1100. }
  1101. }
  1102. }
  1103. }
  1104. },
  1105. _chkOrAudit: function(acc_id) {
  1106. // 检测 '或签' 情况下的审核状态(在或签情况下,另一个审核通过,那么这个也是通过的)
  1107. let rst = false;
  1108. for (const flow of STAGE_FLOW) {
  1109. if (flow.aid === acc_id) {
  1110. if (flow.audit_type === 3) {
  1111. // 判断 或签 用户状态
  1112. for (const secFlow of STAGE_FLOW) {
  1113. if (secFlow.audit_type === 3 && secFlow.order === flow.order && secFlow.aid !== acc_id) {
  1114. rst = secFlow.status === 3 || flow.status === 3;
  1115. if (rst) break;
  1116. }
  1117. }
  1118. }
  1119. break;
  1120. }
  1121. }
  1122. return rst;
  1123. },
  1124. _chkIfAudit: function(role_rel) {
  1125. // 检测是否在审核列表中
  1126. let rst = false;
  1127. for (const stg_audit of STAGE_AUDIT) {
  1128. if (role_rel.acc_id === stg_audit.aid) {
  1129. if (stg_audit.status === 3) {
  1130. rst = true;
  1131. } else {
  1132. rst = false;
  1133. }
  1134. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  1135. }
  1136. }
  1137. if (!rst && current_stage_id > 0) {
  1138. // 还有原报需要检测(这里是计量期单独的判断)
  1139. for (const stg_ort_rpt of STAGE_LIST) {
  1140. if (stg_ort_rpt.id === current_stage_id && role_rel.acc_id === stg_ort_rpt.user_id) {
  1141. if (stg_ort_rpt.status !== 1 && stg_ort_rpt.status !== 4) {
  1142. // 只要不是待上报(1)、退回审批(4) 状态,都需要显示
  1143. rst = true;
  1144. } else {
  1145. rst = false;
  1146. }
  1147. break;
  1148. }
  1149. }
  1150. if (!rst) {
  1151. rst = this._chkOrAudit(role_rel.acc_id);
  1152. }
  1153. }
  1154. // rst = true; //测试,未来将屏蔽
  1155. return rst;
  1156. },
  1157. _chkIfOrgRpt: function(acc_id) {
  1158. // 检测是否原报
  1159. let rst = false;
  1160. for (const stg of STAGE_LIST) {
  1161. if (stg.id === current_stage_id) {
  1162. if (stg.user_id === acc_id) {
  1163. rst = true;
  1164. }
  1165. break;
  1166. }
  1167. }
  1168. return rst;
  1169. },
  1170. _cancelFlowSignDate: function(signature_name) {
  1171. for (const roleRel of ROLE_REL_LIST) {
  1172. if (roleRel.signature_name === signature_name && roleRel.type === '流程') {
  1173. roleRel.assFlowInfos.forEach((asf, index) => {
  1174. const fdtpId = `flowdtp_${signature_name}_${index}`;
  1175. let dtDom = document.getElementById(fdtpId); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象
  1176. if (dtDom) {
  1177. dtDom.value = asf.sign_date || '';
  1178. }
  1179. });
  1180. }
  1181. }
  1182. },
  1183. _saveFlowSignDate: function(signature_name) {
  1184. for (const roleRel of ROLE_REL_LIST) {
  1185. if (roleRel.signature_name === signature_name && roleRel.type === '流程') {
  1186. roleRel.assFlowInfos.forEach((asf, index) => {
  1187. const fdtpId = `flowdtp_${signature_name}_${index}`;
  1188. let dtDom = document.getElementById(fdtpId); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象
  1189. if (dtDom) {
  1190. asf.sign_date = dtDom.value;
  1191. }
  1192. });
  1193. }
  1194. }
  1195. },
  1196. _changeSignType: function(dom, signature_name, chkStr, userStamp, flowIndex = -1) {
  1197. for (const roleRel of ROLE_REL_LIST) {
  1198. if (roleRel.signature_name === signature_name) {
  1199. let newRoleRel = roleRel;
  1200. if (roleRel.type === '流程') {
  1201. newRoleRel = roleRel.assFlowInfos[flowIndex];
  1202. }
  1203. if (dom.checked) {
  1204. if (newRoleRel.sign_output.indexOf(chkStr) < 0) {
  1205. newRoleRel.sign_output.push(chkStr);
  1206. }
  1207. if(chkStr==='private_stamp' && !newRoleRel.private_stamp_path && userStamp){
  1208. newRoleRel.private_stamp_path = userStamp.split('!;!')[0] ;
  1209. // console.log(newRoleRel.private_stamp_path);
  1210. }
  1211. } else {
  1212. let idx = newRoleRel.sign_output.indexOf(chkStr);
  1213. if (idx >= 0) {
  1214. newRoleRel.sign_output.splice(idx, 1);
  1215. }
  1216. }
  1217. break;
  1218. }
  1219. }
  1220. },
  1221. _resetStampPos: function(orgCell, targetCell, controls) {
  1222. const ctrl = controls[orgCell.control];
  1223. let pLeft = orgCell.area.Left, pTop = orgCell.area.Top;
  1224. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
  1225. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
  1226. pLeft = orgCell.area.Left;
  1227. break;
  1228. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
  1229. pLeft = (orgCell.area.Left + orgCell.area.Right - STD_STAMP_SIZE_WIDTH) / 2 ;
  1230. break;
  1231. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
  1232. pLeft = orgCell.area.Right - STD_STAMP_SIZE_WIDTH;
  1233. break;
  1234. }
  1235. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
  1236. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_TOP]:
  1237. pTop = orgCell.area.Top;
  1238. break;
  1239. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_CENTER]:
  1240. pTop = (orgCell.area.Top + orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT) / 2 ;
  1241. break;
  1242. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_BOTTOM]:
  1243. pTop = orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT;
  1244. break;
  1245. }
  1246. targetCell.area.Left = pLeft;
  1247. targetCell.area.Top = pTop;
  1248. targetCell.area.Right = pLeft + STD_STAMP_SIZE_WIDTH;
  1249. targetCell.area.Bottom = pTop + STD_STAMP_SIZE_HEIGHT;
  1250. },
  1251. initChosePrivateStampPath:function(stampPathList, signature_name, flowIndex = -1){
  1252. let currentStamp='';
  1253. const targetNode= ROLE_REL_LIST.find(item=>item.signature_name===signature_name);
  1254. if (targetNode) {
  1255. if (targetNode.type === '流程') {
  1256. currentStamp = targetNode.assFlowInfos[flowIndex].private_stamp_path;
  1257. } else {
  1258. currentStamp = targetNode.private_stamp_path;
  1259. }
  1260. }
  1261. let content=`<div class='row justify-content-md-center'>`;
  1262. stampPathList.split('!;!').forEach(item=>{
  1263. content+=`<div class="card col-3 p-2 m-3 d-flex ${currentStamp===item?'card-gk-active':''} stamp-img">
  1264. <div class="p-0 private-stamp-img">
  1265. <div class="sel-width check-state ${currentStamp===item?'sel-blue':''} "></div>
  1266. <img src="${rptSignatureHelper.fujianOssPath}${item}" data-src='${item}' class="img-fluid" alt="...">
  1267. </div>
  1268. </div>`;
  1269. })
  1270. for(let i=0;i<stampPathList.length%3;i++){
  1271. content+=`<div class="col-3 p-2 m-3"></div>`;
  1272. }
  1273. content+=` </div><div class='privateStampRoleName' data-name='${signature_name}'></div>`;
  1274. content += `<div class='privateStampFlowIndex' data-name='${flowIndex}'></div>`;
  1275. $('#chose-private-stamp-path .modal-body').empty().append(content);
  1276. $('.stamp-img').on('click',(e)=>{
  1277. $('.stamp-img').removeClass('card-gk-active');
  1278. $('.stamp-img').find('.sel-width').removeClass('sel-blue');
  1279. $(e.currentTarget).addClass('card-gk-active');
  1280. $(e.currentTarget).find('.sel-width').addClass('sel-blue');
  1281. })
  1282. },
  1283. setPrivateStamp(e, flowIndex = -1){
  1284. const imgSrc= $('.stamp-img.card-gk-active').find('.img-fluid').data('src');
  1285. const privateStampRoleName=$('.privateStampRoleName').data('name');
  1286. const targetNode= ROLE_REL_LIST.find(item=>item.signature_name==privateStampRoleName);
  1287. if (targetNode.type === '流程') {
  1288. const flowIndex = +($('.privateStampFlowIndex').data('name'));
  1289. targetNode.assFlowInfos[flowIndex].private_stamp_path = imgSrc;
  1290. } else {
  1291. targetNode.private_stamp_path = imgSrc;
  1292. }
  1293. $('#chose-private-stamp-path').modal('hide');
  1294. },
  1295. _get_newPrivate_stamp_path(roleRelObj,userAcc) {
  1296. if (!roleRelObj.private_stamp_path) {
  1297. if (!userAcc.stamp_path) return '';
  1298. if (userAcc.stamp_path.split('!;!').length === 1) {
  1299. return userAcc.stamp_path;
  1300. }else{
  1301. return userAcc.stamp_path.split('!;!')[0];
  1302. }
  1303. }
  1304. return roleRelObj.private_stamp_path;
  1305. }
  1306. }
  1307. function _getSignDateByAllScenarios(userAccId) {
  1308. let rst = '';
  1309. let hasAudit = false;
  1310. for (const stg_audit of STAGE_AUDIT) {
  1311. // 或签的也会在此 STAGE_AUDIT 列里面
  1312. if (stg_audit.aid === userAccId) {
  1313. hasAudit = true;
  1314. // 加上 '或签' 检测
  1315. if (stg_audit.status === 3 || rptSignatureHelper._chkOrAudit(stg_audit.aid)) {
  1316. rst = stg_audit.end_time;
  1317. }
  1318. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  1319. }
  1320. }
  1321. let isOrgRpt = false;
  1322. for (const stg of STAGE_LIST) {
  1323. if (stg.id === current_stage_id) {
  1324. if (stg.user_id === userAccId) {
  1325. isOrgRpt = true;
  1326. }
  1327. break;
  1328. }
  1329. }
  1330. if (isOrgRpt && !hasAudit && STAGE_AUDIT_ORG && STAGE_AUDIT_ORG.length > 0) {
  1331. if (STAGE_AUDIT_ORG[0].begin_time && STAGE_AUDIT_ORG[0].begin_time !== '' && STAGE_AUDIT_ORG[0].begin_time.length >= 10) {
  1332. rst = STAGE_AUDIT_ORG[0].begin_time;
  1333. }
  1334. }
  1335. if (!isOrgRpt && !hasAudit) {
  1336. // 非审批流程人员以及非原报,则显示期截至时间
  1337. // 之前给我的解释有问题的,不应该找stage的period属性,而是找当期最后一个status===3的end_time时间(STAGE_AUDIT已经取了最后times,并已排序了)
  1338. for (const stg_audit of STAGE_AUDIT) {
  1339. if (stg_audit.status === 3) {
  1340. rst = stg_audit.end_time;
  1341. }
  1342. }
  1343. }
  1344. return rst;
  1345. }
  1346. function _getStatusByUserId(userAccId) {
  1347. let rst = -1;
  1348. for (const stg_audit of STAGE_AUDIT) {
  1349. // 或签的也会在此 STAGE_AUDIT 列里面
  1350. if (stg_audit.aid === userAccId) {
  1351. rst = stg_audit.status;
  1352. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  1353. }
  1354. }
  1355. return rst;
  1356. }
  1357. function _getSignDateDftName() {
  1358. return ' 年 月 日';
  1359. }
  1360. function _createDummyCell() {
  1361. const rst = {
  1362. font: 'Footer',
  1363. control: 'Footer',
  1364. style: 'Default_None',
  1365. Value: '',
  1366. area: { Left: 0, Right: 0, Top: 0, Bottom: 0 },
  1367. };
  1368. return rst;
  1369. }
  1370. function prepareRightFlowRoles(pageData, roleRelList = [], stg_audit = [], ledgerList = []) {
  1371. // 争取在这里一次过把所有页面的流程签名数据整理完毕,方便后面的工序能简单处理
  1372. const flowRole = roleRelList.find(role => { return role.type === '流程'; });
  1373. for (const role of roleRelList) {
  1374. if (role.type === '流程') role.flowAccList = []; // 这里直接清理流程签名信息
  1375. }
  1376. if (flowRole) {
  1377. const ledgerCache = {}; // 生成台账信息cache对象,提高查找效率
  1378. ledgerList.forEach(ledger => {
  1379. ledgerCache[ledger.id] = ledger;
  1380. ledgerCache[`_${ledger.ledger_id}`] = ledger;
  1381. })
  1382. const auditCache = {}; // 生成stage审核cache对象,提高查找效率
  1383. stg_audit.forEach(audit => {
  1384. if (audit.audit_type === 4) {
  1385. auditCache[`_${audit.aid}`] = `${audit.audit_ledger_id}`; // 统一用string类型来判断
  1386. }
  1387. });
  1388. const _getShortPath = (assFlowRole, page) => {
  1389. // 此方法获取当前页到流程审核的最短层次路径(考虑到不同人的控制的台账层次会有包含关系,需要厘清,以最短的用户为准),-1表示没有
  1390. let rst = -1;
  1391. let currentPageLedgeId = ledgerCache[page.extend_flow_options].ledger_id;
  1392. const idStr = `${auditCache[`_${assFlowRole.acc_id}`]}`;
  1393. const idStrs = idStr.split(',');
  1394. let lv = 0;
  1395. while (true) {
  1396. if (idStrs.includes(`${currentPageLedgeId}`)) {
  1397. rst = lv;
  1398. break;
  1399. }
  1400. lv++;
  1401. if (currentPageLedgeId !== -1) {
  1402. currentPageLedgeId = ledgerCache[`_${currentPageLedgeId}`].ledger_pid;
  1403. }
  1404. if (currentPageLedgeId === -1) break;
  1405. }
  1406. return rst;
  1407. };
  1408. pageData.items.forEach((page, index) => {
  1409. if (page.extend_flow_options && page.extend_flow_options !== '') {
  1410. for (const role of roleRelList) {
  1411. if (role.type === '流程') {
  1412. role.flowAccList.push(-1); // !!! 每一页都要有一个流程签名指引,-1表示没有
  1413. let preLen = 10000; //
  1414. for (let assIdx = 0; assIdx < role.assFlowInfos.length; assIdx++) {
  1415. const assRole = role.assFlowInfos[assIdx];
  1416. if (auditCache[`_${assRole.acc_id}`]) {
  1417. const chkLv = _getShortPath(assRole, page);
  1418. if (chkLv !== -1) {
  1419. if (chkLv < preLen) {
  1420. role.flowAccList[role.flowAccList.length - 1] = assIdx;
  1421. preLen = chkLv; // 还要考虑到嵌套的情况
  1422. }
  1423. }
  1424. }
  1425. }
  1426. }
  1427. }
  1428. }
  1429. // role.flowAccList
  1430. });
  1431. }
  1432. }
  1433. function getTheRightRole(role, pageIdx) {
  1434. let rst = role;
  1435. if (role.type === '流程') {
  1436. if (role.flowAccList && role.flowAccList.length > pageIdx) {
  1437. if (role.flowAccList[pageIdx] !== -1) {
  1438. rst = role.assFlowInfos[role.flowAccList[pageIdx]];
  1439. if (role.areaData) rst.areaData = role.areaData;
  1440. }
  1441. }
  1442. }
  1443. return rst;
  1444. }
  1445. function resetStampSignature(pageData, roleRelList, checkAudit = false, stg_audit = [], ledgerList = []) {
  1446. prepareRightFlowRoles(pageData, roleRelList, stg_audit, ledgerList);
  1447. const dupPicPaths = [];
  1448. const _getMaxRect = function(page) {
  1449. const rect = [100000000, 100000000, 0, 0];
  1450. for (const cell of page.cells) {
  1451. rect[0] = rect[0] > cell.area.Left ? cell.area.Left : rect[0];
  1452. rect[1] = rect[1] > cell.area.Top ? cell.area.Top : rect[1];
  1453. rect[2] = rect[2] < cell.area.Right ? cell.area.Right : rect[2];
  1454. rect[3] = rect[3] < cell.area.Bottom ? cell.area.Bottom : rect[3];
  1455. }
  1456. return rect;
  1457. };
  1458. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1459. const page = pageData.items[pageIdx];
  1460. const maxRect = _getMaxRect(page);
  1461. if (page.signature_cells) {
  1462. const newStampCells = [];
  1463. for (let scIdx = 0; scIdx < page.signature_cells.length; scIdx++) {
  1464. const sCell = page.signature_cells[scIdx];
  1465. for (const role of roleRelList) {
  1466. const role_rel = getTheRightRole(role, pageIdx);
  1467. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1468. if (sCell.signature_name === role_rel.signature_name) {
  1469. if (Array.isArray(role_rel.sign_output) && role_rel.sign_output.length > 0) {
  1470. for (const signType of role_rel.sign_output) {
  1471. switch (signType) {
  1472. case COMPANY_SIGN_STR:
  1473. case PRIVATE_SIGN_STR:
  1474. // 创建一个新的cell
  1475. let stampPath = (signType === COMPANY_SIGN_STR) ? role_rel.company_stamp_path : role_rel.private_stamp_path;
  1476. stampPath = OSS_PATH + stampPath;
  1477. if (dupPicPaths.indexOf(stampPath) < 0) {
  1478. dupPicPaths.push(stampPath);
  1479. }
  1480. // 签字信息中如果有签章位置信息,则直接用位置信息
  1481. let signatureArea;
  1482. if (role_rel.areaData && role_rel.areaData[signType]){
  1483. signatureArea = role_rel.areaData[signType]
  1484. }
  1485. const newStampCell = {
  1486. signature_name: JV.SIGNATURE_NAME_DUMMY,
  1487. control: sCell.control,
  1488. style: sCell.style,
  1489. path: stampPath,
  1490. isStamp: true,
  1491. maxRect,
  1492. orgArea: sCell.area,
  1493. area: signatureArea || {Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom},
  1494. signatureName: role_rel.signature_name, // 节点名称
  1495. signType, // 签章信息
  1496. isSaveSignature: !!signatureArea, // 是否有签章位置信息
  1497. };
  1498. newStampCells.push(newStampCell);
  1499. break;
  1500. default: break;
  1501. }
  1502. }
  1503. }
  1504. }
  1505. }
  1506. }
  1507. }
  1508. if (newStampCells.length > 0) {
  1509. newStampCells.forEach(newSCell => {
  1510. // 因后台也已生成过签章,这里再生成的话会重复,需要删除(但在多期同时计量,原报签章在刷新后会丢失,所以需要这里再补上,见2024/09/18修改)
  1511. for (let sIdx = 0; sIdx < page.signature_cells.length; sIdx++) {
  1512. if (page.signature_cells[sIdx].path === newSCell.path) {
  1513. page.signature_cells.splice(sIdx, 1);
  1514. break;
  1515. }
  1516. }
  1517. });
  1518. page.signature_cells = page.signature_cells.concat(newStampCells);
  1519. }
  1520. }
  1521. }
  1522. }
  1523. function resetTextSignature(pageData, checkAudit = false) {
  1524. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1525. const page = pageData.items[pageIdx];
  1526. for (let sCell of page.signature_cells) {
  1527. if (!sCell.isStamp) {
  1528. let fitCell = null;
  1529. for (let idx = page.cells.length - 1; idx >= 0; idx--) {
  1530. const cell = page.cells[idx];
  1531. 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) {
  1532. fitCell = cell;
  1533. break;
  1534. }
  1535. }
  1536. if (fitCell) {
  1537. fitCell.Value = '';
  1538. for (let role of ROLE_REL_LIST) {
  1539. const role_rel = getTheRightRole(role, pageIdx);
  1540. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1541. if (sCell.signature_name === role_rel.signature_name) {
  1542. if (role_rel.sign_output && role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {
  1543. fitCell.Value = role_rel.user_name;
  1544. } else {
  1545. fitCell.Value = '';
  1546. }
  1547. break;
  1548. }
  1549. }
  1550. }
  1551. } else {
  1552. // 要创建新的文本签名cell
  1553. const newCell = {
  1554. font: 'Footer',
  1555. control: sCell.control,
  1556. style: sCell.style,
  1557. Value: '',
  1558. area: { Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom },
  1559. };
  1560. if (ROLE_REL_LIST) {
  1561. for (let role of ROLE_REL_LIST) {
  1562. const role_rel = getTheRightRole(role, pageIdx);
  1563. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1564. if (sCell.signature_name === role_rel.signature_name && role_rel.sign_output && role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {
  1565. newCell.Value = role_rel.user_name;
  1566. break;
  1567. }
  1568. }
  1569. }
  1570. }
  1571. page.cells.push(newCell); // 怎么也要有这个,哪怕没有文本也要输出,补边框用的
  1572. }
  1573. }
  1574. }
  1575. }
  1576. }
  1577. function _resetStampArea(ctrl, stampCell, roleRelItem) {
  1578. let pLeft = stampCell.orgArea.Left,
  1579. pTop = stampCell.orgArea.Top;
  1580. if (roleRelItem.stampFeature !== 'not found!') {
  1581. let std_stamp_size_width = STD_STAMP_SIZE_WIDTH, std_stamp_size_height = STD_STAMP_SIZE_HEIGHT;
  1582. let widthRate = 1, heightRate = 1;
  1583. if (roleRelItem.stampFeature) {
  1584. std_stamp_size_width = parseFloat(roleRelItem.stampFeature.ImageWidth.value);
  1585. std_stamp_size_height = parseFloat(roleRelItem.stampFeature.ImageHeight.value);
  1586. if (roleRelItem.stampFeature.ImageWidth.value !== roleRelItem.stampFeature.ImageHeight.value) {
  1587. //设置比例
  1588. if (std_stamp_size_width > std_stamp_size_height) {
  1589. heightRate = std_stamp_size_height / std_stamp_size_width;
  1590. } else {
  1591. widthRate = std_stamp_size_width / std_stamp_size_height;
  1592. }
  1593. }
  1594. if (std_stamp_size_width > STD_STAMP_SIZE_WIDTH || std_stamp_size_height > STD_STAMP_SIZE_HEIGHT) {
  1595. if (widthRate === 1) {
  1596. std_stamp_size_width = Math.min(std_stamp_size_width, STD_STAMP_SIZE_WIDTH);
  1597. std_stamp_size_height = std_stamp_size_width * heightRate;
  1598. } else {
  1599. std_stamp_size_height = Math.min(std_stamp_size_height, STD_STAMP_SIZE_HEIGHT);
  1600. std_stamp_size_width = std_stamp_size_height * widthRate;
  1601. }
  1602. }
  1603. }
  1604. switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
  1605. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
  1606. pLeft = stampCell.orgArea.Left;
  1607. break;
  1608. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
  1609. pLeft = (stampCell.orgArea.Left + stampCell.orgArea.Right - std_stamp_size_width) / 2;
  1610. break;
  1611. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
  1612. pLeft = stampCell.orgArea.Right - std_stamp_size_width;
  1613. break;
  1614. default:break;
  1615. }
  1616. switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
  1617. case JV.OUTPUT_ALIGN.V[JV.V_ALIGN_IDX_TOP]:
  1618. pTop = stampCell.orgArea.Top;
  1619. break;
  1620. case JV.OUTPUT_ALIGN.V[JV.V_ALIGN_IDX_CENTER]:
  1621. pTop = (stampCell.orgArea.Top + stampCell.orgArea.Bottom - std_stamp_size_height) / 2;
  1622. break;
  1623. case JV.OUTPUT_ALIGN.V[JV.V_ALIGN_IDX_BOTTOM]:
  1624. pTop = stampCell.orgArea.Bottom - std_stamp_size_height;
  1625. break;
  1626. default:break;
  1627. }
  1628. stampCell.area.Left = pLeft;
  1629. stampCell.area.Top = pTop;
  1630. stampCell.area.Right = pLeft + std_stamp_size_width;
  1631. stampCell.area.Bottom = pTop + std_stamp_size_height;
  1632. // 最后一步,如超过报表范围,则要调整坐标
  1633. const maxRect = stampCell.maxRect;
  1634. if (stampCell.area.Left < maxRect[0]) {
  1635. const width = maxRect[0] - stampCell.area.Left;
  1636. stampCell.area.Left += width;
  1637. stampCell.area.Right += width;
  1638. }
  1639. if (stampCell.area.Top < maxRect[1]) {
  1640. const height = maxRect[1] - stampCell.area.Top;
  1641. stampCell.area.Top += height;
  1642. stampCell.area.Bottom += height;
  1643. }
  1644. if (stampCell.area.Right > maxRect[2]) {
  1645. const width = maxRect[2] - stampCell.area.Right; // 负
  1646. stampCell.area.Left += width;
  1647. stampCell.area.Right += width;
  1648. }
  1649. if (stampCell.area.Bottom > maxRect[3]) {
  1650. const height = maxRect[3] - stampCell.area.Bottom;
  1651. stampCell.area.Top += height;
  1652. stampCell.area.Bottom += height;
  1653. }
  1654. }
  1655. }