|
@@ -10,41 +10,43 @@
|
|
|
custom-class="dateDialog"
|
|
|
width="650px">
|
|
|
<div class="dialog-min">
|
|
|
- <el-radio-group v-model="dateType" @change="changeType">
|
|
|
- <el-radio :label="1" border>起始时间设置</el-radio>
|
|
|
+ <el-radio-group v-model="radioType" @change="changeType">
|
|
|
+ <el-radio :label="1" border>最近N年</el-radio>
|
|
|
<el-radio :label="2" border>区间设置</el-radio>
|
|
|
</el-radio-group>
|
|
|
<div class="date-cont">
|
|
|
- <template v-if="dateType===2">
|
|
|
- <date-picker
|
|
|
- v-model="start_date"
|
|
|
- type="month"
|
|
|
- value-type="format"
|
|
|
- placeholder="起始时间"
|
|
|
- ></date-picker>
|
|
|
- <span style="margin:0 20px">至</span>
|
|
|
- <date-picker
|
|
|
- v-model="end_date"
|
|
|
- type="month"
|
|
|
- value-type="format"
|
|
|
- placeholder="结束时间"
|
|
|
- ></date-picker>
|
|
|
+ <template v-if="radioType===1">
|
|
|
+ <span style="margin:0 20px;color: #000000;">年数</span>
|
|
|
+ <el-input v-model.number="count_year" placeholder="请输入数字"></el-input>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
- <date-picker
|
|
|
+ <el-date-picker
|
|
|
+ v-show="dateType==1"
|
|
|
v-model="start_date"
|
|
|
- type="month"
|
|
|
+ type="date"
|
|
|
+ value-type="format"
|
|
|
+ value-format="yyyy-MM-dd"
|
|
|
+ placeholder="选择日期"
|
|
|
+ :picker-options="pickerOptions"
|
|
|
+ ></el-date-picker>
|
|
|
+ <el-date-picker
|
|
|
+ v-show="dateType==2"
|
|
|
+ v-model="dates"
|
|
|
+ type="daterange"
|
|
|
value-type="format"
|
|
|
- placeholder="起始时间"
|
|
|
- ></date-picker>
|
|
|
- <span style="margin:0 20px">至</span>
|
|
|
- <el-button type="text" style="font-size: 16px">至今</el-button>
|
|
|
+ value-format="yyyy-MM-dd"
|
|
|
+ start-placeholder="开始日期"
|
|
|
+ end-placeholder="结束日期"
|
|
|
+ :picker-options="pickerOptions"
|
|
|
+ ></el-date-picker>
|
|
|
+ <el-checkbox label="至今" :checked="dateType == 1" @change="changeDateType"
|
|
|
+ style="margin-left: 18px;"></el-checkbox>
|
|
|
</template>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="dia-bot">
|
|
|
- <el-button type="primary" style="margin-right:20px" @click="saveHandle">保存</el-button>
|
|
|
- <el-button type="primary" plain @click="cancelHandle">取消</el-button>
|
|
|
+ <el-button plain @click="cancelHandle" style="width: 120px;">取消</el-button>
|
|
|
+ <el-button type="primary" style="width: 120px;margin-left:30px" @click="saveHandle">保存</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
</template>
|
|
@@ -58,49 +60,90 @@ export default {
|
|
|
},
|
|
|
dialogTitle: {
|
|
|
type: String,
|
|
|
- default:'设置默认时间'
|
|
|
+ default:'时间长度设置'
|
|
|
},
|
|
|
dateForm: {
|
|
|
type:Object
|
|
|
+ },
|
|
|
+ // 最早的日期,开始时间不得早于这个
|
|
|
+ earliestDate:{
|
|
|
+ type: String,
|
|
|
+ default:'0000-00-00'
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
isDateDia(val) {
|
|
|
if(val) {
|
|
|
+ this.radioType = this.dateForm.date_type === 5 || this.dateForm.date_type === 6 ? 2 : 1;
|
|
|
this.dateType = this.dateForm.date_type === 5 ? 2 : 1;
|
|
|
this.start_date = this.dateForm.start_date;
|
|
|
this.end_date = this.dateForm.end_date;
|
|
|
+ this.dates = this.radioType == 2&&this.dateType==2?[this.start_date,this.end_date]:[]
|
|
|
+ this.count_year = this.dateForm.count_year
|
|
|
+ }
|
|
|
+ },
|
|
|
+ dates(value){
|
|
|
+ if(!value){
|
|
|
+ this.start_date = ''
|
|
|
+ this.end_date = ''
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if(value && value.length>0){
|
|
|
+ this.start_date = value[0]
|
|
|
+ this.end_date = value[1]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
- dateType:1,
|
|
|
+ radioType:1,
|
|
|
+ dateType:2,
|
|
|
start_date: '',
|
|
|
end_date: '',
|
|
|
+ count_year:'',// 年数
|
|
|
+ dates:[],
|
|
|
+ pickerOptions:{
|
|
|
+ disabledDate:(date)=>{
|
|
|
+ return date < (new Date(`${this.earliestDate} 00:00:00`) || 0)
|
|
|
+ },
|
|
|
+ }
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
/* 确认时间 返回回调 */
|
|
|
saveHandle() {
|
|
|
- if(!this.start_date || (!this.end_date && this.dateType === 2)) {
|
|
|
+ if(this.radioType == 1 && (!parseInt(this.count_year))) {
|
|
|
+ this.$message.warning('请输入正确的数字')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log(this.radioType,this.dateType,this.start_date,this.end_date,this.dates,this.count_year);
|
|
|
+
|
|
|
+ if(this.radioType == 2 && (!this.start_date || (!this.end_date && this.dateType === 2))) {
|
|
|
this.$message.warning('请选择正确的时间段')
|
|
|
}else {
|
|
|
this.$emit('dateBack',{
|
|
|
- dateType: this.dateType === 1 ? 6 : 5,
|
|
|
+ dateType: this.radioType==1?100:this.dateType === 1 ? 6 : 5,
|
|
|
start_date: this.start_date,
|
|
|
- end_date: this.dateType === 1 ? '' : this.end_date
|
|
|
+ end_date: this.dateType === 1 ? '' : this.end_date,
|
|
|
+ count_year:this.count_year
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
changeType() {
|
|
|
- this.start_date = '';
|
|
|
- this.end_date = '';
|
|
|
+ this.dateType=1
|
|
|
+ this.dates=null
|
|
|
+ this.count_year = ''
|
|
|
+ },
|
|
|
+ changeDateType(check){
|
|
|
+ this.dateType=check?1:2
|
|
|
+ this.dates=null
|
|
|
},
|
|
|
cancelHandle() {
|
|
|
+ this.radioType = 1
|
|
|
this.dateType = 1;
|
|
|
- this.start_date = '';
|
|
|
- this.end_date = '';
|
|
|
+ this.dates=null
|
|
|
+ this.count_year = ''
|
|
|
this.$emit('cancel')
|
|
|
}
|
|
|
},
|
|
@@ -124,13 +167,13 @@ export default {
|
|
|
width: 220px !important;
|
|
|
}
|
|
|
.dialog-min {
|
|
|
- padding: 10px 20px;
|
|
|
+ padding: 0 35px 60px;
|
|
|
.date-cont {
|
|
|
- margin-top: 30px;
|
|
|
+ margin-top: 50px;
|
|
|
}
|
|
|
}
|
|
|
.dia-bot {
|
|
|
- margin: 52px 0 30px;
|
|
|
+ margin: 60px 0 30px;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
}
|