fix: 修复授权管理页面价格显示和编辑问题
- 列表页面添加价格列显示 - 添加/编辑页面价格字段单独一行 - 使用shadcn官方Input组件 - 编辑页面价格修改后正确保存 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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,7 +231,6 @@ onMounted(() => {
|
||||
</UiSelect>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div class="space-y-2">
|
||||
<UiLabel>{{ t('admin.agentApps.createForm.selectCardType') }} <span class="text-destructive">*</span></UiLabel>
|
||||
<UiSelect v-model="formData.card_type_id" :disabled="saving">
|
||||
@@ -259,9 +249,9 @@ onMounted(() => {
|
||||
<UiLabel for="price">{{ t('admin.agentApps.createForm.price') }} <span class="text-destructive">*</span></UiLabel>
|
||||
<div class="relative">
|
||||
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground">¥</span>
|
||||
<UiInput
|
||||
<Input
|
||||
id="price"
|
||||
v-model.number="formData.price"
|
||||
v-model="formData.price"
|
||||
type="number"
|
||||
class="pl-7"
|
||||
:placeholder="t('admin.agentApps.createForm.pricePlaceholder')"
|
||||
@@ -269,7 +259,6 @@ onMounted(() => {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</UiCardContent>
|
||||
</UiCard>
|
||||
</div>
|
||||
|
||||
@@ -66,6 +66,19 @@ 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', {}, '状态'),
|
||||
|
||||
@@ -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,7 +217,6 @@ onMounted(() => {
|
||||
</UiSelect>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div class="space-y-2">
|
||||
<UiLabel>{{ t('admin.agentApps.createForm.selectCardType') }} <span class="text-destructive">*</span></UiLabel>
|
||||
<UiSelect v-model="formData.card_type_id" :disabled="!formData.application_id || saving">
|
||||
@@ -235,9 +235,9 @@ onMounted(() => {
|
||||
<UiLabel for="price">{{ t('admin.agentApps.createForm.price') }} <span class="text-destructive">*</span></UiLabel>
|
||||
<div class="relative">
|
||||
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground">¥</span>
|
||||
<UiInput
|
||||
<Input
|
||||
id="price"
|
||||
v-model.number="formData.price"
|
||||
v-model="formData.price"
|
||||
type="number"
|
||||
class="pl-7"
|
||||
:placeholder="t('admin.agentApps.createForm.pricePlaceholder')"
|
||||
@@ -245,7 +245,6 @@ onMounted(() => {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<UiLabel for="remark">{{ t('admin.agentApps.createForm.remark') }}</UiLabel>
|
||||
|
||||
Reference in New Issue
Block a user