From 1710f687a61ca8ded9f95c1198f9f9f68f7ce082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8?= Date: Mon, 1 Jun 2026 15:34:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=81=E7=A7=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/modules/trade/variety.ts | 5 ++++ src/views/trade/variety/index.vue | 46 ++++++++++++------------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/api/modules/trade/variety.ts b/src/api/modules/trade/variety.ts index a21fa93..1e661af 100644 --- a/src/api/modules/trade/variety.ts +++ b/src/api/modules/trade/variety.ts @@ -22,4 +22,9 @@ export async function editVarietyApi(params: any): Promise { //同步合约品种 export async function syncVarietyApi(): Promise { return request.post('/contractVariety/syncVariety', {}) +} + +//获取品种枚举 +export async function getVarietyEnumsApi(): Promise { + return request.get('/contractVariety/getVarietyEnums') } \ No newline at end of file diff --git a/src/views/trade/variety/index.vue b/src/views/trade/variety/index.vue index d0112fd..992f028 100644 --- a/src/views/trade/variety/index.vue +++ b/src/views/trade/variety/index.vue @@ -80,6 +80,7 @@ import { editVarietyApi, createVarietyApi, syncVarietyApi, + getVarietyEnumsApi, } from '@/api/modules/trade/variety' // 上传图片 import { uploadImageApi } from '@/api/modules/upload' @@ -160,28 +161,7 @@ const varietyFormRules = ref(rules()) const dialogFormItemOptions = ref(DialogFormItem) const varietyFormOptionsMap = ref({ group_id: [], - type: [ - { - label: '外汇', - value: 1, - }, - { - label: '金属', - value: 2, - }, - { - label: '能源', - value: 3, - }, - { - label: '指数', - value: 4, - }, - { - label: '数字货币', - value: 5, - }, - ], + type: [], }) // 选中行 const selectedRow = ref(null) @@ -190,12 +170,19 @@ const colSpan = ref(12) const fileList = ref([]) -const typeMap: any = { - 1: '外汇', - 2: '金属', - 3: '能源', - 4: '指数', - 5: '数字货币', +// 类型枚举列表 +const typeList = ref([]) + +// 获取品种枚举 +const getVarietyEnums = async () => { + const res = await getVarietyEnumsApi() + if (res) { + typeList.value = res.map((item: any) => ({ + label: item.name, + value: item.type, + })) + varietyFormOptionsMap.value.type = typeList.value as any + } } /** @@ -228,7 +215,7 @@ const getVarietyList = async () => { longStockFee: item.fee_inventory_long, shortStockFee: item.fee_inventory_short, profitLevel: item.stop_loss_level, - type: typeMap[item.type], + type: typeList.value.find((t: any) => t.value === item.type)?.label || '', image: item.image, })) } finally { @@ -249,6 +236,7 @@ const getTradeGroupList = async () => { * @description: 页面加载完成需要请求的数据 */ onMounted(() => { + getVarietyEnums() getVarietyList() getTradeGroupList() })