This commit is contained in:
@@ -338,34 +338,47 @@
|
||||
label-width="80"
|
||||
>
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="10">
|
||||
<ElFormItem label="IoT卡" prop="iot_card_id">
|
||||
<ElCol :span="6">
|
||||
<ElFormItem label="搜索类型" prop="search_type">
|
||||
<ElSelect v-model="bindCardForm.search_type" placeholder="请选择搜索类型" style="width: 100%">
|
||||
<ElOption label="ICCID" value="iccid" />
|
||||
<ElOption label="运营商名称" value="carrier_name" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="8">
|
||||
<ElFormItem label="ICCID" prop="iot_card_id">
|
||||
<ElSelect
|
||||
v-model="bindCardForm.iot_card_id"
|
||||
:placeholder="
|
||||
iotCardList.length === 0 && !iotCardSearchLoading
|
||||
? '当前没有未绑定设备的卡'
|
||||
: '请选择或搜索IoT卡(支持ICCID搜索)'
|
||||
bindCardForm.search_type === 'carrier_name'
|
||||
? '请选择或搜索运营商名称'
|
||||
: '请选择或搜索ICCID'
|
||||
"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
:remote-method="searchIotCards"
|
||||
:loading="iotCardSearchLoading"
|
||||
:disabled="iotCardList.length === 0 && !iotCardSearchLoading"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption
|
||||
v-for="card in iotCardList"
|
||||
:key="card.id"
|
||||
:label="`${card.iccid} ${card.msisdn ? '(' + card.msisdn + ')' : ''}`"
|
||||
:label="`${card.iccid} ${card.carrier_name ? '(' + card.carrier_name + ')' : ''}`"
|
||||
:value="card.id"
|
||||
/>
|
||||
<ElOption
|
||||
v-if="iotCardList.length === 0 && !iotCardSearchLoading"
|
||||
label="未找到相关数据"
|
||||
:value="undefined"
|
||||
disabled
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="10">
|
||||
<ElCol :span="6">
|
||||
<ElFormItem label="插槽位置" prop="slot_position">
|
||||
<ElSelect
|
||||
v-model="bindCardForm.slot_position"
|
||||
@@ -561,7 +574,8 @@
|
||||
ShopService,
|
||||
CardService,
|
||||
PackageSeriesService,
|
||||
AssetService
|
||||
AssetService,
|
||||
CarrierService
|
||||
} from '@/api/modules'
|
||||
import { ElMessage, ElMessageBox, ElTag, ElIcon, ElRadioGroup, ElRadio } from 'element-plus'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
@@ -656,11 +670,13 @@
|
||||
const iotCardSearchLoading = ref(false)
|
||||
const iotCardHasSearched = ref(false) // 标记是否已执行过搜索
|
||||
const bindCardForm = reactive({
|
||||
search_type: 'iccid' as 'iccid' | 'carrier_name',
|
||||
iot_card_id: undefined as number | undefined,
|
||||
slot_position: 1
|
||||
})
|
||||
const bindCardRules = reactive<FormRules>({
|
||||
iot_card_id: [{ required: true, message: '请选择IoT卡', trigger: 'change' }],
|
||||
search_type: [{ required: true, message: '请选择搜索类型', trigger: 'change' }],
|
||||
iot_card_id: [{ required: true, message: '请选择ICCID', trigger: 'change' }],
|
||||
slot_position: [{ required: true, message: '请选择插槽位置', trigger: 'change' }]
|
||||
})
|
||||
|
||||
@@ -855,10 +871,14 @@
|
||||
deviceCards.value = []
|
||||
deviceCardsDialogVisible.value = true
|
||||
// 重置绑定卡表单
|
||||
bindCardForm.search_type = 'iccid'
|
||||
bindCardForm.iot_card_id = undefined
|
||||
bindCardForm.slot_position = 1
|
||||
// 只加载设备卡列表
|
||||
await loadDeviceCards(device.virtual_no)
|
||||
// 加载未绑定设备的卡列表
|
||||
await Promise.all([
|
||||
loadDeviceCards(device.virtual_no),
|
||||
loadDefaultIotCards()
|
||||
])
|
||||
}
|
||||
|
||||
// 加载设备绑定的卡列表
|
||||
@@ -897,7 +917,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索IoT卡(根据ICCID)
|
||||
// 搜索IoT卡(根据ICCID或运营商名称)
|
||||
const searchIotCards = async (query: string) => {
|
||||
if (!query) {
|
||||
await loadDefaultIotCards()
|
||||
@@ -906,12 +926,17 @@
|
||||
iotCardSearchLoading.value = true
|
||||
iotCardHasSearched.value = true
|
||||
try {
|
||||
const res = await CardService.getStandaloneIotCards({
|
||||
const params: any = {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
iccid: query,
|
||||
is_standalone: true
|
||||
})
|
||||
}
|
||||
if (bindCardForm.search_type === 'iccid') {
|
||||
params.iccid = query
|
||||
} else if (bindCardForm.search_type === 'carrier_name') {
|
||||
params.carrier_name = query
|
||||
}
|
||||
const res = await CardService.getStandaloneIotCards(params)
|
||||
if (res.code === 0 && res.data?.items) {
|
||||
iotCardList.value = res.data.items
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user