数据、角色等

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. 62
      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`,
resetPwd:`evaluation/tms/system/resetPwd`,
// 角色权限
rolePermissionList:`evaluation/sys-permission/rolePermissionList`,
saveRolePermission:`evaluation/sys-permission/saveRolePermission`,
updateRolePermission:`evaluation/sys-permission/updateRolePermission`,
delRolePermission:`evaluation/sys-permission/delRolePermission`,
queryPermissionArrById:`evaluation/sys-permission/queryPermissionArrById`,
roleTree:`evaluation/sys-permission/tree`,
// 角色管理
batchRemove:`/data/data/role/batchRemove`,
getRole:`/data/data/role/get`,
getName:`/data/data/role/getName`,
listRole:`/data/data/role/list`,
removeRole:`/data/data/role/remove`,
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`,
getTableByClassification:`/data/huoran/data/table/getTableByClassification`,
getTableByCondition:`/data/huoran/data/table/getTableByCondition`,
downloadData:`/data/data/download`,
downloadData:`${host1}/data/data/download`,
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: {
onRoutes() {
watch: {
'$route'(to,from) {
let actives = 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
},
...mapState('auth', [
'routes'
])
this.active = this.$route.path
}
},
created() {
this.initMenu()

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

@ -71,7 +71,7 @@
<h6 class="title">数据介绍</h6>
<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 prop="showName" 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-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>
<div class="pagination">
<el-pagination background @current-change="handlePreviewCurrentChange" :current-page="pagePreview" layout="total, prev, pager, next" :total="totalPreview"></el-pagination>
</div>
</div>
</div>
@ -106,8 +103,9 @@
<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 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>
</div>
</el-form-item>
@ -151,8 +149,10 @@ export default {
pageSizePreview: 10,
totalPreview: 0,
downloadVisible: false,
tableName: '',
curRow: {},
checkAllFields: false,
fields: [],
fieldsList: [],
startTime: '',
endTime: '',
frequency: '',
@ -174,19 +174,15 @@ export default {
name: '年频'
},
],
fieldList: [
{
id: 1,
name: '代码'
},{
id: 2,
name: '名称'
}
],
}
},
mounted() {
this.getType()
if(this.$route.query.download){
this.download({
name: this.$route.query.name
})
}
},
methods: {
getType(){
@ -194,7 +190,10 @@ export default {
res.map(n => {
n.id = String(n.id)
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
@ -208,20 +207,7 @@ export default {
}).catch(res => {})
},
getData(){
let data = {
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.$post(`${this.api.getIdQueryTable}?categoryId=${this.active}&showName=&pageNum=${this.page}&pageSize=${this.pageSize}&updateTime=`).then(res => {
this.listData = res.list
this.total = res.totalCount
}).catch(res => {})
@ -236,40 +222,50 @@ export default {
this.introduce = this.typeList.find(n => n.id == indexPath[0]).introduce
this.previewHead = []
this.previewData = []
this.getData()
},
handlePreviewCurrentChange(val) {
this.pagePreview = val
this.$refs.table.clearSelection()
this.page = 1
this.getData()
},
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 previewHead = []
comment.map(n => {
n.field != 'id' && n.field != 'operation_time' && previewHead.push(n)
})
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 => {})
},
checkAllFieldsChange(val) {
this.fields = val ? this.fieldsList.map(n => n.comment) : []
},
download(row){
this.tableName = row.name
this.curRow = row
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 previewHead = []
let fieldsList = []
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 => {})
},
closeDownload(){
this.checkAllFields = false
this.fields = []
this.startTime = ''
this.endTime = ''
this.frequency = ''
this.$router.push('/data')
},
handleOpen(){
@ -278,17 +274,72 @@ export default {
},
confirmDown(){
// return console.log(this.startTime,this.endTime)
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 previewHead = this.previewHead
let fieldsList = this.fieldsList
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)
this.$get(`${this.api.downloadData}?tableName=${this.tableName}&${newFields.join('&')}&startTime=${this.startTime}&endTime=${this.endTime}&frequency=${this.frequency}`).then(res => {
util.successMsg('数据正在生成中,请稍等片刻,生成后会自动下载,您可以先访问其他页面。',5000)
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{
flex: 1;
max-width: calc(100% - 220px);
.block{
padding: 34px;
margin-bottom: 20px;

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

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

@ -8,17 +8,17 @@
</li>
</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 prop="roleName" label="数据名称" align="center"></el-table-column>
<el-table-column prop="roleName" label="数据表名称" align="center"></el-table-column>
<el-table-column prop="roleName" label="数据总量" align="center"></el-table-column>
<el-table-column prop="roleName" label="数据大小" align="center"></el-table-column>
<el-table-column prop="roleName" 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="databaseName" 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="updateTime" label="更新时间" width="150" 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">
<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>
</el-table-column>
</el-table>
@ -32,6 +32,7 @@
<script>
import { mapState } from 'vuex'
import util from '@/libs/util'
import axios from 'axios'
export default {
name: 'role',
data() {
@ -64,33 +65,40 @@ export default {
},
methods: {
getData() {
let data = {
clientId: this.clientId
}
if(this.keyword.length){
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 => {});
this.$get(`${this.api.getDownloadRecord}?platformUserId=4&pageNum=${this.page}&pageSize=${this.pageSize}&name=${this.keyword}`).then(res => {
this.listData = res.records
this.total = res.total
}).catch(res => {})
},
initData(){
this.page = 1
this.getData()
},
handleSelectionChange(val) {
this.multipleSelection = val
},
handleCurrentChange(val) {
this.page = val
this.$refs.table.clearSelection()
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>

@ -9,7 +9,7 @@ const service = axios.create({
})
// 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 => {
@ -78,27 +78,26 @@ service.interceptors.response.use(
redirect: router.currentRoute.fullPath
}
});
}, 1000);
}, 1000)
break;
// 404请求不存在
case 404:
router.replace({
path: '/404',
});
})
break;
// 其他错误,直接抛出错误提示
default:
Promise.reject(res)
}
return Promise.reject(error.res);
return Promise.reject(error.res)
}
}
);
function get(url, params){
return new Promise((resolve, reject) =>{
service.get(url, {params: params})
.then(res => {
service.get(url, {params: params}).then(res => {
if(res){
resolve(res)
}else{
@ -112,13 +111,12 @@ function get(url, params){
function post(url, params){
return new Promise((resolve, reject) =>{
service.post(url,params)
.then(res => {
if(res){
service.post(url,params).then(res => {
// if(res){
resolve(res)
}else{
reject()
}
// }else{
// reject()
// }
}).catch(err => {
reject(err.data)
})
@ -129,8 +127,7 @@ function del(url, params){
return new Promise((resolve, reject) =>{
service.delete(url, {
params
})
.then(res => {
}).then(res => {
if(res){
resolve(res)
}else{
@ -146,8 +143,7 @@ function put(url, params){
return new Promise((resolve, reject) =>{
service.put(url, {
params
})
.then(res => {
}).then(res => {
if(res){
resolve(res)
}else{

@ -16,7 +16,7 @@ const Setting = {
showProgressBar: true,
// 接口请求地址
// 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,
// 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice

Loading…
Cancel
Save