Commit c43550c0 by Jony.L

修复算力资源sku管理页面中,点击编辑时SPU信息不显示的问题

parent 167cacff
......@@ -86,6 +86,7 @@
</template>
<script setup lang="ts">
import { ResourceSkuApi, ResourceSku } from '@/api/compute/resourcesku'
import { ResourceSpuApi } from '@/api/compute/resourcespu'
import ResourceSpuSelectDialog from '../resourcespu/ResourceSpuSelectDialog.vue'
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from "@/utils/dict"
import { fenToYuan, yuanToFen } from '@/utils'
......@@ -112,8 +113,15 @@ const formData = ref({
})
const selectedSpuName = ref('') // 选中的SPU名称显示
// 租赁时长选项
const durationOptions = getStrDictOptions(DICT_TYPE.COMPUTE_RESOURCE_DURATION)
// 租赁时长选项 - 确保value为字符串类型以匹配后端返回的数字
const durationOptions = computed(() => {
const options = getStrDictOptions(DICT_TYPE.COMPUTE_RESOURCE_DURATION)
// 将字典中的value转换为数字类型,以便与后端返回的数字类型匹配
return options.map(option => ({
...option,
value: option.value === '0' ? 0 : Number(option.value)
}))
})
// 价格的计算属性(元单位)
const paymentPriceYuan = computed({
......@@ -150,6 +158,12 @@ const open = async (type: string, id?: number) => {
formLoading.value = true
try {
formData.value = await ResourceSkuApi.getResourceSku(id)
// 获取关联的SPU信息并设置显示名称
if (formData.value.spuId) {
const spuInfo = await ResourceSpuApi.getResourceSpu(formData.value.spuId)
selectedSpu.value = spuInfo
selectedSpuName.value = spuInfo.name
}
} finally {
formLoading.value = false
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment