/**
|
* 助力贷菜单注入:数据库未配置时,在「财务」下补全套餐/订单入口
|
*/
|
const LOAN_MENU_ITEMS = [
|
{
|
menuId: 3410,
|
parentId: 211,
|
name: '助力贷套餐',
|
url: 'finance/loan-config',
|
perms: null,
|
type: 1,
|
icon: '',
|
orderNum: 10,
|
list: null
|
},
|
{
|
menuId: 3411,
|
parentId: 211,
|
name: '助力贷订单',
|
url: 'finance/loan-order',
|
perms: null,
|
type: 1,
|
icon: '',
|
orderNum: 11,
|
list: null
|
}
|
]
|
|
function hasLoanMenu (list) {
|
if (!Array.isArray(list)) return false
|
return list.some(item => {
|
const url = item.url || ''
|
return url.includes('loan-config') || url.includes('loan-order')
|
})
|
}
|
|
function findFinanceMenu (menuList) {
|
if (!Array.isArray(menuList)) return null
|
return menuList.find(item => item.name === '财务' || item.menuId === 211 || item.menuId === '211')
|
}
|
|
export function injectLoanMenus (menuList) {
|
if (!Array.isArray(menuList)) return menuList
|
const finance = findFinanceMenu(menuList)
|
if (!finance) return menuList
|
if (!finance.list) finance.list = []
|
if (hasLoanMenu(finance.list)) return menuList
|
const parentId = finance.menuId || 211
|
LOAN_MENU_ITEMS.forEach(item => {
|
finance.list.push({ ...item, parentId })
|
})
|
finance.list.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0))
|
return menuList
|
}
|