工作日显示在页面上并选择
小白一枚。欢迎讨论
继上篇文章显示日期到页面:
一、controller
/**
*
* 获取审核完成后22个工作日的时间
*
* */
@RequestMapping(value = "/time")
@ResponseBody
public AjaxCommonObject dueDateList(int num,String serialNo) throws ParseException {
AjaxCommonObject res = new AjaxCommonObject();
try {
List<Duedate> list = dueDateService.getDueDateList();
List<Duedate> listbyflag = dueDateService.getList();
Date ct = itemOrderService.selectpreviewBySerialNo(serialNo);
List datelist = HolidayUtils.getScheduleActiveDate(ct,list,listbyflag,num);
Map<String, Object> ret = new HashMap<>();
ret.put("list",datelist);
res.setData(ret);
} catch (BizCommonException e) {
return new AjaxCommonObject(e);
}
return res;
}
异常类AjaxCommonObject:
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package net.aexit.galaxy.earth.common.utils;
public class AjaxCommonObject {
private int code;
private String message;
private Object data;
public AjaxCommonObject() {
this.code = 0;
this.message = "ajax业务请求正确响应";
}
public AjaxCommonObject(int code, String message) {
this.code = code;
this.message = message;
}
public AjaxCommonObject(BizCommonException bizCommonException) {
this.code = bizCommonException.getCode();
this.message = bizCommonException.getMessage();
}
public AjaxCommonObject(BizCommonExceptionEnum bizCommonExceptionEnum) {
this.code = bizCommonExceptionEnum.getCode();
this.message = bizCommonExceptionEnum.getMessage();
}
public int getCode() {
return this.code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public Object getData() {
return this.data;
}
public void setData(Object data) {
this.data = data;
}
}
异常类:BizCommonException
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package net.aexit.galaxy.earth.common.utils;
public class BizCommonException extends RuntimeException {
private int code;
private String message;
public BizCommonException(int code, String message) {
super(message);
this.code = code;
this.message = message;
}
public BizCommonException(BizCommonExceptionEnum bizCommonExceptionEnum) {
this.code = bizCommonExceptionEnum.getCode();
this.message = bizCommonExceptionEnum.getMessage();
}
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public int getCode() {
return this.code;
}
public void setCode(int code) {
this.code = code;
}
}
页面:
<div class="row" style="border-bottom: 1px solid black">
<ul class="ulStyle">
</ul>
<div style="text-align: center;margin-bottom: 20px;">
<input type="button" id="button" style="display:none;padding:10px;background: #36a9ce;border-radius: 4px;color: #333;border: none;box-shadow: 4px 4px 0 #cdcdcd;">
</div>
</div>
css:
<style>
/*添加预约样式*/
*{
padding: 0;
margin:0 ;
}
.ulStyle{
width: 1000px;
padding: 20px;
margin:10px auto;
overflow: hidden;
box-sizing:border-box;
}
.ulStyle div{
line-height: 40px;
font-size: 16px;
}
.ulStyle li{
float: left;
width: calc(100%/6 - 10px);
margin-left: 1%;
margin-bottom: 10px;
padding: 9px 10px;
border: 1px solid #747474;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
list-style: none;
text-align: center;
}
.ulStyle li a:active {
background-color:#0064b6;
color: #fff;
}
.gettime{
background:#36a9ce;
}
</style>
js:serialNo是我的唯一键需要查日期;
var serialNo=$("#serialNo").val();
$.ajax({
url: Aexit.ctxPath + "/itemorder/time" ,
data:{ "num":22 , "serialNo": serialNo },
type: "POST",
dataType: "json", //表示返回值类型,不必须
success: function (data) {
var infoDom = "";
$.each(data.data.list, function (index,item) {
//获取当前时间
var curDate=new Date();
var cu=new Date(curDate).toLocaleString().replace(/\//g, "-");
//判断返回的时间是否小于当前时间
if(item <cu){
infoDom += "<li readOnly = \"readonly\" style='background: #ccc' value='" + item + " 00:00:00' class='no'>" + item + "上午" + "</li>";
infoDom += "<li readOnly = \"readonly\" style='background: #ccc' value='" + item + " 12:00:00' class='no'>" + item + "下午" + "</li>";
}else{
infoDom += "<li value='" + item + " 00:00:00' class='yes'>" + item + "上午" + "</li>";
infoDom += "<li value='" + item + " 12:00:00' class='yes'>" + item + "下午" + "</li>";
}
});
$(".ulStyle").append(infoDom);
$(".ulStyle li:eq(0)").hide();
$(".ulStyle li:eq(1)").hide();
$(".ulStyle li:eq(2)").hide();
$(".ulStyle li:eq(3)").hide();
$(".ulStyle li").click(function () {
var vv=$(this).attr("class");
if(vv=="yes"){
$(this).addClass("gettime");
$(this).siblings().removeClass("gettime");
var date = $(this).attr("value");
var dateo = new Date(date).toLocaleString().replace(/\//g, "-");
var start = dateo.substr(0, dateo.length - 8);
var endtime = $(".gettime").prev().attr("value");
var dateo1 = new Date(endtime).toLocaleString().replace(/\//g, "-");
var end = dateo1.substr(0, dateo1.length - 8);
$("#button").show().val("您已经选择" + start + ",作为窗口申报材料的时间!按照要求,该项目的现场验收时间自动确定为" + end + "。");
}else {
return false;
}
});
}
})
实现的页面:
点击某个日期下方会显示前半天的日期;灰色区域代表不能点击,是在获取的日期之前;