const ar = async (time) => {
try {
let {data} = await axios({
method: 'get',
url: '/gettime?time=' + time,
});
console.log(data)
} catch (error) {
console.log(error)
}
}
const getlastmonth = () => {
var nowdays = new Date();
var year = nowdays.getFullYear();
var month = nowdays.getMonth();
if(month==0){
month=12;
year=year-1;
}
if (month < 10) {
month = "0" + month;
}
var myDate = new Date(year, month, 0);
var lastDay = year + "-" + month + "-" + myDate.getDate()
return lastDay
}
var fna = 0
var boe = 0
const xuanr = (data) => {
document.querySelector('#der').innerHTML = ''
let checktime=0;
data.map((i)=>{
let d = new Date(i.time)
let times = (d.getMonth() + 1) + '/' + d.getDate()
if(document.getElementById(`${i.id}`)){
let fa = (parseInt(i.fan) - parseInt(fna)).toString()
let bo = (parseInt(i.post) - parseInt(boe)).toString()
if (fa < 0){ var facon = `
${fa}
` } else { var facon = `+${fa}
` }
if (bo < 0){ var faconer = `${bo}
` } else { var faconer = `+${bo}
` }
let der = document.getElementById(`${i.id}`).parentNode
if(d.getDate()!=checktime+1){
checktime=d.getDate();
der.innerHTML += `
${i.post}
${faconer}
${i.fan}
${facon}
`
}else{
checktime++;
der.innerHTML += `
${i.post}
${faconer}
${i.fan}
${facon}
`
}
fna = i.fan
boe = i.post
}else{
checktime=1;
var date = new Date(i.time);
date_value=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
if(getlastmonth() != date_value){
let fa = (parseInt(i.fan) - parseInt(fna)).toString()
let bo = (parseInt(i.post) - parseInt(boe)).toString()
if (fa < 0){ var facon = `${fa}
` } else { var facon = `+${fa}
` }
if (bo < 0){ var faconer = `${bo}
` } else { var faconer = `+${bo}
` }
document.querySelector('#der').innerHTML += `
${i.name}
${i.id}
${i.post}
${faconer}
${i.fan}
${facon}
`
}
fna = i.fan
boe = i.post
}
// boe = i.post
})
let checkdd=0;
for(let der = 0; der < (data.length/45); der ++){
let dd = new Date(data[der].time)
let times = (dd.getMonth() + 1) + '/' + dd.getDate()
let timeser = dd.getFullYear() + '-' + (dd.getMonth() + 1) + '-' + dd.getDate()
if (timeser != getlastmonth()) {
if(dd.getDate()!=checkdd+1){
times = (dd.getMonth()+1) + '/' +(dd.getDate()-1)
document.querySelector('.tim').innerHTML += `${times}
`
times = (dd.getMonth()+1) + '/' +(dd.getDate())
document.querySelector('.tim').innerHTML += `${times}
`
checkdd=dd.getDate();
}else{
checkdd++;
document.querySelector('.tim').innerHTML += `${times}
`
}
}
}
}
var fnaer = 0
var boeer = 0
const chaxun = (data, ad) => {
let checktime=0;
document.querySelector('#der').innerHTML = ''
data.map((i)=>{
let d = new Date(i.time)
let times = (d.getMonth() + 1) + '/' + d.getDate()
let dder = new Date(i.time)
let timeser = dder.getFullYear() + '/' + (dder.getMonth() + 1) + '/' + dder.getDate()
if(document.getElementById(`${i.id}`)){
let fa = (parseInt(i.fan) - parseInt(fnaer)).toString()
let bo = (parseInt(i.post) - parseInt(boeer)).toString()
if (fa < 0){ var facon = `${fa}
` } else { var facon = `+${fa}
` }
if (bo < 0){ var faconer = `${bo}
` } else { var faconer = `+${bo}
` }
let der = document.getElementById(`${i.id}`).parentNode
if(d.getDate()!=checktime+1){
checktime=d.getDate();
der.innerHTML += `
${i.post}
${faconer}
${i.fan}
${facon}
`
}else{
checktime++;
der.innerHTML += `
${i.post}
${faconer}
${i.fan}
${facon}
`
}
/*der.innerHTML += `
${i.post}
${faconer}
${i.fan}
${facon}
`*/
fnaer = i.fan
boeer = i.post
}else{
checktime=1;
var date = new Date(i.time);
date_value=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
if(getlastmonth() != date_value){
let fa = (parseInt(i.fan) - parseInt(fnaer)).toString()
let bo = (parseInt(i.post) - parseInt(boeer)).toString()
if (timeser == "2018/10/24") {
fa = 0
bo = 0
}
if (fa < 0){ var facon = `${fa}
` } else { var facon = `+${fa}
` }
if (bo < 0){ var faconer = `${bo}
` } else { var faconer = `+${bo}
` }
document.querySelector('#der').innerHTML += `
${i.name}
${i.id}
${i.post}
${faconer}
${i.fan}
${facon}
`
}
fnaer = i.fan
boeer = i.post
}
// boe = i.post
})
let checkdd=0;
for(let der = 0; der < (data.length/45); der ++){
let dd = new Date(data[der].time)
let times = (dd.getMonth() + 1) + '/' + dd.getDate()
let timeser = dd.getFullYear() + '-' + (dd.getMonth() + 1) + '-' + dd.getDate()
var nowdays = new Date();
var year = nowdays.getFullYear();
var month = nowdays.getMonth();
if(month==0){
month=12;
year=year-1;
}
if (month < 10) {
month = "0" + month;
}
var myDate = new Date(year, month, 0);
var lastDay = year + "-" + month + "-" + myDate.getDate()
//timeser渲染时
//lastDay上个月
if (document.querySelector('#search_begindate').value == dd.getFullYear() + '-' + (dd.getMonth() + 1)) {
if(dd.getDate()!=checkdd+1){
times = (dd.getMonth()+1) + '/' +(dd.getDate()-1)
document.querySelector('.tim').innerHTML += `${times}
`
times = (dd.getMonth()+1) + '/' +(dd.getDate())
document.querySelector('.tim').innerHTML += `${times}
`
checkdd=dd.getDate();
}else{
checkdd++;
document.querySelector('.tim').innerHTML += `${times}
`
}
//document.querySelector('.tim').innerHTML += `${times}
`
}
}
}
window.onload = async () => {
try {
let {data} = await axios({
method: 'get',
url: '/all',
});
xuanr(data)
} catch (error) {
}
}
const getyue = async () => {
try {
let yue = document.querySelector('#search_begindate').value
let {data} = await axios({
method: 'get',
url: `/getyue?time=${yue}&lasttime=${getlastmonth()}`,
});
document.querySelector('.tim').innerHTML = `#
id
日期
`
document.querySelector('#der').innerHTML = ''
chaxun(data, '1')
} catch (error) {
}
}
const gettimeer = async () => {
let a = document.querySelector('#datepicker').value
let b = document.querySelector('#datepickerer').value
try {
let url = '/setime?starttime=' + a + '&endtime=' + b
let {data} = await axios({
method: 'get',
url: url,
});
document.querySelector('#der').innerHTML = '数据加载中'
xuanr(data)
} catch (error) {
}
}