Skip to content

Commit bccddc6

Browse files
authored
Admin; 如果请求异常导致的 Cannot read property 异常 (#383)
1 parent c25d4a0 commit bccddc6

File tree

2 files changed

+20
-33
lines changed

2 files changed

+20
-33
lines changed

src/view/admin/group/group-list.vue

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,16 @@ export default {
151151
try {
152152
this.loading = true
153153
res = await Admin.deleteOneGroup(val.row.id)
154-
} catch (e) {
154+
if (res.code < window.MAX_SUCCESS_CODE) {
155+
await this.getAllGroups()
156+
this.$message({
157+
type: 'success',
158+
message: `${res.message}`,
159+
})
160+
}
155161
this.loading = false
156-
console.log(e)
157-
}
158-
if (res.code < window.MAX_SUCCESS_CODE) {
159-
await this.getAllGroups()
160-
this.$message({
161-
type: 'success',
162-
message: `${res.message}`,
163-
})
164-
} else {
162+
} catch (e) {
165163
this.loading = false
166-
this.$message({
167-
type: 'error',
168-
message: `${res.message}`,
169-
})
170164
}
171165
})
172166
},

src/view/admin/user/user-list.vue

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,20 @@ export default {
166166
try {
167167
this.loading = true
168168
res = await Admin.deleteOneUser(val.row.id)
169-
} catch (e) {
170-
this.loading = false
171-
console.log(e)
172-
}
173-
if (res.code < window.MAX_SUCCESS_CODE) {
174169
this.loading = false
175-
if (this.total_nums % this.pageCount === 1 && this.currentPage !== 1) {
176-
// 判断删除的是不是每一页的最后一条数据
177-
this.currentPage--
170+
if (res.code < window.MAX_SUCCESS_CODE) {
171+
if (this.total_nums % this.pageCount === 1 && this.currentPage !== 1) {
172+
// 判断删除的是不是每一页的最后一条数据
173+
this.currentPage--
174+
}
175+
await this.getAdminUsers()
176+
this.$message({
177+
type: 'success',
178+
message: `${res.message}`,
179+
})
178180
}
179-
await this.getAdminUsers()
180-
this.$message({
181-
type: 'success',
182-
message: `${res.message}`,
183-
})
184-
} else {
181+
} catch (e) {
185182
this.loading = false
186-
this.$message.error(`${res.message}`)
187183
}
188184
})
189185
},
@@ -259,10 +255,7 @@ export default {
259255
async created() {
260256
await this.getAdminUsers()
261257
this.getAllGroups()
262-
this.tableColumn = [
263-
{ prop: 'username', label: '名称' },
264-
{ prop: 'groupNames', label: '所属分组' },
265-
] // 设置表头信息
258+
this.tableColumn = [{ prop: 'username', label: '名称' }, { prop: 'groupNames', label: '所属分组' }] // 设置表头信息
266259
this.operate = [
267260
{ name: '编辑', func: 'handleEdit', type: 'primary' },
268261
{ name: '删除', func: 'handleDelete', type: 'danger' },

0 commit comments

Comments
 (0)