rpt_signature.js 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728
  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 > 0 || companyPathList.length > 0); //用户账号的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. if (companyPathList.length > 0 ) {
  530. elementsStrArr.push(' <div class="form-check form-check-inline px-1">');
  531. 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}>`);
  532. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign2">单位章</label>`);
  533. if (companyPathList.length > 1 ) {
  534. 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>`);
  535. }
  536. elementsStrArr.push(' </div>');
  537. }
  538. if (stampPathList.length > 0) {
  539. elementsStrArr.push(' <div class="form-check form-check-inline">');
  540. 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}>`);
  541. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign3">个人章</label>`);
  542. if (stampPathList.length > 1) {
  543. 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>`);
  544. }
  545. elementsStrArr.push(' </div>');
  546. }
  547. elementsStrArr.push(' </div>');
  548. elementsStrArr.push(' </div>');
  549. } else {
  550. // elementsStrArr.push(' <div class="form-check form-check-inline px-2">');
  551. // 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}>`);
  552. // elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign10">单位章</label>`);
  553. // elementsStrArr.push(' </div>');
  554. }
  555. elementsStrArr.push(' </div>');
  556. elementsStrArr.push('</div>');
  557. // 2. 日期
  558. elementsStrArr.push('<div class="col-4">');
  559. let dftDate = '';
  560. if (role_rel.sign_date !== '' && role_rel.sign_date.length >= 10) {
  561. dftDate = (new Date(role_rel.sign_date)).Format('yyyy-MM-dd');
  562. } else if (role_rel.sign_date instanceof Date){
  563. dftDate = role_rel.sign_date.Format('yyyy-MM-dd');
  564. } else {
  565. if (userAcc) dftDate = _getSignDateByAllScenarios(userAcc.id);
  566. if (dftDate !== '' && dftDate.length >= 10) {
  567. dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');
  568. }
  569. }
  570. elementsStrArr.push('<div class="input-group input-group-sm margin-inputbox">');
  571. elementsStrArr.push(' <div class="input-group-prepend">');
  572. elementsStrArr.push(' <span class="input-group-text height-inputbox" id="inputGroup-sizing-sm"><i class="fa fa-calendar" title="添加签名日期"></i></span>');
  573. elementsStrArr.push(' </div>');
  574. if (dftDate !== '') {
  575. 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>`);
  576. } else {
  577. 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>`);
  578. }
  579. elementsStrArr.push('</div>');
  580. //-------------------------------------------------
  581. elementsStrArr.push('</div>');
  582. elementsStrArr.push('</div>');
  583. },
  584. removeSignature: function (dom) {
  585. let accTxtName = $(dom.parentNode.parentNode.parentNode.parentNode.parentNode).find('label')[0].innerText;
  586. let jDom = $(dom.parentNode.parentNode);
  587. jDom.empty();
  588. jDom.append('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.currentSelectedESignAccName = \'' +
  589. accTxtName + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签字</a>');
  590. // 要记得清空相关pre_path属性
  591. for (const page of zTreeOprObj.currentRptPageRst.items) {
  592. if (page.signature_cells) {
  593. for (const sCell of page.signature_cells) {
  594. if (sCell.signature_name === accTxtName) {
  595. sCell.pre_path = '';
  596. }
  597. }
  598. }
  599. }
  600. // 还有ROLE_REL_LIST
  601. rptSignatureHelper.cleanOldSignature(accTxtName);
  602. },
  603. removeSelectSignature: function () {
  604. for (const page of zTreeOprObj.currentRptPageRst.items) {
  605. if (page.signature_cells) {
  606. for (const sCell of page.signature_cells) {
  607. if (sCell.hasOwnProperty('pre_path')) {
  608. delete sCell.pre_path;
  609. }
  610. }
  611. }
  612. }
  613. // ROLE_REL_LIST = [];
  614. // ROLE_REL_LIST = ROLE_REL_LIST.concat(rptSignatureHelper.originalRoleRelList);
  615. ROLE_REL_LIST = JSON.parse(JSON.stringify(rptSignatureHelper.originalRoleRelList));
  616. if (PAGE_SHOW.isTextSignature) {
  617. resetTextSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3);
  618. }
  619. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  620. },
  621. resetSignAudit: function () {
  622. rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT);
  623. },
  624. resetSignDate: function(signatureDivId) {
  625. for (const page of zTreeOprObj.currentRptPageRst.items) {
  626. // 调整了下次序,无论有没有签名时间显示,签名对象的sign_date必须得更新及保存
  627. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  628. const role_rel = ROLE_REL_LIST[idx];
  629. if (role_rel.type !== '流程') {
  630. const idSuffixStr = 'dtp_' + role_rel.signature_name + '_' + signatureDivId;
  631. let dtDom = document.getElementById(idSuffixStr); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象
  632. if (dtDom) {
  633. const dtStr = dtDom.value;
  634. if (dtStr && dtStr !== '' && dtStr.length >= 8 && dtStr.length <= 10) {
  635. role_rel.sign_date = new Date(dtStr);
  636. } else {
  637. role_rel.sign_date = '';
  638. }
  639. // 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)
  640. if (page.signature_date_cells) {
  641. for (const sCell of page.signature_date_cells) {
  642. // 在重设之前要先清空旧的日期
  643. sCell.Value = '';
  644. }
  645. for (const sCell of page.signature_date_cells) {
  646. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  647. sCell.Value = _getSignDateDftName();
  648. if (role_rel.sign_date !== '') {
  649. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  650. }
  651. }
  652. }
  653. }
  654. }
  655. } else {
  656. // 流程的处理不一样
  657. }
  658. }
  659. }
  660. },
  661. _commonRefreshAfterSelectSignature: async function(signatureDivId) {
  662. //0. 签名日期
  663. rptSignatureHelper.resetSignDate(signatureDivId);
  664. rptSignatureHelper.resetSignAudit();
  665. //1. 重刷page(不用考虑审核状态)
  666. for (const page of zTreeOprObj.currentRptPageRst.items) {
  667. if (page.signature_cells) {
  668. for (let cIdx = page.signature_cells.length - 1; cIdx >= 0; cIdx--) {
  669. const sCell = page.signature_cells[cIdx];
  670. if (sCell.isStamp) {
  671. page.signature_cells.splice(cIdx);
  672. } else if (sCell.hasOwnProperty('pre_path')) {
  673. sCell.path = sCell.pre_path;
  674. delete sCell.pre_path;
  675. }
  676. }
  677. }
  678. }
  679. resetStampSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3, STAGE_AUDIT, LEDGER_LIST);
  680. rptSignatureHelper.mergeSignDate(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
  681. rptSignatureHelper.mergeSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
  682. await rptSignatureHelper.resetDummySignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3);
  683. // rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT, getStageStatus() !== 3);
  684. if (PAGE_SHOW.isTextSignature) {
  685. resetTextSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3);
  686. }
  687. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  688. },
  689. _getCommonParams: function() {
  690. const params = {};
  691. params.id = CURRENT_ROLE_REL_ID;
  692. params.tender_id = TENDER_ID;
  693. params.stage_id = getStageId();
  694. params.business_id = BUSINESS_ID;
  695. params.source_type = SOURCE_TYPE;
  696. params.rpt_id = zTreeOprObj.currentNode.refId;
  697. // params.rel_content = ROLE_REL_LIST;
  698. params.rel_content = [];
  699. ROLE_REL_LIST.forEach(role_rel => {
  700. if (role_rel.signature_name.indexOf('dummy_pic') < 0) {
  701. params.rel_content.push(role_rel);
  702. }
  703. });
  704. return params;
  705. },
  706. setupAfterSelectMultiChanges: async function (selectedChanges, signatureDivId) {
  707. // 多变更令选择
  708. await this._commonRefreshAfterSelectSignature(signatureDivId);
  709. const params = this._getCommonParams();
  710. params.selectedChanges = selectedChanges;
  711. const new_ROLE_REL_LIST = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  712. new_ROLE_REL_LIST.forEach(nrole => {
  713. nrole.sign_pic = null;
  714. });
  715. params.rel_content = new_ROLE_REL_LIST;
  716. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  717. CommonAjax.postXsrfEx("/tender/report_api/updateMultiChangesRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  718. function(result){
  719. $.bootstrapLoading.end();
  720. if (result.data && result.data.insertId > 0) {
  721. CURRENT_ROLE_REL_ID = result.data.insertId;
  722. }
  723. }, function(err){
  724. $.bootstrapLoading.end();
  725. }, function(ex){
  726. $.bootstrapLoading.end();
  727. }
  728. );
  729. },
  730. setupAfterSelectMultiOther: async function (selectedOther, signatureDivId) {
  731. // 多变更令选择
  732. await this._commonRefreshAfterSelectSignature(signatureDivId);
  733. const params = this._getCommonParams();
  734. params.stg_id = STAGE_ID;
  735. params.selected = selectedOther;
  736. const new_ROLE_REL_LIST = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  737. new_ROLE_REL_LIST.forEach(nrole => {
  738. nrole.sign_pic = null;
  739. });
  740. params.rel_content = new_ROLE_REL_LIST;
  741. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  742. CommonAjax.postXsrfEx("/tender/report_api/updateMultiOtherRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  743. function(result){
  744. $.bootstrapLoading.end();
  745. if (result.data && result.data.insertId > 0) {
  746. CURRENT_ROLE_REL_ID = result.data.insertId;
  747. }
  748. }, function(err){
  749. $.bootstrapLoading.end();
  750. }, function(ex){
  751. $.bootstrapLoading.end();
  752. }
  753. );
  754. },
  755. setupAfterSelectMultiTenders: async function (selectedTenders, signatureDivId) {
  756. // 跨标段选择,有不少要注意的交互:
  757. await this._commonRefreshAfterSelectSignature(signatureDivId);
  758. //2. 集中请求
  759. const params = this._getCommonParams();
  760. params.selectedTenders = selectedTenders;
  761. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  762. $.bootstrapLoading.start();
  763. CommonAjax.postXsrfEx("/tender/report_api/updateMultiRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  764. function(result){
  765. $.bootstrapLoading.end();
  766. if (result.data && result.data.insertId > 0) {
  767. CURRENT_ROLE_REL_ID = result.data.insertId;
  768. }
  769. }, function(err){
  770. $.bootstrapLoading.end();
  771. }, function(ex){
  772. $.bootstrapLoading.end();
  773. }
  774. );
  775. },
  776. _parseRoleRelList: function(org_rel_content) {
  777. const rst = JSON.parse(org_rel_content);
  778. for (const role_rel of rst) {
  779. if (role_rel.sign_date !== null && role_rel.sign_date !== undefined && role_rel.sign_date.length >= 8) {
  780. role_rel.sign_date = new Date(role_rel.sign_date);
  781. }
  782. }
  783. return rst;
  784. },
  785. setupAfterSelectSignature: async function (signatureDivId) {
  786. //0. 签名日期
  787. let me = rptSignatureHelper;
  788. await this._commonRefreshAfterSelectSignature(signatureDivId);
  789. //2. 更新数据
  790. const params = this._getCommonParams();
  791. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(params.rel_content));
  792. $.bootstrapLoading.start();
  793. CommonAjax.postXsrfEx("/tender/report_api/updateRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  794. async function(result){
  795. // console.log(result);
  796. $.bootstrapLoading.end();
  797. if (result.data && result.data.insertId > 0) {
  798. CURRENT_ROLE_REL_ID = result.data.insertId;
  799. }
  800. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  801. CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  802. ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  803. // 原本要刷新的,但在前面的_commonRefreshAfterSelectSignature方法中已经处理好了,无需重复
  804. } else {
  805. // CURRENT_ROLE_REL_ID = -1;
  806. ROLE_REL_LIST = [];
  807. }
  808. }, function(err){
  809. // hintBox.unWaitBox();
  810. $.bootstrapLoading.end();
  811. }, function(ex){
  812. // hintBox.unWaitBox();
  813. $.bootstrapLoading.end();
  814. }
  815. );
  816. },
  817. switchAddRoleDiv: function (dom) {
  818. if (dom.nextElementSibling.children[0].style.display === 'none') {
  819. dom.nextElementSibling.children[0].style.display = '';
  820. } else {
  821. dom.nextElementSibling.children[0].style.display = 'none';
  822. }
  823. },
  824. createNewRole: function (dom) {
  825. if ($('#acc_role_name')[0].value !== '') {
  826. const params = {};
  827. params.name = $('#acc_role_name')[0].value;
  828. const selectedAcc = PRJ_ACCOUNT_LIST[$('#project_account_select_dom')[0].selectedOptions[0].value];
  829. const roleName = (selectedAcc.role === '')?DFT_ROLE_NAME:selectedAcc.role;
  830. params.bind_acc_id = selectedAcc.id;
  831. params.prj_id = PROJECT_ID;
  832. params.tender_id = TENDER_ID;
  833. CommonAjax.postXsrfEx("/tender/report_api/createSignatureRole", params, 10000, true, getCookie('csrfToken_j'),
  834. function(result){
  835. console.log(result);
  836. const newRole = {};
  837. newRole.name = params.name;
  838. newRole.bind_acc_id = selectedAcc.id;
  839. newRole.prj_id = PROJECT_ID;
  840. newRole.tender_id = TENDER_ID;
  841. ROLE_LIST.push(newRole);
  842. const domArr = [];
  843. domArr.push('<li class="add-sign-list-item">');
  844. //1. apply签名
  845. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + (ROLE_LIST.length - 1) +')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  846. domArr.push('<i class="fa fa-plus"></i>');
  847. domArr.push('</a>');
  848. //2. 编辑角色(暂缓处理click事件)
  849. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  850. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  851. domArr.push('</a>');
  852. //3. 显示名称
  853. domArr.push('<i class="fa fa-user"></i> ' + $('#acc_role_name')[0].value + '<p>' + selectedAcc.name + '-<small class="text-muted">' + roleName + '</small></p>');
  854. $('#existed_roles_ul').append(domArr.join(' '));
  855. }, function(err){
  856. // hintBox.unWaitBox();
  857. }, function(ex){
  858. // hintBox.unWaitBox();
  859. }
  860. );
  861. } else {
  862. alert('请输入合适的名称!');
  863. }
  864. },
  865. buildRoleDom: function (roleList) {
  866. const ulDom = $('#existed_roles_ul');
  867. ulDom.empty();
  868. for (let domIdx = 0; domIdx < roleList.length; domIdx++) {
  869. const role = roleList[domIdx];
  870. const domArr = [];
  871. domArr.push('<li class="add-sign-list-item">');
  872. //1. apply签名
  873. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + domIdx + ')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  874. domArr.push('<i class="fa fa-plus"></i>');
  875. domArr.push('</a>');
  876. //2. 编辑角色(暂缓)
  877. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  878. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  879. domArr.push('</a>');
  880. //3. 显示名称
  881. let acc = rptSignatureHelper.getUserAccount(role.bind_acc_id);
  882. 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>');
  883. ulDom.append(domArr.join(' '));
  884. }
  885. },
  886. getUserAccount: function (accId) {
  887. let rst = null;
  888. for (const acc of PRJ_ACCOUNT_LIST) {
  889. if (acc.id === accId) {
  890. rst = acc;
  891. break;
  892. }
  893. }
  894. return rst;
  895. },
  896. _getCompanySign: function(companyName, orgCompanyPath = null, userAccount = null) {
  897. let rst = orgCompanyPath || '';
  898. if (rst === '') {
  899. if (userAccount && userAccount.unit_sign_path && userAccount.unit_sign_path !== '') {
  900. rst = userAccount.unit_sign_path.split('!;!')[0].split('&%&')[0];
  901. } else {
  902. for (const cUnit of CONSTRUCT_UNIT_LIST) {
  903. if (cUnit.name === companyName) {
  904. rst = cUnit.sign_path;
  905. break;
  906. }
  907. }
  908. }
  909. }
  910. return rst;
  911. },
  912. mergeSignature: function (pageData, currRoleRelList, setPic = false, checkAudit = false) {
  913. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  914. const page = pageData.items[pageIdx];
  915. if (page.signature_cells) {
  916. // const adHocScells = [];
  917. for (const sCell of page.signature_cells) {
  918. if (sCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0) {
  919. sCell.path = null;
  920. sCell.pre_path = null;
  921. sCell.pic = null;
  922. }
  923. for (const role of currRoleRelList) {
  924. const role_rel = getTheRightRole(role, pageIdx);
  925. if (!checkAudit || checkAudit && rptSignatureHelper._chkIfAudit(role_rel)) {
  926. // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示
  927. if (role_rel.signature_name === sCell.signature_name) {
  928. // 处理签章
  929. if (!Array.isArray(role_rel.sign_output)) {
  930. role_rel.sign_output = [];
  931. role_rel.sign_output.push(NORMAL_SIGN_STR);
  932. }
  933. for (const signType of role_rel.sign_output) {
  934. switch (signType) {
  935. case NORMAL_SIGN_STR:
  936. sCell.path = role_rel.sign_path;
  937. sCell.pre_path = role_rel.sign_path;
  938. if (setPic) {
  939. sCell.pic = role_rel.sign_pic; // 有些场景(如:批量归档)需要直接设置签名数据
  940. }
  941. break;
  942. case COMPANY_SIGN_STR:
  943. case PRIVATE_SIGN_STR:
  944. // 搬到了mergetStamp方法那去处理了
  945. break;
  946. default:
  947. break;
  948. }
  949. }
  950. break;
  951. }
  952. }
  953. }
  954. }
  955. // page.signature_cells = page.signature_cells.concat(adHocScells);
  956. }
  957. }
  958. },
  959. resetDummySignature: async function(pageData, roleRels, ifPushRoleRel = false, checkAudit = false) {
  960. // 备注:计算草图等其他图形需要额外做些处理
  961. let dummySignIdx = 0;
  962. const stampPicKeys = [], stampPicFeatures = [];
  963. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  964. const page = pageData.items[pageIdx];
  965. if (page[JV.PROP_SIGNATURE_CELLS] && page[JV.PROP_SIGNATURE_CELLS].length > 0) {
  966. for (const signatureCell of page[JV.PROP_SIGNATURE_CELLS]) {
  967. if (signatureCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
  968. let passAuditChk = true;
  969. if (checkAudit) {
  970. passAuditChk = false;
  971. if (roleRels) {
  972. for (const role of roleRels) {
  973. const role_rel = getTheRightRole(role, pageIdx);
  974. if (role_rel.signature_name === signatureCell.signatureName) {
  975. // signatureName(非signature_name)是印章cell特意给的属性,还有isStamp属性
  976. if (rptSignatureHelper._chkIfAudit(role_rel)) {
  977. passAuditChk = true;
  978. break;
  979. }
  980. }
  981. }
  982. }
  983. }
  984. if (passAuditChk) {
  985. // 表示这是一个其他类型的非原生电子签名图,只是借用signature的处理机制,每个图都是唯一的,所以需要重新给个唯一的新signature_name
  986. // signatureCell.signature_name = signatureCell.signature_name + '_' + pageIdx + '_' + dummySignIdx;
  987. signatureCell.signature_name = signatureCell.signature_name + '_' + page.page_seq + '_' + dummySignIdx; // page_seq在分页后都不会变动
  988. dummySignIdx++;
  989. const roleRelItem = { type: '用户', sign_path: signatureCell.path, signature_name: signatureCell.signature_name };
  990. if (signatureCell.isStamp) {
  991. let stmpIdx = stampPicKeys.indexOf(signatureCell.path);
  992. if (stampPicKeys.indexOf(signatureCell.path) < 0) {
  993. stampPicKeys.push(signatureCell.path);
  994. stmpIdx = stampPicKeys.length - 1;
  995. const picRes = await getHttpBlobText(signatureCell.path + '?x-oss-process=image/info');
  996. stampPicFeatures.push(picRes);
  997. }
  998. // { "FileSize": {"value": "2514"}, "Format": {"value": "png"}, "ImageHeight": {"value": "94"}, "ImageWidth": {"value": "94"} }
  999. roleRelItem.stampFeature = stampPicFeatures[stmpIdx];
  1000. // 重新处理cell坐标
  1001. // 如果签章信息中存在位置信息,则不执行该方法
  1002. if(!signatureCell.isSaveSignature) _resetStampArea(pageData[JV.NODE_CONTROL_COLLECTION][signatureCell[JV.PROP_CONTROL]], signatureCell, roleRelItem);
  1003. }
  1004. if (ifPushRoleRel) roleRels.push(roleRelItem);
  1005. }
  1006. }
  1007. }
  1008. }
  1009. }
  1010. },
  1011. mergeSignAudit: function (pageData, currRoleRelList, currAuditList, checkAudit = false) {
  1012. const reg1 = new RegExp('\n\r', 'g');
  1013. const reg2 = new RegExp('\r\n', 'g');
  1014. const reg3 = new RegExp('\n', 'g');
  1015. const reg4 = new RegExp('\r', 'g');
  1016. const reg5 = new RegExp('<br/>', 'g');
  1017. const reg6 = new RegExp('<br>', 'g');
  1018. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1019. const page = pageData.items[pageIdx];
  1020. if (page.signature_audit_cells) {
  1021. for (const sCell of page.signature_audit_cells) {
  1022. sCell.Value = ''; // 这里要先清除原有信息
  1023. for (const role of currRoleRelList) {
  1024. const role_rel = getTheRightRole(role, pageIdx);
  1025. if (!checkAudit || checkAudit && rptSignatureHelper._chkIfAudit(role_rel)) {
  1026. // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示
  1027. if (sCell.signature_name === role_rel.signature_name + '_审核意见') {
  1028. let preDate = '';
  1029. sCell.Value = '同意'; // 只有选择了签名的,才需要初始化一个默认的意见(之前的逻辑在有多个签名,哪怕只选择了一个,其他的意见都会有默认意见)
  1030. for (const audit_rel of currAuditList) {
  1031. if (role_rel.acc_id === audit_rel.aid) {
  1032. const isOrAudit = this._chkOrAudit(role_rel.acc_id);
  1033. if (audit_rel.end_time > preDate && audit_rel.status === 3 || isOrAudit) {
  1034. sCell.Value = audit_rel.opinion;
  1035. if (typeof sCell.Value === 'string') {
  1036. sCell.Value = sCell.Value.replace(reg1, '|').replace(reg2, '|').replace(reg3, '|').replace(reg4, '|').replace(reg5, '|').replace(reg6, '|');
  1037. }
  1038. sCell.Value = (sCell.Value === '' && isOrAudit) ? '同意' : sCell.Value;
  1039. preDate = audit_rel.end_time;
  1040. } else {
  1041. sCell.Value = ''; // 如有匹配,但又不能输出,则需要清空
  1042. }
  1043. //不能break,实际会有多个审核意见,以最后一个为准
  1044. }
  1045. }
  1046. break;
  1047. }
  1048. }
  1049. }
  1050. }
  1051. }
  1052. }
  1053. },
  1054. _setDftDate: function (role_rel, isMergeOrgAlso = false) {
  1055. if (role_rel.acc_id && (role_rel.sign_date === undefined || role_rel.sign_date === null || role_rel.sign_date === '')) {
  1056. let dftDate = _getSignDateByAllScenarios(role_rel.acc_id);
  1057. if (dftDate !== '' && dftDate.length >= 10) {
  1058. dftDate = new Date(dftDate); // 不Format,保留时分秒
  1059. } else if (dftDate === '') {
  1060. if (current_stage_id <= -300 && current_stage_id > -400 && BGL_OBJ && BGL_OBJ.currentBz && BGL_OBJ.currentBz.status === 3) {
  1061. if (STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  1062. dftDate = new Date(STAGE_AUDIT[STAGE_AUDIT.length - 1].end_time);
  1063. } else {
  1064. dftDate = new Date();
  1065. }
  1066. } else {
  1067. dftDate = new Date();
  1068. }
  1069. }
  1070. role_rel.sign_date = dftDate;
  1071. if (isMergeOrgAlso) {
  1072. for (const orgRR of rptSignatureHelper.originalRoleRelList) {
  1073. if (orgRR.signature_name === role_rel.signature_name) {
  1074. orgRR.sign_date = dftDate;
  1075. break;
  1076. }
  1077. }
  1078. // rptSignatureHelper.originalRoleRelList[rridx].sign_date = dftDate; // 这个在实际情况下originalRoleRelList不一定与currRoleRelList一致
  1079. //备注:在多选导出的情况下,originalRoleRelList不需要merge
  1080. }
  1081. }
  1082. },
  1083. mergeSignDate: function (pageData, currRoleRelList, isMergeOrgAlso, checkAudit = false) {
  1084. if (currRoleRelList && currRoleRelList.length > 0 && STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  1085. for (let rridx = 0; rridx < currRoleRelList.length; rridx++) {
  1086. const role_rel = currRoleRelList[rridx];
  1087. if (role_rel.type !== '流程') {
  1088. rptSignatureHelper._setDftDate(role_rel, isMergeOrgAlso);
  1089. }
  1090. }
  1091. }
  1092. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1093. const page = pageData.items[pageIdx];
  1094. if (page.signature_date_cells) {
  1095. for (const sCell of page.signature_date_cells) {
  1096. if (typeof sCell.Value === 'string' && sCell.Value.replace(/ /g, '') === '年月日') {
  1097. sCell.Value = _getSignDateDftName();
  1098. } else {
  1099. sCell.Value = '';
  1100. }
  1101. for (const role of currRoleRelList) {
  1102. const role_rel = getTheRightRole(role, pageIdx);
  1103. // if (role.type === '流程') rptSignatureHelper._setDftDate(role_rel, false);
  1104. if (role.type === '流程') {
  1105. if (role.flowAccList[pageIdx] < 0) continue; // 没有合适的,则判断下一个
  1106. rptSignatureHelper._setDftDate(role_rel, false);
  1107. }
  1108. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  1109. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1110. // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示
  1111. if (!!role_rel.sign_date && role_rel.sign_date !== '') {
  1112. if (typeof role_rel.sign_date === 'string') {
  1113. role_rel.sign_date = new Date(role_rel.sign_date);
  1114. }
  1115. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  1116. }
  1117. }
  1118. break;
  1119. }
  1120. }
  1121. }
  1122. }
  1123. }
  1124. },
  1125. _chkOrAudit: function(acc_id) {
  1126. // 检测 '或签' 情况下的审核状态(在或签情况下,另一个审核通过,那么这个也是通过的)
  1127. let rst = false;
  1128. for (const flow of STAGE_FLOW) {
  1129. if (flow.aid === acc_id) {
  1130. if (flow.audit_type === 3) {
  1131. // 判断 或签 用户状态
  1132. for (const secFlow of STAGE_FLOW) {
  1133. if (secFlow.audit_type === 3 && secFlow.order === flow.order && secFlow.aid !== acc_id) {
  1134. rst = secFlow.status === 3 || flow.status === 3;
  1135. if (rst) break;
  1136. }
  1137. }
  1138. }
  1139. break;
  1140. }
  1141. }
  1142. return rst;
  1143. },
  1144. _chkIfAudit: function(role_rel) {
  1145. // 检测是否在审核列表中
  1146. let rst = false;
  1147. for (const stg_audit of STAGE_AUDIT) {
  1148. if (role_rel.acc_id === stg_audit.aid) {
  1149. if (stg_audit.status === 3) {
  1150. rst = true;
  1151. } else {
  1152. rst = false;
  1153. }
  1154. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  1155. }
  1156. }
  1157. if (!rst && current_stage_id > 0) {
  1158. // 还有原报需要检测(这里是计量期单独的判断)
  1159. for (const stg_ort_rpt of STAGE_LIST) {
  1160. if (stg_ort_rpt.id === current_stage_id && role_rel.acc_id === stg_ort_rpt.user_id) {
  1161. if (stg_ort_rpt.status !== 1 && stg_ort_rpt.status !== 4) {
  1162. // 只要不是待上报(1)、退回审批(4) 状态,都需要显示
  1163. rst = true;
  1164. } else {
  1165. rst = false;
  1166. }
  1167. break;
  1168. }
  1169. }
  1170. if (!rst) {
  1171. rst = this._chkOrAudit(role_rel.acc_id);
  1172. }
  1173. }
  1174. // rst = true; //测试,未来将屏蔽
  1175. return rst;
  1176. },
  1177. _chkIfOrgRpt: function(acc_id) {
  1178. // 检测是否原报
  1179. let rst = false;
  1180. for (const stg of STAGE_LIST) {
  1181. if (stg.id === current_stage_id) {
  1182. if (stg.user_id === acc_id) {
  1183. rst = true;
  1184. }
  1185. break;
  1186. }
  1187. }
  1188. return rst;
  1189. },
  1190. _cancelFlowSignDate: function(signature_name) {
  1191. for (const roleRel of ROLE_REL_LIST) {
  1192. if (roleRel.signature_name === signature_name && roleRel.type === '流程') {
  1193. roleRel.assFlowInfos.forEach((asf, index) => {
  1194. const fdtpId = `flowdtp_${signature_name}_${index}`;
  1195. let dtDom = document.getElementById(fdtpId); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象
  1196. if (dtDom) {
  1197. dtDom.value = asf.sign_date || '';
  1198. }
  1199. });
  1200. }
  1201. }
  1202. },
  1203. _saveFlowSignDate: function(signature_name) {
  1204. for (const roleRel of ROLE_REL_LIST) {
  1205. if (roleRel.signature_name === signature_name && roleRel.type === '流程') {
  1206. roleRel.assFlowInfos.forEach((asf, index) => {
  1207. const fdtpId = `flowdtp_${signature_name}_${index}`;
  1208. let dtDom = document.getElementById(fdtpId); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象
  1209. if (dtDom) {
  1210. asf.sign_date = dtDom.value;
  1211. }
  1212. });
  1213. }
  1214. }
  1215. },
  1216. _changeSignType: function(dom, signature_name, chkStr, userStamp, flowIndex = -1) {
  1217. for (const roleRel of ROLE_REL_LIST) {
  1218. if (roleRel.signature_name === signature_name) {
  1219. let newRoleRel = roleRel;
  1220. if (roleRel.type === '流程') {
  1221. newRoleRel = roleRel.assFlowInfos[flowIndex];
  1222. }
  1223. if (dom.checked) {
  1224. if (newRoleRel.sign_output.indexOf(chkStr) < 0) {
  1225. newRoleRel.sign_output.push(chkStr);
  1226. }
  1227. if(chkStr==='private_stamp' && !newRoleRel.private_stamp_path && userStamp){
  1228. newRoleRel.private_stamp_path = userStamp.split('!;!').split('&%&')[0] ;
  1229. // userAcc.unit_sign_path = userAcc.unit_sign_path.replace(/&%&/g, '!;!');
  1230. // console.log(newRoleRel.private_stamp_path);
  1231. }
  1232. } else {
  1233. let idx = newRoleRel.sign_output.indexOf(chkStr);
  1234. if (idx >= 0) {
  1235. newRoleRel.sign_output.splice(idx, 1);
  1236. }
  1237. }
  1238. break;
  1239. }
  1240. }
  1241. },
  1242. _resetStampPos: function(orgCell, targetCell, controls) {
  1243. const ctrl = controls[orgCell.control];
  1244. let pLeft = orgCell.area.Left, pTop = orgCell.area.Top;
  1245. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
  1246. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
  1247. pLeft = orgCell.area.Left;
  1248. break;
  1249. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
  1250. pLeft = (orgCell.area.Left + orgCell.area.Right - STD_STAMP_SIZE_WIDTH) / 2 ;
  1251. break;
  1252. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
  1253. pLeft = orgCell.area.Right - STD_STAMP_SIZE_WIDTH;
  1254. break;
  1255. }
  1256. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
  1257. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_TOP]:
  1258. pTop = orgCell.area.Top;
  1259. break;
  1260. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_CENTER]:
  1261. pTop = (orgCell.area.Top + orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT) / 2 ;
  1262. break;
  1263. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_BOTTOM]:
  1264. pTop = orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT;
  1265. break;
  1266. }
  1267. targetCell.area.Left = pLeft;
  1268. targetCell.area.Top = pTop;
  1269. targetCell.area.Right = pLeft + STD_STAMP_SIZE_WIDTH;
  1270. targetCell.area.Bottom = pTop + STD_STAMP_SIZE_HEIGHT;
  1271. },
  1272. initChosePrivateStampPath:function(stampPathList, signature_name, flowIndex = -1, destDial = 'chose-private-stamp-path'){
  1273. let currentStamp='';
  1274. const targetNode= ROLE_REL_LIST.find(item=>item.signature_name===signature_name);
  1275. if (targetNode) {
  1276. if (targetNode.type === '流程') {
  1277. currentStamp = targetNode.assFlowInfos[flowIndex].private_stamp_path;
  1278. } else {
  1279. currentStamp = targetNode.private_stamp_path;
  1280. if (destDial !== 'chose-private-stamp-path') {
  1281. currentStamp = targetNode.company_stamp_path || '';
  1282. if (currentStamp.includes('&%&')) {
  1283. currentStamp = stampPathList.split('!;!')[0];
  1284. }
  1285. }
  1286. }
  1287. }
  1288. let content=`<div class='row justify-content-md-center'>`;
  1289. stampPathList.split('!;!').forEach(item=>{
  1290. content+=`<div class="card col-3 p-2 m-3 d-flex ${currentStamp===item?'card-gk-active':''} stamp-img">
  1291. <div class="p-0 private-stamp-img">
  1292. <div class="sel-width check-state ${currentStamp===item?'sel-blue':''} "></div>
  1293. <img src="${rptSignatureHelper.fujianOssPath}${item}" data-src='${item}' class="img-fluid" alt="...">
  1294. </div>
  1295. </div>`;
  1296. })
  1297. for(let i=0;i<stampPathList.length%3;i++){
  1298. content+=`<div class="col-3 p-2 m-3"></div>`;
  1299. }
  1300. content+=` </div><div class='privateStampRoleName' data-name='${signature_name}'></div>`;
  1301. content += `<div class='privateStampFlowIndex' data-name='${flowIndex}'></div>`;
  1302. // $('#chose-private-stamp-path .modal-body').empty().append(content);
  1303. $(`#${destDial} .modal-body`).empty().append(content);
  1304. $('.stamp-img').on('click',(e)=>{
  1305. $('.stamp-img').removeClass('card-gk-active');
  1306. $('.stamp-img').find('.sel-width').removeClass('sel-blue');
  1307. $(e.currentTarget).addClass('card-gk-active');
  1308. $(e.currentTarget).find('.sel-width').addClass('sel-blue');
  1309. })
  1310. },
  1311. setPrivateStamp(e, flowIndex = -1){
  1312. const imgSrc= $('.stamp-img.card-gk-active').find('.img-fluid').data('src');
  1313. const privateStampRoleName=$('.privateStampRoleName').data('name');
  1314. const targetNode= ROLE_REL_LIST.find(item=>item.signature_name==privateStampRoleName);
  1315. if (targetNode.type === '流程') {
  1316. const flowIndex = +($('.privateStampFlowIndex').data('name'));
  1317. targetNode.assFlowInfos[flowIndex].private_stamp_path = imgSrc;
  1318. } else {
  1319. targetNode.private_stamp_path = imgSrc;
  1320. }
  1321. $('#chose-private-stamp-path').modal('hide');
  1322. },
  1323. setCompanyStamp(e, flowIndex = -1) {
  1324. const imgSrc= $('.stamp-img.card-gk-active').find('.img-fluid').data('src');
  1325. const privateStampRoleName=$('.privateStampRoleName').data('name');
  1326. const targetNode = ROLE_REL_LIST.find( item => item.signature_name === privateStampRoleName);
  1327. if (targetNode.type === '流程') {
  1328. const flowIndex = +($('.privateStampFlowIndex').data('name'));
  1329. targetNode.assFlowInfos[flowIndex].company_stamp_path = imgSrc;
  1330. } else {
  1331. targetNode.company_stamp_path = imgSrc;
  1332. }
  1333. $('#chose-company-stamp-path').modal('hide');
  1334. },
  1335. _get_newPrivate_stamp_path(roleRelObj,userAcc) {
  1336. if (!roleRelObj.private_stamp_path) {
  1337. if (!userAcc.stamp_path) return '';
  1338. if (userAcc.stamp_path.split('!;!').length === 1) {
  1339. return userAcc.stamp_path;
  1340. }else{
  1341. return userAcc.stamp_path.split('!;!')[0];
  1342. }
  1343. }
  1344. return roleRelObj.private_stamp_path;
  1345. }
  1346. }
  1347. function _getSignDateByAllScenarios(userAccId) {
  1348. let rst = '';
  1349. let hasAudit = false;
  1350. for (const stg_audit of STAGE_AUDIT) {
  1351. // 或签的也会在此 STAGE_AUDIT 列里面
  1352. if (stg_audit.aid === userAccId) {
  1353. hasAudit = true;
  1354. // 加上 '或签' 检测
  1355. if (stg_audit.status === 3 || rptSignatureHelper._chkOrAudit(stg_audit.aid)) {
  1356. rst = stg_audit.end_time;
  1357. }
  1358. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  1359. }
  1360. }
  1361. let isOrgRpt = false;
  1362. for (const stg of STAGE_LIST) {
  1363. if (stg.id === current_stage_id) {
  1364. if (stg.user_id === userAccId) {
  1365. isOrgRpt = true;
  1366. }
  1367. break;
  1368. }
  1369. }
  1370. if (isOrgRpt && !hasAudit && STAGE_AUDIT_ORG && STAGE_AUDIT_ORG.length > 0) {
  1371. if (STAGE_AUDIT_ORG[0].begin_time && STAGE_AUDIT_ORG[0].begin_time !== '' && STAGE_AUDIT_ORG[0].begin_time.length >= 10) {
  1372. rst = STAGE_AUDIT_ORG[0].begin_time;
  1373. }
  1374. }
  1375. if (!isOrgRpt && !hasAudit) {
  1376. // 非审批流程人员以及非原报,则显示期截至时间
  1377. // 之前给我的解释有问题的,不应该找stage的period属性,而是找当期最后一个status===3的end_time时间(STAGE_AUDIT已经取了最后times,并已排序了)
  1378. for (const stg_audit of STAGE_AUDIT) {
  1379. if (stg_audit.status === 3) {
  1380. rst = stg_audit.end_time;
  1381. }
  1382. }
  1383. }
  1384. return rst;
  1385. }
  1386. function _getStatusByUserId(userAccId) {
  1387. let rst = -1;
  1388. for (const stg_audit of STAGE_AUDIT) {
  1389. // 或签的也会在此 STAGE_AUDIT 列里面
  1390. if (stg_audit.aid === userAccId) {
  1391. rst = stg_audit.status;
  1392. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  1393. }
  1394. }
  1395. return rst;
  1396. }
  1397. function _getSignDateDftName() {
  1398. return ' 年 月 日';
  1399. }
  1400. function _createDummyCell() {
  1401. const rst = {
  1402. font: 'Footer',
  1403. control: 'Footer',
  1404. style: 'Default_None',
  1405. Value: '',
  1406. area: { Left: 0, Right: 0, Top: 0, Bottom: 0 },
  1407. };
  1408. return rst;
  1409. }
  1410. function prepareRightFlowRoles(pageData, roleRelList = [], stg_audit = [], ledgerList = []) {
  1411. // 争取在这里一次过把所有页面的流程签名数据整理完毕,方便后面的工序能简单处理
  1412. const flowRole = roleRelList.find(role => { return role.type === '流程'; });
  1413. for (const role of roleRelList) {
  1414. if (role.type === '流程') role.flowAccList = []; // 这里直接清理流程签名信息
  1415. }
  1416. if (flowRole) {
  1417. const ledgerCache = {}; // 生成台账信息cache对象,提高查找效率
  1418. ledgerList.forEach(ledger => {
  1419. ledgerCache[ledger.id] = ledger;
  1420. ledgerCache[`_${ledger.ledger_id}`] = ledger;
  1421. })
  1422. const auditCache = {}; // 生成stage审核cache对象,提高查找效率
  1423. stg_audit.forEach(audit => {
  1424. if (audit.audit_type === 4) {
  1425. auditCache[`_${audit.aid}`] = `${audit.audit_ledger_id}`; // 统一用string类型来判断
  1426. }
  1427. });
  1428. const _getShortPath = (assFlowRole, page) => {
  1429. // 此方法获取当前页到流程审核的最短层次路径(考虑到不同人的控制的台账层次会有包含关系,需要厘清,以最短的用户为准),-1表示没有
  1430. let rst = -1;
  1431. let currentPageLedgeId = ledgerCache[page.extend_flow_options].ledger_id;
  1432. const idStr = `${auditCache[`_${assFlowRole.acc_id}`]}`;
  1433. const idStrs = idStr.split(',');
  1434. let lv = 0;
  1435. while (true) {
  1436. if (idStrs.includes(`${currentPageLedgeId}`)) {
  1437. rst = lv;
  1438. break;
  1439. }
  1440. lv++;
  1441. if (currentPageLedgeId !== -1) {
  1442. currentPageLedgeId = ledgerCache[`_${currentPageLedgeId}`].ledger_pid;
  1443. }
  1444. if (currentPageLedgeId === -1) break;
  1445. }
  1446. return rst;
  1447. };
  1448. pageData.items.forEach((page, index) => {
  1449. if (page.extend_flow_options && page.extend_flow_options !== '') {
  1450. for (const role of roleRelList) {
  1451. if (role.type === '流程') {
  1452. role.flowAccList.push(-1); // !!! 每一页都要有一个流程签名指引,-1表示没有
  1453. let preLen = 10000; //
  1454. for (let assIdx = 0; assIdx < role.assFlowInfos.length; assIdx++) {
  1455. const assRole = role.assFlowInfos[assIdx];
  1456. if (auditCache[`_${assRole.acc_id}`]) {
  1457. const chkLv = _getShortPath(assRole, page);
  1458. if (chkLv !== -1) {
  1459. if (chkLv < preLen) {
  1460. role.flowAccList[role.flowAccList.length - 1] = assIdx;
  1461. preLen = chkLv; // 还要考虑到嵌套的情况
  1462. }
  1463. }
  1464. }
  1465. }
  1466. }
  1467. }
  1468. }
  1469. // role.flowAccList
  1470. });
  1471. }
  1472. }
  1473. function getTheRightRole(role, pageIdx) {
  1474. let rst = role;
  1475. if (role.type === '流程') {
  1476. if (role.flowAccList && role.flowAccList.length > pageIdx) {
  1477. if (role.flowAccList[pageIdx] !== -1) {
  1478. rst = role.assFlowInfos[role.flowAccList[pageIdx]];
  1479. if (role.areaData) rst.areaData = role.areaData;
  1480. }
  1481. }
  1482. }
  1483. return rst;
  1484. }
  1485. function resetStampSignature(pageData, roleRelList, checkAudit = false, stg_audit = [], ledgerList = []) {
  1486. prepareRightFlowRoles(pageData, roleRelList, stg_audit, ledgerList);
  1487. const dupPicPaths = [];
  1488. const _getMaxRect = function(page) {
  1489. const rect = [100000000, 100000000, 0, 0];
  1490. for (const cell of page.cells) {
  1491. rect[0] = rect[0] > cell.area.Left ? cell.area.Left : rect[0];
  1492. rect[1] = rect[1] > cell.area.Top ? cell.area.Top : rect[1];
  1493. rect[2] = rect[2] < cell.area.Right ? cell.area.Right : rect[2];
  1494. rect[3] = rect[3] < cell.area.Bottom ? cell.area.Bottom : rect[3];
  1495. }
  1496. return rect;
  1497. };
  1498. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1499. const page = pageData.items[pageIdx];
  1500. const maxRect = _getMaxRect(page);
  1501. if (page.signature_cells) {
  1502. const newStampCells = [];
  1503. for (let scIdx = 0; scIdx < page.signature_cells.length; scIdx++) {
  1504. const sCell = page.signature_cells[scIdx];
  1505. for (const role of roleRelList) {
  1506. const role_rel = getTheRightRole(role, pageIdx);
  1507. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1508. if (sCell.signature_name === role_rel.signature_name) {
  1509. if (Array.isArray(role_rel.sign_output) && role_rel.sign_output.length > 0) {
  1510. for (const signType of role_rel.sign_output) {
  1511. switch (signType) {
  1512. case COMPANY_SIGN_STR:
  1513. case PRIVATE_SIGN_STR:
  1514. // 创建一个新的cell
  1515. let stampPath = (signType === COMPANY_SIGN_STR) ? role_rel.company_stamp_path : role_rel.private_stamp_path;
  1516. stampPath = OSS_PATH + stampPath;
  1517. if (dupPicPaths.indexOf(stampPath) < 0) {
  1518. dupPicPaths.push(stampPath);
  1519. }
  1520. // 签字信息中如果有签章位置信息,则直接用位置信息
  1521. let signatureArea;
  1522. if (role_rel.areaData && role_rel.areaData[signType]) {
  1523. // signatureArea = role_rel.areaData[signType];
  1524. signatureArea = JSON.parse(JSON.stringify(role_rel.areaData[signType])); // 这里要重新整理一份新的,否则在导出到同一页面的时候会重合
  1525. }
  1526. const newStampCell = {
  1527. signature_name: JV.SIGNATURE_NAME_DUMMY,
  1528. control: sCell.control,
  1529. style: sCell.style,
  1530. path: stampPath,
  1531. isStamp: true,
  1532. maxRect: JSON.parse(JSON.stringify(maxRect)),
  1533. orgArea: JSON.parse(JSON.stringify(sCell.area)),
  1534. area: signatureArea || {Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom},
  1535. signatureName: role_rel.signature_name, // 节点名称
  1536. signType, // 签章信息
  1537. isSaveSignature: !!signatureArea, // 是否有签章位置信息
  1538. };
  1539. newStampCells.push(newStampCell);
  1540. break;
  1541. default: break;
  1542. }
  1543. }
  1544. }
  1545. }
  1546. }
  1547. }
  1548. }
  1549. if (newStampCells.length > 0) {
  1550. newStampCells.forEach(newSCell => {
  1551. // 因后台也已生成过签章,这里再生成的话会重复,需要删除(但在多期同时计量,原报签章在刷新后会丢失,所以需要这里再补上,见2024/09/18修改)
  1552. for (let sIdx = 0; sIdx < page.signature_cells.length; sIdx++) {
  1553. if (page.signature_cells[sIdx].path === newSCell.path) {
  1554. page.signature_cells.splice(sIdx, 1);
  1555. break;
  1556. }
  1557. }
  1558. });
  1559. page.signature_cells = page.signature_cells.concat(newStampCells);
  1560. }
  1561. }
  1562. }
  1563. }
  1564. function resetTextSignature(pageData, role_rel_list = [], checkAudit = false) {
  1565. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1566. const page = pageData.items[pageIdx];
  1567. for (let sCell of page.signature_cells) {
  1568. if (!sCell.isStamp) {
  1569. let fitCell = null;
  1570. for (let idx = page.cells.length - 1; idx >= 0; idx--) {
  1571. const cell = page.cells[idx];
  1572. 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) {
  1573. fitCell = cell;
  1574. break;
  1575. }
  1576. }
  1577. if (fitCell) {
  1578. fitCell.Value = '';
  1579. for (let role of role_rel_list) {
  1580. const role_rel = getTheRightRole(role, pageIdx);
  1581. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1582. if (sCell.signature_name === role_rel.signature_name) {
  1583. if (role_rel.sign_output && role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {
  1584. fitCell.Value = role_rel.user_name;
  1585. } else {
  1586. fitCell.Value = '';
  1587. }
  1588. break;
  1589. }
  1590. }
  1591. }
  1592. } else {
  1593. // 要创建新的文本签名cell
  1594. const newCell = {
  1595. font: 'Footer',
  1596. control: sCell.control,
  1597. style: sCell.style,
  1598. Value: '',
  1599. area: { Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom },
  1600. };
  1601. if (role_rel_list) {
  1602. for (let role of role_rel_list) {
  1603. const role_rel = getTheRightRole(role, pageIdx);
  1604. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1605. if (sCell.signature_name === role_rel.signature_name && role_rel.sign_output && role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {
  1606. newCell.Value = role_rel.user_name;
  1607. break;
  1608. }
  1609. }
  1610. }
  1611. }
  1612. page.cells.push(newCell); // 怎么也要有这个,哪怕没有文本也要输出,补边框用的
  1613. }
  1614. }
  1615. }
  1616. }
  1617. }
  1618. function _resetStampArea(ctrl, stampCell, roleRelItem) {
  1619. let pLeft = stampCell.orgArea.Left,
  1620. pTop = stampCell.orgArea.Top;
  1621. if (roleRelItem.stampFeature !== 'not found!') {
  1622. let std_stamp_size_width = STD_STAMP_SIZE_WIDTH, std_stamp_size_height = STD_STAMP_SIZE_HEIGHT;
  1623. let widthRate = 1, heightRate = 1;
  1624. if (roleRelItem.stampFeature) {
  1625. std_stamp_size_width = parseFloat(roleRelItem.stampFeature.ImageWidth.value);
  1626. std_stamp_size_height = parseFloat(roleRelItem.stampFeature.ImageHeight.value);
  1627. if (roleRelItem.stampFeature.ImageWidth.value !== roleRelItem.stampFeature.ImageHeight.value) {
  1628. //设置比例
  1629. if (std_stamp_size_width > std_stamp_size_height) {
  1630. heightRate = std_stamp_size_height / std_stamp_size_width;
  1631. } else {
  1632. widthRate = std_stamp_size_width / std_stamp_size_height;
  1633. }
  1634. }
  1635. if (std_stamp_size_width > STD_STAMP_SIZE_WIDTH || std_stamp_size_height > STD_STAMP_SIZE_HEIGHT) {
  1636. if (widthRate === 1) {
  1637. std_stamp_size_width = Math.min(std_stamp_size_width, STD_STAMP_SIZE_WIDTH);
  1638. std_stamp_size_height = std_stamp_size_width * heightRate;
  1639. } else {
  1640. std_stamp_size_height = Math.min(std_stamp_size_height, STD_STAMP_SIZE_HEIGHT);
  1641. std_stamp_size_width = std_stamp_size_height * widthRate;
  1642. }
  1643. }
  1644. }
  1645. switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
  1646. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
  1647. pLeft = stampCell.orgArea.Left;
  1648. break;
  1649. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
  1650. pLeft = (stampCell.orgArea.Left + stampCell.orgArea.Right - std_stamp_size_width) / 2;
  1651. break;
  1652. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
  1653. pLeft = stampCell.orgArea.Right - std_stamp_size_width;
  1654. break;
  1655. default:break;
  1656. }
  1657. switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
  1658. case JV.OUTPUT_ALIGN.V[JV.V_ALIGN_IDX_TOP]:
  1659. pTop = stampCell.orgArea.Top;
  1660. break;
  1661. case JV.OUTPUT_ALIGN.V[JV.V_ALIGN_IDX_CENTER]:
  1662. pTop = (stampCell.orgArea.Top + stampCell.orgArea.Bottom - std_stamp_size_height) / 2;
  1663. break;
  1664. case JV.OUTPUT_ALIGN.V[JV.V_ALIGN_IDX_BOTTOM]:
  1665. pTop = stampCell.orgArea.Bottom - std_stamp_size_height;
  1666. break;
  1667. default:break;
  1668. }
  1669. stampCell.area.Left = pLeft;
  1670. stampCell.area.Top = pTop;
  1671. stampCell.area.Right = pLeft + std_stamp_size_width;
  1672. stampCell.area.Bottom = pTop + std_stamp_size_height;
  1673. // 最后一步,如超过报表范围,则要调整坐标
  1674. const maxRect = stampCell.maxRect;
  1675. if (stampCell.area.Left < maxRect[0]) {
  1676. const width = maxRect[0] - stampCell.area.Left;
  1677. stampCell.area.Left += width;
  1678. stampCell.area.Right += width;
  1679. }
  1680. if (stampCell.area.Top < maxRect[1]) {
  1681. const height = maxRect[1] - stampCell.area.Top;
  1682. stampCell.area.Top += height;
  1683. stampCell.area.Bottom += height;
  1684. }
  1685. if (stampCell.area.Right > maxRect[2]) {
  1686. const width = maxRect[2] - stampCell.area.Right; // 负
  1687. stampCell.area.Left += width;
  1688. stampCell.area.Right += width;
  1689. }
  1690. if (stampCell.area.Bottom > maxRect[3]) {
  1691. const height = maxRect[3] - stampCell.area.Bottom;
  1692. stampCell.area.Top += height;
  1693. stampCell.area.Bottom += height;
  1694. }
  1695. }
  1696. }