|
@@ -1,4 +1,5 @@
|
|
|
// pages/Components/selectDate/selectDate.js
|
|
|
+const util = require('../../../utils/util')
|
|
|
Component({
|
|
|
lifetimes: {
|
|
|
attached: function () {
|
|
@@ -6,9 +7,14 @@ Component({
|
|
|
const year = date.getFullYear()
|
|
|
const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
|
|
const day = date.getDate() + 1 < 10 ? '0' + date.getDate() : date.getDate()
|
|
|
+
|
|
|
+ let now = new Date();
|
|
|
+ let edd = new Date(now.setDate(now.getDate() + 7));
|
|
|
+ let ed = util.formatTime(edd).substring(0, 10).replace(/\//g, '-')
|
|
|
this.setData({
|
|
|
endDate: year + '-' + month + '-' + day,
|
|
|
- lastDate: year + '-' + month + '-' + day
|
|
|
+ lastDate: year + '-' + month + '-' + day,
|
|
|
+ initChangeDate: ed
|
|
|
})
|
|
|
}
|
|
|
},
|
|
@@ -65,9 +71,9 @@ Component({
|
|
|
},
|
|
|
|
|
|
bindEndDateChange: function (e) {
|
|
|
- if (e.detail.value > this.data.endDate) {
|
|
|
+ if (e.detail.value > this.data.initChangeDate) {
|
|
|
this.setData({
|
|
|
- endDate: this.data.lastDate
|
|
|
+ endDate: this.data.initChangeDate
|
|
|
})
|
|
|
} else {
|
|
|
this.setData({
|
|
@@ -79,18 +85,20 @@ Component({
|
|
|
resetDate: function () {
|
|
|
this.setData({
|
|
|
beginDate: this.data.initDate,
|
|
|
- endDate: this.data.lastDate,
|
|
|
+ endDate: this.data.initChangeDate,
|
|
|
typeIndex: 0
|
|
|
})
|
|
|
const date = new Date()
|
|
|
- const dateArr = [date.getFullYear()+"-01"+"-01", this.data.lastDate];
|
|
|
- this.triggerEvent("getDates", dateArr);
|
|
|
+ const dateArr = [date.getFullYear()+"-01"+"-01", this.data.initChangeDate];
|
|
|
+ const typeIndex = this.data.typeIndex
|
|
|
+ this.triggerEvent("getDates", {dateArr,typeIndex});
|
|
|
this.showSelect()
|
|
|
},
|
|
|
|
|
|
submitDate: function () {
|
|
|
const dateArr = [this.data.beginDate, this.data.endDate];
|
|
|
- this.triggerEvent("getDates", dateArr);
|
|
|
+ const typeIndex = this.data.typeIndex
|
|
|
+ this.triggerEvent("getDates", {dateArr,typeIndex});
|
|
|
this.showSelect()
|
|
|
},
|
|
|
|
|
@@ -133,13 +141,7 @@ Component({
|
|
|
|
|
|
bindPickerChange:function(e){
|
|
|
const typeIndex = e.detail.value
|
|
|
- const name = this.data.typeArr[typeIndex]
|
|
|
- const str = {
|
|
|
- typeIndex,
|
|
|
- name
|
|
|
- }
|
|
|
this.setData({
|
|
|
- str,
|
|
|
typeIndex
|
|
|
})
|
|
|
// this.triggerEvent("changeType",str)
|