fetch(add): 订单管理-企业设备
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m30s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m30s
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
<ElButton @click="handleBatchRecall" :disabled="!selectedDevices.length">
|
||||
批量回收
|
||||
</ElButton>
|
||||
<ElButton type="info" @click="handleBatchSetSeries" :disabled="!selectedDevices.length">
|
||||
批量设置套餐系列
|
||||
</ElButton>
|
||||
<ElButton @click="handleImportDevice">导入设备</ElButton>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
@@ -177,6 +180,71 @@
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
|
||||
<!-- 批量设置套餐系列绑定对话框 -->
|
||||
<ElDialog v-model="seriesBindingDialogVisible" title="批量设置设备套餐系列绑定" width="600px">
|
||||
<ElForm ref="seriesBindingFormRef" :model="seriesBindingForm" :rules="seriesBindingRules" label-width="120px">
|
||||
<ElFormItem label="已选设备数">
|
||||
<span style="color: #409eff; font-weight: bold">{{ selectedDevices.length }}</span> 台
|
||||
</ElFormItem>
|
||||
<ElFormItem label="套餐系列分配" prop="series_allocation_id">
|
||||
<ElSelect
|
||||
v-model="seriesBindingForm.series_allocation_id"
|
||||
placeholder="请选择套餐系列分配(选择清除关联将解除绑定)"
|
||||
style="width: 100%"
|
||||
:loading="seriesLoading"
|
||||
>
|
||||
<ElOption label="清除关联" :value="0" />
|
||||
<ElOption
|
||||
v-for="series in seriesAllocationList"
|
||||
:key="series.id"
|
||||
:label="`${series.series_name} (${series.shop_name})`"
|
||||
:value="series.id"
|
||||
:disabled="series.status !== 1"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
|
||||
<!-- 设置结果 -->
|
||||
<div v-if="seriesBindingResult" style="margin-top: 20px">
|
||||
<ElAlert
|
||||
:type="seriesBindingResult.fail_count === 0 ? 'success' : 'warning'"
|
||||
:closable="false"
|
||||
style="margin-bottom: 10px"
|
||||
>
|
||||
<template #title>
|
||||
成功设置 {{ seriesBindingResult.success_count }} 台,失败 {{ seriesBindingResult.fail_count }} 台
|
||||
</template>
|
||||
</ElAlert>
|
||||
<div v-if="seriesBindingResult.failed_items && seriesBindingResult.failed_items.length > 0">
|
||||
<div style="margin-bottom: 10px; font-weight: bold">失败详情:</div>
|
||||
<div
|
||||
v-for="item in seriesBindingResult.failed_items"
|
||||
:key="item.device_id"
|
||||
style="margin-bottom: 8px; color: #f56c6c; font-size: 12px"
|
||||
>
|
||||
设备号: {{ item.device_no }} - {{ item.reason }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<ElButton @click="handleCloseSeriesBindingDialog">
|
||||
{{ seriesBindingResult ? '关闭' : '取消' }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!seriesBindingResult"
|
||||
type="primary"
|
||||
@click="handleConfirmSeriesBinding"
|
||||
:loading="seriesBindingLoading"
|
||||
>
|
||||
确认设置
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</ElCard>
|
||||
</div>
|
||||
</ArtTableFullScreen>
|
||||
@@ -186,19 +254,22 @@
|
||||
import { h } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { DeviceService, ShopService } from '@/api/modules'
|
||||
import { ShopSeriesAllocationService } from '@/api/modules/shopSeriesAllocation'
|
||||
import { ElMessage, ElMessageBox, ElTag, ElSwitch } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type {
|
||||
Device,
|
||||
DeviceStatus,
|
||||
AllocateDevicesResponse,
|
||||
RecallDevicesResponse
|
||||
RecallDevicesResponse,
|
||||
BatchSetDeviceSeriesBindingResponse
|
||||
} from '@/types/api'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
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'
|
||||
|
||||
defineOptions({ name: 'DeviceList' })
|
||||
|
||||
@@ -216,6 +287,20 @@
|
||||
const allocateResult = ref<AllocateDevicesResponse | null>(null)
|
||||
const recallResult = ref<RecallDevicesResponse | null>(null)
|
||||
|
||||
// 套餐系列绑定相关
|
||||
const seriesBindingDialogVisible = ref(false)
|
||||
const seriesBindingLoading = ref(false)
|
||||
const seriesBindingFormRef = ref<FormInstance>()
|
||||
const seriesLoading = ref(false)
|
||||
const seriesAllocationList = ref<ShopSeriesAllocationResponse[]>([])
|
||||
const seriesBindingForm = reactive({
|
||||
series_allocation_id: undefined as number | undefined
|
||||
})
|
||||
const seriesBindingRules = reactive<FormRules>({
|
||||
series_allocation_id: [{ required: true, message: '请选择套餐系列分配', trigger: 'change' }]
|
||||
})
|
||||
const seriesBindingResult = ref<BatchSetDeviceSeriesBindingResponse | null>(null)
|
||||
|
||||
// 搜索表单初始值
|
||||
const initialSearchState = {
|
||||
device_no: '',
|
||||
@@ -665,6 +750,81 @@
|
||||
const handleImportDevice = () => {
|
||||
router.push('/batch/device-import')
|
||||
}
|
||||
|
||||
// 批量设置套餐系列
|
||||
const handleBatchSetSeries = async () => {
|
||||
if (selectedDevices.value.length === 0) {
|
||||
ElMessage.warning('请先选择要设置的设备')
|
||||
return
|
||||
}
|
||||
seriesBindingForm.series_allocation_id = undefined
|
||||
seriesBindingResult.value = null
|
||||
await loadSeriesAllocationList()
|
||||
seriesBindingDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 加载套餐系列分配列表
|
||||
const loadSeriesAllocationList = async () => {
|
||||
seriesLoading.value = true
|
||||
try {
|
||||
const res = await ShopSeriesAllocationService.getShopSeriesAllocations({
|
||||
page: 1,
|
||||
page_size: 1000
|
||||
})
|
||||
if (res.code === 0 && res.data.list) {
|
||||
seriesAllocationList.value = res.data.list
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取套餐系列分配列表失败:', error)
|
||||
ElMessage.error('获取套餐系列分配列表失败')
|
||||
} finally {
|
||||
seriesLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 确认设置套餐系列绑定
|
||||
const handleConfirmSeriesBinding = async () => {
|
||||
if (!seriesBindingFormRef.value) return
|
||||
|
||||
await seriesBindingFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
seriesBindingLoading.value = true
|
||||
try {
|
||||
const data = {
|
||||
device_ids: selectedDevices.value.map((d) => d.id),
|
||||
series_allocation_id: seriesBindingForm.series_allocation_id!
|
||||
}
|
||||
const res = await DeviceService.batchSetDeviceSeriesBinding(data)
|
||||
if (res.code === 0) {
|
||||
seriesBindingResult.value = res.data
|
||||
if (res.data.fail_count === 0) {
|
||||
ElMessage.success('全部设置成功')
|
||||
setTimeout(() => {
|
||||
handleCloseSeriesBindingDialog()
|
||||
getTableData()
|
||||
}, 1500)
|
||||
} else {
|
||||
ElMessage.warning(`部分设置失败,请查看失败详情`)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
ElMessage.error('设置套餐系列绑定失败')
|
||||
} finally {
|
||||
seriesBindingLoading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 关闭套餐系列绑定对话框
|
||||
const handleCloseSeriesBindingDialog = () => {
|
||||
seriesBindingDialogVisible.value = false
|
||||
seriesBindingResult.value = null
|
||||
if (seriesBindingFormRef.value) {
|
||||
seriesBindingFormRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user