rpt_signature.js 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  1. /**
  2. * Created by Tony on 2019/9/25.
  3. */
  4. 'use strict'
  5. const DFT_ROLE_NAME = '';
  6. const NORMAL_SIGN_STR = 'normal_sign';
  7. const COMPANY_SIGN_STR = 'company_stamp';
  8. const PRIVATE_SIGN_STR = 'private_stamp';
  9. const STD_STAMP_SIZE_WIDTH = 5 * 96 / 2.54; // 公章大小:宽度(5 CM)
  10. const STD_STAMP_SIZE_HEIGHT = 5 * 96 / 2.54; // 公章大小:高度(5 CM)
  11. let rptSignatureHelper = {
  12. currentSelectedESignAccDom: null,
  13. currentSelectedESignAccIdx: -1,
  14. currentSelectedESignAccName: null,
  15. currentSelectedESignParentDivId: '',
  16. originalRoleRelList: [],
  17. buildSelectableAccount: function () {
  18. //PRJ_ACCOUNT_LIST
  19. //1. 清理所有选择项
  20. // $("#project_account_select_div").empty();
  21. let accDiv = $('#project_account_select_div');
  22. let accSelect = $('#project_account_select_dom'); //绑定成员
  23. let searchInput = $('#search_account').val();
  24. accDiv.empty();
  25. accSelect.empty();
  26. //2. 一个个加可选用户项
  27. const prj_accounts = [];
  28. const prj_sel_option_accounts = [];
  29. const acc_role_keys = [];
  30. for (let accIdx = 0; accIdx < PRJ_ACCOUNT_LIST.length; accIdx++) {
  31. const prjAccount = PRJ_ACCOUNT_LIST[accIdx];
  32. if (searchInput === '' || (searchInput !== '' && prjAccount.name.indexOf(searchInput) !== -1)) {
  33. let companyKey = prjAccount.account_group;
  34. let roleKey = prjAccount.role;
  35. if (companyKey === '') {
  36. companyKey = '其他单位';
  37. }
  38. if (roleKey === '') {
  39. roleKey = DFT_ROLE_NAME;
  40. }
  41. let keyIdx = acc_role_keys.indexOf(companyKey);
  42. if (keyIdx < 0) {
  43. acc_role_keys.push(companyKey);
  44. prj_accounts.push([]);
  45. prj_sel_option_accounts.push([]);
  46. keyIdx = prj_accounts.length - 1;
  47. //这里先push一些 html prefix,在后面统一在push html suffix
  48. prj_accounts[keyIdx].push('<ul class="list-group">');
  49. prj_accounts[keyIdx].push('<li class="px-2 text-muted"><i class="fa fa-caret-down"></i> ' + companyKey + '</li>');
  50. prj_sel_option_accounts[keyIdx].push('<optgroup label=" ' + companyKey + '">');
  51. }
  52. //push item
  53. // 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>' +
  54. // prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
  55. 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>`);
  56. prj_sel_option_accounts[keyIdx].push('<option value="' + accIdx + '">' + prjAccount.name + '-' + roleKey + '</option>');
  57. }
  58. }
  59. for (const prjAccList of prj_accounts) {
  60. prjAccList.push('</ul>');
  61. }
  62. for (const prjAccList of prj_sel_option_accounts) {
  63. prjAccList.push('</optgroup>');
  64. }
  65. for (let idx = 0; idx < prj_accounts.length; idx++) {
  66. prj_accounts[idx] = prj_accounts[idx].join('');
  67. prj_sel_option_accounts[idx] = prj_sel_option_accounts[idx].join('');
  68. }
  69. accDiv.append(prj_accounts.join(''));
  70. accSelect.append(prj_sel_option_accounts.join(''));
  71. },
  72. buildSelectableAccountUsed: function () {
  73. //PRJ_ACCOUNT_LIST
  74. //1. 清理所有选择项
  75. // $("#project_account_select_div").empty();
  76. let accDiv = $('#account_used_select_div');
  77. accDiv.empty();
  78. //2. 一个个加可选用户项
  79. const prj_accounts = [];
  80. for (let uidx = 0; uidx < USED_LIST.length; uidx++) {
  81. const accIdx = PRJ_ACCOUNT_LIST.findIndex(function(item) {
  82. return item.id === USED_LIST[uidx].uid;
  83. });
  84. if (accIdx === -1 || accIdx === undefined) {
  85. continue;
  86. }
  87. const prjAccount = PRJ_ACCOUNT_LIST[accIdx];
  88. let roleKey = prjAccount.role;
  89. if (roleKey === '') {
  90. roleKey = DFT_ROLE_NAME;
  91. }
  92. //push item
  93. // 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>' +
  94. // prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
  95. 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>`);
  96. }
  97. accDiv.append(prj_accounts.join(''));
  98. },
  99. createEsignatureByAccIdx: function (accIdx) {
  100. rptSignatureHelper.createPreSelectedSignature(PRJ_ACCOUNT_LIST[accIdx], null);
  101. },
  102. createEsignatureByRoleIdx: function (roleIdx) {
  103. rptSignatureHelper.createPreSelectedSignature(null, ROLE_LIST[roleIdx]);
  104. },
  105. createPreSelectedSignature: function (directAcc, roleAcc) {
  106. let dftSignSrc = '/public/upload/sign/user-sign.PNG';
  107. let userAcc = directAcc;
  108. if (roleAcc) {
  109. userAcc = rptSignatureHelper.getUserAccount(roleAcc.bind_acc_id);
  110. }
  111. if (userAcc.sign_path !== '') {
  112. dftSignSrc = '/public/upload/sign/' + userAcc.sign_path;
  113. }
  114. if (rptSignatureHelper.currentSelectedESignAccName !== null) {
  115. for (const page of zTreeOprObj.currentRptPageRst.items) {
  116. if (page.signature_cells) {
  117. for (const sCell of page.signature_cells) {
  118. if (sCell.signature_name === rptSignatureHelper.currentSelectedESignAccName) {
  119. sCell.pre_path = dftSignSrc;
  120. }
  121. }
  122. }
  123. }
  124. // 1. 删除不需要的child dom
  125. $(rptSignatureHelper.currentSelectedESignAccDom).empty();
  126. // 2. 创建已选择签名相关 dom
  127. rptSignatureHelper.cleanOldSignature(rptSignatureHelper.currentSelectedESignAccName);
  128. // 2.1 dom element
  129. const elementsStrArr = [];
  130. let dftDate = _getSignDateByAllScenarios(userAcc.id);
  131. if (dftDate !== '' && dftDate.length > 20) {
  132. dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');
  133. }
  134. let roleRel = null;
  135. if (directAcc) {
  136. rptSignatureHelper.pushDomElementByUser(elementsStrArr, userAcc.name, userAcc.role);
  137. // 还有ROLE_REL_LIST
  138. let roleRelObj = {};
  139. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  140. roleRelObj.sign_path = dftSignSrc;
  141. // roleRelObj.sign_date = '';
  142. roleRelObj.sign_date = dftDate;
  143. roleRelObj.sign_date_format = 'yyyy年M月d日';
  144. roleRelObj.user_name = userAcc.name;
  145. roleRelObj.acc_id = userAcc.id;
  146. roleRelObj.type = '用户';
  147. roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)
  148. roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(directAcc.company);
  149. roleRelObj.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(roleRelObj,userAcc);
  150. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  151. ROLE_REL_LIST.push(roleRelObj);
  152. roleRel = roleRelObj;
  153. } else if (roleAcc) {
  154. // 创建相关dom元素
  155. rptSignatureHelper.pushDomElementByRole(elementsStrArr, roleAcc.name, userAcc.name);
  156. // 还有ROLE_REL_LIST
  157. let roleRelObj = {};
  158. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  159. roleRelObj.sign_path = dftSignSrc;
  160. // roleRelObj.sign_date = '';
  161. roleRelObj.sign_date = dftDate;
  162. roleRelObj.sign_date_format = 'yyyy年M月d日';
  163. roleRelObj.user_name = userAcc.name;
  164. roleRelObj.acc_id = userAcc.id;
  165. roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)
  166. roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  167. roleRelObj.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(roleRelObj,userAcc);
  168. roleRelObj.type = '角色';
  169. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  170. roleRelObj.role_name = roleAcc.name;
  171. ROLE_REL_LIST.push(roleRelObj);
  172. roleRel = roleRelObj;
  173. }
  174. // elementsStrArr.push('');
  175. rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, roleRel, 0);
  176. $(rptSignatureHelper.currentSelectedESignAccDom).append(elementsStrArr.join(' '));
  177. //.appendChild(pNode);
  178. //*/
  179. // 2.2 date-picker
  180. // 更新最近使用名单
  181. const params = {};
  182. params.uid = userAcc.id;
  183. params.prj_id = PROJECT_ID;
  184. params.tender_id = TENDER_ID;
  185. CommonAjax.postXsrfEx("/tender/report_api/updateSignatureUsed", params, 10000, true, getCookie('csrfToken_j'),
  186. function(result){
  187. console.log(result);
  188. USED_LIST = result.data;
  189. $('#search_account').val('');
  190. rptSignatureHelper.buildSelectableAccount();
  191. rptSignatureHelper.buildSelectableAccountUsed();
  192. }, function(err){
  193. // hintBox.unWaitBox();
  194. }, function(ex){
  195. // hintBox.unWaitBox();
  196. }
  197. );
  198. }
  199. },
  200. cleanOldSignature: function (signature_name) {
  201. // 清掉ROLE_REL_LIST原有的签名
  202. for (let idx = ROLE_REL_LIST.length - 1; idx >= 0 ; idx--) {
  203. if (ROLE_REL_LIST[idx].signature_name === signature_name) {
  204. ROLE_REL_LIST.splice(idx, 1);
  205. }
  206. }
  207. },
  208. resetESignature: function (pageRst, signatureDivId) {
  209. // let body = $('#eSignatureBodyDiv');
  210. if (pageRst !== null) {
  211. let body = $('#' + signatureDivId);
  212. rptSignatureHelper.currentSelectedESignParentDivId = signatureDivId;
  213. body.empty();
  214. const signature_cells = [];
  215. const singatureNameArr = [];
  216. for (const page of pageRst.items) {
  217. if (page.signature_cells) {
  218. for (const sCell of page.signature_cells) {
  219. if (sCell.signature_name !== null && sCell.signature_name !== undefined && sCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0) {
  220. if (singatureNameArr.indexOf(sCell.signature_name) < 0) {
  221. signature_cells.push(sCell);
  222. singatureNameArr.push(sCell.signature_name);
  223. }
  224. }
  225. }
  226. }
  227. }
  228. if (signature_cells.length > 0) {
  229. const elementsStrArr = [];
  230. const elementsDateStrArr = [];
  231. for (let scIdx = 0; scIdx < signature_cells.length; scIdx++) {
  232. const sCell = signature_cells[scIdx];
  233. elementsStrArr.push('<div class="form-group row">');
  234. elementsStrArr.push('<label for="staticEmail" class="col-sm-3 col-form-label pr-0">' + sCell.signature_name + '</label>');
  235. elementsStrArr.push('<div class="col-sm-9">');
  236. elementsStrArr.push('<ul class="list-group">');
  237. elementsStrArr.push('<li class="list-group-item">');
  238. let hasPic = false;
  239. //新需求中,即使没有审核,也可以设置签名
  240. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  241. const role_rel = ROLE_REL_LIST[idx];
  242. if (role_rel.signature_name === sCell.signature_name) {
  243. if (role_rel.type === '用户') {
  244. rptSignatureHelper.pushDomElementByUser(elementsStrArr, role_rel.user_name, role_rel.role);
  245. } else {
  246. //角色
  247. rptSignatureHelper.pushDomElementByRole(elementsStrArr, role_rel.role_name, role_rel.user_name);
  248. }
  249. const userAcc = rptSignatureHelper.getUserAccount(role_rel.acc_id);
  250. if (userAcc) {
  251. role_rel.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(role_rel,userAcc);
  252. role_rel.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  253. }
  254. rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, role_rel, idx);
  255. hasPic = true;
  256. break;
  257. }
  258. }
  259. if (!hasPic) {
  260. // 在交互操作中,有可能实际上是没有
  261. 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>');
  262. }
  263. // if (sCell.path || sCell.pic) {
  264. // } else {
  265. // 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>');
  266. // }
  267. elementsStrArr.push('</li>');
  268. elementsStrArr.push('</ul>');
  269. elementsStrArr.push('</div>');
  270. elementsStrArr.push('</div>');
  271. //还有签名日期(用不用得上不管,先放上去再说)
  272. }
  273. body.append(elementsStrArr.join(' '));
  274. }
  275. }
  276. },
  277. checkAndShowCrossTendersESignature: function (fujianOssPath) {
  278. rptSignatureHelper.fujianOssPath=fujianOssPath;
  279. let btnDom = $('#btn_cross_tender')[0];
  280. if (zTreeOprObj.currentNode) {
  281. if (btnDom) btnDom.style.display = '';
  282. } else {
  283. if (btnDom) btnDom.style.display = 'none';
  284. }
  285. },
  286. pushDomElementByUser: function (elementsStrArr, userName, userRole) {
  287. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span>' + userName +
  288. '-<small class="text-muted">' + ((userRole === '')?DFT_ROLE_NAME:userRole) +
  289. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  290. },
  291. pushDomElementByRole: function (elementsStrArr, roleName, userName) {
  292. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span><i class="fa fa-user" title="角色"> ' + roleName +
  293. '</i>-<small class="text-muted">' + userName +
  294. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  295. },
  296. pushDatePickerDom: function (elementsStrArr, userAcc, role_rel, seq = 0) {
  297. const dateIdSuffixStr = 'dtp_' + role_rel.signature_name + '_' + rptSignatureHelper.currentSelectedESignParentDivId;
  298. let milliSec = (new Date()).getMilliseconds();
  299. const idSuffixStr = `dtp_${seq}_${milliSec}_${rptSignatureHelper.currentSelectedESignParentDivId}`;
  300. elementsStrArr.push('<div class="mt-3">');
  301. elementsStrArr.push('<div class="row">');
  302. //-------------------------------------------------
  303. if (!Array.isArray(role_rel.sign_output)) {
  304. role_rel.sign_output = [NORMAL_SIGN_STR];
  305. }
  306. const normalSignChkStr = (role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) ? 'checked' : '';
  307. const companySignChkStr = (role_rel.sign_output.indexOf(COMPANY_SIGN_STR) >= 0) ? 'checked' : '';
  308. const privateSignChkStr = (role_rel.sign_output.indexOf(PRIVATE_SIGN_STR) >= 0) ? 'checked' : '';
  309. // 1. 签章类型:签字 单位章 个人章....
  310. elementsStrArr.push('<div class="col-8">');
  311. elementsStrArr.push(' <div class="form-control form-control-sm d-inline pt-2">');
  312. elementsStrArr.push(' <div class="form-check form-check-inline px-2">');
  313. 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}')" >`);
  314. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign1">签字</label>`);
  315. elementsStrArr.push(' </div>');
  316. const hasIndividualStamp = (userAcc && userAcc.stamp_path && userAcc.stamp_path !== ''); //用户账号的stamp_path是属于用户自己的私章,不是公司章
  317. // let chkType = hasIndividualStamp ? `radio` : 'checkbox';
  318. const chkType = 'checkbox';
  319. let rdoNameStr = `dtp_${role_rel.signature_name}_${rptSignatureHelper.currentSelectedESignParentDivId}`;
  320. // 个人章列表
  321. const stampPathList=userAcc.stamp_path?userAcc.stamp_path.split('!;!'):[];
  322. if (hasIndividualStamp) {
  323. elementsStrArr.push(' <div class="form-check form-check-inline mx-1">');
  324. elementsStrArr.push(' <div class="form-group">');
  325. elementsStrArr.push(' <div class="form-check form-check-inline px-1">');
  326. 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}>`);
  327. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign2">单位章</label>`);
  328. elementsStrArr.push(' </div>');
  329. elementsStrArr.push(' <div class="form-check form-check-inline">');
  330. 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}>`);
  331. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign3">个人章</label>`);
  332. if(stampPathList.length>1){
  333. 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>`);
  334. }
  335. elementsStrArr.push(' </div>');
  336. elementsStrArr.push(' </div>');
  337. elementsStrArr.push(' </div>');
  338. } else {
  339. elementsStrArr.push(' <div class="form-check form-check-inline px-2">');
  340. 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}>`);
  341. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign10">单位章</label>`);
  342. elementsStrArr.push(' </div>');
  343. }
  344. elementsStrArr.push(' </div>');
  345. elementsStrArr.push('</div>');
  346. // 2. 日期
  347. elementsStrArr.push('<div class="col-4">');
  348. let dftDate = '';
  349. if (role_rel.sign_date !== '' && role_rel.sign_date.length > 20) {
  350. dftDate = (new Date(role_rel.sign_date)).Format('yyyy-MM-dd');
  351. } else if (role_rel.sign_date instanceof Date){
  352. dftDate = role_rel.sign_date.Format('yyyy-MM-dd');
  353. } else {
  354. if (userAcc) dftDate = _getSignDateByAllScenarios(userAcc.id);
  355. if (dftDate !== '' && dftDate.length > 20) {
  356. dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');
  357. }
  358. }
  359. elementsStrArr.push('<div class="input-group input-group-sm margin-inputbox">');
  360. elementsStrArr.push(' <div class="input-group-prepend">');
  361. elementsStrArr.push(' <span class="input-group-text height-inputbox" id="inputGroup-sizing-sm"><i class="fa fa-calendar" title="添加签名日期"></i></span>');
  362. elementsStrArr.push(' </div>');
  363. if (dftDate !== '') {
  364. 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>`);
  365. } else {
  366. 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>`);
  367. }
  368. elementsStrArr.push('</div>');
  369. //-------------------------------------------------
  370. elementsStrArr.push('</div>');
  371. elementsStrArr.push('</div>');
  372. },
  373. removeSignature: function (dom) {
  374. let accTxtName = $(dom.parentNode.parentNode.parentNode.parentNode.parentNode).find('label')[0].innerText;
  375. let jDom = $(dom.parentNode.parentNode);
  376. jDom.empty();
  377. jDom.append('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.currentSelectedESignAccName = \'' +
  378. accTxtName + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签字</a>');
  379. // 要记得清空相关pre_path属性
  380. for (const page of zTreeOprObj.currentRptPageRst.items) {
  381. if (page.signature_cells) {
  382. for (const sCell of page.signature_cells) {
  383. if (sCell.signature_name === accTxtName) {
  384. sCell.pre_path = '';
  385. }
  386. }
  387. }
  388. }
  389. // 还有ROLE_REL_LIST
  390. rptSignatureHelper.cleanOldSignature(accTxtName);
  391. },
  392. removeSelectSignature: function () {
  393. for (const page of zTreeOprObj.currentRptPageRst.items) {
  394. if (page.signature_cells) {
  395. for (const sCell of page.signature_cells) {
  396. if (sCell.hasOwnProperty('pre_path')) {
  397. delete sCell.pre_path;
  398. }
  399. }
  400. }
  401. }
  402. // ROLE_REL_LIST = [];
  403. // ROLE_REL_LIST = ROLE_REL_LIST.concat(rptSignatureHelper.originalRoleRelList);
  404. ROLE_REL_LIST = JSON.parse(JSON.stringify(rptSignatureHelper.originalRoleRelList));
  405. if (PAGE_SHOW.isTextSignature) {
  406. resetTextSignature(zTreeOprObj.currentRptPageRst);
  407. }
  408. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  409. },
  410. resetSignAudit: function () {
  411. rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT);
  412. },
  413. resetSignDate: function(signatureDivId) {
  414. for (const page of zTreeOprObj.currentRptPageRst.items) {
  415. if (page.signature_date_cells) {
  416. for (const sCell of page.signature_date_cells) {
  417. sCell.Value = _getSignDateDftName();
  418. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  419. const role_rel = ROLE_REL_LIST[idx];
  420. const idSuffixStr = 'dtp_' + role_rel.signature_name + '_' + signatureDivId;
  421. let dtDom = $('#' + idSuffixStr);
  422. if (dtDom.length === 1) {
  423. const dtStr = dtDom[0].value;
  424. if (dtStr && dtStr !== '' && dtStr.length >= 8 && dtStr.length <= 10) {
  425. role_rel.sign_date = new Date(dtStr);
  426. } else {
  427. role_rel.sign_date = '';
  428. }
  429. // 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)
  430. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  431. if (role_rel.sign_date !== '') {
  432. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  433. }
  434. }
  435. }
  436. }
  437. }
  438. }
  439. }
  440. },
  441. setupAfterSelectMultiTenders: function (selectedTenders, signatureDivId) {
  442. //跨标段选择,有不少要注意的交互:
  443. //0. 签名日期
  444. rptSignatureHelper.resetSignDate(signatureDivId);
  445. rptSignatureHelper.resetSignAudit();
  446. //1. 重刷page
  447. if (current_stage_status === 3) {
  448. for (const page of zTreeOprObj.currentRptPageRst.items) {
  449. if (page.signature_cells) {
  450. for (const sCell of page.signature_cells) {
  451. if (sCell.hasOwnProperty('pre_path')) {
  452. sCell.path = sCell.pre_path;
  453. delete sCell.pre_path;
  454. }
  455. }
  456. }
  457. }
  458. if (PAGE_SHOW.isTextSignature) {
  459. resetTextSignature(zTreeOprObj.currentRptPageRst);
  460. }
  461. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  462. }
  463. //2. 集中请求
  464. let params = {};
  465. params.id = CURRENT_ROLE_REL_ID;
  466. params.tender_id = TENDER_ID;
  467. params.stage_id = getStageId();
  468. params.rpt_id = zTreeOprObj.currentNode.refId;
  469. params.rel_content = ROLE_REL_LIST;
  470. params.selectedTenders = selectedTenders;
  471. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  472. $.bootstrapLoading.start();
  473. CommonAjax.postXsrfEx("/tender/report_api/updateMultiRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  474. function(result){
  475. // console.log(result);
  476. $.bootstrapLoading.end();
  477. if (result.data && result.data.insertId > 0) {
  478. CURRENT_ROLE_REL_ID = result.data.insertId;
  479. }
  480. }, function(err){
  481. // hintBox.unWaitBox();
  482. $.bootstrapLoading.end();
  483. }, function(ex){
  484. // hintBox.unWaitBox();
  485. $.bootstrapLoading.end();
  486. }
  487. );
  488. },
  489. _parseRoleRelList: function(org_rel_content) {
  490. const rst = JSON.parse(org_rel_content);
  491. for (const role_rel of rst) {
  492. if (role_rel.sign_date !== null && role_rel.sign_date !== undefined && role_rel.sign_date.length >= 8) {
  493. role_rel.sign_date = new Date(role_rel.sign_date);
  494. }
  495. }
  496. return rst;
  497. },
  498. setupAfterSelectSignature: async function (signatureDivId) {
  499. //0. 签名日期
  500. let me = rptSignatureHelper;
  501. rptSignatureHelper.resetSignDate(signatureDivId);
  502. rptSignatureHelper.resetSignAudit();
  503. if (current_stage_status === 3) {
  504. //1. 重刷page
  505. // let hasStamp = false;
  506. for (const page of zTreeOprObj.currentRptPageRst.items) {
  507. if (page.signature_cells) {
  508. for (let cIdx = page.signature_cells.length - 1; cIdx >= 0; cIdx--) {
  509. const sCell = page.signature_cells[cIdx];
  510. if (sCell.isStamp) {
  511. page.signature_cells.splice(cIdx);
  512. // hasStamp = true;
  513. } else if (sCell.hasOwnProperty('pre_path')) {
  514. sCell.path = sCell.pre_path;
  515. delete sCell.pre_path;
  516. }
  517. for (let role of ROLE_REL_LIST) {
  518. }
  519. }
  520. }
  521. }
  522. resetStampSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST);
  523. if (PAGE_SHOW.isTextSignature) {
  524. resetTextSignature(zTreeOprObj.currentRptPageRst);
  525. }
  526. // zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  527. }
  528. //2. 更新数据
  529. const params = {};
  530. params.id = CURRENT_ROLE_REL_ID;
  531. params.tender_id = TENDER_ID;
  532. params.stage_id = getStageId();
  533. params.rpt_id = zTreeOprObj.currentNode.refId;
  534. params.rel_content = ROLE_REL_LIST;
  535. // rptSignatureHelper.originalRoleRelList = [];
  536. // rptSignatureHelper.originalRoleRelList = rptSignatureHelper.originalRoleRelList.concat(ROLE_REL_LIST);
  537. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  538. $.bootstrapLoading.start();
  539. CommonAjax.postXsrfEx("/tender/report_api/updateRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  540. async function(result){
  541. // console.log(result);
  542. $.bootstrapLoading.end();
  543. if (result.data && result.data.insertId > 0) {
  544. CURRENT_ROLE_REL_ID = result.data.insertId;
  545. }
  546. // ROLE_REL_LIST = [];
  547. // for (const signatureRel of result.signatureRelInfo) {
  548. // ROLE_REL_LIST.push(JSON.parse(signatureRel.rel_content));
  549. // }
  550. // rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  551. // ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  552. // rptSignatureHelper.originalRoleRelList = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  553. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  554. // CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  555. ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  556. rptSignatureHelper.originalRoleRelList = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  557. if (current_stage_status === 3) {
  558. rptSignatureHelper.mergeSignDate(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true);
  559. rptSignatureHelper.mergeSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true);
  560. await rptSignatureHelper.resetDummySignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST); // 这里重新整理签章坐标信息(因签章大小在后台暂时获取不到,挪到前端处理)
  561. rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT);
  562. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  563. }
  564. } else {
  565. // CURRENT_ROLE_REL_ID = -1;
  566. ROLE_REL_LIST = [];
  567. }
  568. }, function(err){
  569. // hintBox.unWaitBox();
  570. $.bootstrapLoading.end();
  571. }, function(ex){
  572. // hintBox.unWaitBox();
  573. $.bootstrapLoading.end();
  574. }
  575. );
  576. },
  577. switchAddRoleDiv: function (dom) {
  578. if (dom.nextElementSibling.children[0].style.display === 'none') {
  579. dom.nextElementSibling.children[0].style.display = '';
  580. } else {
  581. dom.nextElementSibling.children[0].style.display = 'none';
  582. }
  583. },
  584. createNewRole: function (dom) {
  585. if ($('#acc_role_name')[0].value !== '') {
  586. const params = {};
  587. params.name = $('#acc_role_name')[0].value;
  588. const selectedAcc = PRJ_ACCOUNT_LIST[$('#project_account_select_dom')[0].selectedOptions[0].value];
  589. const roleName = (selectedAcc.role === '')?DFT_ROLE_NAME:selectedAcc.role;
  590. params.bind_acc_id = selectedAcc.id;
  591. params.prj_id = PROJECT_ID;
  592. params.tender_id = TENDER_ID;
  593. CommonAjax.postXsrfEx("/tender/report_api/createSignatureRole", params, 10000, true, getCookie('csrfToken_j'),
  594. function(result){
  595. console.log(result);
  596. const newRole = {};
  597. newRole.name = params.name;
  598. newRole.bind_acc_id = selectedAcc.id;
  599. newRole.prj_id = PROJECT_ID;
  600. newRole.tender_id = TENDER_ID;
  601. ROLE_LIST.push(newRole);
  602. const domArr = [];
  603. domArr.push('<li class="add-sign-list-item">');
  604. //1. apply签名
  605. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + (ROLE_LIST.length - 1) +')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  606. domArr.push('<i class="fa fa-plus"></i>');
  607. domArr.push('</a>');
  608. //2. 编辑角色(暂缓处理click事件)
  609. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  610. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  611. domArr.push('</a>');
  612. //3. 显示名称
  613. domArr.push('<i class="fa fa-user"></i> ' + $('#acc_role_name')[0].value + '<p>' + selectedAcc.name + '-<small class="text-muted">' + roleName + '</small></p>');
  614. $('#existed_roles_ul').append(domArr.join(' '));
  615. }, function(err){
  616. // hintBox.unWaitBox();
  617. }, function(ex){
  618. // hintBox.unWaitBox();
  619. }
  620. );
  621. } else {
  622. alert('请输入合适的名称!');
  623. }
  624. },
  625. buildRoleDom: function (roleList) {
  626. const ulDom = $('#existed_roles_ul');
  627. ulDom.empty();
  628. for (let domIdx = 0; domIdx < roleList.length; domIdx++) {
  629. const role = roleList[domIdx];
  630. const domArr = [];
  631. domArr.push('<li class="add-sign-list-item">');
  632. //1. apply签名
  633. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + domIdx + ')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  634. domArr.push('<i class="fa fa-plus"></i>');
  635. domArr.push('</a>');
  636. //2. 编辑角色(暂缓)
  637. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  638. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  639. domArr.push('</a>');
  640. //3. 显示名称
  641. let acc = rptSignatureHelper.getUserAccount(role.bind_acc_id);
  642. 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>');
  643. ulDom.append(domArr.join(' '));
  644. }
  645. },
  646. getUserAccount: function (accId) {
  647. let rst = null;
  648. for (const acc of PRJ_ACCOUNT_LIST) {
  649. if (acc.id === accId) {
  650. rst = acc;
  651. break;
  652. }
  653. }
  654. return rst;
  655. },
  656. _getCompanySign: function(companyName) {
  657. let rst = '';
  658. for (const cUnit of CONSTRUCT_UNIT_LIST) {
  659. if (cUnit.name === companyName) {
  660. rst = cUnit.sign_path;
  661. break;
  662. }
  663. }
  664. return rst;
  665. },
  666. mergeSignature: function (pageData, currRoleRelList, setPic = false) {
  667. for (const page of pageData.items) {
  668. if (page.signature_cells) {
  669. const adHocScells = [];
  670. for (const sCell of page.signature_cells) {
  671. if (sCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0) {
  672. sCell.path = null;
  673. sCell.pre_path = null;
  674. sCell.pic = null;
  675. }
  676. for (const role_rel of currRoleRelList) {
  677. if (role_rel.signature_name === sCell.signature_name) {
  678. // 处理签章
  679. if (!Array.isArray(role_rel.sign_output)) {
  680. role_rel.sign_output = [];
  681. role_rel.sign_output.push(NORMAL_SIGN_STR);
  682. }
  683. for (const signType of role_rel.sign_output) {
  684. switch (signType) {
  685. case NORMAL_SIGN_STR:
  686. sCell.path = role_rel.sign_path;
  687. sCell.pre_path = role_rel.sign_path;
  688. if (setPic) {
  689. sCell.pic = role_rel.sign_pic; // 有些场景(如:批量归档)需要直接设置签名数据
  690. }
  691. break;
  692. case COMPANY_SIGN_STR:
  693. case PRIVATE_SIGN_STR:
  694. /*
  695. const stampPath = (signType === COMPANY_SIGN_STR) ? role_rel.company_stamp_path : role_rel.private_stamp_path;
  696. // 生成一个新的dummy cell(类似草图)
  697. const newStampCell = _createDummyCell();
  698. newStampCell.signature_name = JV.SIGNATURE_NAME_DUMMY;
  699. newStampCell.path = OSS_PATH + stampPath;
  700. newStampCell.control = sCell.control;
  701. newStampCell.style = sCell.style;
  702. newStampCell.isStamp = true; // 这个标记纯属为了刷新用,其他sign cell是没有的
  703. // 设置坐标
  704. rptSignatureHelper._resetStampPos(sCell, newStampCell, pageData[JV.NODE_CONTROL_COLLECTION]);
  705. // 加到cells去
  706. adHocScells.push(newStampCell);
  707. //*/
  708. break;
  709. default:
  710. break;
  711. }
  712. }
  713. break;
  714. }
  715. }
  716. }
  717. page.signature_cells = page.signature_cells.concat(adHocScells);
  718. }
  719. }
  720. },
  721. resetDummySignature: async function(pageData, roleRel, ifPushRoleRel = false) {
  722. // 备注:计算草图等其他图形需要额外做些处理
  723. let dummySignIdx = 0;
  724. const stampPicKeys = [], stampPicFeatures = [];
  725. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  726. const page = pageData.items[pageIdx];
  727. if (page[JV.PROP_SIGNATURE_CELLS] && page[JV.PROP_SIGNATURE_CELLS].length > 0) {
  728. for (const signatureCell of page[JV.PROP_SIGNATURE_CELLS]) {
  729. if (signatureCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
  730. // 表示这是一个其他类型的非原生电子签名图,只是借用signature的处理机制,每个图都是唯一的,所以需要重新给个唯一的新signature_name
  731. // signatureCell.signature_name = signatureCell.signature_name + '_' + pageIdx + '_' + dummySignIdx;
  732. signatureCell.signature_name = signatureCell.signature_name + '_' + page.page_seq + '_' + dummySignIdx; // page_seq在分页后都不会变动
  733. dummySignIdx++;
  734. const roleRelItem = { type: '用户', sign_path: signatureCell.path, signature_name: signatureCell.signature_name };
  735. if (signatureCell.isStamp) {
  736. let stmpIdx = stampPicKeys.indexOf(signatureCell.path);
  737. if (stampPicKeys.indexOf(signatureCell.path) < 0) {
  738. stampPicKeys.push(signatureCell.path);
  739. stmpIdx = stampPicKeys.length - 1;
  740. const picRes = await getHttpBlobText(signatureCell.path + '?x-oss-process=image/info');
  741. stampPicFeatures.push(picRes);
  742. }
  743. // { "FileSize": {"value": "2514"}, "Format": {"value": "png"}, "ImageHeight": {"value": "94"}, "ImageWidth": {"value": "94"} }
  744. roleRelItem.stampFeature = stampPicFeatures[stmpIdx];
  745. // 重新处理cell坐标
  746. _resetStampArea(pageData[JV.NODE_CONTROL_COLLECTION][signatureCell[JV.PROP_CONTROL]], signatureCell, roleRelItem);
  747. }
  748. if (ifPushRoleRel) roleRel.push(roleRelItem);
  749. }
  750. }
  751. }
  752. }
  753. },
  754. mergeSignAudit: function (pageData, currRoleRelList, currAuditList) {
  755. for (const page of pageData.items) {
  756. if (page.signature_audit_cells) {
  757. for (const sCell of page.signature_audit_cells) {
  758. sCell.Value = ''; // 这里要先清除原有信息
  759. for (const role_rel of currRoleRelList) {
  760. if (sCell.signature_name === role_rel.signature_name + '_审核意见') {
  761. let preDate = '';
  762. sCell.Value = '同意'; // 只有选择了签名的,才需要初始化一个默认的意见(之前的逻辑在有多个签名,哪怕只选择了一个,其他的意见都会有默认意见)
  763. for (const audit_rel of currAuditList) {
  764. if (role_rel.acc_id === audit_rel.aid) {
  765. if (audit_rel.end_time > preDate && audit_rel.status === 3) {
  766. sCell.Value = audit_rel.opinion;
  767. preDate = audit_rel.end_time;
  768. }
  769. //不能break,实际会有多个审核意见,以最后一个为准
  770. }
  771. }
  772. break;
  773. }
  774. }
  775. }
  776. }
  777. }
  778. },
  779. mergeSignDate: function (pageData, currRoleRelList, isMergeOrgAlso) {
  780. if (currRoleRelList && currRoleRelList.length > 0 && STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  781. for (let rridx = 0; rridx < currRoleRelList.length; rridx++) {
  782. const role_rel = currRoleRelList[rridx];
  783. if (role_rel.sign_date === undefined || role_rel.sign_date === null || role_rel.sign_date === '') {
  784. //*
  785. let dftDate = _getSignDateByAllScenarios(role_rel.acc_id);
  786. role_rel.sign_date = dftDate;
  787. if (isMergeOrgAlso) {
  788. rptSignatureHelper.originalRoleRelList[rridx].sign_date = dftDate;
  789. //备注:在多选导出的情况下,originalRoleRelList不需要merge
  790. }
  791. /*/
  792. let hasAudit = false;
  793. for (const stg_audit of STAGE_AUDIT) {
  794. if (role_rel.acc_id === stg_audit.aid) {
  795. hasAudit = true;
  796. if (stg_audit.status === 3) {
  797. role_rel.sign_date = stg_audit.end_time;
  798. rptSignatureHelper.originalRoleRelList[rridx].sign_date = stg_audit.end_time;
  799. } else {
  800. role_rel.sign_date = '';
  801. rptSignatureHelper.originalRoleRelList[rridx].sign_date = '';
  802. }
  803. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  804. }
  805. }
  806. let isOrgRpt = false;
  807. for (const stg of STAGE_LIST) {
  808. if (stg.id === current_stage_id) {
  809. if (stg.user_id === role_rel.acc_id) {
  810. isOrgRpt = true;
  811. }
  812. break;
  813. }
  814. }
  815. if (isOrgRpt && !hasAudit && STAGE_AUDIT_ORG && STAGE_AUDIT_ORG.length > 0) {
  816. if (STAGE_AUDIT_ORG[0].begin_time && STAGE_AUDIT_ORG[0].begin_time !== '' && STAGE_AUDIT_ORG[0].begin_time.length > 20) {
  817. role_rel.sign_date = STAGE_AUDIT_ORG[0].begin_time;
  818. rptSignatureHelper.originalRoleRelList[rridx].sign_date = STAGE_AUDIT_ORG[0].begin_time;
  819. }
  820. }
  821. if (!isOrgRpt && !hasAudit) {
  822. //非审批流程人员以及非原报,则显示期截至时间
  823. for (const stg of STAGE_LIST) {
  824. if (stg.id === current_stage_id && stg.period) {
  825. const period = stg.period.split(' ~ ');
  826. if (period.length === 2) {
  827. role_rel.sign_date = period[1];
  828. rptSignatureHelper.originalRoleRelList[rridx].sign_date = period[1];
  829. }
  830. }
  831. }
  832. }
  833. //*/
  834. }
  835. }
  836. }
  837. for (const page of pageData.items) {
  838. if (page.signature_date_cells) {
  839. for (const sCell of page.signature_date_cells) {
  840. if (sCell.Value === undefined || sCell.Value === null && sCell.Value === '') {
  841. sCell.Value = _getSignDateDftName();
  842. }
  843. for (const role_rel of currRoleRelList) {
  844. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  845. if (role_rel.sign_date !== '') {
  846. if (typeof role_rel.sign_date === 'string') {
  847. role_rel.sign_date = new Date(role_rel.sign_date);
  848. }
  849. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  850. }
  851. break;
  852. }
  853. }
  854. }
  855. }
  856. }
  857. },
  858. _changeSignType: function(dom, signature_name, chkStr, userStamp) {
  859. for (const roleRel of ROLE_REL_LIST) {
  860. if (roleRel.signature_name === signature_name) {
  861. if (dom.checked) {
  862. if (roleRel.sign_output.indexOf(chkStr) < 0) {
  863. roleRel.sign_output.push(chkStr);
  864. }
  865. if(chkStr==='private_stamp'&&!roleRel.private_stamp_path && userStamp){
  866. roleRel.private_stamp_path = userStamp.split('!;!')[0] ;
  867. console.log(roleRel.private_stamp_path);
  868. }
  869. } else {
  870. let idx = roleRel.sign_output.indexOf(chkStr);
  871. if (idx >= 0) {
  872. roleRel.sign_output.splice(idx, 1);
  873. }
  874. }
  875. break;
  876. }
  877. }
  878. },
  879. _resetStampPos: function(orgCell, targetCell, controls) {
  880. const ctrl = controls[orgCell.control];
  881. let pLeft = orgCell.area.Left, pTop = orgCell.area.Top;
  882. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
  883. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
  884. pLeft = orgCell.area.Left;
  885. break;
  886. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
  887. pLeft = (orgCell.area.Left + orgCell.area.Right - STD_STAMP_SIZE_WIDTH) / 2 ;
  888. break;
  889. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
  890. pLeft = orgCell.area.Right - STD_STAMP_SIZE_WIDTH;
  891. break;
  892. }
  893. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
  894. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_TOP]:
  895. pTop = orgCell.area.Top;
  896. break;
  897. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_CENTER]:
  898. pTop = (orgCell.area.Top + orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT) / 2 ;
  899. break;
  900. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_BOTTOM]:
  901. pTop = orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT;
  902. break;
  903. }
  904. targetCell.area.Left = pLeft;
  905. targetCell.area.Top = pTop;
  906. targetCell.area.Right = pLeft + STD_STAMP_SIZE_WIDTH;
  907. targetCell.area.Bottom = pTop + STD_STAMP_SIZE_HEIGHT;
  908. },
  909. initChosePrivateStampPath:function(stampPathList,signature_name){
  910. let currentStamp='';
  911. const targetNode= ROLE_REL_LIST.find(item=>item.signature_name===signature_name);
  912. if(targetNode) currentStamp=targetNode.private_stamp_path
  913. let content=`<div class='row justify-content-md-center'>`;
  914. stampPathList.split('!;!').forEach(item=>{
  915. content+=`<div class="card col-3 p-2 m-3 d-flex ${currentStamp===item?'card-gk-active':''} stamp-img">
  916. <div class="p-0 private-stamp-img">
  917. <div class="sel-width check-state ${currentStamp===item?'sel-blue':''} "></div>
  918. <img src="${rptSignatureHelper.fujianOssPath}${item}" data-src='${item}' class="img-fluid" alt="...">
  919. </div>
  920. </div>`;
  921. })
  922. for(let i=0;i<stampPathList.length%3;i++){
  923. content+=`<div class="col-3 p-2 m-3"></div>`;
  924. }
  925. content+=` </div><div class='privateStampRoleName' data-name='${signature_name}'></div>`;
  926. $('#chose-private-stamp-path .modal-body').empty().append(content);
  927. $('.stamp-img').on('click',(e)=>{
  928. $('.stamp-img').removeClass('card-gk-active');
  929. $('.stamp-img').find('.sel-width').removeClass('sel-blue');
  930. $(e.currentTarget).addClass('card-gk-active');
  931. $(e.currentTarget).find('.sel-width').addClass('sel-blue');
  932. })
  933. },
  934. setPrivateStamp(e){
  935. const imgSrc= $('.stamp-img.card-gk-active').find('.img-fluid').data('src');
  936. const privateStampRoleName=$('.privateStampRoleName').data('name');
  937. const targetNode= ROLE_REL_LIST.find(item=>item.signature_name==privateStampRoleName);
  938. targetNode.private_stamp_path=imgSrc;
  939. $('#chose-private-stamp-path').modal('hide');
  940. },
  941. _get_newPrivate_stamp_path(roleRelObj,userAcc){
  942. if(!roleRelObj.private_stamp_path){
  943. if(!userAcc.stamp_path) return '';
  944. if(userAcc.stamp_path.split('!;!').length===1){
  945. return userAcc.stamp_path;
  946. }else{
  947. return userAcc.stamp_path.split('!;!')[0];
  948. }
  949. }
  950. return roleRelObj.private_stamp_path;
  951. }
  952. }
  953. function _getSignDateByAllScenarios(userAccId) {
  954. let rst = '';
  955. let hasAudit = false;
  956. for (const stg_audit of STAGE_AUDIT) {
  957. if (stg_audit.aid === userAccId) {
  958. hasAudit = true;
  959. if (stg_audit.status === 3) {
  960. rst = stg_audit.end_time;
  961. } else {
  962. rst = '';
  963. }
  964. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  965. }
  966. }
  967. let isOrgRpt = false;
  968. for (const stg of STAGE_LIST) {
  969. if (stg.id === current_stage_id) {
  970. if (stg.user_id === userAccId) {
  971. isOrgRpt = true;
  972. }
  973. break;
  974. }
  975. }
  976. if (isOrgRpt && !hasAudit && STAGE_AUDIT_ORG && STAGE_AUDIT_ORG.length > 0) {
  977. if (STAGE_AUDIT_ORG[0].begin_time && STAGE_AUDIT_ORG[0].begin_time !== '' && STAGE_AUDIT_ORG[0].begin_time.length > 20) {
  978. rst = STAGE_AUDIT_ORG[0].begin_time;
  979. }
  980. }
  981. if (!isOrgRpt && !hasAudit) {
  982. //非审批流程人员以及非原报,则显示期截至时间
  983. for (const stg of STAGE_LIST) {
  984. if (stg.id === current_stage_id && stg.period) {
  985. const period = stg.period.split(' ~ ');
  986. if (period.length === 2) {
  987. rst = period[1];
  988. }
  989. }
  990. }
  991. }
  992. return rst;
  993. }
  994. function _getSignDateDftName() {
  995. return ' 年 月 日';
  996. }
  997. function _createDummyCell() {
  998. const rst = {
  999. font: 'Footer',
  1000. control: 'Footer',
  1001. style: 'Default_None',
  1002. Value: '',
  1003. area: { Left: 0, Right: 0, Top: 0, Bottom: 0 },
  1004. };
  1005. return rst;
  1006. }
  1007. function resetStampSignature(pageData, roleRelList) {
  1008. const dupPicPaths = [];
  1009. const _getMaxRect = function(page) {
  1010. const rect = [100000000, 100000000, 0, 0];
  1011. for (const cell of page.cells) {
  1012. if (rect[0] > cell.area.Left) {
  1013. rect[0] = cell.area.Left;
  1014. }
  1015. if (rect[1] > cell.area.Top) {
  1016. rect[1] = cell.area.Top;
  1017. }
  1018. if (rect[2] < cell.area.Right) {
  1019. rect[2] = cell.area.Right;
  1020. }
  1021. if (rect[3] < cell.area.Bottom) {
  1022. rect[3] = cell.area.Bottom;
  1023. }
  1024. }
  1025. return rect;
  1026. };
  1027. for (const page of pageData.items) {
  1028. const maxRect = _getMaxRect(page);
  1029. if (page.signature_cells) {
  1030. const newStampCells = [];
  1031. for (let scIdx = 0; scIdx < page.signature_cells.length; scIdx++) {
  1032. const sCell = page.signature_cells[scIdx];
  1033. for (const role_rel of roleRelList) {
  1034. if (sCell.signature_name === role_rel.signature_name) {
  1035. if (Array.isArray(role_rel.sign_output) && role_rel.sign_output.length > 0) {
  1036. for (const signType of role_rel.sign_output) {
  1037. switch (signType) {
  1038. case COMPANY_SIGN_STR:
  1039. case PRIVATE_SIGN_STR:
  1040. // 创建一个新的cell
  1041. let stampPath = (signType === COMPANY_SIGN_STR) ? role_rel.company_stamp_path : role_rel.private_stamp_path;
  1042. stampPath = OSS_PATH + stampPath;
  1043. if (dupPicPaths.indexOf(stampPath) < 0) {
  1044. dupPicPaths.push(stampPath);
  1045. }
  1046. const newStampCell = {
  1047. signature_name: JV.SIGNATURE_NAME_DUMMY,
  1048. control: sCell.control,
  1049. style: sCell.style,
  1050. path: stampPath,
  1051. isStamp: true,
  1052. maxRect,
  1053. orgArea: sCell.area,
  1054. area: {Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom},
  1055. };
  1056. newStampCells.push(newStampCell);
  1057. break;
  1058. default: break;
  1059. }
  1060. }
  1061. }
  1062. }
  1063. }
  1064. }
  1065. if (newStampCells.length > 0) {
  1066. page.signature_cells = page.signature_cells.concat(newStampCells);
  1067. }
  1068. }
  1069. }
  1070. }
  1071. function resetTextSignature(pageData) {
  1072. for (const page of pageData.items) {
  1073. for (let sCell of page.signature_cells) {
  1074. if (!sCell.isStamp) {
  1075. let fitCell = null;
  1076. for (let idx = page.cells.length - 1; idx >= 0; idx--) {
  1077. const cell = page.cells[idx];
  1078. 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) {
  1079. fitCell = cell;
  1080. break;
  1081. }
  1082. }
  1083. if (fitCell) {
  1084. fitCell.Value = '';
  1085. for (let role of ROLE_REL_LIST) {
  1086. if (sCell.signature_name === role.signature_name) {
  1087. if (role.sign_output && role.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {
  1088. fitCell.Value = role.user_name;
  1089. } else {
  1090. fitCell.Value = '';
  1091. }
  1092. break;
  1093. }
  1094. }
  1095. } else {
  1096. // 要创建新的文本签名cell
  1097. for (let role of ROLE_REL_LIST) {
  1098. if (sCell.signature_name === role.signature_name && role.sign_output && role.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {
  1099. const newCell = {
  1100. font: 'Footer',
  1101. control: sCell.control,
  1102. style: sCell.style,
  1103. Value: role.user_name,
  1104. area: { Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom },
  1105. };
  1106. page.cells.push(newCell);
  1107. break;
  1108. }
  1109. }
  1110. }
  1111. }
  1112. }
  1113. }
  1114. }
  1115. function _resetStampArea(ctrl, stampCell, roleRelItem) {
  1116. let pLeft = stampCell.orgArea.Left,
  1117. pTop = stampCell.orgArea.Top;
  1118. if (roleRelItem.stampFeature !== 'not found!') {
  1119. let std_stamp_size_width = STD_STAMP_SIZE_WIDTH, std_stamp_size_height = STD_STAMP_SIZE_HEIGHT;
  1120. let widthRate = 1, heightRate = 1;
  1121. if (roleRelItem.stampFeature) {
  1122. std_stamp_size_width = parseFloat(roleRelItem.stampFeature.ImageWidth.value);
  1123. std_stamp_size_height = parseFloat(roleRelItem.stampFeature.ImageHeight.value);
  1124. if (roleRelItem.stampFeature.ImageWidth.value !== roleRelItem.stampFeature.ImageHeight.value) {
  1125. //设置比例
  1126. if (std_stamp_size_width > std_stamp_size_height) {
  1127. heightRate = std_stamp_size_height / std_stamp_size_width;
  1128. } else {
  1129. widthRate = std_stamp_size_width / std_stamp_size_height;
  1130. }
  1131. }
  1132. if (std_stamp_size_width > STD_STAMP_SIZE_WIDTH || std_stamp_size_height > STD_STAMP_SIZE_HEIGHT) {
  1133. if (widthRate === 1) {
  1134. std_stamp_size_width = Math.min(std_stamp_size_width, STD_STAMP_SIZE_WIDTH);
  1135. std_stamp_size_height = std_stamp_size_width * heightRate;
  1136. } else {
  1137. std_stamp_size_height = Math.min(std_stamp_size_height, STD_STAMP_SIZE_HEIGHT);
  1138. std_stamp_size_width = std_stamp_size_height * widthRate;
  1139. }
  1140. }
  1141. }
  1142. switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
  1143. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
  1144. pLeft = stampCell.orgArea.Left;
  1145. break;
  1146. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
  1147. pLeft = (stampCell.orgArea.Left + stampCell.orgArea.Right - std_stamp_size_width) / 2;
  1148. break;
  1149. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
  1150. pLeft = stampCell.orgArea.Right - std_stamp_size_width;
  1151. break;
  1152. default:break;
  1153. }
  1154. switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
  1155. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_TOP]:
  1156. pTop = stampCell.orgArea.Top;
  1157. break;
  1158. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_CENTER]:
  1159. pTop = (stampCell.orgArea.Top + stampCell.orgArea.Bottom - std_stamp_size_height) / 2;
  1160. break;
  1161. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_BOTTOM]:
  1162. pTop = stampCell.orgArea.Bottom - std_stamp_size_height;
  1163. break;
  1164. default:break;
  1165. }
  1166. stampCell.area.Left = pLeft;
  1167. stampCell.area.Top = pTop;
  1168. stampCell.area.Right = pLeft + std_stamp_size_width;
  1169. stampCell.area.Bottom = pTop + std_stamp_size_height;
  1170. // 最后一步,如超过报表范围,则要调整坐标
  1171. const maxRect = stampCell.maxRect;
  1172. if (stampCell.area.Left < maxRect[0]) {
  1173. const width = maxRect[0] - stampCell.area.Left;
  1174. stampCell.area.Left += width;
  1175. stampCell.area.Right += width;
  1176. }
  1177. if (stampCell.area.Top < maxRect[1]) {
  1178. const height = maxRect[1] - stampCell.area.Top;
  1179. stampCell.area.Top += height;
  1180. stampCell.area.Bottom += height;
  1181. }
  1182. if (stampCell.area.Right > maxRect[2]) {
  1183. const width = maxRect[2] - stampCell.area.Right; // 负
  1184. stampCell.area.Left += width;
  1185. stampCell.area.Right += width;
  1186. }
  1187. if (stampCell.area.Bottom > maxRect[3]) {
  1188. const height = maxRect[3] - stampCell.area.Bottom;
  1189. stampCell.area.Top += height;
  1190. stampCell.area.Bottom += height;
  1191. }
  1192. }
  1193. }
  1194. function getHttpBlobText(url) {
  1195. return new Promise(resolve => {
  1196. const xhr = new XMLHttpRequest();
  1197. // let fullUrl = url + '?x-oss-process=image/info';
  1198. xhr.open('GET', url, true);
  1199. xhr.responseType = 'json';
  1200. xhr.onload = () => {
  1201. if (xhr.status === 200) {
  1202. resolve(xhr.response);
  1203. } else {
  1204. resolve('not found!');
  1205. }
  1206. };
  1207. xhr.send();
  1208. });
  1209. }