角色菜单添加国际化
This commit is contained in:
@@ -415,7 +415,7 @@ export default {
|
|||||||
{ required: true, message: this.$t('systemManagement_RoleManagement.checkRoleSortIsNull'), trigger: "blur" }
|
{ required: true, message: this.$t('systemManagement_RoleManagement.checkRoleSortIsNull'), trigger: "blur" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
quaryWarehouse:{
|
queryWarehouse:{
|
||||||
pageNum:1,
|
pageNum:1,
|
||||||
pageSize:99
|
pageSize:99
|
||||||
}
|
}
|
||||||
@@ -428,7 +428,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
/** 获取仓库列表 */
|
/** 获取仓库列表 */
|
||||||
getWarehouseList() {
|
getWarehouseList() {
|
||||||
listWarehouse(this.quaryWarehouse).then(response => {
|
listWarehouse(this.queryWarehouse).then(response => {
|
||||||
this.warehouseOptions = response.rows;
|
this.warehouseOptions = response.rows;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -446,22 +446,18 @@ export default {
|
|||||||
getMenuTreeselect() {
|
getMenuTreeselect() {
|
||||||
menuTreeselect().then(response => {
|
menuTreeselect().then(response => {
|
||||||
// 国际化菜单名称
|
// 国际化菜单名称
|
||||||
// let listMenu = response.data.map(item => {
|
const translateMenuLabels = (items) => {
|
||||||
// return this.$t(item.label); // 只提取翻译后的 label
|
for (const item of items) {
|
||||||
// });
|
item.label = this.$t(item.label)
|
||||||
console.log(response.data);
|
if (item.children && item.children.length > 0) {
|
||||||
// this.menuOptions = response.data
|
translateMenuLabels(item.children)
|
||||||
this.menuOptions = this.translateMenuLabels(response.data)
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
translateMenuLabels(response.data)
|
||||||
|
this.menuOptions = response.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
//@@@
|
|
||||||
translateMenuLabels(data) {
|
|
||||||
return data.map(item => ({
|
|
||||||
...item,
|
|
||||||
label: this.$t(item.label),
|
|
||||||
children: item.children ? this.translateMenuLabels(item.children) : []
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
// 所有菜单节点数据
|
// 所有菜单节点数据
|
||||||
getMenuAllCheckedKeys() {
|
getMenuAllCheckedKeys() {
|
||||||
@@ -484,6 +480,16 @@ export default {
|
|||||||
/** 根据角色ID查询菜单树结构 */
|
/** 根据角色ID查询菜单树结构 */
|
||||||
getRoleMenuTreeselect(roleId) {
|
getRoleMenuTreeselect(roleId) {
|
||||||
return roleMenuTreeselect(roleId).then(response => {
|
return roleMenuTreeselect(roleId).then(response => {
|
||||||
|
// 国际化菜单名称
|
||||||
|
const translateMenuLabels = (items) => {
|
||||||
|
for (const item of items) {
|
||||||
|
item.label = this.$t(item.label)
|
||||||
|
if (item.children && item.children.length > 0) {
|
||||||
|
translateMenuLabels(item.children)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
translateMenuLabels(response.menus)
|
||||||
this.menuOptions = response.menus
|
this.menuOptions = response.menus
|
||||||
return response
|
return response
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user