This commit is contained in:
@@ -315,7 +315,7 @@ export class CardService extends BaseService {
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getStandaloneIotCards(params?: any): Promise<PaginationResponse<any>> {
|
||||
return this.getPage('/api/admin/iot-cards/standalone', { is_standalone: true, ...params })
|
||||
return this.getPage('/api/admin/iot-cards/standalone', params)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,10 +81,11 @@
|
||||
<el-dialog
|
||||
v-model="batchDialogVisible"
|
||||
title="批量触发"
|
||||
width="600px"
|
||||
width="80%"
|
||||
:close-on-click-modal="false"
|
||||
@close="handleBatchDialogClose"
|
||||
>
|
||||
<el-form ref="batchFormRef" :model="batchForm" :rules="batchRules" label-width="120px">
|
||||
<el-form ref="batchFormRef" :model="batchForm" :rules="batchRules" label-width="100">
|
||||
<el-form-item label="任务类型" prop="task_type">
|
||||
<el-select
|
||||
v-model="batchForm.task_type"
|
||||
@@ -96,18 +97,81 @@
|
||||
<el-option label="套餐轮询" value="polling:package" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="卡ID列表" prop="card_ids">
|
||||
<el-input
|
||||
v-model="batchForm.card_ids_text"
|
||||
type="textarea"
|
||||
:rows="5"
|
||||
placeholder="请输入卡ID,多个ID用逗号或换行分隔(最多1000个)"
|
||||
/>
|
||||
<el-form-item label="选择卡">
|
||||
<div class="card-selection-wrapper">
|
||||
<div class="card-search-bar">
|
||||
<el-input
|
||||
v-model="cardSearchKeyword"
|
||||
placeholder="搜索ICCID/MSISDN"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
@input="handleCardSearchInput"
|
||||
/>
|
||||
<el-select
|
||||
v-model="cardSearchForm.card_status"
|
||||
placeholder="卡状态"
|
||||
clearable
|
||||
style="width: 150px; margin-left: 10px"
|
||||
@change="handleCardSearch"
|
||||
>
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="已激活" :value="1" />
|
||||
<el-option label="未激活" :value="0" />
|
||||
<el-option label="停机" :value="2" />
|
||||
<el-option label="异常" :value="3" />
|
||||
</el-select>
|
||||
<el-button type="primary" style="margin-left: 10px" @click="handleCardSearch">
|
||||
搜索
|
||||
</el-button>
|
||||
<el-button @click="handleCardSearchReset">重置</el-button>
|
||||
</div>
|
||||
<div class="card-table-info">
|
||||
<span>已选择 {{ selectedBatchCards.length }} 张卡</span>
|
||||
<span style="margin-left: 20px; color: #909399">
|
||||
最多选择1000张卡
|
||||
</span>
|
||||
</div>
|
||||
<el-table
|
||||
ref="batchCardTableRef"
|
||||
:data="batchCardList"
|
||||
:loading="batchCardLoading"
|
||||
row-key="id"
|
||||
height="300"
|
||||
@selection-change="handleBatchCardSelectionChange"
|
||||
border
|
||||
style="margin-top: 10px"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="iccid" label="ICCID" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="msisdn" label="MSISDN" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="carrier_name" label="运营商" width="100" />
|
||||
<el-table-column prop="status" label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getCardStatusType(row.status)" size="small">
|
||||
{{ getCardStatusName(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-model:current-page="batchCardPagination.page"
|
||||
v-model:page-size="batchCardPagination.pageSize"
|
||||
:total="batchCardPagination.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
style="margin-top: 10px"
|
||||
small
|
||||
@size-change="handleBatchCardPageSizeChange"
|
||||
@current-change="handleBatchCardPageChange"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="batchDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleBatchSubmit">确定</el-button>
|
||||
<el-button type="primary" @click="handleBatchSubmit" :disabled="selectedBatchCards.length === 0">
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
@@ -334,10 +398,137 @@
|
||||
|
||||
// 批量触发表单
|
||||
const batchForm = reactive({
|
||||
task_type: '' as TaskType | '',
|
||||
card_ids_text: ''
|
||||
task_type: '' as TaskType | ''
|
||||
})
|
||||
|
||||
// 批量触发弹窗中的卡列表相关数据
|
||||
const batchCardList = ref<any[]>([])
|
||||
const batchCardLoading = ref(false)
|
||||
const batchCardPagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
const cardSearchKeyword = ref('')
|
||||
const cardSearchForm = reactive({
|
||||
keyword: '',
|
||||
card_status: undefined as number | undefined
|
||||
})
|
||||
const selectedBatchCards = ref<any[]>([])
|
||||
const batchCardTableRef = ref()
|
||||
|
||||
// 搜索防抖定时器
|
||||
let cardSearchTimer: any = null
|
||||
|
||||
// 获取批量触发弹窗中的卡列表
|
||||
const getBatchCardList = async () => {
|
||||
batchCardLoading.value = true
|
||||
try {
|
||||
const params: any = {
|
||||
page: batchCardPagination.page,
|
||||
page_size: batchCardPagination.pageSize,
|
||||
...cardSearchForm
|
||||
}
|
||||
Object.keys(params).forEach((key) => {
|
||||
if (params[key] === '' || params[key] === undefined) {
|
||||
delete params[key]
|
||||
}
|
||||
})
|
||||
const res = await CardService.getStandaloneIotCards(params)
|
||||
if (res.code === 0) {
|
||||
batchCardList.value = res.data.items || []
|
||||
batchCardPagination.total = res.data.total || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
batchCardLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 卡搜索输入(防抖)
|
||||
const handleCardSearchInput = () => {
|
||||
if (cardSearchTimer) {
|
||||
clearTimeout(cardSearchTimer)
|
||||
}
|
||||
cardSearchTimer = setTimeout(() => {
|
||||
cardSearchForm.keyword = cardSearchKeyword.value
|
||||
batchCardPagination.page = 1
|
||||
getBatchCardList()
|
||||
}, 300)
|
||||
}
|
||||
|
||||
// 卡搜索
|
||||
const handleCardSearch = () => {
|
||||
cardSearchForm.keyword = cardSearchKeyword.value
|
||||
batchCardPagination.page = 1
|
||||
getBatchCardList()
|
||||
}
|
||||
|
||||
// 卡搜索重置
|
||||
const handleCardSearchReset = () => {
|
||||
cardSearchKeyword.value = ''
|
||||
cardSearchForm.keyword = ''
|
||||
cardSearchForm.card_status = undefined
|
||||
batchCardPagination.page = 1
|
||||
getBatchCardList()
|
||||
}
|
||||
|
||||
// 批量卡选择变化
|
||||
const handleBatchCardSelectionChange = (selection: any[]) => {
|
||||
if (selection.length > 1000) {
|
||||
ElMessage.warning('最多只能选择1000张卡')
|
||||
// 取消最后一个选择
|
||||
const lastSelected = selection[selection.length - 1]
|
||||
batchCardTableRef.value?.toggleRowSelection(lastSelected, false)
|
||||
return
|
||||
}
|
||||
selectedBatchCards.value = selection
|
||||
}
|
||||
|
||||
// 批量卡分页大小变化
|
||||
const handleBatchCardPageSizeChange = () => {
|
||||
batchCardPagination.page = 1
|
||||
getBatchCardList()
|
||||
}
|
||||
|
||||
// 批量卡分页页码变化
|
||||
const handleBatchCardPageChange = () => {
|
||||
getBatchCardList()
|
||||
}
|
||||
|
||||
// 关闭批量触发弹窗
|
||||
const handleBatchDialogClose = () => {
|
||||
selectedBatchCards.value = []
|
||||
cardSearchKeyword.value = ''
|
||||
cardSearchForm.keyword = ''
|
||||
cardSearchForm.card_status = undefined
|
||||
batchCardPagination.page = 1
|
||||
batchCardPagination.pageSize = 20
|
||||
}
|
||||
|
||||
// 获取卡状态类型
|
||||
const getCardStatusType = (status: number) => {
|
||||
const typeMap: Record<number, 'success' | 'warning' | 'danger' | 'info'> = {
|
||||
0: 'info',
|
||||
1: 'success',
|
||||
2: 'warning',
|
||||
3: 'danger'
|
||||
}
|
||||
return typeMap[status] || 'info'
|
||||
}
|
||||
|
||||
// 获取卡状态名称
|
||||
const getCardStatusName = (status: number) => {
|
||||
const nameMap: Record<number, string> = {
|
||||
0: '未激活',
|
||||
1: '已激活',
|
||||
2: '停机',
|
||||
3: '异常'
|
||||
}
|
||||
return nameMap[status] || '未知'
|
||||
}
|
||||
|
||||
// 条件触发表单
|
||||
const conditionForm = reactive<ConditionManualTriggerRequest>({
|
||||
task_type: '' as TaskType | '',
|
||||
@@ -544,12 +735,18 @@
|
||||
|
||||
const showBatchTriggerDialog = () => {
|
||||
Object.assign(batchForm, {
|
||||
task_type: '',
|
||||
card_ids_text: ''
|
||||
task_type: ''
|
||||
})
|
||||
selectedBatchCards.value = []
|
||||
batchCardPagination.page = 1
|
||||
batchCardPagination.pageSize = 20
|
||||
cardSearchKeyword.value = ''
|
||||
cardSearchForm.keyword = ''
|
||||
cardSearchForm.card_status = undefined
|
||||
batchDialogVisible.value = true
|
||||
nextTick(() => {
|
||||
batchFormRef.value?.clearValidate()
|
||||
getBatchCardList()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -588,13 +785,12 @@
|
||||
if (!valid) return
|
||||
|
||||
try {
|
||||
// 解析卡ID列表
|
||||
const cardIds = batchForm.card_ids_text
|
||||
.split(/[,\n]/)
|
||||
.map((id) => id.trim())
|
||||
.filter((id) => id)
|
||||
.map((id) => parseInt(id))
|
||||
.filter((id) => !isNaN(id))
|
||||
const cardIds = selectedBatchCards.value.map((card) => card.id)
|
||||
|
||||
if (cardIds.length === 0) {
|
||||
ElMessage.warning('请选择要触发的卡')
|
||||
return
|
||||
}
|
||||
|
||||
if (cardIds.length > 1000) {
|
||||
ElMessage.warning('卡ID数量不能超过1000个')
|
||||
@@ -766,5 +962,18 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
|
||||
.card-selection-wrapper {
|
||||
.card-search-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.card-table-info {
|
||||
margin-top: 10px;
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user