|
|
@@ -1,460 +0,0 @@
|
|
|
-/**
|
|
|
- * 工作台首页菜单配置(hdApp)
|
|
|
- * 用途:mall-home-panel 快捷栏 / 花束花材合并栏 / 更多功能;apply 全量目录。
|
|
|
- */
|
|
|
-const homeIcon = name => name
|
|
|
-
|
|
|
-/** 花束栏已下线菜单(兼容本地 storage 旧配置) */
|
|
|
-const REMOVED_FLOWER_MENU_KEYS = ['hsBill', 'hsQuickBill', 'goHsKd', 'goHsKjKd']
|
|
|
-/** 合并栏已下线:花束商城码,首页只保留花材商城码 */
|
|
|
-const REMOVED_BIZ_MENU_KEYS = ['mall']
|
|
|
-
|
|
|
-export const APPLY_MENU_GROUPS = [
|
|
|
- {
|
|
|
- title: '花束花材',
|
|
|
- titleIcon: homeIcon('bouquet'),
|
|
|
- list: [
|
|
|
- { name: '商城码', icon: homeIcon('mall-filled'), url: '/admin/cg/item', pf: 1 },
|
|
|
- { name: '商品管理', icon: homeIcon('bouquet'), url: '/admin/goods/manage', pf: 1 },
|
|
|
- { name: '新增花束', icon: homeIcon('add-bouquet'), url: '/admin/goods/add', pf: 1 },
|
|
|
- { name: '分类', icon: homeIcon('category-filled'), url: '/admin/goods/categoryV2?tab=0', pf: 1 },
|
|
|
- { name: '使用场景', icon: homeIcon('category-filled'), url: '/admin/useCase/list', pf: 1 },
|
|
|
- { name: '花束排序', icon: homeIcon('sort-filled'), url: '/admin/goods/categorySort', pf: 1 },
|
|
|
- { name: '涨价管理', icon: homeIcon('price-increase'), url: '/admin/goods/price-increase', pf: 1 },
|
|
|
- { name: '公告', icon: homeIcon('notice'), url: '/admin/shopNotice/list', pf: 1 },
|
|
|
- { name: '绿植花材', icon: homeIcon('plant-material'), url: '/admin/item/list2', pf: 1 },
|
|
|
- { name: '开单', icon: homeIcon('plant-billing'), action: 'goItemKd', pf: 1 },
|
|
|
- { name: '快捷开单', icon: homeIcon('plant-quick-billing'), action: 'goItemKjKd', pf: 1 },
|
|
|
- { name: '退款', icon: homeIcon('order-filled'), url: '/admin/custom/selectCustom?style=1&refund=1', pf: 1 },
|
|
|
- { name: '退款记录', icon: homeIcon('order-filled'), url: '/admin/billing/freeRefundList', pf: 1 },
|
|
|
- { name: '花材排序', icon: homeIcon('sort-filled'), url: '/admin/itemClass/sort', pf: 1 },
|
|
|
- { name: '改价', icon: homeIcon('change-price-filled'), url: '/admin/changePrice/list2', pf: 1 },
|
|
|
- { name: '报损', icon: homeIcon('breakage'), url: '/admin/breakage/list', pf: 1 },
|
|
|
- { name: '花材分类', icon: homeIcon('category-filled'), url: '/admin/goods/categoryV2?tab=1', pf: 1 },
|
|
|
- { name: '拆散', icon: homeIcon('disassemble'), url: '/admin/part/list', pf: 1 },
|
|
|
- { name: '调拨出库', icon: homeIcon('allot-out'), url: '/pagesStorehouse/allot/allotEx', pf: 0 },
|
|
|
- { name: '调拨入库', icon: homeIcon('allot-in'), url: '/pagesStorehouse/allot/allotPut', pf: 0 },
|
|
|
- { name: '库存预警', icon: homeIcon('stock-warning'), url: '/pagesStorehouse/stockWarn/manage', pf: 1 },
|
|
|
- { name: '买花', icon: homeIcon('buy-item'), url: '/pagesPurchase/order', pf: 1 },
|
|
|
- { name: '买花记录', icon: homeIcon('purchase-record'), url: '/pagesPurchase/shopping', pf: 1 },
|
|
|
- { name: '任务', icon: homeIcon('task-filled'), url: '/admin/work/list', pf: 1 },
|
|
|
- { name: '盘点', icon: homeIcon('inventory'), url: '/pagesStorehouse/inventory/list', pf: 1 }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- title: '门店设置',
|
|
|
- titleIcon: homeIcon('shop-filled'),
|
|
|
- list: [
|
|
|
- { name: '门店', icon: homeIcon('shop-filled'), url: '/admin/shop/list', pf: 1 },
|
|
|
- { name: '首页配置', icon: homeIcon('settings-filled'), url: '/admin/homePageConfig/index', pf: 1 },
|
|
|
- { name: '员工', icon: homeIcon('staff'), url: '/admin/staff/list', pf: 1 },
|
|
|
- { name: '员工业绩', icon: homeIcon('staff-performance'), url: '/admin/staff/achieve', pf: 1 },
|
|
|
- { name: '失信人员', icon: homeIcon('dishonest-person'), url: '/admin/ll/list', pf: 1 },
|
|
|
- { name: '已删商家', icon: homeIcon('store-delete'), url: '/pagesPurchase/pb', pf: 1 },
|
|
|
- { name: '会员等级', icon: homeIcon('member-level'), url: '/admin/member/level', pf: 1 },
|
|
|
- { name: '红包管理', icon: homeIcon('red-packet'), url: '/admin/hb/list', pf: 1 },
|
|
|
- { name: '充值设置', icon: homeIcon('recharge'), url: '/admin/recharge/rechargeSetting', pf: 1 },
|
|
|
- { name: '收款码', icon: homeIcon('pay-code'), url: '/admin/cg/code', pf: 1 },
|
|
|
- { name: '收款流水', icon: homeIcon('pay-code-flow'), url: '/admin/order/scanPay', pf: 1 },
|
|
|
- { name: '绑定跑腿', icon: homeIcon('delivery'), url: '/admin/delivery/deliveryManage', pf: 1 },
|
|
|
- { name: '配送方式', icon: homeIcon('delivery-outline'), url: '/admin/home/psMethod', pf: 1 },
|
|
|
- { name: '配置范围', icon: homeIcon('address'), url: '/admin/shop/sk', pf: 1 },
|
|
|
- { name: '分销规则', icon: homeIcon('settings-filled'), url: '/admin/home/distributionRule', pf: 1 },
|
|
|
- { name: '分销报表', icon: homeIcon('stats-pie-filled'), url: '/admin/home/distributionReport', pf: 1 }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- title: '硬件设置',
|
|
|
- titleIcon: homeIcon('settings-filled'),
|
|
|
- list: [
|
|
|
- { name: '打印设置', icon: homeIcon('print-settings'), url: '/admin/shop/print', pf: 1 },
|
|
|
- { name: '音响设置', icon: homeIcon('sound-filled'), url: '/admin/shop/trumpet', pf: 1 },
|
|
|
- { name: '操作台打印', icon: homeIcon('print-settings'), url: '/admin/shop/makePrint', pf: 1 },
|
|
|
- { name: '操作台音响', icon: homeIcon('sound-filled'), url: '/admin/shop/makeTrumpet', pf: 1 }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- title: '数据统计',
|
|
|
- titleIcon: homeIcon('stats-pie-filled'),
|
|
|
- list: [
|
|
|
- { name: '利润表', icon: homeIcon('profit-filled'), url: '/admin/stat/profit', pf: 1 },
|
|
|
- { name: '收入统计', icon: homeIcon('stats-2'), url: '/admin/stat/kdIncome', pf: 1 },
|
|
|
- { name: '花材销量', icon: homeIcon('order-volume'), url: '/admin/stat/productSale', pf: 1 },
|
|
|
- { name: '客户单量', icon: homeIcon('order-volume-2'), url: '/admin/stat/customSale', pf: 1 },
|
|
|
- { name: '采购统计', icon: homeIcon('stock-in-filled'), url: '/admin/stat/cgStat', pf: 1 },
|
|
|
- { name: '采购花材', icon: homeIcon('procurement'), url: '/admin/stat/cgItem', pf: 1 },
|
|
|
- { name: '绿植统计', icon: homeIcon('plant'), url: '/admin/stat/kindLz', pf: 1 },
|
|
|
- { name: '损耗总览', icon: homeIcon('breakage'), url: '/admin/stat/waste', pf: 1 },
|
|
|
- { name: '挂账汇总', icon: homeIcon('pay-code'), url: '/admin/custom/showTotalBalance', pf: 1 },
|
|
|
- { name: '充值统计', icon: homeIcon('stats-2'), url: '/admin/stat/rechargeStat', pf: 1 },
|
|
|
- { name: '红包统计', icon: homeIcon('red-packet'), url: '/admin/hb/stat', pf: 1 }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- title: '生产',
|
|
|
- titleIcon: homeIcon('bouquet'),
|
|
|
- actionText: '收起',
|
|
|
- list: [
|
|
|
- { name: '工作单列表', icon: homeIcon('list-3'), url: '/admin/work/list', pf: 1 },
|
|
|
- { name: '图文', icon: homeIcon('pic-text'), url: '/admin/picText/picTextList', pf: 1 },
|
|
|
- { name: '花材统计', icon: homeIcon('stats-bar-filled'), url: '/admin/stat/kind', pf: 1 },
|
|
|
- { name: '员工统计', icon: homeIcon('staff'), url: '/admin/stat/makeStat', pf: 1 }
|
|
|
- ]
|
|
|
- }
|
|
|
-]
|
|
|
-
|
|
|
-/** 菜单项配置:快捷栏 / 合并栏 / 更多功能 按 key 取项 */
|
|
|
-export const HOME_MENU_ITEMS = {
|
|
|
- itemBill: { name: '开单', icon: homeIcon('plant-billing'), action: 'goItemKd', pf: 1 },
|
|
|
- itemQuickBill: { name: '快捷开单', icon: homeIcon('plant-quick-billing'), action: 'goItemKjKd', pf: 1 },
|
|
|
- freeRefund: { name: '退款', icon: homeIcon('order-filled'), url: '/admin/custom/selectCustom?style=1&refund=1', pf: 1 },
|
|
|
- freeRefundList: { name: '退款记录', icon: homeIcon('order-filled'), url: '/admin/billing/freeRefundList', pf: 1 },
|
|
|
- customer: { name: '客户', icon: homeIcon('customer-filled'), url: '/admin/home/member', type: 4, pf: 1 },
|
|
|
- mall: { name: '商城码', icon: homeIcon('mall-filled'), url: '/admin/cg/mall', pf: 1 },
|
|
|
- itemMall: { name: '商城码', icon: homeIcon('mall-filled'), url: '/admin/cg/item', pf: 1 },
|
|
|
- task: { name: '任务', icon: homeIcon('task-filled'), url: '/admin/work/list', pf: 1 },
|
|
|
- goodsManage: { name: '商品管理', icon: homeIcon('bouquet'), url: '/admin/goods/manage', pf: 1 },
|
|
|
- addFlower: { name: '新增花束', icon: homeIcon('add-bouquet'), url: '/admin/goods/add', pf: 1 },
|
|
|
- order: { name: '订单', icon: homeIcon('order-filled'), url: '/admin/home/order', type: 4, pf: 1 },
|
|
|
- payCode: { name: '收款码', icon: homeIcon('pay-code'), url: '/admin/cg/code', pf: 1 },
|
|
|
- flowerCategory: { name: '分类', icon: homeIcon('category-filled'), url: '/admin/goods/categoryV2?tab=0', pf: 1 },
|
|
|
- flowerSort: { name: '花束排序', icon: homeIcon('sort-filled'), url: '/admin/goods/categorySort', pf: 1 },
|
|
|
- plant: { name: '绿植花材', icon: homeIcon('plant-material'), url: '/admin/item/list2', pf: 1 },
|
|
|
- plantCategory: { name: '花材分类', icon: homeIcon('category-filled'), url: '/admin/goods/categoryV2?tab=1', pf: 1 },
|
|
|
- plantSort: { name: '花材排序', icon: homeIcon('sort-filled'), url: '/admin/itemClass/sort', pf: 1 },
|
|
|
- part: { name: '拆散', icon: homeIcon('disassemble'), url: '/admin/part/list', pf: 1 },
|
|
|
- changePrice: { name: '改价', icon: homeIcon('change-price-filled'), url: '/admin/changePrice/list2', pf: 1 },
|
|
|
- breakage: { name: '报损', icon: homeIcon('breakage'), url: '/admin/breakage/list', pf: 1 },
|
|
|
- calculator: { name: '计算器', icon: homeIcon('calculator-filled'), url: '/admin/tools/calculator', pf: 1 },
|
|
|
- staff: { name: '员工', icon: homeIcon('staff'), url: '/admin/staff/list', pf: 1 },
|
|
|
- profit: { name: '利润表', icon: homeIcon('profit-filled'), url: '/admin/stat/profit', pf: 1 },
|
|
|
- picText: { name: '图文', icon: homeIcon('pic-text'), url: '/admin/picText/picTextList', pf: 1 },
|
|
|
- scanPay: { name: '收款码流水', icon: homeIcon('pay-code-flow'), url: '/admin/order/scanPay', pf: 1 },
|
|
|
- redPacket: { name: '红包管理', icon: homeIcon('red-packet'), url: '/admin/hb/list', pf: 1 },
|
|
|
- rechargeSetting: { name: '充值设置', icon: homeIcon('recharge'), url: '/admin/recharge/rechargeSetting', pf: 1 },
|
|
|
- buyItem: { name: '买花', icon: homeIcon('buy-item'), url: '/pagesPurchase/order', pf: 1 },
|
|
|
- purchaseRecord: { name: '买花记录', icon: homeIcon('purchase-record'), url: '/pagesPurchase/shopping', pf: 1 },
|
|
|
- priceIncrease: { name: '涨价管理', icon: homeIcon('price-increase'), url: '/admin/goods/price-increase', pf: 1 },
|
|
|
- shopNotice: { name: '公告', icon: homeIcon('notice'), url: '/admin/shopNotice/list', pf: 1 },
|
|
|
- homePageConfig: { name: '首页配置', icon: homeIcon('settings-filled'), url: '/admin/homePageConfig/index', pf: 1 },
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 默认菜单 key 列表
|
|
|
- * quickMenus: 快捷;bizMenus: 花束+绿植合并栏;moreMenus: 更多
|
|
|
- * flowerMenus/plantMenus 仅作旧缓存迁移源
|
|
|
- */
|
|
|
-export const HOME_MENU_DEFAULT_KEYS = {
|
|
|
- quickMenus: ['itemBill', 'itemQuickBill', 'buyItem','purchaseRecord'],
|
|
|
- bizMenus: [
|
|
|
- 'itemMall', 'flowerCategory', 'flowerSort', 'goodsManage', 'addFlower', 'priceIncrease', 'shopNotice',
|
|
|
- 'plant', 'freeRefund', 'freeRefundList','part', 'changePrice', 'breakage', 'plantCategory', 'task', 'homePageConfig'
|
|
|
- ],
|
|
|
- // 兼容旧 storage 读取(迁移时会去掉 mall,并把 task 挪到买花记录后)
|
|
|
- flowerMenus: ['flowerCategory', 'flowerSort', 'goodsManage', 'addFlower', 'priceIncrease', 'shopNotice'],
|
|
|
- plantMenus: ['itemMall', 'plant', 'part', 'changePrice', 'breakage', 'plantCategory', 'buyItem', 'purchaseRecord'],
|
|
|
- moreMenus: ['calculator', 'staff', 'profit', 'picText', 'scanPay', 'payCode', 'redPacket', 'rechargeSetting']
|
|
|
-}
|
|
|
-
|
|
|
-export const HOME_MENU_STORAGE_KEYS = {
|
|
|
- quickMenus: 'mallHome.quickMenus',
|
|
|
- bizMenus: 'mallHome.bizMenus',
|
|
|
- flowerMenus: 'mallHome.flowerMenus',
|
|
|
- plantMenus: 'mallHome.plantMenus'
|
|
|
-}
|
|
|
-
|
|
|
-export const HOME_OVERVIEW_FALLBACK = [
|
|
|
- { name: '花材数', value: 0, url: '/admin/item/list2' },
|
|
|
- { name: '花材值(元)', value: 0, url: '/admin/stat/kind' },
|
|
|
- { name: '花束', value: 0, url: '/admin/goods/manage' },
|
|
|
- { name: '客户总数', value: 0, url: '/admin/home/member', type: 4 },
|
|
|
- { name: '总订单', value: 0, url: '/admin/home/order', type: 4 },
|
|
|
- { name: '总挂账(元)', value: 0, url: '/admin/custom/showTotalBalance' }
|
|
|
-]
|
|
|
-
|
|
|
-export const getMenuItemKey = item => item.url || item.action || item.name
|
|
|
-
|
|
|
-const isRemovedFlowerMenuItem = item => {
|
|
|
- const key = getMenuItemKey(item)
|
|
|
- return REMOVED_FLOWER_MENU_KEYS.includes(key)
|
|
|
- || item.action === 'goHsKd'
|
|
|
- || item.action === 'goHsKjKd'
|
|
|
-}
|
|
|
-
|
|
|
-/** 数组合并去重,保持先出现顺序 */
|
|
|
-const mergeUniqueKeys = (...lists) => {
|
|
|
- const seen = {}
|
|
|
- const result = []
|
|
|
- lists.forEach(list => {
|
|
|
- ;(list || []).forEach(key => {
|
|
|
- if (!key || seen[key]) {
|
|
|
- return
|
|
|
- }
|
|
|
- seen[key] = true
|
|
|
- result.push(key)
|
|
|
- })
|
|
|
- })
|
|
|
- return result
|
|
|
-}
|
|
|
-
|
|
|
-/** 合并栏菜单结构版本:变更默认顺序时递增,强制覆盖本地旧缓存顺序 */
|
|
|
-export const HOME_MENU_BIZ_SCHEMA = 4
|
|
|
-const HOME_MENU_BIZ_SCHEMA_KEY = 'mallHome.bizMenusSchema'
|
|
|
-
|
|
|
-/**
|
|
|
- * 旧缓存可能存的是 url/action,统一成 HOME_MENU_ITEMS 短 key
|
|
|
- */
|
|
|
-const MENU_KEY_ALIASES = {
|
|
|
- '/admin/cg/mall': 'mall',
|
|
|
- '/admin/cg/item': 'itemMall',
|
|
|
- '/admin/work/list': 'task',
|
|
|
- '/admin/goods/manage': 'goodsManage',
|
|
|
- '/admin/goods/add': 'addFlower',
|
|
|
- '/admin/goods/categoryV2?tab=0': 'flowerCategory',
|
|
|
- '/admin/goods/categorySort': 'flowerSort',
|
|
|
- '/admin/item/list2': 'plant',
|
|
|
- '/admin/goods/categoryV2?tab=1': 'plantCategory',
|
|
|
- '/admin/itemClass/sort': 'plantSort',
|
|
|
- '/admin/part/list': 'part',
|
|
|
- '/admin/changePrice/list2': 'changePrice',
|
|
|
- '/admin/breakage/list': 'breakage',
|
|
|
- '/pagesPurchase/order': 'buyItem',
|
|
|
- '/pagesPurchase/shopping': 'purchaseRecord',
|
|
|
- '/admin/goods/price-increase': 'priceIncrease',
|
|
|
- '/admin/shopNotice/list': 'shopNotice',
|
|
|
- '/admin/homePageConfig/index': 'homePageConfig',
|
|
|
- '/admin/billing/freeRefundList': 'freeRefundList',
|
|
|
- '/admin/custom/selectCustom?style=1&refund=1': 'freeRefund',
|
|
|
- goItemKd: 'itemBill',
|
|
|
- goItemKjKd: 'itemQuickBill'
|
|
|
-}
|
|
|
-
|
|
|
-const canonicalizeMenuKeys = keys => {
|
|
|
- return (keys || []).map(key => MENU_KEY_ALIASES[key] || key)
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 按默认顺序重排:默认里有的按默认排,其余追加在后
|
|
|
- */
|
|
|
-const orderKeysByDefault = (keys, defaultKeys) => {
|
|
|
- const set = {}
|
|
|
- ;(keys || []).forEach(key => {
|
|
|
- if (key) set[key] = true
|
|
|
- })
|
|
|
- const ordered = []
|
|
|
- ;(defaultKeys || []).forEach(key => {
|
|
|
- if (set[key]) {
|
|
|
- ordered.push(key)
|
|
|
- delete set[key]
|
|
|
- }
|
|
|
- })
|
|
|
- ;(keys || []).forEach(key => {
|
|
|
- if (set[key]) {
|
|
|
- ordered.push(key)
|
|
|
- delete set[key]
|
|
|
- }
|
|
|
- })
|
|
|
- return ordered
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 缓存菜单补入退款入口:插在报损后(或退款后),避免旧缓存看不到新入口
|
|
|
- */
|
|
|
-const ensureRefundMenuKeys = keys => {
|
|
|
- const next = keys.slice()
|
|
|
- if (!next.includes('freeRefund')) {
|
|
|
- const i = next.indexOf('breakage')
|
|
|
- next.splice(i > -1 ? i + 1 : next.length, 0, 'freeRefund')
|
|
|
- }
|
|
|
- if (!next.includes('freeRefundList')) {
|
|
|
- const i = next.indexOf('freeRefund')
|
|
|
- next.splice(i > -1 ? i + 1 : next.length, 0, 'freeRefundList')
|
|
|
- }
|
|
|
- return next
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 合并栏规范化:去掉花束商城码,花材商城码置顶,并按默认顺序重排(任务在买花记录后)
|
|
|
- */
|
|
|
-const normalizeBizMenuKeys = keys => {
|
|
|
- let next = canonicalizeMenuKeys(keys)
|
|
|
- next = next.filter(key => !REMOVED_BIZ_MENU_KEYS.includes(key))
|
|
|
- next = orderKeysByDefault(next, HOME_MENU_DEFAULT_KEYS.bizMenus)
|
|
|
- // 默认里有、缓存没有的入口也补上(退款/买花记录/任务等)
|
|
|
- HOME_MENU_DEFAULT_KEYS.bizMenus.forEach(key => {
|
|
|
- if (!next.includes(key)) {
|
|
|
- next.push(key)
|
|
|
- }
|
|
|
- })
|
|
|
- next = orderKeysByDefault(next, HOME_MENU_DEFAULT_KEYS.bizMenus)
|
|
|
- return next
|
|
|
-}
|
|
|
-
|
|
|
-export const getMenuByKeys = keys => {
|
|
|
- return keys.map(key => {
|
|
|
- // 兼容旧的分类路由缓存
|
|
|
- if (key === '/admin/goods/category') key = 'flowerCategory'
|
|
|
- if (key === '/admin/itemClass/list') key = 'plantCategory'
|
|
|
- if (key === '/admin/goods/category-new?tab=1') key = 'plantCategory'
|
|
|
- if (key === '/admin/goods/category-new?tab=0' || key === '/admin/goods/category-new') key = 'flowerCategory'
|
|
|
-
|
|
|
- let item = HOME_MENU_ITEMS[key]
|
|
|
- if (!item) {
|
|
|
- APPLY_MENU_GROUPS.some(group => {
|
|
|
- const found = group.list.find(menu => getMenuItemKey(menu) === key || menu.url === key)
|
|
|
- if (found) {
|
|
|
- item = found
|
|
|
- return true
|
|
|
- }
|
|
|
- return false
|
|
|
- })
|
|
|
- }
|
|
|
- return item ? { ...item, key } : null
|
|
|
- }).filter(Boolean)
|
|
|
-}
|
|
|
-
|
|
|
-export const MENU_EDITOR_SCOPE = {
|
|
|
- quickMenus: null,
|
|
|
- bizMenus: '花束花材',
|
|
|
- flowerMenus: '花束花材',
|
|
|
- plantMenus: '花束花材'
|
|
|
-}
|
|
|
-
|
|
|
-export const getApplyCatalog = () => {
|
|
|
- return APPLY_MENU_GROUPS.map(group => ({
|
|
|
- ...group,
|
|
|
- list: group.list
|
|
|
- .filter(item => group.title !== '花束花材' || !isRemovedFlowerMenuItem(item))
|
|
|
- .map(item => ({ ...item, key: getMenuItemKey(item) }))
|
|
|
- }))
|
|
|
-}
|
|
|
-
|
|
|
-export const getEditorCatalog = menuType => {
|
|
|
- const catalog = getApplyCatalog()
|
|
|
- const scopeTitle = MENU_EDITOR_SCOPE[menuType]
|
|
|
- if (scopeTitle) {
|
|
|
- return catalog.filter(group => group.title === scopeTitle)
|
|
|
- }
|
|
|
- return catalog
|
|
|
-}
|
|
|
-
|
|
|
-export const isSameMenuEntry = (storedKey, catalogItem) => {
|
|
|
- if (storedKey === catalogItem.key) {
|
|
|
- return true
|
|
|
- }
|
|
|
- const stored = HOME_MENU_ITEMS[storedKey]
|
|
|
- if (!stored) {
|
|
|
- return false
|
|
|
- }
|
|
|
- if (catalogItem.url && stored.url && catalogItem.url === stored.url) {
|
|
|
- return true
|
|
|
- }
|
|
|
- if (catalogItem.action && stored.action && catalogItem.action === stored.action) {
|
|
|
- return true
|
|
|
- }
|
|
|
- return false
|
|
|
-}
|
|
|
-
|
|
|
-export const findStoredKeyIndex = (keys, catalogItem) => {
|
|
|
- const direct = keys.indexOf(catalogItem.key)
|
|
|
- if (direct > -1) {
|
|
|
- return direct
|
|
|
- }
|
|
|
- return keys.findIndex(key => isSameMenuEntry(key, catalogItem))
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 读取本地缓存菜单;bizMenus 会从旧 flower/plant 缓存合并迁移,并自动补入退款入口
|
|
|
- */
|
|
|
-export const getStoredMenuKeys = type => {
|
|
|
- const storageKey = HOME_MENU_STORAGE_KEYS[type]
|
|
|
- const defaultKeys = HOME_MENU_DEFAULT_KEYS[type] || []
|
|
|
- let storedKeys = []
|
|
|
- if (storageKey) {
|
|
|
- const stored = uni.getStorageSync(storageKey)
|
|
|
- if (Array.isArray(stored)) {
|
|
|
- storedKeys = stored
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 合并栏:结构版本变更时直接用默认顺序,避免旧缓存把「任务」卡在商城码后面
|
|
|
- if (type === 'bizMenus') {
|
|
|
- const schema = uni.getStorageSync(HOME_MENU_BIZ_SCHEMA_KEY)
|
|
|
- if (Number(schema) !== HOME_MENU_BIZ_SCHEMA) {
|
|
|
- const keys = HOME_MENU_DEFAULT_KEYS.bizMenus.slice()
|
|
|
- if (storageKey) {
|
|
|
- uni.setStorageSync(storageKey, keys)
|
|
|
- }
|
|
|
- uni.setStorageSync(HOME_MENU_BIZ_SCHEMA_KEY, HOME_MENU_BIZ_SCHEMA)
|
|
|
- return keys
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 合并栏:优先 bizMenus 缓存;否则合并旧花束+绿植缓存
|
|
|
- if (type === 'bizMenus' && !storedKeys.length) {
|
|
|
- const flowerStored = uni.getStorageSync(HOME_MENU_STORAGE_KEYS.flowerMenus)
|
|
|
- const plantStored = uni.getStorageSync(HOME_MENU_STORAGE_KEYS.plantMenus)
|
|
|
- const flowerKeys = Array.isArray(flowerStored) && flowerStored.length
|
|
|
- ? flowerStored
|
|
|
- : HOME_MENU_DEFAULT_KEYS.flowerMenus
|
|
|
- const plantKeys = Array.isArray(plantStored) && plantStored.length
|
|
|
- ? plantStored
|
|
|
- : HOME_MENU_DEFAULT_KEYS.plantMenus
|
|
|
- storedKeys = mergeUniqueKeys(
|
|
|
- flowerKeys.filter(key => !REMOVED_FLOWER_MENU_KEYS.includes(key)),
|
|
|
- plantKeys
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- let keys = storedKeys.length ? storedKeys : defaultKeys
|
|
|
- keys = keys.filter(key => key !== 'allApply')
|
|
|
- if (type === 'flowerMenus' || type === 'bizMenus') {
|
|
|
- keys = keys.filter(key => !REMOVED_FLOWER_MENU_KEYS.includes(key))
|
|
|
- if (keys.includes('priceIncrease') && !keys.includes('shopNotice')) {
|
|
|
- const priceIndex = keys.indexOf('priceIncrease')
|
|
|
- keys.splice(priceIndex + 1, 0, 'shopNotice')
|
|
|
- }
|
|
|
- }
|
|
|
- if (type === 'bizMenus') {
|
|
|
- keys = normalizeBizMenuKeys(keys)
|
|
|
- }
|
|
|
- if (type === 'bizMenus' || type === 'plantMenus') {
|
|
|
- keys = ensureRefundMenuKeys(keys)
|
|
|
- }
|
|
|
- // 合并栏变更后落盘,覆盖旧缓存
|
|
|
- if (type === 'bizMenus' && storageKey) {
|
|
|
- const existed = uni.getStorageSync(storageKey)
|
|
|
- const same = Array.isArray(existed)
|
|
|
- && existed.length === keys.length
|
|
|
- && existed.every((key, i) => key === keys[i])
|
|
|
- if (!same) {
|
|
|
- uni.setStorageSync(storageKey, keys)
|
|
|
- }
|
|
|
- }
|
|
|
- return keys
|
|
|
-}
|
|
|
-
|
|
|
-export const navigateMenuItem = (vm, item) => {
|
|
|
- if (item.action && typeof vm[item.action] === 'function') {
|
|
|
- vm[item.action]()
|
|
|
- return
|
|
|
- }
|
|
|
- if (vm.loginInfo && vm.loginInfo.pfShopId && Number(vm.loginInfo.pfShopId) > 0 && item.pf === 0) {
|
|
|
- vm.$msg('开发中')
|
|
|
- return
|
|
|
- }
|
|
|
- vm.$util.pageTo(item)
|
|
|
-}
|
|
|
-
|
|
|
-export const HOME_MENU_BILLING_METHODS = {
|
|
|
- goItemKjKd() {
|
|
|
- if (this.myShopInfo && Number(this.myShopInfo.defaultCustomId) > 0) {
|
|
|
- this.$util.pageTo({ url: '/admin/billing/index2?customId=' + this.myShopInfo.defaultCustomId })
|
|
|
- } else {
|
|
|
- this.$msg('请设置快捷开单的对应客户')
|
|
|
- }
|
|
|
- },
|
|
|
- goItemKd() {
|
|
|
- this.$util.pageTo({ url: '/admin/custom/selectCustom' })
|
|
|
- }
|
|
|
-}
|