import { getThirdMenuData } from '@/common/setup/table/button';
import { MenuList } from '@/services/go/ermcp/goodsInfo/interface';
import { Ref, ref } from 'vue';
import {ResultInfo} from "@/common/methods/request";

interface MenuType {
    menuList: Ref<MenuList[]>;
    menuMap: Map<string, number>;
}
/**
 * 获取菜单数据
 * @returns MenuType
 */
export function getInitMenuData(code: 'goods_info_spot' | 'goods_info_hedge'): MenuType {
    const list = getThirdMenuData();
    const obj = list.find(e => e.code === code); // 现货品种 数据
    const menuMap = new Map<string, number>();  // key 正常和停用对应的code，value是它们所在的索引值
    const menuList = ref<MenuList[]>([])
    if (obj && obj.children) {
        obj.children.forEach((e, i) => {
            const { code, title } = e;
            menuMap.set(code, i)
            menuList.value.push({ key: code, title, children: [] })
        })
    }
    return { menuList, menuMap }
}

/************** 接口请求相关提示 ****************/

// 停用提示
export const DeliveryGoodsSign = new Map<number, ResultInfo>([
    [0, ['停用现货品种成功', '停用现货品种失败:']],
    [1, ['恢复现货品种成功', '恢复现货品种失败:']],
])

export const DeliveryTypeSign = new Map<number, ResultInfo>([
    [1, ['新增现货品种成功', '新增现货品种失败:']],
    [2, ['修改现货品种成功', '修改现货品种失败:']],
])
