算力卡

This commit is contained in:
qiuyuan 2026-01-27 17:06:42 +08:00
parent 7cd0f0fb05
commit 7e5f276930
2 changed files with 58 additions and 12 deletions

View File

@ -3,6 +3,12 @@ import request from '@/utils/request'
//获取算力卡列表
export const getCardsList = (params) => request.basic.get('/api/v1/cards', params)
// 算力卡删除
export const deleteCard = (id) => request.basic.delete(`/api/v1/cards/${id}`)
// 下架算力卡
export const editCard = (id, params) => request.basic.put(`/api/v1/cards/${id}`, params)
//获取算力中心列表
export const getCentersList = (params) => request.basic.get('/api/v1/centers', params)
@ -17,3 +23,4 @@ export const addCenter = (data) => request.basic.post('/api/v1/centers', data)
// 删除算力中心
export const deleteCenter = (id) => request.basic.delete(`/api/v1/centers/${id}`)

View File

@ -73,13 +73,13 @@
</a-tag>
</template>
<template v-if="'is_recommend' === column.key">
<template v-if="'status' === column.key">
<!--状态-->
<a-tag v-if="record.banner_type == true" color="processing">
<a-tag v-if="record.status == 'ENABLED'" color="processing">
启用
</a-tag>
<!--状态-->
<a-tag v-else color="processing">
<a-tag v-else color="red">
禁用
</a-tag>
</template>
@ -92,10 +92,18 @@
<template v-if="'action' === column.key">
<!-- <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip>
<template #title> {{ $t('pages.system.role.edit') }}</template>
<template #title> 下架算力卡</template>
<edit-outlined />
</a-tooltip>
</x-action-button> -->
<x-action-button @click="handelEdit(record)" :disabled="record.status === 'DISABLED'">
<a-tooltip>
<template #title>
{{ record.status === 'DISABLED' ? '已下架' : '下架算力卡' }}
</template>
<edit-outlined />
</a-tooltip>
</x-action-button>
<x-action-button @click="handleRemove(record)">
<a-tooltip>
<template #title> {{ $t('pages.system.delete') }}</template>
@ -150,7 +158,7 @@ const columns = [
dataIndex: 'status',
key: 'status',
width: 150,
customRender: ({ text }) => disabledDict.getLabel(text) || text,
// customRender: ({ text }) => disabledDict.getLabel(text) || text,
},
{ title: t('button.action'), key: 'action', fixed: 'right', width: 120 },
];
@ -194,14 +202,14 @@ async function getPageList() {
*/
function handleRemove({ id }) {
Modal.confirm({
title: t('pages.system.role.delTip'),
content: t('button.confirm'),
title: '提示',
content: '是否删除该算力卡?',
okText: t('button.confirm'),
onOk: () => {
return new Promise((resolve, reject) => {
; (async () => {
try {
const { success } = await apis.role.delRole(id).catch(() => {
const { success } = await apis.computing.deleteCard(id).catch(() => {
throw new Error()
})
if (config('http.code.success') === success) {
@ -218,6 +226,37 @@ function handleRemove({ id }) {
})
}
//
function handelEdit({ id, status }) {
if (status === 'DISABLED') {
message.warning('该算力卡已下架,无法重复操作');
return;
}
Modal.confirm({
title: '提示',
content: '是否下架该算力卡?',
okText: t('button.confirm'),
onOk: () => {
return new Promise((resolve, reject) => {
; (async () => {
try {
const { success } = await apis.computing.editCard(id).catch(() => {
throw new Error()
})
if (config('http.code.success') === success) {
resolve()
message.success('下架成功')
await getPageList()
}
} catch (error) {
reject()
}
})()
})
},
})
}
/**
* 分页
*/