This commit is contained in:
@@ -71,6 +71,14 @@
|
||||
|
||||
// 用户信息
|
||||
const userInfo = ref<UserInfo | null>(null)
|
||||
const sessionButtonCodes = ref<string[]>([])
|
||||
|
||||
const ASSET_ACTION_BUTTON_CODES = {
|
||||
cardStop: 'asset:card_stop_h5',
|
||||
cardStart: 'asset:card_start_h5',
|
||||
deviceStop: 'asset:device_stop_h5',
|
||||
deviceStart: 'asset:device_start_h5',
|
||||
} as const
|
||||
|
||||
// 获取单卡列表(代理端)
|
||||
function getStandaloneCards(params : any) {
|
||||
@@ -130,10 +138,36 @@
|
||||
const carrierList = ref<CarrierInfo[]>([])
|
||||
const isAgent = computed(() => userInfo.value?.user_type === 3)
|
||||
const searchPlaceholder = computed(() => activeTab.value === 'card' ? '搜索ICCID' : '搜索设备号')
|
||||
const canShowDeviceStopButton = computed(() => hasActionButtonPermission(ASSET_ACTION_BUTTON_CODES.deviceStop))
|
||||
const canShowDeviceStartButton = computed(() => hasActionButtonPermission(ASSET_ACTION_BUTTON_CODES.deviceStart))
|
||||
|
||||
function hasStatusCode(error : unknown) {
|
||||
return typeof error === 'object' && error !== null && 'statusCode' in error
|
||||
}
|
||||
|
||||
function getSessionButtonCodes() {
|
||||
const cachedUserInfo = uni.getStorageSync('user_info')
|
||||
|
||||
if (!cachedUserInfo || typeof cachedUserInfo !== 'object' || !Array.isArray((cachedUserInfo as UserInfo).buttons)) {
|
||||
return []
|
||||
}
|
||||
|
||||
return (cachedUserInfo as UserInfo).buttons!.filter((code) => {
|
||||
return typeof code === 'string' && code.trim().length > 0
|
||||
})
|
||||
}
|
||||
|
||||
function hasActionButtonPermission(code : string) {
|
||||
return sessionButtonCodes.value.includes(code)
|
||||
}
|
||||
|
||||
function canShowCardStopButton(card : CardInfo) {
|
||||
return card.network_status !== 0 && hasActionButtonPermission(ASSET_ACTION_BUTTON_CODES.cardStop)
|
||||
}
|
||||
|
||||
function canShowCardStartButton(card : CardInfo) {
|
||||
return card.network_status !== 1 && hasActionButtonPermission(ASSET_ACTION_BUTTON_CODES.cardStart)
|
||||
}
|
||||
// 运营商选择器选项
|
||||
const carrierOptions = computed(() => [
|
||||
{ label: '全部运营商', value: undefined },
|
||||
@@ -410,12 +444,12 @@
|
||||
if (asset.type === 'card') {
|
||||
const card = asset.raw as CardInfo
|
||||
uni.navigateTo({
|
||||
url: `/pages/agent-system/asset-search/index?iccid=${card.iccid}`,
|
||||
url: `/pages/agent-system/asset-detail/index?iccid=${card.iccid}`,
|
||||
})
|
||||
} else {
|
||||
const device = asset.raw as DeviceInfo
|
||||
uni.navigateTo({
|
||||
url: `/pages/agent-system/asset-search/index?virtual_no=${device.virtual_no}`,
|
||||
url: `/pages/agent-system/asset-detail/index?virtual_no=${device.virtual_no}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -575,6 +609,7 @@
|
||||
onMounted(async () => {
|
||||
// 1. 获取状态栏高度
|
||||
statusBarHeight.value = uni.getSystemInfoSync().statusBarHeight || 20
|
||||
sessionButtonCodes.value = getSessionButtonCodes()
|
||||
|
||||
// 2. 加载用户信息(判断是企业端还是代理端)
|
||||
try {
|
||||
@@ -646,8 +681,7 @@
|
||||
<view v-if="isAgent"
|
||||
class="flex items-center gap-1.5 px-3 py-1.5 bg-[#f8fafc] rounded-full flex-shrink-0 max-w-36"
|
||||
@click="showShopPicker = true">
|
||||
<text class="text-12px truncate"
|
||||
:class="selectedShopFilter ? 'text-brand font-medium' : 'text-[#64748b]'">
|
||||
<text class="text-12px truncate" :class="selectedShopFilter ? 'text-brand font-medium' : 'text-[#64748b]'">
|
||||
{{ selectedShopName }}
|
||||
</text>
|
||||
<i class="i-mdi-chevron-down text-12px text-[#94a3b8] flex-shrink-0" />
|
||||
@@ -716,42 +750,30 @@
|
||||
<view class="flex items-center gap-2">
|
||||
<!-- IoT卡操作按钮 -->
|
||||
<template v-if="asset.type === 'card'">
|
||||
<template v-if="(asset.raw as CardInfo).network_status === 0">
|
||||
<view
|
||||
class="px-3 py-1.5 rounded-10px text-12px font-medium bg-[#52c41a] text-white shadow-sm shadow-[#52c41a]/30 active:scale-95 transition-transform"
|
||||
@click="handleStartCard(asset, $event)">
|
||||
复机
|
||||
</view>
|
||||
</template>
|
||||
<template v-else-if="(asset.raw as CardInfo).network_status === 1">
|
||||
<view
|
||||
class="px-3 py-1.5 rounded-10px text-12px font-medium bg-[#ff4d4f] text-white shadow-sm shadow-[#ff4d4f]/30 active:scale-95 transition-transform"
|
||||
@click="handleStopCard(asset, $event)">
|
||||
停机
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view
|
||||
class="px-3 py-1.5 rounded-10px text-12px font-medium bg-[#ff4d4f] text-white shadow-sm shadow-[#ff4d4f]/30 active:scale-95 transition-transform"
|
||||
@click="handleStopCard(asset, $event)">
|
||||
停机
|
||||
</view>
|
||||
<view
|
||||
class="px-3 py-1.5 rounded-10px text-12px font-medium bg-[#52c41a] text-white shadow-sm shadow-[#52c41a]/30 active:scale-95 transition-transform"
|
||||
@click="handleStartCard(asset, $event)">
|
||||
复机
|
||||
</view>
|
||||
</template>
|
||||
<view
|
||||
v-if="canShowCardStopButton(asset.raw as CardInfo)"
|
||||
class="px-3 py-1.5 rounded-10px text-12px font-medium bg-[#ff4d4f] text-white shadow-sm shadow-[#ff4d4f]/30 active:scale-95 transition-transform"
|
||||
@click="handleStopCard(asset, $event)">
|
||||
停机
|
||||
</view>
|
||||
<view
|
||||
v-if="canShowCardStartButton(asset.raw as CardInfo)"
|
||||
class="px-3 py-1.5 rounded-10px text-12px font-medium bg-[#52c41a] text-white shadow-sm shadow-[#52c41a]/30 active:scale-95 transition-transform"
|
||||
@click="handleStartCard(asset, $event)">
|
||||
复机
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<!-- 设备操作按钮 -->
|
||||
<template v-else>
|
||||
<view
|
||||
v-if="canShowDeviceStopButton"
|
||||
class="px-3 py-1.5 rounded-10px text-12px font-medium bg-[#ff4d4f] text-white shadow-sm shadow-[#ff4d4f]/30 active:scale-95 transition-transform"
|
||||
@click="handleStopDevice(asset, $event)">
|
||||
停机
|
||||
</view>
|
||||
<view
|
||||
v-if="canShowDeviceStartButton"
|
||||
class="px-3 py-1.5 rounded-10px text-12px font-medium bg-[#52c41a] text-white shadow-sm shadow-[#52c41a]/30 active:scale-95 transition-transform"
|
||||
@click="handleStartDevice(asset, $event)">
|
||||
复机
|
||||
@@ -766,11 +788,10 @@
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="activeTabHasMore" class="py-4 flex justify-center">
|
||||
<view
|
||||
class="min-w-32 px-5 py-2.5 rounded-full text-sm font-medium transition-all"
|
||||
class="min-w-32 px-5 py-2.5 rounded-full text-sm font-medium transition-all flex items-center justify-center"
|
||||
:class="loading
|
||||
? 'bg-[#f1f5f9] text-[#94a3b8]'
|
||||
: 'bg-brand text-white shadow-sm shadow-brand/30 active:scale-95'"
|
||||
@click="!loading && loadMore()">
|
||||
: 'bg-brand text-white shadow-sm shadow-brand/30 active:scale-95'" @click="!loading && loadMore()">
|
||||
<template v-if="loading">
|
||||
<i class="i-mdi-loading animate-spin text-base mr-1.5" />
|
||||
<text>加载中...</text>
|
||||
|
||||
Reference in New Issue
Block a user