fetch(modify):完善ioT卡管理
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m37s

This commit is contained in:
sexygoat
2026-02-02 10:57:31 +08:00
parent e08c962c40
commit 78bd9fba85
2 changed files with 161 additions and 237 deletions

View File

@@ -198,23 +198,23 @@
<ElFormItem label="已选设备数">
<span style="font-weight: bold; color: #409eff">{{ selectedDevices.length }}</span>
</ElFormItem>
<ElFormItem label="套餐系列分配" prop="series_allocation_id">
<ElFormItem label="套餐系列" prop="series_id">
<ElSelect
v-model="seriesBindingForm.series_allocation_id"
placeholder="请选择或搜索套餐系列分配(支持系列名称搜索)"
v-model="seriesBindingForm.series_id"
placeholder="请选择或搜索套餐系列"
style="width: 100%"
filterable
remote
reserve-keyword
:remote-method="searchSeriesAllocations"
:remote-method="searchPackageSeries"
:loading="seriesLoading"
clearable
>
<ElOption label="清除关联" :value="0" />
<ElOption
v-for="series in seriesAllocationList"
v-for="series in packageSeriesList"
:key="series.id"
:label="`${series.series_name} (${series.shop_name})`"
:label="series.series_name"
:value="series.id"
:disabled="series.status !== 1"
/>
@@ -317,7 +317,7 @@
<!-- 绑定卡片列表弹窗 -->
<ElDialog v-model="deviceCardsDialogVisible" title="绑定的卡片" width="900px">
<div style="margin-bottom: 10px; text-align: right">
<ElButton type="primary" size="small" @click="handleBindCard">绑定新卡</ElButton>
<ElButton type="primary" @click="handleBindCard">绑定新卡</ElButton>
</div>
<div v-if="deviceCardsLoading" style="text-align: center; padding: 40px 0">
<ElIcon class="is-loading" :size="40"><Loading /></ElIcon>
@@ -402,8 +402,7 @@
<script setup lang="ts">
import { h } from 'vue'
import { useRouter } from 'vue-router'
import { DeviceService, ShopService, CardService } from '@/api/modules'
import { ShopSeriesAllocationService } from '@/api/modules/shopSeriesAllocation'
import { DeviceService, ShopService, CardService, PackageSeriesService } from '@/api/modules'
import { ElMessage, ElMessageBox, ElTag, ElSwitch, ElIcon, ElTreeSelect } from 'element-plus'
import { Loading } from '@element-plus/icons-vue'
import type { FormInstance, FormRules } from 'element-plus'
@@ -419,7 +418,7 @@
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
import { formatDateTime } from '@/utils/business/format'
import { CommonStatus, getStatusText } from '@/config/constants'
import type { ShopSeriesAllocationResponse } from '@/types/api'
import type { PackageSeriesResponse } from '@/types/api'
defineOptions({ name: 'DeviceList' })
@@ -442,12 +441,12 @@
const seriesBindingLoading = ref(false)
const seriesBindingFormRef = ref<FormInstance>()
const seriesLoading = ref(false)
const seriesAllocationList = ref<ShopSeriesAllocationResponse[]>([])
const packageSeriesList = ref<PackageSeriesResponse[]>([])
const seriesBindingForm = reactive({
series_allocation_id: undefined as number | undefined
series_id: undefined as number | undefined
})
const seriesBindingRules = reactive<FormRules>({
series_allocation_id: [{ required: true, message: '请选择套餐系列分配', trigger: 'change' }]
series_id: [{ required: true, message: '请选择套餐系列', trigger: 'change' }]
})
const seriesBindingResult = ref<BatchSetDeviceSeriesBindingResponse | null>(null)
@@ -1144,14 +1143,14 @@
ElMessage.warning('请先选择要设置的设备')
return
}
seriesBindingForm.series_allocation_id = undefined
seriesBindingForm.series_id = undefined
seriesBindingResult.value = null
await loadSeriesAllocationList()
await loadPackageSeriesList()
seriesBindingDialogVisible.value = true
}
// 加载套餐系列分配列表(默认加载20条
const loadSeriesAllocationList = async (seriesName?: string) => {
// 加载套餐系列列表(支持名称搜索,默认20条
const loadPackageSeriesList = async (seriesName?: string) => {
seriesLoading.value = true
try {
const params: any = {
@@ -1162,21 +1161,21 @@
if (seriesName) {
params.series_name = seriesName
}
const res = await ShopSeriesAllocationService.getShopSeriesAllocations(params)
const res = await PackageSeriesService.getPackageSeries(params)
if (res.code === 0 && res.data.items) {
seriesAllocationList.value = res.data.items
packageSeriesList.value = res.data.items
}
} catch (error) {
console.error('获取套餐系列分配列表失败:', error)
ElMessage.error('获取套餐系列分配列表失败')
console.error('获取套餐系列列表失败:', error)
ElMessage.error('获取套餐系列列表失败')
} finally {
seriesLoading.value = false
}
}
// 搜索套餐系列分配(根据系列名称)
const searchSeriesAllocations = async (query: string) => {
await loadSeriesAllocationList(query || undefined)
// 搜索套餐系列
const searchPackageSeries = async (query: string) => {
await loadPackageSeriesList(query || undefined)
}
// 确认设置套餐系列绑定
@@ -1189,7 +1188,7 @@
try {
const data = {
device_ids: selectedDevices.value.map((d) => d.id),
series_allocation_id: seriesBindingForm.series_allocation_id!
series_allocation_id: seriesBindingForm.series_id! // 注意API参数名仍是series_allocation_id但前端使用series_id
}
const res = await DeviceService.batchSetDeviceSeriesBinding(data)
if (res.code === 0) {
@@ -1206,7 +1205,6 @@
}
} catch (error) {
console.error(error)
ElMessage.error('设置套餐系列绑定失败')
} finally {
seriesBindingLoading.value = false
}