fix(pl): 拆分小程序运输证件页签权限,并让证书齐备列表避开证件类型路由。
页签按独立菜单显示,销售办证员默认不含证书齐备;证书齐备接口先于通配证件路径注册,避免 plans 被当成证件类型。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
af79aa50a2
commit
66bad6b219
8 files changed
+171
-20
No files matched your search
@@ -13,6 +13,7 @@
|
||||
>
|
||||
<template #before-search>
|
||||
<van-tabs
|
||||
v-if="visibleTabs.length"
|
||||
v-model:active="tab"
|
||||
class="mp-customer-view-tabs"
|
||||
shrink
|
||||
@@ -20,11 +21,12 @@
|
||||
aria-label="运输证件管理"
|
||||
@change="onTab"
|
||||
>
|
||||
<van-tab name="archive" title="证件建档" />
|
||||
<van-tab name="contract" title="合同用证" />
|
||||
<van-tab name="usage" title="证件用量" />
|
||||
<van-tab name="plan" title="计划段次用证" />
|
||||
<van-tab name="ready" title="证书齐备" />
|
||||
<van-tab
|
||||
v-for="item in visibleTabs"
|
||||
:key="item.name"
|
||||
:name="item.name"
|
||||
:title="item.title"
|
||||
/>
|
||||
</van-tabs>
|
||||
</template>
|
||||
<template #after-search>
|
||||
@@ -104,8 +106,12 @@
|
||||
</van-dropdown-menu>
|
||||
</template>
|
||||
</MpBusinessHeader>
|
||||
<van-empty
|
||||
v-if="tabsReady && !visibleTabs.length"
|
||||
description="没有可使用的运输证件功能"
|
||||
/>
|
||||
<ArchiveTab
|
||||
v-if="tab === 'archive'"
|
||||
v-else-if="tabsReady && tab === 'archive'"
|
||||
:key="session + committed"
|
||||
:keyword="committed"
|
||||
:kind="archiveKind"
|
||||
@@ -113,15 +119,19 @@
|
||||
:expiring-soon="expiringSoon"
|
||||
@expiring-count="expiringCount = $event"
|
||||
/>
|
||||
<ContractTab v-else-if="tab === 'contract'" :key="session + committed" :keyword="committed" />
|
||||
<ContractTab
|
||||
v-else-if="tabsReady && tab === 'contract'"
|
||||
:key="session + committed"
|
||||
:keyword="committed"
|
||||
/>
|
||||
<UsageTab
|
||||
v-else-if="tab === 'usage'"
|
||||
v-else-if="tabsReady && tab === 'usage'"
|
||||
:key="session + committed"
|
||||
:keyword="committed"
|
||||
:kind="usageKind"
|
||||
/>
|
||||
<PlanTab
|
||||
v-else-if="tab === 'plan'"
|
||||
v-else-if="tabsReady && tab === 'plan'"
|
||||
:key="session + committed"
|
||||
:keyword="committed"
|
||||
:status="planStatus"
|
||||
@@ -131,7 +141,7 @@
|
||||
:show-all="showAllPlans"
|
||||
/>
|
||||
<ReadyTab
|
||||
v-else
|
||||
v-else-if="tabsReady && tab === 'ready'"
|
||||
:key="session + committed"
|
||||
:keyword="committed"
|
||||
:waived="readyState"
|
||||
@@ -145,6 +155,7 @@
|
||||
<script setup lang="ts">
|
||||
import MpWebviewShell from '@/layouts/MpWebviewShell.vue'
|
||||
import MpBusinessHeader from '@/components/mp/MpBusinessHeader.vue'
|
||||
import { fetchGetMenuCodes } from '@/api/auth'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { goToMiniWorkbench } from '@/utils/mp-webview'
|
||||
import { certReadyDefaultPlanDates } from '@/utils/cert-ready-plan-date'
|
||||
@@ -170,12 +181,45 @@
|
||||
const session = ref(0)
|
||||
const keyword = ref('')
|
||||
const committed = ref('')
|
||||
const tabs = ['archive', 'contract', 'usage', 'plan', 'ready'] as const
|
||||
const tab = ref<(typeof tabs)[number]>(
|
||||
tabs.includes(route.query.tab as (typeof tabs)[number])
|
||||
? (route.query.tab as (typeof tabs)[number])
|
||||
: 'archive'
|
||||
const CERT_TABS = [
|
||||
{ name: 'archive', title: '证件建档', perm: 'mini:pl:quota-cert:list' },
|
||||
{ name: 'contract', title: '合同用证', perm: 'mini:pl:contract-quota:list' },
|
||||
{ name: 'usage', title: '证件用量', perm: 'mini:pl:certificate-usage:list' },
|
||||
{ name: 'plan', title: '计划段次用证', perm: 'mini:pl:plan-cert:segment' },
|
||||
{ name: 'ready', title: '证书齐备', perm: 'mini:pl:cert-ready:list' }
|
||||
] as const
|
||||
type CertTabName = (typeof CERT_TABS)[number]['name']
|
||||
const tabs = CERT_TABS.map((item) => item.name)
|
||||
const tabsReady = ref(false)
|
||||
const allowedTabNames = ref<CertTabName[]>([])
|
||||
const visibleTabs = computed(() =>
|
||||
CERT_TABS.filter((item) => allowedTabNames.value.includes(item.name))
|
||||
)
|
||||
const tab = ref<CertTabName>(
|
||||
tabs.includes(route.query.tab as CertTabName) ? (route.query.tab as CertTabName) : 'archive'
|
||||
)
|
||||
|
||||
function selectAllowedTab() {
|
||||
if (!allowedTabNames.value.length) return
|
||||
if (allowedTabNames.value.includes(tab.value)) return
|
||||
tab.value = allowedTabNames.value[0]
|
||||
void router.replace({ query: { ...route.query, tab: tab.value } })
|
||||
}
|
||||
|
||||
async function loadTabPermissions() {
|
||||
const permissions = await fetchGetMenuCodes().catch(() => null)
|
||||
const allowAll = !!permissions?.all || !!permissions?.isSuperAdmin
|
||||
const codes = new Set(permissions?.menuCodes || [])
|
||||
allowedTabNames.value = CERT_TABS.filter((item) => allowAll || codes.has(item.perm)).map(
|
||||
(item) => item.name
|
||||
)
|
||||
tabsReady.value = true
|
||||
selectAllowedTab()
|
||||
}
|
||||
|
||||
watch(ready, (shown) => {
|
||||
if (shown) void loadTabPermissions()
|
||||
})
|
||||
const archiveKind = ref('')
|
||||
const expiringSoon = ref(false)
|
||||
const expiringCount = ref(0)
|
||||
@@ -325,7 +369,7 @@
|
||||
|
||||
function onTab(name: string | number) {
|
||||
const next = String(name)
|
||||
if (!tabs.includes(next as (typeof tabs)[number])) return
|
||||
if (!tabs.includes(next as CertTabName)) return
|
||||
keyword.value = ''
|
||||
committed.value = ''
|
||||
void router.replace({ query: { ...route.query, tab: next } })
|
||||
|
||||
Reference in new issue
Block a user