Merge branch 'master' of https://codeup.aliyun.com/bsdtec/biz-pc-cloud
This commit is contained in:
commit
8e3ef9ffd7
8 files changed
+553
-317
No files matched your search
@@ -1,5 +1,16 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
/**
|
||||
* 食堂菜品购买部门统计
|
||||
*/
|
||||
export function listByDept(query: any) {
|
||||
return request({
|
||||
url: "/hard/hard-canteen-total-dept/list-by-dept",
|
||||
method: "post",
|
||||
data: query,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门 食堂菜品购买统计
|
||||
*/
|
||||
|
||||
@@ -1,201 +1,86 @@
|
||||
<template>
|
||||
<el-select
|
||||
v-model="selectedId"
|
||||
:placeholder="placeholder"
|
||||
style="width: 100%"
|
||||
v-model="state.selectId"
|
||||
:placeholder="props.placeholder"
|
||||
clearable
|
||||
remote-show-suffix
|
||||
filterable
|
||||
remote
|
||||
:remote-method="handleSearch"
|
||||
:remote-method="remoteSearch"
|
||||
:loading="state.loading"
|
||||
@visible-change="handleVisibleChange"
|
||||
@change="handleChange"
|
||||
popper-class="supplier-select-dropdown"
|
||||
@visible-change="(e: boolean) => e && getOptions()"
|
||||
@change="change"
|
||||
>
|
||||
<el-option v-for="item in state.optionList" :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" />
|
||||
<el-option
|
||||
v-if="state.loading && state.optionList.length > 0"
|
||||
value=""
|
||||
disabled
|
||||
style="text-align: center; color: #999;"
|
||||
>
|
||||
加载中...
|
||||
</el-option>
|
||||
<el-option
|
||||
v-if="!state.hasMore && state.optionList.length > 0"
|
||||
value=""
|
||||
disabled
|
||||
style="text-align: center; color: #999;"
|
||||
>
|
||||
没有更多数据了
|
||||
</el-option>
|
||||
<el-option v-for="item in state.options" :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" />
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, watch, nextTick, onMounted, onUnmounted } from "vue"
|
||||
import { reactive, watch } from "vue"
|
||||
import { fetchList } from "/@/api/supermarketerp/smErpSupplier"
|
||||
|
||||
interface Supplier {
|
||||
supplierId: string | number
|
||||
supplierName: string
|
||||
}
|
||||
const emit = defineEmits(["change"])
|
||||
|
||||
interface Props {
|
||||
const selectId = defineModel()
|
||||
|
||||
export type Props = {
|
||||
placeholder?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
placeholder: "请输入",
|
||||
placeholder: "输入货商搜索",
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "change", supplier: Supplier | undefined): void
|
||||
}>()
|
||||
|
||||
const selectedId = defineModel<string | number>()
|
||||
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
optionList: [] as Supplier[],
|
||||
searchParams: {
|
||||
supplierName: "",
|
||||
current: 1,
|
||||
size: 10,
|
||||
},
|
||||
hasMore: true,
|
||||
total: 0,
|
||||
isLoadingMore: false,
|
||||
const queryForm = reactive<any>({
|
||||
supplierName: "",
|
||||
current: 1,
|
||||
size: 10,
|
||||
})
|
||||
|
||||
let scrollContainer: HTMLElement | null = null
|
||||
const state = reactive<any>({
|
||||
loading: true,
|
||||
selectId: selectId,
|
||||
options: [],
|
||||
})
|
||||
|
||||
// 监听选中值变化
|
||||
watch(
|
||||
selectedId,
|
||||
(newVal) => {
|
||||
if (newVal !== undefined) {
|
||||
resetAndFetch()
|
||||
}
|
||||
selectId,
|
||||
(newVal, oldValue) => {
|
||||
if (newVal == oldValue) return
|
||||
state.selectId = newVal
|
||||
getOptions()
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
// 重置并获取数据
|
||||
async function resetAndFetch() {
|
||||
state.searchParams.current = 1
|
||||
state.optionList = []
|
||||
state.hasMore = true
|
||||
state.isLoadingMore = false
|
||||
await fetchoptionList()
|
||||
}
|
||||
|
||||
async function fetchoptionList() {
|
||||
if (state.loading || state.isLoadingMore) return
|
||||
|
||||
async function getOptions() {
|
||||
try {
|
||||
if (state.searchParams.current === 1) {
|
||||
state.loading = true
|
||||
} else {
|
||||
state.isLoadingMore = true
|
||||
state.loading = true
|
||||
const _pa = {
|
||||
supplierId: selectId.value,
|
||||
...queryForm,
|
||||
}
|
||||
|
||||
const params = {
|
||||
supplierId: selectedId.value,
|
||||
...state.searchParams,
|
||||
}
|
||||
const { data } = await fetchList(params)
|
||||
|
||||
// 如果是第一页,替换数据;否则追加数据
|
||||
if (state.searchParams.current === 1) {
|
||||
state.optionList = data.records ?? []
|
||||
} else {
|
||||
// 确保追加而不是替换
|
||||
const newRecords = data.records ?? []
|
||||
state.optionList = [...state.optionList, ...newRecords]
|
||||
}
|
||||
|
||||
state.total = data.total || 0
|
||||
state.hasMore = state.optionList.length < state.total
|
||||
const { data } = await fetchList(_pa)
|
||||
state.options = data.records ?? []
|
||||
} finally {
|
||||
state.loading = false
|
||||
state.isLoadingMore = false
|
||||
setTimeout(() => (state.loading = false), 500)
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索处理
|
||||
function handleSearch(keyword: string) {
|
||||
if (keyword !== state.searchParams.supplierName) {
|
||||
state.searchParams.supplierName = keyword
|
||||
resetAndFetch()
|
||||
function remoteSearch(params: string) {
|
||||
if (params != queryForm.supplierName) {
|
||||
queryForm.supplierName = params
|
||||
getOptions()
|
||||
}
|
||||
}
|
||||
|
||||
// 下拉框显示状态变化
|
||||
function handleVisibleChange(visible: boolean) {
|
||||
if (visible) {
|
||||
if (state.optionList.length === 0) {
|
||||
resetAndFetch()
|
||||
}
|
||||
// 添加滚动监听
|
||||
nextTick(() => {
|
||||
addScrollListener()
|
||||
})
|
||||
} else {
|
||||
// 移除滚动监听
|
||||
removeScrollListener()
|
||||
}
|
||||
function clear() {
|
||||
state.selectId = null
|
||||
getOptions()
|
||||
}
|
||||
|
||||
// 选择变化处理
|
||||
function handleChange(supplierId: string) {
|
||||
const selectedOption = state.optionList.find((option) => option.supplierId === supplierId)
|
||||
emit("change", selectedOption)
|
||||
function change(v: any) {
|
||||
const targetSupplier = state.options.find((i: any) => i.supplierId == v)
|
||||
emit("change", targetSupplier)
|
||||
}
|
||||
|
||||
// 加载更多
|
||||
function loadMore() {
|
||||
if (state.hasMore && !state.loading && !state.isLoadingMore) {
|
||||
state.searchParams.current += 1
|
||||
fetchoptionList()
|
||||
}
|
||||
}
|
||||
|
||||
// 添加滚动监听
|
||||
function addScrollListener() {
|
||||
// 查找下拉框的滚动容器
|
||||
scrollContainer = document.querySelector('.supplier-select-dropdown .el-select-dropdown__wrap') as HTMLElement
|
||||
if (scrollContainer) {
|
||||
scrollContainer.addEventListener('scroll', handleScroll)
|
||||
}
|
||||
}
|
||||
|
||||
// 移除滚动监听
|
||||
function removeScrollListener() {
|
||||
if (scrollContainer) {
|
||||
scrollContainer.removeEventListener('scroll', handleScroll)
|
||||
scrollContainer = null
|
||||
}
|
||||
}
|
||||
|
||||
// 处理滚动事件
|
||||
function handleScroll() {
|
||||
if (!scrollContainer || state.isLoadingMore || !state.hasMore) return
|
||||
|
||||
const { scrollTop, scrollHeight, clientHeight } = scrollContainer
|
||||
// 当滚动到底部附近时(距离底部50px)触发加载
|
||||
if (scrollTop + clientHeight >= scrollHeight - 50) {
|
||||
loadMore()
|
||||
}
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
removeScrollListener()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.supplier-select-dropdown .el-select-dropdown__wrap {
|
||||
max-height: 300px !important;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,255 @@
|
||||
<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 height="450px" :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 type="selection" width="60" align="center" />
|
||||
<el-table-column width="200" label="用户">
|
||||
<template #default="{ row }">
|
||||
<div v-if="row.userId && row.userId != -1" class="flex flex-row items-center justify-center">
|
||||
<preview-image width="50px" height="50px" :src="row.userAvatar" />
|
||||
<div class="flex flex-col ml-2 items-start cursor-pointer hover:underline hover:text-blue-500">
|
||||
<span> {{ row.username }}</span>
|
||||
<span> {{ row.userMobile }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<span>未知用户</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="200px" label="商品">
|
||||
<template #default="{ row }">
|
||||
<div class="desc">
|
||||
<span>商品</span>
|
||||
<el-tooltip :content="row.productDesc" placement="top-start">
|
||||
<span class="text-line">{{ row.productDesc }}</span>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div class="status" v-if="row.hourType">
|
||||
<span>用餐时间段</span>
|
||||
<span>
|
||||
<dict-tag :options="daily_menu" :value="row.hourType" />
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="250px" label="订单信息">
|
||||
<template #default="{ row }">
|
||||
<div class="status">
|
||||
<span>订单类型</span>
|
||||
<span>
|
||||
<dict-tag :options="hard_order_type" :value="row.orderType" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="status">
|
||||
<span>支付方式</span>
|
||||
<span>
|
||||
<dict-tag :options="hard_pay_type" :value="row.payType" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="status">
|
||||
<span>订单状态</span>
|
||||
<span>
|
||||
<dict-tag :options="hard_order_status" :value="row.orderStatus" />
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="200px" prop="paymentInformation" label="付款信息">
|
||||
<template #default="{ row }">
|
||||
<div class="status">
|
||||
<span>商品总价</span>
|
||||
<span class="color-success">
|
||||
{{ displayPrice(row.totalPrice, "元", 2) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="status">
|
||||
<span>额外支付</span>
|
||||
<span class="color-danger">
|
||||
{{ displayPrice(row.extraPrice, "元", 2) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="status">
|
||||
<span>实际支付</span>
|
||||
<span class="color-primary">
|
||||
{{ displayPrice(row.payPrice, "元", 2) }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="支付时间" align="center" prop="payTime">
|
||||
<template #default="{ row }">
|
||||
<div class="status">
|
||||
<span>创建时间</span>
|
||||
<span>{{ row.createTime }} </span>
|
||||
</div>
|
||||
<div class="status">
|
||||
<span>支付时间</span>
|
||||
<span>{{ row.payTime }} </span>
|
||||
</div>
|
||||
</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="dept-person-total-table">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
import * as hardOrderApi from "/@/api/hard/hard-order"
|
||||
|
||||
// 定义查询字典
|
||||
const { daily_menu, hard_pay_type, hard_order_type, hard_order_status, } = useDict(
|
||||
"daily_menu", "hard_pay_type", "hard_order_type", "hard_order_status",
|
||||
)
|
||||
|
||||
// 定义变量内容
|
||||
const visible = ref(false)
|
||||
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any
|
||||
const multiple = ref(true)
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
createdIsNeed: false,
|
||||
queryForm: {},
|
||||
pageList: hardOrderApi.pageJoin,
|
||||
})
|
||||
|
||||
// table hook
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, tableStyle } = useTable(state)
|
||||
|
||||
// 多选事件
|
||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
selectObjs.value = objs.map(({ id }) => id)
|
||||
multiple.value = !objs.length
|
||||
}
|
||||
|
||||
const openDialog = (row: any, query: any) => {
|
||||
console.log("row:", row);
|
||||
console.log("query:", query);
|
||||
|
||||
state.queryForm.merchantId = null
|
||||
state.queryForm.userDeptIds = null
|
||||
state.queryForm.hourType = null
|
||||
state.queryForm.payTimeList = null
|
||||
|
||||
// 只查询食堂
|
||||
state.queryForm.hourTypeIsNotEmpty = true
|
||||
state.queryForm.productDescIsNotEmpty = true
|
||||
state.queryForm.merchantType = '1'
|
||||
state.queryForm.orderStatusCodes = ['5', '20']
|
||||
|
||||
if (row && row.mchId) {
|
||||
state.queryForm.merchantId = row.mchId
|
||||
}
|
||||
if (row && row.userDeptId) {
|
||||
state.queryForm.isInclude = true
|
||||
state.queryForm.userDeptIds = [row.userDeptId]
|
||||
}
|
||||
if (query && query.hourType) {
|
||||
state.queryForm.hourType = query.hourType
|
||||
} else if (row.hourType) {
|
||||
state.queryForm.hourType = row.hourType
|
||||
}
|
||||
if (query.payTimeList && query.payTimeList.length) {
|
||||
state.queryForm.payTimeList = query.payTimeList
|
||||
}
|
||||
console.log("state.queryForm:", state.queryForm);
|
||||
|
||||
getDataList()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
const updateQueryParams = (params: any) => {
|
||||
if (!params) return
|
||||
state.queryForm.hourType = params.hourType ?? null
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
updateQueryParams,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.text-line {
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.desc {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 2px;
|
||||
|
||||
span {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
span:nth-child(1) {
|
||||
min-width: 60px;
|
||||
max-width: 100px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
span:nth-child(2) {
|
||||
flex: 1;
|
||||
min-width: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
.status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 2px;
|
||||
|
||||
span {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
span:nth-child(1) {
|
||||
min-width: 60px;
|
||||
max-width: 100px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
span:nth-child(2) {
|
||||
flex: 1;
|
||||
min-width: 50px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,87 +0,0 @@
|
||||
<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>
|
||||
<el-table-column label="用餐时间" align="center" prop="createTime">
|
||||
<template #default="{ row }">
|
||||
<span>{{ parseTime(row.createTime, "{y}-{m}-{d}") }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="dept-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, tableStyle } = useTable(state)
|
||||
|
||||
// 多选事件
|
||||
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()
|
||||
}
|
||||
|
||||
const updateQueryParams = (params: any) => {
|
||||
if (!params) return
|
||||
state.queryForm.merchantId = params.merchantId ?? null
|
||||
getDataList()
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
updateQueryParams,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -1,37 +1,115 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<DraggableDepTree ref="draggableDepTreeRef" placeholder="请输入部门名称" :show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode" switch-inactive-text="包含" switch-active-text="不包含"
|
||||
:defaultTreeWidth="20" :nodeClickable="false">
|
||||
<el-row>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
<el-form-item style="width: 250px" label="用餐时间段" prop="hourType">
|
||||
<dict-select v-model="state.queryForm.hourType" dict-code="daily_menu" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 250px" label="食堂" prop="merchantId">
|
||||
<select-mch v-model="state.queryForm.merchantId"
|
||||
:apiParams="{ parentIsNull: false, types: '1' }" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 450px" label="创建时间" prop="createTimeList">
|
||||
<el-date-picker v-model="state.queryForm.createTimeList" value-format="YYYY-MM-DD"
|
||||
type="daterange" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="Search" type="primary" @click="doSearch">
|
||||
{{ $t("common.queryBtn") }}
|
||||
</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
|
||||
@sort-change="sortChangeHandle" @expand-change="tableExpandChange">
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
|
||||
v-bind="state.pagination" />
|
||||
</DraggableDepTree>
|
||||
<el-row>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
<el-form-item style="width: 250px" label="用餐时间段" prop="hourType">
|
||||
<dict-select v-model="state.queryForm.hourType" dict-code="daily_menu" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 250px" label="食堂" prop="merchantId">
|
||||
<select-mch v-model="state.queryForm.merchantId"
|
||||
:apiParams="{ parentIsNull: false, types: '1' }" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 450px" label="订单时间" prop="payTimeList">
|
||||
<el-date-picker v-model="state.queryForm.payTimeList" value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="Search" type="primary" @click="doSearch">
|
||||
{{ $t("common.queryBtn") }}
|
||||
</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<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"
|
||||
row-class-name="success-row" @selection-change="selectionChangHandle" @sort-change="sortChangeHandle"
|
||||
@expand-change="tableExpandChange">
|
||||
<el-table-column type="expand" width="80">
|
||||
<!-- start 时间段 start -->
|
||||
<template #default="{ row }">
|
||||
<div v-if="row.children && row.children.length" class="ml-[80px] my-2">
|
||||
<el-table :data="row.children" border :cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle" :summary-method="getSummaries"
|
||||
:show-summary="true" row-class-name="warning-row">
|
||||
<el-table-column type="index" label="#" width="60" align="center" />
|
||||
<el-table-column prop="userDeptName" align="center" label="部门" width="200" />
|
||||
<el-table-column label="用餐时间段" width="150" align="center" prop="hourType">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="daily_menu" :value="row.hourType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="交易人数" width="150" align="center" prop="payUserCountByTable">
|
||||
<template #default="{ row }">
|
||||
<span class="color-primary"> {{ row.payUserCount || 0 }}人 </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="交易次数" width="150" align="center" prop="timeCount">
|
||||
<template #default="{ row }">
|
||||
<span class="color-primary"> {{ row.timeCount || 0 }}次 </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="售出商品数量" width="150" align="center" prop="payCount">
|
||||
<template #default="{ row }">
|
||||
<span class="color-success"> {{ row.payCount || 0 }}份 </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="总价" width="150" prop="totalPrice" align="center">
|
||||
<template #default="{ row }">
|
||||
<span>{{ displayPrice(row.totalPrice) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" label="操作">
|
||||
<template #default="{ row }">
|
||||
<el-button icon="Tickets" text type="primary" @click="doOpenDialog(row)">
|
||||
购买人员
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
<!-- end 时间段 end -->
|
||||
</el-table-column>
|
||||
<el-table-column type="index" label="#" width="60" />
|
||||
<el-table-column label="食堂" align="center" width="200" prop="mchName" />
|
||||
<el-table-column label="用餐部门数" align="center" width="150" prop="deptCount">
|
||||
<template #default="{ row }">
|
||||
<span class="color-danger"> {{ row.deptCount || 0 }}部门 </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="交易人数" width="150" align="center" prop="payUserCount">
|
||||
<template #default="{ row }">
|
||||
<span class="color-primary"> {{ row.payUserCount || 0 }}人 </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="交易次数" width="150" align="center" prop="timeCount">
|
||||
<template #default="{ row }">
|
||||
<span class="color-primary"> {{ row.timeCount || 0 }}次 </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="售出商品数量" width="150" align="center" prop="payCount">
|
||||
<template #default="{ row }">
|
||||
<span class="color-success"> {{ row.payCount || 0 }}份 </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="总价" width="150" prop="totalPrice" align="center">
|
||||
<template #default="{ row }">
|
||||
<span>{{ displayPrice(row.totalPrice) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" label="操作">
|
||||
<template #default="{ row }">
|
||||
<el-button icon="Tickets" text type="primary" @click="doOpenDialog(row)">
|
||||
购买人员
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
|
||||
v-bind="state.pagination" />
|
||||
<dept-person-total-table ref="deptPersonTotalTableRef" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -39,26 +117,52 @@
|
||||
|
||||
<script setup lang="ts" name="canteen-dept-total">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
import * as hardTotalApi from "/@/api/hard/hard-total"
|
||||
|
||||
const DeptPersonTotalTable = defineAsyncComponent(() => import("./components/dept-person-total-table.vue"))
|
||||
|
||||
// 定义查询字典
|
||||
const { daily_menu } = useDict("daily_menu")
|
||||
|
||||
const deptPersonTotalTableRef = ref()
|
||||
|
||||
// 搜索变量
|
||||
const queryRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const productTotalTableRef = ref()
|
||||
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any
|
||||
const multiple = ref(true)
|
||||
const draggableDepTreeRef = ref() // 树组件ref引用
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
const state: BasicTableProps = reactive({
|
||||
queryForm: {},
|
||||
pageList: hardTotalApi.canteenProudctTotal,
|
||||
})
|
||||
|
||||
// table hook
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, postDownBlobFile, tableStyle } = useTable(state)
|
||||
const { currentChangeHandle, sizeChangeHandle, sortChangeHandle, tableStyle } = useTable(state)
|
||||
|
||||
onMounted(() => {
|
||||
getDataList()
|
||||
})
|
||||
|
||||
const getDataList = async () => {
|
||||
try {
|
||||
state.loading = true
|
||||
const { data } = await hardTotalApi.listByDept(state.queryForm)
|
||||
if (data && data.length) {
|
||||
state.dataList = data
|
||||
} else {
|
||||
state.dataList = []
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
state.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
@@ -68,7 +172,6 @@ const resetQuery = () => {
|
||||
selectObjs.value = []
|
||||
state.queryForm.deptId = ""
|
||||
state.queryForm.userDeptIds = []
|
||||
draggableDepTreeRef.value.resetData()
|
||||
getDataList()
|
||||
}
|
||||
|
||||
@@ -81,6 +184,10 @@ const tableExpandChange = async (e: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const doOpenDialog = (row: any) => {
|
||||
deptPersonTotalTableRef.value.openDialog(row, state.queryForm)
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
selectObjs.value = objs.map(({ id }) => id)
|
||||
@@ -89,17 +196,40 @@ const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
|
||||
// 搜索
|
||||
const doSearch = () => {
|
||||
productTotalTableRef.value.updateQueryParams(state.queryForm)
|
||||
deptPersonTotalTableRef.value.updateQueryParams(state.queryForm)
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 树节点选择时
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.userDeptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
const getSummaries = (param: any) => {
|
||||
const { columns, data } = param
|
||||
const totalColumns = ["payUserCount", "timeCount", "payCount", "totalPrice", "payUserCountByTable"]
|
||||
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 if (i.property == 'payUserCountByTable') {
|
||||
totalRow[index] = "";
|
||||
} else {
|
||||
totalRow[index] = total
|
||||
}
|
||||
}
|
||||
})
|
||||
return totalRow
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style>
|
||||
.el-table .warning-row {
|
||||
--el-table-tr-bg-color: var(--el-color-warning-light-9);
|
||||
}
|
||||
|
||||
.el-table .success-row {
|
||||
--el-table-tr-bg-color: var(--el-color-success-light-9);
|
||||
}
|
||||
</style>
|
||||
@@ -34,8 +34,8 @@
|
||||
</el-row>
|
||||
<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"
|
||||
@expand-change="tableExpandChange">
|
||||
:show-summary="true" row-class-name="success-row" @selection-change="selectionChangHandle"
|
||||
@sort-change="sortChangeHandle" @expand-change="tableExpandChange">
|
||||
<el-table-column v-if="false" type="selection" width="80" align="center" />
|
||||
|
||||
<el-table-column type="expand" width="50">
|
||||
@@ -43,9 +43,9 @@
|
||||
<div class="ml-[50px] my-2">
|
||||
<el-table :data="getTableChildrenMap(row.uniqueCode)" border
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
:header-cell-style="tableStyle.headerCellStyle" row-class-name="warning-row">
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column prop="userDeptName" align="center" label="部门" width="150" />
|
||||
<el-table-column prop="userDeptName" align="center" label="部门" width="200" />
|
||||
<el-table-column label="用餐时间段" width="100" align="center" prop="hourType">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="daily_menu" :value="row.hourType" />
|
||||
@@ -77,7 +77,7 @@
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column label="用餐时间" align="center" width="150" prop="createTime">
|
||||
<el-table-column label="用餐时间" align="center" width="200" prop="createTime">
|
||||
<template #default="{ row }">
|
||||
<span>{{ parseTime(row.createTime, "{y}-{m}-{d}") }}</span>
|
||||
</template>
|
||||
@@ -108,7 +108,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column fixed="right" label="操作" width="200">
|
||||
<el-table-column fixed="right" label="操作">
|
||||
<template #default="{ row }">
|
||||
<el-button icon="Tickets" text type="primary"
|
||||
@click="productTotalTableRef.openDialog(parseTime(row.createTime, '{y}-{m}-{d}'), row.hourType)">
|
||||
@@ -236,3 +236,13 @@ const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepT
|
||||
getDataList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.el-table .warning-row {
|
||||
--el-table-tr-bg-color: var(--el-color-warning-light-9);
|
||||
}
|
||||
|
||||
.el-table .success-row {
|
||||
--el-table-tr-bg-color: var(--el-color-success-light-9);
|
||||
}
|
||||
</style>
|
||||
@@ -7,8 +7,8 @@
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
<el-row>
|
||||
<el-form-item style="width: 300px" label="用户" prop="userIds">
|
||||
<select-user v-model="state.queryForm.userIds" />
|
||||
<el-form-item style="width: 300px" label="用户" prop="userId">
|
||||
<select-user v-model="state.queryForm.userId" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 300px" label="商户类型" prop="merchantType">
|
||||
<dict-select v-model="state.queryForm.merchantType" dict-code="merchant_type" />
|
||||
@@ -252,7 +252,6 @@ import { useDict } from "/@/hooks/dict"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import { ElLoading, TableColumnCtx } from "element-plus"
|
||||
import { VNode } from "vue"
|
||||
import { ro } from "element-plus/es/locale"
|
||||
|
||||
const { push } = useRouter()
|
||||
|
||||
|
||||
@@ -113,9 +113,19 @@
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="selectedUnitObj" title="包装单位" :edit-render="{}">
|
||||
<template #edit="{ row }">
|
||||
<el-select v-model="row.selectedUnitObj" value-key="id" placeholder="请选择包装单位">
|
||||
<el-option v-for="item in row.erpUnitVos" :key="item.id" :label="item.unit" :value="item" />
|
||||
<template #edit="{ row, $rowIndex }">
|
||||
<el-select
|
||||
v-model="row.selectedUnitObj"
|
||||
value-key="id"
|
||||
placeholder="请选择包装单位"
|
||||
@change="reComputeTotalAmount(row, $rowIndex)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in row.erpUnitVos"
|
||||
:key="item.id"
|
||||
:label="item.spec ? item.unit + '-' + item.spec : item.unit"
|
||||
:value="item"
|
||||
/>
|
||||
</el-select>
|
||||
<!-- <el-select v-else v-model="row.unitId" value-key="id" placeholder="请选择包装单位">
|
||||
<el-option :key="row.id" :label="row.unit" :value="row.unitId" />
|
||||
@@ -126,11 +136,11 @@
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="quantity" title="数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||
<template #edit="{ row }">
|
||||
<el-input v-model.number="row.quantity" />
|
||||
<template #edit="{ row, $rowIndex }">
|
||||
<el-input v-model.number="row.quantity" @change="reComputeTotalAmount(row, $rowIndex)" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="unitPrice" title="原进价">
|
||||
<vxe-column field="purchasePrice" title="原进价">
|
||||
<template #default="{ row }">
|
||||
{{ displayPrice(row.selectedUnitObj?.purchasePrice || 0) }}
|
||||
</template>
|
||||
@@ -139,15 +149,25 @@
|
||||
<template #default="{ row }">
|
||||
{{ row?.selectedUnitObj?.realPrice || 0 }}
|
||||
</template>
|
||||
<template #edit="{ row }">
|
||||
<el-input-number v-if="row.selectedUnitObj" v-model="row.selectedUnitObj.realPrice" :min="0" :precision="2" />
|
||||
<template #edit="{ row, $rowIndex }">
|
||||
<el-input-number
|
||||
v-if="row.selectedUnitObj"
|
||||
v-model="row.selectedUnitObj.realPrice"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
@change="reComputeTotalAmount(row, $rowIndex)"
|
||||
/>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="totalAmount" title="累计总金额">
|
||||
<vxe-column field="totalAmount" title="累计总金额" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.selectedUnitObj && row.quantity">
|
||||
{{ Number(row.quantity * parseFloat(row.selectedUnitObj.realPrice || 0)).toFixed(2) }}
|
||||
</span>
|
||||
{{ row?.selectedUnitObj?.totalAmount }}
|
||||
<!-- <span v-if="row.selectedUnitObj && row.quantity">
|
||||
{{ Number((row.quantity * parseFloat(row.selectedUnitObj.realPrice || 0)).toFixed(2)) }}
|
||||
</span> -->
|
||||
</template>
|
||||
<template #edit="{ row }">
|
||||
<el-input-number v-if="row.selectedUnitObj" v-model="row.selectedUnitObj.totalAmount" :min="0" :precision="2" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="remark" title="备注" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||
@@ -265,7 +285,11 @@ const getInitData = async () => {
|
||||
const selectedUnitObj = item.erpUnitVos.find((unit: any) => unit.id === item.unitId)
|
||||
return {
|
||||
...item,
|
||||
selectedUnitObj: { ...selectedUnitObj, realPrice: displayPrice(item?.realPrice, "") || 0 },
|
||||
selectedUnitObj: {
|
||||
...selectedUnitObj,
|
||||
realPrice: Number(displayPrice(item?.realPrice, "")) || 0,
|
||||
totalAmount: Number(displayPrice(item?.totalAmount, "")),
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -315,8 +339,12 @@ const getSelectedRows = (selectionRows: any) => {
|
||||
// if (index !== -1) return state.erpSpuItemsMemo[index]
|
||||
return {
|
||||
...addItem,
|
||||
erpUnitVos: addItem.erpUnitVos.map((item: any) => ({ ...item, realPrice: displayPrice(item.purchasePrice, "") })),
|
||||
selectedUnitObj: addItem.erpUnitVos[0],
|
||||
erpUnitVos: addItem.erpUnitVos.map((item: any) => ({ ...item, realPrice: Number(displayPrice(item.purchasePrice, "")) })),
|
||||
selectedUnitObj: {
|
||||
...addItem.erpUnitVos[0],
|
||||
realPrice: parseFloat(displayPrice(addItem.erpUnitVos[0].purchasePrice, "")),
|
||||
totalAmount: 1 * parseFloat(displayPrice(addItem.erpUnitVos[0].purchasePrice, "")),
|
||||
},
|
||||
unitId: addItem.erpUnitVos[0].id,
|
||||
quantity: 1,
|
||||
isNew: true,
|
||||
@@ -347,6 +375,11 @@ const removeRow = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 重新计算累计总金额
|
||||
const reComputeTotalAmount = (row: any, index: number) => {
|
||||
vxeTableData.value[index].selectedUnitObj.totalAmount = Number((row.quantity * parseFloat(row.selectedUnitObj.realPrice || 0)).toFixed(2))
|
||||
}
|
||||
|
||||
// 整理table数据
|
||||
const settledTableItems = computed(() => {
|
||||
return vxeTableData.value.map((item: any) => {
|
||||
@@ -357,7 +390,7 @@ const settledTableItems = computed(() => {
|
||||
quantity: item.quantity,
|
||||
unitPrice: selectedUnitObj.purchasePrice ? Number(selectedUnitObj?.purchasePrice) : 0,
|
||||
realPrice: selectedUnitObj.realPrice ? storePrice(selectedUnitObj?.realPrice) : 0,
|
||||
totalAmount: storePrice(Number(selectedUnitObj?.realPrice || 0) * item.quantity),
|
||||
totalAmount: storePrice(Number(selectedUnitObj?.totalAmount || 0)),
|
||||
remark: item.remark,
|
||||
unitId: selectedUnitObj.id,
|
||||
orderType: baseDataForm.orderType,
|
||||
|
||||
Reference in new issue
Block a user