xiaoyong931011
2021-03-25 3ae27cce492f2534282da39db1ca257b6ce8f0ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<div class="layui-fluid layui-anim febs-anim" id="febs-user" 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">&#xe79b;</i>
                                    </div>
                                </div>
                            </div>
                        </form>
                    <table lay-filter="userTable" lay-data="{id: 'userTable'}"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="isBanner">
    {{#
    var isBanner = {
    2: {title: '否', color: 'red' },
    1: {title: '是' , color: 'green'}
    }[d.isBanner];
    }}
    <span class="layui-badge febs-bg-{{isBanner.color}}">{{ isBanner.title }}</span>
</script>
<script type="text/html" id="isJump">
    {{#
    var isJump = {
    2: {title: '否', color: 'red' },
    1: {title: '是' , color: 'green'}
    }[d.isJump];
    }}
    <span class="layui-badge febs-bg-{{isJump.color}}">{{ isJump.title }}</span>
</script>
<script type="text/html" id="isInside">
    {{#
    var isInside = { 
    2: {title: '外'  , color: 'green'},
    1: {title: '内', color: 'red'}
    }[d.isInside];
    }}
    <span class="layui-badge febs-bg-{{isInside.color}}">{{ isInside.title }}</span>
</script>
<script type="text/html" id="showPort">
    {{#
    var showPort = { 
    2: {title: '手机'  , color: 'green'},
    1: {title: 'pc', color: 'red'}
    }[d.showPort];
    }}
    <span class="layui-badge febs-bg-{{showPort.color}}">{{ showPort.title }}</span>
</script>
<script type="text/html" id="isTop">
    {{#
    var isTop = { 
    2: {title: '否', color: 'red' },
    1: {title: '是' , color: 'green'}
    }[d.isTop];
    }}
    <span class="layui-badge febs-bg-{{isTop.color}}">{{ isTop.title }}</span>
</script>
<!-- 表格操作栏
    <a lay-event="edit" shiro:hasPermission="user:update">编辑
        <i class="layui-icon febs-edit-area febs-blue"></i>
     </a>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>
    <button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" shiro:hasPermission="user:update">修改
        <i class="layui-icon febs-edit-area febs-blue"></i>
    </button>
    <button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="delete" shiro:hasPermission="user:update">删除
        <i class="layui-icon febs-edit-area febs-blue"></i>
     </button>
</script>
<!-- 表格操作栏 end -->
<script data-th-inline="none" type="text/javascript">
    // 引入组件并初始化
    layui.use(['dropdown', 'jquery', 'laydate', 'form', 'table', 'febs'], function () {
        var $ = layui.jquery,
            laydate = layui.laydate,
            febs = layui.febs,
            form = layui.form,
            table = layui.table,
            dropdown = layui.dropdown,
            $view = $('#febs-user'),
            $reset = $view.find('#reset'),
            $add = $view.find('#add'),
            $searchForm = $view.find('form'),
            sortObject = {field: 'spread', type: null},
            tableIns
            ;
 
        form.render();
 
        // 表格初始化
        initTable();
 
        // 初始化表格操作栏各个按钮功能
        table.on('tool(userTable)', function (obj) {
            var data = obj.data,
                layEvent = obj.event;
            
            if (layEvent === 'edit') {
                febs.modal.open('轮播图设置', 'modules/systemSetting/platformBannerUpdate/' + data.id, {
                    btn: ['提交', '取消'],
                    yes: function (index, layero) {
                        $('#user-update').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
            if (layEvent === 'delete') {
                febs.modal.confirm('删除', '您是否确认删除?', function () {
                    deleteUsers(data.id);
                });
            }
        });
        
        function deleteUsers(id) {
            febs.get(ctx + 'systemSetting/platformBannerDelete/' + id, null, function () {
                febs.alert.success('确认删除');
                $reset.click();
            });
        }
        
         // 刷新按钮
        $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/systemSetting/platformBannerAdd/', {
                btn: ['提交', '取消'],
                yes: function (index, layero) {
                    $('#user-add').find('#submit').trigger('click');
                },
                btn2: function () {
                    layer.closeAll();
                }
            });
        });
 
         
         // 获取查询参数
        function getQueryParams() {
            return {};
        }
        
        function initTable() {
            tableIns = febs.table.init({
                elem: $view.find('table'),
                id: 'userTable',
                url: ctx + 'systemSetting/platformBanner',
                cols: [[
                    {field: 'id', title: '', minWidth: 10,align:'left'},
                    {field: 'name', title: '标题', minWidth: 120,align:'center'},
                    {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'},
                    
                    {title: '是否可跳转', templet: '#isJump', minWidth: 60,align:'center'},
                    {title: '跳转外部或内部', templet: '#isInside', minWidth: 60,align:'center'},
                    {title: '显示端口', templet: '#showPort', minWidth: 60,align:'center'},
                    {title: '是否置顶', templet: '#isTop', minWidth: 60,align:'center'},
                    {title: '是否是Banner', templet: '#isBanner', minWidth: 60,align:'center'},
                    
                    {title: '操作', toolbar: '#user-option', minWidth: 140, fixed : 'right'}
                ]]
            });
        }
    })
</script>