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

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

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

Loading…
Cancel
Save