数据、角色等

ui1
yujialong 3 years ago
parent d7ae5b59c3
commit 75c2aefbf5
  1. 25
      src/api/index.js
  2. 13
      src/layouts/navbar/index.vue
  3. 12
      src/libs/util.js
  4. 156
      src/pages/data/list/index.vue
  5. 64
      src/pages/index/list/index.vue
  6. 105
      src/pages/role/list/index.vue
  7. 58
      src/pages/setting/person/download.vue
  8. 28
      src/plugins/requests/index.js
  9. 2
      src/setting.js

@ -48,18 +48,27 @@ export default {
queryAccountStaff:`evaluation/tms/system/queryAccount`, queryAccountStaff:`evaluation/tms/system/queryAccount`,
resetPwd:`evaluation/tms/system/resetPwd`, resetPwd:`evaluation/tms/system/resetPwd`,
// 角色权限 // 角色管理
rolePermissionList:`evaluation/sys-permission/rolePermissionList`, batchRemove:`/data/data/role/batchRemove`,
saveRolePermission:`evaluation/sys-permission/saveRolePermission`, getRole:`/data/data/role/get`,
updateRolePermission:`evaluation/sys-permission/updateRolePermission`, getName:`/data/data/role/getName`,
delRolePermission:`evaluation/sys-permission/delRolePermission`, listRole:`/data/data/role/list`,
queryPermissionArrById:`evaluation/sys-permission/queryPermissionArrById`, removeRole:`/data/data/role/remove`,
roleTree:`evaluation/sys-permission/tree`, saveOrUpdate:`/data/data/role/saveOrUpdate`,
// 权限菜单管理
doAssign:`/data/data/permission/doAssign`,
queryPermissionMenu:`/data/data/permission/queryPermissionMenu`,
savePer:`/data/data/permission/save`,
toAssign:`/data/data/permission/toAssign`,
// 表展示 // 表展示
getIdQueryTable:`/data/huoran/data/table/getIdQueryTable`, getIdQueryTable:`/data/huoran/data/table/getIdQueryTable`,
getTableByClassification:`/data/huoran/data/table/getTableByClassification`, getTableByClassification:`/data/huoran/data/table/getTableByClassification`,
getTableByCondition:`/data/huoran/data/table/getTableByCondition`, getTableByCondition:`/data/huoran/data/table/getTableByCondition`,
downloadData:`/data/data/download`, downloadData:`${host1}/data/data/download`,
previewData:`${host1}/data/data/preview`, previewData:`${host1}/data/data/preview`,
downloadRecord:`${host1}/data/huoran/data/myDownload/downloadRecord`,
getDownloadRecord:`${host1}/data/huoran/data/myDownload/getDownloadRecord`,
downloadAgain:`${host1}/data/data/downloadAgain`,
} }

@ -41,17 +41,14 @@ export default {
} }
}; };
}, },
computed: { watch: {
onRoutes() { '$route'(to,from) {
let actives = this.actives let actives = this.actives
for(let i in this.actives){ for(let i in this.actives){
if(actives[i].includes(this.$route.name)) return `/${i}/list` if(actives[i].includes(this.$route.name)) this.active = `/${i}/list`
} }
return this.$route.path this.active = this.$route.path
}, }
...mapState('auth', [
'routes'
])
}, },
created() { created() {
this.initMenu() this.initMenu()

@ -105,16 +105,16 @@ const util = {
x.send() x.send()
}, },
// 成功提示 // 成功提示
successMsg(message) { successMsg(message,duration = 3000) {
Message.success({message,showClose: true,offset: (document.documentElement.clientHeight - 40) / 2,duration: 3000}) Message.success({message,showClose: true,offset: (document.documentElement.clientHeight - 40) / 2,duration})
}, },
// 警告提示 // 警告提示
warningMsg(message) { warningMsg(message,duration = 3000) {
Message.warning({message,showClose: true,offset: (document.documentElement.clientHeight - 40) / 2,duration: 3000}) Message.warning({message,showClose: true,offset: (document.documentElement.clientHeight - 40) / 2,duration})
}, },
// 错误提示 // 错误提示
errorMsg(message) { errorMsg(message,duration = 3000) {
Message.error({message,showClose: true,offset: (document.documentElement.clientHeight - 40) / 2,duration: 3000}) Message.error({message,showClose: true,offset: (document.documentElement.clientHeight - 40) / 2,duration})
}, },
} }

@ -71,7 +71,7 @@
<h6 class="title">数据介绍</h6> <h6 class="title">数据介绍</h6>
<div class="desc">{{introduce}}</div> <div class="desc">{{introduce}}</div>
<el-table :data="listData" class="table" stripe header-align="center" row-key="id"> <el-table :data="listData" class="table" ref="table" stripe header-align="center" row-key="id">
<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"></el-table-column> <el-table-column prop="showName" label="数据表名称" 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>
@ -94,11 +94,8 @@
<el-table :data="previewData" class="table" stripe header-align="center" row-key="id"> <el-table :data="previewData" class="table" stripe header-align="center" row-key="id">
<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 v-for="(item,index) in previewHead" :prop="item.field" :label="item.comment" align="center"></el-table-column> <el-table-column v-for="(item,index) in previewHead" :prop="item.field" :key="index" :label="item.comment" align="center"></el-table-column>
</el-table> </el-table>
<div class="pagination">
<el-pagination background @current-change="handlePreviewCurrentChange" :current-page="pagePreview" layout="total, prev, pager, next" :total="totalPreview"></el-pagination>
</div>
</div> </div>
</div> </div>
@ -106,8 +103,9 @@
<el-form ref="form" label-width="100px" label-suffix=""> <el-form ref="form" label-width="100px" label-suffix="">
<el-form-item label="数据筛选"> <el-form-item label="数据筛选">
<div class="checkboxs"> <div class="checkboxs">
<el-checkbox v-model="checkAllFields" @change="checkAllFieldsChange">全选</el-checkbox>
<el-checkbox-group v-model="fields"> <el-checkbox-group v-model="fields">
<el-checkbox v-for="(item,index) in previewHead" :key="index" :label="item.comment"></el-checkbox> <el-checkbox v-for="(item,index) in fieldsList" :key="index" :label="item.comment"></el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</div> </div>
</el-form-item> </el-form-item>
@ -151,8 +149,10 @@ export default {
pageSizePreview: 10, pageSizePreview: 10,
totalPreview: 0, totalPreview: 0,
downloadVisible: false, downloadVisible: false,
tableName: '', curRow: {},
checkAllFields: false,
fields: [], fields: [],
fieldsList: [],
startTime: '', startTime: '',
endTime: '', endTime: '',
frequency: '', frequency: '',
@ -174,19 +174,15 @@ export default {
name: '年频' name: '年频'
}, },
], ],
fieldList: [
{
id: 1,
name: '代码'
},{
id: 2,
name: '名称'
}
],
} }
}, },
mounted() { mounted() {
this.getType() this.getType()
if(this.$route.query.download){
this.download({
name: this.$route.query.name
})
}
}, },
methods: { methods: {
getType(){ getType(){
@ -194,7 +190,10 @@ export default {
res.map(n => { res.map(n => {
n.id = String(n.id) n.id = String(n.id)
n.children.map(n => { n.children.map(n => {
n.id = String(n.id) n.id = String(n.id)
n.children.map(n => {
n.id = String(n.id)
})
}) })
}) })
this.typeList = res this.typeList = res
@ -208,20 +207,7 @@ export default {
}).catch(res => {}) }).catch(res => {})
}, },
getData(){ getData(){
let data = { this.$post(`${this.api.getIdQueryTable}?categoryId=${this.active}&showName=&pageNum=${this.page}&pageSize=${this.pageSize}&updateTime=`).then(res => {
endTime: '',
fields: [],
frequency: '',
startTime: '',
tableName: '',
}
// util.successMsg('')
// location.href = 'http://192.168.31.125:8888/data/data/download?endTime=&frequency=&startTime=&tableName='
// this.$get(this.api.download,data).then(res => {
// }).catch(res => {})
this.$post(`${this.api.getIdQueryTable}?categoryId=${this.active}&showName=&pageNum=${this.page}&pageSize=${this.pageSize}`).then(res => {
this.listData = res.list this.listData = res.list
this.total = res.totalCount this.total = res.totalCount
}).catch(res => {}) }).catch(res => {})
@ -236,40 +222,50 @@ export default {
this.introduce = this.typeList.find(n => n.id == indexPath[0]).introduce this.introduce = this.typeList.find(n => n.id == indexPath[0]).introduce
this.previewHead = [] this.previewHead = []
this.previewData = [] this.previewData = []
this.getData() this.page = 1
},
handlePreviewCurrentChange(val) {
this.pagePreview = val
this.$refs.table.clearSelection()
this.getData() this.getData()
}, },
preview(row){ preview(row){
this.$get(`${this.api.previewData}?tableName=${row.name}`).then(res => { this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => {
let comment = res.comment let comment = res.comment
let previewHead = [] let previewHead = []
comment.map(n => { comment.map(n => {
n.field != 'id' && n.field != 'operation_time' && previewHead.push(n) n.field != 'id' && n.field != 'operation_time' && previewHead.push(n)
}) })
this.previewHead = previewHead this.previewHead = previewHead
this.previewData = res.data
let data = res.data
data.map(n => {
for(let i in n){
if(typeof n[i] == 'string' && n[i].endsWith('+0000')) n[i] = util.formatDate('yyyy-MM-dd hh:mm:ss',new Date(n[i]))
}
})
this.previewData = data
}).catch(res => {}) }).catch(res => {})
}, },
checkAllFieldsChange(val) {
this.fields = val ? this.fieldsList.map(n => n.comment) : []
},
download(row){ download(row){
this.tableName = row.name this.curRow = row
this.downloadVisible = true this.downloadVisible = true
this.$get(`${this.api.previewData}?tableName=${row.name}`).then(res => {
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => {
let comment = res.comment let comment = res.comment
let previewHead = [] let fieldsList = []
comment.map(n => { comment.map(n => {
n.field != 'id' && n.field != 'operation_time' && previewHead.push(n) n.field != 'id' && n.field != 'operation_time' && fieldsList.push(n)
}) })
this.previewHead = previewHead this.fieldsList = fieldsList
}).catch(res => {}) }).catch(res => {})
}, },
closeDownload(){ closeDownload(){
this.checkAllFields = false
this.fields = []
this.startTime = ''
this.endTime = ''
this.frequency = ''
this.$router.push('/data')
}, },
handleOpen(){ handleOpen(){
@ -278,17 +274,72 @@ export default {
}, },
confirmDown(){ confirmDown(){
// return console.log(this.startTime,this.endTime)
let fields = this.fields let fields = this.fields
if(!fields.length) 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
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)
}
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 newFields = []
let previewHead = this.previewHead let fieldsList = this.fieldsList
fields.map(n => { fields.map(n => {
newFields.push(`fields=${previewHead.find(e => e.comment == n).field}`) newFields.push(`fields=${fieldsList.find(e => e.comment == n).field}`)
}) })
// return console.log(this.fields,newFields) util.successMsg('数据正在生成中,请稍等片刻,生成后会自动下载,您可以先访问其他页面。',5000)
this.$get(`${this.api.downloadData}?tableName=${this.tableName}&${newFields.join('&')}&startTime=${this.startTime}&endTime=${this.endTime}&frequency=${this.frequency}`).then(res => { this.downloadVisible = false
}).catch(res => {}) 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}&${newFields.join('&')}&startTime=${startTime}&endTime=${endTime}&frequency=${frequency}`,{
responseType: 'blob'
}).then((res) => {
console.log(22,res.data)
const blob = new Blob([res.data])
const fileName = `${this.curRow.showName}.xls`
if ('download' in document.createElement('a')) { // IE
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // URL
document.body.removeChild(elink)
} else { // IE10+
navigator.msSaveBlob(blob, fileName)
}
this.$get(`${this.api.downloadRecord}?platformUserId=4&tableId=${this.curRow.id}&${newFields.join('&')}&startTime=${startTime}&endTime=${endTime}&frequency=${frequency}`).then(res => {}).catch(res => {})
})
} }
} }
}; };
@ -313,6 +364,7 @@ export default {
} }
.right{ .right{
flex: 1; flex: 1;
max-width: calc(100% - 220px);
.block{ .block{
padding: 34px; padding: 34px;
margin-bottom: 20px; margin-bottom: 20px;

@ -1,37 +1,37 @@
<template> <template>
<div class="wrap" :class="{result: keyword}"> <div class="wrap" :class="{result: keyword}">
<div class="title" v-if="!keyword">欢迎来到<br>或然数据网</div> <div class="title" v-if="!keyword">欢迎来到<br>或然数据网</div>
<div class="search"> <div class="search">
<div class="input"> <div class="input">
<img v-if="keyword" src="../../../assets/img/search-gray.png" alt=""> <img v-if="keyword" src="../../../assets/img/search-gray.png" alt="">
<img v-else src="../../../assets/img/search-white.png" alt=""> <img v-else src="../../../assets/img/search-white.png" alt="">
<input v-model="keyword" type="text" placeholder="请输入关键词"> <input v-model="keyword" type="text" placeholder="请输入关键词">
</div>
<img v-if="keyword" src="../../../assets/img/remove-gray.png" alt="" class="remove" @click="keyword = ''">
</div> </div>
<img v-if="keyword" src="../../../assets/img/remove-gray.png" alt="" class="remove" @click="keyword = ''">
</div>
<template v-if="keyword"> <template v-if="keyword">
<div class="tips"> <div class="tips">
<p class="result">搜索结果</p> <p class="result">搜索结果</p>
<p class="num">搜索完成共有{{total}}个结果匹配</p> <p class="num">搜索完成共有{{total}}个结果匹配</p>
</div> </div>
<el-table :data="listData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange"> <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"></el-table-column> <el-table-column prop="showName" label="数据表名称" 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> <el-table-column prop="dataSize" label="数据大小" align="center"></el-table-column>
<el-table-column prop="updateTime" label="更新时间" align="center"></el-table-column> <el-table-column prop="updateTime" label="更新时间" align="center"></el-table-column>
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="download(scope.row)">下载</el-button> <el-button type="text" @click="download(scope.row)">下载</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="pagination"> <div class="pagination">
<el-pagination background @current-change="handleCurrentChange" :current-page="page" layout="total, prev, pager, next" :total="total"></el-pagination> <el-pagination background @current-change="handleCurrentChange" :current-page="page" layout="total, prev, pager, next" :total="total"></el-pagination>
</div> </div>
</template> </template>
</div> </div>
</template> </template>
@ -57,7 +57,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.initData()
}, },
methods: { methods: {
getData(){ getData(){
@ -76,7 +76,7 @@ export default {
this.getData() this.getData()
}, },
download(row){ download(row){
this.$router.push(`/data?download=true&name=${row.name}`)
} }
} }
}; };

@ -15,7 +15,7 @@
</div> </div>
</div> </div>
<el-table :data="roleData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange" :row-key="getRowKeys"> <el-table :data="listData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange" row-key="id">
<el-table-column type="selection" width="80" align="center" :reserve-selection="true"></el-table-column> <el-table-column type="selection" width="80" align="center" :reserve-selection="true"></el-table-column>
<el-table-column type="index" width="100" label="序号" align="center"> <el-table-column type="index" width="100" label="序号" align="center">
</el-table-column> </el-table-column>
@ -51,15 +51,7 @@
</el-form-item> </el-form-item>
<el-form-item prop="role" label="角色权限"> <el-form-item prop="role" label="角色权限">
<div class="per-wrap"> <div class="per-wrap">
<el-tree <el-tree ref="per" :data="permissions" show-checkbox node-key="id" :default-expanded-keys="checkedIds" :default-checked-keys="checkedIds" :props="defaultProps"></el-tree>
ref="per"
:data="permissions"
show-checkbox
node-key="id"
:default-expanded-keys="checkedIds"
:default-checked-keys="checkedIds"
:props="defaultProps">
</el-tree>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -80,6 +72,7 @@ export default {
name: 'role', name: 'role',
data() { data() {
return { return {
clientId: 0,
keyword: '', keyword: '',
form: { form: {
roleName : '', roleName : '',
@ -87,7 +80,7 @@ export default {
id: '' id: ''
}, },
isDetail: false, isDetail: false,
roleData:[], listData:[],
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'name' label: 'name'
@ -106,7 +99,7 @@ export default {
}, },
computed: { computed: {
...mapState('user', [ ...mapState('user', [
'userId','clientId' 'userId'
]) ])
}, },
watch: { watch: {
@ -128,14 +121,14 @@ export default {
if(this.keyword.length){ if(this.keyword.length){
data.name = this.keyword data.name = this.keyword
} }
this.$get(`${this.api.queryRoles}/${this.page}/${this.pageSize}`,data).then(res => { this.$get(`${this.api.listRole}/${this.page}/${this.pageSize}?name=${this.keyword}&clientId=`).then(res => {
this.roleData = res.data.items this.listData = res.items
this.total = res.data.total this.total = res.total
if(!this.roleData.length && this.total){ if(!this.listData.length && this.total){
this.page-- this.page--
this.getData() this.getData()
} }
}).catch(res => {}); }).catch(res => {})
}, },
initData(){ initData(){
this.page = 1 this.page = 1
@ -159,7 +152,7 @@ export default {
getPer(){ getPer(){
if(!this.permissions.length){ if(!this.permissions.length){
this.$get(this.api.queryPermissionMenu).then(res => { this.$get(this.api.queryPermissionMenu).then(res => {
this.permissions = res.data.children[0].children this.permissions = res[0].children
}).catch(res => {}) }).catch(res => {})
} }
}, },
@ -184,15 +177,15 @@ export default {
}, },
async getDetail(row){ async getDetail(row){
this.getPer() this.getPer()
let roleRes = await this.$get(`${this.api.getRole}/${row.id}`) this.$get(`${this.api.getRole}/${row.id}`).then(res => {
if(roleRes.success){ this.form = res
this.form = roleRes.data.item this.$get(this.api.toAssign,{
let perRes = await this.$get(`${this.api.toAssign}/${row.id}`) roleId: row.id
if(perRes.success){ }).then(res => {
this.checkedIds = this.handleRolePer(perRes.data.rolePermissions,this.permissions) this.checkedIds = this.handleRolePer(res,this.permissions)
this.$refs.per.setCheckedNodes(this.checkedIds) this.$refs.per.setCheckedNodes(this.checkedIds)
} }).catch(res => {})
} }).catch(res => {})
}, },
showRole(row){ showRole(row){
this.isDetail = true this.isDetail = true
@ -209,49 +202,41 @@ export default {
if(!this.form.roleName) return util.warningMsg('请填写角色名称') if(!this.form.roleName) return util.warningMsg('请填写角色名称')
if(!this.form.remark) return util.warningMsg('请填写角色描述') if(!this.form.remark) return util.warningMsg('请填写角色描述')
// if(!this.$refs.per.getCheckedKeys().length) return util.warningMsg('') // if(!this.$refs.per.getCheckedKeys().length) return util.warningMsg('')
let roleData = {
let data = {
clientId: this.clientId, clientId: this.clientId,
id: this.form.id, id: this.form.id,
roleName: this.form.roleName, roleName: this.form.roleName,
remark: this.form.remark, remark: this.form.remark,
isPort: 2 isPort: 2
} }
let roleRes = await this.$post(this.api.saveOrUpdate,roleData) this.$post(this.api.saveOrUpdate,data).then(res => {
if(roleRes.success){
let permissionId = [...this.$refs.per.getHalfCheckedKeys(),...this.$refs.per.getCheckedKeys()] let permissionId = [...this.$refs.per.getHalfCheckedKeys(),...this.$refs.per.getCheckedKeys()]
let perData = { let perData = {
clientId: this.clientId, roleId: res.roleId,
roleId: roleRes.data.roleId,
permissionId, permissionId,
isPort: 2 isPort: 2
} }
let perRes = await this.$post(this.api.doAssign,perData) this.$post(this.api.doAssign,perData).then(res => {
if(perRes.success){ // console.log(333)
util.successMsg('新增成功') util.successMsg('新增成功')
this.getData() this.getData()
this.roleVisible = false this.roleVisible = false
} }).catch(res => {})
} }).catch(res => {})
}, },
handleDelete(row) { handleDelete(row) {
this.$confirm('该角色下已有账号,删除角色会将该角色下的账号一并删除,是否继续删除?', '提示', { this.$confirm('该角色下已有账号,删除角色会将该角色下的账号一并删除,是否继续删除?', '提示', {
type: 'warning' type: 'warning'
}) }).then(() => {
.then(() => { this.$post(`${this.api.removeRole}/${row.id}`).then(res => {
this.$del(`${this.api.removeRole}?roleIds=${row.id}`).then(res => { util.successMsg('删除成功')
if(res.success){ this.getData()
util.successMsg('删除成功');
this.getData()
}
}).catch(res => {}) }).catch(res => {})
}) }).catch(() => {})
.catch(() => {});
},
getRowKeys(row) {
return row.id;
}, },
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val
}, },
delAllSelection() { delAllSelection() {
if(this.multipleSelection.length != ''){ if(this.multipleSelection.length != ''){
@ -260,18 +245,15 @@ export default {
return item.id return item.id
}) })
// //
this.$confirm(`此批量删除操作不可逆,是否确认删除${util.ellipsisStr(newArr[0].roleName)}${newArr.length}个选中项`, '提示', { this.$confirm(`此批量删除操作不可逆,是否确认删除?`, '提示', {
type: 'warning' type: 'warning'
}) }).then(() => {
.then(() => { this.$post(`${this.api.batchRemove}?roleIds=${delList.join()}`).then(res => {
this.$del(`${this.api.removeRole}?roleIds=${delList.join()}`).then(res => { this.$refs.table.clearSelection()
if(res.success){ util.successMsg('删除成功')
this.$refs.table.clearSelection() this.getData()
util.successMsg('删除成功')
this.getData()
}
}).catch(res => {}) }).catch(res => {})
}).catch(() => {}); }).catch(() => {})
}else{ }else{
util.errorMsg('请先选择数据 !') util.errorMsg('请先选择数据 !')
} }
@ -281,13 +263,6 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.no-mb /deep/.el-form-item{
margin-bottom: 0;
}
/deep/.el-row{
padding: 0 !important;
margin-bottom: 0;
}
.per-wrap{ .per-wrap{
max-height: 400px; max-height: 400px;
overflow: auto; overflow: auto;

@ -8,17 +8,17 @@
</li> </li>
</ul> </ul>
<el-table :data="listData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange"> <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="roleName" label="数据名称" align="center"></el-table-column> <el-table-column prop="databaseType" label="数据类型" width="100" align="center"></el-table-column>
<el-table-column prop="roleName" label="数据表名称" align="center"></el-table-column> <el-table-column prop="databaseName" label="数据表名称" align="center"></el-table-column>
<el-table-column prop="roleName" label="数据总量" align="center"></el-table-column> <el-table-column prop="dataTotal" label="数据总量" align="center"></el-table-column>
<el-table-column prop="roleName" label="数据大小" align="center"></el-table-column> <el-table-column prop="dataSize" label="数据大小" align="center"></el-table-column>
<el-table-column prop="roleName" label="更新时间" align="center"></el-table-column> <el-table-column prop="updateTime" label="更新时间" width="150" align="center"></el-table-column>
<el-table-column prop="roleName" label="下载时间" align="center"></el-table-column> <el-table-column prop="downloadTime" label="下载时间" width="150" align="center"></el-table-column>
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="showRole(scope.row)">再次下载</el-button> <el-button type="text" @click="download(scope.row)">再次下载</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -32,6 +32,7 @@
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'
import util from '@/libs/util' import util from '@/libs/util'
import axios from 'axios'
export default { export default {
name: 'role', name: 'role',
data() { data() {
@ -64,33 +65,40 @@ export default {
}, },
methods: { methods: {
getData() { getData() {
let data = { this.$get(`${this.api.getDownloadRecord}?platformUserId=4&pageNum=${this.page}&pageSize=${this.pageSize}&name=${this.keyword}`).then(res => {
clientId: this.clientId this.listData = res.records
} this.total = res.total
if(this.keyword.length){ }).catch(res => {})
data.name = this.keyword
}
this.$get(`${this.api.queryRoles}/${this.page}/${this.pageSize}`,data).then(res => {
this.listData = res.data.items
this.total = res.data.total
if(!this.listData.length && this.total){
this.page--
this.getData()
}
}).catch(res => {});
}, },
initData(){ initData(){
this.page = 1 this.page = 1
this.getData() this.getData()
}, },
handleSelectionChange(val) {
this.multipleSelection = val
},
handleCurrentChange(val) { handleCurrentChange(val) {
this.page = val this.page = val
this.$refs.table.clearSelection() this.$refs.table.clearSelection()
this.getData() this.getData()
}, },
download(row){
axios.get(`${this.api.downloadAgain}?table_id=${row.id}&fields=${row.fields}&startTime=${row.startTime ? row.startTime : ''}&endTime=${row.endTime ? row.endTime : ''}&frequency=${row.frequency ? row.frequency : ''}`,{
responseType: 'blob'
}).then(res => {
const blob = new Blob([res.data])
const fileName = `${row.databaseName}.xls`
if ('download' in document.createElement('a')) { // IE
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // URL
document.body.removeChild(elink)
} else { // IE10+
navigator.msSaveBlob(blob, fileName)
}
}).catch(res => {})
}
} }
}; };
</script> </script>

@ -9,7 +9,7 @@ const service = axios.create({
}) })
// post请求头 // post请求头
service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'; service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
// 请求拦截器 // 请求拦截器
// service.interceptors.request.use(config => { // service.interceptors.request.use(config => {
@ -78,27 +78,26 @@ service.interceptors.response.use(
redirect: router.currentRoute.fullPath redirect: router.currentRoute.fullPath
} }
}); });
}, 1000); }, 1000)
break; break;
// 404请求不存在 // 404请求不存在
case 404: case 404:
router.replace({ router.replace({
path: '/404', path: '/404',
}); })
break; break;
// 其他错误,直接抛出错误提示 // 其他错误,直接抛出错误提示
default: default:
Promise.reject(res) Promise.reject(res)
} }
return Promise.reject(error.res); return Promise.reject(error.res)
} }
} }
); );
function get(url, params){ function get(url, params){
return new Promise((resolve, reject) =>{ return new Promise((resolve, reject) =>{
service.get(url, {params: params}) service.get(url, {params: params}).then(res => {
.then(res => {
if(res){ if(res){
resolve(res) resolve(res)
}else{ }else{
@ -112,13 +111,12 @@ function get(url, params){
function post(url, params){ function post(url, params){
return new Promise((resolve, reject) =>{ return new Promise((resolve, reject) =>{
service.post(url,params) service.post(url,params).then(res => {
.then(res => { // if(res){
if(res){
resolve(res) resolve(res)
}else{ // }else{
reject() // reject()
} // }
}).catch(err => { }).catch(err => {
reject(err.data) reject(err.data)
}) })
@ -129,8 +127,7 @@ function del(url, params){
return new Promise((resolve, reject) =>{ return new Promise((resolve, reject) =>{
service.delete(url, { service.delete(url, {
params params
}) }).then(res => {
.then(res => {
if(res){ if(res){
resolve(res) resolve(res)
}else{ }else{
@ -146,8 +143,7 @@ function put(url, params){
return new Promise((resolve, reject) =>{ return new Promise((resolve, reject) =>{
service.put(url, { service.put(url, {
params params
}) }).then(res => {
.then(res => {
if(res){ if(res){
resolve(res) resolve(res)
}else{ }else{

@ -16,7 +16,7 @@ const Setting = {
showProgressBar: true, showProgressBar: true,
// 接口请求地址 // 接口请求地址
// apiBaseURL: env === 'development' ? 'http://192.168.31.125:8888' : 'http://39.108.250.202:8000', // apiBaseURL: env === 'development' ? 'http://192.168.31.125:8888' : 'http://39.108.250.202:8000',
apiBaseURL: env === 'development' ? 'http://192.168.31.216:8888' : 'http://www.liuwanr.cn', apiBaseURL: env === 'development' ? 'http://192.168.31.151:10001' : 'http://www.liuwanr.cn',
// 接口请求返回错误时,弹窗的持续时间,单位:秒 // 接口请求返回错误时,弹窗的持续时间,单位:秒
modalDuration: 3, modalDuration: 3,
// 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice

Loading…
Cancel
Save