12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109 |
- /*全局自适应高度*/
- /*全局自适应高度*/
- function autoFlashHeight(){
- function getObjHeight(select) {
- return select.length > 0 ? select.height() : 0;
- }
- /*侧栏高度*/
- var sBar1 = getObjHeight($(".sjs-bar-1"));
- var sBar2 = getObjHeight($(".sjs-bar-2"));
- var sBar3 = getObjHeight($(".sjs-bar-3"));
- var sBar4 = getObjHeight($(".sjs-bar-4"));
- var sBar5 = getObjHeight($(".sjs-bar-5"));
- /*侧栏高度*/
- var cHeader = getObjHeight($(".c-header"));
- var sBar = getObjHeight($(".sjs-bar"));
- var sBart = getObjHeight($(".sjs-bart"));
- var sBarz = getObjHeight($(".side-bar"));
- var pBarz = getObjHeight($(".toolsbar-f"));
- var bdtopc = getObjHeight($(".body-height-top"));
- var bcontent = getObjHeight($(".bcontent-wrap"));
- $(".sjs-height-0").height($(window).height()-cHeader-90+53);
- $(".sjs-height-1").height($(window).height()-cHeader-bcontent-90+53);
- $(".sjs-height-2").height($(window).height()-cHeader-sBarz-120);
- $(".sjs-height-3").height($(window).height()-cHeader-sBar-492+25+150);/*492*/
- $(".sjs-height-4").height($(window).height()-cHeader-pBarz-110+75);
- $(".sjs-height-5").height($(window).height()-cHeader-sBar-492+55);/*492*/
- $(".sjs-height-6").height($(window).height()-cHeader-34-sBar1);
- $(".sp-wrap").height(bcontent-30);
- /*侧栏高度*/
- $(".sjs-sh-1").height($(window).height()-cHeader-sBar1-92+55);
- $(".sjs-sh-2").height($(window).height()-cHeader-sBar2-92+55);
- $(".sjs-sh-3").height($(window).height()-cHeader-sBar3-92+55);
- $(".sjs-sh-4").height($(window).height()-cHeader-sBar4-92+55);
- $(".sjs-sh-5").height($(window).height()-cHeader-sBar5-92+55);
- for (const sh of $('.sjs-sh')) {
- $(sh).height($(window).height()-cHeader-getObjHeight($('.sjs-bar', sh.parentNode))-getObjHeight($('.sjs-bottom', sh.parentNode))-92+55);
- }
- /*工程变更添加清单高度*/
- $(".sjs-biangeng-height").height($(window).height()/3.3);
- };
- $(window).resize(autoFlashHeight);
- /*全局自适应高度结束*/
- $(function(){
- /*侧滑*/
- $(".open-sidebar").click(function(){
- $(".slide-sidebar").animate({width:"800"}).addClass("open");
- });
- $("body").click(function(event){
- var e = event || window.event; //浏览器兼容性
- if(!$(event.target).is('a')) {
- var elem = event.target || e.srcElement;
- while (elem) { //循环判断至跟节点,防止点击的是div子元素
- if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
- return false;
- }
- elem = elem.parentNode;
- }
- $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
- }
- });
- /*侧滑*/
- /*工具提示*/
- $(function () {
- $('[data-toggle="tooltip"]').tooltip()
- });
- /*侧栏菜单*/
- $(".bg-nav > li > a").click(function() {
- var self = $(this);
- var subMenu = $(this).siblings('ul.sub-menu');
- if(subMenu.length > 0) {
- if(subMenu.is(":visible")) {
- self.find('.menu-arrow').removeClass('fa-angle-up').addClass('fa-angle-down');
- subMenu.slideUp('fast');
- self.parent().removeClass('active');
- }else{
- self.parent().addClass('active');
- self.find('.menu-arrow').removeClass('fa-angle-down').addClass('fa-angle-up');
- subMenu.slideDown('fast');
- }
- }
- });
- // 数据提交
- $("#submit-form").click(function() {
- $("#save-form").submit();
- });
- // modal弹窗拖动
- // $(document).on("show.bs.modal", ".modal", function() {
- // $(this).draggable({
- // handle: ".modal-header" // 只能点击头部拖动
- // });
- // $(this).css("overflow", "hidden");
- // });
- // 动态生成datepicker
- $('body').on('focus', ".datepicker-here", function (e) {
- if ($(this).data("datepicker") != "1") {
- $(this).datepicker();
- }
- $(this).data("datepicker", "1");
- });
- $('a[href="/setting/user"]').each(function () {
- if (getLocalCache('account-pageSize')) {
- $(this).attr('href', $(this).attr('href') + '?pageSize=' + getLocalCache('account-pageSize'));
- }
- });
- $('.change_sort_link').each(function () {
- const tender_id = $(this).attr('href').split('/')[2];
- let orderSetting = getLocalCache('change-'+ tender_id +'-list-order');
- if(orderSetting) {
- const orders = orderSetting.split('|');
- $(this).attr('href', $(this).attr('href') + '?sort=' + orders[0] + '&order=' + orders[1]);
- }
- });
- $('.change_project_sort_link').each(function () {
- const tender_id = $(this).attr('href').split('/')[2];
- let orderSetting = getLocalCache('change-project-'+ tender_id +'-list-order');
- if(orderSetting) {
- const orders = orderSetting.split('|');
- $(this).attr('href', $(this).attr('href') + '?sort=' + orders[0] + '&order=' + orders[1]);
- }
- });
- $('.change_apply_sort_link').each(function () {
- const tender_id = $(this).attr('href').split('/')[2];
- let orderSetting = getLocalCache('change-apply-'+ tender_id +'-list-order');
- if(orderSetting) {
- const orders = orderSetting.split('|');
- $(this).attr('href', $(this).attr('href') + '?sort=' + orders[0] + '&order=' + orders[1]);
- }
- });
- $('#nav_management').click(function(e) {
- e.preventDefault()
- showWaitingView();
- $.ajax({
- type: 'GET',
- url: '/management/proxy/project/vertify',
- dataType: 'json',
- cache: false,
- timeout: 60000,
- success: function ({code = -1, data: { exist, is_admin, redirect } = { exist: 0, is_admin: false}}) {
- if (code === 0) {
- if (!exist && !is_admin) {
- toastr.error('「项目管理」系统不存在当前项目,请联系管理员进行处理。');
- } else if(!exist && is_admin) {
- $('#add-management').modal('show')
- } else {
- redirect && window.open(redirect)
- }
- }
- closeWaitingView()
- },
- error: function(jqXHR, textStatus, errorThrown){
- toastr.error('error: ' + textStatus + " " + errorThrown);
- closeWaitingView();
- }
- })
- });
- $('#add-management .btn-primary').click(function() {
- $('#add-management').modal('hide')
- $('#process-management').modal('show')
- $.ajax({
- tpye: 'post',
- url: '/management/proxy/project/add',
- dataType: 'json',
- cache: false,
- timeout: 60000,
- // beforeSend: function(xhr) {
- // let csrfToken = Cookies.get('csrfToken_j');
- // xhr.setRequestHeader('x-csrf-token', csrfToken);
- // },
- success: function ({code = -1, data = {}}) {
- if (code === 0) {
- timer = setTimeout(() => {
- $('#process-management .process-child').css('width', '100%')
- setTimeout(() => {
- const { redirect } = data
- redirect && window.open(redirect)
- $('#process-management').modal('hide')
- }, 150);
- }, 500);
- }
- }
- })
- })
- });
- function checkShowLast (count) {
- if (count > 12500) {
- $('a[name=showLevel][tag=last]').hide();
- } else {
- $('a[name=showLevel][tag=last]').show();
- }
- }
- /**
- * 提示框
- *
- * @param string message
- * @param string type
- * @param string icon
- * @return void
- */
- function toast(message, type, icon) {
- var toast = $(".toast");
- toast.addClass(type);
- toast.children('.message').html(message);
- var iconClass = 'fa-' + icon;
- toast.children('.icon').addClass(iconClass);
- toast.fadeIn(500);
- setTimeout(function() {
- toast.fadeOut('fast');
- toast.children('.message').text('');
- toast.children('.icon').removeClass(iconClass);
- }, 3000);
- }
- /**
- * 动态请求数据
- * @param {String} url - 请求链接
- * @param data - 提交数据
- * @param {function} successCallback - 返回成功回调
- * @param {function} errorCallBack - 返回失败回调
- */
- const postData = function (url, data, successCallback, errorCallBack, showWaiting = true) {
- if (showWaiting) showWaitingView();
- $.ajax({
- type:"POST",
- url: url,
- data: {'data': JSON.stringify(data)},
- dataType: 'json',
- cache: false,
- timeout: 60000,
- beforeSend: function(xhr) {
- let csrfToken = Cookies.get('csrfToken_j');
- xhr.setRequestHeader('x-csrf-token', csrfToken);
- },
- success: function(result){
- if (result.err === 0) {
- if (successCallback) {
- successCallback(result.data);
- }
- } else if (result.err === 2) {
- toastr.error('error: ' + result.msg);
- setTimeout(function () {
- window.location.href = '/login';
- },1000);
- } else {
- toastr.error('error: ' + result.msg);
- if (errorCallBack) {
- errorCallBack(result.msg);
- }
- }
- if (showWaiting) closeWaitingView();
- },
- error: function(jqXHR, textStatus, errorThrown){
- toastr.error('error: ' + textStatus + " " + errorThrown);
- if (errorCallBack) {
- errorCallBack();
- }
- if (showWaiting) closeWaitingView();
- }
- });
- };
- /**
- * 动态请求数据(压缩数据)
- * @param {String} url - 请求链接
- * @param data - 提交数据
- * @param {function} successCallback - 返回成功回调
- * @param {function} errorCallBack - 返回失败回调
- */
- const postDataCompress = function (url, data, successCallback, errorCallBack, htype = 'progress') {
- if (htype === 'wait') showWaitingView();
- if (htype === 'progress') showProgress();
- $.ajax({
- type:"POST",
- url: url,
- data: {'data': LZString.compressToUTF16(JSON.stringify(data))},
- dataType: 'json',
- cache: false,
- timeout: 80000, // 导入清单Excel(10w行)预计需要时间
- beforeSend: function(xhr) {
- let csrfToken = Cookies.get('csrfToken_j');
- xhr.setRequestHeader('x-csrf-token', csrfToken);
- },
- success: function(result){
- if (htype === 'progress') doneProgress();
- if (result.err === 0) {
- if (successCallback) {
- successCallback(result.data);
- }
- } else if (result.err === 2) {
- toastr.error('error: ' + result.msg);
- setTimeout(function () {
- window.location.href = '/login';
- },1000);
- } else {
- toastr.error('error: ' + result.msg);
- if (errorCallBack) {
- errorCallBack(result.msg);
- }
- }
- if (htype === 'wait') closeWaitingView();
- if (htype === 'progress') closeProgress();
- },
- error: function(jqXHR, textStatus, errorThrown){
- toastr.error('error: ' + textStatus + " " + errorThrown);
- if (errorCallBack) {
- errorCallBack();
- }
- if (htype === 'wait') closeWaitingView();
- if (htype === 'progress') closeProgress();
- }
- });
- };
- /**
- * 动态请求数据
- * @param {String} url - 请求链接
- * @param data - 提交数据
- * @param {function} successCallback - 返回成功回调
- * @param {function} errorCallBack - 返回失败回调
- */
- const postDataWithFile = function (url, formData, successCallback, errorCallBack, showWaiting = true) {
- if (showWaiting) showWaitingView();
- if (formData.getAll('file[]').length > 10) {
- toastr.error('文件数量不能多于10个');
- if (showWaiting) closeWaitingView();
- return
- }
- $.ajax({
- type:"POST",
- url: url,
- data: formData,
- dataType: 'json',
- cache: false,
- // 告诉jQuery不要去设置Content-Type请求头
- contentType: false,
- // 告诉jQuery不要去处理发送的数据
- processData: false,
- timeout: 60000,
- beforeSend: function(xhr) {
- let csrfToken = Cookies.get('csrfToken_j');
- xhr.setRequestHeader('x-csrf-token', csrfToken);
- },
- success: function(result){
- if (result.err === 0) {
- if (successCallback) {
- successCallback(result.data);
- }
- } else if (result.err === 2) {
- toastr.error('error: ' + result.msg);
- setTimeout(function () {
- window.location.href = '/login';
- },1000);
- } else {
- toastr.error('error: ' + result.msg);
- if (errorCallBack) {
- errorCallBack();
- }
- }
- if (showWaiting) closeWaitingView();
- },
- error: function(jqXHR, textStatus, errorThrown){
- toastr.error('error: ' + textStatus + " " + errorThrown);
- if (errorCallBack) {
- errorCallBack();
- }
- if (showWaiting) closeWaitingView();
- }
- });
- };
- const postDataWithFileProgress = function (url, formData, successCallback, errorCallBack) {
- showUploadFileProgress();
- $.ajax({
- type:"POST",
- url: url,
- data: formData,
- dataType: 'json',
- cache: false,
- // 告诉jQuery不要去设置Content-Type请求头
- contentType: false,
- // 告诉jQuery不要去处理发送的数据
- processData: false,
- beforeSend: function(xhr) {
- let csrfToken = Cookies.get('csrfToken_j');
- xhr.setRequestHeader('x-csrf-token', csrfToken);
- },
- success: function(result){
- doneProgress();
- if (result.err === 0) {
- if (successCallback) {
- successCallback(result.data);
- }
- } else if (result.err === 2) {
- toastr.error('error: ' + result.msg);
- setTimeout(function () {
- window.location.href = '/login';
- },1000);
- } else {
- toastr.error('error: ' + result.msg);
- if (errorCallBack) {
- errorCallBack();
- }
- }
- closeProgress();
- },
- error: function(jqXHR, textStatus, errorThrown){
- toastr.error('error: ' + textStatus + " " + errorThrown);
- if (errorCallBack) {
- errorCallBack();
- }
- closeProgress();
- },
- xhr: function() {
- var xhr = new XMLHttpRequest();
- //使用XMLHttpRequest.upload监听上传过程,注册progress事件,打印回调函数中的event事件
- xhr.upload.addEventListener('progress', function (e) {
- console.log(e);
- //loaded代表上传了多少
- //total代表总数为多少
- var progressRate = (e.loaded / e.total) * 95;
- //通过设置进度条的宽度达到效果
- setUploadFileProgress(progressRate);
- })
- return xhr;
- }
- });
- }
- const postCompressFile = function (url, data, successCallback, errorCallBack) {
- $.ajax({
- type:"POST",
- url: url,
- data: {'data': JSON.stringify(data)},
- // dataType: 'blob',
- cache: false,
- timeout: 180000,
- xhrFields: {
- responseType: 'blob'
- },
- beforeSend: function(xhr) {
- let csrfToken = Cookies.get('csrfToken_j');
- xhr.setRequestHeader('x-csrf-token', csrfToken);
- },
- success: function(result){
- // if (result.err === 0) {
- // if (successCallback) {
- // successCallback(result.data);
- // }
- // } else if (result.err === 2) {
- // toastr.error('error: ' + result.msg);
- // setTimeout(function () {
- // window.location.href = '/login';
- // },1000);
- // } else {
- // toastr.error('error: ' + result.msg);
- // if (errorCallBack) {
- // errorCallBack(result.msg);
- // }
- // }
- if (successCallback) {
- successCallback(result)
- }
- },
- error: function(jqXHR, textStatus, errorThrown){
- // console.log(jqXHR, textStatus, errorThrown);
- // toastr.error('error: ' + textStatus + " " + errorThrown);
- if (errorCallBack) {
- errorCallBack();
- }
- }
- });
- }
- /**
- * 获取url中参数
- * @param variable
- * @returns {*}
- */
- function getQueryVariable(variable) {
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i=0;i<vars.length;i++) {
- var pair = vars[i].split("=");
- if(pair[0] == variable){return pair[1];}
- }
- return(false);
- }
- const zeroRange = 0.00000001;
- function checkZero(value) {
- return value === null || value === undefined || (_.isNumber(value) && Math.abs(value) < zeroRange);
- }
- function checkFieldChange(o, n) {
- return o == n || ((!o || o === '') && (n === ''));
- }
- var bShowWaiting = false, beginWaitingTime;
- //关闭等待窗口
- function closeWaitingView() {
- bShowWaiting = false;
- const time = parseInt(new Date());
- setTimeout(function () {
- var bgDiv = document.getElementById("bgDiv");
- var msgDiv = document.getElementById("msgDiv");
- //移除背景遮罩层div
- if(bgDiv != null){
- document.body.removeChild(bgDiv);
- }
- //移除中间信息提示层div
- if(msgDiv != null){
- document.body.removeChild(msgDiv);
- }
- }, Math.max(beginWaitingTime - time + 500, 0));
- }
- //显示等待窗口
- function showWaitingView() {
- // bShowWaiting = true;
- // setTimeout(function () {
- // if (!bShowWaiting) return;
- // beginWaitingTime = parseInt(new Date());
- // var msgw = 300; //提示窗口的宽度
- // var msgh = 100; //提示窗口的高度
- //
- // var sWidth, sHeight;
- // sWidth = document.body.clientWidth;
- // sHeight = document.body.clientHeight;
- //
- // //背景遮罩层div
- // var bgObj = document.createElement("div");
- // bgObj.setAttribute('id', 'bgDiv');
- // bgObj.style.zIndex = '9998';
- // bgObj.style.position = "absolute";
- // bgObj.style.top = "0px";
- // bgObj.style.background = "#888";
- // bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
- // bgObj.style.opacity = "0.6";
- // bgObj.style.left = "0px";
- // bgObj.style.width = sWidth + "px";
- // bgObj.style.height = sHeight + "px";
- // document.body.appendChild(bgObj);
- //
- // //信息提示层div
- // var msgObj = document.createElement("div");
- // msgObj.style.zIndex = '9999';
- // msgObj.setAttribute("id", "msgDiv");
- // msgObj.setAttribute("align", "center");
- // msgObj.style.position = "absolute";
- // msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
- // msgObj.style.width = msgw + "px";
- // msgObj.style.height = msgh + "px";
- // msgObj.style.top = (document.documentElement.scrollTop + (sHeight - msgh) / 2) + "px";
- // msgObj.style.left = (sWidth - msgw) / 2 + "px";
- // document.body.appendChild(msgObj);
- //
- // //中间等待图标
- // document.getElementById("msgDiv").innerHTML = '<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>';
- // }, 1000);
- beginWaitingTime = parseInt(new Date());
- var msgw = 300; //提示窗口的宽度
- var msgh = 100; //提示窗口的高度
- var sWidth, sHeight;
- sWidth = document.body.clientWidth;
- sHeight = document.body.clientHeight;
- //背景遮罩层div
- var bgObj = document.createElement("div");
- bgObj.setAttribute('id', 'bgDiv');
- bgObj.style.zIndex = '9998';
- bgObj.style.position = "absolute";
- bgObj.style.top = "0px";
- // bgObj.style.background = "#888";
- bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
- bgObj.style.opacity = "0.6";
- bgObj.style.left = "0px";
- bgObj.style.width = sWidth + "px";
- bgObj.style.height = sHeight + "px";
- document.body.appendChild(bgObj);
- //信息提示层div
- var msgObj = document.createElement("div");
- msgObj.style.zIndex = '9999';
- msgObj.setAttribute("id", "msgDiv");
- msgObj.setAttribute("align", "center");
- msgObj.style.position = "absolute";
- msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
- msgObj.style.width = msgw + "px";
- msgObj.style.height = msgh + "px";
- msgObj.style.top = (document.documentElement.scrollTop + (sHeight - msgh) / 2) + "px";
- msgObj.style.left = (sWidth - msgw) / 2 + "px";
- document.body.appendChild(msgObj);
- //中间等待图标
- document.getElementById("msgDiv").innerHTML = '<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>';
- }
- let progressInterval;
- function showProgress() {
- var sWidth, sHeight;
- sWidth = document.body.clientWidth;
- sHeight = document.body.clientHeight;
- //背景遮罩层div
- var bgObj = document.createElement("div");
- bgObj.setAttribute('id', 'bgDiv');
- bgObj.style.zIndex = '9998';
- bgObj.style.position = "absolute";
- bgObj.style.top = "0px";
- bgObj.style.background = "#888";
- bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
- bgObj.style.opacity = "0.6";
- bgObj.style.left = "0px";
- bgObj.style.width = sWidth + "px";
- bgObj.style.height = sHeight + "px";
- document.body.appendChild(bgObj);
- //信息提示层div
- var msgObj = document.createElement("div");
- msgObj.classList.add('progress');
- msgObj.style.zIndex = '9999';
- msgObj.style.position = "absolute";
- msgObj.setAttribute("id", "progressDiv");
- msgObj.style.height = "2px";
- msgObj.style.width = "600px";
- msgObj.style.top = (document.documentElement.scrollTop + sHeight / 2) + "px";
- msgObj.style.left = (sWidth - 600) / 2 + "px";
- document.body.appendChild(msgObj);
- msgObj.innerHTML = '<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>';
- const processObj = $('.progress-bar');
- let count = 0;
- progressInterval = setInterval(function () {
- const pos = parseInt(processObj.attr('aria-valuenow'));
- if (pos < 20) { // 1
- processObj.attr('aria-valuenow', pos + 2);
- processObj.width((pos + 2) + '%');
- } else if (pos < 40) { // 2
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- } else if (pos < 60) { // 4
- count += 1;
- if (count % 2 === 0) {
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- }
- } else if (pos < 80) { // 10
- count += 1;
- if (count % 5 === 0) {
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- }
- } else if (pos < 90) { // 15
- count += 1;
- if (count % 15 === 0) {
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- }
- } else if (pos < 95) { // 20
- count += 1;
- if (count % 40 === 0) {
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- }
- } else if (pos < 100) { // 30
- count += 1;
- if (count % 60 === 0) {
- processObj.attr('aria-valuenow', pos + 1);
- }
- }
- }, 100);
- }
- function doneProgress() {
- clearInterval(progressInterval);
- $('.progress-bar').attr('aria-valuenow', 100).width('100%');
- }
- function closeProgress() {
- setTimeout(function () {
- var bgDiv = document.getElementById("bgDiv");
- var msgDiv = document.getElementById("progressDiv");
- //移除背景遮罩层div
- if(bgDiv != null){
- document.body.removeChild(bgDiv);
- }
- //移除中间信息提示层div
- if(msgDiv != null){
- document.body.removeChild(msgDiv);
- }
- }, 500);
- }
- function showUploadFileProgress() {
- var sWidth, sHeight;
- sWidth = document.body.clientWidth;
- sHeight = document.body.clientHeight;
- //背景遮罩层div
- var bgObj = document.createElement("div");
- bgObj.setAttribute('id', 'bgDiv');
- bgObj.style.zIndex = '9998';
- bgObj.style.position = "absolute";
- bgObj.style.top = "0px";
- bgObj.style.background = "#888";
- bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
- bgObj.style.opacity = "0.6";
- bgObj.style.left = "0px";
- bgObj.style.width = sWidth + "px";
- bgObj.style.height = sHeight + "px";
- document.body.appendChild(bgObj);
- //信息提示层div
- var msgObj = document.createElement("div");
- msgObj.classList.add('progress');
- msgObj.style.zIndex = '9999';
- msgObj.style.position = "absolute";
- msgObj.setAttribute("id", "progressDiv");
- msgObj.style.height = "2px";
- msgObj.style.width = "600px";
- msgObj.style.top = (document.documentElement.scrollTop + sHeight / 2) + "px";
- msgObj.style.left = (sWidth - 600) / 2 + "px";
- document.body.appendChild(msgObj);
- msgObj.innerHTML = '<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>';
- }
- function setUploadFileProgress(pos) {
- const processObj = $('.progress-bar');
- processObj.attr('aria-valuenow', pos);
- processObj.width(pos + '%');
- }
- /**
- * 设置本地缓存
- *
- * @param {String} key
- * @param {String|Number} value
- * @return {void}
- */
- function setLocalCache(key, value) {
- const storage = window.localStorage;
- if (!storage || key === '' || value === '') {
- return;
- }
- storage.setItem(key, value);
- }
- /**
- * 获取本地缓存
- *
- * @param {String} key
- * @return {String}
- */
- function getLocalCache(key) {
- const storage = window.localStorage;
- if (!storage || key === '') {
- return null;
- }
- return storage.getItem(key);
- }
- /**
- * 移除本地缓存
- * @param {String} key
- * @returns {Boolean}
- */
- function removeLocalCache(key) {
- const storage = window.localStorage;
- if (!storage || key === '') {
- return null;
- }
- return storage.removeItem(key);
- }
- //params: 需要复制的对象(元素)
- function copyToClipboard( text ) {
- var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
- var aux = document.createElement('textarea');// 创建元素用于复制
- // Prevent zooming on iOS
- aux.style.fontSize = '12pt';
- // Reset box model
- aux.style.border = '0';
- aux.style.padding = '0';
- aux.style.margin = '0';
- // Move element out of screen horizontally
- aux.style.position = 'absolute';
- aux.style[isRTL ? 'right' : 'left'] = '-9999px';
- // Move element to the same position vertically
- var yPosition = window.pageYOffset || document.documentElement.scrollTop;
- aux.style.top = yPosition + 'px';
- aux.setAttribute('readonly', '');
- // 设置元素内容
- aux.value = text;
- // 将元素插入页面进行调用
- document.body.appendChild(aux);
- // 复制内容
- aux.select();
- aux.setSelectionRange(0, text.length);
- // 将内容复制到剪贴板
- document.execCommand("copy", true);
- // 删除创建元素
- document.body.removeChild(aux);
- }
- function toastMessageUniq (obj) {
- if (!obj.msg || !obj.type) return;
- if (!obj.once) {
- switch (obj.type) {
- case 'error':
- toastr.error(obj.msg);
- break;
- case 'warning':
- toastr.warning(obj.msg);
- break;
- case 'info':
- toastr.info(obj.msg);
- break;
- case 'success':
- toastr.success(obj.msg);
- break;
- }
- obj.once = true;
- }
- }
- function trimInvalidChar(str) {
- return $.trim(str).replace(/\n/g, '').replace(/\r/g, '').replace(/\t/g, '');
- }
- function cleanSymbols(str) {
- return $.trim(str).replace(/\\/g, '').replace(/\'/g, '').replace(/\"/g, '').replace(/\</g, '').replace(/\|/g, '');
- }
- jQuery.bootstrapLoading = {
- isLoading: function () {
- return $('#loadingPage').is(':visible');
- },
- start: function (options) {
- if(this.isLoading()){
- return;
- }
- var defaults = {
- opacity: 0.5,
- //loading页面透明度
- // backgroundColor: "#FFFFFF",
- //loading页面背景色
- borderColor: "#bbb",
- //提示边框颜色
- borderWidth: 1,
- //提示边框宽度
- borderStyle: "solid",
- //提示边框样式
- loadingTips: "Loading, please wait...",
- //提示文本
- TipsColor: "#fff",
- //提示颜色
- delayTime: 500,
- //页面加载完成后,加载页面渐出速度
- zindex: 2000,
- //loading页面层次
- sleep: 0
- //设置挂起,等于0时则无需挂起
- }
- var options = $.extend(defaults, options);
- //获取页面宽高
- var _PageHeight = document.documentElement.clientHeight,
- _PageWidth = document.documentElement.clientWidth;
- //在页面未加载完毕之前显示的loading Html自定义内容
- //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>';
- 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>';
- //呈现loading效果
- $("body").append(_LoadingHtml);
- //获取loading提示框宽高
- var _LoadingTipsH = document.getElementById("loadingTips").clientHeight,
- _LoadingTipsW = document.getElementById("loadingTips").clientWidth;
- //计算距离,让loading提示框保持在屏幕上下左右居中
- var _LoadingTop = _PageHeight > _LoadingTipsH ? (_PageHeight - _LoadingTipsH) / 2 : 0,
- _LoadingLeft = _PageWidth > _LoadingTipsW ? (_PageWidth - _LoadingTipsW) / 2 : 0;
- $("#loadingTips").css({
- "left": _LoadingLeft + "px",
- "top": _LoadingTop + "px"
- });
- //监听页面加载状态
- document.onreadystatechange = PageLoaded;
- //当页面加载完成后执行
- function PageLoaded() {
- if (document.readyState == "complete") {
- var loadingMask = $('#loadingPage');
- setTimeout(function () {
- loadingMask.animate({
- "opacity": 0
- },
- options.delayTime,
- function () {
- $(this).hide();
- });
- },
- options.sleep);
- }
- }
- },
- end: function () {
- $("#loadingPage").remove();
- },
- progressStop:true,
- progressStart:async function(title="导出文件",autoBar = false){
- if($("#progressModal").length == 0){
- let phtml = `<div class="modal fade" id="progressModal" data-backdrop="static">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="progress_modal_title">${title}</h5>
- </div>
- <div class="modal-body">
- <!--正在生成-->
- <h5 class="my-3" id="progress_modal_body">正在${title}</h5>
- <div class="progress mb-3">
- <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>
- </div>
- </div>
- </div>
- </div>
- </div>`;
- $("body").append(phtml);
- }else {
- $("#progress_modal_title").text(title);
- $("#progress_modal_body").text(`正在${title}`);
- }
- $("#progress_modal_bar").css('width','0%');
- $("#progressModal").modal('show');
- if(autoBar == true){//假的进度条
- $.bootstrapLoading.progressStop = false;
- let width = 0;
- while ($.bootstrapLoading.progressStop == false){
- await setTimeoutSync(null,1000);
- width += 5;
- if(width > 90) width -= 50;
- $("#progress_modal_bar").css('width',`${width}%`);
- }
- }
- },
- progressEnd:function () {
- $("#progress_modal_bar").css('width','100%');
- $.bootstrapLoading.progressStop = true;
- $("#progressModal").modal('hide');
- }
- };
- // 光标插入button内容
- $.fn.extend({
- insertAtCaret: function(myValue){
- var $t=$(this)[0];
- if (document.selection) {
- this.focus();
- sel = document.selection.createRange();
- sel.text = myValue;
- this.focus();
- }
- else
- if ($t.selectionStart || $t.selectionStart == '0') {
- var startPos = $t.selectionStart;
- var endPos = $t.selectionEnd;
- var scrollTop = $t.scrollTop;
- $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
- this.focus();
- $t.selectionStart = startPos + myValue.length;
- $t.selectionEnd = startPos + myValue.length;
- $t.scrollTop = scrollTop;
- }
- else {
- this.value += myValue;
- this.focus();
- }
- }
- });
- const checkUtils = {
- posOver(data) {
- if (!data) return false;
- if (!data.quantity) return !!data.end_contract_qty;
- return data.quantity > 0
- ? data.end_contract_qty > data.quantity
- : data.end_contract_qty < data.quantity || data.end_contract_qty > 0;
- },
- billsOver(data, isTz, relaPos) {
- if (!data) return false;
- if (isTz) {
- const posRange = relaPos.ledgerPos[itemsPre + data.id] || [];
- if (posRange.length > 0) {
- for (const p of posRange) {
- if (checkUtils.posOver(p)) return true;
- }
- }
- if (data.is_tp) {
- if (!data.total_price) return !!data.end_contract_tp;
- return data.total_price > 0
- ? data.end_contract_tp > data.total_price
- : data.end_contract_tp < data.total_price || data.end_contract_tp > 0;
- } else {
- if (!data.quantity) return !!data.end_contract_qty;
- return data.quantity > 0
- ? data.end_contract_qty > data.quantity
- : data.end_contract_qty < data.quantity || data.end_contract_qty > 0;
- }
- } else {
- if (data.is_tp) {
- if (!data.deal_tp) return !!data.end_contract_tp;
- return data.deal_tp > 0
- ? data.end_contract_tp > data.deal_tp
- : data.end_contract_tp < data.deal_tp || data.end_contract_tp > 0;
- } else {
- if (!data.deal_qty) return !!data.end_contract_qty;
- return data.deal_qty > 0
- ? data.end_contract_qty > data.deal_qty
- : data.end_contract_qty < data.deal_qty || data.end_contract_qty > 0;
- }
- }
- }
- };
- Number.prototype.format2Str = function (pattern) {
- var strarr = this?this.toString().split('.'):['0'];
- var fmtarr = pattern?pattern.split('.'):[''];
- var retstr='';
- // 整数部分
- var str = strarr[0];
- var fmt = fmtarr[0];
- var i = str.length-1;
- var comma = false;
- for(var f=fmt.length-1;f>=0;f--){
- switch(fmt.substr(f,1)){
- case '#':
- if(i>=0 ) retstr = str.substr(i--,1) + retstr;
- break;
- case '0':
- if(i>=0) retstr = str.substr(i--,1) + retstr;
- else retstr = '0' + retstr;
- break;
- case ',':
- comma = true;
- retstr=','+retstr;
- break;
- }
- }
- if(i>=0){
- if(comma){
- var l = str.length;
- for(;i>=0;i--){
- retstr = str.substr(i,1) + retstr;
- if(i>0 && ((l-i)%3)==0) retstr = ',' + retstr;
- }
- }
- else retstr = str.substr(0,i+1) + retstr;
- }
- retstr = retstr+'.';
- // 处理小数部分
- str=strarr.length>1?strarr[1]:'';
- fmt=fmtarr.length>1?fmtarr[1]:'';
- i=0;
- for(var f=0;f<fmt.length;f++){
- switch(fmt.substr(f,1)){
- case '#':
- if(i<str.length) retstr+=str.substr(i++,1);
- break;
- case '0':
- if(i<str.length) retstr+= str.substr(i++,1);
- else retstr+='0';
- break;
- }
- }
- return retstr.replace(/^,+/,'').replace(/\.$/,'');
- };
- function transFormToChinese(num) {
- const changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
- const unit = ["", "十", "百", "千", "万"];
- num = parseInt(num);
- let getWan = (temp) => {
- let strArr = temp.toString().split("").reverse();
- let newNum = "";
- for (var i = 0; i < strArr.length; i++) {
- 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;
- }
- return strArr.length === 2 && newNum.indexOf("一十") !== -1 ? newNum.replace('一十', '十') : newNum;
- }
- let overWan = Math.floor(num / 10000);
- let noWan = num % 10000;
- if (noWan.toString().length < 4) noWan = "0" + noWan;
- return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num);
- }
|