|
@@ -1,46 +1,58 @@
|
|
<template>
|
|
<template>
|
|
- <view v-if="isShow">
|
|
|
|
- <view class="date-picker-mask" bubble='true' @click="hide" :class="[isOpen?'show-date-picker-mask':'hide-date-picekr-mask']"
|
|
|
|
- :style="{backgroundColor:maskColor}"></view>
|
|
|
|
- <view class="date-picker-container" @click.stop="handleClick" :class="[isOpen?'show-date-picker':'hide-date-picekr']">
|
|
|
|
|
|
+ <view>
|
|
|
|
+ <view v-if="isShow">
|
|
|
|
+ <view class="date-picker-mask" bubble='true' @click="hide" :class="[isOpen?'show-date-picker-mask':'hide-date-picekr-mask']"
|
|
|
|
+ :style="{backgroundColor:maskColor}"></view>
|
|
|
|
+ <view class="date-picker-container" @click.stop="handleClick" :class="[isOpen?'show-date-picker':'hide-date-picekr']">
|
|
|
|
|
|
- <!-- 操作 -->
|
|
|
|
- <view class="date-picker-title row between-center">
|
|
|
|
- <text class="date-picker-cancel" @click="hide">取消</text>
|
|
|
|
- <text class="date-picker-confirm" @click="dateConfirm">确定</text>
|
|
|
|
|
|
+ <!-- 操作 -->
|
|
|
|
+ <view class="date-picker-title row between-center">
|
|
|
|
+ <text class="date-picker-cancel" @click="hide">取消</text>
|
|
|
|
+ <text class="date-picker-confirm" @click="dateConfirm">确定</text>
|
|
|
|
+ </view>
|
|
|
|
+ <!-- 内容 -->
|
|
|
|
+ <picker-view class="date-picker-box" v-if="visible" :indicator-style="indicatorStyle" :value="value" @change="bindChange">
|
|
|
|
+ <picker-view-column class="center">
|
|
|
|
+ <view class="date-picker-item center" v-for="(item,index) in years" :key="index">
|
|
|
|
+ <text >{{item}}</text>
|
|
|
|
+ </view>
|
|
|
|
+ </picker-view-column>
|
|
|
|
+ <picker-view-column>
|
|
|
|
+ <view class="date-picker-item center" v-for="(item,index) in months" :key="index">
|
|
|
|
+ <text>{{item}}</text>
|
|
|
|
+ </view>
|
|
|
|
+ </picker-view-column>
|
|
|
|
+ <picker-view-column>
|
|
|
|
+ <view class="date-picker-item center" v-for="(item,index) in days" :key="index">
|
|
|
|
+ <text>{{item}}</text>
|
|
|
|
+ </view>
|
|
|
|
+ </picker-view-column>
|
|
|
|
+ </picker-view>
|
|
</view>
|
|
</view>
|
|
- <!-- 内容 -->
|
|
|
|
- <picker-view class="date-picker-box" v-if="visible" :indicator-style="indicatorStyle" :value="value" @change="bindChange">
|
|
|
|
- <picker-view-column class="center">
|
|
|
|
- <view class="date-picker-item center" v-for="(item,index) in years" :key="index">
|
|
|
|
- <text v-if='item!="长期"'>{{item}}年</text>
|
|
|
|
- <text v-else>{{item}}</text>
|
|
|
|
- </view>
|
|
|
|
- </picker-view-column>
|
|
|
|
- <picker-view-column>
|
|
|
|
- <view class="date-picker-item center" v-for="(item,index) in months" :key="index">
|
|
|
|
- <text v-if="item!=''">{{item}}月</text>
|
|
|
|
- <text v-else>{{item}}</text>
|
|
|
|
- </view>
|
|
|
|
- </picker-view-column>
|
|
|
|
- <picker-view-column>
|
|
|
|
- <view class="date-picker-item center" v-for="(item,index) in days" :key="index">
|
|
|
|
-
|
|
|
|
- <text v-if="item!=''">{{item}}日</text>
|
|
|
|
- <text v-else>{{item}}</text>
|
|
|
|
- </view>
|
|
|
|
- </picker-view-column>
|
|
|
|
- </picker-view>
|
|
|
|
-
|
|
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+ var that
|
|
|
|
+ /**
|
|
|
|
+ * 日期控件
|
|
|
|
+ * @property {String} maskColor 模态框背景色
|
|
|
|
+ * @property {String,Number} checkYear 控件打开默认选中的年份(未传值或传空字符串默认选中的年份为当年)
|
|
|
|
+ * @property {String,Number} checkMonth 控件打开默认选中的月份(未传值或传空字符串默认选中的年份为当月)
|
|
|
|
+ * @property {String,Number} checkDay 控件打开默认选中的日期(未传值或传空字符串默认选中的年份为当日)
|
|
|
|
+ * @property {String,Number} startYear 开始年份,默认为1940
|
|
|
|
+ * @property {String,Number} futureYear 终止年份,今年向后多少年,可选的最晚年份(截止日期未传时生效)
|
|
|
|
+ * @property {Boolean} periodOfValidity = [true | false] 是否是有效期(开启之后选择今天及之前的日期提示日期已过期)
|
|
|
|
+ * @property {Boolean} isShow = [true | false] 开启|关闭
|
|
|
|
+ * @property {String} overdueContent 开启periodOfValidity之后,选择今天及之前的日期提示日期已过期的内容文字
|
|
|
|
+ * @property {Object} endDate 截止日期,可选的最晚日期
|
|
|
|
+ * @property {String,Number} dateStatus 日期类型,默认0没有长期和随时,1长期,2随时
|
|
|
|
+ */
|
|
export default {
|
|
export default {
|
|
name: "datePicker",
|
|
name: "datePicker",
|
|
props: {
|
|
props: {
|
|
- maskColor: { // 模态框背景色
|
|
|
|
|
|
+ maskColor: {
|
|
type: String,
|
|
type: String,
|
|
default: 'rgba(0,0,0,0.3)'
|
|
default: 'rgba(0,0,0,0.3)'
|
|
},
|
|
},
|
|
@@ -55,27 +67,91 @@
|
|
checkDay:{
|
|
checkDay:{
|
|
type: [String,Number],
|
|
type: [String,Number],
|
|
default: new Date().getDate()
|
|
default: new Date().getDate()
|
|
|
|
+ },
|
|
|
|
+ startYear:{
|
|
|
|
+ type: [String,Number],
|
|
|
|
+ default: 1940
|
|
|
|
+ },
|
|
|
|
+ futureYear:{
|
|
|
|
+ type: [String,Number],
|
|
|
|
+ default: 10
|
|
|
|
+ },
|
|
|
|
+ periodOfValidity:{
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false
|
|
|
|
+ },
|
|
|
|
+ overdueContent:{
|
|
|
|
+ type: String,
|
|
|
|
+ default: ''
|
|
|
|
+ },
|
|
|
|
+ endDate: {
|
|
|
|
+ type: Object,
|
|
|
|
+ default: () => ({})
|
|
|
|
+ },
|
|
|
|
+ dateStatus:{
|
|
|
|
+ type: [String,Number],
|
|
|
|
+ default: 0
|
|
}
|
|
}
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
const date = new Date();
|
|
const date = new Date();
|
|
- const years = ['长期'];
|
|
|
|
- const months = [''];
|
|
|
|
|
|
+ let years = [],months = [];
|
|
|
|
+ if(this.dateStatus==1){
|
|
|
|
+ years = ['长期'];
|
|
|
|
+ months = [''];
|
|
|
|
+ }
|
|
|
|
+ if(this.dateStatus==2){
|
|
|
|
+ years = ['随时'];
|
|
|
|
+ months = [''];
|
|
|
|
+ }
|
|
|
|
+ const currectyear = date.getFullYear()
|
|
|
|
+ const currectmonth = date.getMonth() + 1
|
|
|
|
+ const currectday = date.getDate()
|
|
// console.log(this.checkYear)
|
|
// console.log(this.checkYear)
|
|
// const month = date.getMonth() + 1
|
|
// const month = date.getMonth() + 1
|
|
// const day = date.getDate();
|
|
// const day = date.getDate();
|
|
- const year = this.checkYear
|
|
|
|
- const month = this.checkMonth
|
|
|
|
- const day = this.checkDay
|
|
|
|
- console.log(year,month,day)
|
|
|
|
- // 可在此设置起始年份和终止年份
|
|
|
|
- for (let i = 1940; i <= date.getFullYear() + 10; i++) {
|
|
|
|
- years.push(i);
|
|
|
|
|
|
+
|
|
|
|
+ // 传截止日期设置起始年份和终止年份
|
|
|
|
+ if(JSON.stringify(this.endDate)!='{}'){
|
|
|
|
+ if(this.endDate.year&&this.endDate.year<currectyear){
|
|
|
|
+ this.showtoast('截止日期年份必须大于等于当前年份')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(this.endDate.year&&this.endDate.year==currectyear&&this.endDate.month&&this.endDate.month<currectmonth){
|
|
|
|
+ this.showtoast('截止日期月份必须大于等于当前月份')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(this.endDate.year&&this.endDate.year==currectyear&&this.endDate.month&&this.endDate.month==currectmonth&&this.endDate.day&&this.endDate.day<currectday){
|
|
|
|
+ this.showtoast('截止日期必须大于等于今天')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var obj=this.createExpirationDate()
|
|
|
|
+ // console.log(obj)
|
|
|
|
+ years=obj.years
|
|
|
|
+ months=obj.months
|
|
}
|
|
}
|
|
- for (let i = 1; i <= 12; i++) {
|
|
|
|
- months.push(i);
|
|
|
|
|
|
+
|
|
|
|
+ const year = this.checkYear?this.checkYear:currectyear
|
|
|
|
+ const month = this.checkMonth?Number(this.checkMonth):currectmonth
|
|
|
|
+ const day = this.checkDay?Number(this.checkDay):currectday
|
|
|
|
+
|
|
|
|
+ console.log(year,month,day)
|
|
|
|
+ // 未传截止日期设置起始年份和终止年份
|
|
|
|
+ if(JSON.stringify(this.endDate)=='{}'){
|
|
|
|
+ for (let i = this.startYear; i <= currectyear + this.futureYear; i++) {
|
|
|
|
+ years.push(i);
|
|
|
|
+ }
|
|
|
|
+ if(this.dateStatus==0&&year=='长期'||this.dateStatus==0&&year=='随时'){
|
|
|
|
+ this.showtoast('当前日期选择器未带长期和随时选项,请修改当前类型')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(year!='长期'&&year!='随时'){
|
|
|
|
+ for (let i = 1; i <= 12; i++) {
|
|
|
|
+ months.push(i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- console.log(months)
|
|
|
|
|
|
+
|
|
return {
|
|
return {
|
|
isShow: false, // 是否弹出
|
|
isShow: false, // 是否弹出
|
|
isOpen: false,
|
|
isOpen: false,
|
|
@@ -86,39 +162,119 @@
|
|
year,
|
|
year,
|
|
month,
|
|
month,
|
|
day,
|
|
day,
|
|
- value: [year - 1940, month - 1, day - 1], // 默认选中当天
|
|
|
|
|
|
+ value: year=='长期'||year=='随时'?[0,0,0]:[Number(year - this.startYear+1), month , day], // 默认选中当天
|
|
visible: true,
|
|
visible: true,
|
|
indicatorStyle: `height: ${Math.round(uni.getSystemInfoSync().screenWidth/(750/100))}px;`
|
|
indicatorStyle: `height: ${Math.round(uni.getSystemInfoSync().screenWidth/(750/100))}px;`
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
-
|
|
|
|
|
|
+ createExpirationDate(){
|
|
|
|
+ let years = [],months = [];
|
|
|
|
+ if(this.dateStatus==1){
|
|
|
|
+ years = ['长期'];
|
|
|
|
+ months = [''];
|
|
|
|
+ }
|
|
|
|
+ if(this.dateStatus==2){
|
|
|
|
+ years = ['随时'];
|
|
|
|
+ months = [''];
|
|
|
|
+ }
|
|
|
|
+ var year=this.checkYear?this.checkYear:this.year?this.year:new Date().getFullYear()
|
|
|
|
+ if(this.dateStatus==0&&year=='长期'||this.dateStatus==0&&year=='随时'){
|
|
|
|
+ this.showtoast('当前日期选择器未带长期和随时选项,请修改当前类型')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for (let i = this.startYear; i <= this.endDate.year; i++) {
|
|
|
|
+ years.push(i);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(year==this.endDate.year&&this.endDate.month){
|
|
|
|
+ if(year!='长期'||year!='随时'){
|
|
|
|
+ for (let i = 1; i <= this.endDate.month; i++) {
|
|
|
|
+ months.push(i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(year!=this.endDate.year){
|
|
|
|
+ for (let i = 1; i <= 12; i++) {
|
|
|
|
+ months.push(i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {years,months}
|
|
|
|
+ },
|
|
|
|
+ showtoast(content){
|
|
|
|
+ // #ifdef APP-PLUS
|
|
|
|
+ plus.nativeUI.toast(`<font style=\"font-size:15px;margin:20px;\" color="#f56c6c">    ${content?content:this.overdueContent}!    </font>`, {
|
|
|
|
+ icon : "icon URL",// eg. "/img/add.png"
|
|
|
|
+ duration : "long",// 持续3.5s,short---2s
|
|
|
|
+ align : "center",// 水平居中
|
|
|
|
+ verticalAlign : "center",// 垂直底部
|
|
|
|
+ background:'#FEF0F0',
|
|
|
|
+ type: "richtext",
|
|
|
|
+ })
|
|
|
|
+ // #endif
|
|
|
|
+ // #ifdef H5
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: (content?content:this.overdueContent)+'!',
|
|
|
|
+ icon:'none',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ // #endif
|
|
|
|
+ },
|
|
|
|
+ setValue(){
|
|
|
|
+ var val=[]
|
|
|
|
+ for (let i = 0; i < this.years.length; i++) {
|
|
|
|
+ if(this.year==this.years[i]){
|
|
|
|
+ val[0]=i
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (let i = 0; i < this.months.length; i++) {
|
|
|
|
+ if(Number(this.month)==this.months[i]){
|
|
|
|
+ val[1]=i
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (let i = 0; i < this.days.length; i++) {
|
|
|
|
+ if(Number(this.day)==this.days[i]){
|
|
|
|
+ val[2]=i
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return val
|
|
|
|
+ },
|
|
// 选中日期
|
|
// 选中日期
|
|
dateConfirm() {
|
|
dateConfirm() {
|
|
|
|
+ if(this.month==''&&this.year!='长期'&&this.month==''&&this.year!='随时'){
|
|
|
|
+ this.showtoast('未选择月份')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(this.day==''&&this.year!='长期'&&this.day==''&&this.year!='随时'){
|
|
|
|
+ this.showtoast('未选择日期')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(this.periodOfValidity&&this.year!='长期'&&this.periodOfValidity&&this.year!='随时'){
|
|
|
|
+ const date=new Date()
|
|
|
|
+ const currectyear = date.getFullYear()
|
|
|
|
+ const currectmonth = date.getMonth() + 1
|
|
|
|
+ const currectday = date.getDate()
|
|
|
|
+ if(this.year<currectyear){
|
|
|
|
+ this.showtoast()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(this.year==currectyear&&this.month<currectmonth){
|
|
|
|
+ this.showtoast()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(this.year==currectyear&&this.month==currectmonth&&this.day<=currectday){
|
|
|
|
+ this.showtoast()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
let dateobj={
|
|
let dateobj={
|
|
year:this.year,
|
|
year:this.year,
|
|
month:this.month?this.month > 9 ? this.month : '0' + this.month:'',
|
|
month:this.month?this.month > 9 ? this.month : '0' + this.month:'',
|
|
day:this.day?this.day > 9 ? this.day :'0' + this.day:'',
|
|
day:this.day?this.day > 9 ? this.day :'0' + this.day:'',
|
|
date:''
|
|
date:''
|
|
}
|
|
}
|
|
- if(this.year!='长期'){
|
|
|
|
- var val=[]
|
|
|
|
- for (let i = 0; i < this.years.length; i++) {
|
|
|
|
- if(this.year==this.years[i]){
|
|
|
|
- val[0]=i
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (let i = 0; i < this.months.length; i++) {
|
|
|
|
- if(this.month==this.months[i]){
|
|
|
|
- val[1]=i
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (let i = 0; i < this.days.length; i++) {
|
|
|
|
- if(this.day==this.days[i]){
|
|
|
|
- val[2]=i
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- this.value=val
|
|
|
|
|
|
+ if(this.year!='长期'&&this.year!='随时'){
|
|
|
|
+ this.value=this.setValue()
|
|
dateobj.date= this.year + '-' + (this.month > 9 ? this.month : '0' + this.month) + '-' + (this.day > 9 ? this.day :
|
|
dateobj.date= this.year + '-' + (this.month > 9 ? this.month : '0' + this.month) + '-' + (this.day > 9 ? this.day :
|
|
'0' + this.day);
|
|
'0' + this.day);
|
|
}else{
|
|
}else{
|
|
@@ -134,7 +290,12 @@
|
|
},
|
|
},
|
|
|
|
|
|
bindChange(e) {
|
|
bindChange(e) {
|
|
|
|
+ const date = new Date();
|
|
|
|
+ const year = date.getFullYear()
|
|
|
|
+ const month = date.getMonth() + 1
|
|
|
|
+ const day = date.getDate()
|
|
// console.log(this.value,e)
|
|
// console.log(this.value,e)
|
|
|
|
+
|
|
const val = e.detail.value;
|
|
const val = e.detail.value;
|
|
this.year = this.years[val[0]];
|
|
this.year = this.years[val[0]];
|
|
this.month = this.months[val[1]];
|
|
this.month = this.months[val[1]];
|
|
@@ -167,44 +328,144 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
|
|
+ "checkYear":{
|
|
|
|
+ handler(val){
|
|
|
|
+ // console.log(val)
|
|
|
|
+ this.checkYear=val
|
|
|
|
+ this.year=val
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ if(val=='长期'||val=='随时'){
|
|
|
|
+ this.value=[0,0,0]
|
|
|
|
+ }
|
|
|
|
+ }, 500);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ "endDate":{
|
|
|
|
+ handler(val){
|
|
|
|
+ this.endDate=val
|
|
|
|
+ },
|
|
|
|
+ deep: true,
|
|
|
|
+ immediate: true
|
|
|
|
+ },
|
|
|
|
+ "checkMonth":{
|
|
|
|
+ handler(val){
|
|
|
|
+ this.checkMonth=val
|
|
|
|
+ this.month=val
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ // console.log(this.month,this.day,this.days)
|
|
|
|
+ if(val!='长期'&&val!='随时'){
|
|
|
|
+ this.value=this.setValue()
|
|
|
|
+ // console.log(this.value)
|
|
|
|
+ }
|
|
|
|
+ }, 500);
|
|
|
|
+ })
|
|
|
|
+ // this.$nextTick(() => {
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
+ // if(val!='长期'&&val!='随时'){
|
|
|
|
+ // this.value=this.setValue()
|
|
|
|
+ // // console.log(this.value)
|
|
|
|
+ // }else{
|
|
|
|
+ // this.value=[0,0,0]
|
|
|
|
+ // }
|
|
|
|
+ // }, 350);
|
|
|
|
+ // })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ "checkDay":{
|
|
|
|
+ handler(val){
|
|
|
|
+ console.log(val,333333)
|
|
|
|
+ this.checkDay=val
|
|
|
|
+ this.day=val
|
|
|
|
+ // this.$nextTick(() => {
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
+ // if(val!='长期'&&val!='随时'){
|
|
|
|
+ // this.value=this.setValue()
|
|
|
|
+ // // console.log(this.value)
|
|
|
|
+ // }else{
|
|
|
|
+ // this.value=[0,0,0]
|
|
|
|
+ // }
|
|
|
|
+ // }, 350);
|
|
|
|
+ // })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
"month": { // 监听月份变化,改变当前月份天数值
|
|
"month": { // 监听月份变化,改变当前月份天数值
|
|
handler(val) {
|
|
handler(val) {
|
|
- if (val < 8&&this.year!='长期') {
|
|
|
|
|
|
+ console.log(this.endDate)
|
|
|
|
+ if (val < 8&&this.year!='长期'&&val < 8&&this.year!='随时') {
|
|
if (val % 2 !== 0) {
|
|
if (val % 2 !== 0) {
|
|
this.days = [''];
|
|
this.days = [''];
|
|
- for (let i = 1; i <= 31; i++) {
|
|
|
|
- this.days.push(i);
|
|
|
|
|
|
+ if(this.endDate.day&&val===this.endDate.month&&this.year===this.endDate.year){
|
|
|
|
+ for (let i = 1; i <= this.endDate.day; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = 1; i <= 31; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
this.days = [''];
|
|
this.days = [''];
|
|
- for (let i = 1; i <= 30; i++) {
|
|
|
|
- this.days.push(i);
|
|
|
|
|
|
+ if(this.endDate.day&&val===this.endDate.month&&this.year===this.endDate.year){
|
|
|
|
+ for (let i = 1; i <= this.endDate.day; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = 1; i <= 30; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (val > 7&&this.year!='长期') {
|
|
|
|
|
|
+ if (val > 7&&this.year!='长期'&&val > 7&&this.year!='随时') {
|
|
if (val % 2 === 0) {
|
|
if (val % 2 === 0) {
|
|
this.days = [''];
|
|
this.days = [''];
|
|
- for (let i = 1; i <= 31; i++) {
|
|
|
|
- this.days.push(i);
|
|
|
|
|
|
+ if(this.endDate.day&&val===this.endDate.month&&this.year===this.endDate.year){
|
|
|
|
+ for (let i = 1; i <= this.endDate.day; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = 1; i <= 31; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
this.days = [''];
|
|
this.days = [''];
|
|
- for (let i = 1; i <= 30; i++) {
|
|
|
|
- this.days.push(i);
|
|
|
|
|
|
+ if(this.endDate.day&&val===this.endDate.month&&this.year===this.endDate.year){
|
|
|
|
+ for (let i = 1; i <= this.endDate.day; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = 1; i <= 30; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (val === 2&&this.year!='长期') {
|
|
|
|
|
|
+ if (val === 2&&this.year!='长期'&&val === 2&&this.year!='随时') {
|
|
if (this.year % 4 === 0) {
|
|
if (this.year % 4 === 0) {
|
|
this.days = [''];
|
|
this.days = [''];
|
|
- for (let i = 1; i <= 29; i++) {
|
|
|
|
- this.days.push(i);
|
|
|
|
|
|
+ if(this.endDate.day&&val===this.endDate.month&&this.year===this.endDate.year){
|
|
|
|
+ for (let i = 1; i <= this.endDate.day; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = 1; i <= 29; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
this.days = [''];
|
|
this.days = [''];
|
|
- for (let i = 1; i <= 28; i++) {
|
|
|
|
- this.days.push(i);
|
|
|
|
|
|
+ if(this.endDate.day&&val===this.endDate.month&&this.year===this.endDate.year){
|
|
|
|
+ for (let i = 1; i <= this.endDate.day; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = 1; i <= 28; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -214,27 +475,47 @@
|
|
},
|
|
},
|
|
"year": { // 监听年份变化,处理2月份天数变化
|
|
"year": { // 监听年份变化,处理2月份天数变化
|
|
handler(val) {
|
|
handler(val) {
|
|
- if(val=='长期'){
|
|
|
|
|
|
+ if(val=='长期'||val=='随时'){
|
|
this.months=[''];
|
|
this.months=[''];
|
|
this.days = [''];
|
|
this.days = [''];
|
|
}else{
|
|
}else{
|
|
const months = [''];
|
|
const months = [''];
|
|
- for (let i = 1; i <= 12; i++) {
|
|
|
|
- months.push(i);
|
|
|
|
|
|
+ console.log(this.endDate)
|
|
|
|
+ if(this.endDate.year&&val===this.endDate.year&&this.endDate.month){
|
|
|
|
+ for (let i = 1; i <= this.endDate.month; i++) {
|
|
|
|
+ months.push(i);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = 1; i <= 12; i++) {
|
|
|
|
+ months.push(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
this.months=months
|
|
this.months=months
|
|
if (val % 4 === 0) {
|
|
if (val % 4 === 0) {
|
|
if (this.month === 2) {
|
|
if (this.month === 2) {
|
|
this.days = [''];
|
|
this.days = [''];
|
|
- for (let i = 1; i <= 29; i++) {
|
|
|
|
- this.days.push(i);
|
|
|
|
|
|
+ if(this.endDate.year&&val===this.endDate.year&&this.endDate.month&&this.endDate.month===this.month&&this.endDate.day){
|
|
|
|
+ for (let i = 1; i <= this.endDate.day; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = 1; i <= 29; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (this.month === 2) {
|
|
if (this.month === 2) {
|
|
this.days = [''];
|
|
this.days = [''];
|
|
- for (let i = 1; i <= 28; i++) {
|
|
|
|
- this.days.push(i);
|
|
|
|
|
|
+ if(this.endDate.year&&val===this.endDate.year&&this.endDate.month&&this.endDate.month===this.month&&this.endDate.day){
|
|
|
|
+ for (let i = 1; i <= this.endDate.day; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ for (let i = 1; i <= 28; i++) {
|
|
|
|
+ this.days.push(i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -335,7 +616,7 @@
|
|
.date-picker-title {
|
|
.date-picker-title {
|
|
height: 100rpx;
|
|
height: 100rpx;
|
|
padding: 0 20rpx;
|
|
padding: 0 20rpx;
|
|
- box-shadow: 0 1rpx 1rpx #e4e4e4;
|
|
|
|
|
|
+ // box-shadow: 0 1rpx 1rpx #e4e4e4;
|
|
}
|
|
}
|
|
|
|
|
|
.date-picker-confirm {
|
|
.date-picker-confirm {
|
|
@@ -347,7 +628,7 @@
|
|
.date-picker-cancel {
|
|
.date-picker-cancel {
|
|
padding: 10rpx 30rpx;
|
|
padding: 10rpx 30rpx;
|
|
font-size: 32rpx;
|
|
font-size: 32rpx;
|
|
- color: red;
|
|
|
|
|
|
+ // color: red;
|
|
}
|
|
}
|
|
|
|
|
|
// 内容
|
|
// 内容
|