forked from github/dataease
feat: 调整response返回值
This commit is contained in:
parent
60d0146518
commit
71195722f8
@ -25,7 +25,10 @@ export default {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
title: String
|
||||
title: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cancel() {
|
||||
|
@ -37,7 +37,7 @@ router.beforeEach(async(to, from, next) => {
|
||||
store.dispatch('user/getInfo').then(() => {
|
||||
loadMenus(next, to)
|
||||
}).catch(() => {
|
||||
store.dispatch('logout').then(() => {
|
||||
store.dispatch('user/logout').then(() => {
|
||||
location.reload() // 为了重新实例化vue-router对象 避免bug
|
||||
})
|
||||
})
|
||||
@ -65,7 +65,7 @@ router.beforeEach(async(to, from, next) => {
|
||||
})
|
||||
export const loadMenus = (next, to) => {
|
||||
buildMenus().then(res => {
|
||||
const asyncRouter = filterAsyncRouter(res.data.data)
|
||||
const asyncRouter = filterAsyncRouter(res.data)
|
||||
asyncRouter.push({ path: '*', redirect: '/404', hidden: true })
|
||||
store.dispatch('permission/GenerateRoutes', asyncRouter).then(() => { // 存储路由
|
||||
router.addRoutes(asyncRouter)
|
||||
|
@ -46,7 +46,7 @@ const actions = {
|
||||
const { username, password } = userInfo
|
||||
return new Promise((resolve, reject) => {
|
||||
login({ username: username.trim(), password: password }).then(response => {
|
||||
const { data } = response.data
|
||||
const { data } = response
|
||||
commit('SET_TOKEN', data.token)
|
||||
setToken(data.token)
|
||||
resolve()
|
||||
@ -60,7 +60,7 @@ const actions = {
|
||||
getInfo({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getInfo(state.token).then(response => {
|
||||
const { data } = response.data
|
||||
const { data } = response
|
||||
|
||||
if (!data) {
|
||||
reject('Verification failed, please Login again.')
|
||||
|
@ -98,7 +98,7 @@ service.interceptors.response.use(
|
||||
// 请根据实际需求修改
|
||||
service.interceptors.response.use(response => {
|
||||
checkAuth(response)
|
||||
return response
|
||||
return response.data
|
||||
}, error => {
|
||||
let msg
|
||||
if (error.response) {
|
||||
|
@ -23,6 +23,7 @@
|
||||
export default {
|
||||
name: 'DatasetTableData',
|
||||
props: {
|
||||
// eslint-disable-next-line vue/require-default-prop
|
||||
table: Object
|
||||
},
|
||||
data() {
|
||||
|
@ -462,7 +462,7 @@ export default {
|
||||
|
||||
tree(group) {
|
||||
groupTree(group).then(res => {
|
||||
this.tData = res.data.data
|
||||
this.tData = res.data
|
||||
})
|
||||
},
|
||||
|
||||
@ -473,7 +473,7 @@ export default {
|
||||
sort: 'type asc,create_time desc,name asc',
|
||||
sceneId: this.currGroup.id
|
||||
}).then(res => {
|
||||
this.tableData = res.data.data
|
||||
this.tableData = res.data
|
||||
})
|
||||
}
|
||||
},
|
||||
@ -555,7 +555,7 @@ export default {
|
||||
this.sceneMode = true
|
||||
const sceneId = this.$store.state.dataset.sceneData
|
||||
getScene(sceneId).then(res => {
|
||||
this.currGroup = res.data.data
|
||||
this.currGroup = res.data
|
||||
})
|
||||
} else {
|
||||
this.$router.push('/dataset')
|
||||
|
@ -361,7 +361,7 @@ export default {
|
||||
},
|
||||
initTableData() {
|
||||
dsGrid(this.currentPage, this.pageSize, this.condition).then(response => {
|
||||
const data = response.data.data
|
||||
const data = response.data
|
||||
this.tableData = data.listObject
|
||||
this.total = data.itemCount
|
||||
})
|
||||
|
@ -218,7 +218,9 @@ export default {
|
||||
treeByArr(arr) {
|
||||
if (!Array.isArray(arr) || !arr.length) return
|
||||
const map = {}
|
||||
arr.forEach(item => map[item.id] = item)
|
||||
arr.forEach(item => {
|
||||
map[item.id] = item
|
||||
})
|
||||
|
||||
const roots = []
|
||||
arr.forEach(item => {
|
||||
@ -236,7 +238,7 @@ export default {
|
||||
const _self = this
|
||||
const pid = row ? row.deptId : '0'
|
||||
getDeptTree(pid).then(response => {
|
||||
let data = response.data.data
|
||||
let data = response.data
|
||||
data = data.map(obj => {
|
||||
if (obj.subCount > 0) {
|
||||
obj.hasChildren = true
|
||||
@ -244,7 +246,9 @@ export default {
|
||||
return obj
|
||||
})
|
||||
if (!row) {
|
||||
data.some(node => node.children = null)
|
||||
data.some(node => {
|
||||
node.children = null
|
||||
})
|
||||
_self.tableData = data
|
||||
_self.depts = null
|
||||
} else {
|
||||
@ -267,7 +271,7 @@ export default {
|
||||
if (action === LOAD_ROOT_OPTIONS) {
|
||||
const _self = this
|
||||
!this.depts && getDeptTree('0').then(res => {
|
||||
_self.depts = res.data.data.map(node => _self.normalizer(node))
|
||||
_self.depts = res.data.map(node => _self.normalizer(node))
|
||||
callback()
|
||||
})
|
||||
}
|
||||
@ -275,7 +279,7 @@ export default {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.data.map(function(obj) {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
return _self.normalizer(obj)
|
||||
})
|
||||
callback()
|
||||
@ -375,7 +379,9 @@ export default {
|
||||
array2Tree(arr) {
|
||||
if (!Array.isArray(arr) || !arr.length) return
|
||||
const map = {}
|
||||
arr.forEach(item => map[item.id] = item)
|
||||
arr.forEach(item => {
|
||||
map[item.id] = item
|
||||
})
|
||||
|
||||
const roots = []
|
||||
arr.forEach(item => {
|
||||
|
@ -284,7 +284,7 @@ export default {
|
||||
const pid = row ? row.menuId : '0'
|
||||
|
||||
getMenusTree(pid).then(response => {
|
||||
let data = response.data.data
|
||||
let data = response.data
|
||||
data = data.map(obj => {
|
||||
if (obj.subCount > 0) {
|
||||
obj.hasChildren = true
|
||||
@ -316,7 +316,7 @@ export default {
|
||||
if (action === LOAD_ROOT_OPTIONS) {
|
||||
const _self = this
|
||||
!this.menus && getMenusTree('0').then(res => {
|
||||
_self.menus = res.data.data.map(node => _self.normalizer(node))
|
||||
_self.menus = res.data.map(node => _self.normalizer(node))
|
||||
callback()
|
||||
})
|
||||
}
|
||||
@ -324,7 +324,7 @@ export default {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
const _self = this
|
||||
getMenusTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.data.map(function(obj) {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
return _self.normalizer(obj)
|
||||
})
|
||||
callback()
|
||||
|
@ -142,7 +142,7 @@ export default {
|
||||
},
|
||||
search() {
|
||||
roleGrid(this.currentPage, this.pageSize, this.condition).then(response => {
|
||||
const data = response.data.data
|
||||
const data = response.data
|
||||
this.total = data.itemCount
|
||||
this.tableData = data.listObject
|
||||
})
|
||||
@ -178,7 +178,7 @@ export default {
|
||||
getMenuDatas(node, resolve) {
|
||||
const pid = node.data.id ? node.data.id : '0'
|
||||
getMenusTree(pid).then(res => {
|
||||
const datas = res.data.data
|
||||
const datas = res.data
|
||||
const nodes = datas.map(data => this.formatNode(data))
|
||||
resolve && resolve(nodes)
|
||||
})
|
||||
@ -194,7 +194,7 @@ export default {
|
||||
},
|
||||
menuChange(menu) {
|
||||
getChild(menu.id).then(res => {
|
||||
const childIds = res.data.data
|
||||
const childIds = res.data
|
||||
if (this.menuIds.indexOf(menu.id) !== -1) {
|
||||
for (let i = 0; i < childIds.length; i++) {
|
||||
const index = this.menuIds.indexOf(childIds[i])
|
||||
|
@ -346,7 +346,7 @@ export default {
|
||||
},
|
||||
search() {
|
||||
userLists(this.currentPage, this.pageSize, this.condition).then(response => {
|
||||
const data = response.data.data
|
||||
const data = response.data
|
||||
this.total = data.itemCount
|
||||
this.tableData = data.listObject
|
||||
})
|
||||
@ -380,7 +380,7 @@ export default {
|
||||
if (action === LOAD_ROOT_OPTIONS) {
|
||||
const _self = this
|
||||
!this.depts && getDeptTree('0').then(res => {
|
||||
_self.depts = res.data.data.map(node => _self.normalizer(node))
|
||||
_self.depts = res.data.map(node => _self.normalizer(node))
|
||||
callback()
|
||||
})
|
||||
}
|
||||
@ -388,7 +388,7 @@ export default {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.data.map(function(obj) {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
return _self.normalizer(obj)
|
||||
})
|
||||
callback()
|
||||
@ -421,7 +421,7 @@ export default {
|
||||
},
|
||||
allRoles() {
|
||||
allRoles().then(res => {
|
||||
this.roles = res.data.data
|
||||
this.roles = res.data
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ export default {
|
||||
const { currentPage, pageSize } = this.paginationConfig
|
||||
userLists(currentPage, pageSize, {}).then(response => {
|
||||
this.data = response.data.data.listObject
|
||||
this.paginationConfig.total = response.data.data.itemCount
|
||||
this.paginationConfig.total = response.data.itemCount
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user