rpt_signature.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /**
  2. * Created by Tony on 2019/9/25.
  3. */
  4. 'use strict'
  5. const DFT_ROLE_NAME = '';
  6. let rptSignatureHelper = {
  7. currentSelectedESignAccDom: null,
  8. currentSelectedESignAccIdx: -1,
  9. currentSelectedESignAccName: null,
  10. originalRoleRelList: [],
  11. buildSelectableAccount: function () {
  12. //PRJ_ACCOUNT_LIST
  13. //1. 清理所有选择项
  14. // $("#project_account_select_div").empty();
  15. let accDiv = $('#project_account_select_div');
  16. let accSelect = $('#project_account_select_dom'); //绑定成员
  17. let searchInput = $('#search_account').val();
  18. accDiv.empty();
  19. accSelect.empty();
  20. //2. 一个个加可选用户项
  21. const prj_accounts = [];
  22. const prj_sel_option_accounts = [];
  23. const acc_role_keys = [];
  24. for (let accIdx = 0; accIdx < PRJ_ACCOUNT_LIST.length; accIdx++) {
  25. const prjAccount = PRJ_ACCOUNT_LIST[accIdx];
  26. if (searchInput === '' || (searchInput !== '' && prjAccount.name.indexOf(searchInput) !== -1)) {
  27. let companyKey = prjAccount.account_group;
  28. let roleKey = prjAccount.role;
  29. if (companyKey === '') {
  30. companyKey = '其他单位';
  31. }
  32. if (roleKey === '') {
  33. roleKey = DFT_ROLE_NAME;
  34. }
  35. let keyIdx = acc_role_keys.indexOf(companyKey);
  36. if (keyIdx < 0) {
  37. acc_role_keys.push(companyKey);
  38. prj_accounts.push([]);
  39. prj_sel_option_accounts.push([]);
  40. keyIdx = prj_accounts.length - 1;
  41. //这里先push一些 html prefix,在后面统一在push html suffix
  42. prj_accounts[keyIdx].push('<ul class="list-group">');
  43. prj_accounts[keyIdx].push('<li class="px-2 text-muted"><i class="fa fa-caret-down"></i> ' + companyKey + '</li>');
  44. prj_sel_option_accounts[keyIdx].push('<optgroup label=" ' + companyKey + '">');
  45. }
  46. //push item
  47. 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>' +
  48. prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
  49. prj_sel_option_accounts[keyIdx].push('<option value="' + accIdx + '">' + prjAccount.name + '-' + roleKey + '</option>');
  50. }
  51. }
  52. for (const prjAccList of prj_accounts) {
  53. prjAccList.push('</ul>');
  54. }
  55. for (const prjAccList of prj_sel_option_accounts) {
  56. prjAccList.push('</optgroup>');
  57. }
  58. for (let idx = 0; idx < prj_accounts.length; idx++) {
  59. prj_accounts[idx] = prj_accounts[idx].join('');
  60. prj_sel_option_accounts[idx] = prj_sel_option_accounts[idx].join('');
  61. }
  62. accDiv.append(prj_accounts.join(''));
  63. accSelect.append(prj_sel_option_accounts.join(''));
  64. },
  65. buildSelectableAccountUsed: function () {
  66. //PRJ_ACCOUNT_LIST
  67. //1. 清理所有选择项
  68. // $("#project_account_select_div").empty();
  69. let accDiv = $('#account_used_select_div');
  70. accDiv.empty();
  71. //2. 一个个加可选用户项
  72. const prj_accounts = [];
  73. for (let uidx = 0; uidx < USED_LIST.length; uidx++) {
  74. const accIdx = PRJ_ACCOUNT_LIST.findIndex(function(item) {
  75. return item.id === USED_LIST[uidx].uid;
  76. });
  77. if (accIdx === -1 || accIdx === undefined) {
  78. continue;
  79. }
  80. const prjAccount = PRJ_ACCOUNT_LIST[accIdx];
  81. let roleKey = prjAccount.role;
  82. if (roleKey === '') {
  83. roleKey = DFT_ROLE_NAME;
  84. }
  85. //push item
  86. 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>' +
  87. prjAccount.name + '-<small class="text-muted">' + roleKey + '</small></li>');
  88. }
  89. accDiv.append(prj_accounts.join(''));
  90. },
  91. createEsignatureByAccIdx: function (accIdx) {
  92. rptSignatureHelper.createPreSelectedSignature(PRJ_ACCOUNT_LIST[accIdx], null);
  93. },
  94. createEsignatureByRoleIdx: function (roleIdx) {
  95. rptSignatureHelper.createPreSelectedSignature(null, ROLE_LIST[roleIdx]);
  96. },
  97. createPreSelectedSignature: function (directAcc, roleAcc) {
  98. let dftSignSrc = '/public/upload/sign/user-sign.PNG';
  99. let userAcc = directAcc;
  100. if (roleAcc) {
  101. userAcc = rptSignatureHelper.getUserAccount(roleAcc.bind_acc_id);
  102. }
  103. if (userAcc.sign_path !== '') {
  104. dftSignSrc = '/public/upload/sign/' + userAcc.sign_path;
  105. }
  106. if (rptSignatureHelper.currentSelectedESignAccName !== null) {
  107. for (const page of zTreeOprObj.currentRptPageRst.items) {
  108. if (page.signature_cells) {
  109. for (const sCell of page.signature_cells) {
  110. if (sCell.signature_name === rptSignatureHelper.currentSelectedESignAccName) {
  111. sCell.pre_path = dftSignSrc;
  112. }
  113. }
  114. }
  115. }
  116. // 1. 删除不需要的child dom
  117. $(rptSignatureHelper.currentSelectedESignAccDom).empty();
  118. // 2. 创建已选择签名相关 dom
  119. rptSignatureHelper.cleanOldSignature(rptSignatureHelper.currentSelectedESignAccName);
  120. // 2.1 dom element
  121. const elementsStrArr = [];
  122. if (directAcc) {
  123. rptSignatureHelper.pushDomElementByUser(elementsStrArr, userAcc.name, userAcc.role);
  124. // 还有ROLE_REL_LIST
  125. let roleRelObj = {};
  126. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  127. roleRelObj.sign_path = dftSignSrc;
  128. roleRelObj.sign_date = '';
  129. roleRelObj.sign_date_format = 'yyyy年M月d日';
  130. roleRelObj.user_name = userAcc.name;
  131. roleRelObj.acc_id = userAcc.id;
  132. roleRelObj.type = '用户';
  133. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  134. ROLE_REL_LIST.push(roleRelObj);
  135. } else if (roleAcc) {
  136. // 创建相关dom元素
  137. rptSignatureHelper.pushDomElementByRole(elementsStrArr, roleAcc.name, userAcc.name);
  138. // 还有ROLE_REL_LIST
  139. let roleRelObj = {};
  140. roleRelObj.signature_name = rptSignatureHelper.currentSelectedESignAccName;
  141. roleRelObj.sign_path = dftSignSrc;
  142. roleRelObj.sign_date = '';
  143. roleRelObj.sign_date_format = 'yyyy年M月d日';
  144. roleRelObj.user_name = userAcc.name;
  145. roleRelObj.acc_id = userAcc.id;
  146. roleRelObj.type = '角色';
  147. roleRelObj.role = (userAcc.role === '')?DFT_ROLE_NAME:userAcc.role;
  148. roleRelObj.role_name = roleAcc.name;
  149. ROLE_REL_LIST.push(roleRelObj);
  150. }
  151. // elementsStrArr.push('');
  152. rptSignatureHelper.pushDatePickerDom(elementsStrArr, userAcc.id);
  153. $(rptSignatureHelper.currentSelectedESignAccDom).append(elementsStrArr.join(' '));
  154. //.appendChild(pNode);
  155. //*/
  156. // 2.2 date-picker
  157. // 更新最近使用名单
  158. const params = {};
  159. params.uid = userAcc.id;
  160. params.prj_id = PROJECT_ID;
  161. params.tender_id = TENDER_ID;
  162. CommonAjax.postXsrfEx("/tender/report_api/updateSignatureUsed", params, 10000, true, getCookie('csrfToken'),
  163. function(result){
  164. console.log(result);
  165. USED_LIST = result.data;
  166. $('#search_account').val('');
  167. rptSignatureHelper.buildSelectableAccount();
  168. rptSignatureHelper.buildSelectableAccountUsed();
  169. }, function(err){
  170. // hintBox.unWaitBox();
  171. }, function(ex){
  172. // hintBox.unWaitBox();
  173. }
  174. );
  175. }
  176. },
  177. cleanOldSignature: function (signature_name) {
  178. // 清掉ROLE_REL_LIST原有的签名
  179. for (let idx = ROLE_REL_LIST.length - 1; idx >= 0 ; idx--) {
  180. if (ROLE_REL_LIST[idx].signature_name === signature_name) {
  181. ROLE_REL_LIST.splice(idx, 1);
  182. }
  183. }
  184. },
  185. resetESignature: function (pageRst) {
  186. let body = $('#eSignatureBodyDiv');
  187. body.empty();
  188. const signature_cells = [];
  189. const singatureNameArr = [];
  190. for (const page of pageRst.items) {
  191. if (page.signature_cells) {
  192. for (const sCell of page.signature_cells) {
  193. if (sCell.signature_name !== null && sCell.signature_name !== undefined && sCell.signature_name !== 'dummy_pic') {
  194. if (singatureNameArr.indexOf(sCell.signature_name) < 0) {
  195. signature_cells.push(sCell);
  196. singatureNameArr.push(sCell.signature_name);
  197. }
  198. }
  199. }
  200. }
  201. }
  202. if (signature_cells.length > 0) {
  203. const elementsStrArr = [];
  204. const elementsDateStrArr = [];
  205. for (let scIdx = 0; scIdx < signature_cells.length; scIdx++) {
  206. const sCell = signature_cells[scIdx];
  207. elementsStrArr.push('<div class="form-group row">');
  208. elementsStrArr.push('<label for="staticEmail" class="col-sm-3 col-form-label pr-0">' + sCell.signature_name + '</label>');
  209. elementsStrArr.push('<div class="col-sm-9">');
  210. elementsStrArr.push('<ul class="list-group">');
  211. elementsStrArr.push('<li class="list-group-item">');
  212. let hasPic = false;
  213. //新需求中,即使没有审核,也可以设置签名
  214. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  215. const role_rel = ROLE_REL_LIST[idx];
  216. if (role_rel.signature_name === sCell.signature_name) {
  217. if (role_rel.type === '用户') {
  218. rptSignatureHelper.pushDomElementByUser(elementsStrArr, role_rel.user_name, role_rel.role);
  219. } else {
  220. //角色
  221. rptSignatureHelper.pushDomElementByRole(elementsStrArr, role_rel.role_name, role_rel.user_name);
  222. }
  223. const idSuffixStr = 'dtp_' + role_rel.signature_name;
  224. elementsStrArr.push('<div class="">');
  225. if (role_rel.sign_date !== '') {
  226. const dt = new Date(role_rel.sign_date);
  227. const dtVal = dt.Format('yyyy-MM-dd');
  228. //elementsStrArr.push('<input class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" value="' + (new Date(role_rel.sign_date)).Format('yyyy-M-d') + '">');
  229. // elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" readonly="true" value="' + dtVal + '"');
  230. elementsStrArr.push('<input id="' + idSuffixStr + '" class="form-control form-control-sm mt-0" placeholder="选择签名日期" type="date" value="' + dtVal + '"');
  231. } else {
  232. // elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" readonly="true"');
  233. elementsStrArr.push('<input id="' + idSuffixStr + '" class="form-control form-control-sm mt-0" placeholder="选择签名日期" type="date"');
  234. }
  235. elementsStrArr.push('</div>');
  236. hasPic = true;
  237. break;
  238. }
  239. }
  240. if (!hasPic) {
  241. // 在交互操作中,有可能实际上是没有
  242. 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>');
  243. }
  244. // if (sCell.path || sCell.pic) {
  245. // } else {
  246. // 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>');
  247. // }
  248. elementsStrArr.push('</li>');
  249. elementsStrArr.push('</ul>');
  250. elementsStrArr.push('</div>');
  251. elementsStrArr.push('</div>');
  252. //还有签名日期(用不用得上不管,先放上去再说)
  253. }
  254. body.append(elementsStrArr.join(' '));
  255. }
  256. },
  257. pushDomElementByUser: function (elementsStrArr, userName, userRole) {
  258. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span>' + userName +
  259. '-<small class="text-muted">' + ((userRole === '')?DFT_ROLE_NAME:userRole) +
  260. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  261. // rptSignatureHelper.pushDatePickerDom(elementsStrArr);
  262. },
  263. pushDomElementByRole: function (elementsStrArr, roleName, userName) {
  264. elementsStrArr.push('<p class=" d-flex justify-content-between m-0"><span><i class="fa fa-user" title="角色"> ' + roleName +
  265. '</i>-<small class="text-muted">' + userName +
  266. '</small></span><a onclick="rptSignatureHelper.removeSignature(this)" class="text-danger"><i class="fa fa-remove" title="移除签名"></i></a></p>');
  267. // rptSignatureHelper.pushDatePickerDom(elementsStrArr);
  268. },
  269. pushDatePickerDom: function (elementsStrArr, userAccId) {
  270. let idSuffixStr = 'dtp_' + rptSignatureHelper.currentSelectedESignAccName;
  271. elementsStrArr.push('<div class="">');
  272. // 日期控件存在页面高度不过高无法选中bug,先不用
  273. // elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" data-position="right bottom" type="text" readonly="true"');
  274. let dftDate = '';
  275. if (STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  276. for (const stga of STAGE_AUDIT) {
  277. if (stga.aid === userAccId) {
  278. if (stga.end_time && stga.end_time !== '' && stga.end_time.length > 20) {
  279. // let dt = new Date(stga.end_time);
  280. dftDate = (new Date(stga.end_time)).Format('yyyy-MM-dd');
  281. }
  282. break;
  283. }
  284. }
  285. }
  286. if (dftDate !== '') {
  287. elementsStrArr.push('<input id="' + idSuffixStr + '" class="form-control form-control-sm mt-0" placeholder="选择签名日期" type="date" value="' + dftDate + '"');
  288. } else {
  289. elementsStrArr.push('<input id="' + idSuffixStr + '" class="form-control form-control-sm mt-0" placeholder="选择签名日期" type="date"');
  290. }
  291. elementsStrArr.push('</div>');
  292. },
  293. removeSignature: function (dom) {
  294. let accTxtName = $(dom.parentNode.parentNode.parentNode.parentNode.parentNode).find('label')[0].innerText;
  295. let jDom = $(dom.parentNode.parentNode);
  296. jDom.empty();
  297. jDom.append('<a href="#add-sign" onclick="rptSignatureHelper.currentSelectedESignAccDom = this.parentNode; rptSignatureHelper.currentSelectedESignAccName = \'' +
  298. accTxtName + '\'" data-toggle="modal" data-target="#add-sign"><i class="fa fa-plus"></i> 添加签名</a>');
  299. // 要记得清空相关pre_path属性
  300. for (const page of zTreeOprObj.currentRptPageRst.items) {
  301. if (page.signature_cells) {
  302. for (const sCell of page.signature_cells) {
  303. if (sCell.signature_name === accTxtName) {
  304. sCell.pre_path = '';
  305. }
  306. }
  307. }
  308. }
  309. // 还有ROLE_REL_LIST
  310. rptSignatureHelper.cleanOldSignature(accTxtName);
  311. },
  312. removeSelectSignature: function () {
  313. for (const page of zTreeOprObj.currentRptPageRst.items) {
  314. if (page.signature_cells) {
  315. for (const sCell of page.signature_cells) {
  316. if (sCell.hasOwnProperty('pre_path')) {
  317. delete sCell.pre_path;
  318. }
  319. }
  320. }
  321. }
  322. // ROLE_REL_LIST = [];
  323. // ROLE_REL_LIST = ROLE_REL_LIST.concat(rptSignatureHelper.originalRoleRelList);
  324. ROLE_REL_LIST = JSON.parse(JSON.stringify(rptSignatureHelper.originalRoleRelList));
  325. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  326. },
  327. resetSignDate: function() {
  328. // for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  329. // const role_rel = ROLE_REL_LIST[idx];
  330. // const idSuffixStr = 'dtp_' + role_rel.signature_name;
  331. // let dtDom = $('#' + idSuffixStr);
  332. // if (dtDom.length === 1) {
  333. // const dtStr = dtDom[0].value;
  334. // if (dtStr && dtStr !== '' && dtStr.length >= 8 && dtStr.length <= 10) {
  335. // // const tmpDt = new Date(dtStr);
  336. // // const year = parseInt(tmpDt.getFullYear());
  337. // // const month = parseInt(tmpDt.getMonth());
  338. // // const dt = parseInt(tmpDt.getDate());
  339. // // role_rel.sign_date = new Date(year, month, dt);
  340. // role_rel.sign_date = new Date(dtStr);
  341. // } else {
  342. // role_rel.sign_date = '';
  343. // }
  344. // // 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)
  345. // for (const page of zTreeOprObj.currentRptPageRst.items) {
  346. // if (page.signature_date_cells) {
  347. // for (const sCell of page.signature_date_cells) {
  348. // sCell.Value = _getSignDateDftName();
  349. // if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  350. // if (role_rel.sign_date !== '') {
  351. // sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  352. // } else {
  353. // }
  354. // }
  355. // }
  356. // }
  357. // }
  358. // }
  359. // }
  360. for (const page of zTreeOprObj.currentRptPageRst.items) {
  361. if (page.signature_date_cells) {
  362. for (const sCell of page.signature_date_cells) {
  363. sCell.Value = _getSignDateDftName();
  364. for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
  365. const role_rel = ROLE_REL_LIST[idx];
  366. const idSuffixStr = 'dtp_' + role_rel.signature_name;
  367. let dtDom = $('#' + idSuffixStr);
  368. if (dtDom.length === 1) {
  369. const dtStr = dtDom[0].value;
  370. if (dtStr && dtStr !== '' && dtStr.length >= 8 && dtStr.length <= 10) {
  371. // const tmpDt = new Date(dtStr);
  372. // const year = parseInt(tmpDt.getFullYear());
  373. // const month = parseInt(tmpDt.getMonth());
  374. // const dt = parseInt(tmpDt.getDate());
  375. // role_rel.sign_date = new Date(year, month, dt);
  376. role_rel.sign_date = new Date(dtStr);
  377. } else {
  378. role_rel.sign_date = '';
  379. }
  380. // 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)
  381. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  382. if (role_rel.sign_date !== '') {
  383. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  384. }
  385. }
  386. }
  387. }
  388. }
  389. }
  390. }
  391. },
  392. setupAfterSelectSignature: function () {
  393. //0. 签名日期
  394. rptSignatureHelper.resetSignDate();
  395. if (current_stage_status === 3) {
  396. //1. 重刷page
  397. for (const page of zTreeOprObj.currentRptPageRst.items) {
  398. if (page.signature_cells) {
  399. for (const sCell of page.signature_cells) {
  400. if (sCell.hasOwnProperty('pre_path')) {
  401. sCell.path = sCell.pre_path;
  402. delete sCell.pre_path;
  403. }
  404. }
  405. }
  406. }
  407. zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
  408. }
  409. //2. 更新数据
  410. const params = {};
  411. params.id = CURRENT_ROLE_REL_ID;
  412. params.tender_id = TENDER_ID;
  413. params.stage_id = getStageId();
  414. params.rpt_id = zTreeOprObj.currentNode.refId;
  415. params.rel_content = ROLE_REL_LIST;
  416. // rptSignatureHelper.originalRoleRelList = [];
  417. // rptSignatureHelper.originalRoleRelList = rptSignatureHelper.originalRoleRelList.concat(ROLE_REL_LIST);
  418. rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
  419. CommonAjax.postXsrfEx("/tender/report_api/updateRoleRelationship", params, 10000, true, getCookie('csrfToken'),
  420. function(result){
  421. console.log(result);
  422. if (result.data && result.data.insertId > 0) {
  423. CURRENT_ROLE_REL_ID = result.data.insertId;
  424. }
  425. }, function(err){
  426. // hintBox.unWaitBox();
  427. }, function(ex){
  428. // hintBox.unWaitBox();
  429. }
  430. );
  431. },
  432. switchAddRoleDiv: function (dom) {
  433. if (dom.nextElementSibling.children[0].style.display === 'none') {
  434. dom.nextElementSibling.children[0].style.display = '';
  435. } else {
  436. dom.nextElementSibling.children[0].style.display = 'none';
  437. }
  438. },
  439. createNewRole: function (dom) {
  440. if ($('#acc_role_name')[0].value !== '') {
  441. const params = {};
  442. params.name = $('#acc_role_name')[0].value;
  443. const selectedAcc = PRJ_ACCOUNT_LIST[$('#project_account_select_dom')[0].selectedOptions[0].value];
  444. const roleName = (selectedAcc.role === '')?DFT_ROLE_NAME:selectedAcc.role;
  445. params.bind_acc_id = selectedAcc.id;
  446. params.prj_id = PROJECT_ID;
  447. params.tender_id = TENDER_ID;
  448. CommonAjax.postXsrfEx("/tender/report_api/createSignatureRole", params, 10000, true, getCookie('csrfToken'),
  449. function(result){
  450. console.log(result);
  451. const newRole = {};
  452. newRole.name = params.name;
  453. newRole.bind_acc_id = selectedAcc.id;
  454. newRole.prj_id = PROJECT_ID;
  455. newRole.tender_id = TENDER_ID;
  456. ROLE_LIST.push(newRole);
  457. const domArr = [];
  458. domArr.push('<li class="add-sign-list-item">');
  459. //1. apply签名
  460. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + (ROLE_LIST.length - 1) +')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  461. domArr.push('<i class="fa fa-plus"></i>');
  462. domArr.push('</a>');
  463. //2. 编辑角色(暂缓处理click事件)
  464. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  465. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  466. domArr.push('</a>');
  467. //3. 显示名称
  468. domArr.push('<i class="fa fa-user"></i> ' + $('#acc_role_name')[0].value + '<p>' + selectedAcc.name + '-<small class="text-muted">' + roleName + '</small></p>');
  469. $('#existed_roles_ul').append(domArr.join(' '));
  470. }, function(err){
  471. // hintBox.unWaitBox();
  472. }, function(ex){
  473. // hintBox.unWaitBox();
  474. }
  475. );
  476. } else {
  477. alert('请输入合适的名称!');
  478. }
  479. },
  480. buildRoleDom: function (roleList) {
  481. const ulDom = $('#existed_roles_ul');
  482. ulDom.empty();
  483. for (let domIdx = 0; domIdx < roleList.length; domIdx++) {
  484. const role = roleList[domIdx];
  485. const domArr = [];
  486. domArr.push('<li class="add-sign-list-item">');
  487. //1. apply签名
  488. domArr.push('<a href="javascript:void(0)" onclick="rptSignatureHelper.createEsignatureByRoleIdx(' + domIdx + ')" class="btn-link pull-right" title="添加" data-dismiss="modal">');
  489. domArr.push('<i class="fa fa-plus"></i>');
  490. domArr.push('</a>');
  491. //2. 编辑角色(暂缓)
  492. domArr.push('<a href="javascript:void(0)" onclick="" class="btn-link pull-right mr-1" title="编辑">');
  493. domArr.push('<i class="fa fa-pencil-square-o"></i>');
  494. domArr.push('</a>');
  495. //3. 显示名称
  496. let acc = rptSignatureHelper.getUserAccount(role.bind_acc_id);
  497. 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>');
  498. ulDom.append(domArr.join(' '));
  499. }
  500. },
  501. getUserAccount: function (accId) {
  502. let rst = null;
  503. for (const acc of PRJ_ACCOUNT_LIST) {
  504. if (acc.id === accId) {
  505. rst = acc;
  506. break;
  507. }
  508. }
  509. return rst;
  510. },
  511. mergeSignature: function (pageData, currRoleRelList) {
  512. for (const page of pageData.items) {
  513. if (page.signature_cells) {
  514. for (const sCell of page.signature_cells) {
  515. for (const role_rel of currRoleRelList) {
  516. if (role_rel.signature_name === sCell.signature_name) {
  517. sCell.path = role_rel.sign_path;
  518. sCell.pre_path = role_rel.sign_path;
  519. }
  520. }
  521. }
  522. }
  523. }
  524. },
  525. mergeSignDate: function (pageData, currRoleRelList) {
  526. if (currRoleRelList && currRoleRelList.length > 0 && STAGE_AUDIT && STAGE_AUDIT.length > 0) {
  527. for (let rridx = 0; rridx < currRoleRelList.length; rridx++) {
  528. const role_rel = currRoleRelList[rridx];
  529. if (role_rel.sign_date === undefined || role_rel.sign_date === null || role_rel.sign_date === '') {
  530. for (const stg_audit of STAGE_AUDIT) {
  531. if (role_rel.acc_id === stg_audit.aid) {
  532. role_rel.sign_date = stg_audit.end_time;
  533. rptSignatureHelper.originalRoleRelList[rridx].sign_date = stg_audit.end_time;
  534. break;
  535. }
  536. }
  537. }
  538. }
  539. }
  540. for (const page of pageData.items) {
  541. if (page.signature_date_cells) {
  542. for (const sCell of page.signature_date_cells) {
  543. sCell.Value = _getSignDateDftName();
  544. for (const role_rel of currRoleRelList) {
  545. if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
  546. if (role_rel.sign_date !== '') {
  547. if (typeof role_rel.sign_date === 'string') {
  548. role_rel.sign_date = new Date(role_rel.sign_date);
  549. }
  550. sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
  551. }
  552. break;
  553. }
  554. }
  555. }
  556. }
  557. }
  558. }
  559. }
  560. function _getSignDateDftName() {
  561. return ' 年 月 日';
  562. }