global.js 46 KB

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