rpt_signature.js 92 KB

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