var table,form,layer,laydate,element;
var currentDate = new Date();
var tabList=[];
var month = currentDate.getMonth() + 1;//当前第几月
var year = currentDate.getFullYear();
var resultUserId;
var resultProId;
var resultMonth;
layui.use(['form','layer','table','laydate','element'], function () {
table = layui.table;
form = layui.form;
layer = layui.layer;
laydate = layui.laydate;
element = layui.element;
// 渲染时间选择器
laydate.render({
elem:'#month', //指定元素 元素选择器
type:'month', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
trigger:'click',
min:firstDayStr(),
max:lastDayStr(),
format: 'yyyy-MM',
btns:['now','confirm'], //选择框右下角显示的按钮 清除-现在-确定
value: formatCurrentMonth(), // 如果你想预设当前日期为选中状态
done: function (value, date) {//时间回调
console.log("date:", date);
localStorage.setItem("resultMakeMonth",value);
resultMonth=value;
init(date.year,date.month);
}
});
$("#month").val(localStorage.getItem("resultMakeMonth"));
resultMonth=localStorage.getItem("resultMakeMonth")
setData()
init(year,month)
});
function firstDayStr(){
var today = new Date();
var thisMonth = today.getMonth(); // 获取当前月份(从0开始)
var year = today.getFullYear(); // 获取当前年份
// 当月的第一天
var firstDay = new Date(year, thisMonth-1, 2);
var firstDayString = firstDay.toISOString().slice(0, 10); // 转换为YYYY-MM-DD格式
// 当月的最后一天
var lastDay = new Date(year, thisMonth + 1, 1);
var lastDayString = lastDay.toISOString().slice(0, 7); // 转换为YYYY-MM-DD格式
console.log("First day of this month: " + firstDayString);
return firstDayString;
}
function lastDayStr(){
var today = new Date();
var thisMonth = today.getMonth(); // 获取当前月份(从0开始)
var year = today.getFullYear(); // 获取当前年份
// 当月的第一天
var firstDay = new Date(year, thisMonth, 1);
var firstDayString = firstDay.toISOString().slice(0, 7); // 转换为YYYY-MM-DD格式
// 当月的最后一天
var lastDay = new Date();
var lastDayString = lastDay.toISOString().slice(0, 10); // 转换为YYYY-MM-DD格式
console.log("Last day of this month: " + lastDayString);
return lastDayString;
}
function currMonth(){
var lastDay = new Date();
var lastDayString = lastDay.toISOString().slice(0, 7); // 转换为YYYY-MM-DD格式
console.log("Last day of this month: " + lastDayString);
return lastDayString;
}
//工程切换
function projectTab(event,proId){
resultProId=proId;
localStorage.setItem("resultProId",resultProId);
console.log(resultProId,'resultProId')
//修改所点工程样式
$("#projects>div").removeClass("projectsStyle");
$(event).addClass("projectsStyle")
getView();
getSpecial(localStorage.getItem("resultMakeMonth").substring(0,4),localStorage.getItem("resultMakeMonth").substring(5,7)<10?localStorage.getItem("resultMakeMonth").substring(5,7).replace("0",""):localStorage.getItem("resultMakeMonth").substring(5,7));
}
function formatCurrentMonth() {
var date = new Date();
var month = date.getMonth() + 1; // 注意月份是从0开始的,所以加1
return date.getFullYear() + '-' + (month < 10 ? '0' + month : month);
}
/**
* 初始化数据
*/
function init(chosenYear,chosenMonth){
layui.use(['table'], function () {
getTab(chosenMonth)
if(localStorage.getItem("resultMakeMonth")!=currMonth()){
$("#normalInspectionUpload").css("display","none")
getViewc();
}else{
$("#normalInspectionUpload").css("display","")
getView();
}
getSpecial(chosenYear,chosenMonth)
})
}
function getSpecial(chosenYear,chosenMonth){
let table = layui.table;
let daysInMonth = new Date(chosenYear, chosenMonth, 0).getDate();
console.log(daysInMonth)
let tableData = []
$.ajax({//id获取详情打开弹窗传值子页面
type: 'post',
url: PATH_URL + "/makeInfo/getSpecialData",
dataType: 'json',
async:false,
data: {
userId: localStorage.getItem("resultUserId"),proId:localStorage.getItem("resultProId"),makeMonth:localStorage.getItem("resultMakeMonth")
},
success: function (data) {
console.log(data,"resultSpecial");
var isWorkData=[];
$.each(data.data,function(index,item){
isWorkData.push(item.makeTime)
})
var isWork={};
isWork.isWork=isWorkData;
tableData.push(isWork);
},
error:function(e){
}
})
let cols = []
for (let k = 1; k <= daysInMonth; k++) {
let str = chosenMonth+'.'+k;
let obj = {field:'isWork', title: str,align: 'center',width:70,
templet: function(d){
if(d.isWork.includes(d.LAY_COL.title)){
return ` `
}else{
return `
${gtName} `
if("1"==viewList1[i].state||"1"==viewList1[i].makeType){
html +=`
`
}
html +=`
`
html += `
`
html += `
${gtName}
`
if("1"==viewList2[i].state||"1"==viewList2[i].makeType){
html +=`
`
}
html +=`
`
html += `
`
html += `
${gtName}
${gtName}
${gtName}
${gtName}