yn_hxy_web/hxy-web/js/wireManager/attendance/attendanceDetail.js

224 lines
7.0 KiB
JavaScript
Raw Normal View History

2024-07-26 18:15:22 +08:00
var table,form,layer,laydate,element;
var currentDate = new Date();
var tabList=[];
var month = currentDate.getMonth() + 1;//当前第几月
var year = currentDate.getFullYear();
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)
init(date.year,date.month);
}
});
function formatCurrentMonth() {
var date = new Date();
var month = date.getMonth() + 1; // 注意月份是从0开始的所以加1
return date.getFullYear() + '-' + (month < 10 ? '0' + month : month);
}
//监听Tab切换以改变地址hash值
2024-08-16 09:20:11 +08:00
// element.on('tab(projectTab)', function(data){
// console.log(data)
// console.log(tabList[data.index])
// // tabIndex = data.index;
// getView()
// });
2024-07-26 18:15:22 +08:00
});
2024-08-16 09:20:11 +08:00
function setData(data){
$("#username").text(data.data.userName);
$("#tel").text(data.data.tel);
$("#allMake").text(data.data.allMake);
$("#oneMake").text(data.data.oneMake);
$("#twoMake").text(data.data.twoMake);
$("#special").text(data.data.special);
$("#makeMonth").val(data.data.makeMonth);
getView(data)
}
2024-07-26 18:15:22 +08:00
/**
* 初始化数据
*/
function init(chosenYear,chosenMonth){
layui.use(['table'], function () {
let table = layui.table;
let daysInMonth = new Date(chosenYear, chosenMonth, 0).getDate();
console.log(daysInMonth)
let tableData = [{isWork:['7.1','7.3','7.6','7.8']}]
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 `<i class="layui-icon" style="color: red;">&#xe605;</i> `
}else{
return `<apan></apan>`
}
}}
cols.push(obj)
}
table.render({
elem: '#isWorkList',
// url: "/sys/achievement",
// where: obj,
skin: 'line', // 表格样式
cols: [cols],
data: tableData
});
2024-08-16 09:20:11 +08:00
// getTab(chosenMonth)
2024-07-26 18:15:22 +08:00
})
}
2024-08-16 09:20:11 +08:00
// function getTab(chosenMonth){
// console.log(chosenMonth)
// tabList = [{id:'1',projectName:'xxx工程'},{id:'2',projectName:'xxx工程'},{id:'3',projectName:'xxx工程'},{id:'4',projectName:'xxx工程'}]
// // projectList
// $("#projectList").html('')
// let html = ``
// for (let k = 0; k < tabList.length; k++) {
// if(k==0){
// html+= '<li class="layui-this" style="margin-left:20px;">'+ tabList[0].projectName +'</li>';
// }else{
// html+= '<li>'+ tabList[k].projectName +'</li>';
// }
// }
// $("#projectList").append(html);
// getView()
// }
2024-07-26 18:15:22 +08:00
2024-08-16 09:20:11 +08:00
function getView(data){
var oneMakeList = data.data.oneMakeList;
2024-07-26 18:15:22 +08:00
$("#firstViewBox").html('');
let html1 = ``;
2024-08-16 09:20:11 +08:00
for (let i = 0;i < oneMakeList.length;i++) {
var color;
var proNameHtml;
var height;
var imgHeight;
if(oneMakeList[i].makeType == "0"){
//巡视计划内
color = "#52C1F5";
proNameHtml = ""
height = "220px"
imgHeight = "210px";
}else{
//巡视计划外
color = "#FF9900";
proNameHtml = `
<div class="viewFooter">
<i class="layui-icon">&#xe637;</i>
${ oneMakeList[i].proName }
</div>
`;
height = "196px";
imgHeight = "186px";
}
2024-07-26 18:15:22 +08:00
html1+= `<div class="viewBox">
2024-08-16 09:20:11 +08:00
<div class="viewHeader" style="background-color: ${color};">
2024-07-26 18:15:22 +08:00
<img src="../../../image/dataIcon3.png" alt="">
2024-08-16 09:20:11 +08:00
<span>${oneMakeList[i].gtName}</span>
2024-07-26 18:15:22 +08:00
</div>
2024-08-16 09:20:11 +08:00
<div class="viewContent" style="height: ${ height }">
<img src="../../../image/viewImg.jpg" style="height: ${ imgHeight }" alt="">
2024-07-26 18:15:22 +08:00
</div>
<div class="viewFooter">
<i class="layui-icon">&#xe637;</i>
2024-03-15
</div>
2024-08-16 09:20:11 +08:00
${ proNameHtml }
2024-07-26 18:15:22 +08:00
</div>`;
}
$("#firstViewBox").append(html1);
2024-08-16 09:20:11 +08:00
var twoMakeList = data.data.twoMakeList;
2024-07-26 18:15:22 +08:00
$("#secondViewBox").html('');
let html2 = ``;
2024-08-16 09:20:11 +08:00
for (let i = 0;i < twoMakeList.length;i++) {
var color;
var proNameHtml;
var height;
var imgHeight;
if(oneMakeList[i].makeType == "0"){
//巡视计划内
color = "#52C1F5";
proNameHtml = "";
height = "220px";
imgHeight = "210px";
}else{
//巡视计划外
color = "#FF9900";
proNameHtml = `
<div class="viewFooter">
<i class="layui-icon">&#xe637;</i>
${ twoMakeList[i].proName }
</div>
`;
height = "196px";
imgHeight = "186px";
}
2024-07-26 18:15:22 +08:00
html2+= `<div class="viewBox">
2024-08-16 09:20:11 +08:00
<div class="viewHeader" style="background-color: ${color};">
2024-07-26 18:15:22 +08:00
<img src="../../../image/dataIcon3.png" alt="">
2024-08-16 09:20:11 +08:00
<span>${twoMakeList[i].gtName}</span>
2024-07-26 18:15:22 +08:00
</div>
2024-08-16 09:20:11 +08:00
<div class="viewContent" style="height: ${ height }">
<img src="../../../image/viewImg.jpg" style="height: ${ imgHeight }" alt="">
2024-07-26 18:15:22 +08:00
</div>
<div class="viewFooter">
<i class="layui-icon">&#xe637;</i>
2024-03-15
</div>
2024-08-16 09:20:11 +08:00
${ proNameHtml }
2024-07-26 18:15:22 +08:00
</div>`;
}
$("#secondViewBox").append(html2);
2024-08-16 09:20:11 +08:00
spMakeList = data.data.spMakeList;
2024-07-26 18:15:22 +08:00
$("#specialViewBox").html('');
let html3 = ``;
2024-08-16 09:20:11 +08:00
for (let i = 0;i < spMakeList.length;i++) {
var color;
var proNameHtml;
var height;
var imgHeight;
html2+= `<div class="viewBox">
<div class="viewHeader" style="background-color: #73A0FA;">
2024-07-26 18:15:22 +08:00
<img src="../../../image/dataIcon3.png" alt="">
2024-08-16 09:20:11 +08:00
<span>${spMakeList[i].gtName}</span>
2024-07-26 18:15:22 +08:00
</div>
2024-08-16 09:20:11 +08:00
<div class="viewContent" style="height: 220px">
<img src="../../../image/viewImg.jpg" style="height: 210px" alt="">
2024-07-26 18:15:22 +08:00
</div>
<div class="viewFooter">
<i class="layui-icon">&#xe637;</i>
2024-03-15
</div>
2024-08-16 09:20:11 +08:00
${ proNameHtml }
2024-07-26 18:15:22 +08:00
</div>`;
}
$("#specialViewBox").append(html3);
}