feat:食堂菜品购买统计

This commit is contained in:
dzc committed 2025-05-12 17:26:55 +08:00
1 parent e718cfff82
commit 270a373789
4 files changed
+147 -6

No files matched your search

+2 -2
View File
@@ -11,14 +11,14 @@ ENV = 'development'
# VITE_ADMIN_PROXY_PATH = http://123.156.230.15:8089/api/ # 测试线上
# VITE_ADMIN_PROXY_PATH = http://pjcloud.center.takin.cc/
# VITE_ADMIN_PROXY_PATH = http://localhost:9999/
VITE_ADMIN_PROXY_PATH = http://192.168.101.123:9999/ # 邓-本地
VITE_ADMIN_PROXY_PATH = http://192.168.101.125:9999/ # 邓-本地
# VITE_ADMIN_PROXY_PATH = http://59.202.170.152:81/api # 正式环境线上
# 图片访问基础地址
# VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api/ # 测试线上
# VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc
# VITE_IMAGE_BASE_PATH = http://localhost:9999
VITE_IMAGE_BASE_PATH = http://192.168.101.123:9999 # 邓-本地
VITE_IMAGE_BASE_PATH = http://192.168.101.125:9999 # 邓-本地
# VITE_IMAGE_BASE_PATH = http://59.202.170.152:81/api/ # 正式环境线上
# 代码生成服务地址
+15
View File
@@ -15,6 +15,21 @@ export function canteenProudctTotal(query: any) {
})
}
/**
* 食堂统计
*/
export function canteenProudctQuery(query: any) {
return request({
url: "/hard/hard-canteen-total-log/proudct-query",
method: "post",
params: {
current: query.current,
size: query.size,
},
data: query,
})
}
export function pageListDept(query?: any) {
return request({
url: "/hard/hard-total/page-list-dept",
@@ -0,0 +1,105 @@
<template>
<el-dialog title="菜品统计" width="70%" v-model="visible" :close-on-click-modal="false" draggable>
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList"> </el-form>
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
:summary-method="getSummaries"
:show-summary="true"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table-column label="用餐时间" align="center" prop="createTime">
<template #default="{ row }">
<span>{{ parseTime(row.createTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column label="商品" align="center" prop="productName" />
<el-table-column label="商品图片" align="center">
<template #default="{ row }">
<preview-image v-if="row.productPic" :src="row.productPic" />
</template>
</el-table-column>
<el-table-column label="单价" align="center">
<template #default="{ row }">
<span>{{ displayPrice(row.productPrice) }}</span>
</template>
</el-table-column>
<el-table-column label="总数量" prop="count" align="center">
<template #default="{ row }">
<span>{{ row.count }}份</span>
</template>
</el-table-column>
<el-table-column label="总价" prop="totalPrice" align="center">
<template #default="{ row }">
<span>{{ displayPrice(row.totalPrice) }}</span>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</el-dialog>
</template>
<script setup lang="ts" name="product-total-table">
import { BasicTableProps, useTable } from "/@/hooks/table"
import { displayPrice } from "/@/utils/formatMoney"
import { parseTime } from "/@/utils/formatTime"
import * as hardTotalApi from "/@/api/hard/hard-total"
// 定义变量内容
const visible = ref(false)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
createdIsNeed: false,
queryForm: {},
pageList: hardTotalApi.canteenProudctQuery,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, postDownBlobFile, tableStyle } = useTable(state)
const getSummaries = (param: any) => {
const { columns, data } = param
const totalColumns = ["count", "totalPrice"]
const totalRow = Array.from({ length: columns.length })
totalRow[0] = "合计"
columns.forEach((i: any, index: number) => {
if (totalColumns.includes(i.property)) {
const total = data
.filter((v: any) => v[i.property] != null)
.map((v: any) => Number(v[i.property]))
.reduce((pren: number, next: number) => pren + next, 0)
if (i.property.includes("Price")) {
totalRow[index] = displayPrice(total)
} else {
totalRow[index] = total
}
}
})
return totalRow
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
const openDialog = (createTimeStr: any, hourType: any) => {
visible.value = true
state.queryForm.createTimeStr = createTimeStr
state.queryForm.hourType = hourType
getDataList()
}
// 暴露变量
defineExpose({
openDialog,
})
</script>
+25 -4
View File
@@ -52,7 +52,11 @@
>
<el-table-column type="selection" width="80" align="center" />
<el-table-column type="index" label="#" width="50" />
<el-table-column label="用餐时间" align="center" prop="createTime" />
<el-table-column label="用餐时间" align="center" prop="createTime">
<template #default="{ row }">
<span>{{ parseTime(row.createTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column label="用餐时间段" align="center" prop="hourType">
<template #default="{ row }">
<dict-tag :options="daily_menu" :value="row.hourType" />
@@ -63,9 +67,22 @@
<span class="color-success"> {{ row.payCount || 0 }}份 </span>
</template>
</el-table-column>
<el-table-column label="总价" prop="totalPrice" align="center">
<template #default="{ row }">
<span>{{ displayPrice(row.totalPrice) }}</span>
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="200">
<template #default="{ row }">
<el-button icon="Tickets" text type="primary"> 菜品详情 </el-button>
<el-button
icon="Tickets"
text
type="primary"
@click="productTotalTableRef.openDialog(parseTime(row.createTime, '{y}-{m}-{d}'), row.hourType)"
>
菜品详情
</el-button>
</template>
</el-table-column>
</el-table>
@@ -73,6 +90,7 @@
</template>
</DraggableDepTree>
</div>
<product-total-table ref="productTotalTableRef" />
</div>
</template>
@@ -81,11 +99,14 @@ import { BasicTableProps, useTable } from "/@/hooks/table"
import * as hardTotalApi from "/@/api/hard/hard-total"
import { displayPrice } from "/@/utils/formatMoney"
import { useDict } from "/@/hooks/dict"
import { parseTime } from "/@/utils/formatTime"
const ProductTotalTable = defineAsyncComponent(() => import("./components/product-total-table.vue"))
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
const productTotalTableRef = ref()
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
@@ -109,7 +130,7 @@ const exportExcel = () => {
const getSummaries = (param: any) => {
const { columns, data } = param
const totalColumns = ["payCount"]
const totalColumns = ["payCount", "totalPrice"]
const totalRow = Array.from({ length: columns.length })
totalRow[0] = "合计"
columns.forEach((i: any, index: number) => {