Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 3 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. /**
  2. * Created by admin on 2017/1/3.
  3. */
  4. var fileSize = 3000000; //文件上传大小限制
  5. window.z = (function ($) {
  6. });
  7. jQuery(document).ready(function () {
  8. // if (typeof bootbox != 'undefined') {
  9. // bootbox.setDefaults({
  10. // /**
  11. // * @optional String
  12. // * @default: en
  13. // * which locale settings to use to translate the three
  14. // * standard button labels: OK, CONFIRM, CANCEL
  15. // */
  16. // locale: "zh_CN",
  17. //
  18. // });
  19. // //bootbox设置语言不起作用,修改了源码
  20. // // bootbox.removeLocale('zh_CN');
  21. // // bootbox.setLocale('zh_CN', {OK:"好",CANCEL:"取消",CONFIRM:"确认"
  22. // // })
  23. // }
  24. //点击缩略图,弹出显示大图
  25. $(".thumbnail").on('click', "img[data-trigger='openImage']", function () {
  26. if (self.frameElement && self.frameElement.tagName == "IFRAME") {
  27. parent.z.showImage(z.thumbnailToHeight($(this).attr('src')));
  28. } else {
  29. z.showImage(z.thumbnailToHeight($(this).attr('src')));
  30. }
  31. var type = $(this).parent().siblings().attr('data-type');
  32. if(type)
  33. {
  34. switch (type)
  35. {
  36. case '1':
  37. $('.bigImage').css('width', '180px');
  38. $('.bigImage').css('height', '180px');
  39. $('.bigImage').find('img').css('width', '170px');
  40. $('.bigImage').find('img').css('height', '170px');
  41. break;
  42. case '2':
  43. $('.bigImage').css('width', '160px');
  44. $('.bigImage').css('height', '130px');
  45. $('.bigImage').find('img').css('width', '150px');
  46. $('.bigImage').find('img').css('height', '120px');
  47. break;
  48. }
  49. }
  50. })
  51. $(".fileinput").on('click', "div[data-trigger='openDivImage']", function () {
  52. if (self.frameElement && self.frameElement.tagName == "IFRAME") {
  53. parent.z.showImage($(this).find('img').attr('src'));
  54. } else {
  55. z.showImage($(this).find('img').attr('src'));
  56. }
  57. var type = $(this).attr('data-type');
  58. if(type)
  59. {
  60. switch (type)
  61. {
  62. case '1':
  63. $('.bigImage').css('width', '180px');
  64. $('.bigImage').css('height', '180px');
  65. $('.bigImage').find('img').css('width', '170px');
  66. $('.bigImage').find('img').css('height', '170px');
  67. break;
  68. case '2':
  69. $('.bigImage').css('width', '160px');
  70. $('.bigImage').css('height', '130px');
  71. $('.bigImage').find('img').css('width', '150px');
  72. $('.bigImage').find('img').css('height', '120px');
  73. break;
  74. }
  75. }
  76. })
  77. $("._image").on('click', "img[data-trigger='openImage']", function () {
  78. if (self.frameElement && self.frameElement.tagName == "IFRAME") {
  79. parent.z.showImage(z.thumbnailToHeight($(this).attr('src')));
  80. } else {
  81. z.showImage(z.thumbnailToHeight($(this).attr('src')));
  82. }
  83. })
  84. $("body").on('click', ".bigDivImage", function () {
  85. $(".bigDivImage").remove();
  86. })
  87. $('.loading-form').on('beforeValidate', function (e) {
  88. loading();
  89. return true;
  90. }).on('beforeSubmit', function (e) {
  91. loading();
  92. return true;
  93. }).on('ajaxComplete', function (e) {
  94. closeLoading();
  95. return true;
  96. }).on('afterValidate', function (e) {
  97. closeLoading();
  98. return true;
  99. });
  100. //如果使用了pajx,重载后,需要closeLoading()
  101. $(document).on('click', '.zLoading', function (e) {
  102. loading();
  103. if ($(this).attr('type') !== undefined && $(this).attr('type').toLowerCase() === 'submit') {
  104. $('form').submit();
  105. }
  106. return true;
  107. });
  108. $(document).on('pjax:success', '[data-pjax-container]', function () {
  109. closeLoading();
  110. });
  111. if (typeof initFlag !== 'undefined' && initFlag === true)
  112. z.init();
  113. });
  114. //在iframe中,如果需要新窗口中打开某链接
  115. //@param location 主窗口 URL,一般就是module名,例如 hotel motorcade zzcs
  116. //@param url iframe中实际 URL
  117. //@param data_role 导航选中id
  118. //@param path_role 左侧菜单激活id
  119. function zNewWin(location, url, data_role, path_role) {
  120. // parent.window.open('/' + location + "?iframeURL=" + encodeURIComponent(url));
  121. if(location === 'CS'){
  122. $.cookie('path_url', url, {domain: domain_path, path: "/"});
  123. $.cookie('user_path', "2", {path: "/", domain: domain_path});
  124. }else{
  125. $.cookie('fo_url', url, {domain: domain_path, path: "/"});
  126. $.cookie('home_page_show', 'hide', {domain: domain_path, path: "/"});
  127. }
  128. if (typeof path_role !== 'undefined') {
  129. $.cookie('path_role', path_role, {path: "/", domain: domain_path});
  130. }
  131. if (typeof data_role !== 'undefined') {
  132. $.cookie('data-role', data_role, {path: "/", domain: domain_path});
  133. }
  134. window.open(parent.window.location.href);
  135. }
  136. var getUrlParameter = function getUrlParameter(sParam) {
  137. var sPageURL = window.location.search.substring(1),
  138. sURLVariables = sPageURL.split('&'),
  139. sParameterName,
  140. i;
  141. for (i = 0; i < sURLVariables.length; i++) {
  142. sParameterName = sURLVariables[i].split('=');
  143. if (sParameterName[0] === sParam) {
  144. return sParameterName[1] === undefined ? true : sParameterName[1];
  145. }
  146. }
  147. };
  148. //由于没有标题只有内容,以双竖线分隔||,message要包含1、类型、2、标题、3、内容
  149. yii.confirm = function (message, okCallback, cancelCallback) {
  150. data = message.split('||');
  151. var title = '操作确认';
  152. if (data.length > 1) {
  153. title = data[1] !== '' ? data[1] : '操作确认';
  154. message = data[2];
  155. message = (data[0] !== '' ? '<i class="fa fa-warning font-yellow-crusta font-hg vertical-middle modal-body-icon"></i>' : '') + message;
  156. }
  157. if (self.frameElement && self.frameElement.tagName == "IFRAME") {
  158. parent.bootbox.confirm({
  159. title: title,
  160. message: message,
  161. buttons: {
  162. confirm: {
  163. label: '确定'
  164. },
  165. cancel: {
  166. label: '取消'
  167. }
  168. },
  169. callback: function (result) {
  170. if (result) {
  171. okCallback();
  172. } else {
  173. if (typeof cancelCallback === 'function')
  174. cancelCallback();
  175. }
  176. }
  177. });
  178. } else {
  179. bootbox.confirm({
  180. title: title,
  181. message: message,
  182. buttons: {
  183. confirm: {
  184. label: '确定'
  185. },
  186. cancel: {
  187. label: '取消'
  188. }
  189. },
  190. callback: function (result) {
  191. if (result) {
  192. okCallback();
  193. } else {
  194. if (typeof cancelCallback === 'function')
  195. cancelCallback();
  196. }
  197. }
  198. });
  199. }
  200. };
  201. yii.alert = function (message, title, type) {
  202. if (typeof title == 'undefined')
  203. title = '提示';
  204. //根据type在modal body前添加图标
  205. // if (typeof type != 'undefined') {
  206. message = '<i class="fa fa-warning font-yellow-crusta font-hg vertical-middle modal-body-icon"></i>' + message;
  207. // message += '<i class="fa fa-'+ type+ '"></i>'
  208. // }
  209. if (self.frameElement && self.frameElement.tagName == "IFRAME") {
  210. parent.bootbox.alert({
  211. title: title,
  212. message: message
  213. })
  214. } else {
  215. bootbox.alert({
  216. title: title,
  217. message: message
  218. })
  219. }
  220. }
  221. //info,error,success,warning
  222. //显示右上角提示 http://plnkr.co/edit/6W9URNyyp2ItO4aUWzBB?p=preview,官方文档,可以自定义显示图标及位置,
  223. //必须要用setTimeout,否则新页面无法显示
  224. z.showTip = function (type, message) {
  225. setTimeout(function () {
  226. if (self.frameElement && self.frameElement.tagName == "IFRAME") {
  227. parent.toastr[type](message);
  228. } else {
  229. toastr[type](message);
  230. }
  231. }, 0)
  232. };
  233. //点击图片,弹出显示大图
  234. //如果是默认图片,不显示大图, 包含字符串 default-thumbnail
  235. z.showImage = function (src, width, height) {
  236. if (src.indexOf('default-thumbnail') === -1) {
  237. var str = '';
  238. str += '<div class="bigDivImage"><div class="bigImage"><img src="' + src + '" /></div> </div>';
  239. $('body .bigDivImage').remove();
  240. $('body').append(str);
  241. }
  242. };
  243. //弹出框,显示一个表格
  244. //如果没有data 有callData参数,数据都从callData获取
  245. //type 如果为null,就是直接调用函数callData,如果type==ajax,就用ajax获取数据
  246. //attr是ajax返回时候,data对应的键名
  247. //data_attr是需要显示td的字段名,如果需要作函数处理,函数名+空格+字段名
  248. //将tr 中的数据作一次处理,比如有时为0时不显示名显示为‘-’,
  249. z.showTable = function (title, head, data, type, callData, params, attr, data_attr, formatData) {
  250. if (data == "" && typeof callData != "undefined") {
  251. //ajax获取数据
  252. if (typeof type != 'undefined' && type == 'ajax') {
  253. $.ajax({
  254. type: 'POST',
  255. url: callData,
  256. async: false,
  257. data: params,
  258. success: function (res) {
  259. data = JSON.parse(res);
  260. },
  261. error: function (msg) {
  262. }
  263. });
  264. } else { //callData函数获取数据
  265. var strParam = '';
  266. $.each(params, function (k, e) {
  267. if (k != 0) {
  268. strParam += ',';
  269. }
  270. strParam += e;
  271. })
  272. data = eval(callData + "(" + strParam + ")");
  273. }
  274. if (typeof attr != "undefined") {
  275. $.each(attr, function (k, e) {
  276. data = data[e];
  277. })
  278. }
  279. }
  280. var strTHead = '';
  281. $.each(head, function (k, e) {
  282. strTHead += '<th style="text-align: center">' + e + '</th>';
  283. })
  284. 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>";
  285. $.each(data, function (k, e) {
  286. strTable += '<tr>';
  287. if (typeof data_attr == "undefined") {
  288. data_attr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  289. }
  290. if (typeof formatData != 'undefined') {
  291. e = eval(formatData + "(e)");
  292. }
  293. $.each(data_attr, function (k, f) {
  294. //td字段处理
  295. var pos = f.indexOf(' ');
  296. if (pos > -1) {
  297. f = eval(f.substring(0, pos) + "(" + e[f.substring(pos + 1)] + ")");
  298. strTable += '<td>' + f + '</td>';
  299. } else {
  300. strTable += '<td>' + e[f] + '</td>';
  301. }
  302. })
  303. strTable += '</tr>';
  304. })
  305. strTable += "</tbody></table>";
  306. //显示表格
  307. parent.bootbox.dialog({
  308. title: title,
  309. message: strTable,
  310. buttons: {
  311. cancel: {
  312. label: '关闭'
  313. }
  314. },
  315. callback: function (result) {
  316. // console.log(result);
  317. }
  318. });
  319. }
  320. z.showModal = function (target, url, param, callback) {
  321. var csrfToken = yii.getCsrfToken();
  322. $(target).on('pjax:success', function () {
  323. if (typeof callback !== 'undefined' && callback.call)
  324. callback();
  325. closeLoading();
  326. });
  327. $.pjax.reload({
  328. container: target,
  329. url: url,
  330. data: {param: param, _csrf: csrfToken},
  331. timeout: false,
  332. replace: false
  333. })
  334. };
  335. z.init = function (prefix) {
  336. var selectorDate, selectSelect;
  337. if (typeof prefix === 'string') {
  338. selectorDate = '.' + prefix + '_form_date';
  339. selectSelect = '.' + prefix + '_select_screen';
  340. } else {
  341. selectorDate = '.form_date';
  342. selectSelect = '.select_screen';
  343. }
  344. var form_date = $(selectorDate);
  345. if (form_date.length > 0 && typeof form_date.datetimepicker === 'function') {
  346. $(form_date).datetimepicker({
  347. format: 'yyyy-mm-dd',
  348. autoclose: true,
  349. minView: 2,
  350. pickerPosition: "bottom-left"
  351. });
  352. }
  353. var select_screen = $(selectSelect);
  354. if (select_screen.length > 0 && typeof select_screen.comboSelect === 'function') {
  355. $(select_screen).removeClass('form-control').comboSelect();
  356. }
  357. };
  358. z.hideModal = function (target) {
  359. $(target).modal('hide');
  360. };
  361. z.thumbnailToHeight = function ($url) {
  362. var reg = /\d+x\d+_/;
  363. return $url.replace(reg, '');
  364. };
  365. z.removeComboSelect = function () {
  366. var t_class = '.comboSelect';
  367. if (typeof target !== 'undefined')
  368. t_class = target;
  369. $(t_class).parent('.combo-select').children(':not(select)').remove();
  370. $('.combo-select').find(t_class).unwrap();
  371. };
  372. z.pjaxOne = function (url) {
  373. $.ajax({
  374. url: url, //'/motorcade/order-finance/cancel-finance?id='+ id,
  375. method: 'post',
  376. success: function (data) {
  377. data = JSON.parse(data);
  378. if (data.code === 0) {
  379. z.showTip('success', data.msg);
  380. } else {
  381. z.showTip('error', data.msg)
  382. }
  383. if (typeof data.callback === 'string') {
  384. eval(data.callback);
  385. }
  386. },
  387. error: function (data) {
  388. console.log(data.responseText);
  389. }
  390. });
  391. };
  392. z.pjaxFinish = function (type, msg, target) {
  393. z.showTip(type, msg);
  394. //z.hideModal需要有延时,执行顺序问题会导致无法隐藏弹出框
  395. setTimeout(function () {
  396. z.hideModal(target)
  397. }, 0);
  398. closeLoading();
  399. };
  400. //和上面yii.confirm重复,上面不好再改
  401. z.confirm = function (message, okCallback, cancelCallback) {
  402. data = message.split('||');
  403. var title = '操作确认';
  404. if (data.length > 1) {
  405. title = data[1] !== '' ? data[1] : '操作确认';
  406. message = data[2];
  407. message = (data[0] !== '' ? '<i class="fa fa-warning font-yellow-crusta font-hg vertical-middle modal-body-icon"></i>' : '') + message;
  408. }
  409. if (self.frameElement && self.frameElement.tagName == "IFRAME") {
  410. parent.bootbox.confirm({
  411. title: title,
  412. message: message,
  413. buttons: {
  414. confirm: {
  415. label: '确定'
  416. },
  417. cancel: {
  418. label: '取消'
  419. }
  420. },
  421. callback: function (result) {
  422. if (result) {
  423. eval(okCallback);
  424. } else {
  425. eval(cancelCallback);
  426. // if (typeof cancelCallback === 'function')
  427. // cancelCallback();
  428. }
  429. }
  430. });
  431. } else {
  432. bootbox.confirm({
  433. title: title,
  434. message: message,
  435. buttons: {
  436. confirm: {
  437. label: '确定'
  438. },
  439. cancel: {
  440. label: '取消'
  441. }
  442. },
  443. callback: function (result) {
  444. if (result) {
  445. okCallback();
  446. } else {
  447. if (typeof cancelCallback === 'function')
  448. cancelCallback();
  449. }
  450. }
  451. });
  452. }
  453. };
  454. /**
  455. * 批量操作,传回后台的都是id,ajax返回的数据格式 ['code'=> 0|1, 'msg'=> '提示信息']
  456. * @param url 后台url
  457. * @param checkboxSelector 选中checkbox
  458. * @param emptyWarnTip 没有选中checkbox的提示
  459. * @param title 提示框的标题
  460. * @param message 提示确认内容
  461. * @param callback 回调函数
  462. * @returns {boolean}|{void}
  463. */
  464. z.multiAction = function (url, checkboxSelector, emptyWarnTip, title, message, callback) {
  465. var id_array = [];
  466. $(checkboxSelector).each(function () {
  467. if ($(this).is(":checked")) {
  468. id_array.push($(this).val());
  469. }
  470. });
  471. var id_str = id_array.join(',');
  472. if (id_str === '') {
  473. parent.toastr["warning"](emptyWarnTip === '' ? '请选择要操作的数据' : emptyWarnTip);
  474. return false;
  475. }
  476. var csrfToken = yii.getCsrfToken();
  477. parent.bootbox.dialog({
  478. title: title,
  479. message: message,
  480. buttons: {
  481. cancel: {
  482. label: "取消",
  483. callback: function () {
  484. }
  485. },
  486. sure: {
  487. label: '确认',
  488. callback: function () {
  489. $.ajax({
  490. url: url,
  491. dataType: 'json',
  492. type: 'post',
  493. data: {id: id_str, _csrf: csrfToken},
  494. success: function (res_data) {
  495. parent.toastr[res_data.code === 0 ? "success" : "error"](res_data.msg);
  496. eval(callback);
  497. if (typeof res_data.callback === 'string') {
  498. eval(res_data.callback);
  499. }
  500. },
  501. error: function (e) {
  502. parent.toastr["warning"](title + "失败");
  503. console.log(e)
  504. }
  505. })
  506. }
  507. }
  508. }
  509. })
  510. };
  511. z.timePicker = function () {
  512. var hour_temp = "";
  513. var minute_temp = "";
  514. var i;
  515. for (i = 0; i < 24; i++) {
  516. if (i < 10) {
  517. if (i === 0) {
  518. hour_temp += '<div class="select_hour select_option">0' + i + '</div>'
  519. } else {
  520. hour_temp += '<div class="select_hour">0' + i + '</div>'
  521. }
  522. } else {
  523. hour_temp += '<div class="select_hour">' + i + '</div>'
  524. }
  525. }
  526. for (i = 0; i < 60; i++) {
  527. if (i < 10) {
  528. if (i === 0) {
  529. minute_temp += '<div class="select_minute select_option">0' + i + '</div>'
  530. } else {
  531. minute_temp += '<div class="select_minute">0' + i + '</div>'
  532. }
  533. } else {
  534. minute_temp += '<div class="select_minute">' + i + '</div>'
  535. }
  536. }
  537. $(".select_hour_box").html(hour_temp);
  538. $(".select_minute_box").html(minute_temp);
  539. $(".select_hour").on("click", function () {
  540. var time_id = $(this).closest(".timepicker_box").attr("id");
  541. var selector = $("#" + time_id);
  542. var parent_height = $(selector).find(".timepicker_select").offset().top;
  543. var this_height = $(this).offset().top;
  544. var scroll_height = $(selector).find(".select_hour_box").scrollTop();
  545. var move_height = this_height - parent_height + scroll_height;
  546. $(selector).find(".select_hour_box").animate({scrollTop: move_height}, 200);
  547. $(selector).find(".select_hour_box").children().removeClass("select_option");
  548. $(this).addClass("select_option");
  549. var times = $(selector).find(".select_hour_box .select_option").text() + ':' + $(selector).find(".select_minute_box .select_option").text();
  550. $(selector).find(".timepicker input").val(times);
  551. });
  552. $(".select_minute").on("click", function () {
  553. var time_id = $(this).closest(".timepicker_box").attr("id");
  554. var selector = $("#" + time_id);
  555. var parent_height = $(selector).find(".timepicker_select").offset().top;
  556. var this_height = $(this).offset().top;
  557. var scroll_height = $(selector).find(".select_minute_box").scrollTop();
  558. var move_height = this_height - parent_height + scroll_height;
  559. $(selector).find(".select_minute_box").animate({scrollTop: move_height}, 200);
  560. $(selector).find(".select_minute_box").children().removeClass("select_option");
  561. $(this).addClass("select_option");
  562. var times = $(selector).find(".select_hour_box .select_option").text() + ':' + $(selector).find(".select_minute_box .select_option").text();
  563. $(selector).find(".timepicker input").val(times);
  564. });
  565. $(".timepicker_box").on("click", function (e) {
  566. var time_id = this.id;
  567. $(".timepicker_select").not("#" + time_id + " .timepicker_select").animate({
  568. height: 'hide'
  569. }, 200);
  570. $("#" + this.id).find(".timepicker_select").animate({
  571. height: 'show'
  572. }, 200);
  573. e.stopPropagation();
  574. });
  575. };
  576. z.pager = function (pagination, max_page, obj) {
  577. var li = $(obj).closest('.bottom_nav').find("." + pagination + ' a:first');
  578. var pager = $(obj).closest('.zPagerGo').find('.pager-go');
  579. if(li.length <= 0){
  580. li = $('.pagination a:first');
  581. pager = $('.zPagerGo').find('.pager-go');
  582. }
  583. if (li.length > 0) {
  584. var page = $(pager).val();
  585. if (page <= 0) {
  586. page = 1;
  587. } else if ($(pager).val() > max_page) {
  588. page = max_page;
  589. }
  590. loading();
  591. var href = $(li).attr('href');
  592. href = href.replace(/page\=\d+/, 'page=' + page);
  593. $(li).attr('href', href);
  594. var a = $(li)[0];
  595. a.click();
  596. }
  597. };
  598. //导出或者某些查询的时候可以用到,导出功能,都是根据查询的条件获取数据的
  599. z.exportExcel = function (form_container, url) {
  600. var form = document.querySelector(form_container);
  601. var action = form.action;
  602. form.action = url;
  603. form.submit();
  604. form.action = action;
  605. };
  606. //::todo 不符合规则,没有重置图片
  607. function checkSize(obj) {
  608. var reset = false, msg = '';
  609. if (typeof $(obj)[0].files[0] !== 'undefined' && $(obj)[0].files[0].size > fileSize) {
  610. $(obj).val('');
  611. z.showTip('warning', '图片大小不能超过3M');
  612. return false;
  613. }
  614. if($(obj)[0].files.length === 0){
  615. return true;
  616. }
  617. if ($(obj)[0].files[0].size < 0) {
  618. $(obj).val('');
  619. z.showTip('warning', '图片无法使用,请重新选择');
  620. return false;
  621. }
  622. var _URL = window.URL || window.webkitURL;
  623. if ((file = $(obj)[0].files[0])) {
  624. img = new Image();
  625. img.onload = function () {
  626. if ((this.width * this.height * 32) >= 128000000) {
  627. reset = true;
  628. msg = '图片分辨率太高,请编辑后上传';
  629. // $(obj).val('');
  630. z.showTip('warning', msg);
  631. $(obj).parent().next('a').click()
  632. return false;
  633. }
  634. };
  635. img.onerror = function () {
  636. reset = true;
  637. msg = '图片无法使用,请重新选择';
  638. // $(obj).val('');
  639. z.showTip('warning', msg);
  640. $(obj).parent().next('a').click()
  641. return false;
  642. };
  643. img.src = _URL.createObjectURL(file);
  644. }
  645. }
  646. //为了减少数据库连接查询次数,dictType表中的部分数据,可以在这里进行简单查询
  647. function getDictType(res_id) {
  648. var arr = [];
  649. arr[108] = {text: '上'};
  650. arr[109] = {text: '上下'};
  651. arr[110] = {text: '下'};
  652. arr[114] = {text: '不停靠'};
  653. if (typeof arr[res_id] === 'undefined') {
  654. return '';
  655. } else {
  656. return arr[res_id].text;
  657. }
  658. }
  659. function getDictName(res_id, type) {
  660. var arr = [];
  661. arr[108] = {text: '仅上客', tag: '上'};
  662. arr[109] = {text: '同时上下客', tag: '上下'};
  663. arr[110] = {text: '仅下客', tag: '下'};
  664. arr[114] = {text: '不停靠', tag: '不停靠'};
  665. if (typeof type === "undefined") {
  666. return arr[res_id].text;
  667. } else {
  668. return arr[res_id].tag;
  669. }
  670. }
  671. function passengerData(trData) {
  672. if (trData['station_inout_type'] == 108)
  673. trData['people_down_all_num'] = '-';
  674. if (trData['station_inout_type'] == 110)
  675. trData['people_up_all_num'] = '-';
  676. if (trData['station_inout_type'] == 114) {
  677. trData['people_down_all_num'] = '-';
  678. trData['people_up_all_num'] = '-';
  679. }
  680. return trData;
  681. }
  682. function startTimeToEndTime(trData) {
  683. if (trData['bus_no'] == null) {
  684. trData['bus_no'] = ''
  685. }
  686. if (trData['driver_name'] == null) {
  687. trData['driver_name'] = ''
  688. }
  689. trData['start_time'] = trData['start_time'] + '-' + trData['end_time'];
  690. return trData;
  691. }
  692. function loading(time) {
  693. //注释提交按钮的禁用,既然已经有加载动画了,提交按钮肯定已经被遮住,有可能loading时需要手动提交
  694. // $("button[type='submit']").attr('disabled', true);
  695. 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;' +
  696. '"><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>' +
  697. '</div>';
  698. if (typeof $("#screen-cover") != 'undefined')
  699. $("#screen-cover").remove();
  700. /*$("<link>")
  701. .attr({ rel: "stylesheet",
  702. type: "text/css",
  703. href: "/css/loader.css"
  704. })
  705. .appendTo("head");*/
  706. $("html").append(newDiv);
  707. var screenTop = $(document).scrollTop();
  708. $("#screen-cover").css('padding-top', screenTop + $(window).height() / 2 - 55);
  709. // if(typeof time == 'undefined')
  710. // time = 15000;
  711. // setTimeout('closeLoading()',time);
  712. }
  713. function closeLoading() {
  714. $("button[type='submit']").attr('disabled', false);
  715. if ($("#screen-cover").length > 0)
  716. $("#screen-cover").remove();
  717. }
  718. //提交按钮统一需要加载loading动画,完成提交后,需要手动关闭动画closeLoading()
  719. function loadingForm(target, item) {
  720. $(target).on('beforeValidate', item, function (e) {
  721. loading();
  722. return true;
  723. }).on('beforeSubmit', item, function (e) {
  724. loading();
  725. return true;
  726. }).on('ajaxComplete', item, function (e) {
  727. closeLoading();
  728. return true;
  729. }).on('afterValidate', item, function (e) {
  730. closeLoading();
  731. return true;
  732. });
  733. }
  734. function postDisable(url, target) {
  735. $.ajax({
  736. url: url, //'/motorcade/order-finance/cancel-finance?id='+ id,
  737. method: 'post',
  738. success: function (data) {
  739. data = JSON.parse(data);
  740. if (data.code === 0) {
  741. z.showTip('success', data.msg);
  742. } else {
  743. z.showTip('error', data.msg)
  744. }
  745. },
  746. error: function (data) {
  747. console.log(data.responseText);
  748. }
  749. });
  750. //更新当前页面
  751. $(target).trigger('click');
  752. }