feat:添加贩卖机日志
This commit is contained in:
1 parent
6b89a5e9f6
commit
4673cc532c
6 files changed
+420
-14
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// 贩卖机出货日志 VO
|
||||
export interface DeviceLogVO {
|
||||
id: number // 日志主键
|
||||
userId: number // 用户编号
|
||||
orderId: number // 订单号
|
||||
orderNo: string // 订单流水号
|
||||
deviceId: string // 设备IMEI
|
||||
deviceStatus: number // 出货状态
|
||||
content: string // 内容
|
||||
}
|
||||
|
||||
// 贩卖机出货日志 API
|
||||
export const DeviceLogApi = {
|
||||
// 查询贩卖机出货日志分页
|
||||
getDeviceLogPage: async (params: any) => {
|
||||
return await request.get({ url: `/trade/device-log/page`, params })
|
||||
},
|
||||
|
||||
// 查询贩卖机出货日志详情
|
||||
getDeviceLog: async (id: number) => {
|
||||
return await request.get({ url: `/trade/device-log/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增贩卖机出货日志
|
||||
createDeviceLog: async (data: DeviceLogVO) => {
|
||||
return await request.post({ url: `/trade/device-log/create`, data })
|
||||
},
|
||||
|
||||
// 修改贩卖机出货日志
|
||||
updateDeviceLog: async (data: DeviceLogVO) => {
|
||||
return await request.put({ url: `/trade/device-log/update`, data })
|
||||
},
|
||||
|
||||
// 删除贩卖机出货日志
|
||||
deleteDeviceLog: async (id: number) => {
|
||||
return await request.delete({ url: `/trade/device-log/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出贩卖机出货日志 Excel
|
||||
exportDeviceLog: async (params) => {
|
||||
return await request.download({ url: `/trade/device-log/export-excel`, params })
|
||||
}
|
||||
}
|
||||
@@ -322,22 +322,22 @@ const fetchAllProducts = async () => {
|
||||
barCode: queryParams.value.barCode
|
||||
}
|
||||
|
||||
console.log('获取商品数据,参数:', largePageParams)
|
||||
// console.log('获取商品数据,参数:', largePageParams)
|
||||
|
||||
const [mallResponse, containerResponse] = await Promise.all([
|
||||
ProductSpuApi.getSpuPage({ ...largePageParams, types: 0 }), // 商城商品
|
||||
ProductSpuApi.getSpuPage({ ...largePageParams, types: 1 }) // 提货柜商品
|
||||
])
|
||||
|
||||
console.log('商城商品响应:', mallResponse)
|
||||
console.log('提货柜商品响应:', containerResponse)
|
||||
// console.log('商城商品响应:', mallResponse)
|
||||
// console.log('提货柜商品响应:', containerResponse)
|
||||
|
||||
return [
|
||||
...(mallResponse.list || []).map((product) => ({ ...product, source: 'mall' })),
|
||||
...(containerResponse.list || []).map((product) => ({ ...product, source: 'container' }))
|
||||
]
|
||||
} catch (error) {
|
||||
console.error('获取商品数据失败:', error)
|
||||
// console.error('获取商品数据失败:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
@@ -347,19 +347,19 @@ const fetchAllProducts = async () => {
|
||||
*/
|
||||
const fetchProductDetails = async (products) => {
|
||||
if (!products || products.length === 0) {
|
||||
console.log('没有商品数据需要获取详情')
|
||||
// console.log('没有商品数据需要获取详情')
|
||||
return []
|
||||
}
|
||||
|
||||
const spuIds = products.map((item) => item.id).filter(Boolean)
|
||||
|
||||
if (spuIds.length === 0) {
|
||||
console.log('没有有效的SPU ID')
|
||||
// console.log('没有有效的SPU ID')
|
||||
return []
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('获取商品详情,SPU IDs:', spuIds)
|
||||
// console.log('获取商品详情,SPU IDs:', spuIds)
|
||||
const detailResponse = await ProductSpuApi.getSpuDetailList(spuIds)
|
||||
console.log('商品详情响应:', detailResponse)
|
||||
|
||||
@@ -368,7 +368,7 @@ const fetchProductDetails = async (products) => {
|
||||
return { ...product, source: originalProduct?.source || 'unknown' }
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('获取商品详情失败:', error)
|
||||
// console.error('获取商品详情失败:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
@@ -377,15 +377,15 @@ const fetchProductDetails = async (products) => {
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
console.log('开始获取商品汇总列表,查询参数:', queryParams.value)
|
||||
// console.log('开始获取商品汇总列表,查询参数:', queryParams.value)
|
||||
|
||||
// Step 1: 获取所有商品数据
|
||||
const allProducts = await fetchAllProducts()
|
||||
console.log('获取到的所有商品数据:', allProducts)
|
||||
// console.log('获取到的所有商品数据:', allProducts)
|
||||
|
||||
// Step 2: 获取详细信息
|
||||
const detailedProducts = await fetchProductDetails(allProducts)
|
||||
console.log('获取到的详细商品数据:', detailedProducts)
|
||||
// console.log('获取到的详细商品数据:', detailedProducts)
|
||||
|
||||
// Step 3: 获取汇总数据(如果需要)
|
||||
let summaryData = []
|
||||
@@ -418,9 +418,9 @@ const getList = async () => {
|
||||
createTime: summary.createTime
|
||||
}]
|
||||
}))
|
||||
console.log('转换后的汇总数据:', summaryData)
|
||||
// console.log('转换后的汇总数据:', summaryData)
|
||||
} catch (summaryError) {
|
||||
console.warn('获取汇总数据失败,继续处理商品数据:', summaryError)
|
||||
// console.warn('获取汇总数据失败,继续处理商品数据:', summaryError)
|
||||
}
|
||||
|
||||
// Step 4: 按barCode分组合并商品
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="用户编号" prop="userId">
|
||||
<el-input v-model="formData.userId" placeholder="请输入用户编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="订单号" prop="orderId">
|
||||
<el-input v-model="formData.orderId" placeholder="请输入订单号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="订单流水号" prop="orderNo">
|
||||
<el-input v-model="formData.orderNo" placeholder="请输入订单流水号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="设备IMEI" prop="deviceId">
|
||||
<el-input v-model="formData.deviceId" placeholder="请输入设备IMEI" />
|
||||
</el-form-item>
|
||||
<el-form-item label="出货状态" prop="deviceStatus">
|
||||
<el-radio-group v-model="formData.deviceStatus">
|
||||
<el-radio value="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="内容" prop="content">
|
||||
<Editor v-model="formData.content" height="150px" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { DeviceLogApi, DeviceLogVO } from '@/api/mall/statistics/devicelog'
|
||||
|
||||
|
||||
|
||||
/** 贩卖机出货日志 表单 */
|
||||
defineOptions({ name: 'DeviceLogForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
orderId: undefined,
|
||||
orderNo: undefined,
|
||||
deviceId: undefined,
|
||||
deviceStatus: undefined,
|
||||
content: undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
userId: [{ required: true, message: '用户编号不能为空', trigger: 'blur' }],
|
||||
orderId: [{ required: true, message: '订单号不能为空', trigger: 'blur' }],
|
||||
orderNo: [{ required: true, message: '订单流水号不能为空', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '内容不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await DeviceLogApi.getDeviceLog(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as DeviceLogVO
|
||||
if (formType.value === 'create') {
|
||||
await DeviceLogApi.createDeviceLog(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await DeviceLogApi.updateDeviceLog(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
orderId: undefined,
|
||||
orderNo: undefined,
|
||||
deviceId: undefined,
|
||||
deviceStatus: undefined,
|
||||
content: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,234 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="用户编号" prop="userId">
|
||||
<el-input
|
||||
v-model="queryParams.userId"
|
||||
placeholder="请输入用户编号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单号" prop="orderId">
|
||||
<el-input
|
||||
v-model="queryParams.orderId"
|
||||
placeholder="请输入订单号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单流水号" prop="orderNo">
|
||||
<el-input
|
||||
v-model="queryParams.orderNo"
|
||||
placeholder="请输入订单流水号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备IMEI" prop="deviceId">
|
||||
<el-input
|
||||
v-model="queryParams.deviceId"
|
||||
placeholder="请输入设备IMEI"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="出货状态" prop="deviceStatus">
|
||||
<el-select
|
||||
v-model="queryParams.deviceStatus"
|
||||
placeholder="请选择出货状态"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-220px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['trade:device-log:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['trade:device-log:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<el-table-column label="日志主键" align="center" prop="id" />
|
||||
<el-table-column label="用户编号" align="center" prop="userId" />
|
||||
<el-table-column label="订单号" align="center" prop="orderId" />
|
||||
<el-table-column label="订单流水号" align="center" prop="orderNo" />
|
||||
<el-table-column label="设备IMEI" align="center" prop="deviceId" />
|
||||
<el-table-column label="出货状态" align="center" prop="deviceStatus" />
|
||||
<el-table-column label="内容" align="center" prop="content" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" min-width="120px">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['trade:device-log:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['trade:device-log:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<DeviceLogForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { DeviceLogApi, DeviceLogVO } from '@/api/mall/statistics/devicelog'
|
||||
import DeviceLogForm from './DeviceLogForm.vue'
|
||||
|
||||
/** 贩卖机出货日志 列表 */
|
||||
defineOptions({ name: 'DeviceLog' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<DeviceLogVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
userId: undefined,
|
||||
orderId: undefined,
|
||||
orderNo: undefined,
|
||||
deviceId: undefined,
|
||||
deviceStatus: undefined,
|
||||
content: undefined,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await DeviceLogApi.getDeviceLogPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await DeviceLogApi.deleteDeviceLog(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await DeviceLogApi.exportDeviceLog(queryParams)
|
||||
download.excel(data, '贩卖机出货日志.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
@@ -289,6 +289,7 @@ const getList = async () => {
|
||||
const data = await TradeOrderApi.getOrderPage(unref(queryParams))
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
console.log("订单列表",data)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" stripe>
|
||||
<el-table-column label="设备IMEI" align="center" prop="deviceId" min-width="120" />
|
||||
|
||||
<el-table-column label="物料编码" align="center" prop="barCode" min-width="120" />
|
||||
<el-table-column label="商品名称" align="center" prop="spuName" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column label="销售数量" align="center" prop="orderCount" min-width="100">
|
||||
@@ -79,6 +79,7 @@
|
||||
<el-tag type="success">{{ scope.row.orderCount }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="设备IMEI" align="center" prop="deviceId" min-width="120" />
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
@@ -123,6 +124,7 @@ const getList = async () => {
|
||||
const data = await OrderSalesStatisticsApi.getSalesStatistics(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
console.log("销售订单",data)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user