分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

js基于Layui模块化封装

发布时间:2023-09-06 02:18责任编辑:顾先生关键词:js
//设置body高度$(function () { ???var topHei = 0; ???var CH = window.innerHeight || document.documentElement.clientHeight; ???document.getElementsByTagName("body")[0].style.height = CH - topHei + ‘px‘; ???return CH - topHei;});//-------------对UI中表格进行模块化封装处理-----------------------------------var laytable;//基础参数配置var baseCfg = { ???datatype: ‘table‘, ???page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档 ???????layout: [‘limit‘, ‘count‘, ‘prev‘, ‘page‘, ‘next‘, ‘skip‘] //自定义分页布局 ???????????????, groups: 3 //只显示 1 个连续页码 ???????????????, first: false //不显示首页 ???????????????, last: false //不显示尾页 ???????????????, limit: 5 ???????????????, curr: location.hash.replace(‘#!fenye=‘, ‘‘) //获取起始页 ?, hash: ‘fenye‘ //自定义hash值 ???} ?, height: 415 ?, id: ‘TableDataReload‘ ?, method: "post"};var le= le|| {};(function () { ???var commerical = function (cusCfg) { ???????this.config = {}; ???????$.extend(this.config, baseCfg); ???????$.extend(this.config, cusCfg); ???????this.__init(this.config); ???????this.__bindEvent(); ???}; ???commerical.prototype = { ???????__init: function (cfg) { ???????????layui.use([‘table‘], function () { ???????????????laytable = layui.table; ???????????????laytable.render(cfg); ???????????????if (cfg.actionBar) { ???????????????????laytable.on(‘tool(‘ + cfg.actionBarFilter + ‘)‘, function (obj) { ???????????????????????var data = obj.data; ???????????????????????var type = obj.event; ???????????????????????active[type] ? active[type].call(this, data) : ‘‘; ???????????????????}); ???????????????} ???????????}); ???????}, ???????__bindEvent: function () { ???????????//动态绑定全局.layui-btn按钮事件 ???????????$(‘.layui-btn‘).on(‘click‘, function () { ???????????????var type = $(this).data(‘type‘); ???????????????active[type] ? active[type].call(this) : ‘‘; ???????????}); ???????} ???}; ???le.sy = function () { ???????return { ???????????init: function (config) { ???????????????try { ???????????????????if (config == undefined || config == null) { ???????????????????????throw ‘config is empty!‘; ???????????????????} else { ???????????????????????return new commerical(config); ???????????????????} ???????????????} catch (e) { ???????????????????return e; ???????????????} ???????????}, ???????????reload: function (obj) { ???????????????laytable.reload(‘TableDataReload‘, { ???????????????????where: obj ???????????????}); ???????????}, ???????????layerOpen: function (domId,title) { ???????????????layer.open({ ???????????????????type: 1, ???????????????????shade: 0.8, ???????????????????btnAlign: ‘c‘, ???????????????????resize: false, ???????????????????title: title||"编辑", ???????????????????area: [‘440px‘, ‘410px‘], ???????????????????offset: [‘100px‘, ‘200px‘], ???????????????????content: $(‘#‘ + domId) ???????????????}); ???????????}, ???????????layerClose: function () { ???????????}, ???????????msg: function (msg) { ???????????????layer.msg(msg); ???????????} ???????} ???}();})();

js基于Layui模块化封装

原文地址:https://www.cnblogs.com/micnote/p/9800306.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved