rpt_signature.js 85 KB

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