rpt_signature.js 87 KB

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