Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
super-hive-web
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
front-end
super-hive-web
Commits
374d875b
Commit
374d875b
authored
Jul 31, 2020
by
wends
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add 获取字典表
parent
f10e31c3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
5 deletions
+67
-5
basic-services.js
src/api/components/basic-services.js
+8
-1
index.vue
src/components/SvgIcon/index.vue
+1
-1
permission.js
src/permission.js
+3
-0
getters.js
src/store/getters.js
+2
-1
app.js
src/store/modules/app.js
+20
-1
dictionary.js
src/utils/dictionary.js
+32
-0
request.js
src/utils/request.js
+1
-1
No files found.
src/api/components/basic-services.js
View file @
374d875b
...
...
@@ -18,4 +18,11 @@ export function verifyCaptcha(data) {
data
})
}
// 获取字典表
export
function
getDictionaryTable
(
data
)
{
return
request
({
url
:
`
${
baseURL
}
/base/dict/get`
,
method
:
'
post
'
,
data
})
}
src/components/SvgIcon/index.vue
View file @
374d875b
...
...
@@ -49,7 +49,7 @@ export default {
.svg-icon
{
width
:
1em
;
height
:
1em
;
vertical-align
:
-0.
15
em
;
vertical-align
:
-0.
2
em
;
fill
:
currentColor
;
overflow
:
hidden
;
}
...
...
src/permission.js
View file @
374d875b
...
...
@@ -68,6 +68,9 @@ router.beforeEach(async(to, from, next) => {
// get user info
await
store
.
dispatch
(
'
user/getInfo
'
)
// 获取字典表数据
await
store
.
dispatch
(
'
app/getDictionary
'
)
// 获取可访问的 菜单页面列表 和 按键列表
const
{
data
:
menuList
}
=
await
store
.
dispatch
(
'
user/getMenuList
'
)
const
{
data
:
permissionList
}
=
await
store
.
dispatch
(
'
user/getPermissionList
'
)
...
...
src/store/getters.js
View file @
374d875b
...
...
@@ -12,6 +12,7 @@ const getters = {
permissions
:
state
=>
state
.
permission
.
permissions
,
tokenValid
:
state
=>
state
.
user
.
tokenValid
,
userInfo
:
state
=>
state
.
user
.
userInfo
,
currentMenuId
:
state
=>
state
.
permission
.
currentMenuId
currentMenuId
:
state
=>
state
.
permission
.
currentMenuId
,
dictionary
:
state
=>
state
.
app
.
dictionary
}
export
default
getters
src/store/modules/app.js
View file @
374d875b
import
Cookies
from
'
js-cookie
'
import
{
getDictionaryTable
}
from
'
@/api/components/basic-services
'
const
state
=
{
sidebar
:
{
...
...
@@ -6,7 +7,8 @@ const state = {
withoutAnimation
:
false
},
device
:
'
desktop
'
,
size
:
Cookies
.
get
(
'
size
'
)
||
'
medium
'
size
:
Cookies
.
get
(
'
size
'
)
||
'
medium
'
,
dictionary
:
{}
}
const
mutations
=
{
...
...
@@ -30,6 +32,9 @@ const mutations = {
SET_SIZE
:
(
state
,
size
)
=>
{
state
.
size
=
size
Cookies
.
set
(
'
size
'
,
size
)
},
SET_DIST
:
(
state
,
dictionary
)
=>
{
state
.
dictionary
=
dictionary
}
}
...
...
@@ -45,6 +50,20 @@ const actions = {
},
setSize
({
commit
},
size
)
{
commit
(
'
SET_SIZE
'
,
size
)
},
getDictionary
({
commit
})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
getDictionaryTable
({
type
:
null
})
.
then
(
res
=>
{
const
data
=
{}
res
.
data
.
forEach
(
v
=>
{
data
[
v
.
type
.
replace
(
v
.
type
[
0
],
v
.
type
[
0
].
toLowerCase
())]
=
v
.
dictList
})
commit
(
'
SET_DIST
'
,
data
)
resolve
()
})
.
catch
(
err
=>
reject
(
err
))
})
}
}
...
...
src/utils/dictionary.js
0 → 100644
View file @
374d875b
import
{
mapGetters
}
from
'
vuex
'
const
dictionary
=
{
data
()
{
return
{
goodsTypeProps
:
{
value
:
'
code
'
,
label
:
'
name
'
}
}
},
computed
:
{
...
mapGetters
([
'
dictionary
'
])
},
methods
:
{
$_dictionaryFormat
(
row
,
column
,
cellValue
,
index
,
prop
)
{
// 3种情况
// 用在 table-column 中,使用默认入参,4个入参
// 用在 table-column 中,使用指定入参,5个入参
// 当作 filter 使用,使用指定入参,2个入参
// 处理cellValue为0时 (cellValue && true)为false的情况,
const
val
=
((
cellValue
===
0
?
true
:
cellValue
)
&&
true
)
?
cellValue
:
row
const
property
=
prop
||
column
.
property
||
column
const
data
=
this
.
dictionary
[
property
].
find
(
v
=>
v
.
code
===
parseInt
(
val
))
return
data
?
data
.
name
:
null
}
}
}
export
default
dictionary
src/utils/request.js
View file @
374d875b
...
...
@@ -6,7 +6,7 @@ import { getToken } from '@/utils/auth'
// create an axios instance
const
service
=
axios
.
create
({
baseURL
:
process
.
env
.
VUE_APP_BASE_API
,
// url = base url + request url
withCredentials
:
tru
e
,
// send cookies when cross-domain requests
withCredentials
:
fals
e
,
// send cookies when cross-domain requests
timeout
:
20000
// request timeout
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment