下载数据开始结束时间限制

dev_2022-04-07
jialong.yu 3 years ago
parent 1dca51cce6
commit b69759e77c
  1. 21
      src/pages/data/list/index.vue
  2. 18
      src/pages/index/list/index.vue

@ -53,10 +53,10 @@
</div>
</el-form-item>
<el-form-item label="开始时间">
<el-date-picker v-model="startTime" type="date" placeholder="请选择开始时间" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :picker-options="timeOptions" :disabled="startTimeDisabled" :default-value="timeDefault"></el-date-picker>
<el-date-picker v-model="startTime" type="date" placeholder="请选择开始时间" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :picker-options="timeOptions" :disabled="startTimeDisabled" :default-value="startTimeDefault" @change="timeChange"></el-date-picker>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker v-model="endTime" type="date" placeholder="请选择结束时间" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :picker-options="timeOptions" :disabled="endTimeDisabled" :default-value="timeDefault"></el-date-picker>
<el-date-picker v-model="endTime" type="date" placeholder="请选择结束时间" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :picker-options="timeOptions" :disabled="endTimeDisabled" :default-value="endTimeDefault" @change="timeChange"></el-date-picker>
</el-form-item>
<el-form-item label="数据频率">
<el-select v-model="frequency" placeholder="请选择数据频率" size="small">
@ -137,7 +137,8 @@ export default {
startTimeDisabled: false,
endTimeLimit: '',
endTimeDisabled: false,
timeDefault: '',
startTimeDefault: '',
endTimeDefault: '',
timeOptions: {
disabledDate(time) {
return time.getTime() < startTimeLimit || time.getTime() > endTimeLimit
@ -349,6 +350,7 @@ export default {
checkAllFieldsChange(val) {
this.fields = val ? this.fieldsList.map(n => n.comment) : []
},
//
download(row) {
// ,
this.$get(`${this.api.isDownload}`, {
@ -360,13 +362,14 @@ export default {
//
if (row.startTime) {
startTimeLimit = new Date(row.startTime).getTime()
this.startTimeDefault = row.startTime
} else {
// ,
this.startTimeDisabled = true
}
if (row.endTime) {
endTimeLimit = new Date(row.endTime).getTime()
this.timeDefault = row.endTime
this.endTimeDefault = row.endTime
} else {
// ,
this.endTimeDisabled = true
@ -382,6 +385,11 @@ export default {
}).catch(res => { })
}).catch(res => { })
},
//
timeChange() {
//
if (this.startTime && this.endTime && new Date(this.startTime) > new Date(this.endTime)) util.warningMsg('结束时间不能小于开始时间')
},
closeDownload() {
this.checkAllFields = false
this.fields = []
@ -395,6 +403,7 @@ export default {
if (!fields.length) return util.warningMsg('请选择字段')
if (!this.startTime) return util.warningMsg('请选择开始时间')
if (!this.endTime) return util.warningMsg('请选择结束时间')
if (new Date(this.endTime) < new Date(this.startTime)) return util.warningMsg('结束时间不能小于开始时间')
if (!this.frequency) return util.warningMsg('请选择数据频率')
let invalid = false
@ -443,8 +452,8 @@ export default {
let msgObj = util.successMsg('数据正在生成中,请稍等片刻,生成后会自动下载,您可以先访问其他页面。', 5000)
this.downloadVisible = false
let startTime = this.startTime ? this.startTime : ''
let endTime = this.endTime ? this.endTime : ''
let startTime = this.startTime || ''
let endTime = this.endTime || ''
let frequency = this.frequency
axios.get(`${this.api.downloadData}?tableName=${this.curRow.name}&table_id=${this.curRow.id}&fields=${newFields.join()}&startTime=${startTime}&endTime=${endTime}&frequency=${frequency}`, {
headers: {

@ -187,10 +187,10 @@
</div>
</el-form-item>
<el-form-item label="开始时间">
<el-date-picker v-model="startTime" type="date" placeholder="请选择开始时间" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :picker-options="timeOptions" :disabled="startTimeDisabled" :default-value="timeDefault"></el-date-picker>
<el-date-picker v-model="startTime" type="date" placeholder="请选择开始时间" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :picker-options="timeOptions" :disabled="startTimeDisabled" :default-value="startTimeDefault" @change="timeChange"></el-date-picker>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker v-model="endTime" type="date" placeholder="请选择结束时间" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :picker-options="timeOptions" :disabled="endTimeDisabled" :default-value="timeDefault"></el-date-picker>
<el-date-picker v-model="endTime" type="date" placeholder="请选择结束时间" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :picker-options="timeOptions" :disabled="endTimeDisabled" :default-value="endTimeDefault" @change="timeChange"></el-date-picker>
</el-form-item>
<el-form-item label="数据频率">
<el-select v-model="frequency" placeholder="请选择数据频率" size="small">
@ -241,7 +241,8 @@ export default {
startTimeDisabled: false,
endTimeLimit: '',
endTimeDisabled: false,
timeDefault: '',
startTimeDefault: '',
endTimeDefault: '',
timeOptions: {
disabledDate(time) {
return time.getTime() < startTimeLimit || time.getTime() > endTimeLimit
@ -419,13 +420,14 @@ export default {
//
if (row.startTime) {
startTimeLimit = new Date(row.startTime).getTime()
this.startTimeDefault = row.startTime
} else {
// ,
this.startTimeDisabled = true
}
if (row.endTime) {
endTimeLimit = new Date(row.endTime).getTime()
this.timeDefault = row.endTime
this.endTimeDefault = row.endTime
} else {
// ,
this.endTimeDisabled = true
@ -441,6 +443,11 @@ export default {
}).catch(res => { })
}).catch(res => { })
},
//
timeChange() {
//
if (this.startTime && this.endTime && new Date(this.startTime) > new Date(this.endTime)) util.warningMsg('结束时间不能小于开始时间')
},
closeDownload() {
this.checkAllFields = false
this.fields = []
@ -453,6 +460,7 @@ export default {
if (!fields.length) return util.warningMsg('请选择字段')
if (!this.startTime) return util.warningMsg('请选择开始时间')
if (!this.endTime) return util.warningMsg('请选择结束时间')
if (new Date(this.endTime) < new Date(this.startTime)) return util.warningMsg('结束时间不能小于开始时间')
if (!this.frequency) return util.warningMsg('请选择数据频率')
let invalid = false
@ -740,7 +748,7 @@ export default {
display: flex;
justify-content: space-between;
.icon{
width: 44px;
width: 60px;
}
.text{
width: 340px;

Loading…
Cancel
Save