Browse Source

fix: 添加角色频道获取逻辑并优化频道显示条件

zhangrenyuan/feature-20251215114424-现金管理三期
zhangrenyuan 4 weeks ago
parent
commit
27344d284e
  1. 27
      src/views/channelManage/fans/fans.vue
  2. 33
      src/views/channelManage/reward/reward.vue

27
src/views/channelManage/fans/fans.vue

@ -57,7 +57,8 @@ const beanConsumeFan = ref({
}) })
// //
const channels = ref([]) const channels = ref([])
//
const showChannelFilter = ref(false)
const getChannel = async function () { const getChannel = async function () {
try { try {
const result = await request({ const result = await request({
@ -76,6 +77,26 @@ const getChannel = async function () {
}) })
} }
} }
const getRoleChannel = async function () {
try {
if (!adminData.value || !adminData.value.roleId) {
showChannelFilter.value = true
return
}
const result = await request({
url: '/beanConsume/getRoleChannel',
data: { roleId: adminData.value.roleId }
})
const data = result.data ?? result
const channelName = typeof data === 'string' ? data : data.channelName
const allLabel = t('common.all')
showChannelFilter.value = channelName === allLabel || channelName === '全部'
} catch (error) {
console.log('请求角色频道失败', error)
showChannelFilter.value = true
}
}
// // // //
// const filterChannel = (query) => { // const filterChannel = (query) => {
// if (query) { // if (query) {
@ -390,10 +411,10 @@ const handleCurrentChange = function (val) {
onMounted(async function () { onMounted(async function () {
await getAdminData() await getAdminData()
await getRoleChannel()
await ConsumeSelectBy() await ConsumeSelectBy()
await getChannel() await getChannel()
await getDept() await getDept()
}) })
@ -500,7 +521,7 @@ const getTagText = (state) => {
<el-card class="card1" style="margin-bottom: 0.5vh;"> <el-card class="card1" style="margin-bottom: 0.5vh;">
<el-col style="margin-bottom: 1vh"> <el-col style="margin-bottom: 1vh">
<div class="select"> <div class="select">
<div class="selectRow">
<div class="selectRow" v-if="showChannelFilter">
<el-text class="text">{{ t('common.jwcode') }}</el-text> <el-text class="text">{{ t('common.jwcode') }}</el-text>
<el-input class="selectContent" v-model="beanConsumeFan.jwcode" :placeholder="t('common.jwcodePlaceholder')" clearable /> <el-input class="selectContent" v-model="beanConsumeFan.jwcode" :placeholder="t('common.jwcodePlaceholder')" clearable />
</div> </div>

33
src/views/channelManage/reward/reward.vue

@ -40,7 +40,6 @@ const formatTime = (val) => val ? dayjs(val).format('YYYY-MM-DD HH:mm:ss') : ''
/* /*
====================数据================================= ====================数据=================================
*/ */
//
const adminData = ref({}) const adminData = ref({})
// //
const tableData = ref([]) const tableData = ref([])
@ -83,7 +82,8 @@ const getGift = async function () {
// //
const channels = ref([]) const channels = ref([])
//
const showChannelFilter = ref(false)
const getChannel = async function () { const getChannel = async function () {
try { try {
const result = await request({ const result = await request({
@ -103,6 +103,26 @@ const getChannel = async function () {
} }
} }
const getRoleChannel = async function () {
try {
if (!adminData.value || !adminData.value.roleId) {
showChannelFilter.value = true
return
}
const result = await request({
url: '/beanConsume/getRoleChannel',
data: { roleId: adminData.value.roleId }
})
const data = result.data ?? result
const channelName = typeof data === 'string' ? data : data.channelName
const allLabel = t('common.all')
showChannelFilter.value = channelName === allLabel || channelName === '全部'
} catch (error) {
console.log('请求角色频道失败', error)
showChannelFilter.value = true
}
}
// //
const consumeTypes = ref([ const consumeTypes = ref([
{label: t('consume.consumeTypes.1'), value: 1}, {label: t('consume.consumeTypes.1'), value: 1},
@ -402,10 +422,11 @@ const handleCurrentChange = function (val) {
onMounted(async function () { onMounted(async function () {
await getAdminData() await getAdminData()
await selectLiveBy()
await getRoleChannel()
await getDept() await getDept()
await getGift()
await selectLiveBy()
await getChannel() await getChannel()
await getGift()
}) })
@ -538,7 +559,7 @@ const getTagText = (state) => {
<el-option v-for="(item, index) in dept" :key="index" :label="item" :value="item"/> <el-option v-for="(item, index) in dept" :key="index" :label="item" :value="item"/>
</el-select> </el-select>
</div> </div>
<div class="selectRow" style="width: 14vw;">
<div class="selectRow" style="min-width: 14vw;">
<el-text class="text">{{ t('common.giftName') }}</el-text> <el-text class="text">{{ t('common.giftName') }}</el-text>
<el-select class="selectContent" v-model="beanConsumeLive.gift" :placeholder="t('common.giftNamePlaceholder')" clearable <el-select class="selectContent" v-model="beanConsumeLive.gift" :placeholder="t('common.giftNamePlaceholder')" clearable
filterable filterable
@ -546,7 +567,7 @@ const getTagText = (state) => {
<el-option v-for="(item, index) in gifts" :key="index" :label="item" :value="item"/> <el-option v-for="(item, index) in gifts" :key="index" :label="item" :value="item"/>
</el-select> </el-select>
</div> </div>
<div class="selectRow" style="min-width: 12vw;">
<div class="selectRow" style="min-width: 12vw;" v-if="showChannelFilter">
<el-text class="textB" size="large">{{ t('common.channel') }}</el-text> <el-text class="textB" size="large">{{ t('common.channel') }}</el-text>
<el-select class="selectContent" v-model="beanConsumeLive.liveChannel" :placeholder="t('common.channelPlaceholder')" clearable <el-select class="selectContent" v-model="beanConsumeLive.liveChannel" :placeholder="t('common.channelPlaceholder')" clearable
filterable allow-create default-first-option> filterable allow-create default-first-option>

Loading…
Cancel
Save