rpt_signature.js 65 KB

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