global.js 45 KB

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