From 8385329056b1fdeb6ceebaea484fbefc4c194c47 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 9 May 2026 19:45:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E4=BB=B7=E6=A0=BC=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=92=8C=E7=BC=96=E8=BE=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 列表页面添加价格列显示 - 添加/编辑页面价格字段单独一行 - 使用shadcn官方Input组件 - 编辑页面价格修改后正确保存 Co-Authored-By: Claude Opus 4.7 --- frontend/src/pages/admin/agent-apps/[id].vue | 67 ++++++++----------- .../admin/agent-apps/components/columns.ts | 27 ++++++-- .../src/pages/admin/agent-apps/create.vue | 55 ++++++++------- 3 files changed, 75 insertions(+), 74 deletions(-) diff --git a/frontend/src/pages/admin/agent-apps/[id].vue b/frontend/src/pages/admin/agent-apps/[id].vue index 15ea44f..cbc534e 100644 --- a/frontend/src/pages/admin/agent-apps/[id].vue +++ b/frontend/src/pages/admin/agent-apps/[id].vue @@ -6,6 +6,7 @@ import { useRoute, useRouter } from 'vue-router' import { toast } from 'vue-sonner' import { BasicPage } from '@/components/global-layout' +import { Input } from '@/components/ui/input' import api from '@/services/api' const router = useRouter() @@ -42,7 +43,6 @@ const formData = ref({ application_id: '', card_type_id: '', price: 0, - remark: '', }) const selectedAgent = computed(() => { @@ -129,23 +129,14 @@ async function fetchAgentApp() { } } +// 不自动更新价格,让用户手动输入 watch(selectedCardType, (ct) => { - if (ct && !loading.value) { + if (ct && loading.value) { formData.value.price = ct.price } }) async function handleSubmit() { - if (!formData.value.agent_id) { - toast.error(t('admin.agentApps.createForm.selectAgentRequired')) - return - } - - if (!formData.value.application_id) { - toast.error(t('admin.agentApps.createForm.selectAppRequired')) - return - } - if (!formData.value.card_type_id) { toast.error(t('admin.agentApps.createForm.selectCardRequired')) return @@ -240,34 +231,32 @@ onMounted(() => { -
-
- {{ t('admin.agentApps.createForm.selectCardType') }} * - - - - - - - {{ ct.name }} - - - -
+
+ {{ t('admin.agentApps.createForm.selectCardType') }} * + + + + + + + {{ ct.name }} + + + +
-
- {{ t('admin.agentApps.createForm.price') }} * -
- ¥ - -
+
+ {{ t('admin.agentApps.createForm.price') }} * +
+ ¥ +
diff --git a/frontend/src/pages/admin/agent-apps/components/columns.ts b/frontend/src/pages/admin/agent-apps/components/columns.ts index 7a8b9d0..7acae14 100644 --- a/frontend/src/pages/admin/agent-apps/components/columns.ts +++ b/frontend/src/pages/admin/agent-apps/components/columns.ts @@ -49,13 +49,13 @@ export function getColumns(actions: { if (!cardTypes || cardTypes.length === 0) { return h('span', { class: 'text-muted-foreground' }, '-') } - - return h('div', { class: 'flex flex-wrap gap-1' }, - cardTypes.map(ct => + + return h('div', { class: 'flex flex-wrap gap-1' }, + cardTypes.map(ct => h('span', { class: `inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs ${ - ct.can_generate - ? 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400' + ct.can_generate + ? 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400' : 'bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400' }` }, [ @@ -66,13 +66,26 @@ export function getColumns(actions: { ) }, }, + { + accessorKey: 'card_types', + id: 'price', + header: () => h('span', {}, '价格'), + cell: ({ row }) => { + const cardTypes = row.getValue('card_types') as AgentApp['card_types'] + if (!cardTypes || cardTypes.length === 0) { + return h('span', { class: 'text-muted-foreground' }, '-') + } + const price = cardTypes[0]?.price || 0 + return h('span', { class: 'font-medium' }, `¥${price}`) + }, + }, { accessorKey: 'status', header: () => h('span', {}, '状态'), cell: ({ row }) => { const status = row.getValue('status') as string const isActive = status === 'active' - return h(Badge, { variant: isActive ? 'default' : 'secondary' }, () => + return h(Badge, { variant: isActive ? 'default' : 'secondary' }, () => isActive ? '已启用' : '已禁用' ) }, @@ -137,4 +150,4 @@ export function getColumns(actions: { }, }, ] -} +} \ No newline at end of file diff --git a/frontend/src/pages/admin/agent-apps/create.vue b/frontend/src/pages/admin/agent-apps/create.vue index e226322..dc3cd07 100644 --- a/frontend/src/pages/admin/agent-apps/create.vue +++ b/frontend/src/pages/admin/agent-apps/create.vue @@ -6,6 +6,7 @@ import { useRouter } from 'vue-router' import { toast } from 'vue-sonner' import { BasicPage } from '@/components/global-layout' +import { Input } from '@/components/ui/input' import api from '@/services/api' const router = useRouter() @@ -216,34 +217,32 @@ onMounted(() => {
-
-
- {{ t('admin.agentApps.createForm.selectCardType') }} * - - - - - - - {{ ct.name }} - - - -
+
+ {{ t('admin.agentApps.createForm.selectCardType') }} * + + + + + + + {{ ct.name }} + + + +
-
- {{ t('admin.agentApps.createForm.price') }} * -
- ¥ - -
+
+ {{ t('admin.agentApps.createForm.price') }} * +
+ ¥ +
@@ -323,4 +322,4 @@ onMounted(() => {
- + \ No newline at end of file