<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"></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="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"></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>
|