Administrator
2025-07-10 a2c4af86b65f9c0b339bfcb37b1cc00b33f48b9e
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
<div class="layui-fluid layui-anim febs-anim" id="febs-type" 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="clothesType-table-form">
                        <div class="layui-row">
                            <div class="layui-col-md10">
                                <div class="layui-form-item">
                                </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">&#xe848;</i>
                                </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="clothesTypeTable" lay-data="{id: 'clothesTypeTable'}"></table>
 
                    <style type="text/css">
                        .layui-table-cell{
                            text-align:center;
                            height: auto;
                            white-space: nowrap; /*文本不会换行,在同一行显示*/
                            overflow: hidden; /*超出隐藏*/
                            text-overflow: ellipsis; /*省略号显示*/
                        }
                        .layui-table img{
                            max-width:100px
                        }
                        ::-webkit-scrollbar {
                            height: 20px !important;
                            background-color: #f4f4f4;
                        }
                    </style>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 表格操作栏 start -->
<script type="text/html" id="user-option">
    <span shiro:lacksPermission="list:view,add:add,votesActivityUpdate:update">
        <span class="layui-badge-dot febs-bg-orange"></span> 无权限
    </span>
    <a lay-event="edit" shiro:hasPermission="votesActivityUpdate:update"><i
            class="layui-icon febs-edit-area febs-blue">&#xe7a5;</i></a>
</script>
 
<script type="text/html" id="clothesTypeToolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="typeAdd:add" lay-event="typeAdd">新增</button>
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="artSet:view" lay-event="artSet">工艺配置</button>
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="sizeSet:view" lay-event="sizeSet">尺码配置</button>
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="clothSet:view" lay-event="clothSet">布料配置</button>
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="patternSet:view" lay-event="patternSet">正面图案配置</button>
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="locationSet:view" lay-event="locationSet">反面图案配置</button>
    </div>
</script>
 
<script type="text/html" id="clothesTypeOption">
    <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="typeInfo:view" lay-event="typeInfoEvent">编辑</button>
</script>
 
 
<script type="text/html" id="stateSwitch">
    {{# if(d.state === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" checked lay-skin="switch" lay-filter="stateSwitch">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" lay-skin="switch" lay-filter="stateSwitch">
    {{# } }}
</script>
<script type="text/html" id="clothStateSwitch">
    {{# if(d.clothState === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" checked lay-skin="switch" lay-filter="clothStateSwitch">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" lay-skin="switch" lay-filter="clothStateSwitch">
    {{# } }}
</script>
<script type="text/html" id="artStateSwitch">
    {{# if(d.artState === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" checked lay-skin="switch" lay-filter="artStateSwitch">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" lay-skin="switch" lay-filter="artStateSwitch">
    {{# } }}
</script>
<script type="text/html" id="patternStateSwitch">
    {{# if(d.patternState === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" checked lay-skin="switch" lay-filter="patternStateSwitch">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" lay-skin="switch" lay-filter="patternStateSwitch">
    {{# } }}
</script>
<script type="text/html" id="locationStateSwitch">
    {{# if(d.locationState === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" checked lay-skin="switch" lay-filter="locationStateSwitch">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" lay-skin="switch" lay-filter="locationStateSwitch">
    {{# } }}
</script>
<script type="text/html" id="sizeStateSwitch">
    {{# if(d.sizeState === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" checked lay-skin="switch" lay-filter="sizeStateSwitch">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" lay-skin="switch" lay-filter="sizeStateSwitch">
    {{# } }}
</script>
 
<style>
    .layui-form-onswitch {
        background-color: #5FB878 !important;
    }
</style>
<!-- 表格操作栏 end -->
<script data-th-inline="none" type="text/javascript">
    // 引入组件并初始化
    layui.use([ 'jquery', 'form', 'table', 'febs'], function () {
        var $ = layui.jquery,
            febs = layui.febs,
            form = layui.form,
            table = layui.table,
            $view = $('#febs-type'),
            $query = $view.find('#query'),
            $reset = $view.find('#reset'),
            $searchForm = $view.find('form'),
            sortObject = {field: 'orderNum', type: null},
            tableIns;
 
        form.render();
 
        // 表格初始化
        initClothesTypeTable();
 
        // 初始化表格操作栏各个按钮功能
        table.on('tool(clothesTypeTable)', function (obj) {
            console.log("触发事件:", obj.event); // 调试信息
            var data = obj.data,
                layEvent = obj.event;
 
            if (layEvent === 'seeImage') {
                var t = $view.find('#seeImage'+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 === 'seeImageFront') {
                var t = $view.find('#seeImageFront'+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 === 'seeImageBack') {
                var t = $view.find('#seeImageBack'+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 === 'typeInfoEvent') {
                febs.modal.open('编辑','modules/clothesType/typeInfo/' + data.id, {
                    btn: ['提交', '取消'],
                    area: ['100%', '100%'],
                    yes: function (index, layero) {
                        $('#febs-type-Info').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
        });
 
        form.on('switch(stateSwitch)', function (data) {
            if (data.elem.checked) {
                typeStateSwitch(1,data.value,1);
            } else {
                typeStateSwitch(1,data.value,0);
            }
        })
 
        form.on('switch(clothStateSwitch)', function (data) {
            if (data.elem.checked) {
                typeStateSwitch(2,data.value,1);
            } else {
                typeStateSwitch(2,data.value,0);
            }
        })
 
        form.on('switch(artStateSwitch)', function (data) {
            if (data.elem.checked) {
                typeStateSwitch(3,data.value,1);
            } else {
                typeStateSwitch(3,data.value,0);
            }
        })
 
        form.on('switch(patternStateSwitch)', function (data) {
            if (data.elem.checked) {
                typeStateSwitch(4,data.value,1);
            } else {
                typeStateSwitch(4,data.value,0);
            }
        })
 
        form.on('switch(locationStateSwitch)', function (data) {
            if (data.elem.checked) {
                typeStateSwitch(5,data.value,1);
            } else {
                typeStateSwitch(5,data.value,0);
            }
        })
 
        form.on('switch(sizeStateSwitch)', function (data) {
            if (data.elem.checked) {
                typeStateSwitch(6,data.value,1);
            } else {
                typeStateSwitch(6,data.value,0);
            }
        })
 
        function typeStateSwitch(type,id,state) {
            febs.get(ctx + 'admin/clothesType/changeState/' + id+'/' + type+'/' + state, null, function (data) {
                febs.alert.success(data.message);
                $query.click();
            });
        }
 
        // 初始化表格操作栏各个按钮功能
        table.on('toolbar(clothesTypeTable)', function (obj) {
            let data = obj.data,
                layEvent = obj.event;
            console.log("触发事件:", obj.event); // 调试信息
            if(layEvent === 'typeAdd'){
                febs.modal.open('新增', 'modules/clothesType/typeAdd/', {
                    btn: ['提交', '取消'],
                    area:['100%','100%'],
                    yes: function (index, layero) {
                        $('#febs-type-add').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
 
            if (layEvent === 'artSet') {
                var checkData = table.checkStatus('clothesTypeTable').data;
                if (checkData.length > 1 || checkData.length === 0) {
                    febs.alert.warn('每次操作只能操作一行数据');
                    return;
                }
                febs.modal.open('工艺配置', 'modules/clothesType/artSet/' + checkData[0].id, {
                    btn: ['提交', '取消'],
                    area:['100%','100%'],
                    yes: function (index, layero) {
                        $('#art-set').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
 
            if (layEvent === 'sizeSet') {
                var checkData = table.checkStatus('clothesTypeTable').data;
                if (checkData.length > 1 || checkData.length === 0) {
                    febs.alert.warn('每次操作只能操作一行数据');
                    return;
                }
                febs.modal.open('尺码配置', 'modules/clothesType/sizeSet/' + checkData[0].id, {
                    btn: ['提交', '取消'],
                    area:['100%','100%'],
                    yes: function (index, layero) {
                        $('#size-set').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
 
            if (layEvent === 'clothSet') {
                var checkData = table.checkStatus('clothesTypeTable').data;
                if (checkData.length > 1 || checkData.length === 0) {
                    febs.alert.warn('每次操作只能操作一行数据');
                    return;
                }
                febs.modal.open('布料配置', 'modules/clothesType/clothSet/' + checkData[0].id, {
                    btn: ['提交', '取消'],
                    area:['100%','100%'],
                    yes: function (index, layero) {
                        $('#cloth-set').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
 
            if (layEvent === 'patternSet') {
                var checkData = table.checkStatus('clothesTypeTable').data;
                if (checkData.length > 1 || checkData.length === 0) {
                    febs.alert.warn('每次操作只能操作一行数据');
                    return;
                }
                febs.modal.open('正面图案配置', 'modules/clothesType/patternSet/' + checkData[0].id, {
                    btn: ['提交', '取消'],
                    area:['100%','100%'],
                    yes: function (index, layero) {
                        $('#pattern-set').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
 
            if (layEvent === 'locationSet') {
                var checkData = table.checkStatus('clothesTypeTable').data;
                if (checkData.length > 1 || checkData.length === 0) {
                    febs.alert.warn('每次操作只能操作一行数据');
                    return;
                }
                febs.modal.open('反面图案配置', 'modules/clothesType/locationSet/' + checkData[0].id, {
                    btn: ['提交', '取消'],
                    area:['100%','100%'],
                    yes: function (index, layero) {
                        $('#location-set').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
        });
 
        function initClothesTypeTable() {
            tableIns = febs.table.init({
                elem: $view.find('table'),
                id: 'clothesTypeTable',
                url: ctx + 'admin/clothesType/typeList',
                toolbar:"#clothesTypeToolbar",
                defaultToolbar:[],
                cols: [[
                    {type: 'checkbox'},
                    {type: 'numbers', title: '', width: 80},
                    {title: '操作', toolbar: '#clothesTypeOption', minWidth: 200, align: 'center'},
                    {field: 'name', title: '名称', minWidth: 150,align:'center'},
                    {field: 'orderNum', title: '序号', minWidth: 100,align:'center'},
                    {field: 'state', title: '允许上线', templet: '#stateSwitch', minWidth: 130,align:'center'},
                    {field: 'clothState', title: '允许选择布料', templet: '#clothStateSwitch', minWidth: 130,align:'center'},
                    {field: 'artState', title: '允许选择工艺', templet: '#artStateSwitch', minWidth: 130,align:'center'},
                    {field: 'patternState', title: '允许选择正面图案', templet: '#patternStateSwitch', minWidth: 130,align:'center'},
                    {field: 'locationState', title: '允许选择反面图案', templet: '#locationStateSwitch', minWidth: 180,align:'center'},
                    {field: 'sizeState', title: '允许选择尺码', templet: '#sizeStateSwitch', minWidth: 130,align:'center'},
                    {field: 'image',title: '小图标',
                        templet: function (d) {
                            return '<a lay-event="seeImage">' +
                                '<img id="seeImage' + d.id + '" src="' + d.image +
                                '" alt="小图标" style="width: 50px; height: 50px; object-fit: cover; border-radius: 5px; cursor: pointer;">' +
                                '</a>';
                        },
                    minWidth: 150,align: 'center'},
                    {field: 'imageFront',title: '正面',
                        templet: function (d) {
                            return '<a lay-event="seeImageFront">' +
                                '<img id="seeImageFront' + d.id + '" src="' + d.imageFront +
                                '" alt="正面" style="width: 50px; height: 50px; object-fit: cover; border-radius: 5px; cursor: pointer;">' +
                                '</a>';
                        },
                    minWidth: 150,align: 'center'},
                    {field: 'imageBack',title: '反面',
                        templet: function (d) {
                            return '<a lay-event="seeImageBack">' +
                                '<img id="seeImageBack' + d.id + '" src="' + d.imageBack +
                                '" alt="反面" style="width: 50px; height: 50px; object-fit: cover; border-radius: 5px; cursor: pointer;">' +
                                '</a>';
                        },
                    minWidth: 150,align: 'center'},
                ]]
            });
        }
 
 
        // 查询按钮
        $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});
        });
        // 获取查询参数
        function getQueryParams() {
            return {
                // name: $searchForm.find('input[name="name"]').val().trim(),
                // state: $searchForm.find("select[name='state']").val(),
                // categoryId: $searchForm.find("select[name='categoryId']").val(),
            };
        }
 
    })
</script>