提交 71195722 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat: 调整response返回值

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