global.js 46 KB

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