|
@@ -21,12 +21,15 @@ const conf = {
|
|
|
visitList:[],
|
|
|
tableData: [],
|
|
|
curDate: '',
|
|
|
+ fromDate:'',
|
|
|
+ toDate:'',
|
|
|
calendarConfig: {
|
|
|
- theme: 'elegant',
|
|
|
- // showHolidays: true,
|
|
|
- // emphasisWeek: true,
|
|
|
- // chooseAreaMode: true
|
|
|
- defaultDate: formatDate(new Date()),
|
|
|
+ theme: 'default',
|
|
|
+ showHolidays: true,
|
|
|
+ emphasisWeek: true,
|
|
|
+ chooseAreaMode: false,
|
|
|
+ autoChoosedWhenJump: true,
|
|
|
+ defaultDate: formatDate(new Date())
|
|
|
// autoChoosedWhenJump: true
|
|
|
},
|
|
|
actionBtn: [
|
|
@@ -102,12 +105,19 @@ const conf = {
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
+ initData(){
|
|
|
+ let curDate = formatDate(new Date());
|
|
|
+ let fromDate = curDate.substr(0,8)+ "01"
|
|
|
+ let toDate = curDate.substr(0,8)+ "31"
|
|
|
+ this.setData( {curDate, fromDate, toDate})
|
|
|
+ },
|
|
|
afterTapDate(e) {
|
|
|
let curDate = object2Date( e.detail );
|
|
|
this.setData({curDate});
|
|
|
this.filterData()
|
|
|
},
|
|
|
onShow: function(){
|
|
|
+ this.initData();
|
|
|
app.checkLogin(res=>{
|
|
|
if( !res.userId ){
|
|
|
wx.navigateTo({
|
|
@@ -120,6 +130,7 @@ const conf = {
|
|
|
},
|
|
|
filterData(){
|
|
|
let {curDate, outList, visitList} = this.data;
|
|
|
+
|
|
|
let allList = outList.map( item=>{
|
|
|
item.isOut= true
|
|
|
return item;
|
|
@@ -131,7 +142,7 @@ const conf = {
|
|
|
tableData.push( allList[i] );
|
|
|
}
|
|
|
}
|
|
|
- console.log("tableData", curDate, allList, tableData)
|
|
|
+ console.log("filterData", curDate, tableData)
|
|
|
this.setData({tableData})
|
|
|
},
|
|
|
gotoDetail( e ){
|
|
@@ -147,9 +158,7 @@ const conf = {
|
|
|
}
|
|
|
},
|
|
|
loadData(){
|
|
|
- let curDate = this.data.calendarConfig.defaultDate;
|
|
|
- let fromDate = curDate.substr(0,8)+ "01"
|
|
|
- let toDate = curDate.substr(0,8)+ "31"
|
|
|
+ let {fromDate, toDate} = this.data;
|
|
|
app.formPost("User.loadData", {fromDate, toDate}).then( res=>{
|
|
|
if( res.code == 200){
|
|
|
let outList = res.data.outList||[];
|
|
@@ -170,8 +179,8 @@ const conf = {
|
|
|
let {fromDate,toDate} = item;
|
|
|
if( toDate < fromDate) continue;
|
|
|
while( fromDate <= toDate){
|
|
|
- dateMap[fromDate] = 1
|
|
|
- fromDate = util.nextDate( fromDate);
|
|
|
+ dateMap[fromDate] = 1;
|
|
|
+ fromDate = util.nextDate(fromDate);
|
|
|
}
|
|
|
}
|
|
|
//
|
|
@@ -179,28 +188,36 @@ const conf = {
|
|
|
let item = visitList[i];
|
|
|
let {fromDate,toDate} = item;
|
|
|
if( toDate < fromDate) continue;
|
|
|
- while( fromDate <= toDate){
|
|
|
- dateMap[fromDate] = dateMap[fromDate]?3:2
|
|
|
- fromDate = util.nextDate( fromDate);
|
|
|
+ let tempDate = fromDate
|
|
|
+ while( tempDate <= toDate){
|
|
|
+ let curNum = dateMap[tempDate]||0;
|
|
|
+ if( curNum == 1 ){
|
|
|
+ dateMap[tempDate] = 3;
|
|
|
+ } else if( !curNum ){
|
|
|
+ dateMap[tempDate] = 2
|
|
|
+ }
|
|
|
+ tempDate = util.nextDate( tempDate );
|
|
|
}
|
|
|
}
|
|
|
var dates = [];
|
|
|
for( let date in dateMap ){
|
|
|
let d = new Date(date);
|
|
|
let item = {year: d.getFullYear(), month: d.getMonth()+1, date: d.getDate()};
|
|
|
- switch( dateMap[date]){
|
|
|
+ console.log("mark", date, dateMap[date])
|
|
|
+ switch( dateMap[date] ){
|
|
|
case 1:
|
|
|
item.todoText = "出";
|
|
|
+ item.dotColor = "red"
|
|
|
break;
|
|
|
case 2:
|
|
|
item.todoText = "临";
|
|
|
+ item.dotColor = "green"
|
|
|
break;
|
|
|
default:
|
|
|
item.todoText = "临&出";
|
|
|
}
|
|
|
dates.push( item );
|
|
|
}
|
|
|
- console.log("dates", dates );
|
|
|
calendar.setTodos({
|
|
|
showLabelAlways: true,
|
|
|
dates
|
|
@@ -208,6 +225,11 @@ const conf = {
|
|
|
},
|
|
|
whenChangeMonth(e) {
|
|
|
console.log('whenChangeMonth', e.detail)
|
|
|
+ let {year, month} = e.detail.next;
|
|
|
+ let fromDate = object2Date({year, month:month, date:1})
|
|
|
+ let toDate = object2Date({year, month:month, date:31})
|
|
|
+ this.setData({fromDate, toDate})
|
|
|
+ this.loadData()
|
|
|
},
|
|
|
whenChangeWeek(e) {
|
|
|
console.log('whenChangeWeek', e.detail)
|