fix(props): isolate gift send forms

This commit is contained in:
zhx 2026-07-22 17:04:30 +08:00
parent 62632adc7e
commit 36999097d8

View File

@ -1,35 +1,67 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-row :gutter="10"> <el-tabs v-if="giftTabs.length" v-model="activeGiftTab" type="border-card">
<!-- 赠送道具 --> <el-tab-pane
<el-col v-if="buttonPermissions.includes('send:props')"> v-for="tab in giftTabs"
<send-props /> :key="tab.name"
</el-col> :label="$t(tab.titleKey)"
<!-- 赠送徽章 --> :name="tab.name"
<el-col v-if="buttonPermissions.includes('send:props:badge')"> >
<send-badge /> <!-- 只挂载当前赠送表单避免未选择的赠送类型显示和参与必填校验 -->
</el-col> <component :is="tab.component" v-if="activeGiftTab === tab.name" />
<!-- 赠送道具券 --> </el-tab-pane>
<el-col v-if="buttonPermissions.includes('send:props:coupon')"> </el-tabs>
<send-ticket />
</el-col>
</el-row>
</div> </div>
</template> </template>
<script> <script>
import SendProps from "./send-props"; import SendProps from './send-props'
import SendBadge from "./send-badge"; import SendBadge from './send-badge'
import SendTicket from "./send-ticket"; import SendTicket from './send-ticket'
import { mapGetters } from "vuex"; import { mapGetters } from 'vuex'
export default { export default {
components: { SendProps, SendBadge, SendTicket }, components: { SendProps, SendBadge, SendTicket },
data() { data() {
return {}; return {
activeGiftTab: '',
giftTabDefinitions: [
{
name: 'props',
titleKey: 'pages.propsSendTool.title.props',
permission: 'send:props',
component: 'SendProps'
},
{
name: 'badge',
titleKey: 'pages.propsSendTool.title.badge',
permission: 'send:props:badge',
component: 'SendBadge'
},
{
name: 'ticket',
titleKey: 'pages.propsSendTool.title.ticket',
permission: 'send:props:coupon',
component: 'SendTicket'
}
]
}
}, },
computed: { computed: {
...mapGetters(["buttonPermissions"]) ...mapGetters(['buttonPermissions']),
giftTabs() {
return this.giftTabDefinitions.filter(tab => this.buttonPermissions.includes(tab.permission))
}
}, },
created() {} watch: {
}; giftTabs: {
immediate: true,
handler(tabs) {
//
if (!tabs.some(tab => tab.name === this.activeGiftTab)) {
this.activeGiftTab = tabs.length ? tabs[0].name : ''
}
}
}
}
}
</script> </script>