Skip to content

Commit 16804d1

Browse files
committed
feat(*): success code less than 9999
1 parent 3bfa6cb commit 16804d1

13 files changed

Lines changed: 37 additions & 34 deletions

File tree

src/components/layout/User.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export default {
277277
})
278278
.then(putRes => {
279279
// eslint-disable-line
280-
if (putRes.error_code < 100) {
280+
if (putRes.error_code < window.SUCCESS_CODE) {
281281
this.$message({
282282
type: 'success',
283283
message: '更新头像成功',
@@ -317,7 +317,8 @@ export default {
317317
},
318318
})
319319
.then(res => {
320-
if (res.error_code < 100) {
320+
debugger
321+
if (res.error_code < window.SUCCESS_CODE) {
321322
this.$message({
322323
type: 'success',
323324
message: '更新昵称成功',
@@ -366,7 +367,7 @@ export default {
366367
// eslint-disable-line
367368
if (valid) {
368369
const res = await User.updatePassword(this.form)
369-
if (res.error_code === 0) {
370+
if (res.error_code < window.SUCCESS_CODE) {
370371
this.$message.success(`${res.msg}`)
371372
this.resetForm(formName)
372373
this.dialogFormVisible = false

src/config/global.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.SUCCESS_CODE = 9999

src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import '@babel/polyfill'
22
import Vue from 'vue'
33
import ElementUI from 'element-ui'
44

5+
import '@/config/global'
56
import '@/lin/mixin'
67
import '@/lin/filter'
78
import '@/lin/plugins'

src/views/admin/group/GroupAdd.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default {
9191
this.loading = false
9292
console.log(e)
9393
}
94-
if (res.error_code === 0) {
94+
if (res.error_code < window.SUCCESS_CODE) {
9595
this.loading = false
9696
this.$message.success(`${res.msg}`)
9797
this.eventBus.$emit('addGroup', true)

src/views/admin/group/GroupList.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export default {
124124
if (this.cacheForm.name !== this.form.name || this.cacheForm.info !== this.form.info) {
125125
// eslint-disable-line
126126
const res = await Admin.updateOneGroup(this.form.name, this.form.info, this.id)
127-
if (res.error_code === 0) {
127+
if (res.error_code < window.SUCCESS_CODE) {
128128
this.$message.success(`${res.msg}`)
129129
this.getAllGroups()
130130
}
@@ -150,7 +150,7 @@ export default {
150150
if (deletePermissions.length > 0) {
151151
delRes = await Admin.removePermissions(this.id, deletePermissions)
152152
}
153-
if (addRes.error_code === 0 || delRes.error_code === 0) {
153+
if (addRes.error_code < window.SUCCESS_CODE || delRes.error_code < window.SUCCESS_CODE) {
154154
this.$message.success('权限修改成功')
155155
}
156156
}
@@ -191,7 +191,7 @@ export default {
191191
this.loading = false
192192
console.log(e)
193193
}
194-
if (res.error_code === 0) {
194+
if (res.error_code < window.SUCCESS_CODE) {
195195
await this.getAllGroups()
196196
this.$message({
197197
type: 'success',

src/views/admin/user/UserInfo.vue

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@
3535
<el-input size="medium" clearable type="password" v-model="form.confirm_password" autocomplete="off"></el-input>
3636
</el-form-item>
3737
<el-form-item v-if="pageType !== 'password'" label="选择分组">
38-
<el-select
38+
<!-- <el-select
3939
size="medium"
4040
multiple
4141
v-model="form.group_ids"
4242
:disabled="groups.length === 0"
4343
placeholder="请选择分组"
4444
>
4545
<el-option v-for="item in groups" :key="item.id" :label="item.name" :value="item.id"> </el-option>
46-
</el-select>
47-
<!-- <el-radio-group v-model="form.group_id" label-position="top" class="user-info">
48-
<el-radio :label="item.id" v-for="(item, index) in groups" :key="index">{{item.name}}</el-radio>
49-
</el-radio-group> -->
46+
</el-select> -->
47+
<el-checkbox-group v-model="form.group_ids">
48+
<el-checkbox v-for="item in groups" :key="item.id" :label="item.id">{{ item.name }}</el-checkbox>
49+
</el-checkbox-group>
5050
</el-form-item>
5151
<el-form-item v-show="submit" class="submit">
5252
<el-button type="primary" @click="submitForm('form')">保 存</el-button>
@@ -165,7 +165,7 @@ export default {
165165
try {
166166
this.loading = true
167167
res = await User.register(this.form)
168-
if (res.error_code === 0) {
168+
if (res.error_code < window.SUCCESS_CODE) {
169169
this.loading = false
170170
this.$message.success(`${res.msg}`)
171171
this.eventBus.$emit('addUser', true)
@@ -192,7 +192,7 @@ export default {
192192
this.loading = false
193193
console.log(e)
194194
}
195-
if (res.error_code === 0) {
195+
if (res.error_code < window.SUCCESS_CODE) {
196196
this.loading = false
197197
this.$message.success(`${res.msg}`)
198198
this.$emit('handleInfoResult', true)
@@ -226,17 +226,17 @@ export default {
226226
this.form.group_ids = temp
227227
},
228228
},
229-
watch: {
230-
groups: {
231-
// 默认选中管理员组
232-
handler() {
233-
if (this.groups && this.groups[0] && this.groups[0].id) {
234-
this.form.group_ids = [this.groups[0].id]
235-
}
236-
},
237-
immediate: true,
238-
},
239-
},
229+
// watch: {
230+
// groups: {
231+
// // 默认选中管理员组
232+
// handler() {
233+
// if (this.groups && this.groups[0] && this.groups[0].id) {
234+
// this.form.group_ids = [this.groups[0].id]
235+
// }
236+
// },
237+
// immediate: true,
238+
// },
239+
// },
240240
created() {
241241
// 通过是否接收到数据来判断当前页面是添加数据还是编辑数据
242242
if (this.pageType === 'edit') {

src/views/admin/user/UserList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export default {
170170
this.loading = false
171171
console.log(e)
172172
}
173-
if (res.error_code === 0) {
173+
if (res.error_code < window.SUCCESS_CODE) {
174174
this.loading = false
175175
if (this.total_nums % this.pageCount === 1 && this.currentPage !== 1) {
176176
// 判断删除的是不是每一页的最后一条数据

src/views/admin/user/UserPassword.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default {
8181
this.loading = false
8282
console.log(e)
8383
}
84-
if (res.error_code === 0) {
84+
if (res.error_code < window.SUCCESS_CODE) {
8585
this.loading = false
8686
this.$message.success(`${res.msg}`)
8787
this.resetForm(formName)

src/views/book/BookAdd.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default {
5454
async submitForm(formName) {
5555
try {
5656
const res = await book.addBook(this.form)
57-
if (res.error_code === 0) {
57+
if (res.error_code < window.SUCCESS_CODE) {
5858
this.$message.success(`${res.msg}`)
5959
this.resetForm(formName)
6060
}

src/views/book/BookEdit.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default {
6060
methods: {
6161
async submitForm() {
6262
const res = await book.editBook(this.editBookID, this.form)
63-
if (res.error_code === 0) {
63+
if (res.error_code < window.SUCCESS_CODE) {
6464
this.$message.success(`${res.msg}`)
6565
this.$emit('editClose')
6666
}

0 commit comments

Comments
 (0)