rpt_signature.js 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659
  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. collapseExpandTreeNode: (dom, isDblClick = false) => {
  18. const classMap = {
  19. 'fa fa-caret-down': ['fa fa-caret-right', 'none'],
  20. 'fa fa-caret-right': ['fa fa-caret-down', ''],
  21. };
  22. const curPicDom = isDblClick ? $(dom).children()[0] : dom;
  23. const doms = $($(curPicDom).parent()).nextAll();
  24. for (let idx = 0; idx < doms.length; idx++) {
  25. doms[idx].style.display = classMap[curPicDom.className][1];
  26. }
  27. curPicDom.className = classMap[curPicDom.className][0];
  28. },
  29. buildFlowAccount: function() {
  30. // 显示:显示当前期(或材差、预付款等)的审核流程里面审批类型为协同的流程
  31. // 1. 清理所有选择项
  32. const accDiv = $('#assistant_audit_account_div');
  33. accDiv.empty();
  34. // 2. 获取STAG_FLOW的审核信息(如一审、二审等)
  35. const collectedSf = [];
  36. STAGE_FLOW.forEach(sf => {
  37. // audit_type === 4 // 4是协审
  38. if (sf.audit_type === 4) {
  39. collectedSf.push(sf);
  40. }
  41. });
  42. if (collectedSf.length > 0) {
  43. const cacheObj = {};
  44. collectedSf.forEach(sf => {
  45. const chnStr = `${transFormToChinese(sf.audit_order)}审`;
  46. if (!cacheObj[chnStr]) {
  47. cacheObj[chnStr] = { order: sf.audit_order };
  48. }
  49. // cacheObj[chnStr].push(sf);
  50. });
  51. const htmls = ['<ul class="list-group">'];
  52. // htmls.push('<optgroup label="审批流程">');
  53. htmls.push('<li class="px-2 text-muted"><i class="fa fa-caret-down"></i>审批流程</li>');
  54. for (let key in cacheObj) {
  55. // cacheObj[key]
  56. // htmls.push(`<a class="dropdown-item" href="javascript: void(0)" data-dismiss="modal">${key}(协同)</a>`);
  57. htmls.push(`<a class="dropdown-item" href="javascript: void(0)" onclick="rptSignatureHelper.createEsignatureByAssistantFlow('${key}', ${cacheObj[key].order})" data-dismiss="modal">${key}(协同)</a>`);
  58. }
  59. // htmls.push('</optgroup>');
  60. htmls.push('</ul>')
  61. accDiv.append(htmls.join(''));
  62. } else {
  63. // 隐藏这里的div/button?
  64. }
  65. },
  66. buildSelectableAccount: function () {
  67. //PRJ_ACCOUNT_LIST
  68. //1. 清理所有选择项
  69. // $("#project_account_select_div").empty();
  70. let accDiv = $('#project_account_select_div');
  71. let accSelect = $('#project_account_select_dom'); //绑定成员
  72. let searchInput = $('#search_account').val();
  73. accDiv.empty();
  74. accSelect.empty();
  75. //2. 一个个加可选用户项
  76. const prj_accounts = [];
  77. const prj_sel_option_accounts = [];
  78. const acc_role_keys = [];
  79. for (let accIdx = 0; accIdx < PRJ_ACCOUNT_LIST.length; accIdx++) {
  80. const prjAccount = PRJ_ACCOUNT_LIST[accIdx];
  81. if (searchInput === '' || (searchInput !== '' && prjAccount.name.indexOf(searchInput) !== -1)) {
  82. let companyKey = prjAccount.account_group;
  83. let roleKey = prjAccount.role;
  84. if (companyKey === '') {
  85. companyKey = '其他单位';
  86. }
  87. if (roleKey === '') {
  88. roleKey = DFT_ROLE_NAME;
  89. }
  90. let keyIdx = acc_role_keys.indexOf(companyKey);
  91. if (keyIdx < 0) {
  92. acc_role_keys.push(companyKey);
  93. prj_accounts.push([]);
  94. prj_sel_option_accounts.push([]);
  95. keyIdx = prj_accounts.length - 1;
  96. //这里先push一些 html prefix,在后面统一在push html suffix
  97. prj_accounts[keyIdx].push('<ul class="list-group">');
  98. prj_accounts[keyIdx].push('<li class="px-2 text-muted" ondblclick="rptSignatureHelper.collapseExpandTreeNode(this, true)"><i class="fa fa-caret-down" onclick="rptSignatureHelper.collapseExpandTreeNode(this)"></i> ' + companyKey + '</li>');
  99. prj_sel_option_accounts[keyIdx].push('<optgroup label=" ' + companyKey + '">');
  100. }
  101. //push item
  102. // 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>' +
  103. // prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
  104. 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>`);
  105. prj_sel_option_accounts[keyIdx].push('<option value="' + accIdx + '">' + prjAccount.name + '-' + roleKey + '</option>');
  106. }
  107. }
  108. for (const prjAccList of prj_accounts) {
  109. prjAccList.push('</ul>');
  110. }
  111. for (const prjAccList of prj_sel_option_accounts) {
  112. prjAccList.push('</optgroup>');
  113. }
  114. for (let idx = 0; idx < prj_accounts.length; idx++) {
  115. prj_accounts[idx] = prj_accounts[idx].join('');
  116. prj_sel_option_accounts[idx] = prj_sel_option_accounts[idx].join('');
  117. }
  118. accDiv.append(prj_accounts.join(''));
  119. accSelect.append(prj_sel_option_accounts.join(''));
  120. },
  121. buildSelectableAccountUsed: function () {
  122. //PRJ_ACCOUNT_LIST
  123. //1. 清理所有选择项
  124. // $("#project_account_select_div").empty();
  125. let accDiv = $('#account_used_select_div');
  126. accDiv.empty();
  127. //2. 一个个加可选用户项
  128. const prj_accounts = [];
  129. for (let uidx = 0; uidx < USED_LIST.length; uidx++) {
  130. const accIdx = PRJ_ACCOUNT_LIST.findIndex(function(item) {
  131. return item.id === USED_LIST[uidx].uid;
  132. });
  133. if (accIdx === -1 || accIdx === undefined) {
  134. continue;
  135. }
  136. const prjAccount = PRJ_ACCOUNT_LIST[accIdx];
  137. let roleKey = prjAccount.role;
  138. if (roleKey === '') {
  139. roleKey = DFT_ROLE_NAME;
  140. }
  141. //push item
  142. // 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>' +
  143. // prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
  144. 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>`);
  145. }
  146. accDiv.append(prj_accounts.join(''));
  147. },
  148. createEsignatureByAssistantFlow: function(assName, order) {
  149. const dftSignSrc = '/public/upload/sign/user-sign.PNG';
  150. if (rptSignatureHelper.currentSelectedESignAccName !== null) {
  151. for (const page of zTreeOprObj.currentRptPageRst.items) {
  152. if (page.signature_cells) {
  153. for (const sCell of page.signature_cells) {
  154. if (sCell.signature_name === rptSignatureHelper.currentSelectedESignAccName) {
  155. sCell.pre_path = dftSignSrc;
  156. }
  157. }
  158. }
  159. }
  160. // 1. 删除不需要的child dom
  161. $(rptSignatureHelper.currentSelectedESignAccDom).empty();
  162. // 2. 创建已选择签名相关 dom
  163. rptSignatureHelper.cleanOldSignature(rptSignatureHelper.currentSelectedESignAccName);
  164. const elementsStrArr = [];
  165. rptSignatureHelper.pushDomElementByFlow(elementsStrArr, `${assName}(协同)`, rptSignatureHelper.currentSelectedESignAccName);
  166. let roleRelObj = {};
  167. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  168. roleRelObj.type = '流程';
  169. roleRelObj.flowOrder = order;
  170. roleRelObj.flow_name = `${assName}(协同)`;
  171. roleRelObj.assFlowInfos = []; // 这里动态记录流程的协审信息(含:人名、单位、职位、签字签章、签字日期, 其实相当于另一个完整的roleRel对象)
  172. roleRelObj.sign_output = [];
  173. ROLE_REL_LIST.push(roleRelObj);
  174. STAGE_FLOW.forEach(sf => {
  175. if (sf.audit_order === order) {
  176. const userAcc = rptSignatureHelper.getUserAccount(sf.aid);
  177. let dftDate = '';
  178. const status = _getStatusByUserId(userAcc.id);
  179. if (status === 3) dftDate = _getSignDateByAllScenarios(userAcc.id);
  180. const newRoleRel = {
  181. signature_name: rptSignatureHelper.currentSelectedESignAccName,
  182. acc_id: sf.aid,
  183. user_name: sf.name,
  184. company: sf.company,
  185. role: sf.role,
  186. sign_date: dftDate,
  187. sign_date_format: 'yyyy年M月d日',
  188. sign_output: [NORMAL_SIGN_STR], // , PRIVATE_SIGN_STR, COMPANY_SIGN_STR
  189. company_stamp_path: rptSignatureHelper._getCompanySign(sf.company),
  190. status, // 记录一下吧,没坏处
  191. }
  192. newRoleRel.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(newRoleRel, userAcc); // 个人章从PRJ_ACCOUNT_LIST中获取
  193. roleRelObj.assFlowInfos.push(newRoleRel);
  194. }
  195. });
  196. $(rptSignatureHelper.currentSelectedESignAccDom).append(elementsStrArr.join(' '));
  197. }
  198. },
  199. getFlowRoleRel(signature_name) {
  200. let rst = null;
  201. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  202. if (ROLE_REL_LIST[idx].signature_name === signature_name) {
  203. rst = ROLE_REL_LIST[idx];
  204. break;
  205. }
  206. }
  207. return rst;
  208. },
  209. iniAssFlowDialog(roleRelObj) {
  210. if (roleRelObj.type !== '流程') return;
  211. // 初始化协同人信息
  212. const assFlowDialog = $('#assistant-flow-setting-table')
  213. assFlowDialog.empty();
  214. const assFlowElements = [];
  215. assFlowElements.push('<tr class="text-center"><th width="60px">协同人</th><th>单位</th><th>职位</th><th width="100px">签字</th><th width="100px">个人章</th><th width="100px">公司章</th><th width="120px">签字日期</th></tr>');
  216. roleRelObj.assFlowInfos.forEach((flowRoleRel, index) => {
  217. const userAcc = rptSignatureHelper.getUserAccount(flowRoleRel.acc_id);
  218. assFlowElements.push('<tr class="text-center">');
  219. // 栏头
  220. assFlowElements.push(`<td>${flowRoleRel.user_name}</td><td>${flowRoleRel.company}</td><td>${flowRoleRel.role}</td>`);
  221. // 签字
  222. const normalChk = flowRoleRel.sign_output.includes(NORMAL_SIGN_STR) ? 'checked' : '';
  223. assFlowElements.push(`<td><input type="checkbox" ${normalChk} onchange="rptSignatureHelper._changeSignType(this, '${roleRelObj.signature_name}', '${NORMAL_SIGN_STR}', '${userAcc.stamp_path || ''}', ${index})" ></td>`);
  224. //
  225. // 个人章
  226. if (flowRoleRel.private_stamp_path && flowRoleRel.private_stamp_path !== '') {
  227. const privateChk = flowRoleRel.sign_output.includes(PRIVATE_SIGN_STR) ? 'checked' : '';
  228. assFlowElements.push(`<td><input type="checkbox" ${privateChk} onchange="rptSignatureHelper._changeSignType(this, '${roleRelObj.signature_name}', '${PRIVATE_SIGN_STR}', '${userAcc.stamp_path || ''}', ${index})" >
  229. <a class="pl-2" href="#chose-private-stamp-path" data-toggle="modal" data-target="#chose-private-stamp-path" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode;rptSignatureHelper.initChosePrivateStampPath('${userAcc.stamp_path}','${roleRelObj.signature_name}', ${index}) ">选择个人章</a>
  230. </td>`);
  231. } else {
  232. assFlowElements.push(`<td></td>`);
  233. }
  234. // 公司章 + 签字日期
  235. const dateIdSuffixStr = `flowdtp_${roleRelObj.signature_name}_${index}`;
  236. if (flowRoleRel.company_stamp_path && flowRoleRel.company_stamp_path !== '') {
  237. const companyChk = flowRoleRel.sign_output.includes(COMPANY_SIGN_STR) ? 'checked' : '';
  238. assFlowElements.push(`<td><input type="checkbox" ${companyChk} onchange="rptSignatureHelper._changeSignType(this, '${roleRelObj.signature_name}', '${COMPANY_SIGN_STR}', '${userAcc.stamp_path || ''}', ${index})" ></td>`);
  239. assFlowElements.push(`<td><input type="text" class="form-control form-control-sm datepicker-here height-inputbox" aria-label="Small" aria-describedby="inputGroup-sizing-sm" data-language="zh"
  240. id="${dateIdSuffixStr}" value="${flowRoleRel.sign_date || ''}"></td>`);
  241. // 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>`);
  242. } else {
  243. assFlowElements.push(`<td></td>`);
  244. }
  245. // 收尾
  246. assFlowElements.push('</tr>');
  247. });
  248. assFlowDialog.append(assFlowElements.join(' '));
  249. },
  250. createEsignatureByAccIdx: function (accIdx) {
  251. rptSignatureHelper.createPreSelectedSignature(PRJ_ACCOUNT_LIST[accIdx], null);
  252. },
  253. createEsignatureByRoleIdx: function (roleIdx) {
  254. rptSignatureHelper.createPreSelectedSignature(null, ROLE_LIST[roleIdx]);
  255. },
  256. createPreSelectedSignature: function (directAcc, roleAcc) {
  257. let dftSignSrc = '/public/upload/sign/user-sign.PNG';
  258. let userAcc = directAcc;
  259. if (roleAcc) {
  260. userAcc = rptSignatureHelper.getUserAccount(roleAcc.bind_acc_id);
  261. }
  262. if (userAcc.sign_path !== '') {
  263. dftSignSrc = '/public/upload/sign/' + userAcc.sign_path;
  264. }
  265. if (rptSignatureHelper.currentSelectedESignAccName !== null) {
  266. for (const page of zTreeOprObj.currentRptPageRst.items) {
  267. if (page.signature_cells) {
  268. for (const sCell of page.signature_cells) {
  269. if (sCell.signature_name === rptSignatureHelper.currentSelectedESignAccName) {
  270. sCell.pre_path = dftSignSrc;
  271. }
  272. }
  273. }
  274. }
  275. // 1. 删除不需要的child dom
  276. $(rptSignatureHelper.currentSelectedESignAccDom).empty();
  277. // 2. 创建已选择签名相关 dom
  278. rptSignatureHelper.cleanOldSignature(rptSignatureHelper.currentSelectedESignAccName);
  279. // 2.1 dom element
  280. const elementsStrArr = [];
  281. let dftDate = _getSignDateByAllScenarios(userAcc.id);
  282. if (dftDate !== '' && dftDate.length >= 10) {
  283. dftDate = new Date(dftDate); // 不Format,保留时分秒
  284. } else if (dftDate === '') {
  285. if (current_stage_id <= -300 && current_stage_id > -400 && BGL_OBJ && BGL_OBJ.currentBz && BGL_OBJ.currentBz.status === 3) {
  286. if (STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  287. dftDate = new Date(STAGE_AUDIT[STAGE_AUDIT.length - 1].end_time);
  288. } else {
  289. dftDate = new Date();
  290. }
  291. } else {
  292. dftDate = new Date();
  293. }
  294. }
  295. let roleRel = null;
  296. if (directAcc) {
  297. rptSignatureHelper.pushDomElementByUser(elementsStrArr, userAcc.name, userAcc.role);
  298. // 还有ROLE_REL_LIST
  299. let roleRelObj = {};
  300. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  301. roleRelObj.sign_path = dftSignSrc;
  302. // roleRelObj.sign_date = '';
  303. roleRelObj.sign_date = dftDate;
  304. roleRelObj.sign_date_format = 'yyyy年M月d日';
  305. roleRelObj.user_name = userAcc.name;
  306. roleRelObj.acc_id = userAcc.id;
  307. roleRelObj.type = '用户';
  308. roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)
  309. roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(directAcc.company);
  310. roleRelObj.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(roleRelObj,userAcc);
  311. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  312. ROLE_REL_LIST.push(roleRelObj);
  313. roleRel = roleRelObj;
  314. } else if (roleAcc) {
  315. // 创建相关dom元素
  316. rptSignatureHelper.pushDomElementByRole(elementsStrArr, roleAcc.name, userAcc.name);
  317. // 还有ROLE_REL_LIST
  318. let roleRelObj = {};
  319. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  320. roleRelObj.sign_path = dftSignSrc;
  321. // roleRelObj.sign_date = '';
  322. roleRelObj.sign_date = dftDate;
  323. roleRelObj.sign_date_format = 'yyyy年M月d日';
  324. roleRelObj.user_name = userAcc.name;
  325. roleRelObj.acc_id = userAcc.id;
  326. roleRelObj.sign_output = [NORMAL_SIGN_STR]; // 默认是签字(还有:COMPANY_SIGN_STR:单位章, PRIVATE_SIGN_STR:个人章)
  327. roleRelObj.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  328. roleRelObj.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(roleRelObj,userAcc);
  329. roleRelObj.type = '角色';
  330. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  331. roleRelObj.role_name = roleAcc.name;
  332. ROLE_REL_LIST.push(roleRelObj);
  333. roleRel = roleRelObj;
  334. }
  335. // elementsStrArr.push('');
  336. rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, roleRel, 0);
  337. $(rptSignatureHelper.currentSelectedESignAccDom).append(elementsStrArr.join(' '));
  338. //.appendChild(pNode);
  339. //*/
  340. // 2.2 date-picker
  341. // 更新最近使用名单
  342. const params = {};
  343. params.uid = userAcc.id;
  344. params.prj_id = PROJECT_ID;
  345. params.tender_id = TENDER_ID;
  346. CommonAjax.postXsrfEx("/tender/report_api/updateSignatureUsed", params, 10000, true, getCookie('csrfToken_j'),
  347. function(result){
  348. console.log(result);
  349. USED_LIST = result.data;
  350. $('#search_account').val('');
  351. rptSignatureHelper.buildFlowAccount();
  352. rptSignatureHelper.buildSelectableAccount();
  353. rptSignatureHelper.buildSelectableAccountUsed();
  354. }, function(err){
  355. // hintBox.unWaitBox();
  356. }, function(ex){
  357. // hintBox.unWaitBox();
  358. }
  359. );
  360. }
  361. },
  362. cleanOldSignature: function (signature_name) {
  363. // 清掉ROLE_REL_LIST原有的签名
  364. for (let idx = ROLE_REL_LIST.length - 1; idx >= 0 ; idx--) {
  365. if (ROLE_REL_LIST[idx].signature_name === signature_name) {
  366. ROLE_REL_LIST.splice(idx, 1);
  367. }
  368. }
  369. },
  370. resetESignature: function (pageRst, signatureDivId, cleanSignDate = false) {
  371. // let body = $('#eSignatureBodyDiv');
  372. if (pageRst !== null) {
  373. let body = $('#' + signatureDivId);
  374. rptSignatureHelper.currentSelectedESignParentDivId = signatureDivId;
  375. body.empty();
  376. const signature_cells = [];
  377. const singatureNameArr = [];
  378. for (const page of pageRst.items) {
  379. if (page.signature_cells) {
  380. for (const sCell of page.signature_cells) {
  381. if (sCell.signature_name !== null && sCell.signature_name !== undefined && sCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0) {
  382. if (singatureNameArr.indexOf(sCell.signature_name) < 0) {
  383. signature_cells.push(sCell);
  384. singatureNameArr.push(sCell.signature_name);
  385. }
  386. }
  387. }
  388. }
  389. }
  390. if (signature_cells.length > 0) {
  391. const elementsStrArr = [];
  392. const elementsDateStrArr = [];
  393. for (let scIdx = 0; scIdx < signature_cells.length; scIdx++) {
  394. const sCell = signature_cells[scIdx];
  395. elementsStrArr.push('<div class="form-group row">');
  396. elementsStrArr.push('<label for="staticEmail" class="col-sm-2 col-form-label pr-0">' + sCell.signature_name + '</label>');
  397. elementsStrArr.push('<div class="col-sm-10">');
  398. elementsStrArr.push('<ul class="list-group">');
  399. elementsStrArr.push('<li class="list-group-item">');
  400. let hasPic = false;
  401. //新需求中,即使没有审核,也可以设置签名
  402. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  403. const role_rel = ROLE_REL_LIST[idx];
  404. if (role_rel.signature_name === sCell.signature_name) {
  405. if (role_rel.type === '用户') {
  406. rptSignatureHelper.pushDomElementByUser(elementsStrArr, role_rel.user_name, role_rel.role);
  407. } else if (role_rel.type === '角色') {
  408. rptSignatureHelper.pushDomElementByRole(elementsStrArr, role_rel.role_name, role_rel.user_name);
  409. } else {
  410. // 流程
  411. rptSignatureHelper.pushDomElementByFlow(elementsStrArr, role_rel.flow_name, role_rel.signature_name);
  412. }
  413. if (role_rel.type === '流程') {
  414. role_rel.assFlowInfos.forEach(sf => {
  415. const userAcc = rptSignatureHelper.getUserAccount(sf.acc_id);
  416. if (userAcc) {
  417. sf.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(sf, userAcc);
  418. sf.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  419. }
  420. });
  421. } else {
  422. const userAcc = rptSignatureHelper.getUserAccount(role_rel.acc_id);
  423. if (userAcc) {
  424. role_rel.private_stamp_path = rptSignatureHelper._get_newPrivate_stamp_path(role_rel,userAcc);
  425. role_rel.company_stamp_path = rptSignatureHelper._getCompanySign(userAcc.company);
  426. }
  427. rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc, role_rel, idx);
  428. }
  429. hasPic = true;
  430. break;
  431. }
  432. }
  433. if (!hasPic) {
  434. // 在交互操作中,有可能实际上是没有
  435. 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>');
  436. }
  437. // if (sCell.path || sCell.pic) {
  438. // } else {
  439. // 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>');
  440. // }
  441. elementsStrArr.push('</li>');
  442. elementsStrArr.push('</ul>');
  443. elementsStrArr.push('</div>');
  444. elementsStrArr.push('</div>');
  445. //还有签名日期(用不用得上不管,先放上去再说)
  446. }
  447. body.append(elementsStrArr.join(' '));
  448. }
  449. }
  450. },
  451. checkAndShowCrossTendersESignature: function (fujianOssPath) {
  452. rptSignatureHelper.fujianOssPath=fujianOssPath;
  453. let btnDom = $('#btn_cross_tender')[0];
  454. if (zTreeOprObj.currentNode) {
  455. if (btnDom) btnDom.style.display = '';
  456. } else {
  457. if (btnDom) btnDom.style.display = 'none';
  458. }
  459. },
  460. pushDomElementByUser: function (elementsStrArr, userName, userRole) {
  461. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span>' + userName +
  462. '-<small class="text-muted">' + ((userRole === '')?DFT_ROLE_NAME:userRole) +
  463. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  464. },
  465. pushDomElementByRole: function (elementsStrArr, roleName, userName) {
  466. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span><i class="fa fa-user" title="角色"> ' + roleName +
  467. '</i>-<small class="text-muted">' + userName +
  468. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  469. },
  470. pushDomElementByFlow: function (elementsStrArr, flowName, signature_name) {
  471. elementsStrArr.push(`<p class=" d-flex justify-content-between m-0"><span>${flowName}<a href="#add-liucheng" data-toggle="modal" data-target="#add-liucheng"
  472. onclick="rptSignatureHelper.iniAssFlowDialog(rptSignatureHelper.getFlowRoleRel('${signature_name}'))">(设置签字签章)</a>
  473. </span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>`);
  474. },
  475. pushDatePickerDom: function (elementsStrArr, userAcc, role_rel, seq = 0) {
  476. if (role_rel.type === '流程') return;
  477. const dateIdSuffixStr = 'dtp_' + role_rel.signature_name + '_' + rptSignatureHelper.currentSelectedESignParentDivId;
  478. let milliSec = (new Date()).getMilliseconds();
  479. const idSuffixStr = `dtp_${seq}_${milliSec}_${rptSignatureHelper.currentSelectedESignParentDivId}`;
  480. elementsStrArr.push('<div class="mt-3">');
  481. elementsStrArr.push('<div class="row">');
  482. //-------------------------------------------------
  483. if (!Array.isArray(role_rel.sign_output)) {
  484. role_rel.sign_output = [NORMAL_SIGN_STR];
  485. }
  486. const normalSignChkStr = (role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) ? 'checked' : '';
  487. const companySignChkStr = (role_rel.sign_output.indexOf(COMPANY_SIGN_STR) >= 0) ? 'checked' : '';
  488. const privateSignChkStr = (role_rel.sign_output.indexOf(PRIVATE_SIGN_STR) >= 0) ? 'checked' : '';
  489. // 1. 签章类型:签字 单位章 个人章....
  490. elementsStrArr.push('<div class="col-8">');
  491. elementsStrArr.push(' <div class="form-control form-control-sm d-inline pt-2">');
  492. elementsStrArr.push(' <div class="form-check form-check-inline px-2">');
  493. 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}')" >`);
  494. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign1">签字</label>`);
  495. elementsStrArr.push(' </div>');
  496. const hasIndividualStamp = (userAcc && userAcc.stamp_path && userAcc.stamp_path !== ''); //用户账号的stamp_path是属于用户自己的私章,不是公司章
  497. // let chkType = hasIndividualStamp ? `radio` : 'checkbox';
  498. const chkType = 'checkbox';
  499. let rdoNameStr = `dtp_${role_rel.signature_name}_${rptSignatureHelper.currentSelectedESignParentDivId}`;
  500. // 个人章列表
  501. const stampPathList=userAcc&&userAcc.stamp_path?userAcc.stamp_path.split('!;!'):[];
  502. if (hasIndividualStamp) {
  503. elementsStrArr.push(' <div class="form-check form-check-inline mx-1">');
  504. elementsStrArr.push(' <div class="form-group">');
  505. elementsStrArr.push(' <div class="form-check form-check-inline px-1">');
  506. 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}>`);
  507. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign2">单位章</label>`);
  508. elementsStrArr.push(' </div>');
  509. elementsStrArr.push(' <div class="form-check form-check-inline">');
  510. 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}>`);
  511. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign3">个人章</label>`);
  512. if(stampPathList.length>1){
  513. 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>`);
  514. }
  515. elementsStrArr.push(' </div>');
  516. elementsStrArr.push(' </div>');
  517. elementsStrArr.push(' </div>');
  518. } else {
  519. elementsStrArr.push(' <div class="form-check form-check-inline px-2">');
  520. 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}>`);
  521. elementsStrArr.push(` <label class="form-check-label" for="${idSuffixStr}_sign10">单位章</label>`);
  522. elementsStrArr.push(' </div>');
  523. }
  524. elementsStrArr.push(' </div>');
  525. elementsStrArr.push('</div>');
  526. // 2. 日期
  527. elementsStrArr.push('<div class="col-4">');
  528. let dftDate = '';
  529. if (role_rel.sign_date !== '' && role_rel.sign_date.length > 20) {
  530. dftDate = (new Date(role_rel.sign_date)).Format('yyyy-MM-dd');
  531. } else if (role_rel.sign_date instanceof Date){
  532. dftDate = role_rel.sign_date.Format('yyyy-MM-dd');
  533. } else {
  534. if (userAcc) dftDate = _getSignDateByAllScenarios(userAcc.id);
  535. if (dftDate !== '' && dftDate.length > 20) {
  536. dftDate = (new Date(dftDate)).Format('yyyy-MM-dd');
  537. }
  538. }
  539. elementsStrArr.push('<div class="input-group input-group-sm margin-inputbox">');
  540. elementsStrArr.push(' <div class="input-group-prepend">');
  541. elementsStrArr.push(' <span class="input-group-text height-inputbox" id="inputGroup-sizing-sm"><i class="fa fa-calendar" title="添加签名日期"></i></span>');
  542. elementsStrArr.push(' </div>');
  543. if (dftDate !== '') {
  544. 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>`);
  545. } else {
  546. 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>`);
  547. }
  548. elementsStrArr.push('</div>');
  549. //-------------------------------------------------
  550. elementsStrArr.push('</div>');
  551. elementsStrArr.push('</div>');
  552. },
  553. removeSignature: function (dom) {
  554. let accTxtName = $(dom.parentNode.parentNode.parentNode.parentNode.parentNode).find('label')[0].innerText;
  555. let jDom = $(dom.parentNode.parentNode);
  556. jDom.empty();
  557. jDom.append('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.currentSelectedESignAccName = \'' +
  558. accTxtName + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签字</a>');
  559. // 要记得清空相关pre_path属性
  560. for (const page of zTreeOprObj.currentRptPageRst.items) {
  561. if (page.signature_cells) {
  562. for (const sCell of page.signature_cells) {
  563. if (sCell.signature_name === accTxtName) {
  564. sCell.pre_path = '';
  565. }
  566. }
  567. }
  568. }
  569. // 还有ROLE_REL_LIST
  570. rptSignatureHelper.cleanOldSignature(accTxtName);
  571. },
  572. removeSelectSignature: function () {
  573. for (const page of zTreeOprObj.currentRptPageRst.items) {
  574. if (page.signature_cells) {
  575. for (const sCell of page.signature_cells) {
  576. if (sCell.hasOwnProperty('pre_path')) {
  577. delete sCell.pre_path;
  578. }
  579. }
  580. }
  581. }
  582. // ROLE_REL_LIST = [];
  583. // ROLE_REL_LIST = ROLE_REL_LIST.concat(rptSignatureHelper.originalRoleRelList);
  584. ROLE_REL_LIST = JSON.parse(JSON.stringify(rptSignatureHelper.originalRoleRelList));
  585. if (PAGE_SHOW.isTextSignature) {
  586. // resetTextSignature(zTreeOprObj.currentRptPageRst);
  587. resetTextSignature(zTreeOprObj.currentRptPageRst, getStageStatus() !== 3);
  588. }
  589. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  590. },
  591. resetSignAudit: function () {
  592. rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT);
  593. },
  594. resetSignDate: function(signatureDivId) {
  595. for (const page of zTreeOprObj.currentRptPageRst.items) {
  596. // 调整了下次序,无论有没有签名时间显示,签名对象的sign_date必须得更新及保存
  597. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  598. const role_rel = ROLE_REL_LIST[idx];
  599. if (role_rel.type !== '流程') {
  600. const idSuffixStr = 'dtp_' + role_rel.signature_name + '_' + signatureDivId;
  601. let dtDom = document.getElementById(idSuffixStr); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象
  602. if (dtDom) {
  603. const dtStr = dtDom.value;
  604. if (dtStr && dtStr !== '' && dtStr.length >= 8 && dtStr.length <= 10) {
  605. role_rel.sign_date = new Date(dtStr);
  606. } else {
  607. role_rel.sign_date = '';
  608. }
  609. // 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)
  610. if (page.signature_date_cells) {
  611. for (const sCell of page.signature_date_cells) {
  612. // 在重设之前要先清空旧的日期
  613. sCell.Value = '';
  614. }
  615. for (const sCell of page.signature_date_cells) {
  616. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  617. sCell.Value = _getSignDateDftName();
  618. if (role_rel.sign_date !== '') {
  619. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  620. }
  621. }
  622. }
  623. }
  624. }
  625. } else {
  626. // 流程的处理不一样
  627. }
  628. }
  629. }
  630. },
  631. _commonRefreshAfterSelectSignature: async function(signatureDivId) {
  632. //0. 签名日期
  633. rptSignatureHelper.resetSignDate(signatureDivId);
  634. rptSignatureHelper.resetSignAudit();
  635. //1. 重刷page(不用考虑审核状态)
  636. for (const page of zTreeOprObj.currentRptPageRst.items) {
  637. if (page.signature_cells) {
  638. for (let cIdx = page.signature_cells.length - 1; cIdx >= 0; cIdx--) {
  639. const sCell = page.signature_cells[cIdx];
  640. if (sCell.isStamp) {
  641. page.signature_cells.splice(cIdx);
  642. } else if (sCell.hasOwnProperty('pre_path')) {
  643. sCell.path = sCell.pre_path;
  644. delete sCell.pre_path;
  645. }
  646. }
  647. }
  648. }
  649. resetStampSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3, STAGE_AUDIT, LEDGER_LIST);
  650. rptSignatureHelper.mergeSignDate(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
  651. rptSignatureHelper.mergeSignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
  652. await rptSignatureHelper.resetDummySignature(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, getStageStatus() !== 3);
  653. // rptSignatureHelper.mergeSignAudit(zTreeOprObj.currentRptPageRst, ROLE_REL_LIST, STAGE_AUDIT, getStageStatus() !== 3);
  654. if (PAGE_SHOW.isTextSignature) {
  655. resetTextSignature(zTreeOprObj.currentRptPageRst, getStageStatus() !== 3);
  656. }
  657. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  658. },
  659. _getCommonParams: function() {
  660. const params = {};
  661. params.id = CURRENT_ROLE_REL_ID;
  662. params.tender_id = TENDER_ID;
  663. params.stage_id = getStageId();
  664. params.business_id = BUSINESS_ID;
  665. params.source_type = SOURCE_TYPE;
  666. params.rpt_id = zTreeOprObj.currentNode.refId;
  667. // params.rel_content = ROLE_REL_LIST;
  668. params.rel_content = [];
  669. ROLE_REL_LIST.forEach(role_rel => {
  670. if (role_rel.signature_name.indexOf('dummy_pic') < 0) {
  671. params.rel_content.push(role_rel);
  672. }
  673. });
  674. return params;
  675. },
  676. setupAfterSelectMultiChanges: async function (selectedChanges, signatureDivId) {
  677. // 多变更令选择
  678. await this._commonRefreshAfterSelectSignature(signatureDivId);
  679. const params = this._getCommonParams();
  680. params.selectedChanges = selectedChanges;
  681. const new_ROLE_REL_LIST = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  682. new_ROLE_REL_LIST.forEach(nrole => {
  683. nrole.sign_pic = null;
  684. });
  685. params.rel_content = new_ROLE_REL_LIST;
  686. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  687. CommonAjax.postXsrfEx("/tender/report_api/updateMultiChangesRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  688. function(result){
  689. $.bootstrapLoading.end();
  690. if (result.data && result.data.insertId > 0) {
  691. CURRENT_ROLE_REL_ID = result.data.insertId;
  692. }
  693. }, function(err){
  694. $.bootstrapLoading.end();
  695. }, function(ex){
  696. $.bootstrapLoading.end();
  697. }
  698. );
  699. },
  700. setupAfterSelectMultiOther: async function (selectedOther, signatureDivId) {
  701. // 多变更令选择
  702. await this._commonRefreshAfterSelectSignature(signatureDivId);
  703. const params = this._getCommonParams();
  704. params.stg_id = STAGE_ID;
  705. params.selected = selectedOther;
  706. const new_ROLE_REL_LIST = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  707. new_ROLE_REL_LIST.forEach(nrole => {
  708. nrole.sign_pic = null;
  709. });
  710. params.rel_content = new_ROLE_REL_LIST;
  711. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  712. CommonAjax.postXsrfEx("/tender/report_api/updateMultiOtherRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  713. function(result){
  714. $.bootstrapLoading.end();
  715. if (result.data && result.data.insertId > 0) {
  716. CURRENT_ROLE_REL_ID = result.data.insertId;
  717. }
  718. }, function(err){
  719. $.bootstrapLoading.end();
  720. }, function(ex){
  721. $.bootstrapLoading.end();
  722. }
  723. );
  724. },
  725. setupAfterSelectMultiTenders: async function (selectedTenders, signatureDivId) {
  726. // 跨标段选择,有不少要注意的交互:
  727. await this._commonRefreshAfterSelectSignature(signatureDivId);
  728. //2. 集中请求
  729. const params = this._getCommonParams();
  730. params.selectedTenders = selectedTenders;
  731. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  732. $.bootstrapLoading.start();
  733. CommonAjax.postXsrfEx("/tender/report_api/updateMultiRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  734. function(result){
  735. $.bootstrapLoading.end();
  736. if (result.data && result.data.insertId > 0) {
  737. CURRENT_ROLE_REL_ID = result.data.insertId;
  738. }
  739. }, function(err){
  740. $.bootstrapLoading.end();
  741. }, function(ex){
  742. $.bootstrapLoading.end();
  743. }
  744. );
  745. },
  746. _parseRoleRelList: function(org_rel_content) {
  747. const rst = JSON.parse(org_rel_content);
  748. for (const role_rel of rst) {
  749. if (role_rel.sign_date !== null && role_rel.sign_date !== undefined && role_rel.sign_date.length >= 8) {
  750. role_rel.sign_date = new Date(role_rel.sign_date);
  751. }
  752. }
  753. return rst;
  754. },
  755. setupAfterSelectSignature: async function (signatureDivId) {
  756. //0. 签名日期
  757. let me = rptSignatureHelper;
  758. await this._commonRefreshAfterSelectSignature(signatureDivId);
  759. //2. 更新数据
  760. const params = this._getCommonParams();
  761. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(params.rel_content));
  762. $.bootstrapLoading.start();
  763. CommonAjax.postXsrfEx("/tender/report_api/updateRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
  764. async function(result){
  765. // console.log(result);
  766. $.bootstrapLoading.end();
  767. if (result.data && result.data.insertId > 0) {
  768. CURRENT_ROLE_REL_ID = result.data.insertId;
  769. }
  770. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  771. CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  772. ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  773. // 原本要刷新的,但在前面的_commonRefreshAfterSelectSignature方法中已经处理好了,无需重复
  774. } else {
  775. // CURRENT_ROLE_REL_ID = -1;
  776. ROLE_REL_LIST = [];
  777. }
  778. }, function(err){
  779. // hintBox.unWaitBox();
  780. $.bootstrapLoading.end();
  781. }, function(ex){
  782. // hintBox.unWaitBox();
  783. $.bootstrapLoading.end();
  784. }
  785. );
  786. },
  787. switchAddRoleDiv: function (dom) {
  788. if (dom.nextElementSibling.children[0].style.display === 'none') {
  789. dom.nextElementSibling.children[0].style.display = '';
  790. } else {
  791. dom.nextElementSibling.children[0].style.display = 'none';
  792. }
  793. },
  794. createNewRole: function (dom) {
  795. if ($('#acc_role_name')[0].value !== '') {
  796. const params = {};
  797. params.name = $('#acc_role_name')[0].value;
  798. const selectedAcc = PRJ_ACCOUNT_LIST[$('#project_account_select_dom')[0].selectedOptions[0].value];
  799. const roleName = (selectedAcc.role === '')?DFT_ROLE_NAME:selectedAcc.role;
  800. params.bind_acc_id = selectedAcc.id;
  801. params.prj_id = PROJECT_ID;
  802. params.tender_id = TENDER_ID;
  803. CommonAjax.postXsrfEx("/tender/report_api/createSignatureRole", params, 10000, true, getCookie('csrfToken_j'),
  804. function(result){
  805. console.log(result);
  806. const newRole = {};
  807. newRole.name = params.name;
  808. newRole.bind_acc_id = selectedAcc.id;
  809. newRole.prj_id = PROJECT_ID;
  810. newRole.tender_id = TENDER_ID;
  811. ROLE_LIST.push(newRole);
  812. const domArr = [];
  813. domArr.push('<li class="add-sign-list-item">');
  814. //1. apply签名
  815. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + (ROLE_LIST.length - 1) +')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  816. domArr.push('<i class="fa fa-plus"></i>');
  817. domArr.push('</a>');
  818. //2. 编辑角色(暂缓处理click事件)
  819. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  820. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  821. domArr.push('</a>');
  822. //3. 显示名称
  823. domArr.push('<i class="fa fa-user"></i> ' + $('#acc_role_name')[0].value + '<p>' + selectedAcc.name + '-<small class="text-muted">' + roleName + '</small></p>');
  824. $('#existed_roles_ul').append(domArr.join(' '));
  825. }, function(err){
  826. // hintBox.unWaitBox();
  827. }, function(ex){
  828. // hintBox.unWaitBox();
  829. }
  830. );
  831. } else {
  832. alert('请输入合适的名称!');
  833. }
  834. },
  835. buildRoleDom: function (roleList) {
  836. const ulDom = $('#existed_roles_ul');
  837. ulDom.empty();
  838. for (let domIdx = 0; domIdx < roleList.length; domIdx++) {
  839. const role = roleList[domIdx];
  840. const domArr = [];
  841. domArr.push('<li class="add-sign-list-item">');
  842. //1. apply签名
  843. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + domIdx + ')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  844. domArr.push('<i class="fa fa-plus"></i>');
  845. domArr.push('</a>');
  846. //2. 编辑角色(暂缓)
  847. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  848. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  849. domArr.push('</a>');
  850. //3. 显示名称
  851. let acc = rptSignatureHelper.getUserAccount(role.bind_acc_id);
  852. 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>');
  853. ulDom.append(domArr.join(' '));
  854. }
  855. },
  856. getUserAccount: function (accId) {
  857. let rst = null;
  858. for (const acc of PRJ_ACCOUNT_LIST) {
  859. if (acc.id === accId) {
  860. rst = acc;
  861. break;
  862. }
  863. }
  864. return rst;
  865. },
  866. _getCompanySign: function(companyName) {
  867. let rst = '';
  868. for (const cUnit of CONSTRUCT_UNIT_LIST) {
  869. if (cUnit.name === companyName) {
  870. rst = cUnit.sign_path;
  871. break;
  872. }
  873. }
  874. return rst;
  875. },
  876. mergeSignature: function (pageData, currRoleRelList, setPic = false, checkAudit = false) {
  877. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  878. const page = pageData.items[pageIdx];
  879. if (page.signature_cells) {
  880. // const adHocScells = [];
  881. for (const sCell of page.signature_cells) {
  882. if (sCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0) {
  883. sCell.path = null;
  884. sCell.pre_path = null;
  885. sCell.pic = null;
  886. }
  887. for (const role of currRoleRelList) {
  888. const role_rel = getTheRightRole(role, pageIdx);
  889. if (!checkAudit || checkAudit && rptSignatureHelper._chkIfAudit(role_rel)) {
  890. // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示
  891. if (role_rel.signature_name === sCell.signature_name) {
  892. // 处理签章
  893. if (!Array.isArray(role_rel.sign_output)) {
  894. role_rel.sign_output = [];
  895. role_rel.sign_output.push(NORMAL_SIGN_STR);
  896. }
  897. for (const signType of role_rel.sign_output) {
  898. switch (signType) {
  899. case NORMAL_SIGN_STR:
  900. sCell.path = role_rel.sign_path;
  901. sCell.pre_path = role_rel.sign_path;
  902. if (setPic) {
  903. sCell.pic = role_rel.sign_pic; // 有些场景(如:批量归档)需要直接设置签名数据
  904. }
  905. break;
  906. case COMPANY_SIGN_STR:
  907. case PRIVATE_SIGN_STR:
  908. // 搬到了mergetStamp方法那去处理了
  909. break;
  910. default:
  911. break;
  912. }
  913. }
  914. break;
  915. }
  916. }
  917. }
  918. }
  919. // page.signature_cells = page.signature_cells.concat(adHocScells);
  920. }
  921. }
  922. },
  923. resetDummySignature: async function(pageData, roleRels, ifPushRoleRel = false, checkAudit = false) {
  924. // 备注:计算草图等其他图形需要额外做些处理
  925. let dummySignIdx = 0;
  926. const stampPicKeys = [], stampPicFeatures = [];
  927. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  928. const page = pageData.items[pageIdx];
  929. if (page[JV.PROP_SIGNATURE_CELLS] && page[JV.PROP_SIGNATURE_CELLS].length > 0) {
  930. for (const signatureCell of page[JV.PROP_SIGNATURE_CELLS]) {
  931. if (signatureCell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
  932. let passAuditChk = true;
  933. if (checkAudit) {
  934. passAuditChk = false;
  935. if (roleRels) {
  936. for (const role of roleRels) {
  937. const role_rel = getTheRightRole(role, pageIdx);
  938. if (role_rel.signature_name === signatureCell.signatureName) {
  939. // signatureName(非signature_name)是印章cell特意给的属性,还有isStamp属性
  940. if (rptSignatureHelper._chkIfAudit(role_rel)) {
  941. passAuditChk = true;
  942. break;
  943. }
  944. }
  945. }
  946. }
  947. }
  948. if (passAuditChk) {
  949. // 表示这是一个其他类型的非原生电子签名图,只是借用signature的处理机制,每个图都是唯一的,所以需要重新给个唯一的新signature_name
  950. // signatureCell.signature_name = signatureCell.signature_name + '_' + pageIdx + '_' + dummySignIdx;
  951. signatureCell.signature_name = signatureCell.signature_name + '_' + page.page_seq + '_' + dummySignIdx; // page_seq在分页后都不会变动
  952. dummySignIdx++;
  953. const roleRelItem = { type: '用户', sign_path: signatureCell.path, signature_name: signatureCell.signature_name };
  954. if (signatureCell.isStamp) {
  955. let stmpIdx = stampPicKeys.indexOf(signatureCell.path);
  956. if (stampPicKeys.indexOf(signatureCell.path) < 0) {
  957. stampPicKeys.push(signatureCell.path);
  958. stmpIdx = stampPicKeys.length - 1;
  959. const picRes = await getHttpBlobText(signatureCell.path + '?x-oss-process=image/info');
  960. stampPicFeatures.push(picRes);
  961. }
  962. // { "FileSize": {"value": "2514"}, "Format": {"value": "png"}, "ImageHeight": {"value": "94"}, "ImageWidth": {"value": "94"} }
  963. roleRelItem.stampFeature = stampPicFeatures[stmpIdx];
  964. // 重新处理cell坐标
  965. // 如果签章信息中存在位置信息,则不执行该方法
  966. if(!signatureCell.isSaveSignature) _resetStampArea(pageData[JV.NODE_CONTROL_COLLECTION][signatureCell[JV.PROP_CONTROL]], signatureCell, roleRelItem);
  967. }
  968. if (ifPushRoleRel) roleRels.push(roleRelItem);
  969. }
  970. }
  971. }
  972. }
  973. }
  974. },
  975. mergeSignAudit: function (pageData, currRoleRelList, currAuditList, checkAudit = false) {
  976. const reg1 = new RegExp('\n\r', 'g');
  977. const reg2 = new RegExp('\r\n', 'g');
  978. const reg3 = new RegExp('\n', 'g');
  979. const reg4 = new RegExp('\r', 'g');
  980. const reg5 = new RegExp('<br/>', 'g');
  981. const reg6 = new RegExp('<br>', 'g');
  982. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  983. const page = pageData.items[pageIdx];
  984. if (page.signature_audit_cells) {
  985. for (const sCell of page.signature_audit_cells) {
  986. sCell.Value = ''; // 这里要先清除原有信息
  987. for (const role of currRoleRelList) {
  988. const role_rel = getTheRightRole(role, pageIdx);
  989. if (!checkAudit || checkAudit && rptSignatureHelper._chkIfAudit(role_rel)) {
  990. // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示
  991. if (sCell.signature_name === role_rel.signature_name + '_审核意见') {
  992. let preDate = '';
  993. sCell.Value = '同意'; // 只有选择了签名的,才需要初始化一个默认的意见(之前的逻辑在有多个签名,哪怕只选择了一个,其他的意见都会有默认意见)
  994. for (const audit_rel of currAuditList) {
  995. if (role_rel.acc_id === audit_rel.aid) {
  996. const isOrAudit = this._chkOrAudit(role_rel.acc_id);
  997. if (audit_rel.end_time > preDate && audit_rel.status === 3 || isOrAudit) {
  998. sCell.Value = audit_rel.opinion;
  999. if (typeof sCell.Value === 'string') {
  1000. sCell.Value = sCell.Value.replace(reg1, '|').replace(reg2, '|').replace(reg3, '|').replace(reg4, '|').replace(reg5, '|').replace(reg6, '|');
  1001. }
  1002. sCell.Value = (sCell.Value === '' && isOrAudit) ? '同意' : sCell.Value;
  1003. preDate = audit_rel.end_time;
  1004. } else {
  1005. sCell.Value = ''; // 如有匹配,但又不能输出,则需要清空
  1006. }
  1007. //不能break,实际会有多个审核意见,以最后一个为准
  1008. }
  1009. }
  1010. break;
  1011. }
  1012. }
  1013. }
  1014. }
  1015. }
  1016. }
  1017. },
  1018. _setDftDate: function (role_rel, isMergeOrgAlso = false) {
  1019. if (role_rel.acc_id && (role_rel.sign_date === undefined || role_rel.sign_date === null || role_rel.sign_date === '')) {
  1020. let dftDate = _getSignDateByAllScenarios(role_rel.acc_id);
  1021. if (dftDate !== '' && dftDate.length >= 10) {
  1022. dftDate = new Date(dftDate); // 不Format,保留时分秒
  1023. } else if (dftDate === '') {
  1024. if (current_stage_id <= -300 && current_stage_id > -400 && BGL_OBJ && BGL_OBJ.currentBz && BGL_OBJ.currentBz.status === 3) {
  1025. if (STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  1026. dftDate = new Date(STAGE_AUDIT[STAGE_AUDIT.length - 1].end_time);
  1027. } else {
  1028. dftDate = new Date();
  1029. }
  1030. } else {
  1031. dftDate = new Date();
  1032. }
  1033. }
  1034. role_rel.sign_date = dftDate;
  1035. if (isMergeOrgAlso) {
  1036. for (const orgRR of rptSignatureHelper.originalRoleRelList) {
  1037. if (orgRR.signature_name === role_rel.signature_name) {
  1038. orgRR.sign_date = dftDate;
  1039. break;
  1040. }
  1041. }
  1042. // rptSignatureHelper.originalRoleRelList[rridx].sign_date = dftDate; // 这个在实际情况下originalRoleRelList不一定与currRoleRelList一致
  1043. //备注:在多选导出的情况下,originalRoleRelList不需要merge
  1044. }
  1045. }
  1046. },
  1047. mergeSignDate: function (pageData, currRoleRelList, isMergeOrgAlso, checkAudit = false) {
  1048. if (currRoleRelList && currRoleRelList.length > 0 && STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  1049. for (let rridx = 0; rridx < currRoleRelList.length; rridx++) {
  1050. const role_rel = currRoleRelList[rridx];
  1051. if (role_rel.type !== '流程') {
  1052. rptSignatureHelper._setDftDate(role_rel, isMergeOrgAlso);
  1053. }
  1054. }
  1055. }
  1056. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1057. const page = pageData.items[pageIdx];
  1058. if (page.signature_date_cells) {
  1059. for (const sCell of page.signature_date_cells) {
  1060. if (typeof sCell.Value === 'string' && sCell.Value.replace(/ /g, '') === '年月日') {
  1061. sCell.Value = _getSignDateDftName();
  1062. } else {
  1063. sCell.Value = '';
  1064. }
  1065. for (const role of currRoleRelList) {
  1066. const role_rel = getTheRightRole(role, pageIdx);
  1067. if (role.type === '流程') rptSignatureHelper._setDftDate(role_rel, false);
  1068. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  1069. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1070. // 如果签名者是在审核流程中并已审批通过(个人通过,非期通过),则也需要显示
  1071. if (role_rel.sign_date !== '') {
  1072. if (typeof role_rel.sign_date === 'string') {
  1073. role_rel.sign_date = new Date(role_rel.sign_date);
  1074. }
  1075. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  1076. }
  1077. }
  1078. break;
  1079. }
  1080. }
  1081. }
  1082. }
  1083. }
  1084. },
  1085. _chkOrAudit: function(acc_id) {
  1086. // 检测 '或签' 情况下的审核状态(在或签情况下,另一个审核通过,那么这个也是通过的)
  1087. let rst = false;
  1088. for (const flow of STAGE_FLOW) {
  1089. if (flow.aid === acc_id) {
  1090. if (flow.audit_type === 3) {
  1091. // 判断 或签 用户状态
  1092. for (const secFlow of STAGE_FLOW) {
  1093. if (secFlow.audit_type === 3 && secFlow.order === flow.order && secFlow.aid !== acc_id) {
  1094. rst = secFlow.status === 3 || flow.status === 3;
  1095. if (rst) break;
  1096. }
  1097. }
  1098. }
  1099. break;
  1100. }
  1101. }
  1102. return rst;
  1103. },
  1104. _chkIfAudit: function(role_rel) {
  1105. // 检测是否在审核列表中
  1106. let rst = false;
  1107. for (const stg_audit of STAGE_AUDIT) {
  1108. if (role_rel.acc_id === stg_audit.aid) {
  1109. if (stg_audit.status === 3) {
  1110. rst = true;
  1111. } else {
  1112. rst = false;
  1113. }
  1114. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  1115. }
  1116. }
  1117. if (!rst && current_stage_id > 0) {
  1118. // 还有原报需要检测(这里是计量期单独的判断)
  1119. for (const stg_ort_rpt of STAGE_LIST) {
  1120. if (stg_ort_rpt.id === current_stage_id && role_rel.acc_id === stg_ort_rpt.user_id) {
  1121. if (stg_ort_rpt.status !== 1 && stg_ort_rpt.status !== 4) {
  1122. // 只要不是待上报(1)、退回审批(4) 状态,都需要显示
  1123. rst = true;
  1124. } else {
  1125. rst = false;
  1126. }
  1127. break;
  1128. }
  1129. }
  1130. if (!rst) {
  1131. rst = this._chkOrAudit(role_rel.acc_id);
  1132. }
  1133. }
  1134. // rst = true; //测试,未来将屏蔽
  1135. return rst;
  1136. },
  1137. _chkIfOrgRpt: function(acc_id) {
  1138. // 检测是否原报
  1139. let rst = false;
  1140. for (const stg of STAGE_LIST) {
  1141. if (stg.id === current_stage_id) {
  1142. if (stg.user_id === acc_id) {
  1143. rst = true;
  1144. }
  1145. break;
  1146. }
  1147. }
  1148. return rst;
  1149. },
  1150. _cancelFlowSignDate: function(signature_name) {
  1151. for (const roleRel of ROLE_REL_LIST) {
  1152. if (roleRel.signature_name === signature_name && roleRel.type === '流程') {
  1153. roleRel.assFlowInfos.forEach((asf, index) => {
  1154. const fdtpId = `flowdtp_${signature_name}_${index}`;
  1155. let dtDom = document.getElementById(fdtpId); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象
  1156. if (dtDom) {
  1157. dtDom.value = asf.sign_date || '';
  1158. }
  1159. });
  1160. }
  1161. }
  1162. },
  1163. _saveFlowSignDate: function(signature_name) {
  1164. for (const roleRel of ROLE_REL_LIST) {
  1165. if (roleRel.signature_name === signature_name && roleRel.type === '流程') {
  1166. roleRel.assFlowInfos.forEach((asf, index) => {
  1167. const fdtpId = `flowdtp_${signature_name}_${index}`;
  1168. let dtDom = document.getElementById(fdtpId); // 考虑到signature_name有括号的情况下,用jQuery会出异常,换成传统的方式取dom对象
  1169. if (dtDom) {
  1170. asf.sign_date = dtDom.value;
  1171. }
  1172. });
  1173. }
  1174. }
  1175. },
  1176. _changeSignType: function(dom, signature_name, chkStr, userStamp, flowIndex = -1) {
  1177. for (const roleRel of ROLE_REL_LIST) {
  1178. if (roleRel.signature_name === signature_name) {
  1179. let newRoleRel = roleRel;
  1180. if (roleRel.type === '流程') {
  1181. newRoleRel = roleRel.assFlowInfos[flowIndex];
  1182. }
  1183. if (dom.checked) {
  1184. if (newRoleRel.sign_output.indexOf(chkStr) < 0) {
  1185. newRoleRel.sign_output.push(chkStr);
  1186. }
  1187. if(chkStr==='private_stamp' && !newRoleRel.private_stamp_path && userStamp){
  1188. newRoleRel.private_stamp_path = userStamp.split('!;!')[0] ;
  1189. // console.log(newRoleRel.private_stamp_path);
  1190. }
  1191. } else {
  1192. let idx = newRoleRel.sign_output.indexOf(chkStr);
  1193. if (idx >= 0) {
  1194. newRoleRel.sign_output.splice(idx, 1);
  1195. }
  1196. }
  1197. break;
  1198. }
  1199. }
  1200. },
  1201. _resetStampPos: function(orgCell, targetCell, controls) {
  1202. const ctrl = controls[orgCell.control];
  1203. let pLeft = orgCell.area.Left, pTop = orgCell.area.Top;
  1204. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
  1205. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
  1206. pLeft = orgCell.area.Left;
  1207. break;
  1208. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
  1209. pLeft = (orgCell.area.Left + orgCell.area.Right - STD_STAMP_SIZE_WIDTH) / 2 ;
  1210. break;
  1211. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
  1212. pLeft = orgCell.area.Right - STD_STAMP_SIZE_WIDTH;
  1213. break;
  1214. }
  1215. switch(ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
  1216. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_TOP]:
  1217. pTop = orgCell.area.Top;
  1218. break;
  1219. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_CENTER]:
  1220. pTop = (orgCell.area.Top + orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT) / 2 ;
  1221. break;
  1222. case JV.OUTPUT_ALIGN.H[JV.V_ALIGN_IDX_BOTTOM]:
  1223. pTop = orgCell.area.Bottom - STD_STAMP_SIZE_HEIGHT;
  1224. break;
  1225. }
  1226. targetCell.area.Left = pLeft;
  1227. targetCell.area.Top = pTop;
  1228. targetCell.area.Right = pLeft + STD_STAMP_SIZE_WIDTH;
  1229. targetCell.area.Bottom = pTop + STD_STAMP_SIZE_HEIGHT;
  1230. },
  1231. initChosePrivateStampPath:function(stampPathList, signature_name, flowIndex = -1){
  1232. let currentStamp='';
  1233. const targetNode= ROLE_REL_LIST.find(item=>item.signature_name===signature_name);
  1234. if (targetNode) {
  1235. if (targetNode.type === '流程') {
  1236. currentStamp = targetNode.assFlowInfos[flowIndex].private_stamp_path;
  1237. } else {
  1238. currentStamp = targetNode.private_stamp_path;
  1239. }
  1240. }
  1241. let content=`<div class='row justify-content-md-center'>`;
  1242. stampPathList.split('!;!').forEach(item=>{
  1243. content+=`<div class="card col-3 p-2 m-3 d-flex ${currentStamp===item?'card-gk-active':''} stamp-img">
  1244. <div class="p-0 private-stamp-img">
  1245. <div class="sel-width check-state ${currentStamp===item?'sel-blue':''} "></div>
  1246. <img src="${rptSignatureHelper.fujianOssPath}${item}" data-src='${item}' class="img-fluid" alt="...">
  1247. </div>
  1248. </div>`;
  1249. })
  1250. for(let i=0;i<stampPathList.length%3;i++){
  1251. content+=`<div class="col-3 p-2 m-3"></div>`;
  1252. }
  1253. content+=` </div><div class='privateStampRoleName' data-name='${signature_name}'></div>`;
  1254. content += `<div class='privateStampFlowIndex' data-name='${flowIndex}'></div>`;
  1255. $('#chose-private-stamp-path .modal-body').empty().append(content);
  1256. $('.stamp-img').on('click',(e)=>{
  1257. $('.stamp-img').removeClass('card-gk-active');
  1258. $('.stamp-img').find('.sel-width').removeClass('sel-blue');
  1259. $(e.currentTarget).addClass('card-gk-active');
  1260. $(e.currentTarget).find('.sel-width').addClass('sel-blue');
  1261. })
  1262. },
  1263. setPrivateStamp(e, flowIndex = -1){
  1264. const imgSrc= $('.stamp-img.card-gk-active').find('.img-fluid').data('src');
  1265. const privateStampRoleName=$('.privateStampRoleName').data('name');
  1266. const targetNode= ROLE_REL_LIST.find(item=>item.signature_name==privateStampRoleName);
  1267. if (targetNode.type = '流程') {
  1268. const flowIndex = +($('.privateStampFlowIndex').data('name'));
  1269. targetNode.assFlowInfos[flowIndex].private_stamp_path = imgSrc;
  1270. } else {
  1271. targetNode.private_stamp_path = imgSrc;
  1272. }
  1273. $('#chose-private-stamp-path').modal('hide');
  1274. },
  1275. _get_newPrivate_stamp_path(roleRelObj,userAcc) {
  1276. if (!roleRelObj.private_stamp_path) {
  1277. if (!userAcc.stamp_path) return '';
  1278. if (userAcc.stamp_path.split('!;!').length === 1) {
  1279. return userAcc.stamp_path;
  1280. }else{
  1281. return userAcc.stamp_path.split('!;!')[0];
  1282. }
  1283. }
  1284. return roleRelObj.private_stamp_path;
  1285. }
  1286. }
  1287. function _getSignDateByAllScenarios(userAccId) {
  1288. let rst = '';
  1289. let hasAudit = false;
  1290. for (const stg_audit of STAGE_AUDIT) {
  1291. // 或签的也会在此 STAGE_AUDIT 列里面
  1292. if (stg_audit.aid === userAccId) {
  1293. hasAudit = true;
  1294. // 加上 '或签' 检测
  1295. if (stg_audit.status === 3 || rptSignatureHelper._chkOrAudit(stg_audit.aid)) {
  1296. rst = stg_audit.end_time;
  1297. }
  1298. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  1299. }
  1300. }
  1301. let isOrgRpt = false;
  1302. for (const stg of STAGE_LIST) {
  1303. if (stg.id === current_stage_id) {
  1304. if (stg.user_id === userAccId) {
  1305. isOrgRpt = true;
  1306. }
  1307. break;
  1308. }
  1309. }
  1310. if (isOrgRpt && !hasAudit && STAGE_AUDIT_ORG && STAGE_AUDIT_ORG.length > 0) {
  1311. if (STAGE_AUDIT_ORG[0].begin_time && STAGE_AUDIT_ORG[0].begin_time !== '' && STAGE_AUDIT_ORG[0].begin_time.length > 20) {
  1312. rst = STAGE_AUDIT_ORG[0].begin_time;
  1313. }
  1314. }
  1315. if (!isOrgRpt && !hasAudit) {
  1316. // 非审批流程人员以及非原报,则显示期截至时间
  1317. // 之前给我的解释有问题的,不应该找stage的period属性,而是找当期最后一个status===3的end_time时间(STAGE_AUDIT已经取了最后times,并已排序了)
  1318. for (const stg_audit of STAGE_AUDIT) {
  1319. if (stg_audit.status === 3) {
  1320. rst = stg_audit.end_time;
  1321. }
  1322. }
  1323. }
  1324. return rst;
  1325. }
  1326. function _getStatusByUserId(userAccId) {
  1327. let rst = -1;
  1328. for (const stg_audit of STAGE_AUDIT) {
  1329. // 或签的也会在此 STAGE_AUDIT 列里面
  1330. if (stg_audit.aid === userAccId) {
  1331. rst = stg_audit.status;
  1332. // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
  1333. }
  1334. }
  1335. return rst;
  1336. }
  1337. function _getSignDateDftName() {
  1338. return ' 年 月 日';
  1339. }
  1340. function _createDummyCell() {
  1341. const rst = {
  1342. font: 'Footer',
  1343. control: 'Footer',
  1344. style: 'Default_None',
  1345. Value: '',
  1346. area: { Left: 0, Right: 0, Top: 0, Bottom: 0 },
  1347. };
  1348. return rst;
  1349. }
  1350. function prepareRightFlowRoles(pageData, roleRelList = [], stg_audit = [], ledgerList = []) {
  1351. // 争取在这里一次过把所有页面的流程签名数据整理完毕,方便后面的工序能简单处理
  1352. const flowRole = roleRelList.find(role => { return role.type === '流程'; });
  1353. for (const role of roleRelList) {
  1354. if (role.type === '流程') role.flowAccList = []; // 这里直接清理流程签名信息
  1355. }
  1356. if (flowRole) {
  1357. const ledgerCache = {}; // 生成台账信息cache对象,提高查找效率
  1358. ledgerList.forEach(ledger => {
  1359. ledgerCache[ledger.id] = ledger;
  1360. ledgerCache[`_${ledger.ledger_id}`] = ledger;
  1361. })
  1362. const auditCache = {}; // 生成stage审核cache对象,提高查找效率
  1363. stg_audit.forEach(audit => {
  1364. if (audit.audit_type === 4) {
  1365. auditCache[`_${audit.aid}`] = `${audit.audit_ledger_id}`; // 统一用string类型来判断
  1366. }
  1367. });
  1368. const _chkMultiAuditFlow = (assFlowRole, page) => {
  1369. let rst = false;
  1370. const idStr = `${auditCache[`_${assFlowRole.acc_id}`]}`;
  1371. const idStrs = idStr.split(',');
  1372. for (const key of idStrs) {
  1373. const rootLedgerPath = ledgerCache[`_${key}`].full_path || '';
  1374. const thisLedgerPath = ledgerCache[page.extend_flow_options].full_path || '';
  1375. if (thisLedgerPath.indexOf(rootLedgerPath) === 0) {
  1376. rst = true;
  1377. break;
  1378. }
  1379. }
  1380. return rst;
  1381. };
  1382. pageData.items.forEach((page, index) => {
  1383. if (page.extend_flow_options && page.extend_flow_options !== '') {
  1384. for (const role of roleRelList) {
  1385. if (role.type === '流程') {
  1386. role.flowAccList.push(-1); // !!! 每一页都要有一个流程签名指引,-1表示没有
  1387. let preLen = -1; //
  1388. for (let assIdx = 0; assIdx < role.assFlowInfos.length; assIdx++) {
  1389. const assRole = role.assFlowInfos[assIdx];
  1390. if (auditCache[`_${assRole.acc_id}`]) {
  1391. if (_chkMultiAuditFlow(assRole, page)) {
  1392. role.flowAccList[role.flowAccList.length - 1] = assIdx;
  1393. const thisLedgerPath = ledgerCache[page.extend_flow_options].full_path || '';
  1394. if (thisLedgerPath.length > preLen) {
  1395. preLen = thisLedgerPath.length; // 还要考虑到嵌套的情况
  1396. } else break;
  1397. }
  1398. }
  1399. }
  1400. }
  1401. }
  1402. }
  1403. // role.flowAccList
  1404. });
  1405. }
  1406. }
  1407. function getTheRightRole(role, pageIdx) {
  1408. let rst = role;
  1409. if (role.type === '流程') {
  1410. if (role.flowAccList && role.flowAccList.length > pageIdx) {
  1411. if (role.flowAccList[pageIdx] !== -1) {
  1412. rst = role.assFlowInfos[role.flowAccList[pageIdx]];
  1413. }
  1414. }
  1415. }
  1416. return rst;
  1417. }
  1418. function resetStampSignature(pageData, roleRelList, checkAudit = false, stg_audit = [], ledgerList = []) {
  1419. prepareRightFlowRoles(pageData, roleRelList, stg_audit, ledgerList);
  1420. const dupPicPaths = [];
  1421. const _getMaxRect = function(page) {
  1422. const rect = [100000000, 100000000, 0, 0];
  1423. for (const cell of page.cells) {
  1424. rect[0] = rect[0] > cell.area.Left ? cell.area.Left : rect[0];
  1425. rect[1] = rect[1] > cell.area.Top ? cell.area.Top : rect[1];
  1426. rect[2] = rect[2] < cell.area.Right ? cell.area.Right : rect[2];
  1427. rect[3] = rect[3] < cell.area.Bottom ? cell.area.Bottom : rect[3];
  1428. }
  1429. return rect;
  1430. };
  1431. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1432. const page = pageData.items[pageIdx];
  1433. const maxRect = _getMaxRect(page);
  1434. if (page.signature_cells) {
  1435. const newStampCells = [];
  1436. for (let scIdx = 0; scIdx < page.signature_cells.length; scIdx++) {
  1437. const sCell = page.signature_cells[scIdx];
  1438. for (const role of roleRelList) {
  1439. const role_rel = getTheRightRole(role, pageIdx);
  1440. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1441. if (sCell.signature_name === role_rel.signature_name) {
  1442. if (Array.isArray(role_rel.sign_output) && role_rel.sign_output.length > 0) {
  1443. for (const signType of role_rel.sign_output) {
  1444. switch (signType) {
  1445. case COMPANY_SIGN_STR:
  1446. case PRIVATE_SIGN_STR:
  1447. // 创建一个新的cell
  1448. let stampPath = (signType === COMPANY_SIGN_STR) ? role_rel.company_stamp_path : role_rel.private_stamp_path;
  1449. stampPath = OSS_PATH + stampPath;
  1450. if (dupPicPaths.indexOf(stampPath) < 0) {
  1451. dupPicPaths.push(stampPath);
  1452. }
  1453. // 签字信息中如果有签章位置信息,则直接用位置信息
  1454. let signatureArea;
  1455. if (role_rel.areaData && role_rel.areaData[signType]){
  1456. signatureArea = role_rel.areaData[signType]
  1457. }
  1458. const newStampCell = {
  1459. signature_name: JV.SIGNATURE_NAME_DUMMY,
  1460. control: sCell.control,
  1461. style: sCell.style,
  1462. path: stampPath,
  1463. isStamp: true,
  1464. maxRect,
  1465. orgArea: sCell.area,
  1466. area: signatureArea || {Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom},
  1467. signatureName: role_rel.signature_name, // 节点名称
  1468. signType, // 签章信息
  1469. isSaveSignature: !!signatureArea, // 是否有签章位置信息
  1470. };
  1471. newStampCells.push(newStampCell);
  1472. break;
  1473. default: break;
  1474. }
  1475. }
  1476. }
  1477. }
  1478. }
  1479. }
  1480. }
  1481. if (newStampCells.length > 0) {
  1482. newStampCells.forEach(newSCell => {
  1483. // 因后台也已生成过签章,这里再生成的话会重复,需要删除(但在多期同时计量,原报签章在刷新后会丢失,所以需要这里再补上,见2024/09/18修改)
  1484. for (let sIdx = 0; sIdx < page.signature_cells.length; sIdx++) {
  1485. if (page.signature_cells[sIdx].path === newSCell.path) {
  1486. page.signature_cells.splice(sIdx, 1);
  1487. break;
  1488. }
  1489. }
  1490. });
  1491. page.signature_cells = page.signature_cells.concat(newStampCells);
  1492. }
  1493. }
  1494. }
  1495. }
  1496. function resetTextSignature(pageData, checkAudit = false) {
  1497. for (let pageIdx = 0; pageIdx < pageData.items.length; pageIdx++) {
  1498. const page = pageData.items[pageIdx];
  1499. for (let sCell of page.signature_cells) {
  1500. if (!sCell.isStamp) {
  1501. let fitCell = null;
  1502. for (let idx = page.cells.length - 1; idx >= 0; idx--) {
  1503. const cell = page.cells[idx];
  1504. 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) {
  1505. fitCell = cell;
  1506. break;
  1507. }
  1508. }
  1509. if (fitCell) {
  1510. fitCell.Value = '';
  1511. for (let role of ROLE_REL_LIST) {
  1512. const role_rel = getTheRightRole(role, pageIdx);
  1513. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1514. if (sCell.signature_name === role_rel.signature_name) {
  1515. if (role_rel.sign_output && role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {
  1516. fitCell.Value = role_rel.user_name;
  1517. } else {
  1518. fitCell.Value = '';
  1519. }
  1520. break;
  1521. }
  1522. }
  1523. }
  1524. } else {
  1525. // 要创建新的文本签名cell
  1526. const newCell = {
  1527. font: 'Footer',
  1528. control: sCell.control,
  1529. style: sCell.style,
  1530. Value: '',
  1531. area: { Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom },
  1532. };
  1533. if (ROLE_REL_LIST) {
  1534. for (let role of ROLE_REL_LIST) {
  1535. const role_rel = getTheRightRole(role, pageIdx);
  1536. if (!checkAudit || rptSignatureHelper._chkIfAudit(role_rel)) {
  1537. if (sCell.signature_name === role_rel.signature_name && role_rel.sign_output && role_rel.sign_output.indexOf(NORMAL_SIGN_STR) >= 0) {
  1538. newCell.Value = role_rel.user_name;
  1539. break;
  1540. }
  1541. }
  1542. }
  1543. }
  1544. page.cells.push(newCell); // 怎么也要有这个,哪怕没有文本也要输出,补边框用的
  1545. }
  1546. }
  1547. }
  1548. }
  1549. }
  1550. function _resetStampArea(ctrl, stampCell, roleRelItem) {
  1551. let pLeft = stampCell.orgArea.Left,
  1552. pTop = stampCell.orgArea.Top;
  1553. if (roleRelItem.stampFeature !== 'not found!') {
  1554. let std_stamp_size_width = STD_STAMP_SIZE_WIDTH, std_stamp_size_height = STD_STAMP_SIZE_HEIGHT;
  1555. let widthRate = 1, heightRate = 1;
  1556. if (roleRelItem.stampFeature) {
  1557. std_stamp_size_width = parseFloat(roleRelItem.stampFeature.ImageWidth.value);
  1558. std_stamp_size_height = parseFloat(roleRelItem.stampFeature.ImageHeight.value);
  1559. if (roleRelItem.stampFeature.ImageWidth.value !== roleRelItem.stampFeature.ImageHeight.value) {
  1560. //设置比例
  1561. if (std_stamp_size_width > std_stamp_size_height) {
  1562. heightRate = std_stamp_size_height / std_stamp_size_width;
  1563. } else {
  1564. widthRate = std_stamp_size_width / std_stamp_size_height;
  1565. }
  1566. }
  1567. if (std_stamp_size_width > STD_STAMP_SIZE_WIDTH || std_stamp_size_height > STD_STAMP_SIZE_HEIGHT) {
  1568. if (widthRate === 1) {
  1569. std_stamp_size_width = Math.min(std_stamp_size_width, STD_STAMP_SIZE_WIDTH);
  1570. std_stamp_size_height = std_stamp_size_width * heightRate;
  1571. } else {
  1572. std_stamp_size_height = Math.min(std_stamp_size_height, STD_STAMP_SIZE_HEIGHT);
  1573. std_stamp_size_width = std_stamp_size_height * widthRate;
  1574. }
  1575. }
  1576. }
  1577. switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
  1578. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_LEFT]:
  1579. pLeft = stampCell.orgArea.Left;
  1580. break;
  1581. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_CENTER]:
  1582. pLeft = (stampCell.orgArea.Left + stampCell.orgArea.Right - std_stamp_size_width) / 2;
  1583. break;
  1584. case JV.OUTPUT_ALIGN.H[JV.H_ALIGN_IDX_RIGHT]:
  1585. pLeft = stampCell.orgArea.Right - std_stamp_size_width;
  1586. break;
  1587. default:break;
  1588. }
  1589. switch (ctrl[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_VERTICAL]]) {
  1590. case JV.OUTPUT_ALIGN.V[JV.V_ALIGN_IDX_TOP]:
  1591. pTop = stampCell.orgArea.Top;
  1592. break;
  1593. case JV.OUTPUT_ALIGN.V[JV.V_ALIGN_IDX_CENTER]:
  1594. pTop = (stampCell.orgArea.Top + stampCell.orgArea.Bottom - std_stamp_size_height) / 2;
  1595. break;
  1596. case JV.OUTPUT_ALIGN.V[JV.V_ALIGN_IDX_BOTTOM]:
  1597. pTop = stampCell.orgArea.Bottom - std_stamp_size_height;
  1598. break;
  1599. default:break;
  1600. }
  1601. stampCell.area.Left = pLeft;
  1602. stampCell.area.Top = pTop;
  1603. stampCell.area.Right = pLeft + std_stamp_size_width;
  1604. stampCell.area.Bottom = pTop + std_stamp_size_height;
  1605. // 最后一步,如超过报表范围,则要调整坐标
  1606. const maxRect = stampCell.maxRect;
  1607. if (stampCell.area.Left < maxRect[0]) {
  1608. const width = maxRect[0] - stampCell.area.Left;
  1609. stampCell.area.Left += width;
  1610. stampCell.area.Right += width;
  1611. }
  1612. if (stampCell.area.Top < maxRect[1]) {
  1613. const height = maxRect[1] - stampCell.area.Top;
  1614. stampCell.area.Top += height;
  1615. stampCell.area.Bottom += height;
  1616. }
  1617. if (stampCell.area.Right > maxRect[2]) {
  1618. const width = maxRect[2] - stampCell.area.Right; // 负
  1619. stampCell.area.Left += width;
  1620. stampCell.area.Right += width;
  1621. }
  1622. if (stampCell.area.Bottom > maxRect[3]) {
  1623. const height = maxRect[3] - stampCell.area.Bottom;
  1624. stampCell.area.Top += height;
  1625. stampCell.area.Bottom += height;
  1626. }
  1627. }
  1628. }