tool.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. layui.define(function (exports) {
  2. let MOD_NAME = 'tool',dropdown=layui.dropdown;
  3. let tool = {
  4. loading: false,
  5. expressClose:function(index){return '<div class="express-close" data-index="'+index+'" title="关闭">\
  6. <div class="express-container">\
  7. <div class="express-bar">\
  8. <svg viewBox="0 0 202.9 45.5" >\
  9. <clipPath id="menu" clipPathUnits="objectBoundingBox" transform="scale(0.0049285362247413 0.021978021978022)">\
  10. <path d="M6.7,45.5c5.7,0.1,14.1-0.4,23.3-4c5.7-2.3,9.9-5,18.1-10.5c10.7-7.1,11.8-9.2,20.6-14.3c5-2.9,9.2-5.2,15.2-7c7.1-2.1,13.3-2.3,17.6-2.1c4.2-0.2,10.5,0.1,17.6,2.1c6.1,1.8,10.2,4.1,15.2,7c8.8,5,9.9,7.1,20.6,14.3c8.3,5.5,12.4,8.2,18.1,10.5c9.2,3.6,17.6,4.2,23.3,4H6.7z"/>\
  11. </clipPath>\
  12. </svg>\
  13. </div>\
  14. <div class="express-btn">\
  15. <svg class="express-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M463.787 512l-253.44-253.44a34.133 34.133 0 0 1 48.213-48.213L512 463.787l253.44-253.44a34.133 34.133 0 1 1 48.213 48.213L560.213 512l253.44 253.44a34.133 34.133 0 1 1-48.213 48.213L512 560.213l-253.44 253.44a34.133 34.133 0 0 1-48.213-48.213z" fill="#ffffff"></path></svg>\
  16. </div>\
  17. </div>\
  18. </div>'
  19. },
  20. side: function (url, width) {
  21. let that = this;
  22. if (that.loading == true) {
  23. return false;
  24. }
  25. that.loading = true;
  26. sideWidth = '80%';
  27. if(window.innerWidth>1366 && window.innerWidth<=1600){
  28. sideWidth = '86%';
  29. }
  30. if(window.innerWidth>1000 && window.innerWidth<=1440){
  31. sideWidth = '93%';
  32. }
  33. if(window.innerWidth<=1000){
  34. sideWidth = '95%';
  35. }
  36. layer.open({
  37. type: 2,
  38. title: false,
  39. offset: 'r',
  40. anim: 'slideLeft',
  41. closeBtn: 0,
  42. content: url,
  43. area: [sideWidth, '100%'],
  44. skin:'layui-layer-gougu-admin',
  45. end: function(){
  46. $(parent.$('.express-close')).removeClass('parent-colse');
  47. $('body').removeClass('right-open');
  48. if (layui.pageTable && layui.pageTable.resize) {
  49. layui.pageTable.resize();
  50. }
  51. },
  52. success: function (obj, index) {
  53. $('body').addClass('right-open');
  54. obj.append(that.expressClose(index));
  55. that.loading = false;
  56. obj.on('click','.express-close', function () {
  57. layer.close(index);
  58. });
  59. setTimeout(function(){
  60. $(parent.$('.express-close')).addClass('parent-colse');
  61. },500)
  62. }
  63. })
  64. },
  65. box: function (url,title="内容", width=720,height=405) {
  66. let that = this;
  67. if (that.loading == true) {
  68. return false;
  69. }
  70. that.loading = true;
  71. layer.open({
  72. type: 2,
  73. title: title,
  74. content: url,
  75. area: [width+'px', height+'px'],
  76. maxmin: true,
  77. end: function(){
  78. if (layui.pageTable && layui.pageTable.resize) {
  79. layui.pageTable.resize();
  80. }
  81. },
  82. success: function (obj, index) {
  83. let btn = '<div data-index="'+index+'" class="express-close" style="display:none;" title="关闭">关闭</div>';
  84. obj.append(btn);
  85. that.loading = false;
  86. obj.on('click','.express-close', function () {
  87. layer.close(index);
  88. })
  89. }
  90. })
  91. },
  92. //右侧ajax请求的方式打开页面参考勾股DEV
  93. open: function (url, width) {
  94. let that = this;
  95. if (that.loading == true) {
  96. return false;
  97. }
  98. that.loading = true;
  99. let countWidth = window.innerWidth-(window.innerWidth*0.5)+456;
  100. if(window.innerWidth<=1000){
  101. countWidth = 750;
  102. }
  103. if (width && width > 0) {
  104. sideWidth = width + 'px';
  105. }
  106. else{
  107. sideWidth = countWidth + 'px';
  108. }
  109. $.ajax({
  110. url: url,
  111. type: "GET",
  112. timeout: 10000,
  113. success: function (res) {
  114. if (res['code'] && res['code'] > 0) {
  115. layer.msg(res.msg);
  116. return false;
  117. }
  118. let index = timestamp = new Date().getTime();
  119. let express = '<section id="expressLayer" class="express-box" style="width:' + sideWidth + '"><article id="articleLayer">' + res + '</article>'+that.expressClose(index)+'</section><div id="expressMask" class="express-mask"></div>';
  120. $('body').append(express).addClass('right-open');
  121. $('#expressMask').fadeIn(200);
  122. $('#expressLayer').animate({ 'right': 0 }, 200, 'linear', function () {
  123. if (typeof (openInit) == "function") {
  124. openInit();
  125. }
  126. });
  127. that.loading = false;
  128. //关闭
  129. $('body').on('click','.express-close', function () {
  130. $('#expressMask').fadeOut(100);
  131. $('body').removeClass('right-open');
  132. let op_width = $('#expressLayer').outerWidth();
  133. $('#expressLayer').animate({ left: '+=' + op_width + 'px' }, 200, 'linear', function () {
  134. $('#expressLayer').remove();
  135. $('#expressMask').remove();
  136. if (layui.pageTable) {
  137. layui.pageTable.resize();
  138. }
  139. })
  140. })
  141. $(window).resize(function () {
  142. let resizeWidth = window.innerWidth-(window.innerWidth*0.5)+456;
  143. if(window.innerWidth<=1000){
  144. resizeWidth = 750;
  145. }
  146. $('#expressLayer').width(resizeWidth);
  147. })
  148. },
  149. error: function (xhr, textstatus, thrown) {
  150. console.log('错误');
  151. },
  152. complete: function () {
  153. that.loading = false;
  154. }
  155. });
  156. },
  157. load: function (url) {
  158. let that = this;
  159. if (that.loading == true) {
  160. return false;
  161. }
  162. that.loading = true;
  163. $.ajax({
  164. url: url,
  165. type: "GET",
  166. timeout: 10000,
  167. success: function (res) {
  168. if (res['code'] && res['code'] > 0) {
  169. layer.msg(res.msg);
  170. return false;
  171. }
  172. $('#articleLayer').html(res);
  173. openInit();
  174. }
  175. , error: function (xhr, textstatus, thrown) {
  176. console.log('错误');
  177. },
  178. complete: function () {
  179. that.loading = false;
  180. }
  181. });
  182. },
  183. page: function (url) {
  184. let that = this;
  185. if (that.loading == true) {
  186. return false;
  187. }
  188. that.loading = true;
  189. $.ajax({
  190. url: url,
  191. type: "GET",
  192. timeout: 10000,
  193. success: function (res) {
  194. if (res['code'] && res['code'] > 0) {
  195. layer.msg(res.msg);
  196. return false;
  197. }
  198. $('#pageBox').html(res);
  199. pageInit();
  200. },
  201. error: function (xhr, textstatus, thrown) {
  202. console.log('错误');
  203. },
  204. complete: function () {
  205. that.loading = false;
  206. }
  207. });
  208. },
  209. reload: function (delay) {
  210. //延迟刷新,一般是在编辑完页面数据后需要自动关闭页面用到
  211. if(delay && delay>0){
  212. setTimeout(function () {
  213. location.reload();
  214. }, delay);
  215. }else{
  216. location.reload();
  217. }
  218. },
  219. ask:function(tips,yes,cancel){
  220. layer.confirm(tips, {
  221. icon: 3,
  222. title: '提示',
  223. success:function(){
  224. $(parent.$('.express-close')).addClass('parent-colse');
  225. },
  226. end:function(){
  227. $(parent.$('.express-close')).removeClass('parent-colse');
  228. }
  229. }, function (index) {
  230. if (yes && typeof yes === 'function') {
  231. yes();
  232. }
  233. layer.close(index);
  234. }, function (index) {
  235. if (cancel && typeof cancel === 'function') {
  236. cancel();
  237. }
  238. layer.close(index);
  239. });
  240. },
  241. close: function (delay,table,reload) {
  242. //延迟关闭,一般是在编辑完页面数据后需要自动关闭页面用到
  243. if (typeof(delay) === "undefined" || delay === '') {
  244. delay = 0;
  245. }
  246. if (typeof(table) === "undefined" || table === '') {
  247. table = 'pageTable';
  248. }
  249. if (typeof(reload) === "undefined" || reload === '') {
  250. reload = 1;
  251. }
  252. if(delay>0){
  253. setTimeout(function () {
  254. $('.express-close').last().click();
  255. }, delay);
  256. }else{
  257. $('.express-close').last().click();
  258. }
  259. if (layui[table]) {
  260. layui[table].reload();
  261. }
  262. else{
  263. if(reload==1){
  264. tool.reload(delay);
  265. }
  266. }
  267. },
  268. ajax: function (options, callback, clickbtn) {
  269. let format = 'json';
  270. if (options.hasOwnProperty('data')) {
  271. format = options.data.hasOwnProperty('format') ? options.data.format : 'json';
  272. }
  273. callback = callback || options.success;
  274. callback && delete options.success;
  275. let optsetting = { timeout: 10000 };
  276. if (format == 'jsonp') {
  277. optsetting = { timeout: 10000, dataType: 'jsonp', jsonp: 'callback' }
  278. }
  279. let opts = $.extend({}, optsetting, {
  280. success: function (res) {
  281. if (callback && typeof callback === 'function') {
  282. callback(res);
  283. }
  284. },
  285. beforeSend:function(){
  286. if (clickbtn && typeof clickbtn === 'object') {
  287. clickbtn.attr('disabled',true).html('提交中 ...');
  288. }
  289. },
  290. complete: function () {
  291. if (clickbtn && typeof clickbtn === 'object') {
  292. setTimeout(function(){
  293. clickbtn.removeAttr('disabled').html('立即提交');
  294. },1000);
  295. }
  296. }
  297. }, options);
  298. $.ajax(opts);
  299. },
  300. get: function (url, data, callback) {
  301. this.ajax({url: url,type: "GET",data: data}, callback);
  302. },
  303. post: function (url, data, callback, clickbtn) {
  304. this.ajax({url: url,type: "POST",data: data}, callback, clickbtn);
  305. },
  306. put: function (url, data, callback) {
  307. this.ajax({url: url,type: "PUT",data: data}, callback);
  308. },
  309. delete: function (url, data, callback) {
  310. this.ajax({url: url,type: "DELETE",data: data}, callback);
  311. },
  312. parentAdmin:function () {
  313. if(parent.layui.admin){
  314. return parent.layui.admin;
  315. }
  316. else{
  317. if(parent.parent.layui.admin){
  318. return parent.parent.layui.admin;
  319. }
  320. else{
  321. if(parent.parent.parent.layui.admin){
  322. return parent.parent.parent.layui.admin;
  323. }
  324. else{
  325. if(parent.parent.parent.parent.layui.admin){
  326. return parent.parent.parent.parent.layui.admin;
  327. }
  328. else{
  329. return false;
  330. }
  331. }
  332. }
  333. }
  334. },
  335. sideClose(delay,table,reload){
  336. if(parent.layui.tool){
  337. parent.layui.tool.close(delay,table,reload);
  338. }
  339. else{
  340. console.log('父页面没引用tool模块');
  341. }
  342. },
  343. tabAdd:function(url,title,id){
  344. let parentAdmin = this.parentAdmin();
  345. if(parentAdmin){
  346. parentAdmin.sonAdd(url,title,id);
  347. }
  348. },
  349. tabClose:function(){
  350. let parentAdmin = this.parentAdmin();
  351. if(parentAdmin){
  352. parentAdmin.sonClose();
  353. }
  354. },
  355. tabDelete:function(id){
  356. let parentAdmin = this.parentAdmin();
  357. if(parentAdmin){
  358. parentAdmin.tabDelete(id);
  359. }
  360. },
  361. tabChange:function(id){
  362. let parentAdmin = this.parentAdmin();
  363. if(parentAdmin){
  364. parentAdmin.tabChange(id);
  365. }
  366. },
  367. tabRefresh:function(id){
  368. let parentAdmin = this.parentAdmin();
  369. if(parentAdmin){
  370. parentAdmin.refresh(id);
  371. }
  372. },
  373. officeView:function(id,mode){
  374. let parentAdmin = this.parentAdmin();
  375. if(parentAdmin){
  376. parentAdmin.officeView(id,mode);
  377. }
  378. },
  379. pdfView:function(href){
  380. let parentAdmin = this.parentAdmin();
  381. if(parentAdmin){
  382. parentAdmin.pdfView(href);
  383. }
  384. },
  385. photoView:function(href){
  386. let parentAdmin = this.parentAdmin();
  387. if(parentAdmin){
  388. parentAdmin.photoView(href);
  389. }
  390. },
  391. videoView:function(href){
  392. let parentAdmin = this.parentAdmin();
  393. if(parentAdmin){
  394. parentAdmin.videoView(href);
  395. }
  396. },
  397. audioView:function(href){
  398. let parentAdmin = this.parentAdmin();
  399. if(parentAdmin){
  400. parentAdmin.audioView(href);
  401. }
  402. },
  403. articleView:function(fileid) {
  404. tool.side('/disk/index/view_article?id='+fileid);
  405. },
  406. articleEdit:function(fileid) {
  407. tool.side('/disk/index/add_article?id='+fileid);
  408. },
  409. downloadFile:function(url, fileName) {
  410. let link = document.createElement("a");
  411. link.href = url;
  412. link.download = fileName;
  413. link.click();
  414. layer.msg('文件下载中...', {time: 2000});
  415. },
  416. copyCtrl:function(content) {
  417. var save = function(e){
  418. e.clipboardData.setData('text/plain', content);
  419. e.preventDefault();
  420. }
  421. document.addEventListener('copy', save);
  422. document.execCommand('copy');
  423. document.removeEventListener('copy',save);
  424. if (content != '') {
  425. layer.msg('复制成功');
  426. }
  427. },
  428. //格式化文件大小
  429. renderSize:function(val){
  430. if(null==val||val==''){
  431. return "0 Bytes";
  432. }
  433. var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
  434. var index=0;
  435. var srcsize = parseFloat(val);
  436. index=Math.floor(Math.log(srcsize)/Math.log(1024));
  437. var size =srcsize/Math.pow(1024,index);
  438. size=size.toFixed(2);//保留的小数位数
  439. return size+unitArr[index];
  440. },
  441. //格式化附件展示
  442. fileCard:function(file,view){
  443. if(!file.hasOwnProperty('file_id')){
  444. file['file_id'] = file['id'];
  445. }
  446. let image=['jpg','jpeg','png','gif'];
  447. let office=['doc','docx','xls','xlsx','ppt','pptx'];
  448. let type_icon = 'icon-xiangmuguanli';
  449. let type = 0;//0下载+重命名+删除,1下载+查看+重命名+删除,2下载+查看+编辑+重命名+删除
  450. let ext = 'zip';
  451. let view_btn = '<a class="blue" href="'+file['filepath']+'" download="'+file['name']+'" target="_blank" title="下载"><i class="iconfont icon-xiazai"></i></a>';
  452. if(file['fileext'] == 'pdf'){
  453. type_icon = 'icon-kejian';
  454. ext = 'pdf';
  455. type = 1;
  456. }
  457. if(image.includes(file['fileext'])){
  458. type_icon = 'icon-sucaiguanli';
  459. ext = 'image';
  460. type = 1;
  461. }
  462. if(office.includes(file['fileext'])){
  463. type_icon = 'icon-shenbao';
  464. ext = 'office';
  465. type = 1;
  466. }
  467. if(view == ''){
  468. view_btn = '<span class="file-ctrl blue" data-ctrl="edit" data-type="'+type+'" data-fileid="'+file['file_id']+'" data-ext="'+ext+'" data-filename="'+file['name']+'" data-href="'+file['filepath']+'" data-id="'+file['id']+'" data-uid="'+file['admin_id']+'" title="附件操作"><i class="iconfont icon-gengduo1"></i></span><span class="name-edit green" style="display:none;" data-id="'+file['id']+'" data-fileid="'+file['file_id']+'" id="fileEdit'+file['file_id']+'" data-name="'+file['name']+'" data-fileext="'+file['fileext']+'" title="重命名"></span><span class="file-delete red" style="display:none;" data-uid="'+file['admin_id']+'" data-id="'+file['id']+'" data-fileid="'+file['file_id']+'" id="fileDel'+file['file_id']+'" title="删除"></span>';
  469. }
  470. else{
  471. view_btn = '<span class="file-ctrl blue" data-ctrl="view" data-type="'+type+'" data-fileid="'+file['file_id']+'" data-ext="'+ext+'" data-filename="'+file['name']+'" data-href="'+file['filepath']+'" title="附件操作"><i class="iconfont icon-gengduo1"></i></span>';
  472. }
  473. let file_del='';
  474. if(file['delete_time'] > 0){
  475. file_del = 'file-hasdelete';
  476. }
  477. let item = '<div class="file-card '+file_del+'" id="fileItem'+file['file_id']+'">\
  478. <i class="file-icon iconfont '+type_icon+'"></i>\
  479. <div class="file-info">\
  480. <div class="file-title" title="'+file['name']+'">'+file['name']+'</div>\
  481. <div class="file-ops">'+this.renderSize(file['filesize'])+','+layui.util.toDateString(file['create_time']*1000, 'yyyy-MM-dd hh:mm:ss')+'</div>\
  482. </div>\
  483. <div class="file-tool">'+view_btn+'</div>\
  484. </div>';
  485. return item;
  486. }
  487. };
  488. //时间选择快捷操作
  489. $('body').on('click', '.tool-time', function () {
  490. let that = $(this);
  491. let type = that.data('type');
  492. let range = that.data('range');
  493. let min = that.data('min');
  494. let max = that.data('max');
  495. let format = that.data('format');
  496. if (typeof(type) == "undefined" || type === '') {
  497. type = 'date';
  498. }
  499. if (typeof(range) == "undefined" || type === '') {
  500. range = false;
  501. }
  502. if (typeof(min) == "undefined" || min === '') {
  503. min = '1900-1-1';
  504. }
  505. if (typeof(max) == "undefined" || max === '') {
  506. max = '2099-1-1';
  507. }
  508. if (typeof(format) == "undefined" || format === '') {
  509. layui.laydate.render({
  510. elem: that,
  511. show: true,
  512. type: type,
  513. range: range,
  514. min: min,
  515. max: max,
  516. fullPanel: true
  517. });
  518. }else{
  519. layui.laydate.render({
  520. elem: that,
  521. show: true,
  522. type: type,
  523. range: range,
  524. min: min,
  525. max: max,
  526. format:format,
  527. fullPanel: true
  528. });
  529. }
  530. return false;
  531. });
  532. //附件操作
  533. const ctrlBtn=function(ctrl){
  534. //操作按钮'0下载','1查看','2编辑','3重命名','4删除','5移动','6标星','7取消标星','8还原','9清除'
  535. let ctrl_types = ['下载','查看','编辑','重命名','删除','移动','标星','取消标星','还原','清除'];
  536. let ctrls=[];
  537. for(let i=0;i<ctrl.length;i++){
  538. ctrls.push({"id":ctrl[i]+'',"title":ctrl_types[ctrl[i]]});
  539. }
  540. return ctrls;
  541. }
  542. $('body').on('click','.file-ctrl',function () {
  543. let that = $(this);
  544. let ctrl = $(this).data('ctrl');
  545. let fileid = $(this).data('fileid');
  546. let filename = $(this).data('filename');
  547. let type = $(this).data('type');
  548. let ext = $(this).data('ext');
  549. let href = $(this).data('href');
  550. let actionid=0;
  551. let file_menu = ctrlBtn([0]);
  552. //type:0下载+重命名+删除,1下载+查看+重命名+删除,2下载+查看+编辑+重命名+删除
  553. if(ctrl=='edit'){
  554. let types=[
  555. [0,1,3,4],//下载+查看+重命名+删除
  556. [0,1,3,4],//下载+查看+重命名+删除
  557. [0,1,2,3,4]//下载+查看+编辑+重命名+删除
  558. ];
  559. file_menu = ctrlBtn(types[type]);
  560. }
  561. if(ctrl=='view'){
  562. if(type==0){
  563. file_menu = ctrlBtn([0]);
  564. }
  565. else{
  566. file_menu = ctrlBtn([0,1]);
  567. }
  568. }
  569. if(ctrl=='disk'){
  570. if(type!=''){
  571. actionid = $(this).data('actionid');
  572. file_menu = ctrlBtn((type+'').split(","));
  573. }
  574. }
  575. console.log(actionid);
  576. dropdown.render({
  577. elem: that,
  578. className:'file-menu',
  579. align: 'right',
  580. show: true, // 外部事件触发即显示
  581. data: file_menu,
  582. click: function(obj){
  583. let click_t = obj.id;
  584. switch (click_t) {
  585. case '0':
  586. tool.downloadFile(href,filename);
  587. break;
  588. case '1':
  589. if(ext=='image'){
  590. tool.photoView(href);
  591. }
  592. if(ext=='pdf'){
  593. tool.pdfView(href);
  594. }
  595. if(ext=='video'){
  596. tool.videoView(href);
  597. }
  598. if(ext=='audio'){
  599. tool.audioView(href);
  600. }
  601. if(ext=='office'){
  602. if(ctrl=='disk'){
  603. tool.officeView(actionid,'view');
  604. }
  605. else{
  606. tool.officeView(fileid,'view');
  607. }
  608. }
  609. if(ext=='article'){
  610. tool.articleView(fileid);
  611. }
  612. break;
  613. case '2':
  614. if(ext=='office'){
  615. if(ctrl=='disk'){
  616. tool.officeView(actionid,'view');
  617. }
  618. else{
  619. tool.officeView(fileid,'view');
  620. }
  621. }
  622. if(ext=='article'){
  623. tool.articleEdit(fileid);
  624. }
  625. break;
  626. case '3'://编辑
  627. $('#fileEdit'+fileid).click();
  628. break;
  629. case '4'://删除
  630. $('#fileDel'+fileid).click();
  631. break;
  632. case '5'://移动
  633. $('#fileMove'+fileid).click();
  634. break;
  635. case '6'://标星
  636. $('#fileStar'+fileid).click();
  637. break;
  638. case '7'://取消标星
  639. $('#fileStarno'+fileid).click();
  640. break;
  641. case '8'://还原
  642. $('#fileBack'+fileid).click();
  643. break;
  644. case '9'://清除
  645. $('#fileClear'+fileid).click();
  646. break;
  647. default:
  648. return false;
  649. break;
  650. }
  651. }
  652. });
  653. });
  654. //搜索表单重置快捷操作
  655. $('body').on('click', '[lay-filter="reset"]', function () {
  656. let that = $(this);
  657. let prev = that.prev();
  658. if (typeof(prev) != "undefined") {
  659. setTimeout(function () {
  660. prev.click();
  661. }, 10)
  662. }
  663. });
  664. //新建按钮快捷操作
  665. $('body').on('click', '.tool-add', function () {
  666. let href = $(this).data('href');
  667. if (typeof(href) == "undefined" || href == '') {
  668. return false;
  669. }
  670. tool.side(href);
  671. return false;
  672. });
  673. $('body').on('click', '.tab-a', function () {
  674. let id = $(this).data('id');
  675. let url = $(this).data('href');
  676. let title = $(this).data('title');
  677. if (url && url !== '') {
  678. if (typeof(id) == "undefined" || id == '') {
  679. id = Date.now();
  680. }
  681. tool.tabAdd(url,title,id);
  682. }
  683. return false;
  684. });
  685. $('body').on('click', '.side-a', function () {
  686. let url = $(this).data('href');
  687. if (url && url !== '') {
  688. tool.side(url);
  689. }
  690. return false;
  691. });
  692. $('body').on('click', '.open-a', function () {
  693. let url = $(this).data('href');
  694. if (url && url !== '') {
  695. tool.open(url);
  696. }
  697. return false;
  698. });
  699. $('body').on('click', '.link-a', function () {
  700. let url = $(this).data('href');
  701. if (url && url !== '') {
  702. window.location.href=url;
  703. }
  704. return false;
  705. });
  706. exports(MOD_NAME, tool);
  707. });