|
@@ -1,9 +1,10 @@
|
|
|
|
|
+import { getThirdMenuData } from '@/common/setup/table/button';
|
|
|
import { getItemEnum } from '@/services/bus/allEnum';
|
|
import { getItemEnum } from '@/services/bus/allEnum';
|
|
|
import { QueryDeliveryGoodsDetail } from '@/services/go/ermcp/goodsInfo';
|
|
import { QueryDeliveryGoodsDetail } from '@/services/go/ermcp/goodsInfo';
|
|
|
import { ErmcpDeliveryGoodsDetailEx, MenuList } from '@/services/go/ermcp/goodsInfo/interface';
|
|
import { ErmcpDeliveryGoodsDetailEx, MenuList } from '@/services/go/ermcp/goodsInfo/interface';
|
|
|
import { mergeObj } from '@/utils/objHandle';
|
|
import { mergeObj } from '@/utils/objHandle';
|
|
|
import { message } from 'ant-design-vue';
|
|
import { message } from 'ant-design-vue';
|
|
|
-import { reactive, ref } from 'vue';
|
|
|
|
|
|
|
+import { reactive, Ref, ref } from 'vue';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 初始化 现货品种对象数据
|
|
* 初始化 现货品种对象数据
|
|
@@ -46,17 +47,41 @@ export function initMenu(): MenuList[] {
|
|
|
]
|
|
]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+interface MenuType {
|
|
|
|
|
+ menuList: Ref<MenuList[]>;
|
|
|
|
|
+ menuMap: Map<string, number>;
|
|
|
|
|
+}
|
|
|
|
|
+/**
|
|
|
|
|
+ * 获取菜单数据
|
|
|
|
|
+ * @returns MenuType
|
|
|
|
|
+ */
|
|
|
|
|
+function getInitMenuData(): MenuType {
|
|
|
|
|
+ const list = getThirdMenuData();
|
|
|
|
|
+ const obj = list.find(e => e.code === 'goods_info_spot'); // 现货品种 数据
|
|
|
|
|
+ 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 }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取现货品种数据
|
|
* 获取现货品种数据
|
|
|
* @returns
|
|
* @returns
|
|
|
*/
|
|
*/
|
|
|
export function handleDG() {
|
|
export function handleDG() {
|
|
|
|
|
+ const { menuList, menuMap } = getInitMenuData()
|
|
|
const loading = ref<boolean>(false);
|
|
const loading = ref<boolean>(false);
|
|
|
// 现货品种列表
|
|
// 现货品种列表
|
|
|
const deliveryGoodsList = ref<ErmcpDeliveryGoodsDetailEx[]>([])
|
|
const deliveryGoodsList = ref<ErmcpDeliveryGoodsDetailEx[]>([])
|
|
|
// 选中的具体某一天现货品种数据
|
|
// 选中的具体某一天现货品种数据
|
|
|
const selctedDeliveryGoods = reactive<ErmcpDeliveryGoodsDetailEx>(initDG())
|
|
const selctedDeliveryGoods = reactive<ErmcpDeliveryGoodsDetailEx>(initDG())
|
|
|
- const menuList = ref<MenuList[]>(initMenu());
|
|
|
|
|
|
|
+ // const menuList = ref<MenuList[]>(initMenu());
|
|
|
// 获取现货品种数据
|
|
// 获取现货品种数据
|
|
|
function queryDG(param?: number) {
|
|
function queryDG(param?: number) {
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
@@ -65,9 +90,19 @@ export function handleDG() {
|
|
|
res.forEach(e => {
|
|
res.forEach(e => {
|
|
|
const { dgstatus, isvalid, deliverygoodsname, deliverygoodsid } = e.data
|
|
const { dgstatus, isvalid, deliverygoodsname, deliverygoodsid } = e.data
|
|
|
if (isvalid) { // 有效
|
|
if (isvalid) { // 有效
|
|
|
- const index = dgstatus ? 0 : 1; // 0:未激活 1:正常
|
|
|
|
|
- const obj = { key: deliverygoodsid.toString(), title: deliverygoodsname }
|
|
|
|
|
- menuList.value[index].children?.push(obj)
|
|
|
|
|
|
|
+ const normal = 'goods_info_spot_normal', disable = 'goods_info_spot_disable';
|
|
|
|
|
+ const result = { key: deliverygoodsid.toString(), title: deliverygoodsname }
|
|
|
|
|
+ if (dgstatus) { //1:正常
|
|
|
|
|
+ if (menuMap.has(normal)) {
|
|
|
|
|
+ const index = menuMap.get(normal) as number;
|
|
|
|
|
+ menuList.value[index].children?.push(result)
|
|
|
|
|
+ }
|
|
|
|
|
+ } else { // 0:未激活
|
|
|
|
|
+ if (menuMap.has(disable)) {
|
|
|
|
|
+ const index = menuMap.get(disable) as number;
|
|
|
|
|
+ menuList.value[index].children?.push(result)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
// 获取默认第一条数据
|
|
// 获取默认第一条数据
|
|
@@ -105,4 +140,16 @@ export function getGoodsUnit(unit: number) {
|
|
|
*/
|
|
*/
|
|
|
export function getGoodsUnitList() {
|
|
export function getGoodsUnitList() {
|
|
|
return getItemEnum('goodsunit')
|
|
return getItemEnum('goodsunit')
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 处理现货品种的状态
|
|
|
|
|
+ * @returns
|
|
|
|
|
+ */
|
|
|
|
|
+export function handleGDStatue() {
|
|
|
|
|
+ const isNormal = ref<boolean>(true) // true => 正常; false => 停用
|
|
|
|
|
+ function changeStatue(value: boolean) {
|
|
|
|
|
+ isNormal.value = value;
|
|
|
|
|
+ }
|
|
|
|
|
+ return { isNormal, changeStatue }
|
|
|
}
|
|
}
|