|
|
@ -25,7 +25,7 @@ |
|
|
|
<el-table :data="listData" class="table" ref="table" stripe header-align="center"> |
|
|
|
<el-table :data="listData" class="table" ref="table" stripe header-align="center"> |
|
|
|
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column> |
|
|
|
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column> |
|
|
|
<el-table-column prop="showName" label="数据表名称" align="center" :show-overflow-tooltip="true"></el-table-column> |
|
|
|
<el-table-column prop="showName" label="数据表名称" align="center" :show-overflow-tooltip="true"></el-table-column> |
|
|
|
<el-table-column prop="createTime" label="起止日期" align="center"></el-table-column> |
|
|
|
<el-table-column prop="timeRange" label="起止日期" width="220" align="center"></el-table-column> |
|
|
|
<el-table-column prop="dataTotal" label="数据总量" align="center"></el-table-column> |
|
|
|
<el-table-column prop="dataTotal" label="数据总量" align="center"></el-table-column> |
|
|
|
<el-table-column prop="dataSize" label="数据大小" align="center"> |
|
|
|
<el-table-column prop="dataSize" label="数据大小" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<template slot-scope="scope"> |
|
|
@ -176,6 +176,34 @@ |
|
|
|
</el-table> |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-drawer> |
|
|
|
</el-drawer> |
|
|
|
|
|
|
|
<el-dialog title="下载" :visible.sync="downloadVisible" width="540px" @close="closeDownload" :close-on-click-modal="false"> |
|
|
|
|
|
|
|
<el-form ref="form" label-width="100px" label-suffix=":"> |
|
|
|
|
|
|
|
<el-form-item label="数据筛选"> |
|
|
|
|
|
|
|
<div class="checkboxs"> |
|
|
|
|
|
|
|
<el-checkbox v-model="checkAllFields" @change="checkAllFieldsChange">全选</el-checkbox> |
|
|
|
|
|
|
|
<el-checkbox-group v-model="fields"> |
|
|
|
|
|
|
|
<el-checkbox v-for="(item,index) in fieldsList" :key="index" :label="item.comment"></el-checkbox> |
|
|
|
|
|
|
|
</el-checkbox-group> |
|
|
|
|
|
|
|
</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-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-form-item> |
|
|
|
|
|
|
|
<el-form-item label="数据频率"> |
|
|
|
|
|
|
|
<el-select v-model="frequency" placeholder="请选择数据频率" size="small"> |
|
|
|
|
|
|
|
<el-option v-for="(item,index) in frequencyList" :key="index" :label="item.name" :value="item.id"></el-option> |
|
|
|
|
|
|
|
</el-select> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
</el-form> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
|
|
|
|
<el-button size="small" @click="downloadVisible = false">取消</el-button> |
|
|
|
|
|
|
|
<el-button size="small" type="primary" @click="confirmDown">确定</el-button> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
@ -183,6 +211,9 @@ |
|
|
|
import { mapState } from 'vuex' |
|
|
|
import { mapState } from 'vuex' |
|
|
|
import Setting from '@/setting' |
|
|
|
import Setting from '@/setting' |
|
|
|
import util from '@/libs/util' |
|
|
|
import util from '@/libs/util' |
|
|
|
|
|
|
|
import axios from 'axios' |
|
|
|
|
|
|
|
let startTimeLimit = '' |
|
|
|
|
|
|
|
let endTimeLimit = '' |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
name: 'index', |
|
|
|
name: 'index', |
|
|
|
data() { |
|
|
|
data() { |
|
|
@ -198,7 +229,43 @@ export default { |
|
|
|
active: '', |
|
|
|
active: '', |
|
|
|
previewVisible: false, |
|
|
|
previewVisible: false, |
|
|
|
previewHead: [], |
|
|
|
previewHead: [], |
|
|
|
previewData: [] |
|
|
|
previewData: [], |
|
|
|
|
|
|
|
downloadVisible: false, |
|
|
|
|
|
|
|
curRow: {}, |
|
|
|
|
|
|
|
checkAllFields: false, |
|
|
|
|
|
|
|
fields: [], |
|
|
|
|
|
|
|
fieldsList: [], |
|
|
|
|
|
|
|
startTime: '', |
|
|
|
|
|
|
|
endTime: '', |
|
|
|
|
|
|
|
startTimeLimit: '', |
|
|
|
|
|
|
|
startTimeDisabled: false, |
|
|
|
|
|
|
|
endTimeLimit: '', |
|
|
|
|
|
|
|
endTimeDisabled: false, |
|
|
|
|
|
|
|
timeDefault: '', |
|
|
|
|
|
|
|
timeOptions: { |
|
|
|
|
|
|
|
disabledDate(time) { |
|
|
|
|
|
|
|
return time.getTime() < startTimeLimit || time.getTime() > endTimeLimit |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
frequency: '', |
|
|
|
|
|
|
|
frequencyList: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 1, |
|
|
|
|
|
|
|
name: '日频' |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
id: 2, |
|
|
|
|
|
|
|
name: '周频' |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
id: 3, |
|
|
|
|
|
|
|
name: '月频' |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
id: 4, |
|
|
|
|
|
|
|
name: '季频' |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
id: 5, |
|
|
|
|
|
|
|
name: '年频' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
computed: { |
|
|
@ -226,7 +293,20 @@ export default { |
|
|
|
getData(){ |
|
|
|
getData(){ |
|
|
|
if (this.keyword) { |
|
|
|
if (this.keyword) { |
|
|
|
this.$post(`${this.api.getTableByCondition}?showName=${this.keyword}&pageNum=${this.page}&pageSize=${this.pageSize}`).then(res => { |
|
|
|
this.$post(`${this.api.getTableByCondition}?showName=${this.keyword}&pageNum=${this.page}&pageSize=${this.pageSize}`).then(res => { |
|
|
|
this.listData = res.data.records |
|
|
|
const list = res.data.records |
|
|
|
|
|
|
|
list.map(e => { |
|
|
|
|
|
|
|
// 开始结束时间只显示日期 |
|
|
|
|
|
|
|
const startTime = e.startTime ? e.startTime.slice(0, 10) : '' |
|
|
|
|
|
|
|
const endTime = e.endTime ? e.endTime.slice(0, 10) : '' |
|
|
|
|
|
|
|
if (startTime && endTime) { |
|
|
|
|
|
|
|
e.timeRange = startTime + ' ~ ' + endTime |
|
|
|
|
|
|
|
} else if (startTime) { |
|
|
|
|
|
|
|
e.timeRange = startTime |
|
|
|
|
|
|
|
} else if (endTime) { |
|
|
|
|
|
|
|
e.timeRange = e.endTime |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
this.listData = list |
|
|
|
this.total = res.data.total |
|
|
|
this.total = res.data.total |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => {}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -255,6 +335,30 @@ export default { |
|
|
|
this.$refs.table.clearSelection() |
|
|
|
this.$refs.table.clearSelection() |
|
|
|
this.getData() |
|
|
|
this.getData() |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clearKeyword() { |
|
|
|
|
|
|
|
this.keyword = '' |
|
|
|
|
|
|
|
this.listData = [] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
toData(row){ |
|
|
|
|
|
|
|
// 登录了才能查看数据,否则直接跳转到登录页 |
|
|
|
|
|
|
|
if(this.token){ |
|
|
|
|
|
|
|
if (this.routes.find(e => e.path === '/data/list')) { |
|
|
|
|
|
|
|
this.$router.push(`/data?typeId=${row.categoryTwoId}`) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.keyword = row.categoryTwo |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
let route = this.$router.resolve({ |
|
|
|
|
|
|
|
path: '/login' |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
window.open(route.href) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
toPart(i){ |
|
|
|
|
|
|
|
this.active = i |
|
|
|
|
|
|
|
document.querySelector(`#part${i}`).scrollIntoView() |
|
|
|
|
|
|
|
}, |
|
|
|
preview(row) { |
|
|
|
preview(row) { |
|
|
|
// 登录后才能预览,否则直接跳转到登录页 |
|
|
|
// 登录后才能预览,否则直接跳转到登录页 |
|
|
|
if(this.token){ |
|
|
|
if(this.token){ |
|
|
@ -293,14 +397,7 @@ export default { |
|
|
|
download(row){ |
|
|
|
download(row){ |
|
|
|
// 登录了才能下载,否则直接跳转到登录页 |
|
|
|
// 登录了才能下载,否则直接跳转到登录页 |
|
|
|
if(this.token){ |
|
|
|
if(this.token){ |
|
|
|
// 查询是否有下载权限 |
|
|
|
this.showDownload(row) |
|
|
|
this.$get(`${this.api.isDownload}`,{ |
|
|
|
|
|
|
|
tableId: row.id, |
|
|
|
|
|
|
|
schoolId: this.schoolId, |
|
|
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
|
|
// 跳转到数据页去下载 |
|
|
|
|
|
|
|
this.$router.push(`/data?download=true&id=${row.id}&name=${row.name}&showName=${row.showName}`) |
|
|
|
|
|
|
|
}).catch(res => {}) |
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
let route = this.$router.resolve({ |
|
|
|
let route = this.$router.resolve({ |
|
|
|
path: '/login' |
|
|
|
path: '/login' |
|
|
@ -308,28 +405,124 @@ export default { |
|
|
|
window.open(route.href) |
|
|
|
window.open(route.href) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
clearKeyword() { |
|
|
|
checkAllFieldsChange(val) { |
|
|
|
this.keyword = '' |
|
|
|
this.fields = val ? this.fieldsList.map(n => n.comment) : [] |
|
|
|
this.listData = [] |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
toData(row){ |
|
|
|
showDownload(row) { |
|
|
|
// 登录了才能查看数据,否则直接跳转到登录页 |
|
|
|
// 查询是否购买了该数据,只有购买了才能下载 |
|
|
|
if(this.token){ |
|
|
|
this.$get(`${this.api.isDownload}`, { |
|
|
|
if (this.routes.find(e => e.path === '/data/list')) { |
|
|
|
tableId: row.id, |
|
|
|
this.$router.push(`/data?typeId=${row.categoryTwoId}`) |
|
|
|
schoolId: this.schoolId, |
|
|
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
|
|
this.curRow = row |
|
|
|
|
|
|
|
this.downloadVisible = true |
|
|
|
|
|
|
|
// 限制数据可选择的开始结束时间 |
|
|
|
|
|
|
|
if (row.startTime) { |
|
|
|
|
|
|
|
startTimeLimit = new Date(row.startTime).getTime() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.keyword = row.categoryTwo |
|
|
|
// 如果没有开始时间,则禁止选择开始时间 |
|
|
|
|
|
|
|
this.startTimeDisabled = true |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if (row.endTime) { |
|
|
|
let route = this.$router.resolve({ |
|
|
|
endTimeLimit = new Date(row.endTime).getTime() |
|
|
|
path: '/login' |
|
|
|
this.timeDefault = row.endTime |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 如果没有结束时间,则禁止选择结束时间 |
|
|
|
|
|
|
|
this.endTimeDisabled = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => { |
|
|
|
|
|
|
|
let comment = res.comment |
|
|
|
|
|
|
|
let fieldsList = [] |
|
|
|
|
|
|
|
comment.map(n => { |
|
|
|
|
|
|
|
n.field != 'id' && n.field != 'operation_time' && fieldsList.push(n) |
|
|
|
}) |
|
|
|
}) |
|
|
|
window.open(route.href) |
|
|
|
this.fieldsList = fieldsList |
|
|
|
|
|
|
|
}).catch(res => { }) |
|
|
|
|
|
|
|
}).catch(res => { }) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
closeDownload() { |
|
|
|
|
|
|
|
this.checkAllFields = false |
|
|
|
|
|
|
|
this.fields = [] |
|
|
|
|
|
|
|
this.startTime = '' |
|
|
|
|
|
|
|
this.endTime = '' |
|
|
|
|
|
|
|
this.frequency = '' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
confirmDown() { |
|
|
|
|
|
|
|
let fields = this.fields |
|
|
|
|
|
|
|
if (!fields.length) return util.warningMsg('请选择字段') |
|
|
|
|
|
|
|
if (!this.startTime) return util.warningMsg('请选择开始时间') |
|
|
|
|
|
|
|
if (!this.endTime) return util.warningMsg('请选择结束时间') |
|
|
|
|
|
|
|
if (!this.frequency) return util.warningMsg('请选择数据频率') |
|
|
|
|
|
|
|
let invalid = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.startTime && this.endTime) { |
|
|
|
|
|
|
|
let startTime = new Date(this.startTime) |
|
|
|
|
|
|
|
let endTime = new Date(this.endTime) |
|
|
|
|
|
|
|
let frequency = this.frequency |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 只要选择的不是日频,则要判断选择的日期区间有没有包含这段频率对应的完整交易日段 |
|
|
|
|
|
|
|
// 比如选的是周频,则判断选择的时间区间有没有包含一段完整的星期交易日,即星期1~5, |
|
|
|
|
|
|
|
// 选的是月频的话,则判断选择的时间区间有没有包含一个完整的月份,即30天;年份同理 |
|
|
|
|
|
|
|
if (frequency == 2) { |
|
|
|
|
|
|
|
let week = [] |
|
|
|
|
|
|
|
while (startTime <= endTime) { |
|
|
|
|
|
|
|
let weekNum = startTime.getDay() |
|
|
|
|
|
|
|
if (weekNum == 0) weekNum = 7 |
|
|
|
|
|
|
|
week.push(weekNum) |
|
|
|
|
|
|
|
startTime.setTime(startTime.getTime() + 86400000) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 如果没有包含1~5,则提示请选择完整区间,下面同理 |
|
|
|
|
|
|
|
for (let i = 1; i <= 5; i++) { |
|
|
|
|
|
|
|
if (!week.includes(i)) { |
|
|
|
|
|
|
|
invalid = true |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (frequency == 3) { |
|
|
|
|
|
|
|
if ((endTime.getTime() - startTime.getTime()) / 86400000 < 30) invalid = true |
|
|
|
|
|
|
|
} else if (frequency == 4) { |
|
|
|
|
|
|
|
if ((endTime.getTime() - startTime.getTime()) / 86400000 < 90) invalid = true |
|
|
|
|
|
|
|
} else if (frequency == 5) { |
|
|
|
|
|
|
|
if ((endTime.getTime() - startTime.getTime()) / 86400000 < 365) invalid = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (invalid) return util.warningMsg('请选择完整区间') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let newFields = [] |
|
|
|
|
|
|
|
let fieldsList = this.fieldsList |
|
|
|
|
|
|
|
fields.map(n => { |
|
|
|
|
|
|
|
newFields.push(fieldsList.find(e => e.comment == n).field) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
let msgObj = util.successMsg('数据正在生成中,请稍等片刻,生成后会自动下载,您可以先访问其他页面。', 5000) |
|
|
|
|
|
|
|
this.downloadVisible = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let startTime = this.startTime ? this.startTime : '' |
|
|
|
|
|
|
|
let endTime = this.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: { |
|
|
|
|
|
|
|
token: this.token |
|
|
|
}, |
|
|
|
}, |
|
|
|
toPart(i){ |
|
|
|
responseType: 'blob' |
|
|
|
this.active = i |
|
|
|
}).then((res) => { |
|
|
|
document.querySelector(`#part${i}`).scrollIntoView() |
|
|
|
msgObj.close() |
|
|
|
|
|
|
|
if (res.data.type != 'multipart/form-data') return util.warningMsg('数据总数为零!') |
|
|
|
|
|
|
|
// 统一调用该方法去下载excel |
|
|
|
|
|
|
|
util.downloadFileDirect(`${this.curRow.showName}.xls`, new Blob([res.data])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 下载记录 |
|
|
|
|
|
|
|
this.$get(`${this.api.downloadRecord}?tableId=${this.curRow.id}&fields=${newFields.join()}` + (startTime ? `&startTime=${startTime}` : '') + (endTime ? `&endTime=${endTime}` : '') + `&frequency=${frequency}`).then(res => { }).catch(res => { }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 下载次数+1 |
|
|
|
|
|
|
|
this.$post(this.api.saveRecord, { |
|
|
|
|
|
|
|
tableId: this.curRow.id, |
|
|
|
|
|
|
|
type: 1, |
|
|
|
|
|
|
|
}).then(res => { }).catch(res => { }) |
|
|
|
|
|
|
|
}).catch(res => { |
|
|
|
|
|
|
|
msgObj.close() |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|