rpt_signature.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  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 = 4.2 * 96 / 2.54; // 公章大小:宽度(4.2CM)
  10. const STD_STAMP_SIZE_HEIGHT = 4.2 * 96 / 2.54; // 公章大小:高度(4.2CM)
  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_sel_option_accounts[keyIdx].push('<option value="' + accIdx + '">' + prjAccount.name + '-' + roleKey + '</option>');
  56. }
  57. }
  58. for (const prjAccList of prj_accounts) {
  59. prjAccList.push('</ul>');
  60. }
  61. for (const prjAccList of prj_sel_option_accounts) {
  62. prjAccList.push('</optgroup>');
  63. }
  64. for (let idx = 0; idx < prj_accounts.length; idx++) {
  65. prj_accounts[idx] = prj_accounts[idx].join('');
  66. prj_sel_option_accounts[idx] = prj_sel_option_accounts[idx].join('');
  67. }
  68. accDiv.append(prj_accounts.join(''));
  69. accSelect.append(prj_sel_option_accounts.join(''));
  70. },
  71. buildSelectableAccountUsed: function () {
  72. //PRJ_ACCOUNT_LIST
  73. //1. 清理所有选择项
  74. // $("#project_account_select_div").empty();
  75. let accDiv = $('#account_used_select_div');
  76. accDiv.empty();
  77. //2. 一个个加可选用户项
  78. const prj_accounts = [];
  79. for (let uidx = 0; uidx < USED_LIST.length; uidx++) {
  80. const accIdx = PRJ_ACCOUNT_LIST.findIndex(function(item) {
  81. return item.id === USED_LIST[uidx].uid;
  82. });
  83. if (accIdx === -1 || accIdx === undefined) {
  84. continue;
  85. }
  86. const prjAccount = PRJ_ACCOUNT_LIST[accIdx];
  87. let roleKey = prjAccount.role;
  88. if (roleKey === '') {
  89. roleKey = DFT_ROLE_NAME;
  90. }
  91. //push item
  92. 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>' +
  93. prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
  94. }
  95. accDiv.append(prj_accounts.join(''));
  96. },
  97. createEsignatureByAccIdx: function (accIdx) {
  98. rptSignatureHelper.createPreSelectedSignature(PRJ_ACCOUNT_LIST[accIdx], null);
  99. },
  100. createEsignatureByRoleIdx: function (roleIdx) {
  101. rptSignatureHelper.createPreSelectedSignature(null, ROLE_LIST[roleIdx]);
  102. },
  103. createPreSelectedSignature: function (directAcc, roleAcc) {
  104. let dftSignSrc = '/public/upload/sign/user-sign.PNG';
  105. let userAcc = directAcc;
  106. if (roleAcc) {
  107. userAcc = rptSignatureHelper.getUserAccount(roleAcc.bind_acc_id);
  108. }
  109. if (userAcc.sign_path !== '') {
  110. dftSignSrc = '/public/upload/sign/' + userAcc.sign_path;
  111. }
  112. if (rptSignatureHelper.currentSelectedESignAccName !== null) {
  113. for (const page of zTreeOprObj.currentRptPageRst.items) {
  114. if (page.signature_cells) {
  115. for (const sCell of page.signature_cells) {
  116. if (sCell.signature_name === rptSignatureHelper.currentSelectedESignAccName) {
  117. sCell.pre_path = dftSignSrc;
  118. }
  119. }
  120. }
  121. }
  122. // 1. 删除不需要的child dom
  123. $(rptSignatureHelper.currentSelectedESignAccDom).empty();
  124. // 2. 创建已选择签名相关 dom
  125. rptSignatureHelper.cleanOldSignature(rptSignatureHelper.currentSelectedESignAccName);
  126. // 2.1 dom element
  127. const elementsStrArr = [];
  128. let dftDate = _getSignDateByAllScenarios(userAcc.id);
  129. if (dftDate !== '' && dftDate.length > 20) {
  130. dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');
  131. }
  132. let roleRel = null;
  133. if (directAcc) {
  134. rptSignatureHelper.pushDomElementByUser(elementsStrArr, userAcc.name, userAcc.role);
  135. // 还有ROLE_REL_LIST
  136. let roleRelObj = {};
  137. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  138. roleRelObj.sign_path = dftSignSrc;
  139. // roleRelObj.sign_date = '';
  140. roleRelObj.sign_date = dftDate;
  141. roleRelObj.sign_date_format = 'yyyy年M月d日';
  142. roleRelObj.user_name = userAcc.name;
  143. roleRelObj.acc_id = userAcc.id;
  144. roleRelObj.type = '用户';
  145. roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)
  146. roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(directAcc.company);
  147. roleRelObj.private_stamp_path = (userAcc.stamp_path && userAcc.stamp_path !== '') ? userAcc.stamp_path : '';
  148. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  149. ROLE_REL_LIST.push(roleRelObj);
  150. roleRel = roleRelObj;
  151. } else if (roleAcc) {
  152. // 创建相关dom元素
  153. rptSignatureHelper.pushDomElementByRole(elementsStrArr, roleAcc.name, userAcc.name);
  154. // 还有ROLE_REL_LIST
  155. let roleRelObj = {};
  156. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  157. roleRelObj.sign_path = dftSignSrc;
  158. // roleRelObj.sign_date = '';
  159. roleRelObj.sign_date = dftDate;
  160. roleRelObj.sign_date_format = 'yyyy年M月d日';
  161. roleRelObj.user_name = userAcc.name;
  162. roleRelObj.acc_id = userAcc.id;
  163. roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)
  164. roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  165. roleRelObj.private_stamp_path = (userAcc.stamp_path && userAcc.stamp_path !== '') ? userAcc.stamp_path : null;
  166. roleRelObj.type = '角色';
  167. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  168. roleRelObj.role_name = roleAcc.name;
  169. ROLE_REL_LIST.push(roleRelObj);
  170. roleRel = roleRelObj;
  171. }
  172. // elementsStrArr.push('');
  173. rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, roleRel);
  174. $(rptSignatureHelper.currentSelectedESignAccDom).append(elementsStrArr.join(' '));
  175. //.appendChild(pNode);
  176. //*/
  177. // 2.2 date-picker
  178. // 更新最近使用名单
  179. const params = {};
  180. params.uid = userAcc.id;
  181. params.prj_id = PROJECT_ID;
  182. params.tender_id = TENDER_ID;
  183. CommonAjax.postXsrfEx("/tender/report_api/updateSignatureUsed", params, 10000, true, getCookie('csrfToken_j'),
  184. function(result){
  185. console.log(result);
  186. USED_LIST = result.data;
  187. $('#search_account').val('');
  188. rptSignatureHelper.buildSelectableAccount();
  189. rptSignatureHelper.buildSelectableAccountUsed();
  190. }, function(err){
  191. // hintBox.unWaitBox();
  192. }, function(ex){
  193. // hintBox.unWaitBox();
  194. }
  195. );
  196. }
  197. },
  198. cleanOldSignature: function (signature_name) {
  199. // 清掉ROLE_REL_LIST原有的签名
  200. for (let idx = ROLE_REL_LIST.length - 1; idx >= 0 ; idx--) {
  201. if (ROLE_REL_LIST[idx].signature_name === signature_name) {
  202. ROLE_REL_LIST.splice(idx, 1);
  203. }
  204. }
  205. },
  206. resetESignature: function (pageRst, signatureDivId) {
  207. // let body = $('#eSignatureBodyDiv');
  208. if (pageRst !== null) {
  209. let body = $('#' + signatureDivId);
  210. rptSignatureHelper.currentSelectedESignParentDivId = signatureDivId;
  211. body.empty();
  212. const signature_cells = [];
  213. const singatureNameArr = [];
  214. for (const page of pageRst.items) {
  215. if (page.signature_cells) {
  216. for (const sCell of page.signature_cells) {
  217. if (sCell.signature_name !== null && sCell.signature_name !== undefined && sCell.signature_name !== 'dummy_pic') {
  218. if (singatureNameArr.indexOf(sCell.signature_name) < 0) {
  219. signature_cells.push(sCell);
  220. singatureNameArr.push(sCell.signature_name);
  221. }
  222. }
  223. }
  224. }
  225. }
  226. if (signature_cells.length > 0) {
  227. const elementsStrArr = [];
  228. const elementsDateStrArr = [];
  229. for (let scIdx = 0; scIdx < signature_cells.length; scIdx++) {
  230. const sCell = signature_cells[scIdx];
  231. elementsStrArr.push('<div class="form-group row">');
  232. elementsStrArr.push('<label for="staticEmail" class="col-sm-3 col-form-label pr-0">' + sCell.signature_name + '</label>');
  233. elementsStrArr.push('<div class="col-sm-9">');
  234. elementsStrArr.push('<ul class="list-group">');
  235. elementsStrArr.push('<li class="list-group-item">');
  236. let hasPic = false;
  237. //新需求中,即使没有审核,也可以设置签名
  238. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  239. const role_rel = ROLE_REL_LIST[idx];
  240. if (role_rel.signature_name === sCell.signature_name) {
  241. if (role_rel.type === '用户') {
  242. rptSignatureHelper.pushDomElementByUser(elementsStrArr, role_rel.user_name, role_rel.role);
  243. } else {
  244. //角色
  245. rptSignatureHelper.pushDomElementByRole(elementsStrArr, role_rel.role_name, role_rel.user_name);
  246. }
  247. const userAcc = rptSignatureHelper.getUserAccount(role_rel.acc_id);
  248. role_rel.private_stamp_path = (userAcc.stamp_path && userAcc.stamp_path !== '') ? userAcc.stamp_path : '';
  249. role_rel.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  250. rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, role_rel);
  251. hasPic = true;
  252. break;
  253. }
  254. }
  255. if (!hasPic) {
  256. // 在交互操作中,有可能实际上是没有
  257. 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>');
  258. }
  259. // if (sCell.path || sCell.pic) {
  260. // } else {
  261. // elementsStrArr.push('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.currentSelectedESignAccName = \'' + sCell.signature_name + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签名</a>');
  262. // }
  263. elementsStrArr.push('</li>');
  264. elementsStrArr.push('</ul>');
  265. elementsStrArr.push('</div>');
  266. elementsStrArr.push('</div>');
  267. //还有签名日期(用不用得上不管,先放上去再说)
  268. }
  269. body.append(elementsStrArr.join(' '));
  270. }
  271. }
  272. },
  273. checkAndShowCrossTendersESignature: function () {
  274. let btnDom = $('#btn_cross_tender')[0];
  275. if (zTreeOprObj.currentNode) {
  276. if (btnDom) btnDom.style.display = '';
  277. } else {
  278. if (btnDom) btnDom.style.display = 'none';
  279. }
  280. },
  281. pushDomElementByUser: function (elementsStrArr, userName, userRole) {
  282. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span>' + userName +
  283. '-<small class="text-muted">' + ((userRole === '')?DFT_ROLE_NAME:userRole) +
  284. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  285. },
  286. pushDomElementByRole: function (elementsStrArr, roleName, userName) {
  287. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span><i class="fa fa-user" title="角色"> ' + roleName +
  288. '</i>-<small class="text-muted">' + userName +
  289. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  290. },
  291. pushDatePickerDom: function (elementsStrArr, userAcc, role_rel) {
  292. let idSuffixStr = 'dtp_' + rptSignatureHelper.currentSelectedESignAccName + '_' + rptSignatureHelper.currentSelectedESignParentDivId;
  293. elementsStrArr.push('<div class="mt-3">');
  294. elementsStrArr.push('<div class="row">');
  295. //-------------------------------------------------
  296. if (!Array.isArray(role_rel.sign_output)) {
  297. role_rel.sign_output = [NORMAL_SIGN_STR];
  298. }
  299. const normalSignChkStr = (role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) ? 'checked' : '';
  300. const companySignChkStr = (role_rel.sign_output.indexOf(COMPANY_SIGN_STR) >= 0) ? 'checked' : '';
  301. const privateSignChkStr = (role_rel.sign_output.indexOf(PRIVATE_SIGN_STR) >= 0) ? 'checked' : '';
  302. // 1. 签章类型:签字 单位章 个人章....
  303. elementsStrArr.push('<div class="col-6">');
  304. elementsStrArr.push(' <div class="form-control form-control-sm d-inline pt-2">');
  305. elementsStrArr.push(' <div class="form-check form-check-inline px-2">');
  306. elementsStrArr.push(` <input class="form-check-input" type="checkbox" id="${idSuffixStr}_sign1" value="option1" ${normalSignChkStr} onchange="rptSignatureHelper._changeSignType(this, ${userAcc.id}, '${NORMAL_SIGN_STR}')" >`);
  307. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign1">签字</label>`);
  308. elementsStrArr.push(' </div>');
  309. const hasIndividualStamp = (userAcc.stamp_path && userAcc.stamp_path !== ''); //用户账号的stamp_path是属于用户自己的私章,不是公司章
  310. let chkType = hasIndividualStamp ? 'radio' : 'checkbox';
  311. if (hasIndividualStamp) {
  312. elementsStrArr.push(' <div class="form-check form-check-inline mx-1">');
  313. elementsStrArr.push(' <div class="form-group">');
  314. elementsStrArr.push(' <div class="form-check form-check-inline px-1">');
  315. elementsStrArr.push(` <input class="form-check-input" type="${chkType}" id="${idSuffixStr}_sign2" value="companyStamp" name="${idSuffixStr}" onchange="rptSignatureHelper._changeSignType(this, ${userAcc.id}, '${COMPANY_SIGN_STR}')" ${companySignChkStr}>`);
  316. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_rdSign1">单位章</label>`);
  317. elementsStrArr.push(' </div>');
  318. elementsStrArr.push(' <div class="form-check form-check-inline">');
  319. elementsStrArr.push(` <input class="form-check-input" type="${chkType}" id="${idSuffixStr}_sign3" value="individualStamp" name="${idSuffixStr}" onchange="rptSignatureHelper._changeSignType(this, ${userAcc.id}, '${PRIVATE_SIGN_STR}')" ${privateSignChkStr}>`);
  320. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign3">个人章</label>`);
  321. elementsStrArr.push(' </div>');
  322. elementsStrArr.push(' </div>');
  323. elementsStrArr.push(' </div>');
  324. } else {
  325. elementsStrArr.push(' <div class="form-check form-check-inline px-2">');
  326. elementsStrArr.push(` <input class="form-check-input" type="${chkType}" id="${idSuffixStr}_sign2" value="option2" onchange="rptSignatureHelper._changeSignType(this, ${userAcc.id}, '${COMPANY_SIGN_STR}')" ${companySignChkStr}>`);
  327. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign2">单位章</label>`);
  328. elementsStrArr.push(' </div>');
  329. }
  330. elementsStrArr.push(' </div>');
  331. elementsStrArr.push('</div>');
  332. // 2. 日期
  333. elementsStrArr.push('<div class="col-6">');
  334. let dftDate = _getSignDateByAllScenarios(userAcc.id);
  335. if (dftDate !== '' && dftDate.length > 20) {
  336. dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');
  337. }
  338. elementsStrArr.push('<div class="input-group input-group-sm margin-inputbox">');
  339. elementsStrArr.push(' <div class="input-group-prepend">');
  340. elementsStrArr.push(' <span class="input-group-text height-inputbox" id="inputGroup-sizing-sm"><i class="fa fa-calendar" title="添加签名日期"></i></span>');
  341. elementsStrArr.push(' </div>');
  342. if (dftDate !== '') {
  343. elementsStrArr.push(`<input id="${idSuffixStr}" type="text" class="form-control datepicker-here height-inputbox" aria-label="Small" aria-describedby="inputGroup-sizing-sm" data-language="zh" value="${dftDate}"></input>`);
  344. } else {
  345. elementsStrArr.push(`<input id="${idSuffixStr}" type="text" class="form-control datepicker-here height-inputbox" aria-label="Small" aria-describedby="inputGroup-sizing-sm" data-language="zh"></input>`);
  346. }
  347. elementsStrArr.push('</div>');
  348. //-------------------------------------------------
  349. elementsStrArr.push('</div>');
  350. elementsStrArr.push('</div>');
  351. },
  352. removeSignature: function (dom) {
  353. let accTxtName = $(dom.parentNode.parentNode.parentNode.parentNode.parentNode).find('label')[0].innerText;
  354. let jDom = $(dom.parentNode.parentNode);
  355. jDom.empty();
  356. jDom.append('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.currentSelectedESignAccName = \'' +
  357. accTxtName + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签字</a>');
  358. // 要记得清空相关pre_path属性
  359. for (const page of zTreeOprObj.currentRptPageRst.items) {
  360. if (page.signature_cells) {
  361. for (const sCell of page.signature_cells) {
  362. if (sCell.signature_name === accTxtName) {
  363. sCell.pre_path = '';
  364. }
  365. }
  366. }
  367. }
  368. // 还有ROLE_REL_LIST
  369. rptSignatureHelper.cleanOldSignature(accTxtName);
  370. },
  371. removeSelectSignature: function () {
  372. for (const page of zTreeOprObj.currentRptPageRst.items) {
  373. if (page.signature_cells) {
  374. for (const sCell of page.signature_cells) {
  375. if (sCell.hasOwnProperty('pre_path')) {
  376. delete sCell.pre_path;
  377. }
  378. }
  379. }
  380. }
  381. // ROLE_REL_LIST = [];
  382. // ROLE_REL_LIST = ROLE_REL_LIST.concat(rptSignatureHelper.originalRoleRelList);
  383. ROLE_REL_LIST = JSON.parse(JSON.stringify(rptSignatureHelper.originalRoleRelList));
  384. if (PAGE_SHOW.isTextSignature) {
  385. resetTextSignature(zTreeOprObj.currentRptPageRst);
  386. }
  387. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  388. },
  389. resetSignAudit: function () {
  390. rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT);
  391. },
  392. resetSignDate: function(signatureDivId) {
  393. for (const page of zTreeOprObj.currentRptPageRst.items) {
  394. if (page.signature_date_cells) {
  395. for (const sCell of page.signature_date_cells) {
  396. sCell.Value = _getSignDateDftName();
  397. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  398. const role_rel = ROLE_REL_LIST[idx];
  399. const idSuffixStr = 'dtp_' + role_rel.signature_name + '_' + signatureDivId;
  400. let dtDom = $('#' + idSuffixStr);
  401. if (dtDom.length === 1) {
  402. const dtStr = dtDom[0].value;
  403. if (dtStr && dtStr !== '' && dtStr.length >= 8 && dtStr.length <= 10) {
  404. role_rel.sign_date = new Date(dtStr);
  405. } else {
  406. role_rel.sign_date = '';
  407. }
  408. // 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)
  409. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  410. if (role_rel.sign_date !== '') {
  411. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  412. }
  413. }
  414. }
  415. }
  416. }
  417. }
  418. }
  419. },
  420. setupAfterSelectMultiTenders: function (selectedTenders, signatureDivId) {
  421. //跨标段选择,有不少要注意的交互:
  422. //0. 签名日期
  423. rptSignatureHelper.resetSignDate(signatureDivId);
  424. rptSignatureHelper.resetSignAudit();
  425. //1. 重刷page
  426. if (current_stage_status === 3) {
  427. for (const page of zTreeOprObj.currentRptPageRst.items) {
  428. if (page.signature_cells) {
  429. for (const sCell of page.signature_cells) {
  430. if (sCell.hasOwnProperty('pre_path')) {
  431. sCell.path = sCell.pre_path;
  432. delete sCell.pre_path;
  433. }
  434. }
  435. }
  436. }
  437. if (PAGE_SHOW.isTextSignature) {
  438. resetTextSignature(zTreeOprObj.currentRptPageRst);
  439. }
  440. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  441. }
  442. //2. 集中请求
  443. let params = {};
  444. params.id = CURRENT_ROLE_REL_ID;
  445. params.tender_id = TENDER_ID;
  446. params.stage_id = getStageId();
  447. params.rpt_id = zTreeOprObj.currentNode.refId;
  448. params.rel_content = ROLE_REL_LIST;
  449. params.selectedTenders = selectedTenders;
  450. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  451. CommonAjax.postXsrfEx("/tender/report_api/updateMultiRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  452. function(result){
  453. console.log(result);
  454. if (result.data && result.data.insertId > 0) {
  455. CURRENT_ROLE_REL_ID = result.data.insertId;
  456. }
  457. }, function(err){
  458. // hintBox.unWaitBox();
  459. }, function(ex){
  460. // hintBox.unWaitBox();
  461. }
  462. );
  463. },
  464. _parseRoleRelList: function(org_rel_content) {
  465. const rst = JSON.parse(org_rel_content);
  466. for (const role_rel of rst) {
  467. if (role_rel.sign_date !== null && role_rel.sign_date !== undefined && role_rel.sign_date.length >= 8) {
  468. role_rel.sign_date = new Date(role_rel.sign_date);
  469. }
  470. }
  471. return rst;
  472. },
  473. setupAfterSelectSignature: function (signatureDivId) {
  474. //0. 签名日期
  475. let me = rptSignatureHelper;
  476. rptSignatureHelper.resetSignDate(signatureDivId);
  477. rptSignatureHelper.resetSignAudit();
  478. if (current_stage_status === 3) {
  479. //1. 重刷page
  480. let hasStamp = false;
  481. for (const page of zTreeOprObj.currentRptPageRst.items) {
  482. if (page.signature_cells) {
  483. for (let cIdx = page.signature_cells.length - 1; cIdx >= 0; cIdx--) {
  484. const sCell = page.signature_cells[cIdx];
  485. if (sCell.isStamp) {
  486. page.signature_cells.splice(cIdx);
  487. hasStamp = true;
  488. } else if (sCell.hasOwnProperty('pre_path')) {
  489. sCell.path = sCell.pre_path;
  490. delete sCell.pre_path;
  491. }
  492. }
  493. }
  494. }
  495. if (PAGE_SHOW.isTextSignature) {
  496. resetTextSignature(zTreeOprObj.currentRptPageRst);
  497. }
  498. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  499. }
  500. //2. 更新数据
  501. const params = {};
  502. params.id = CURRENT_ROLE_REL_ID;
  503. params.tender_id = TENDER_ID;
  504. params.stage_id = getStageId();
  505. params.rpt_id = zTreeOprObj.currentNode.refId;
  506. params.rel_content = ROLE_REL_LIST;
  507. // rptSignatureHelper.originalRoleRelList = [];
  508. // rptSignatureHelper.originalRoleRelList = rptSignatureHelper.originalRoleRelList.concat(ROLE_REL_LIST);
  509. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  510. CommonAjax.postXsrfEx("/tender/report_api/updateRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  511. function(result){
  512. // console.log(result);
  513. if (result.data && result.data.insertId > 0) {
  514. CURRENT_ROLE_REL_ID = result.data.insertId;
  515. }
  516. // ROLE_REL_LIST = [];
  517. // for (const signatureRel of result.signatureRelInfo) {
  518. // ROLE_REL_LIST.push(JSON.parse(signatureRel.rel_content));
  519. // }
  520. // rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  521. // ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  522. // rptSignatureHelper.originalRoleRelList = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  523. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  524. // CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  525. ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  526. rptSignatureHelper.originalRoleRelList = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  527. if (current_stage_status === 3) {
  528. rptSignatureHelper.mergeSignDate(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true);
  529. rptSignatureHelper.mergeSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST);
  530. rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT);
  531. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  532. }
  533. } else {
  534. // CURRENT_ROLE_REL_ID = -1;
  535. ROLE_REL_LIST = [];
  536. }
  537. }, function(err){
  538. // hintBox.unWaitBox();
  539. }, function(ex){
  540. // hintBox.unWaitBox();
  541. }
  542. );
  543. },
  544. switchAddRoleDiv: function (dom) {
  545. if (dom.nextElementSibling.children[0].style.display === 'none') {
  546. dom.nextElementSibling.children[0].style.display = '';
  547. } else {
  548. dom.nextElementSibling.children[0].style.display = 'none';
  549. }
  550. },
  551. createNewRole: function (dom) {
  552. if ($('#acc_role_name')[0].value !== '') {
  553. const params = {};
  554. params.name = $('#acc_role_name')[0].value;
  555. const selectedAcc = PRJ_ACCOUNT_LIST[$('#project_account_select_dom')[0].selectedOptions[0].value];
  556. const roleName = (selectedAcc.role === '')?DFT_ROLE_NAME:selectedAcc.role;
  557. params.bind_acc_id = selectedAcc.id;
  558. params.prj_id = PROJECT_ID;
  559. params.tender_id = TENDER_ID;
  560. CommonAjax.postXsrfEx("/tender/report_api/createSignatureRole", params, 10000, true, getCookie('csrfToken_j'),
  561. function(result){
  562. console.log(result);
  563. const newRole = {};
  564. newRole.name = params.name;
  565. newRole.bind_acc_id = selectedAcc.id;
  566. newRole.prj_id = PROJECT_ID;
  567. newRole.tender_id = TENDER_ID;
  568. ROLE_LIST.push(newRole);
  569. const domArr = [];
  570. domArr.push('<li class="add-sign-list-item">');
  571. //1. apply签名
  572. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + (ROLE_LIST.length - 1) +')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  573. domArr.push('<i class="fa fa-plus"></i>');
  574. domArr.push('</a>');
  575. //2. 编辑角色(暂缓处理click事件)
  576. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  577. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  578. domArr.push('</a>');
  579. //3. 显示名称
  580. domArr.push('<i class="fa fa-user"></i> ' + $('#acc_role_name')[0].value + '<p>' + selectedAcc.name + '-<small class="text-muted">' + roleName + '</small></p>');
  581. $('#existed_roles_ul').append(domArr.join(' '));
  582. }, function(err){
  583. // hintBox.unWaitBox();
  584. }, function(ex){
  585. // hintBox.unWaitBox();
  586. }
  587. );
  588. } else {
  589. alert('请输入合适的名称!');
  590. }
  591. },
  592. buildRoleDom: function (roleList) {
  593. const ulDom = $('#existed_roles_ul');
  594. ulDom.empty();
  595. for (let domIdx = 0; domIdx < roleList.length; domIdx++) {
  596. const role = roleList[domIdx];
  597. const domArr = [];
  598. domArr.push('<li class="add-sign-list-item">');
  599. //1. apply签名
  600. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + domIdx + ')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  601. domArr.push('<i class="fa fa-plus"></i>');
  602. domArr.push('</a>');
  603. //2. 编辑角色(暂缓)
  604. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  605. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  606. domArr.push('</a>');
  607. //3. 显示名称
  608. let acc = rptSignatureHelper.getUserAccount(role.bind_acc_id);
  609. 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>');
  610. ulDom.append(domArr.join(' '));
  611. }
  612. },
  613. getUserAccount: function (accId) {
  614. let rst = null;
  615. for (const acc of PRJ_ACCOUNT_LIST) {
  616. if (acc.id === accId) {
  617. rst = acc;
  618. break;
  619. }
  620. }
  621. return rst;
  622. },
  623. _getCompanySign: function(companyName) {
  624. let rst = '';
  625. for (const cUnit of CONSTRUCT_UNIT_LIST) {
  626. if (cUnit.name === companyName) {
  627. rst = cUnit.sign_path;
  628. break;
  629. }
  630. }
  631. return rst;
  632. },
  633. mergeSignature: function (pageData, currRoleRelList, setPic = false) {
  634. for (const page of pageData.items) {
  635. if (page.signature_cells) {
  636. const adHocScells = [];
  637. for (const sCell of page.signature_cells) {
  638. for (const role_rel of currRoleRelList) {
  639. if (role_rel.signature_name === sCell.signature_name) {
  640. // 处理签章
  641. if (!Array.isArray(role_rel.sign_output)) {
  642. role_rel.sign_output = [];
  643. role_rel.sign_output.push(NORMAL_SIGN_STR);
  644. }
  645. for (const signType of role_rel.sign_output) {
  646. switch (signType) {
  647. case NORMAL_SIGN_STR:
  648. sCell.path = role_rel.sign_path;
  649. sCell.pre_path = role_rel.sign_path;
  650. if (setPic) {
  651. sCell.pic = role_rel.sign_pic; // 有些场景(如:批量归档)需要直接设置签名数据
  652. }
  653. break;
  654. case COMPANY_SIGN_STR:
  655. case PRIVATE_SIGN_STR:
  656. /*
  657. const stampPath = (signType === COMPANY_SIGN_STR) ? role_rel.company_stamp_path : role_rel.private_stamp_path;
  658. // 生成一个新的dummy cell(类似草图)
  659. const newStampCell = _createDummyCell();
  660. newStampCell.signature_name = JV.SIGNATURE_NAME_DUMMY;
  661. newStampCell.path = OSS_PATH + stampPath;
  662. newStampCell.control = sCell.control;
  663. newStampCell.style = sCell.style;
  664. newStampCell.isStamp = true; // 这个标记纯属为了刷新用,其他sign cell是没有的
  665. // 设置坐标
  666. rptSignatureHelper._resetStampPos(sCell, newStampCell, pageData[JV.NODE_CONTROL_COLLECTION]);
  667. // 加到cells去
  668. adHocScells.push(newStampCell);
  669. //*/
  670. break;
  671. default:
  672. break;
  673. }
  674. }
  675. }
  676. }
  677. }
  678. page.signature_cells = page.signature_cells.concat(adHocScells);
  679. }
  680. }
  681. },
  682. mergeSignAudit: function (pageData, currRoleRelList, currAuditList) {
  683. for (const page of pageData.items) {
  684. if (page.signature_audit_cells) {
  685. for (const sCell of page.signature_audit_cells) {
  686. sCell.Value = ''; // 这里要先清除原有信息
  687. for (const role_rel of currRoleRelList) {
  688. if (sCell.signature_name === role_rel.signature_name + '_审核意见') {
  689. let preDate = '';
  690. sCell.Value = '同意'; // 只有选择了签名的,才需要初始化一个默认的意见(之前的逻辑在有多个签名,哪怕只选择了一个,其他的意见都会有默认意见)
  691. for (const audit_rel of currAuditList) {
  692. if (role_rel.acc_id === audit_rel.aid) {
  693. if (audit_rel.end_time > preDate && audit_rel.status === 3) {
  694. sCell.Value = audit_rel.opinion;
  695. preDate = audit_rel.end_time;
  696. }
  697. //不能break,实际会有多个审核意见,以最后一个为准
  698. }
  699. }
  700. break;
  701. }
  702. }
  703. }
  704. }
  705. }
  706. },
  707. mergeSignDate: function (pageData, currRoleRelList, isMergeOrgAlso) {
  708. if (currRoleRelList && currRoleRelList.length > 0 && STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  709. for (let rridx = 0; rridx < currRoleRelList.length; rridx++) {
  710. const role_rel = currRoleRelList[rridx];
  711. if (role_rel.sign_date === undefined || role_rel.sign_date === null || role_rel.sign_date === '') {
  712. //*
  713. let dftDate = _getSignDateByAllScenarios(role_rel.acc_id);
  714. role_rel.sign_date = dftDate;
  715. if (isMergeOrgAlso) {
  716. rptSignatureHelper.originalRoleRelList[rridx].sign_date = dftDate;
  717. //备注:在多选导出的情况下,originalRoleRelList不需要merge
  718. }
  719. /*/
  720. let hasAudit = false;
  721. for (const stg_audit of STAGE_AUDIT) {
  722. if (role_rel.acc_id === stg_audit.aid) {
  723. hasAudit = true;
  724. if (stg_audit.status === 3) {
  725. role_rel.sign_date = stg_audit.end_time;
  726. rptSignatureHelper.originalRoleRelList[rridx].sign_date = stg_audit.end_time;
  727. } else {
  728. role_rel.sign_date = '';
  729. rptSignatureHelper.originalRoleRelList[rridx].sign_date = '';
  730. }
  731. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  732. }
  733. }
  734. let isOrgRpt = false;
  735. for (const stg of STAGE_LIST) {
  736. if (stg.id === current_stage_id) {
  737. if (stg.user_id === role_rel.acc_id) {
  738. isOrgRpt = true;
  739. }
  740. break;
  741. }
  742. }
  743. if (isOrgRpt && !hasAudit && STAGE_AUDIT_ORG && STAGE_AUDIT_ORG.length > 0) {
  744. if (STAGE_AUDIT_ORG[0].begin_time && STAGE_AUDIT_ORG[0].begin_time !== '' && STAGE_AUDIT_ORG[0].begin_time.length > 20) {
  745. role_rel.sign_date = STAGE_AUDIT_ORG[0].begin_time;
  746. rptSignatureHelper.originalRoleRelList[rridx].sign_date = STAGE_AUDIT_ORG[0].begin_time;
  747. }
  748. }
  749. if (!isOrgRpt && !hasAudit) {
  750. //非审批流程人员以及非原报,则显示期截至时间
  751. for (const stg of STAGE_LIST) {
  752. if (stg.id === current_stage_id && stg.period) {
  753. const period = stg.period.split(' ~ ');
  754. if (period.length === 2) {
  755. role_rel.sign_date = period[1];
  756. rptSignatureHelper.originalRoleRelList[rridx].sign_date = period[1];
  757. }
  758. }
  759. }
  760. }
  761. //*/
  762. }
  763. }
  764. }
  765. for (const page of pageData.items) {
  766. if (page.signature_date_cells) {
  767. for (const sCell of page.signature_date_cells) {
  768. if (sCell.Value === undefined || sCell.Value === null && sCell.Value === '') {
  769. sCell.Value = _getSignDateDftName();
  770. }
  771. for (const role_rel of currRoleRelList) {
  772. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  773. if (role_rel.sign_date !== '') {
  774. if (typeof role_rel.sign_date === 'string') {
  775. role_rel.sign_date = new Date(role_rel.sign_date);
  776. }
  777. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  778. }
  779. break;
  780. }
  781. }
  782. }
  783. }
  784. }
  785. },
  786. _changeSignType: function(dom, acc_id, chkStr) {
  787. for (const roleRel of ROLE_REL_LIST) {
  788. if (roleRel.acc_id === acc_id) {
  789. if (dom.checked) {
  790. if (roleRel.sign_output.indexOf(chkStr) < 0) {
  791. roleRel.sign_output.push(chkStr);
  792. }
  793. } else {
  794. let idx = roleRel.sign_output.indexOf(chkStr);
  795. if (idx >= 0) {
  796. roleRel.sign_output.splice(idx, 1);
  797. }
  798. }
  799. if (chkStr === COMPANY_SIGN_STR) {
  800. let idx = roleRel.sign_output.indexOf(PRIVATE_SIGN_STR);
  801. if (idx >= 0) {
  802. roleRel.sign_output.splice(idx, 1);
  803. }
  804. } else if (chkStr === PRIVATE_SIGN_STR) {
  805. let idx = roleRel.sign_output.indexOf(COMPANY_SIGN_STR);
  806. if (idx >= 0) {
  807. roleRel.sign_output.splice(idx, 1);
  808. }
  809. }
  810. break;
  811. }
  812. }
  813. },
  814. _resetStampPos: function(orgCell, targetCell, controls) {
  815. const ctrl = controls[orgCell.control];
  816. let pLeft = orgCell.area.Left, pTop = orgCell.area.Top;
  817. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
  818. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
  819. pLeft = orgCell.area.Left;
  820. break;
  821. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
  822. pLeft = (orgCell.area.Left + orgCell.area.Right - STD_STAMP_SIZE_WIDTH) / 2 ;
  823. break;
  824. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
  825. pLeft = orgCell.area.Right - STD_STAMP_SIZE_WIDTH;
  826. break;
  827. }
  828. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
  829. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_TOP]:
  830. pTop = orgCell.area.Top;
  831. break;
  832. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_CENTER]:
  833. pTop = (orgCell.area.Top + orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT) / 2 ;
  834. break;
  835. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_BOTTOM]:
  836. pTop = orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT;
  837. break;
  838. }
  839. targetCell.area.Left = pLeft;
  840. targetCell.area.Top = pTop;
  841. targetCell.area.Right = pLeft + STD_STAMP_SIZE_WIDTH;
  842. targetCell.area.Bottom = pTop + STD_STAMP_SIZE_HEIGHT;
  843. },
  844. }
  845. function _getSignDateByAllScenarios(userAccId) {
  846. let rst = '';
  847. let hasAudit = false;
  848. for (const stg_audit of STAGE_AUDIT) {
  849. if (stg_audit.aid === userAccId) {
  850. hasAudit = true;
  851. if (stg_audit.status === 3) {
  852. rst = stg_audit.end_time;
  853. } else {
  854. rst = '';
  855. }
  856. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  857. }
  858. }
  859. let isOrgRpt = false;
  860. for (const stg of STAGE_LIST) {
  861. if (stg.id === current_stage_id) {
  862. if (stg.user_id === userAccId) {
  863. isOrgRpt = true;
  864. }
  865. break;
  866. }
  867. }
  868. if (isOrgRpt && !hasAudit && STAGE_AUDIT_ORG && STAGE_AUDIT_ORG.length > 0) {
  869. if (STAGE_AUDIT_ORG[0].begin_time && STAGE_AUDIT_ORG[0].begin_time !== '' && STAGE_AUDIT_ORG[0].begin_time.length > 20) {
  870. rst = STAGE_AUDIT_ORG[0].begin_time;
  871. }
  872. }
  873. if (!isOrgRpt && !hasAudit) {
  874. //非审批流程人员以及非原报,则显示期截至时间
  875. for (const stg of STAGE_LIST) {
  876. if (stg.id === current_stage_id && stg.period) {
  877. const period = stg.period.split(' ~ ');
  878. if (period.length === 2) {
  879. rst = period[1];
  880. }
  881. }
  882. }
  883. }
  884. return rst;
  885. }
  886. function _getSignDateDftName() {
  887. return ' 年 月 日';
  888. }
  889. function _createDummyCell() {
  890. const rst = {
  891. font: 'Footer',
  892. control: 'Footer',
  893. style: 'Default_None',
  894. Value: '',
  895. area: { Left: 0, Right: 0, Top: 0, Bottom: 0 },
  896. };
  897. return rst;
  898. }
  899. function resetTextSignature(pageData) {
  900. for (const page of pageData.items) {
  901. for (let sCell of page.signature_cells) {
  902. let fitCell = null;
  903. for (let idx = page.cells.length - 1; idx >= 0; idx--) {
  904. const cell = page.cells[idx];
  905. 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) {
  906. fitCell = cell;
  907. break;
  908. }
  909. }
  910. if (fitCell) {
  911. fitCell.Value = '';
  912. for (let role of ROLE_REL_LIST) {
  913. if (sCell.signature_name === role.signature_name) {
  914. fitCell.Value = role.user_name;
  915. break;
  916. }
  917. }
  918. } else {
  919. // 要创建新的文本签名cell
  920. for (let role of ROLE_REL_LIST) {
  921. if (sCell.signature_name === role.signature_name) {
  922. const newCell = {
  923. font: 'Footer',
  924. control: sCell.control,
  925. style: sCell.style,
  926. Value: role.user_name,
  927. area: { Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom },
  928. };
  929. page.cells.push(newCell);
  930. break;
  931. }
  932. }
  933. }
  934. }
  935. }
  936. }