rpt_signature.js 60 KB

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