feat: 资产管理新增字段
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 1m47s

This commit is contained in:
sexygoat
2026-05-20 11:06:57 +08:00
parent f9fe76ff99
commit 3e42c4e98c
4 changed files with 176 additions and 12 deletions

View File

@@ -80,13 +80,54 @@
deviceStart: 'asset:device_start_h5',
} as const
type CardSearchType = 'iccid' | 'virtual_no' | 'msisdn'
type DeviceSearchType = 'device_name' | 'virtual_no' | 'imei'
interface SearchTypeOption {
label : string
value : string
}
interface StandaloneCardsParams {
page : number
page_size : number
carrier_id ?: number
status ?: number
iccid ?: string
virtual_no ?: string
msisdn ?: string
shop_id ?: number
}
interface DevicesParams {
page : number
page_size : number
status ?: number
device_name ?: string
virtual_no ?: string
imei ?: string
shop_id ?: number
}
const cardSearchTypeOptions : SearchTypeOption[] = [
{ label: 'ICCID', value: 'iccid' },
{ label: '虚拟号', value: 'virtual_no' },
{ label: '接入号', value: 'msisdn' },
]
const deviceSearchTypeOptions : SearchTypeOption[] = [
{ label: '设备号', value: 'device_name' },
{ label: '虚拟号', value: 'virtual_no' },
{ label: 'IMEI', value: 'imei' },
]
// 获取单卡列表(代理端)
function getStandaloneCards(params : any) {
function getStandaloneCards(params : StandaloneCardsParams) {
return get<{ items : CardInfo[], page : number, size : number, total : number }>('/api/admin/iot-cards/standalone', { params })
}
// 获取设备列表(代理端)
function getDevices(params : any) {
function getDevices(params : DevicesParams) {
return get<{ items : DeviceInfo[], page : number, size : number, total : number }>('/api/admin/devices', { params })
}
@@ -131,13 +172,35 @@
const carrierFilter = ref<number | undefined>(undefined)
const statusFilter = ref<number | undefined>(undefined)
const selectedShopFilter = ref<SelectedShopFilter | null>(null)
const cardSearchType = ref<CardSearchType>('iccid')
const deviceSearchType = ref<DeviceSearchType>('device_name')
const showCarrierPicker = ref(false)
const showSearchTypePicker = ref(false)
const showStatusPicker = ref(false)
const showShopPicker = ref(false)
// 运营商列表
const carrierList = ref<CarrierInfo[]>([])
const isAgent = computed(() => userInfo.value?.user_type === 3)
const searchPlaceholder = computed(() => activeTab.value === 'card' ? '搜索ICCID' : '搜索设备号')
const currentSearchType = computed(() => activeTab.value === 'card' ? cardSearchType.value : deviceSearchType.value)
const searchTypeOptions = computed(() => activeTab.value === 'card' ? cardSearchTypeOptions : deviceSearchTypeOptions)
const selectedSearchTypeLabel = computed(() => {
return searchTypeOptions.value.find(option => option.value === currentSearchType.value)?.label
|| (activeTab.value === 'card' ? 'ICCID' : '设备号')
})
const isDefaultSearchType = computed(() => {
return activeTab.value === 'card' ? cardSearchType.value === 'iccid' : deviceSearchType.value === 'device_name'
})
const searchPlaceholder = computed(() => {
if (activeTab.value === 'card') {
if (cardSearchType.value === 'virtual_no') return '搜索虚拟号'
if (cardSearchType.value === 'msisdn') return '搜索接入号'
return '搜索ICCID'
}
if (deviceSearchType.value === 'imei') return '搜索IMEI'
if (deviceSearchType.value === 'virtual_no') return '搜索虚拟号'
return '搜索设备号'
})
const canShowDeviceStopButton = computed(() => hasActionButtonPermission(ASSET_ACTION_BUTTON_CODES.deviceStop))
const canShowDeviceStartButton = computed(() => hasActionButtonPermission(ASSET_ACTION_BUTTON_CODES.deviceStart))
@@ -192,6 +255,34 @@
: 'bg-[#fff7e6] text-[#d46b08]'
}
function applyCardSearchKeyword(params : StandaloneCardsParams, keyword : string) {
if (cardSearchType.value === 'virtual_no') {
params.virtual_no = keyword
return
}
if (cardSearchType.value === 'msisdn') {
params.msisdn = keyword
return
}
params.iccid = keyword
}
function applyDeviceSearchKeyword(params : DevicesParams, keyword : string) {
if (deviceSearchType.value === 'imei') {
params.imei = keyword
return
}
if (deviceSearchType.value === 'device_name') {
params.device_name = keyword
return
}
params.virtual_no = keyword
}
// 合并后的资产列表
const assetList = computed<AssetItem[]>(() => {
const cards : AssetItem[] = cardList.value.map(card => ({
@@ -259,7 +350,7 @@
cardHasMore.value = true
}
const params : any = {
const params : StandaloneCardsParams = {
page: cardPage.value,
page_size: pageSize,
}
@@ -272,7 +363,7 @@
params.status = statusFilter.value
}
if (searchKeyword.value.trim()) {
params.iccid = searchKeyword.value.trim()
applyCardSearchKeyword(params, searchKeyword.value.trim())
}
if (userInfo.value?.user_type === 3 && selectedShopFilter.value) {
params.shop_id = selectedShopFilter.value.id
@@ -326,13 +417,13 @@
deviceHasMore.value = true
}
const params : any = {
const params : DevicesParams = {
page: devicePage.value,
page_size: pageSize,
}
if (searchKeyword.value.trim()) {
params.virtual_no = searchKeyword.value.trim()
applyDeviceSearchKeyword(params, searchKeyword.value.trim())
}
if (statusFilter.value !== undefined) {
params.status = statusFilter.value
@@ -416,6 +507,16 @@
refreshList()
}
function onSearchTypeConfirm(option : SearchTypeOption) {
if (activeTab.value === 'card') {
cardSearchType.value = option.value as CardSearchType
} else {
deviceSearchType.value = option.value as DeviceSearchType
}
refreshList()
}
// 获取当前选中的运营商名称
const selectedCarrierName = computed(() => {
if (carrierFilter.value === undefined) return '运营商'
@@ -661,6 +762,14 @@
</view>
</view>
<view class="flex items-center gap-1.5 px-3 py-1.5 bg-[#f8fafc] rounded-full flex-shrink-0"
@click="showSearchTypePicker = true">
<text class="text-12px" :class="isDefaultSearchType ? 'text-[#64748b]' : 'text-brand font-medium'">
{{ selectedSearchTypeLabel }}
</text>
<i class="i-mdi-chevron-down text-12px text-[#94a3b8]" />
</view>
<view class="flex items-center gap-1.5 px-3 py-1.5 bg-[#f8fafc] rounded-full flex-shrink-0 max-w-36"
@click="showCarrierPicker = true">
<text class="text-12px truncate"
@@ -818,11 +927,18 @@
</view>
<!-- 运营商选择器 -->
<SimplePicker v-model:show="showCarrierPicker" :options="carrierOptions" title="选择运营商"
<SimplePicker v-model:show="showCarrierPicker" :options="carrierOptions" :selected-value="carrierFilter"
auto-confirm title="选择运营商"
@confirm="onCarrierConfirm" />
<!-- 搜索字段选择器 -->
<SimplePicker v-model:show="showSearchTypePicker" :options="searchTypeOptions" :selected-value="currentSearchType"
auto-confirm title="选择搜索字段"
@confirm="onSearchTypeConfirm" />
<!-- 状态选择器 -->
<SimplePicker v-model:show="showStatusPicker" :options="statusOptions" title="选择状态" @confirm="onStatusConfirm" />
<SimplePicker v-model:show="showStatusPicker" :options="statusOptions" :selected-value="statusFilter"
auto-confirm title="选择状态" @confirm="onStatusConfirm" />
<ShopCascadePicker v-model:show="showShopPicker" :selected-shop="selectedShopFilter" title="选择店铺"
@confirm="onShopConfirm" />