From 87ba499f143619a1fdf45291c20a6fe6c793a046 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 9 May 2026 19:36:42 +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=86API=E8=B7=AF=E5=BE=84=E5=92=8C=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - POST /dev/agent-apps → POST /dev/agent-apps/authorize - PUT /dev/agent-apps/:id → PUT /dev/agent-apps/:id/card-types - 参考版本管理页面优化布局样式 - 编辑页面禁用代理和应用选择(不可修改) Co-Authored-By: Claude Opus 4.7 --- frontend/src/pages/admin/agent-apps/[id].vue | 138 ++++++++---------- .../src/pages/admin/agent-apps/create.vue | 134 +++++++++-------- 2 files changed, 124 insertions(+), 148 deletions(-) diff --git a/frontend/src/pages/admin/agent-apps/[id].vue b/frontend/src/pages/admin/agent-apps/[id].vue index f5be003..15ea44f 100644 --- a/frontend/src/pages/admin/agent-apps/[id].vue +++ b/frontend/src/pages/admin/agent-apps/[id].vue @@ -37,7 +37,7 @@ const agents = ref([]) const applications = ref([]) const cardTypes = ref([]) -const form = ref({ +const formData = ref({ agent_id: '', application_id: '', card_type_id: '', @@ -46,22 +46,22 @@ const form = ref({ }) const selectedAgent = computed(() => { - if (form.value.agent_id) { - return agents.value.find(a => String(a.id) === form.value.agent_id) + if (formData.value.agent_id) { + return agents.value.find(a => String(a.id) === formData.value.agent_id) } return null }) const selectedApplication = computed(() => { - if (form.value.application_id) { - return applications.value.find(app => String(app.id) === form.value.application_id) + if (formData.value.application_id) { + return applications.value.find(app => String(app.id) === formData.value.application_id) } return null }) const selectedCardType = computed(() => { - if (form.value.card_type_id) { - return cardTypes.value.find(ct => String(ct.id) === form.value.card_type_id) + if (formData.value.card_type_id) { + return cardTypes.value.find(ct => String(ct.id) === formData.value.card_type_id) } return null }) @@ -107,17 +107,16 @@ async function fetchAgentApp() { const agentApp = data?.agent_app || data if (agentApp) { - form.value.agent_id = String(agentApp.agent_id) - form.value.application_id = String(agentApp.application_id) - form.value.remark = agentApp.remark || '' + formData.value.agent_id = String(agentApp.agent_id) + formData.value.application_id = String(agentApp.application_id) await fetchCardTypes(String(agentApp.application_id)) // 取第一个卡类权限 if (agentApp.card_types && agentApp.card_types.length > 0) { const firstCardType = agentApp.card_types[0] - form.value.card_type_id = String(firstCardType.card_type_id) - form.value.price = firstCardType.price || 0 + formData.value.card_type_id = String(firstCardType.card_type_id) + formData.value.price = firstCardType.price || 0 } } } @@ -132,38 +131,34 @@ async function fetchAgentApp() { watch(selectedCardType, (ct) => { if (ct && !loading.value) { - form.value.price = ct.price + formData.value.price = ct.price } }) -async function handleSave() { - if (!form.value.agent_id) { +async function handleSubmit() { + if (!formData.value.agent_id) { toast.error(t('admin.agentApps.createForm.selectAgentRequired')) return } - if (!form.value.application_id) { + if (!formData.value.application_id) { toast.error(t('admin.agentApps.createForm.selectAppRequired')) return } - if (!form.value.card_type_id) { + if (!formData.value.card_type_id) { toast.error(t('admin.agentApps.createForm.selectCardRequired')) return } saving.value = true try { - await api.put(`/dev/agent-apps/${agentAppId.value}`, { - agent_id: Number(form.value.agent_id), - application_id: Number(form.value.application_id), + await api.put(`/dev/agent-apps/${agentAppId.value}/card-types`, { card_types: [{ - card_type_id: Number(form.value.card_type_id), + card_type_id: Number(formData.value.card_type_id), can_generate: true, - price: Number(form.value.price), + price: Number(formData.value.price), }], - discount: 0, - remark: form.value.remark, }) toast.success(t('admin.agentApps.createForm.updateSuccess')) router.push('/admin/agent-apps') @@ -209,48 +204,46 @@ onMounted(() => { {{ t('admin.agentApps.createForm.authConfigDesc') }} -
-
- {{ t('admin.agentApps.createForm.selectAgent') }} * - - - - - - - {{ agent.username }} - - - -
+
+ {{ t('admin.agentApps.createForm.selectAgent') }} + + + + + + + {{ agent.username }} + + + +
-
- {{ t('admin.agentApps.createForm.selectApp') }} * - - - - - - - {{ app.name }} - - - -
+
+ {{ t('admin.agentApps.createForm.selectApp') }} + + + + + + + {{ app.name }} + + +
{{ t('admin.agentApps.createForm.selectCardType') }} * - + @@ -268,7 +261,7 @@ onMounted(() => { ¥ {
- -
- {{ t('admin.agentApps.createForm.remark') }} -