{ { -- 月-- } }
< el- form- item>
< el- date- picker
v- model= "monthRange"
type= "monthrange"
clearable
align= "right"
class = 'cellSize'
unlink- panels
range- separator= "-"
start- placeholder= "开始月份"
end- placeholder= "结束月份"
@change= "getData(2)"
: picker- options= "pickerOptions"
value- format= "yyyy-MM-dd" >
< / el- date- picker>
< / el- form- item>
{ { -- 周-- } }
< el- form- item>
< el- date- picker
v- model= "week_value"
type= "week"
{ { -- format= "yyyy 第 WW 周" -- } }
: format= "'yyyy 第' + cur_week + '周'"
@input= "Dayofweek"
value- format= "yyyy-MM-dd"
placeholder= "选择周"
: picker- options= "{ firstDayOfWeek: 6 }"
style= "width: 150px"
@change= "getData(1)" >
< / el- date- picker>
< / el- form- item>
transformTime ( date ) {
var dd = new Date ( date) ;
var y = dd. getFullYear ( ) ;
var m = dd. getMonth ( ) + 1 ;
var d = dd. getDate ( ) ;
m = m < 9 ? "0" + m : m;
d = d < 9 ? "0" + d : d;
return y + "-" + m + "-" + d;
} ,
setDate ( strDate ) {
var date = eval ( 'new Date(' + strDate. replace ( / \d+(?=-[^-]+$) / ,
function ( a ) { return parseInt ( a, 10 ) - 1 ; } ) . match ( / \d+ / g ) + ')' ) ;
return date;
} ,
GetMonday ( dd ) {
var date = new Date ( dd) ;
var week = new Date ( date) . getDay ( ) ;
var minus = week ? week - 1 : 6 ;
date. setDate ( date. getDate ( ) - minus) ;
var y = date. getFullYear ( ) ;
var m = date. getMonth ( ) + 1 ;
var d = date. getDate ( ) ;
return y + "-" + m + "-" + d;
} ,
GetSaturday ( dd ) {
var date = new Date ( dd) ;
var timestamp = new Date ( date) . getTime ( ) ;
var currentDay = new Date ( date) . getDay ( ) ;
var previousSaturdayTime;
if ( currentDay == 0 ) {
previousSaturdayTime = timestamp- 24 * 60 * 60 * 1000 ;
} else {
previousSaturdayTime = timestamp - ( currentDay + 1 ) * 24 * 60 * 60 * 1000 ;
}
var saturdayTime = new Date ( previousSaturdayTime) ;
let saturdayYear = saturdayTime. getFullYear ( ) ;
let saturdayMonth = saturdayTime. getMonth ( ) + 1 ;
let saturdayDay = saturdayTime. getDate ( ) ;
saturdayMonth = saturdayMonth >= 10 ? saturdayMonth : '0' + saturdayMonth;
saturdayDay = saturdayDay >= 10 ? saturdayDay : '0' + saturdayDay;
let lastSatDay = saturdayYear+ '-' + saturdayMonth+ '-' + saturdayDay;
return lastSatDay
} ,
Dayofweek ( ) {
let Saturday = this . GetSaturday ( this . week_value) ;
let curweek = this . getWeek ( Saturday) ;
this . cur_week = curweek;
} ,
getWeek ( dt ) {
let d1 = new Date ( dt) ;
let d2 = new Date ( dt) ;
d2. setMonth ( 0 ) ;
d2. setDate ( 1 ) ;
let rq = d1 - d2;
let days = Math. ceil ( rq / ( 24 * 60 * 60 * 1000 ) ) ;
let num = Math. ceil ( days / 7 ) ;
return num + 1 ;
} ,
dateToMs ( date ) {
let result = new Date ( date) . getTime ( ) ;
return result;
} ,
msToDate ( msec ) {
let datetime = new Date ( msec) ;
let year = datetime. getFullYear ( ) ;
let month = datetime. getMonth ( ) ;
let date = datetime. getDate ( ) ;
let hour = datetime. getHours ( ) ;
let minute = datetime. getMinutes ( ) ;
let second = datetime. getSeconds ( ) ;
let result1 = year +
'-' +
( ( month + 1 ) >= 10 ? ( month + 1 ) : '0' + ( month + 1 ) ) +
'-' +
( ( date + 1 ) < 10 ? '0' + date : date) +
' ' +
( ( hour + 1 ) < 10 ? '0' + hour : hour) +
':' +
( ( minute + 1 ) < 10 ? '0' + minute : minute) +
':' +
( ( second + 1 ) < 10 ? '0' + second : second) ;
let result2 = year +
'-' +
( ( month + 1 ) >= 10 ? ( month + 1 ) : '0' + ( month + 1 ) ) +
'-' +
( ( date + 1 ) < 10 ? '0' + date : date) ;
let result = {
hasTime : result1,
withoutTime : result2
} ;
return result;
} ,
getLastDay ( year, month ) {
var new_year = year;
var new_month = month++ ;
if ( month> 12 ) {
new_month -= 12 ;
new_year++ ;
}
var new_date = new Date ( new_year, new_month, 1 ) ;
return ( new Date ( new_date. getTime ( ) - 1000 * 60 * 60 * 24 ) ) . getDate ( ) ;
} ,
function addDate ( date, days ) {
var d = new Date ( date) ;
d. setDate ( d. getDate ( ) + days) ;
var m = d. getMonth ( ) + 1 ;
m = m < 10 ? '0' + m : m;
var dd = d. getDate ( ) ;
dd = dd < 10 ? '0' + dd : dd;
return d. getFullYear ( ) + '-' + m + '-' + dd;
}
function getDays ( strDateBegin, strDateEnd ) {
var Date_start = strDateBegin. split ( "-" ) ;
var Date_end = strDateEnd. split ( "-" ) ;
var strDateS = new Date ( Date_start[ 0 ] , Date_start[ 1 ] , Date_start[ 2 ] ) . getTime ( ) ;
var strDateE = new Date ( Date_end[ 0 ] , Date_end[ 1 ] , Date_end[ 2 ] ) . getTime ( ) ;
iDays = parseInt ( ( strDateE - strDateS) / 86400000 ) ;
return iDays ;
}
function timeStamp ( StatusMinute ) {
var day = parseInt ( StatusMinute / 60 / 24 ) ;
var hour = parseInt ( StatusMinute / 60 % 24 ) ;
var min = parseInt ( StatusMinute % 60 ) ;
StatusMinute = "" ;
if ( day > 0 ) {
StatusMinute = day + "d" ;
}
if ( hour > 0 ) {
StatusMinute += hour + "h" ;
}
if ( min > 0 ) {
StatusMinute += parseFloat ( min) + "m" ;
}
return StatusMinute == "" ? "0分钟" : StatusMinute;
}
getData ( flag ) {
var that = this
if ( flag == 1 ) {
var date = that. week_value;
var dd = that. setDate ( date) ;
var date_begin = that. GetSaturday ( dd) ;
var d_end = that. setDate ( date_begin) ;
d_end = new Date ( ( d_end/ 1000 + ( 86400 * 6 ) ) * 1000 ) ;
var date_end = that. transformTime ( d_end) ;
}
else {
var date = that. monthRange;
var date1 = date[ 0 ] ;
var date2 = date[ 1 ] ;
var d_begin = that. dateToMs ( date1) ;
var date_begin = that. msToDate ( d_begin) . withoutTime;
var datetime = new Date ( date2) ;
var lastday = new Date ( datetime. getFullYear ( ) , datetime. getMonth ( ) + 1 , 0 )
var d_end = that. dateToMs ( lastday) ;
var date_end = that. msToDate ( d_end) . withoutTime;
}
$. ajax ( {
url : "/admin/report/getProofingData" ,
type : "GET" ,
data : {
date_begin : date_begin,
date_end : date_end,
} ,
dataType : 'json' ,
success : function ( res ) {
if ( res. code == 100 ) {
} else {
}
}
} ) ;
} ,
function isNull ( str ) {
if ( str == "" ) return true ;
var regu = "^[ ]+$" ;
var re = new RegExp ( regu) ;
return re. test ( str)
}
function dateAddDays ( dataStr, dayCount, flag= 1 ) {
var strdate = dataStr;
var isdate = new Date ( strdate. replace ( / - / g , "/" ) ) ;
if ( flag == 1 ) {
isdate = new Date ( ( isdate/ 1000 + ( 86400 * dayCount) ) * 1000 ) ;
}
else {
isdate = new Date ( ( isdate/ 1000 - ( 86400 * dayCount) ) * 1000 ) ;
}
var year = isdate. getFullYear ( ) ;
var month = isdate. getMonth ( ) + 1 ;
if ( month < 10 ) month = "0" + month;
var date = isdate. getDate ( ) ;
if ( date < 10 ) date = "0" + date;
var newDate = year + "-" + month + "-" + date;
return newDate;
}
function get_curdate ( ) {
var date = new Date ( ) ;
var year = date. getFullYear ( ) ;
var month = date. getMonth ( ) + 1 ;
var day = date. getDate ( ) ;
if ( month >= 10 ) {
if ( day >= 10 ) {
var cur_date = year+ "-" + month+ "-" + day;
} else {
var cur_date = year+ "-" + month+ "-0" + day;
}
} else {
if ( day >= 10 ) {
var cur_date = year+ "-0" + month+ "-" + day;
} else {
var cur_date = year+ "-0" + month+ "-0" + day;
}
}
return cur_date;
}
function timeStamp ( StatusMinute ) {
var day = parseInt ( StatusMinute / 60 / 24 ) ;
var hour = parseInt ( StatusMinute / 60 % 24 ) ;
var min = parseInt ( StatusMinute % 60 ) ;
StatusMinute = "" ;
if ( day > 0 ) {
StatusMinute = day + "d" ;
}
if ( hour > 0 ) {
StatusMinute += hour + "h" ;
}
if ( min > 0 ) {
StatusMinute += parseFloat ( min) + "m" ;
}
return StatusMinute == "" ? "0分钟" : StatusMinute;
}
function isNull ( str ) {
if ( str == "" ) return true ;
var regu = "^[ ]+$" ;
var re = new RegExp ( regu) ;
return re. test ( str)
}
getFirstDay ( date ) {
var y = new Date ( date) . getFullYear ( ) ;
var m = new Date ( date) . getMonth ( ) + 1 ;
var d = "01" ;
m = m < 10 ? "0" + m : m;
return [ y, m, d] . join ( "-" ) ;
} ,
getLastDay ( date ) {
var y = new Date ( date) . getFullYear ( ) ;
var m = new Date ( date) . getMonth ( ) + 1 ;
var d = new Date ( y, m, 0 ) . getDate ( ) ;
m = m < 10 ? "0" + m : m;
d = d < 10 ? "0" + d : d;
return [ y, m, d] . join ( "-" ) ;
} ,