Skip to content

Commit 754d693

Browse files
committed
merge type and bug fixed
1 parent e580fc7 commit 754d693

File tree

10 files changed

+80
-44
lines changed

10 files changed

+80
-44
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
NODE_ENV = 'development'
33

44
# base api
5-
VUE_APP_BASE_API = 'https://gumingchen.cn/apis/loafer'
5+
VUE_APP_BASE_API = 'http://localhost:8887/loafer'
66

77
VUE_APP_PORT = '9585'
88

src/types/el/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
/*
2+
* @Description:
3+
* @Author: gumingchen
4+
5+
* @Date: 2021-04-28 14:35:39
6+
* @LastEditors: gumingchen
7+
* @LastEditTime: 2021-04-29 13:50:55
8+
*/
19
import { CascaderProps as ElCascaderProps, CascaderOption as ElCascaderOption } from 'node_modules/element-plus/lib/el-cascader-panel/src/types'
210

311
export namespace El {
412

513
export type CascaderProps = ElCascaderProps
614
export type CascaderOption = ElCascaderOption
15+
export interface CascaderCheckedNode<T> {
16+
pathValues: T[]
17+
}
718

819
export interface TreeNode<T> {
920
children: T[]

src/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
* @Date: 2021-01-19 14:41:18
66
* @LastEditors: gumingchen
7-
* @LastEditTime: 2021-04-21 17:42:11
7+
* @LastEditTime: 2021-04-29 11:38:07
88
*/
99
import store from '@/store'
1010
import { IObject } from '@/types'
@@ -174,7 +174,7 @@ export function $clearJson<T>(data: T): void {
174174
for (key in json) {
175175
if (json[key] instanceof Array) {
176176
json[key] = []
177-
} else if (typeof json[key] === 'object' && IObject.prototype.toString.call(json[key]).toLowerCase() === '[object object]' && !json[key].length) {
177+
} else if (typeof json[key] === 'object' && Object.prototype.toString.call(json[key]).toLowerCase() === '[object object]' && !json[key].length) {
178178
json[key] = {}
179179
} else {
180180
json[key] = ''

src/utils/request.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
* @Date: 2020-12-21 16:45:49
66
* @LastEditors: gumingchen
7-
* @LastEditTime: 2021-04-17 13:20:12
7+
* @LastEditTime: 2021-04-29 13:13:16
88
*/
99
'use strict'
1010
import axios from 'axios'
@@ -39,8 +39,7 @@ const prompt = (message?: string): void => {
3939
*/
4040
const codeHandle = (code?: number, message?: string): void => {
4141
switch (code) {
42-
case 5001:
43-
case 5005:
42+
case 401:
4443
prompt(message)
4544
router.replace({
4645
name: 'login'

src/views/components/page/index.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<!--
2+
* @Description:
3+
* @Author: gumingchen
4+
5+
* @Date: 2021-04-26 16:58:39
6+
* @LastEditors: gumingchen
7+
* @LastEditTime: 2021-04-29 11:39:19
8+
-->
19
<template>
210
<el-pagination
311
class="page"
@@ -16,7 +24,7 @@
1624
<script lang="ts">
1725
import { Options, Vue } from 'vue-class-component'
1826
import { Prop } from 'vue-property-decorator'
19-
import { Mixins } from '@/types/mixins'
27+
import { IPage } from '@/mixins/page'
2028
2129
@Options({
2230
emits: ['change']
@@ -26,7 +34,7 @@ export default class extends Vue {
2634
type: Object,
2735
require: true
2836
})
29-
readonly page!: Mixins.Page
37+
readonly page!: IPage
3038
3139
currentChangeHandle(val: number): void {
3240
this.$emit('change', { current: val, size: this.page.size })

src/views/modules/base/menu/components/add-edit.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
* @Date: 2021-02-03 15:48:37
66
* @LastEditors: gumingchen
7-
* @LastEditTime: 2021-04-21 22:42:39
7+
* @LastEditTime: 2021-04-29 14:12:49
88
-->
99
<template>
1010
<el-dialog
@@ -157,6 +157,7 @@ export default class extends Vue {
157157
158158
async init(id?: number): Promise<void> {
159159
this.visible = true
160+
this.loading = true
160161
this.form.id = id
161162
const res = await select()
162163
if (res) {
@@ -169,12 +170,14 @@ export default class extends Vue {
169170
this.menus = $parseData2Tree(res.data, 'id', 'parent_id')
170171
}
171172
if (this.form.id) {
172-
info(this.form.id).then(r => {
173-
if (r) {
174-
this.form = r.data
175-
}
176-
})
173+
const r = await info(this.form.id)
174+
if (r) {
175+
this.form = r.data
176+
}
177177
}
178+
this.$nextTick(() => {
179+
this.loading = false
180+
})
178181
}
179182
180183
/**

src/views/modules/base/role/components/add-edit.vue

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
* @Date: 2021-02-03 15:48:37
66
* @LastEditors: gumingchen
7-
* @LastEditTime: 2021-04-21 22:42:39
7+
* @LastEditTime: 2021-04-29 14:08:04
88
-->
99
<template>
1010
<el-dialog
@@ -52,7 +52,7 @@ import { Inject } from 'vue-property-decorator'
5252
import { add, edit, info } from '@/api/base/role'
5353
import { selfSelect } from '@/api/base/menu'
5454
import { $parseData2Tree } from '@/utils/index'
55-
import { Set } from '@/store/modules/common'
55+
import { Set as ISet } from '@/store/modules/common'
5656
import { El } from '@/types/el'
5757
import { IObject } from '@/types'
5858
import { Menu } from '@/types/menu'
@@ -62,7 +62,7 @@ import { Role } from '@/types/role'
6262
emits: ['refresh']
6363
})
6464
export default class extends Vue {
65-
@Inject('set') readonly set!: Set
65+
@Inject('set') readonly set!: ISet
6666
protected visible: boolean = false
6767
protected loading: boolean = false
6868
@@ -77,7 +77,7 @@ export default class extends Vue {
7777
const prop = {
7878
multiple: true,
7979
emitPath: false,
80-
checkStrictly: true,
80+
checkStrictly: false,
8181
value: 'id',
8282
label: `name_${ this.set.language }`,
8383
children: 'children'
@@ -96,6 +96,7 @@ export default class extends Vue {
9696
9797
async init(id?: number): Promise<void> {
9898
this.visible = true
99+
this.loading = true
99100
this.form.id = id
100101
const res = await selfSelect()
101102
if (res) {
@@ -109,12 +110,14 @@ export default class extends Vue {
109110
this.menus = $parseData2Tree(res.data, 'id', 'parent_id')
110111
}
111112
if (this.form.id) {
112-
info(this.form.id).then(r => {
113-
if (r) {
114-
this.form = r.data
115-
}
116-
})
113+
const r = await info(this.form.id)
114+
if (r) {
115+
this.form = r.data
116+
}
117117
}
118+
this.$nextTick(() => {
119+
this.loading = false
120+
})
118121
}
119122
120123
/**
@@ -126,6 +129,17 @@ export default class extends Vue {
126129
submit(): void {
127130
this.$refs.formR.validate(async (valid: boolean) => {
128131
if (valid) {
132+
// 处理菜单权限ID
133+
const checkedNodes = this.$refs.cascaderR.getCheckedNodes(true) as El.CascaderCheckedNode<number>[]
134+
let menuIds: number[] = []
135+
checkedNodes.forEach(item => {
136+
menuIds.push.apply(menuIds, item.pathValues)
137+
})
138+
menuIds = Array.from(new Set(menuIds)).filter(item => {
139+
return item !== 0
140+
})
141+
this.form.menu_ids = menuIds
142+
129143
const r = !this.form.id ? await add(this.form) : await edit(this.form)
130144
if (r) {
131145
this.visible = false

src/views/modules/base/role/index.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
* @Date: 2021-04-21 22:52:19
66
* @LastEditors: gumingchen
7-
* @LastEditTime: 2021-04-21 23:19:02
7+
* @LastEditTime: 2021-04-29 11:40:58
88
-->
99
<template>
1010
<div class="g-container">
@@ -76,13 +76,12 @@
7676
<script lang="ts">
7777
import { mixins, Options } from 'vue-class-component'
7878
import { Inject } from 'vue-property-decorator'
79-
import page from '@/mixins/page'
79+
import page, { IPage } from '@/mixins/page'
8080
import Page from '@V/components/page/index.vue'
8181
import AddEdit from './components/add-edit.vue'
8282
import { del, getPage } from '@/api/base/role'
8383
import { IObject } from '@/types'
8484
import { Role } from '@/types/role'
85-
import { Mixins } from '@/types/mixins'
8685
8786
@Options({
8887
components: { Page, AddEdit }
@@ -191,7 +190,7 @@ export default class extends mixins(page) {
191190
* @return {*}
192191
* @author: gumingchen
193192
*/
194-
pageChangeHandle(data: Mixins.Page): void {
193+
pageChangeHandle(data: IPage): void {
195194
this.page.current = data.current
196195
this.page.size = data.size
197196
this.getList()

src/views/modules/base/user/components/add-edit.vue

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
* @Date: 2021-02-03 15:48:37
66
* @LastEditors: gumingchen
7-
* @LastEditTime: 2021-04-21 22:42:39
7+
* @LastEditTime: 2021-04-29 14:11:28
88
-->
99
<template>
1010
<el-dialog
@@ -128,25 +128,28 @@ export default class extends Vue {
128128
129129
async init(id?: number): Promise<void> {
130130
this.visible = true
131+
this.loading = true
131132
this.form.id = id
132133
const res = await select()
133134
if (res) {
134135
this.roles = res.data
135136
}
136137
if (this.form.id) {
137-
info(this.form.id).then(r => {
138-
if (r) {
139-
this.form.username = r.data.username
140-
this.form.nickname = r.data.username
141-
this.form.mobile = r.data.mobile
142-
this.form.email = r.data.email
143-
this.form.status = r.data.status
144-
this.form.role_ids = r.data.roles!.map(item => {
145-
return item.id
146-
})
147-
}
148-
})
138+
const r = await info(this.form.id)
139+
if (r) {
140+
this.form.username = r.data.username
141+
this.form.nickname = r.data.username
142+
this.form.mobile = r.data.mobile
143+
this.form.email = r.data.email
144+
this.form.status = r.data.status
145+
this.form.role_ids = r.data.roles!.map(item => {
146+
return item.id
147+
})
148+
}
149149
}
150+
this.$nextTick(() => {
151+
this.loading = false
152+
})
150153
}
151154
152155
/**

src/views/modules/base/user/index.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
* @Date: 2021-04-21 22:52:19
66
* @LastEditors: gumingchen
7-
* @LastEditTime: 2021-04-21 23:19:02
7+
* @LastEditTime: 2021-04-29 11:41:32
88
-->
99
<template>
1010
<div class="g-container">
@@ -101,13 +101,12 @@
101101
<script lang="ts">
102102
import { mixins, Options } from 'vue-class-component'
103103
import { Inject } from 'vue-property-decorator'
104-
import page from '@/mixins/page'
104+
import page, { IPage } from '@/mixins/page'
105105
import Page from '@V/components/page/index.vue'
106106
import AddEdit from './components/add-edit.vue'
107107
import { del, getPage, setStatus } from '@/api/base/user'
108108
import { IObject } from '@/types'
109109
import { User } from '@/types/user'
110-
import { Mixins } from '@/types/mixins'
111110
112111
@Options({
113112
components: { Page, AddEdit }
@@ -249,7 +248,7 @@ export default class extends mixins(page) {
249248
* @return {*}
250249
* @author: gumingchen
251250
*/
252-
pageChangeHandle(data: Mixins.Page): void {
251+
pageChangeHandle(data: IPage): void {
253252
this.page.current = data.current
254253
this.page.size = data.size
255254
this.getList()

0 commit comments

Comments
 (0)