记得上下班打卡 | git大法好,push需谨慎

Commit bdae082e authored by wangyifan's avatar wangyifan

admin banner时间范围、排序必填

parent b326d5fd
...@@ -38,7 +38,7 @@ public class GoblinFrontBannerBuildParam implements Serializable { ...@@ -38,7 +38,7 @@ public class GoblinFrontBannerBuildParam implements Serializable {
/** /**
* 排序 * 排序
*/ */
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序", required = true)
private Integer indexs; private Integer indexs;
/** /**
...@@ -50,14 +50,14 @@ public class GoblinFrontBannerBuildParam implements Serializable { ...@@ -50,14 +50,14 @@ public class GoblinFrontBannerBuildParam implements Serializable {
/** /**
* 开启时间 * 开启时间
*/ */
@ApiModelProperty(value = "开启时间") @ApiModelProperty(value = "开启时间", required = true)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
private LocalDateTime startTime; private LocalDateTime startTime;
/** /**
* 结束时间 * 结束时间
*/ */
@ApiModelProperty(value = "结束时间") @ApiModelProperty(value = "结束时间", required = true)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern=DateUtil.DATE_FULL_STR) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern=DateUtil.DATE_FULL_STR)
private LocalDateTime endTime; private LocalDateTime endTime;
......
...@@ -70,6 +70,28 @@ public class GoblinFrontBannerController extends BaseController { ...@@ -70,6 +70,28 @@ public class GoblinFrontBannerController extends BaseController {
@ApiOperation(value = "修改或者增加banner") @ApiOperation(value = "修改或者增加banner")
@ResponseBody @ResponseBody
public AjaxResult updateOrCreate(@RequestBody List<GoblinFrontBannerBuildParam> list) { public AjaxResult updateOrCreate(@RequestBody List<GoblinFrontBannerBuildParam> list) {
if (list == null || list.isEmpty()) {
return error("请添加banner");
}
int i = 0;
for (GoblinFrontBannerBuildParam param : list) {
i++;
if (param.getStartTime() == null) {
return error("第" + i + "张banner请填写开启时间");
}
if (param.getEndTime() == null) {
return error("第" + i + "张banner请填写结束时间");
}
if (param.getEndTime().isBefore(param.getStartTime())) {
return error("第" + i + "张banner结束时间不能早于开启时间");
}
// type=2 活动banner 页面隐藏了单项排序,不校验 indexs
if (param.getBannerType() == null || param.getBannerType() != 2) {
if (param.getIndexs() == null) {
return error("第" + i + "张banner请填写排序");
}
}
}
List<GoblinFrontBanner> goblinFrontBannerList=new ArrayList<>(); List<GoblinFrontBanner> goblinFrontBannerList=new ArrayList<>();
for(GoblinFrontBannerBuildParam goblinFrontBannerBuildParam1:list){ for(GoblinFrontBannerBuildParam goblinFrontBannerBuildParam1:list){
GoblinFrontBanner goblinFrontBanner=new GoblinFrontBanner(); GoblinFrontBanner goblinFrontBanner=new GoblinFrontBanner();
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
</div> </div>
<div class="function_btn" id="showMiddleBanner" style="display: none;"> <div class="function_btn" id="showMiddleBanner" style="display: none;">
<div class="hot_title"> <div class="hot_title">
位置顺序: 位置顺序:<span style="color:#f5222d;">*</span>
</div> </div>
<div class="tags" style="font-weight: 600;font-size: 16px;"> <div class="tags" style="font-weight: 600;font-size: 16px;">
<input type="text" class="layui-input form-control titleIpt" id="sorting" value="" autocomplete="off" placeholder="请输入模块顺序"> <input type="text" class="layui-input form-control titleIpt" id="sorting" value="" autocomplete="off" placeholder="请输入模块顺序">
...@@ -270,19 +270,19 @@ ...@@ -270,19 +270,19 @@
<div class="set_function"> <div class="set_function">
<div class="set_function_time"> <div class="set_function_time">
<div class="title"> <div class="title">
时间设置: 时间设置:<span style="color:#f5222d;">*</span>
</div> </div>
<div class="select_tiem" style="display:flex;"> <div class="select_tiem" style="display:flex;">
<input type="text" class="layui-input form-control timeStart" id="startTime${i+1}" value="${data[i].startTime || ''}" autocomplete="off" placeholder="配置活动时间"> <input type="text" class="layui-input form-control timeStart" id="startTime${i+1}" value="${data[i].startTime || ''}" autocomplete="off" placeholder="开始时间(必填)">
<input type="text" class="layui-input form-control timeEnd" id="endTime${i+1}" value="${data[i].endTime || ''}" autocomplete="off" placeholder="配置活动时间"> <input type="text" class="layui-input form-control timeEnd" id="endTime${i+1}" value="${data[i].endTime || ''}" autocomplete="off" placeholder="结束时间(必填)">
</div> </div>
</div> </div>
<div class="set_function_time pxBox" style="width: 40%;"> <div class="set_function_time pxBox" style="width: 40%;">
<div class="title"> <div class="title">
排序: 排序:<span style="color:#f5222d;">*</span>
</div> </div>
<div class="select_tiem"> <div class="select_tiem">
<input id="px${i+1}" type="text" class="layui-input form-control px" value="${data[i].indexs}" placeholder="请输入顺序数字"> <input id="px${i+1}" type="text" class="layui-input form-control px" value="${data[i].indexs}" placeholder="请输入顺序数字(必填)">
</div> </div>
</div> </div>
</div> </div>
...@@ -359,19 +359,19 @@ ...@@ -359,19 +359,19 @@
<div class="set_function"> <div class="set_function">
<div class="set_function_time"> <div class="set_function_time">
<div class="title"> <div class="title">
时间设置: 时间设置:<span style="color:#f5222d;">*</span>
</div> </div>
<div class="select_tiem" style="display:flex;"> <div class="select_tiem" style="display:flex;">
<input type="text" class="layui-input form-control timeStart" id="startTime${num}" autocomplete="off" placeholder="配置活动时间"> <input type="text" class="layui-input form-control timeStart" id="startTime${num}" autocomplete="off" placeholder="开始时间(必填)">
<input type="text" class="layui-input form-control timeEnd" id="endTime${num}" autocomplete="off" placeholder="配置活动时间"> <input type="text" class="layui-input form-control timeEnd" id="endTime${num}" autocomplete="off" placeholder="结束时间(必填)">
</div> </div>
</div> </div>
<div class="set_function_time pxBox" style="width: 40%;"> <div class="set_function_time pxBox" style="width: 40%;">
<div class="title"> <div class="title">
排序: 排序:<span style="color:#f5222d;">*</span>
</div> </div>
<div class="select_tiem"> <div class="select_tiem">
<input id="px${num}" type="text" class="layui-input form-control px" placeholder="请输入顺序数字"> <input id="px${num}" type="text" class="layui-input form-control px" placeholder="请输入顺序数字(必填)">
</div> </div>
</div> </div>
</div> </div>
...@@ -385,24 +385,40 @@ ...@@ -385,24 +385,40 @@
} }
} }
function save () { function save () {
let obj = {};
let itmeLength = $(".banner_item"); let itmeLength = $(".banner_item");
if (!itmeLength.length) {
let data = [] return layer.msg('请先添加banner');
Array.prototype.forEach.call(itmeLength,function (item,index,arr) { }
let data = [];
for (let index = 0; index < itmeLength.length; index++) {
let item = itmeLength[index];
let startTime = (item.querySelector('.timeStart').value || '').trim();
let endTime = (item.querySelector('.timeEnd').value || '').trim();
let indexs = (item.querySelector('.px').value || '').trim();
if (!startTime) {
return layer.msg('请填写第' + (index + 1) + '张banner的开始时间');
}
if (!endTime) {
return layer.msg('请填写第' + (index + 1) + '张banner的结束时间');
}
if (startTime > endTime) {
return layer.msg('第' + (index + 1) + '张banner结束时间不能早于开始时间');
}
if (type != 2 && indexs === '') {
return layer.msg('请填写第' + (index + 1) + '张banner的排序');
}
let obj = {};
obj.activityUrl = item.querySelector('.h5Url').value; obj.activityUrl = item.querySelector('.h5Url').value;
obj.bannerId = item.getAttribute('data-id'); obj.bannerId = item.getAttribute('data-id');
obj.bannerType = type; obj.bannerType = type;
obj.createTime = item.getAttribute('data-createTime'); obj.createTime = item.getAttribute('data-createTime');
obj.delTag = '0'; obj.delTag = '0';
obj.endTime = item.getAttribute('data-endTime'); obj.indexs = indexs;
obj.indexs = item.querySelector('.px').value;
obj.jumpType = item.querySelector('#jumpSelect'+(index+1)+'').value; obj.jumpType = item.querySelector('#jumpSelect'+(index+1)+'').value;
obj.mid = item.getAttribute('data-mid') || 0; // obj.mid = item.getAttribute('data-mid') || 0;
obj.picUrl = item.querySelector('.imgBox').getAttribute('src'); obj.picUrl = item.querySelector('.imgBox').getAttribute('src');
obj.startTime = item.querySelector('.timeStart').value; obj.startTime = startTime;
obj.endTime = item.querySelector('.timeEnd').value; obj.endTime = endTime;
// obj.updateTime = item.getAttribute('data-upData');
if (item.querySelector('#jumpSelect'+(index+1)+'').value == 2) { if (item.querySelector('#jumpSelect'+(index+1)+'').value == 2) {
obj.ticketId = item.querySelector('.h5Url').getAttribute('data-id'); obj.ticketId = item.querySelector('.h5Url').getAttribute('data-id');
obj.ticketName = item.querySelector('.h5Url').value; obj.ticketName = item.querySelector('.h5Url').value;
...@@ -413,8 +429,11 @@ ...@@ -413,8 +429,11 @@
obj.ticketId = item.querySelector('.storeList').getAttribute('data-id'); obj.ticketId = item.querySelector('.storeList').getAttribute('data-id');
obj.ticketName = item.querySelector('.storeList').value; obj.ticketName = item.querySelector('.storeList').value;
} }
data.push({...obj}) data.push(obj);
});//foreach js6章封装的方法 }
if (type == 2 && !($("#sorting").val() || '').trim()) {
return layer.msg('请填写位置顺序');
}
promiseMethods('/frontBanner/updateOrCreate', 'post', JSON.stringify(data), 'application/json').then(res => { promiseMethods('/frontBanner/updateOrCreate', 'post', JSON.stringify(data), 'application/json').then(res => {
if (type == 2) { if (type == 2) {
let data = { let data = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment