global.js 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306
  1. /*全局自适应高度*/
  2. /*全局自适应高度*/
  3. const postDefaultTime = 60 * 1000 * 2;
  4. function autoFlashHeight(){
  5. const select = $(".scrollbar-auto .active");
  6. if (select.length > 0) $(".scrollbar-auto")[0].scrollTop = select[0].offsetTop - 72;
  7. function getObjHeight(select) {
  8. return select.length > 0 ? select.height() : 0;
  9. }
  10. /*侧栏高度*/
  11. var sBar1 = getObjHeight($(".sjs-bar-1"));
  12. var sBar2 = getObjHeight($(".sjs-bar-2"));
  13. var sBar3 = getObjHeight($(".sjs-bar-3"));
  14. var sBar4 = getObjHeight($(".sjs-bar-4"));
  15. var sBar5 = getObjHeight($(".sjs-bar-5"));
  16. /*侧栏高度*/
  17. var cHeader = getObjHeight($(".c-header"));
  18. var sBar = getObjHeight($(".sjs-bar"));
  19. var sBart = getObjHeight($(".sjs-bart"));
  20. var sBarz = getObjHeight($(".side-bar"));
  21. var pBarz = getObjHeight($(".toolsbar-f"));
  22. var bdtopc = getObjHeight($(".body-height-top"));
  23. var bcontent = getObjHeight($(".bcontent-wrap"));
  24. $(".sjs-height-0").height($(window).height()-cHeader-90+53);
  25. $(".sjs-height-1").height($(window).height()-cHeader-bcontent-90+53);
  26. $(".sjs-height-2").height($(window).height()-cHeader-sBarz-120);
  27. $(".sjs-height-3").height($(window).height()-cHeader-sBar-492+25+150);/*492*/
  28. $(".sjs-height-4").height($(window).height()-cHeader-pBarz-110+75);
  29. $(".sjs-height-5").height($(window).height()-cHeader-sBar-492+55);/*492*/
  30. $(".sjs-height-6").height($(window).height()-cHeader-34-sBar1);
  31. $(".sjs-height-7").height($(window).height()-cHeader-34-41);
  32. const bcBar = getObjHeight($('.bcontent-wrap .bc-bar'));
  33. $(".sp-wrap").height(bcontent-(bcBar || 30));
  34. /*侧栏高度*/
  35. $(".sjs-sh-1").height($(window).height()-cHeader-sBar1-92+55);
  36. $(".sjs-sh-2").height($(window).height()-cHeader-sBar2-92+55);
  37. $(".sjs-sh-3").height($(window).height()-cHeader-sBar3-92+55);
  38. $(".sjs-sh-4").height($(window).height()-cHeader-sBar4-92+55);
  39. $(".sjs-sh-5").height($(window).height()-cHeader-sBar5-92+55);
  40. for (const sh of $('.sjs-sh')) {
  41. $(sh).height($(window).height()-cHeader-getObjHeight($('.sjs-bar', sh.parentNode))-getObjHeight($('.sjs-bottom', sh.parentNode))-92+55);
  42. }
  43. for (const sh of $('.sjs-quality')) {
  44. // 16为.sjs-quality-nav的margin
  45. $(sh).height($(window).height()-$('.panel-title').height()-getObjHeight($('.sjs-quality-nav'))-16-getObjHeight($('.sjs-bar', sh.parentNode)));
  46. }
  47. /*工程变更添加清单高度*/
  48. $(".sjs-biangeng-height").height($(window).height()/3.3);
  49. // 大于高度时隐藏nav文字
  50. if (!navOriginalHeight) {
  51. navOriginalHeight = getObjHeight($('.nav-top')) + getObjHeight($('.nav-bottom')) + getObjHeight($('.logo'));
  52. }
  53. if (navOriginalHeight > getObjHeight($('.main-nav'))) {
  54. $('.bg-nav li:not([class="bg-danger"]) a span').hide();
  55. } else {
  56. $('.bg-nav li:not([class="bg-danger"]) a span').show();
  57. }
  58. };
  59. let navOriginalHeight = false;
  60. $(window).resize(autoFlashHeight);
  61. /*全局自适应高度结束*/
  62. $(function(){
  63. /*侧滑*/
  64. $(".open-sidebar").click(function(){
  65. $(".slide-sidebar").animate({width:"800"}).addClass("open");
  66. });
  67. $("body").click(function(event){
  68. var e = event || window.event; //浏览器兼容性
  69. if(!$(event.target).is('a')) {
  70. var elem = event.target || e.srcElement;
  71. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  72. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  73. return false;
  74. }
  75. elem = elem.parentNode;
  76. }
  77. $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
  78. }
  79. });
  80. /*侧滑*/
  81. /*工具提示*/
  82. $(function () {
  83. $('[data-toggle="tooltip"]').tooltip()
  84. });
  85. /*侧栏菜单*/
  86. $(".bg-nav > li > a").click(function() {
  87. var self = $(this);
  88. var subMenu = $(this).siblings('ul.sub-menu');
  89. if(subMenu.length > 0) {
  90. if(subMenu.is(":visible")) {
  91. self.find('.menu-arrow').removeClass('fa-angle-up').addClass('fa-angle-down');
  92. subMenu.slideUp('fast');
  93. self.parent().removeClass('active');
  94. }else{
  95. self.parent().addClass('active');
  96. self.find('.menu-arrow').removeClass('fa-angle-down').addClass('fa-angle-up');
  97. subMenu.slideDown('fast');
  98. }
  99. }
  100. });
  101. $('.bg-nav > li > .nav-up-down').on('click', function() {
  102. const nav = $(this).attr('id');
  103. if ($(this).children('.child-up-down').hasClass('fa-angle-down')) {
  104. $(this).children('.child-up-down').removeClass('fa-angle-down').addClass('fa-angle-right');
  105. $('.bg-nav li[data-index="'+ nav + '"]').slideUp('fast');
  106. } else {
  107. $(this).children('.child-up-down').removeClass('fa-angle-right').addClass('fa-angle-down');
  108. $('.bg-nav li[data-index="'+ nav + '"]').slideDown('fast');
  109. }
  110. setLocalCache('nav-' + nav, $(this).children('.child-up-down').hasClass('fa-angle-down') ? 1 : 0);
  111. });
  112. // 侧栏菜单状态判断展开收起
  113. $('.bg-nav > li > .nav-up-down').each(function() {
  114. const nav = $(this).attr('id');
  115. if (getLocalCache('nav-' + nav) == 0) {
  116. $(this).children('.child-up-down').removeClass('fa-angle-down').addClass('fa-angle-right');
  117. $('.bg-nav li[data-index="'+ nav + '"]').slideUp(0);
  118. }
  119. });
  120. // 数据提交
  121. $("#submit-form").click(function() {
  122. $("#save-form").submit();
  123. });
  124. // modal弹窗拖动
  125. // $(document).on("show.bs.modal", ".modal", function() {
  126. // $(this).draggable({
  127. // handle: ".modal-header" // 只能点击头部拖动
  128. // });
  129. // $(this).css("overflow", "hidden");
  130. // });
  131. // 动态生成datepicker
  132. $('body').on('focus', ".datepicker-here", function (e) {
  133. if ($(this).data("datepicker") != "1") {
  134. $(this).datepicker();
  135. }
  136. $(this).data("datepicker", "1");
  137. });
  138. $('a[href="/setting/user"]').each(function () {
  139. if (getLocalCache('account-pageSize')) {
  140. $(this).attr('href', $(this).attr('href') + '?pageSize=' + getLocalCache('account-pageSize'));
  141. }
  142. });
  143. $('.account-page-size').each(function () {
  144. if (getLocalCache('account-pageSize')) {
  145. // 判断是否有?,是则变成&,否则变成?
  146. const href = $(this).attr('href');
  147. if (href.indexOf('?') !== -1) {
  148. $(this).attr('href', href + '&pageSize=' + getLocalCache('account-pageSize'));
  149. } else {
  150. $(this).attr('href', href + '?pageSize=' + getLocalCache('account-pageSize'));
  151. }
  152. }
  153. });
  154. $('.change_sort_link').each(function () {
  155. const tender_id = $(this).attr('href').split('/')[2];
  156. const filterString = setChangeFilterData('change-'+ tender_id +'-list-order');
  157. if (filterString) $(this).attr('href', $(this).attr('href') + filterString);
  158. });
  159. $('.change_project_sort_link').each(function () {
  160. const tender_id = $(this).attr('href').split('/')[2];
  161. const filterString = setChangeFilterData('change-project-'+ tender_id +'-list-order');
  162. if (filterString) $(this).attr('href', $(this).attr('href') + filterString);
  163. });
  164. $('.change_apply_sort_link').each(function () {
  165. const tender_id = $(this).attr('href').split('/')[2];
  166. const filterString = setChangeFilterData('change-apply-'+ tender_id +'-list-order');
  167. if (filterString) $(this).attr('href', $(this).attr('href') + filterString);
  168. });
  169. $('.change_plan_sort_link').each(function () {
  170. const tender_id = $(this).attr('href').split('/')[2];
  171. const filterString = setChangeFilterData('change-plan-'+ tender_id +'-list-order');
  172. if (filterString) $(this).attr('href', $(this).attr('href') + filterString);
  173. });
  174. $('#nav_management').click(function(e) {
  175. e.preventDefault()
  176. showWaitingView();
  177. $.ajax({
  178. type: 'GET',
  179. url: '/management/proxy/project/vertify',
  180. dataType: 'json',
  181. cache: false,
  182. timeout: 60000,
  183. success: function ({code = -1, data: { exist, is_admin, redirect } = { exist: 0, is_admin: false}}) {
  184. if (code === 0) {
  185. if (!exist && !is_admin) {
  186. toastr.error('「项目管理」系统不存在当前项目,请联系管理员进行处理。');
  187. } else if(!exist && is_admin) {
  188. $('#add-management').modal('show')
  189. } else {
  190. redirect && window.open(redirect)
  191. }
  192. }
  193. closeWaitingView()
  194. },
  195. error: function(jqXHR, textStatus, errorThrown){
  196. toastr.error('error: ' + textStatus + " " + errorThrown);
  197. closeWaitingView();
  198. }
  199. })
  200. });
  201. $('#add-management .btn-primary').click(function() {
  202. $('#add-management').modal('hide')
  203. $('#process-management').modal('show')
  204. $.ajax({
  205. tpye: 'post',
  206. url: '/management/proxy/project/add',
  207. dataType: 'json',
  208. cache: false,
  209. timeout: 60000,
  210. // beforeSend: function(xhr) {
  211. // let csrfToken = Cookies.get('csrfToken_j');
  212. // xhr.setRequestHeader('x-csrf-token', csrfToken);
  213. // },
  214. success: function ({code = -1, data = {}}) {
  215. if (code === 0) {
  216. timer = setTimeout(() => {
  217. $('#process-management .process-child').css('width', '100%')
  218. setTimeout(() => {
  219. const { redirect } = data
  220. redirect && window.open(redirect)
  221. $('#process-management').modal('hide')
  222. }, 150);
  223. }, 500);
  224. }
  225. }
  226. })
  227. })
  228. });
  229. function setChangeFilterData(orderLocal, filterString = '') {
  230. const filterData = [];
  231. const orderSetting = getLocalCache(orderLocal);
  232. if(orderSetting) {
  233. const orders = orderSetting.split('|');
  234. filterData.push('sort=' + orders[0]);
  235. filterData.push('order=' + orders[1]);
  236. }
  237. if (getLocalCache('account-pageSize')) {
  238. filterData.push('pageSize=' + getLocalCache('account-pageSize'));
  239. }
  240. filterString = filterString ? filterString + '&' : filterString + '?';
  241. if (filterData.length > 0) filterString = filterString + filterData.join('&');
  242. return filterString;
  243. }
  244. function checkShowLast (count) {
  245. if (count > 12500) {
  246. $('a[name=showLevel][tag=last]').hide();
  247. } else {
  248. $('a[name=showLevel][tag=last]').show();
  249. }
  250. }
  251. /**
  252. * 提示框
  253. *
  254. * @param string message
  255. * @param string type
  256. * @param string icon
  257. * @return void
  258. */
  259. function toast(message, type, icon) {
  260. var toast = $(".toast");
  261. toast.addClass(type);
  262. toast.children('.message').html(message);
  263. var iconClass = 'fa-' + icon;
  264. toast.children('.icon').addClass(iconClass);
  265. toast.fadeIn(500);
  266. setTimeout(function() {
  267. toast.fadeOut('fast');
  268. toast.children('.message').text('');
  269. toast.children('.icon').removeClass(iconClass);
  270. }, 3000);
  271. }
  272. /**
  273. * 动态请求数据
  274. * @param {String} url - 请求链接
  275. * @param data - 提交数据
  276. * @param {function} successCallback - 返回成功回调
  277. * @param {function} errorCallBack - 返回失败回调
  278. */
  279. const postData = function (url, data, successCallback, errorCallBack, showWaiting = true) {
  280. if (showWaiting) showWaitingView();
  281. $.ajax({
  282. type:"POST",
  283. url: url,
  284. data: {'data': JSON.stringify(data)},
  285. dataType: 'json',
  286. cache: false,
  287. timeout: postDefaultTime,
  288. beforeSend: function(xhr) {
  289. let csrfToken = Cookies.get('csrfToken_j');
  290. xhr.setRequestHeader('x-csrf-token', csrfToken);
  291. },
  292. success: function(result){
  293. if (result.err === 0) {
  294. if (result.hpack) {
  295. result.hpack.forEach(x => {
  296. result.data[x] = hpackArrBack(result.data[x]);
  297. });
  298. }
  299. if (successCallback) {
  300. successCallback(result.data, result.msg);
  301. }
  302. } else if (result.err === 2) {
  303. toastr.error('error: ' + result.msg);
  304. setTimeout(function () {
  305. window.location.href = '/login';
  306. },1000);
  307. } else {
  308. toastr.error('error: ' + result.msg);
  309. if (errorCallBack) {
  310. errorCallBack(result.msg);
  311. }
  312. }
  313. if (showWaiting) closeWaitingView();
  314. },
  315. error: function(jqXHR, textStatus, errorThrown){
  316. toastr.error('error: ' + textStatus + " " + errorThrown);
  317. if (errorCallBack) {
  318. errorCallBack();
  319. }
  320. if (showWaiting) closeWaitingView();
  321. }
  322. });
  323. };
  324. const postDataAsync = function (url, data, showWaiting = true) {
  325. return new Promise(function (resolve, reject) {
  326. postData(url, data, result => {
  327. resolve(result);
  328. }, err => {
  329. reject(err);
  330. }, showWaiting);
  331. }).catch((e) => { console.log(e) });
  332. };
  333. /**
  334. * 动态请求数据(压缩数据)
  335. * @param {String} url - 请求链接
  336. * @param data - 提交数据
  337. * @param {function} successCallback - 返回成功回调
  338. * @param {function} errorCallBack - 返回失败回调
  339. */
  340. const postDataCompress = function (url, data, successCallback, errorCallBack, htype = 'progress') {
  341. if (htype === 'wait') showWaitingView();
  342. if (htype === 'progress') showProgress();
  343. $.ajax({
  344. type:"POST",
  345. url: url,
  346. data: {'data': LZString.compressToUTF16(JSON.stringify(data))},
  347. dataType: 'json',
  348. cache: false,
  349. timeout: postDefaultTime,
  350. beforeSend: function(xhr) {
  351. let csrfToken = Cookies.get('csrfToken_j');
  352. xhr.setRequestHeader('x-csrf-token', csrfToken);
  353. },
  354. success: function(result){
  355. if (htype === 'progress') doneProgress();
  356. if (result.err === 0) {
  357. if (successCallback) {
  358. successCallback(result.data);
  359. }
  360. } else if (result.err === 2) {
  361. toastr.error('error: ' + result.msg);
  362. setTimeout(function () {
  363. window.location.href = '/login';
  364. },1000);
  365. } else {
  366. toastr.error('error: ' + result.msg);
  367. if (errorCallBack) {
  368. errorCallBack(result.msg);
  369. }
  370. }
  371. if (htype === 'wait') closeWaitingView();
  372. if (htype === 'progress') closeProgress();
  373. },
  374. error: function(jqXHR, textStatus, errorThrown){
  375. toastr.error('error: ' + textStatus + " " + errorThrown);
  376. if (errorCallBack) {
  377. errorCallBack();
  378. }
  379. if (htype === 'wait') closeWaitingView();
  380. if (htype === 'progress') closeProgress();
  381. }
  382. });
  383. };
  384. /**
  385. * 动态请求数据
  386. * @param {String} url - 请求链接
  387. * @param data - 提交数据
  388. * @param {function} successCallback - 返回成功回调
  389. * @param {function} errorCallBack - 返回失败回调
  390. */
  391. const postDataWithFile = function (url, formData, successCallback, errorCallBack, showWaiting = true) {
  392. if (showWaiting) showWaitingView();
  393. if (formData.getAll('file[]').length > 10) {
  394. toastr.error('文件数量不能多于10个');
  395. if (showWaiting) closeWaitingView();
  396. return
  397. }
  398. $.ajax({
  399. type:"POST",
  400. url: url,
  401. data: formData,
  402. dataType: 'json',
  403. cache: false,
  404. // 告诉jQuery不要去设置Content-Type请求头
  405. contentType: false,
  406. // 告诉jQuery不要去处理发送的数据
  407. processData: false,
  408. timeout: postDefaultTime,
  409. beforeSend: function(xhr) {
  410. let csrfToken = Cookies.get('csrfToken_j');
  411. xhr.setRequestHeader('x-csrf-token', csrfToken);
  412. },
  413. success: function(result){
  414. if (result.err === 0) {
  415. if (successCallback) {
  416. successCallback(result.data);
  417. }
  418. } else if (result.err === 2) {
  419. toastr.error('error: ' + result.msg);
  420. setTimeout(function () {
  421. window.location.href = '/login';
  422. },1000);
  423. } else {
  424. toastr.error('error: ' + result.msg);
  425. if (errorCallBack) {
  426. errorCallBack();
  427. }
  428. }
  429. if (showWaiting) closeWaitingView();
  430. },
  431. error: function(jqXHR, textStatus, errorThrown){
  432. toastr.error('error: ' + textStatus + " " + errorThrown);
  433. if (errorCallBack) {
  434. errorCallBack();
  435. }
  436. if (showWaiting) closeWaitingView();
  437. }
  438. });
  439. };
  440. const postDataWithFileAsync = function (url, formData, showWaiting = true) {
  441. return new Promise(function (resolve, reject) {
  442. postDataWithFile(url, formData, result => {
  443. resolve(result);
  444. }, err => {
  445. reject(err);
  446. }, showWaiting);
  447. });
  448. };
  449. const postDataWithFileProgress = function (url, formData, successCallback, errorCallBack) {
  450. showUploadFileProgress();
  451. $.ajax({
  452. type:"POST",
  453. url: url,
  454. data: formData,
  455. dataType: 'json',
  456. cache: false,
  457. // 告诉jQuery不要去设置Content-Type请求头
  458. contentType: false,
  459. // 告诉jQuery不要去处理发送的数据
  460. processData: false,
  461. beforeSend: function(xhr) {
  462. let csrfToken = Cookies.get('csrfToken_j');
  463. xhr.setRequestHeader('x-csrf-token', csrfToken);
  464. },
  465. success: function(result){
  466. doneProgress();
  467. if (result.err === 0) {
  468. if (successCallback) {
  469. successCallback(result.data);
  470. }
  471. } else if (result.err === 2) {
  472. toastr.error('error: ' + result.msg);
  473. setTimeout(function () {
  474. window.location.href = '/login';
  475. },1000);
  476. } else {
  477. toastr.error('error: ' + result.msg);
  478. if (errorCallBack) {
  479. errorCallBack();
  480. }
  481. }
  482. closeProgress();
  483. },
  484. error: function(jqXHR, textStatus, errorThrown){
  485. toastr.error('error: ' + textStatus + " " + errorThrown);
  486. if (errorCallBack) {
  487. errorCallBack();
  488. }
  489. closeProgress();
  490. },
  491. xhr: function() {
  492. var xhr = new XMLHttpRequest();
  493. //使用XMLHttpRequest.upload监听上传过程,注册progress事件,打印回调函数中的event事件
  494. xhr.upload.addEventListener('progress', function (e) {
  495. console.log(e);
  496. //loaded代表上传了多少
  497. //total代表总数为多少
  498. var progressRate = (e.loaded / e.total) * 95;
  499. //通过设置进度条的宽度达到效果
  500. setUploadFileProgress(progressRate);
  501. })
  502. return xhr;
  503. }
  504. });
  505. }
  506. const postCompressFile = function (url, data, successCallback, errorCallBack) {
  507. $.ajax({
  508. type:"POST",
  509. url: url,
  510. data: {'data': JSON.stringify(data)},
  511. // dataType: 'blob',
  512. cache: false,
  513. timeout: 180000,
  514. xhrFields: {
  515. responseType: 'blob'
  516. },
  517. beforeSend: function(xhr) {
  518. let csrfToken = Cookies.get('csrfToken_j');
  519. xhr.setRequestHeader('x-csrf-token', csrfToken);
  520. },
  521. success: function(result){
  522. // if (result.err === 0) {
  523. // if (successCallback) {
  524. // successCallback(result.data);
  525. // }
  526. // } else if (result.err === 2) {
  527. // toastr.error('error: ' + result.msg);
  528. // setTimeout(function () {
  529. // window.location.href = '/login';
  530. // },1000);
  531. // } else {
  532. // toastr.error('error: ' + result.msg);
  533. // if (errorCallBack) {
  534. // errorCallBack(result.msg);
  535. // }
  536. // }
  537. if (successCallback) {
  538. successCallback(result)
  539. }
  540. },
  541. error: function(jqXHR, textStatus, errorThrown){
  542. // console.log(jqXHR, textStatus, errorThrown);
  543. // toastr.error('error: ' + textStatus + " " + errorThrown);
  544. if (errorCallBack) {
  545. errorCallBack();
  546. }
  547. }
  548. });
  549. }
  550. /**
  551. * 获取url中参数
  552. * @param variable
  553. * @returns {*}
  554. */
  555. function getQueryVariable(variable) {
  556. var query = window.location.search.substring(1);
  557. var vars = query.split("&");
  558. for (var i=0;i<vars.length;i++) {
  559. var pair = vars[i].split("=");
  560. if(pair[0] == variable){return pair[1];}
  561. }
  562. return(false);
  563. }
  564. const zeroRange = 0.00000001;
  565. function checkZero(value) {
  566. return value === null || value === undefined || (_.isNumber(value) && Math.abs(value) < zeroRange);
  567. }
  568. function checkFieldChange(o, n) {
  569. return o == n || ((!o || o === '') && (n === ''));
  570. }
  571. var bShowWaiting = false, beginWaitingTime;
  572. //关闭等待窗口
  573. function closeWaitingView() {
  574. bShowWaiting = false;
  575. const time = parseInt(new Date());
  576. setTimeout(function () {
  577. var bgDiv = document.getElementById("bgDiv");
  578. var msgDiv = document.getElementById("msgDiv");
  579. //移除背景遮罩层div
  580. if(bgDiv != null){
  581. document.body.removeChild(bgDiv);
  582. }
  583. //移除中间信息提示层div
  584. if(msgDiv != null){
  585. document.body.removeChild(msgDiv);
  586. }
  587. }, Math.max(beginWaitingTime - time + 500, 0));
  588. }
  589. //显示等待窗口
  590. function showWaitingView() {
  591. // bShowWaiting = true;
  592. // setTimeout(function () {
  593. // if (!bShowWaiting) return;
  594. // beginWaitingTime = parseInt(new Date());
  595. // var msgw = 300; //提示窗口的宽度
  596. // var msgh = 100; //提示窗口的高度
  597. //
  598. // var sWidth, sHeight;
  599. // sWidth = document.body.clientWidth;
  600. // sHeight = document.body.clientHeight;
  601. //
  602. // //背景遮罩层div
  603. // var bgObj = document.createElement("div");
  604. // bgObj.setAttribute('id', 'bgDiv');
  605. // bgObj.style.zIndex = '9998';
  606. // bgObj.style.position = "absolute";
  607. // bgObj.style.top = "0px";
  608. // bgObj.style.background = "#888";
  609. // bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
  610. // bgObj.style.opacity = "0.6";
  611. // bgObj.style.left = "0px";
  612. // bgObj.style.width = sWidth + "px";
  613. // bgObj.style.height = sHeight + "px";
  614. // document.body.appendChild(bgObj);
  615. //
  616. // //信息提示层div
  617. // var msgObj = document.createElement("div");
  618. // msgObj.style.zIndex = '9999';
  619. // msgObj.setAttribute("id", "msgDiv");
  620. // msgObj.setAttribute("align", "center");
  621. // msgObj.style.position = "absolute";
  622. // msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
  623. // msgObj.style.width = msgw + "px";
  624. // msgObj.style.height = msgh + "px";
  625. // msgObj.style.top = (document.documentElement.scrollTop + (sHeight - msgh) / 2) + "px";
  626. // msgObj.style.left = (sWidth - msgw) / 2 + "px";
  627. // document.body.appendChild(msgObj);
  628. //
  629. // //中间等待图标
  630. // document.getElementById("msgDiv").innerHTML = '<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>';
  631. // }, 1000);
  632. beginWaitingTime = parseInt(new Date());
  633. var msgw = 300; //提示窗口的宽度
  634. var msgh = 100; //提示窗口的高度
  635. var sWidth, sHeight;
  636. sWidth = document.body.clientWidth;
  637. sHeight = document.body.clientHeight;
  638. //背景遮罩层div
  639. var bgObj = document.createElement("div");
  640. bgObj.setAttribute('id', 'bgDiv');
  641. bgObj.style.zIndex = '9998';
  642. bgObj.style.position = "absolute";
  643. bgObj.style.top = "0px";
  644. // bgObj.style.background = "#888";
  645. bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
  646. bgObj.style.opacity = "0.6";
  647. bgObj.style.left = "0px";
  648. bgObj.style.width = sWidth + "px";
  649. bgObj.style.height = sHeight + "px";
  650. document.body.appendChild(bgObj);
  651. //信息提示层div
  652. var msgObj = document.createElement("div");
  653. msgObj.style.zIndex = '9999';
  654. msgObj.setAttribute("id", "msgDiv");
  655. msgObj.setAttribute("align", "center");
  656. msgObj.style.position = "absolute";
  657. msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
  658. msgObj.style.width = msgw + "px";
  659. msgObj.style.height = msgh + "px";
  660. msgObj.style.top = (document.documentElement.scrollTop + (sHeight - msgh) / 2) + "px";
  661. msgObj.style.left = (sWidth - msgw) / 2 + "px";
  662. document.body.appendChild(msgObj);
  663. //中间等待图标
  664. document.getElementById("msgDiv").innerHTML = '<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>';
  665. }
  666. let progressInterval;
  667. function showProgress() {
  668. var sWidth, sHeight;
  669. sWidth = document.body.clientWidth;
  670. sHeight = document.body.clientHeight;
  671. //背景遮罩层div
  672. var bgObj = document.createElement("div");
  673. bgObj.setAttribute('id', 'bgDiv');
  674. bgObj.style.zIndex = '9998';
  675. bgObj.style.position = "absolute";
  676. bgObj.style.top = "0px";
  677. bgObj.style.background = "#888";
  678. bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
  679. bgObj.style.opacity = "0.6";
  680. bgObj.style.left = "0px";
  681. bgObj.style.width = sWidth + "px";
  682. bgObj.style.height = sHeight + "px";
  683. document.body.appendChild(bgObj);
  684. //信息提示层div
  685. var msgObj = document.createElement("div");
  686. msgObj.classList.add('progress');
  687. msgObj.style.zIndex = '9999';
  688. msgObj.style.position = "absolute";
  689. msgObj.setAttribute("id", "progressDiv");
  690. msgObj.style.height = "2px";
  691. msgObj.style.width = "600px";
  692. msgObj.style.top = (document.documentElement.scrollTop + sHeight / 2) + "px";
  693. msgObj.style.left = (sWidth - 600) / 2 + "px";
  694. document.body.appendChild(msgObj);
  695. msgObj.innerHTML = '<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>';
  696. const processObj = $('.progress-bar');
  697. let count = 0;
  698. progressInterval = setInterval(function () {
  699. const pos = parseInt(processObj.attr('aria-valuenow'));
  700. if (pos < 20) { // 1
  701. processObj.attr('aria-valuenow', pos + 2);
  702. processObj.width((pos + 2) + '%');
  703. } else if (pos < 40) { // 2
  704. processObj.attr('aria-valuenow', pos + 1);
  705. processObj.width((pos + 1) + '%');
  706. } else if (pos < 60) { // 4
  707. count += 1;
  708. if (count % 2 === 0) {
  709. processObj.attr('aria-valuenow', pos + 1);
  710. processObj.width((pos + 1) + '%');
  711. }
  712. } else if (pos < 80) { // 10
  713. count += 1;
  714. if (count % 5 === 0) {
  715. processObj.attr('aria-valuenow', pos + 1);
  716. processObj.width((pos + 1) + '%');
  717. }
  718. } else if (pos < 90) { // 15
  719. count += 1;
  720. if (count % 15 === 0) {
  721. processObj.attr('aria-valuenow', pos + 1);
  722. processObj.width((pos + 1) + '%');
  723. }
  724. } else if (pos < 95) { // 20
  725. count += 1;
  726. if (count % 40 === 0) {
  727. processObj.attr('aria-valuenow', pos + 1);
  728. processObj.width((pos + 1) + '%');
  729. }
  730. } else if (pos < 100) { // 30
  731. count += 1;
  732. if (count % 60 === 0) {
  733. processObj.attr('aria-valuenow', pos + 1);
  734. }
  735. }
  736. }, 100);
  737. }
  738. function doneProgress() {
  739. clearInterval(progressInterval);
  740. $('.progress-bar').attr('aria-valuenow', 100).width('100%');
  741. }
  742. function closeProgress() {
  743. setTimeout(function () {
  744. var bgDiv = document.getElementById("bgDiv");
  745. var msgDiv = document.getElementById("progressDiv");
  746. //移除背景遮罩层div
  747. if(bgDiv != null){
  748. document.body.removeChild(bgDiv);
  749. }
  750. //移除中间信息提示层div
  751. if(msgDiv != null){
  752. document.body.removeChild(msgDiv);
  753. }
  754. }, 500);
  755. }
  756. function showUploadFileProgress() {
  757. var sWidth, sHeight;
  758. sWidth = document.body.clientWidth;
  759. sHeight = document.body.clientHeight;
  760. //背景遮罩层div
  761. var bgObj = document.createElement("div");
  762. bgObj.setAttribute('id', 'bgDiv');
  763. bgObj.style.zIndex = '9998';
  764. bgObj.style.position = "absolute";
  765. bgObj.style.top = "0px";
  766. bgObj.style.background = "#888";
  767. bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
  768. bgObj.style.opacity = "0.6";
  769. bgObj.style.left = "0px";
  770. bgObj.style.width = sWidth + "px";
  771. bgObj.style.height = sHeight + "px";
  772. document.body.appendChild(bgObj);
  773. //信息提示层div
  774. var msgObj = document.createElement("div");
  775. msgObj.classList.add('progress');
  776. msgObj.style.zIndex = '9999';
  777. msgObj.style.position = "absolute";
  778. msgObj.setAttribute("id", "progressDiv");
  779. msgObj.style.height = "2px";
  780. msgObj.style.width = "600px";
  781. msgObj.style.top = (document.documentElement.scrollTop + sHeight / 2) + "px";
  782. msgObj.style.left = (sWidth - 600) / 2 + "px";
  783. document.body.appendChild(msgObj);
  784. msgObj.innerHTML = '<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>';
  785. }
  786. function setUploadFileProgress(pos) {
  787. const processObj = $('.progress-bar');
  788. processObj.attr('aria-valuenow', pos);
  789. processObj.width(pos + '%');
  790. }
  791. /**
  792. * 设置本地缓存
  793. *
  794. * @param {String} key
  795. * @param {String|Number} value
  796. * @return {void}
  797. */
  798. function setLocalCache(key, value) {
  799. const storage = window.localStorage;
  800. if (!storage || key === '' || value === '') {
  801. return;
  802. }
  803. storage.setItem(key, value);
  804. }
  805. /**
  806. * 获取本地缓存
  807. *
  808. * @param {String} key
  809. * @return {String}
  810. */
  811. function getLocalCache(key) {
  812. const storage = window.localStorage;
  813. if (!storage || key === '') {
  814. return null;
  815. }
  816. return storage.getItem(key);
  817. }
  818. /**
  819. * 移除本地缓存
  820. * @param {String} key
  821. * @returns {Boolean}
  822. */
  823. function removeLocalCache(key) {
  824. const storage = window.localStorage;
  825. if (!storage || key === '') {
  826. return null;
  827. }
  828. return storage.removeItem(key);
  829. }
  830. //params: 需要复制的对象(元素)
  831. function copyToClipboard( text ) {
  832. var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  833. var aux = document.createElement('textarea');// 创建元素用于复制
  834. // Prevent zooming on iOS
  835. aux.style.fontSize = '12pt';
  836. // Reset box model
  837. aux.style.border = '0';
  838. aux.style.padding = '0';
  839. aux.style.margin = '0';
  840. // Move element out of screen horizontally
  841. aux.style.position = 'absolute';
  842. aux.style[isRTL ? 'right' : 'left'] = '-9999px';
  843. // Move element to the same position vertically
  844. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  845. aux.style.top = yPosition + 'px';
  846. aux.setAttribute('readonly', '');
  847. // 设置元素内容
  848. aux.value = text;
  849. // 将元素插入页面进行调用
  850. document.body.appendChild(aux);
  851. // 复制内容
  852. aux.select();
  853. aux.setSelectionRange(0, text.length);
  854. // 将内容复制到剪贴板
  855. document.execCommand("copy", true);
  856. // 删除创建元素
  857. document.body.removeChild(aux);
  858. }
  859. function toastMessageUniq (obj) {
  860. if (!obj.msg || !obj.type) return;
  861. if (!obj.once) {
  862. switch (obj.type) {
  863. case 'error':
  864. toastr.error(obj.msg);
  865. break;
  866. case 'warning':
  867. toastr.warning(obj.msg);
  868. break;
  869. case 'info':
  870. toastr.info(obj.msg);
  871. break;
  872. case 'success':
  873. toastr.success(obj.msg);
  874. break;
  875. }
  876. obj.once = true;
  877. }
  878. }
  879. function trimInvalidChar(str) {
  880. return $.trim(str).replace(/\n/g, '').replace(/\r/g, '').replace(/\t/g, '');
  881. }
  882. function cleanSymbols(str) {
  883. return $.trim(str).replace(/\\/g, '').replace(/\'/g, '').replace(/\"/g, '').replace(/\</g, '').replace(/\|/g, '');
  884. }
  885. jQuery.bootstrapLoading = {
  886. isLoading: function () {
  887. return $('#loadingPage').is(':visible');
  888. },
  889. start: function (options) {
  890. if(this.isLoading()){
  891. return;
  892. }
  893. var defaults = {
  894. opacity: 0.5,
  895. //loading页面透明度
  896. // backgroundColor: "#FFFFFF",
  897. //loading页面背景色
  898. borderColor: "#bbb",
  899. //提示边框颜色
  900. borderWidth: 1,
  901. //提示边框宽度
  902. borderStyle: "solid",
  903. //提示边框样式
  904. loadingTips: "Loading, please wait...",
  905. //提示文本
  906. TipsColor: "#fff",
  907. //提示颜色
  908. delayTime: 500,
  909. //页面加载完成后,加载页面渐出速度
  910. zindex: 2000,
  911. //loading页面层次
  912. sleep: 0
  913. //设置挂起,等于0时则无需挂起
  914. }
  915. var options = $.extend(defaults, options);
  916. //获取页面宽高
  917. var _PageHeight = document.documentElement.clientHeight,
  918. _PageWidth = document.documentElement.clientWidth;
  919. //在页面未加载完毕之前显示的loading Html自定义内容
  920. //var _LoadingHtml = '<div id="loadingPage" style="position:fixed;left:0;top:0;_position: absolute;width:100%;height:' + _PageHeight + 'px;background:' + options.backgroundColor + ';opacity:' + options.opacity + ';filter:alpha(opacity=' + options.opacity * 100 + ');z-index:' + options.zindex + ';"><div id="loadingTips" style="position: absolute; cursor1: wait; width: auto;border-color:' + options.borderColor + ';border-style:' + options.borderStyle + ';border-width:' + options.borderWidth + 'px; height:80px; line-height:80px; padding-left:80px; padding-right: 5px;border-radius:10px; background: ' + options.backgroundColor + ' url(/Content/bootstrap-loading/images/loading.gif) no-repeat 5px center; color:' + options.TipsColor + ';font-size:20px;">' + options.loadingTips + '</div></div>';
  921. var _LoadingHtml = '<div id="loadingPage" style="position:fixed;left:0;top:0;_position: absolute;width:100%;height:' + _PageHeight + 'px;background:' + options.backgroundColor + ';opacity:' + options.opacity + ';filter:alpha(opacity=' + options.opacity * 100 + ');z-index:' + options.zindex + ';"><div id="loadingTips" style="position: absolute; cursor1: wait; width: auto;">' +'<div class="text-green"><i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i> <span class="sr-only">Loading...</span> </div> </div></div>';
  922. //呈现loading效果
  923. $("body").append(_LoadingHtml);
  924. //获取loading提示框宽高
  925. var _LoadingTipsH = document.getElementById("loadingTips").clientHeight,
  926. _LoadingTipsW = document.getElementById("loadingTips").clientWidth;
  927. //计算距离,让loading提示框保持在屏幕上下左右居中
  928. var _LoadingTop = _PageHeight > _LoadingTipsH ? (_PageHeight - _LoadingTipsH) / 2 : 0,
  929. _LoadingLeft = _PageWidth > _LoadingTipsW ? (_PageWidth - _LoadingTipsW) / 2 : 0;
  930. $("#loadingTips").css({
  931. "left": _LoadingLeft + "px",
  932. "top": _LoadingTop + "px"
  933. });
  934. //监听页面加载状态
  935. document.onreadystatechange = PageLoaded;
  936. //当页面加载完成后执行
  937. function PageLoaded() {
  938. if (document.readyState == "complete") {
  939. var loadingMask = $('#loadingPage');
  940. setTimeout(function () {
  941. loadingMask.animate({
  942. "opacity": 0
  943. },
  944. options.delayTime,
  945. function () {
  946. $(this).hide();
  947. });
  948. },
  949. options.sleep);
  950. }
  951. }
  952. },
  953. end: function () {
  954. $("#loadingPage").remove();
  955. },
  956. progressStop:true,
  957. progressStart:async function(title="导出文件",autoBar = false){
  958. if($("#progressModal").length == 0){
  959. let phtml = `<div class="modal fade" id="progressModal" data-backdrop="static">
  960. <div class="modal-dialog" role="document">
  961. <div class="modal-content">
  962. <div class="modal-header">
  963. <h5 class="modal-title" id="progress_modal_title">${title}</h5>
  964. </div>
  965. <div class="modal-body">
  966. <!--正在生成-->
  967. <h5 class="my-3" id="progress_modal_body">正在${title}</h5>
  968. <div class="progress mb-3">
  969. <div id="progress_modal_bar" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 10%"></div>
  970. </div>
  971. </div>
  972. </div>
  973. </div>
  974. </div>`;
  975. $("body").append(phtml);
  976. }else {
  977. $("#progress_modal_title").text(title);
  978. $("#progress_modal_body").text(`正在${title}`);
  979. }
  980. $("#progress_modal_bar").css('width','0%');
  981. $("#progressModal").modal('show');
  982. if(autoBar == true){//假的进度条
  983. $.bootstrapLoading.progressStop = false;
  984. let width = 0;
  985. while ($.bootstrapLoading.progressStop == false){
  986. await setTimeoutSync(null,1000);
  987. width += 5;
  988. if(width > 90) width -= 50;
  989. $("#progress_modal_bar").css('width',`${width}%`);
  990. }
  991. }
  992. },
  993. progressEnd:function () {
  994. $("#progress_modal_bar").css('width','100%');
  995. $.bootstrapLoading.progressStop = true;
  996. $("#progressModal").modal('hide');
  997. }
  998. };
  999. // 光标插入button内容
  1000. $.fn.extend({
  1001. insertAtCaret: function(myValue){
  1002. var $t=$(this)[0];
  1003. if (document.selection) {
  1004. this.focus();
  1005. sel = document.selection.createRange();
  1006. sel.text = myValue;
  1007. this.focus();
  1008. }
  1009. else
  1010. if ($t.selectionStart || $t.selectionStart == '0') {
  1011. var startPos = $t.selectionStart;
  1012. var endPos = $t.selectionEnd;
  1013. var scrollTop = $t.scrollTop;
  1014. $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
  1015. this.focus();
  1016. $t.selectionStart = startPos + myValue.length;
  1017. $t.selectionEnd = startPos + myValue.length;
  1018. $t.scrollTop = scrollTop;
  1019. }
  1020. else {
  1021. this.value += myValue;
  1022. this.focus();
  1023. }
  1024. }
  1025. });
  1026. const checkUtils = {
  1027. _checkPosOverRangeTz(p, coe) {
  1028. const end_contract_qty = ZhCalc.add(p.pre_contract_qty, p.contract_qty);
  1029. const base_qty = p.quantity;
  1030. const compare_qty = ZhCalc.mul(p.final_1_qty, coe);
  1031. if (!base_qty) return !!end_contract_qty;
  1032. return base_qty > 0
  1033. ? end_contract_qty > compare_qty
  1034. : (compare_qty > 0 ? true : end_contract_qty < compare_qty || end_contract_qty > 0);
  1035. },
  1036. _checkBillsOverRangeTz(bills, coe) {
  1037. const end_contract_qty = ZhCalc.add(bills.contract_qty, bills.pre_contract_qty);
  1038. const end_contract_tp = ZhCalc.add(bills.contract_tp, bills.pre_contract_tp);
  1039. if (bills.is_tp) {
  1040. const base_tp = bills.total_price;
  1041. const compare_tp = ZhCalc.mul(base_tp, coe);
  1042. if (!base_tp) return !!end_contract_tp;
  1043. return base_tp >= 0 ? end_contract_tp > compare_tp : end_contract_tp < compare_tp || end_contract_tp > 0;
  1044. } else {
  1045. const base_qty = bills.quantity;
  1046. const compare_qty = ZhCalc.mul(bills.final_1_qty, coe);
  1047. if (!base_qty) return !!end_contract_qty;
  1048. return base_qty > 0
  1049. ? end_contract_qty > compare_qty
  1050. : (compare_qty > 0 ? true : end_contract_qty < compare_qty || end_contract_qty > 0);
  1051. }
  1052. },
  1053. _checkBillsOverRangeDeal(bills, coe) {
  1054. const end_contract_qty = ZhCalc.add(bills.contract_qty, bills.pre_contract_qty);
  1055. const end_contract_tp = ZhCalc.add(bills.contract_tp, bills.pre_contract_tp);
  1056. if (bills.is_tp) {
  1057. const base_tp = bills.deal_tp;
  1058. const compare_tp = ZhCalc.mul(base_tp, coe);
  1059. if (!base_tp) return !!end_contract_tp;
  1060. return base_tp >= 0 ? end_contract_tp > compare_tp : end_contract_tp < compare_tp || end_contract_tp > 0;
  1061. } else {
  1062. const base_qty = bills.deal_qty;
  1063. const compare_qty = ZhCalc.mul(bills.deal_final_1_qty, coe);
  1064. if (!base_qty) return !!end_contract_qty;
  1065. return base_qty > 0
  1066. ? end_contract_qty > compare_qty
  1067. : (compare_qty > 0 ? true : end_contract_qty < compare_qty || end_contract_qty > 0);
  1068. }
  1069. },
  1070. posOver(pos, checkInfo) {
  1071. if (!pos) return false;
  1072. const checkTz = checkInfo.checkTz ? this._checkPosOverRangeTz(pos, checkInfo.coe) : false;
  1073. const checkDeal = false;
  1074. return checkTz || checkDeal;
  1075. },
  1076. billsOver(bills, relaPos, checkInfo) {
  1077. if (!bills) return false;
  1078. const posRange = relaPos.ledgerPos[itemsPre + bills.id] || [];
  1079. if (checkInfo.hasPosCheckPos && posRange.length > 0) {
  1080. for (const p of posRange) {
  1081. if (this.posOver(p, checkInfo)) return true;
  1082. }
  1083. }
  1084. if (checkInfo.hasPosCheckBills || posRange.length === 0) {
  1085. const checkTz = checkInfo.checkTz ? this._checkBillsOverRangeTz(bills, checkInfo.coe) : false;
  1086. const checkDeal = checkInfo.checkDeal ? this._checkBillsOverRangeDeal(bills, checkInfo.coe) : false;
  1087. return checkTz || checkDeal;
  1088. }
  1089. return false;
  1090. },
  1091. compareCode(str1, str2, symbol = '-') {
  1092. if (!str1) {
  1093. return 1;
  1094. } else if (!str2) {
  1095. return -1;
  1096. }
  1097. function compareSubCode(code1, code2) {
  1098. if (numReg.test(code1)) {
  1099. if (numReg.test(code2)) {
  1100. return parseInt(code1) - parseInt(code2);
  1101. } else {
  1102. return -1
  1103. }
  1104. } else {
  1105. if (numReg.test(code2)) {
  1106. return 1;
  1107. } else {
  1108. return code1 === code2 ? 0 : (code1 < code2 ? -1 : 1); //code1.localeCompare(code2);
  1109. }
  1110. }
  1111. }
  1112. const numReg = /^[0-9]+$/;
  1113. const aCodes = str1.split(symbol), bCodes = str2.split(symbol);
  1114. for (let i = 0, iLength = Math.min(aCodes.length, bCodes.length); i < iLength; ++i) {
  1115. const iCompare = compareSubCode(aCodes[i], bCodes[i]);
  1116. if (iCompare !== 0) {
  1117. return iCompare;
  1118. }
  1119. }
  1120. return aCodes.length - bCodes.length;
  1121. },
  1122. };
  1123. Number.prototype.format2Str = function (pattern) {
  1124. var strarr = this?this.toString().split('.'):['0'];
  1125. var fmtarr = pattern?pattern.split('.'):[''];
  1126. var retstr='';
  1127. // 整数部分
  1128. var str = strarr[0];
  1129. var fmt = fmtarr[0];
  1130. var i = str.length-1;
  1131. var comma = false;
  1132. for(var f=fmt.length-1;f>=0;f--){
  1133. switch(fmt.substr(f,1)){
  1134. case '#':
  1135. if(i>=0 ) retstr = str.substr(i--,1) + retstr;
  1136. break;
  1137. case '0':
  1138. if(i>=0) retstr = str.substr(i--,1) + retstr;
  1139. else retstr = '0' + retstr;
  1140. break;
  1141. case ',':
  1142. comma = true;
  1143. retstr=','+retstr;
  1144. break;
  1145. }
  1146. }
  1147. if(i>=0){
  1148. if(comma){
  1149. var l = str.length;
  1150. for(;i>=0;i--){
  1151. retstr = str.substr(i,1) + retstr;
  1152. if(i>0 && ((l-i)%3)==0) retstr = ',' + retstr;
  1153. }
  1154. }
  1155. else retstr = str.substr(0,i+1) + retstr;
  1156. }
  1157. retstr = retstr+'.';
  1158. // 处理小数部分
  1159. str=strarr.length>1?strarr[1]:'';
  1160. fmt=fmtarr.length>1?fmtarr[1]:'';
  1161. i=0;
  1162. for(var f=0;f<fmt.length;f++){
  1163. switch(fmt.substr(f,1)){
  1164. case '#':
  1165. if(i<str.length) retstr+=str.substr(i++,1);
  1166. break;
  1167. case '0':
  1168. if(i<str.length) retstr+= str.substr(i++,1);
  1169. else retstr+='0';
  1170. break;
  1171. }
  1172. }
  1173. return retstr.replace(/^,+/,'').replace(/\.$/,'');
  1174. };
  1175. function transFormToChinese(num) {
  1176. const changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
  1177. const unit = ["", "十", "百", "千", "万"];
  1178. num = parseInt(num);
  1179. let getWan = (temp) => {
  1180. let strArr = temp.toString().split("").reverse();
  1181. let newNum = "";
  1182. for (var i = 0; i < strArr.length; i++) {
  1183. newNum = (i == 0 && strArr[i] == 0 ? "" : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? "" : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum;
  1184. }
  1185. return strArr.length === 2 && newNum.indexOf("一十") !== -1 ? newNum.replace('一十', '十') : newNum;
  1186. }
  1187. let overWan = Math.floor(num / 10000);
  1188. let noWan = num % 10000;
  1189. if (noWan.toString().length < 4) noWan = "0" + noWan;
  1190. return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num);
  1191. }
  1192. function hpackArrBack(data) {
  1193. if (data.length === 0) return data;
  1194. if (data.length === 1) throw '数据错误';
  1195. const result = [];
  1196. //const keyIndex = {};
  1197. // data[0].forEach((x, i) => {
  1198. // keyIndex[x] = i;
  1199. // });
  1200. const key = data[0];
  1201. data.forEach((d, i) => {
  1202. if (i === 0) return;
  1203. const obj = {};
  1204. d.forEach((v, j) => {
  1205. if (v === undefined) return;
  1206. obj[key[j]] = v;
  1207. });
  1208. result.push(obj);
  1209. });
  1210. return result;
  1211. }
  1212. const spreadColor = {
  1213. stage: {
  1214. over: '#FF9595', //'#ff6f5c', '#f8d7da'
  1215. differ: '#FF9595', // '#F2DEDE',
  1216. settle: '#f2f2f2',
  1217. },
  1218. gcl: {
  1219. differ: '#FFE699', // 同编号时,名称、单位、单价存在不同
  1220. calc_differ: '#f8d7da', //
  1221. },
  1222. pay: {
  1223. expr_err: '#FF9595',
  1224. pause: '#f2f2f2',
  1225. yf_without: '#d6d8db',
  1226. cur_add: '#FFFFE1',
  1227. },
  1228. safe: {
  1229. differ: '#F2DEDE',
  1230. },
  1231. revise: {
  1232. used: '#F2F2F2',
  1233. }
  1234. };
  1235. const featureShowCache = 'zh-feature-show';
  1236. $(document).ready(function () {
  1237. $('.modal').draggable({handle: '.modal-header'});
  1238. });