| | |
| | | <div class="layui-fluid layui-anim febs-anim" id="febs-banner" lay-title="轮播图"> |
| | | <div class="layui-fluid layui-anim febs-anim" id="febs-banner" lay-title="轮播图列表"> |
| | | <div class="layui-row febs-container"> |
| | | <div class="layui-col-md12"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body febs-table-full"> |
| | | <form class="layui-form layui-table-form" lay-filter="user-table-form"> |
| | | <div class="layui-row"> |
| | | <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area"> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="add"> |
| | | 新增 |
| | | </div> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset"> |
| | | <i class="layui-icon"></i> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </form> |
| | | <form class="layui-form layui-table-form" lay-filter="user-table-form"> |
| | | <div class="layui-row"> |
| | | <div class="layui-col-md10"> |
| | | <div class="layui-form-item"> |
| | | |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label layui-form-label-sm">分类</label> |
| | | <div class="layui-input-inline"> |
| | | <select name="type" class="bannerList-type"> |
| | | <option value="0">请选择</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area"> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query"> |
| | | <i class="layui-icon"></i> |
| | | </div> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset"> |
| | | <i class="layui-icon"></i> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </form> |
| | | <table lay-filter="bannerTable" lay-data="{id: 'bannerTable'}"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <script type="text/html" id="typeName"> |
| | | {{# |
| | | var type = { |
| | | 4: {title: '社区首页', color: 'red' }, |
| | | 3: {title: '商城首页', color: 'gray' }, |
| | | 2: {title: '开屏页', color: 'green' }, |
| | | 1: {title: '小程序首页' , color: 'blue'}, |
| | | }[d.type]; |
| | | }} |
| | | <span class="layui-badge febs-bg-{{type.color}}">{{ type.title }}</span> |
| | | </script> |
| | | |
| | | <script type="text/html" id="isJump"> |
| | | {{# |
| | |
| | | }} |
| | | <span class="layui-badge febs-bg-{{isTop.color}}">{{ isTop.title }}</span> |
| | | </script> |
| | | |
| | | <script type="text/html" id="bannerToolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="platformBannerAdd:add" lay-event="platformBannerAdd">新增</button> |
| | | </div> |
| | | </script> |
| | | <!-- 表格操作栏 start --> |
| | | <script type="text/html" id="user-option"> |
| | | <!-- <span shiro:lacksPermission="user:view,user:update,user:delete">--> |
| | | <!-- <span class="layui-badge-dot febs-bg-orange"></span> 无权限--> |
| | | <!-- </span>--> |
| | | <!-- <a lay-event="edit" shiro:hasPermission="user:update">编辑--> |
| | | <a lay-event="edit">编辑 |
| | | <i class="layui-icon febs-edit-area febs-blue"></i> |
| | | </a> |
| | | <!-- <a lay-event="delete" shiro:hasPermission="user:update">删除--> |
| | | <a lay-event="delete">删除 |
| | | <i class="layui-icon febs-edit-area febs-blue"></i> |
| | | </a> |
| | | |
| | | <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="platformBannerUpdate:update" lay-event="editBanner">编辑</button> |
| | | <button class="layui-btn layui-btn-danger layui-btn-sm" type="button" shiro:hasPermission="platformBannerUpdate:update" lay-event="deleteBanner">删除</button> |
| | | </script> |
| | | <!-- 表格操作栏 end --> |
| | | <script data-th-inline="none" type="text/javascript"> |
| | |
| | | table = layui.table, |
| | | dropdown = layui.dropdown, |
| | | $view = $('#febs-banner'), |
| | | $query = $view.find('#query'), |
| | | $reset = $view.find('#reset'), |
| | | $add = $view.find('#add'), |
| | | $searchForm = $view.find('form'), |
| | | sortObject = {field: 'spread', type: null}, |
| | | sortObject = {field: 'sort', type: null}, |
| | | tableIns |
| | | ; |
| | | |
| | | form.render(); |
| | | |
| | | //(下拉框) |
| | | $.get(ctx + 'admin/banner/typeAll', function (res) { |
| | | var data = res.data; |
| | | for (let k in data) |
| | | { |
| | | $(".bannerList-type").append("<option value='" + data[k].type + "'>" + data[k].code + "</option>"); |
| | | } |
| | | layui.use('form', function () { |
| | | var form = layui.form; |
| | | form.render(); |
| | | }); |
| | | }); |
| | | |
| | | // 表格初始化 |
| | | initTable(); |
| | |
| | | table.on('tool(bannerTable)', function (obj) { |
| | | var data = obj.data, |
| | | layEvent = obj.event; |
| | | |
| | | if (layEvent === 'seeIconPng') { |
| | | var t = $view.find('#seeIconPng'+data.id+''); |
| | | //页面层 |
| | | layer.open({ |
| | | type: 1, |
| | | title: "图片", |
| | | skin: 'layui-layer-rim', //加上边框 |
| | | area: ['100%', '100%'], //宽高 |
| | | shadeClose: true, //开启遮罩关闭 |
| | | end: function (index, layero) { |
| | | return false; |
| | | }, |
| | | content: '<div style="text-align:center"><img src="' + $(t).attr('src') + '" /></div>' |
| | | }); |
| | | } |
| | | |
| | | if (layEvent === 'edit') { |
| | | febs.modal.open('轮播图设置', 'modules/banner/platformBannerUpdate/' + data.id, { |
| | | if (layEvent === 'editBanner') { |
| | | febs.modal.open('设置', 'modules/banner/platformBannerUpdate/' + data.id, { |
| | | btn: ['提交', '取消'], |
| | | area: ['100%', '100%'], |
| | | yes: function (index, layero) { |
| | | $('#banner-update').find('#submit').trigger('click'); |
| | | $('#febs-banner-Info').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | } |
| | | if (layEvent === 'delete') { |
| | | if (layEvent === 'deleteBanner') { |
| | | febs.modal.confirm('删除', '您是否确认删除?', function () { |
| | | deleteUsers(data.id); |
| | | }); |
| | |
| | | $reset.click(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | // 查询按钮 |
| | | $query.on('click', function () { |
| | | var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type}); |
| | | tableIns.reload({where: params, page: {curr: 1}}); |
| | | }); |
| | | // 刷新按钮 |
| | | $reset.on('click', function () { |
| | | $searchForm[0].reset(); |
| | | sortObject.type = 'null'; |
| | | tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject}); |
| | | }); |
| | | |
| | | // 刷新按钮 |
| | | $add.on('click', function () { |
| | | febs.modal.open('轮播图新增', 'modules/banner/platformBannerAdd/', { |
| | | btn: ['提交', '取消'], |
| | | yes: function (index, layero) { |
| | | $('#banner-add').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | |
| | | // 初始化表格操作栏各个按钮功能 |
| | | table.on('toolbar(bannerTable)', function (obj) { |
| | | let data = obj.data, |
| | | layEvent = obj.event; |
| | | console.log("触发事件:", obj.event); // 调试信息 |
| | | if(layEvent === 'platformBannerAdd'){ |
| | | febs.modal.open('新增', 'modules/banner/platformBannerAdd/', { |
| | | btn: ['提交', '取消'], |
| | | area:['100%','100%'], |
| | | yes: function (index, layero) { |
| | | $('#febs-banner-add').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | // 获取查询参数 |
| | | function getQueryParams() { |
| | | return {}; |
| | | return { |
| | | type: $searchForm.find("select[name='type']").val(), |
| | | }; |
| | | } |
| | | |
| | | |
| | | function initTable() { |
| | | tableIns = febs.table.init({ |
| | | elem: $view.find('table'), |
| | | id: 'bannerTable', |
| | | url: ctx + 'admin/banner/platformBanner', |
| | | toolbar:"#bannerToolbar", |
| | | defaultToolbar:[], |
| | | cols: [[ |
| | | {field: 'id', title: '', minWidth: 10,align:'left'}, |
| | | {title: '操作', toolbar: '#user-option', minWidth: 140, fixed : 'right'}, |
| | | {title: '分类', templet: '#typeName', minWidth: 60,align:'center'}, |
| | | {field: 'name', title: '标题', minWidth: 120,align:'center'}, |
| | | {field: 'imageUrl', title: '图片链接', |
| | | {field: 'imageUrl',title: '图片', |
| | | templet: function (d) { |
| | | return '<img src="'+d.imageUrl+'" >' |
| | | }, minWidth: 200,align:'center'}, |
| | | {field: 'jumpUrl', title: '跳转链接', minWidth: 200,align:'center'}, |
| | | // {field: 'sort', title: '联系方式', minWidth: 200,align:'center'}, |
| | | |
| | | return '<a lay-event="seeIconPng">' + |
| | | '<img id="seeIconPng' + d.id + '" src="' + d.imageUrl + |
| | | '" alt="图片" style="width: 50px; height: 50px; object-fit: cover; border-radius: 5px; cursor: pointer;">' + |
| | | '</a>'; |
| | | }, |
| | | minWidth: 150,align: 'center'}, |
| | | {title: '是否可跳转', templet: '#isJump', minWidth: 60,align:'center'}, |
| | | {field: 'jumpUrl', title: '跳转链接', minWidth: 200,align:'center'}, |
| | | {title: '跳转外部或内部', templet: '#isInside', minWidth: 60,align:'center'}, |
| | | // {title: '显示端口', templet: '#showPort', minWidth: 60,align:'center'}, |
| | | {title: '是否置顶', templet: '#isTop', minWidth: 60,align:'center'}, |
| | | |
| | | {title: '操作', toolbar: '#user-option', minWidth: 140, fixed : 'right'} |
| | | ]] |
| | | }); |
| | | } |