|
@@ -12,6 +12,8 @@
|
|
|
:disabledDate="disabledDate"
|
|
|
v-model="createDate"
|
|
|
:format="dateFormat"
|
|
|
+ @change="dateChange"
|
|
|
+ @calendarChange="dateCalendarChange"
|
|
|
:placeholder="['开始时间', '结束时间']" />
|
|
|
</a-form-item>
|
|
|
</a-form-item>
|
|
@@ -181,6 +183,7 @@ export default {
|
|
|
return data
|
|
|
})
|
|
|
},
|
|
|
+ selectPriceDate: '',
|
|
|
allocateTypeList: [], // 调拨类型
|
|
|
openModal: false, // 新增编辑 弹框
|
|
|
itemId: '' // 当前品牌id
|
|
@@ -188,8 +191,42 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
// 不可选日期
|
|
|
- disabledDate (date, dateStrings) {
|
|
|
- return date && date.valueOf() > Date.now()
|
|
|
+ disabledDate (current) {
|
|
|
+ const tYearVs = moment().subtract(2, 'years') // 两年前 负值
|
|
|
+ // 限制最多只能查一年区间的数据
|
|
|
+ if (this.selectPriceDate) {
|
|
|
+ const yearVs = moment(this.selectPriceDate, 'YYYY-MM-DD').subtract(1, 'years') // 去年 负值
|
|
|
+ const yearSVs = moment(this.selectPriceDate, 'YYYY-MM-DD').add(1, 'years') // 明年 正值
|
|
|
+ // 判断两个时间段是否相差m年 第二个参数指相差单位,第三个参数指是否返回浮点形式(小数)
|
|
|
+ // console.log(tYearVs.diff(yearVs, 'days'), '---------比小') // 负
|
|
|
+ // console.log(yearSVs.diff(moment(), 'days'), '---------比大') // 正
|
|
|
+ // const beginDate = tYearVs.diff(yearVs, 'days') > 0 ? yearVs : tYearVs
|
|
|
+ // const endDate = moment().diff(yearSVs, 'days') > 0 ? yearSVs : moment()
|
|
|
+ // return current && current.valueOf() > beginDate || current && current.valueOf() < endDate
|
|
|
+ // console.log(moment().diff(tYearVs, 'days'), '---------两年前和今天相差天数')
|
|
|
+ // console.log(moment().diff(yearVs, 'days'), '---------去年和今天相差天数')
|
|
|
+ const tDiffV = moment().diff(tYearVs, 'days') // 两年前和今天相差天数
|
|
|
+ const oDiffV = moment().diff(yearVs, 'days') // 去年和今天相差天数
|
|
|
+ // console.log(tDiffV, '+++相差比值', oDiffV)
|
|
|
+ const beginDate = tDiffV > oDiffV ? tYearVs : yearVs
|
|
|
+ const endDate = moment().diff(yearSVs, 'days') > 0 ? yearSVs : moment()
|
|
|
+ return current && current.valueOf() > beginDate.valueOf() || current && current.valueOf() < endDate.valueOf()
|
|
|
+ } else {
|
|
|
+ return current && current.valueOf() > Date.now() || current && current.valueOf() < tYearVs
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 日期 change
|
|
|
+ dateChange (date, dateStrings) {
|
|
|
+ this.selectPriceDate = ''
|
|
|
+ console.log('--------change', date, dateStrings)
|
|
|
+ // // 判断两个时间段是否相差m年 第二个参数指相差单位,第三个参数指是否返回浮点形式(小数)
|
|
|
+ // if (moment(dateStrings[0]).diff(moment(dateStrings[1]), 'years', true) > 1) {
|
|
|
+ // this.$message.error('仅支持导出最多3个月的数据,请先修改收取时间再进行导出!')
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ dateCalendarChange (date, dateStrings) {
|
|
|
+ console.log('--------calendar', date, dateStrings)
|
|
|
+ this.selectPriceDate = date[0]
|
|
|
},
|
|
|
// 重置
|
|
|
resetSearchForm () {
|