首页下载等bug修复

dev_2022-04-07
Jo 3 years ago
parent 6065ddfb59
commit 9720860941
  1. 18
      src/layouts/header/index.vue
  2. 6
      src/layouts/navbar/index.vue
  3. 247
      src/pages/index/list/index.vue
  4. 6
      src/router/permission.js

@ -146,18 +146,12 @@ export default {
this.showSetting = false this.showSetting = false
}, },
toIndex() { toIndex() {
this.$route.path === '/index/list' if (this.$route.path === '/index/list') {
? location.reload() location.reload()
: this.$refs.nav.jump({ } else {
index: '/index/list', this.$refs.nav.toIndex()
title: '首页' this.showSetting = true
}) }
},
toSearch() {
this.$refs.nav.jump({
index: '/index/list',
title: '首页'
})
}, },
toLogin() { toLogin() {
this.$refs.nav.jump({ this.$refs.nav.jump({

@ -102,6 +102,12 @@ export default {
this.active = item.index this.active = item.index
this.$router.push(item.index).catch(err => { }) this.$router.push(item.index).catch(err => { })
}, },
toIndex() {
this.$router.push('/index')
this.isManager = false
this.setManager(true)
this.initMenu()
},
// //
getPer() { getPer() {
this.$get(`${this.api.getPermissions}?platformId=${Setting.platformId}`).then(res => { this.$get(`${this.api.getPermissions}?platformId=${Setting.platformId}`).then(res => {

@ -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()
})
} }
} }
}; };

@ -19,7 +19,10 @@ router.beforeEach((to, from, next) => {
// 如果是管理员则需要从获取的路由权限里判断当前访问页面是否有权限访问,如果没权限访问则跳转到403 // 如果是管理员则需要从获取的路由权限里判断当前访问页面是否有权限访问,如果没权限访问则跳转到403
if((mg && atob(decodeURI(mg)) === 'true') || (to.query.mg && atob(decodeURI(to.query.mg)) === 'true')){ if((mg && atob(decodeURI(mg)) === 'true') || (to.query.mg && atob(decodeURI(to.query.mg)) === 'true')){
if(routes.length){ if(routes.length){
if(routes.find(n => n.name == toPath) || toPath == '/setting/person' || toPath == '/setting/download'){ if(routes.find(n => n.name == toPath) || toPath == '/setting/person' || toPath == '/setting/download' || toPath == '/index/list'){
if (toPath === '/index/list') {
next()
} else {
if(!to.query.mg){ if(!to.query.mg){
next({ next({
path: toPath, path: toPath,
@ -28,6 +31,7 @@ router.beforeEach((to, from, next) => {
}else{ }else{
next() next()
} }
}
}else{ }else{
if(to.path != '/403'){ if(to.path != '/403'){
next('/403') next('/403')

Loading…
Cancel
Save