|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798 |
- /**
- * Created by admin on 2017/1/3.
- */
- var fileSize = 3000000; //文件上传大小限制
- window.z = (function ($) {
-
- });
- jQuery(document).ready(function () {
- // if (typeof bootbox != 'undefined') {
- // bootbox.setDefaults({
- // /**
- // * @optional String
- // * @default: en
- // * which locale settings to use to translate the three
- // * standard button labels: OK, CONFIRM, CANCEL
- // */
- // locale: "zh_CN",
- //
- // });
- // //bootbox设置语言不起作用,修改了源码
- // // bootbox.removeLocale('zh_CN');
- // // bootbox.setLocale('zh_CN', {OK:"好",CANCEL:"取消",CONFIRM:"确认"
- // // })
- // }
-
- //点击缩略图,弹出显示大图
- $(".thumbnail").on('click', "img[data-trigger='openImage']", function () {
-
- if (self.frameElement && self.frameElement.tagName == "IFRAME") {
- parent.z.showImage(z.thumbnailToHeight($(this).attr('src')));
- } else {
- z.showImage(z.thumbnailToHeight($(this).attr('src')));
- }
- var type = $(this).parent().siblings().attr('data-type');
- if(type)
- {
- switch (type)
- {
- case '1':
- $('.bigImage').css('width', '180px');
- $('.bigImage').css('height', '180px');
- $('.bigImage').find('img').css('width', '170px');
- $('.bigImage').find('img').css('height', '170px');
- break;
- case '2':
- $('.bigImage').css('width', '160px');
- $('.bigImage').css('height', '130px');
- $('.bigImage').find('img').css('width', '150px');
- $('.bigImage').find('img').css('height', '120px');
- break;
- }
- }
- })
- $(".fileinput").on('click', "div[data-trigger='openDivImage']", function () {
-
- if (self.frameElement && self.frameElement.tagName == "IFRAME") {
- parent.z.showImage($(this).find('img').attr('src'));
- } else {
- z.showImage($(this).find('img').attr('src'));
- }
-
- var type = $(this).attr('data-type');
- if(type)
- {
- switch (type)
- {
- case '1':
- $('.bigImage').css('width', '180px');
- $('.bigImage').css('height', '180px');
- $('.bigImage').find('img').css('width', '170px');
- $('.bigImage').find('img').css('height', '170px');
- break;
- case '2':
- $('.bigImage').css('width', '160px');
- $('.bigImage').css('height', '130px');
- $('.bigImage').find('img').css('width', '150px');
- $('.bigImage').find('img').css('height', '120px');
- break;
- }
- }
- })
- $("._image").on('click', "img[data-trigger='openImage']", function () {
-
- if (self.frameElement && self.frameElement.tagName == "IFRAME") {
- parent.z.showImage(z.thumbnailToHeight($(this).attr('src')));
- } else {
- z.showImage(z.thumbnailToHeight($(this).attr('src')));
- }
- })
- $("body").on('click', ".bigDivImage", function () {
- $(".bigDivImage").remove();
- })
-
- $('.loading-form').on('beforeValidate', function (e) {
- loading();
- return true;
- }).on('beforeSubmit', function (e) {
- loading();
- return true;
- }).on('ajaxComplete', function (e) {
- closeLoading();
- return true;
- }).on('afterValidate', function (e) {
- closeLoading();
- return true;
- });
-
- //如果使用了pajx,重载后,需要closeLoading()
- $(document).on('click', '.zLoading', function (e) {
- loading();
- if ($(this).attr('type') !== undefined && $(this).attr('type').toLowerCase() === 'submit') {
- $('form').submit();
- }
- return true;
- });
- $(document).on('pjax:success', '[data-pjax-container]', function () {
- closeLoading();
- });
- if (typeof initFlag !== 'undefined' && initFlag === true)
- z.init();
- });
-
- //在iframe中,如果需要新窗口中打开某链接
- //@param location 主窗口 URL,一般就是module名,例如 hotel motorcade zzcs
- //@param url iframe中实际 URL
- //@param data_role 导航选中id
- //@param path_role 左侧菜单激活id
- function zNewWin(location, url, data_role, path_role) {
- // parent.window.open('/' + location + "?iframeURL=" + encodeURIComponent(url));
- if(location === 'CS'){
- $.cookie('path_url', url, {domain: domain_path, path: "/"});
- $.cookie('user_path', "2", {path: "/", domain: domain_path});
- }else{
- $.cookie('fo_url', url, {domain: domain_path, path: "/"});
- $.cookie('home_page_show', 'hide', {domain: domain_path, path: "/"});
- }
-
- if (typeof path_role !== 'undefined') {
- $.cookie('path_role', path_role, {path: "/", domain: domain_path});
- }
- if (typeof data_role !== 'undefined') {
- $.cookie('data-role', data_role, {path: "/", domain: domain_path});
- }
- window.open(parent.window.location.href);
- }
-
- var getUrlParameter = function getUrlParameter(sParam) {
- var sPageURL = window.location.search.substring(1),
- sURLVariables = sPageURL.split('&'),
- sParameterName,
- i;
-
- for (i = 0; i < sURLVariables.length; i++) {
- sParameterName = sURLVariables[i].split('=');
-
- if (sParameterName[0] === sParam) {
- return sParameterName[1] === undefined ? true : sParameterName[1];
- }
- }
- };
- //由于没有标题只有内容,以双竖线分隔||,message要包含1、类型、2、标题、3、内容
- yii.confirm = function (message, okCallback, cancelCallback) {
-
- data = message.split('||');
- var title = '操作确认';
- if (data.length > 1) {
- title = data[1] !== '' ? data[1] : '操作确认';
- message = data[2];
- message = (data[0] !== '' ? '<i class="fa fa-warning font-yellow-crusta font-hg vertical-middle modal-body-icon"></i>' : '') + message;
-
- }
- if (self.frameElement && self.frameElement.tagName == "IFRAME") {
- parent.bootbox.confirm({
- title: title,
- message: message,
- buttons: {
- confirm: {
- label: '确定'
- },
- cancel: {
- label: '取消'
- }
- },
- callback: function (result) {
- if (result) {
- okCallback();
- } else {
- if (typeof cancelCallback === 'function')
- cancelCallback();
- }
- }
- });
- } else {
- bootbox.confirm({
- title: title,
- message: message,
- buttons: {
- confirm: {
- label: '确定'
- },
- cancel: {
- label: '取消'
- }
- },
- callback: function (result) {
- if (result) {
- okCallback();
- } else {
- if (typeof cancelCallback === 'function')
- cancelCallback();
- }
- }
- });
- }
- };
-
-
- yii.alert = function (message, title, type) {
- if (typeof title == 'undefined')
- title = '提示';
- //根据type在modal body前添加图标
- // if (typeof type != 'undefined') {
- message = '<i class="fa fa-warning font-yellow-crusta font-hg vertical-middle modal-body-icon"></i>' + message;
- // message += '<i class="fa fa-'+ type+ '"></i>'
- // }
- if (self.frameElement && self.frameElement.tagName == "IFRAME") {
- parent.bootbox.alert({
- title: title,
- message: message
- })
- } else {
- bootbox.alert({
- title: title,
- message: message
- })
- }
- }
-
- //info,error,success,warning
- //显示右上角提示 http://plnkr.co/edit/6W9URNyyp2ItO4aUWzBB?p=preview,官方文档,可以自定义显示图标及位置,
- //必须要用setTimeout,否则新页面无法显示
- z.showTip = function (type, message) {
- setTimeout(function () {
- if (self.frameElement && self.frameElement.tagName == "IFRAME") {
- parent.toastr[type](message);
- } else {
- toastr[type](message);
- }
-
- }, 0)
- };
-
- //点击图片,弹出显示大图
- //如果是默认图片,不显示大图, 包含字符串 default-thumbnail
- z.showImage = function (src, width, height) {
- if (src.indexOf('default-thumbnail') === -1) {
- var str = '';
- str += '<div class="bigDivImage"><div class="bigImage"><img src="' + src + '" /></div> </div>';
- $('body .bigDivImage').remove();
- $('body').append(str);
- }
- };
-
- //弹出框,显示一个表格
- //如果没有data 有callData参数,数据都从callData获取
- //type 如果为null,就是直接调用函数callData,如果type==ajax,就用ajax获取数据
- //attr是ajax返回时候,data对应的键名
- //data_attr是需要显示td的字段名,如果需要作函数处理,函数名+空格+字段名
- //将tr 中的数据作一次处理,比如有时为0时不显示名显示为‘-’,
- z.showTable = function (title, head, data, type, callData, params, attr, data_attr, formatData) {
- if (data == "" && typeof callData != "undefined") {
- //ajax获取数据
- if (typeof type != 'undefined' && type == 'ajax') {
- $.ajax({
- type: 'POST',
- url: callData,
- async: false,
- data: params,
- success: function (res) {
- data = JSON.parse(res);
- },
- error: function (msg) {
-
- }
- });
- } else { //callData函数获取数据
- var strParam = '';
- $.each(params, function (k, e) {
- if (k != 0) {
- strParam += ',';
- }
- strParam += e;
- })
- data = eval(callData + "(" + strParam + ")");
- }
-
- if (typeof attr != "undefined") {
- $.each(attr, function (k, e) {
- data = data[e];
- })
- }
- }
-
- var strTHead = '';
- $.each(head, function (k, e) {
- strTHead += '<th style="text-align: center">' + e + '</th>';
- })
- var strTable = "<table class='table table-striped table-hover text-center'><thead class='th-text-center'><tr style='text-align: center;'>" + strTHead + "</tr></thead><tbody>";
- $.each(data, function (k, e) {
- strTable += '<tr>';
- if (typeof data_attr == "undefined") {
- data_attr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
- }
- if (typeof formatData != 'undefined') {
- e = eval(formatData + "(e)");
- }
- $.each(data_attr, function (k, f) {
- //td字段处理
- var pos = f.indexOf(' ');
- if (pos > -1) {
- f = eval(f.substring(0, pos) + "(" + e[f.substring(pos + 1)] + ")");
- strTable += '<td>' + f + '</td>';
- } else {
- strTable += '<td>' + e[f] + '</td>';
- }
- })
- strTable += '</tr>';
- })
- strTable += "</tbody></table>";
- //显示表格
- parent.bootbox.dialog({
- title: title,
- message: strTable,
- buttons: {
- cancel: {
- label: '关闭'
- }
- },
- callback: function (result) {
- // console.log(result);
- }
- });
- }
-
- z.showModal = function (target, url, param, callback) {
-
- var csrfToken = yii.getCsrfToken();
- $(target).on('pjax:success', function () {
- if (typeof callback !== 'undefined' && callback.call)
- callback();
- closeLoading();
- });
-
- $.pjax.reload({
- container: target,
- url: url,
- data: {param: param, _csrf: csrfToken},
- timeout: false,
- replace: false
- })
- };
- z.init = function (prefix) {
- var selectorDate, selectSelect;
- if (typeof prefix === 'string') {
- selectorDate = '.' + prefix + '_form_date';
- selectSelect = '.' + prefix + '_select_screen';
- } else {
- selectorDate = '.form_date';
- selectSelect = '.select_screen';
- }
- var form_date = $(selectorDate);
- if (form_date.length > 0 && typeof form_date.datetimepicker === 'function') {
- $(form_date).datetimepicker({
- format: 'yyyy-mm-dd',
- autoclose: true,
- minView: 2,
- pickerPosition: "bottom-left"
- });
- }
-
- var select_screen = $(selectSelect);
- if (select_screen.length > 0 && typeof select_screen.comboSelect === 'function') {
- $(select_screen).removeClass('form-control').comboSelect();
- }
- };
- z.hideModal = function (target) {
- $(target).modal('hide');
- };
-
- z.thumbnailToHeight = function ($url) {
- var reg = /\d+x\d+_/;
- return $url.replace(reg, '');
- };
-
- z.removeComboSelect = function () {
- var t_class = '.comboSelect';
- if (typeof target !== 'undefined')
- t_class = target;
- $(t_class).parent('.combo-select').children(':not(select)').remove();
- $('.combo-select').find(t_class).unwrap();
- };
- z.pjaxOne = function (url) {
- $.ajax({
- url: url, //'/motorcade/order-finance/cancel-finance?id='+ id,
- method: 'post',
- success: function (data) {
- data = JSON.parse(data);
- if (data.code === 0) {
- z.showTip('success', data.msg);
- } else {
- z.showTip('error', data.msg)
- }
- if (typeof data.callback === 'string') {
- eval(data.callback);
- }
- },
- error: function (data) {
- console.log(data.responseText);
- }
- });
- };
- z.pjaxFinish = function (type, msg, target) {
- z.showTip(type, msg);
- //z.hideModal需要有延时,执行顺序问题会导致无法隐藏弹出框
- setTimeout(function () {
- z.hideModal(target)
- }, 0);
- closeLoading();
- };
- //和上面yii.confirm重复,上面不好再改
- z.confirm = function (message, okCallback, cancelCallback) {
- data = message.split('||');
- var title = '操作确认';
- if (data.length > 1) {
- title = data[1] !== '' ? data[1] : '操作确认';
- message = data[2];
- message = (data[0] !== '' ? '<i class="fa fa-warning font-yellow-crusta font-hg vertical-middle modal-body-icon"></i>' : '') + message;
-
- }
- if (self.frameElement && self.frameElement.tagName == "IFRAME") {
- parent.bootbox.confirm({
- title: title,
- message: message,
- buttons: {
- confirm: {
- label: '确定'
- },
- cancel: {
- label: '取消'
- }
- },
- callback: function (result) {
- if (result) {
- eval(okCallback);
- } else {
- eval(cancelCallback);
- // if (typeof cancelCallback === 'function')
- // cancelCallback();
- }
- }
- });
- } else {
- bootbox.confirm({
- title: title,
- message: message,
- buttons: {
- confirm: {
- label: '确定'
- },
- cancel: {
- label: '取消'
- }
- },
- callback: function (result) {
- if (result) {
- okCallback();
- } else {
- if (typeof cancelCallback === 'function')
- cancelCallback();
- }
- }
- });
- }
- };
-
- /**
- * 批量操作,传回后台的都是id,ajax返回的数据格式 ['code'=> 0|1, 'msg'=> '提示信息']
- * @param url 后台url
- * @param checkboxSelector 选中checkbox
- * @param emptyWarnTip 没有选中checkbox的提示
- * @param title 提示框的标题
- * @param message 提示确认内容
- * @param callback 回调函数
- * @returns {boolean}|{void}
- */
- z.multiAction = function (url, checkboxSelector, emptyWarnTip, title, message, callback) {
- var id_array = [];
- $(checkboxSelector).each(function () {
- if ($(this).is(":checked")) {
- id_array.push($(this).val());
- }
- });
- var id_str = id_array.join(',');
- if (id_str === '') {
- parent.toastr["warning"](emptyWarnTip === '' ? '请选择要操作的数据' : emptyWarnTip);
- return false;
- }
- var csrfToken = yii.getCsrfToken();
- parent.bootbox.dialog({
- title: title,
- message: message,
- buttons: {
- cancel: {
- label: "取消",
- callback: function () {
-
- }
- },
- sure: {
- label: '确认',
- callback: function () {
- $.ajax({
- url: url,
- dataType: 'json',
- type: 'post',
- data: {id: id_str, _csrf: csrfToken},
- success: function (res_data) {
- parent.toastr[res_data.code === 0 ? "success" : "error"](res_data.msg);
- eval(callback);
- if (typeof res_data.callback === 'string') {
- eval(res_data.callback);
- }
- },
- error: function (e) {
- parent.toastr["warning"](title + "失败");
- console.log(e)
- }
- })
- }
- }
- }
- })
- };
- z.timePicker = function () {
- var hour_temp = "";
- var minute_temp = "";
- var i;
- for (i = 0; i < 24; i++) {
- if (i < 10) {
- if (i === 0) {
- hour_temp += '<div class="select_hour select_option">0' + i + '</div>'
- } else {
- hour_temp += '<div class="select_hour">0' + i + '</div>'
- }
-
- } else {
- hour_temp += '<div class="select_hour">' + i + '</div>'
- }
- }
- for (i = 0; i < 60; i++) {
- if (i < 10) {
- if (i === 0) {
- minute_temp += '<div class="select_minute select_option">0' + i + '</div>'
- } else {
- minute_temp += '<div class="select_minute">0' + i + '</div>'
- }
-
- } else {
- minute_temp += '<div class="select_minute">' + i + '</div>'
- }
- }
- $(".select_hour_box").html(hour_temp);
- $(".select_minute_box").html(minute_temp);
- $(".select_hour").on("click", function () {
- var time_id = $(this).closest(".timepicker_box").attr("id");
- var selector = $("#" + time_id);
- var parent_height = $(selector).find(".timepicker_select").offset().top;
- var this_height = $(this).offset().top;
- var scroll_height = $(selector).find(".select_hour_box").scrollTop();
- var move_height = this_height - parent_height + scroll_height;
- $(selector).find(".select_hour_box").animate({scrollTop: move_height}, 200);
- $(selector).find(".select_hour_box").children().removeClass("select_option");
- $(this).addClass("select_option");
- var times = $(selector).find(".select_hour_box .select_option").text() + ':' + $(selector).find(".select_minute_box .select_option").text();
- $(selector).find(".timepicker input").val(times);
- });
- $(".select_minute").on("click", function () {
- var time_id = $(this).closest(".timepicker_box").attr("id");
- var selector = $("#" + time_id);
- var parent_height = $(selector).find(".timepicker_select").offset().top;
- var this_height = $(this).offset().top;
- var scroll_height = $(selector).find(".select_minute_box").scrollTop();
- var move_height = this_height - parent_height + scroll_height;
- $(selector).find(".select_minute_box").animate({scrollTop: move_height}, 200);
- $(selector).find(".select_minute_box").children().removeClass("select_option");
- $(this).addClass("select_option");
- var times = $(selector).find(".select_hour_box .select_option").text() + ':' + $(selector).find(".select_minute_box .select_option").text();
- $(selector).find(".timepicker input").val(times);
- });
- $(".timepicker_box").on("click", function (e) {
- var time_id = this.id;
- $(".timepicker_select").not("#" + time_id + " .timepicker_select").animate({
- height: 'hide'
- }, 200);
- $("#" + this.id).find(".timepicker_select").animate({
- height: 'show'
- }, 200);
- e.stopPropagation();
-
- });
- };
- z.pager = function (pagination, max_page, obj) {
- var li = $(obj).closest('.bottom_nav').find("." + pagination + ' a:first');
- var pager = $(obj).closest('.zPagerGo').find('.pager-go');
- if(li.length <= 0){
- li = $('.pagination a:first');
- pager = $('.zPagerGo').find('.pager-go');
- }
- if (li.length > 0) {
- var page = $(pager).val();
- if (page <= 0) {
- page = 1;
- } else if ($(pager).val() > max_page) {
- page = max_page;
- }
- loading();
- var href = $(li).attr('href');
- href = href.replace(/page\=\d+/, 'page=' + page);
- $(li).attr('href', href);
- var a = $(li)[0];
- a.click();
- }
- };
- //导出或者某些查询的时候可以用到,导出功能,都是根据查询的条件获取数据的
- z.exportExcel = function (form_container, url) {
- var form = document.querySelector(form_container);
- var action = form.action;
- form.action = url;
- form.submit();
- form.action = action;
- };
- //::todo 不符合规则,没有重置图片
- function checkSize(obj) {
- var reset = false, msg = '';
- if (typeof $(obj)[0].files[0] !== 'undefined' && $(obj)[0].files[0].size > fileSize) {
- $(obj).val('');
- z.showTip('warning', '图片大小不能超过3M');
- return false;
- }
-
- if($(obj)[0].files.length === 0){
- return true;
- }
-
- if ($(obj)[0].files[0].size < 0) {
- $(obj).val('');
- z.showTip('warning', '图片无法使用,请重新选择');
- return false;
- }
- var _URL = window.URL || window.webkitURL;
- if ((file = $(obj)[0].files[0])) {
- img = new Image();
- img.onload = function () {
- if ((this.width * this.height * 32) >= 128000000) {
- reset = true;
- msg = '图片分辨率太高,请编辑后上传';
- // $(obj).val('');
- z.showTip('warning', msg);
- $(obj).parent().next('a').click()
- return false;
- }
- };
- img.onerror = function () {
- reset = true;
- msg = '图片无法使用,请重新选择';
- // $(obj).val('');
- z.showTip('warning', msg);
- $(obj).parent().next('a').click()
- return false;
- };
- img.src = _URL.createObjectURL(file);
- }
- }
-
- //为了减少数据库连接查询次数,dictType表中的部分数据,可以在这里进行简单查询
- function getDictType(res_id) {
- var arr = [];
- arr[108] = {text: '上'};
- arr[109] = {text: '上下'};
- arr[110] = {text: '下'};
- arr[114] = {text: '不停靠'};
- if (typeof arr[res_id] === 'undefined') {
- return '';
- } else {
- return arr[res_id].text;
- }
- }
- function getDictName(res_id, type) {
- var arr = [];
- arr[108] = {text: '仅上客', tag: '上'};
- arr[109] = {text: '同时上下客', tag: '上下'};
- arr[110] = {text: '仅下客', tag: '下'};
- arr[114] = {text: '不停靠', tag: '不停靠'};
-
- if (typeof type === "undefined") {
- return arr[res_id].text;
- } else {
- return arr[res_id].tag;
- }
- }
-
- function passengerData(trData) {
- if (trData['station_inout_type'] == 108)
- trData['people_down_all_num'] = '-';
- if (trData['station_inout_type'] == 110)
- trData['people_up_all_num'] = '-';
- if (trData['station_inout_type'] == 114) {
- trData['people_down_all_num'] = '-';
- trData['people_up_all_num'] = '-';
- }
- return trData;
- }
- function startTimeToEndTime(trData) {
- if (trData['bus_no'] == null) {
- trData['bus_no'] = ''
- }
- if (trData['driver_name'] == null) {
- trData['driver_name'] = ''
- }
- trData['start_time'] = trData['start_time'] + '-' + trData['end_time'];
- return trData;
- }
-
- function loading(time) {
- //注释提交按钮的禁用,既然已经有加载动画了,提交按钮肯定已经被遮住,有可能loading时需要手动提交
- // $("button[type='submit']").attr('disabled', true);
- var newDiv = '<div id="screen-cover" class="loader-inner ball-beat" style="width: 100%; height: ' + $(window).height() + 'px; position: fixed; top: 0; left: 0; background-color: rgba(0,0,0,0.5); text-align: center; z-index: 9999;' +
- '"><div class="on" style="border-radius: 100%!important;"></div><div class="off" style="border-radius: 100%!important;"></div><div class="on" style="border-radius: 100%!important;"></div>' +
- '</div>';
- if (typeof $("#screen-cover") != 'undefined')
- $("#screen-cover").remove();
- /*$("<link>")
- .attr({ rel: "stylesheet",
- type: "text/css",
- href: "/css/loader.css"
- })
- .appendTo("head");*/
- $("html").append(newDiv);
- var screenTop = $(document).scrollTop();
- $("#screen-cover").css('padding-top', screenTop + $(window).height() / 2 - 55);
- // if(typeof time == 'undefined')
- // time = 15000;
- // setTimeout('closeLoading()',time);
-
- }
-
- function closeLoading() {
- $("button[type='submit']").attr('disabled', false);
- if ($("#screen-cover").length > 0)
- $("#screen-cover").remove();
- }
-
- //提交按钮统一需要加载loading动画,完成提交后,需要手动关闭动画closeLoading()
- function loadingForm(target, item) {
- $(target).on('beforeValidate', item, function (e) {
- loading();
- return true;
- }).on('beforeSubmit', item, function (e) {
- loading();
- return true;
- }).on('ajaxComplete', item, function (e) {
- closeLoading();
- return true;
- }).on('afterValidate', item, function (e) {
- closeLoading();
- return true;
- });
- }
- function postDisable(url, target) {
- $.ajax({
- url: url, //'/motorcade/order-finance/cancel-finance?id='+ id,
- method: 'post',
- success: function (data) {
- data = JSON.parse(data);
- if (data.code === 0) {
- z.showTip('success', data.msg);
- } else {
- z.showTip('error', data.msg)
- }
- },
- error: function (data) {
- console.log(data.responseText);
- }
- });
-
- //更新当前页面
- $(target).trigger('click');
- }
|