var table,form,layer,laydate,element;
var currentDate = new Date();
var tabList=[];
var month = currentDate.getMonth() + 1;//当前第几月
var year = currentDate.getFullYear();
var resultdataUserId;
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',
format: 'yyyy-MM',
btns:['now','confirm'], //选择框右下角显示的按钮 清除-现在-确定
value: formatCurrentMonth(), // 如果你想预设当前日期为选中状态
done: function (value, date) {//时间回调
console.log("date:", date);
localStorage.setItem("resultdataMakeMonth",value);
resultMonth=value;
init(date.year,date.month);
}
});
$("#month").val(localStorage.getItem("resultdataMakeMonth"));
resultMonth=localStorage.getItem("resultdataMakeMonth")
init(year,month)
setData()
});
//工程切换
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("resultdataMakeMonth").substring(0,4),localStorage.getItem("resultdataMakeMonth").substring(5,7)<10?localStorage.getItem("resultdataMakeMonth").substring(5,7).replace("0",""):localStorage.getItem("resultdataMakeMonth").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)
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("resultdataUserId"),proId:localStorage.getItem("resultProId"),makeMonth:localStorage.getItem("resultdataMakeMonth")
},
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}
${gtName}
${gtName}