Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
5ec5e1a6
提交
5ec5e1a6
authored
7月 20, 2022
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化字典数据使用store存取
上级
1f0e7427
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
86 行增加
和
1 行删除
+86
-1
index.js
ruoyi-ui/src/components/DictData/index.js
+29
-1
getters.js
ruoyi-ui/src/store/getters.js
+1
-0
index.js
ruoyi-ui/src/store/index.js
+2
-0
dict.js
ruoyi-ui/src/store/modules/dict.js
+50
-0
data.vue
ruoyi-ui/src/views/system/dict/data.vue
+3
-0
index.vue
ruoyi-ui/src/views/system/dict/index.vue
+1
-0
没有找到文件。
ruoyi-ui/src/components/DictData/index.js
浏览文件 @
5ec5e1a6
import
Vue
from
'vue'
import
Vue
from
'vue'
import
store
from
'@/store'
import
DataDict
from
'@/utils/dict'
import
DataDict
from
'@/utils/dict'
import
{
getDicts
as
getDicts
}
from
'@/api/system/dict/data'
import
{
getDicts
as
getDicts
}
from
'@/api/system/dict/data'
function
searchDictByKey
(
dict
,
key
)
{
if
(
key
==
null
&&
key
==
""
)
{
return
null
}
try
{
for
(
let
i
=
0
;
i
<
dict
.
length
;
i
++
)
{
if
(
dict
[
i
].
key
==
key
)
{
return
dict
[
i
].
value
}
}
}
catch
(
e
)
{
return
null
}
}
function
install
()
{
function
install
()
{
Vue
.
use
(
DataDict
,
{
Vue
.
use
(
DataDict
,
{
metas
:
{
metas
:
{
...
@@ -9,7 +25,19 @@ function install() {
...
@@ -9,7 +25,19 @@ function install() {
labelField
:
'dictLabel'
,
labelField
:
'dictLabel'
,
valueField
:
'dictValue'
,
valueField
:
'dictValue'
,
request
(
dictMeta
)
{
request
(
dictMeta
)
{
return
getDicts
(
dictMeta
.
type
).
then
(
res
=>
res
.
data
)
const
storeDict
=
searchDictByKey
(
store
.
getters
.
dict
,
dictMeta
.
type
)
if
(
storeDict
)
{
return
new
Promise
(
resolve
=>
{
resolve
(
storeDict
)
})
}
else
{
return
new
Promise
((
resolve
,
reject
)
=>
{
getDicts
(
dictMeta
.
type
).
then
(
res
=>
{
store
.
dispatch
(
'dict/setDict'
,
{
key
:
dictMeta
.
type
,
value
:
res
.
data
})
resolve
(
res
.
data
)
}).
catch
(
error
=>
{
reject
(
error
)
})
})
}
},
},
},
},
},
},
...
...
ruoyi-ui/src/store/getters.js
浏览文件 @
5ec5e1a6
...
@@ -2,6 +2,7 @@ const getters = {
...
@@ -2,6 +2,7 @@ const getters = {
sidebar
:
state
=>
state
.
app
.
sidebar
,
sidebar
:
state
=>
state
.
app
.
sidebar
,
size
:
state
=>
state
.
app
.
size
,
size
:
state
=>
state
.
app
.
size
,
device
:
state
=>
state
.
app
.
device
,
device
:
state
=>
state
.
app
.
device
,
dict
:
state
=>
state
.
dict
.
dict
,
visitedViews
:
state
=>
state
.
tagsView
.
visitedViews
,
visitedViews
:
state
=>
state
.
tagsView
.
visitedViews
,
cachedViews
:
state
=>
state
.
tagsView
.
cachedViews
,
cachedViews
:
state
=>
state
.
tagsView
.
cachedViews
,
token
:
state
=>
state
.
user
.
token
,
token
:
state
=>
state
.
user
.
token
,
...
...
ruoyi-ui/src/store/index.js
浏览文件 @
5ec5e1a6
import
Vue
from
'vue'
import
Vue
from
'vue'
import
Vuex
from
'vuex'
import
Vuex
from
'vuex'
import
app
from
'./modules/app'
import
app
from
'./modules/app'
import
dict
from
'./modules/dict'
import
user
from
'./modules/user'
import
user
from
'./modules/user'
import
tagsView
from
'./modules/tagsView'
import
tagsView
from
'./modules/tagsView'
import
permission
from
'./modules/permission'
import
permission
from
'./modules/permission'
...
@@ -12,6 +13,7 @@ Vue.use(Vuex)
...
@@ -12,6 +13,7 @@ Vue.use(Vuex)
const
store
=
new
Vuex
.
Store
({
const
store
=
new
Vuex
.
Store
({
modules
:
{
modules
:
{
app
,
app
,
dict
,
user
,
user
,
tagsView
,
tagsView
,
permission
,
permission
,
...
...
ruoyi-ui/src/store/modules/dict.js
0 → 100644
浏览文件 @
5ec5e1a6
const
state
=
{
dict
:
new
Array
()
}
const
mutations
=
{
SET_DICT
:
(
state
,
{
key
,
value
})
=>
{
if
(
key
!==
null
&&
key
!==
""
)
{
state
.
dict
.
push
({
key
:
key
,
value
:
value
})
}
},
REMOVE_DICT
:
(
state
,
key
)
=>
{
try
{
for
(
let
i
=
0
;
i
<
state
.
dict
.
length
;
i
++
)
{
if
(
state
.
dict
[
i
].
key
==
key
)
{
state
.
dict
.
splice
(
i
,
i
)
return
true
}
}
}
catch
(
e
)
{
}
},
CLEAN_DICT
:
(
state
)
=>
{
state
.
dict
=
new
Array
()
}
}
const
actions
=
{
// 设置字典
setDict
({
commit
},
data
)
{
commit
(
'SET_DICT'
,
data
)
},
// 删除字典
removeDict
({
commit
},
key
)
{
commit
(
'REMOVE_DICT'
,
key
)
},
// 清空字典
cleanDict
({
commit
})
{
commit
(
'CLEAN_DICT'
)
}
}
export
default
{
namespaced
:
true
,
state
,
mutations
,
actions
}
ruoyi-ui/src/views/system/dict/data.vue
浏览文件 @
5ec5e1a6
...
@@ -364,12 +364,14 @@ export default {
...
@@ -364,12 +364,14 @@ export default {
if
(
valid
)
{
if
(
valid
)
{
if
(
this
.
form
.
dictCode
!=
undefined
)
{
if
(
this
.
form
.
dictCode
!=
undefined
)
{
updateData
(
this
.
form
).
then
(
response
=>
{
updateData
(
this
.
form
).
then
(
response
=>
{
this
.
$store
.
dispatch
(
'dict/removeDict'
,
this
.
queryParams
.
dictType
);
this
.
$modal
.
msgSuccess
(
"修改成功"
);
this
.
$modal
.
msgSuccess
(
"修改成功"
);
this
.
open
=
false
;
this
.
open
=
false
;
this
.
getList
();
this
.
getList
();
});
});
}
else
{
}
else
{
addData
(
this
.
form
).
then
(
response
=>
{
addData
(
this
.
form
).
then
(
response
=>
{
this
.
$store
.
dispatch
(
'dict/removeDict'
,
this
.
queryParams
.
dictType
);
this
.
$modal
.
msgSuccess
(
"新增成功"
);
this
.
$modal
.
msgSuccess
(
"新增成功"
);
this
.
open
=
false
;
this
.
open
=
false
;
this
.
getList
();
this
.
getList
();
...
@@ -386,6 +388,7 @@ export default {
...
@@ -386,6 +388,7 @@ export default {
}).
then
(()
=>
{
}).
then
(()
=>
{
this
.
getList
();
this
.
getList
();
this
.
$modal
.
msgSuccess
(
"删除成功"
);
this
.
$modal
.
msgSuccess
(
"删除成功"
);
this
.
$store
.
dispatch
(
'dict/removeDict'
,
this
.
queryParams
.
dictType
);
}).
catch
(()
=>
{});
}).
catch
(()
=>
{});
},
},
/** 导出按钮操作 */
/** 导出按钮操作 */
...
...
ruoyi-ui/src/views/system/dict/index.vue
浏览文件 @
5ec5e1a6
...
@@ -339,6 +339,7 @@ export default {
...
@@ -339,6 +339,7 @@ export default {
handleRefreshCache
()
{
handleRefreshCache
()
{
refreshCache
().
then
(()
=>
{
refreshCache
().
then
(()
=>
{
this
.
$modal
.
msgSuccess
(
"刷新成功"
);
this
.
$modal
.
msgSuccess
(
"刷新成功"
);
this
.
$store
.
dispatch
(
'dict/cleanDict'
);
});
});
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论