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"
|
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>
|
<template>
|
||||||
<el-select
|
<el-select
|
||||||
v-model="selectedId"
|
style="width: 100%"
|
||||||
:placeholder="placeholder"
|
v-model="state.selectId"
|
||||||
|
:placeholder="props.placeholder"
|
||||||
clearable
|
clearable
|
||||||
remote-show-suffix
|
remote-show-suffix
|
||||||
filterable
|
filterable
|
||||||
remote
|
remote
|
||||||
:remote-method="handleSearch"
|
:remote-method="remoteSearch"
|
||||||
:loading="state.loading"
|
:loading="state.loading"
|
||||||
@visible-change="handleVisibleChange"
|
@visible-change="(e: boolean) => e && getOptions()"
|
||||||
@change="handleChange"
|
@change="change"
|
||||||
popper-class="supplier-select-dropdown"
|
|
||||||
>
|
>
|
||||||
<el-option v-for="item in state.optionList" :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" />
|
<el-option v-for="item in state.options" :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-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, watch, nextTick, onMounted, onUnmounted } from "vue"
|
import { reactive, watch } from "vue"
|
||||||
import { fetchList } from "/@/api/supermarketerp/smErpSupplier"
|
import { fetchList } from "/@/api/supermarketerp/smErpSupplier"
|
||||||
|
|
||||||
interface Supplier {
|
const emit = defineEmits(["change"])
|
||||||
supplierId: string | number
|
|
||||||
supplierName: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
const selectId = defineModel()
|
||||||
|
|
||||||
|
export type Props = {
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
placeholder: "请输入",
|
placeholder: "输入货商搜索",
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const queryForm = reactive<any>({
|
||||||
(e: "change", supplier: Supplier | undefined): void
|
supplierName: "",
|
||||||
}>()
|
current: 1,
|
||||||
|
size: 10,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
let scrollContainer: HTMLElement | null = null
|
const state = reactive<any>({
|
||||||
|
loading: true,
|
||||||
|
selectId: selectId,
|
||||||
|
options: [],
|
||||||
|
})
|
||||||
|
|
||||||
// 监听选中值变化
|
|
||||||
watch(
|
watch(
|
||||||
selectedId,
|
selectId,
|
||||||
(newVal) => {
|
(newVal, oldValue) => {
|
||||||
if (newVal !== undefined) {
|
if (newVal == oldValue) return
|
||||||
resetAndFetch()
|
state.selectId = newVal
|
||||||
}
|
getOptions()
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
// 重置并获取数据
|
async function getOptions() {
|
||||||
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
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (state.searchParams.current === 1) {
|
state.loading = true
|
||||||
state.loading = true
|
const _pa = {
|
||||||
} else {
|
supplierId: selectId.value,
|
||||||
state.isLoadingMore = true
|
...queryForm,
|
||||||
}
|
}
|
||||||
|
const { data } = await fetchList(_pa)
|
||||||
const params = {
|
state.options = data.records ?? []
|
||||||
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
|
|
||||||
} finally {
|
} finally {
|
||||||
state.loading = false
|
setTimeout(() => (state.loading = false), 500)
|
||||||
state.isLoadingMore = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索处理
|
function remoteSearch(params: string) {
|
||||||
function handleSearch(keyword: string) {
|
if (params != queryForm.supplierName) {
|
||||||
if (keyword !== state.searchParams.supplierName) {
|
queryForm.supplierName = params
|
||||||
state.searchParams.supplierName = keyword
|
getOptions()
|
||||||
resetAndFetch()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下拉框显示状态变化
|
function clear() {
|
||||||
function handleVisibleChange(visible: boolean) {
|
state.selectId = null
|
||||||
if (visible) {
|
getOptions()
|
||||||
if (state.optionList.length === 0) {
|
|
||||||
resetAndFetch()
|
|
||||||
}
|
|
||||||
// 添加滚动监听
|
|
||||||
nextTick(() => {
|
|
||||||
addScrollListener()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// 移除滚动监听
|
|
||||||
removeScrollListener()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择变化处理
|
function change(v: any) {
|
||||||
function handleChange(supplierId: string) {
|
const targetSupplier = state.options.find((i: any) => i.supplierId == v)
|
||||||
const selectedOption = state.optionList.find((option) => option.supplierId === supplierId)
|
emit("change", targetSupplier)
|
||||||
emit("change", selectedOption)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载更多
|
|
||||||
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>
|
</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>
|
<template>
|
||||||
<div class="layout-padding">
|
<div class="layout-padding">
|
||||||
<div class="layout-padding-auto layout-padding-view">
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
<DraggableDepTree ref="draggableDepTreeRef" placeholder="请输入部门名称" :show-expand="true"
|
<el-row>
|
||||||
@getSelectNode="handleGetSelectNode" switch-inactive-text="包含" switch-active-text="不包含"
|
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||||
:defaultTreeWidth="20" :nodeClickable="false">
|
<el-form-item style="width: 250px" label="用餐时间段" prop="hourType">
|
||||||
<el-row>
|
<dict-select v-model="state.queryForm.hourType" dict-code="daily_menu" />
|
||||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
</el-form-item>
|
||||||
<el-form-item style="width: 250px" label="用餐时间段" prop="hourType">
|
<el-form-item style="width: 250px" label="食堂" prop="merchantId">
|
||||||
<dict-select v-model="state.queryForm.hourType" dict-code="daily_menu" />
|
<select-mch v-model="state.queryForm.merchantId"
|
||||||
</el-form-item>
|
:apiParams="{ parentIsNull: false, types: '1' }" />
|
||||||
<el-form-item style="width: 250px" label="食堂" prop="merchantId">
|
</el-form-item>
|
||||||
<select-mch v-model="state.queryForm.merchantId"
|
<el-form-item style="width: 450px" label="订单时间" prop="payTimeList">
|
||||||
:apiParams="{ parentIsNull: false, types: '1' }" />
|
<el-date-picker v-model="state.queryForm.payTimeList" value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
</el-form-item>
|
type="daterange" />
|
||||||
<el-form-item style="width: 450px" label="创建时间" prop="createTimeList">
|
</el-form-item>
|
||||||
<el-date-picker v-model="state.queryForm.createTimeList" value-format="YYYY-MM-DD"
|
<el-form-item>
|
||||||
type="daterange" />
|
<el-button icon="Search" type="primary" @click="doSearch">
|
||||||
</el-form-item>
|
{{ $t("common.queryBtn") }}
|
||||||
<el-form-item>
|
</el-button>
|
||||||
<el-button icon="Search" type="primary" @click="doSearch">
|
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
|
||||||
{{ $t("common.queryBtn") }}
|
</el-form-item>
|
||||||
</el-button>
|
</el-form>
|
||||||
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
|
</el-row>
|
||||||
</el-form-item>
|
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
|
||||||
</el-form>
|
:header-cell-style="tableStyle.headerCellStyle" :summary-method="getSummaries" :show-summary="true"
|
||||||
</el-row>
|
row-class-name="success-row" @selection-change="selectionChangHandle" @sort-change="sortChangeHandle"
|
||||||
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
|
@expand-change="tableExpandChange">
|
||||||
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
|
<el-table-column type="expand" width="80">
|
||||||
@sort-change="sortChangeHandle" @expand-change="tableExpandChange">
|
<!-- start 时间段 start -->
|
||||||
</el-table>
|
<template #default="{ row }">
|
||||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
|
<div v-if="row.children && row.children.length" class="ml-[80px] my-2">
|
||||||
v-bind="state.pagination" />
|
<el-table :data="row.children" border :cell-style="tableStyle.cellStyle"
|
||||||
</DraggableDepTree>
|
: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>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -39,26 +117,52 @@
|
|||||||
|
|
||||||
<script setup lang="ts" name="canteen-dept-total">
|
<script setup lang="ts" name="canteen-dept-total">
|
||||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||||
|
import { displayPrice } from "/@/utils/formatMoney"
|
||||||
|
import { useDict } from "/@/hooks/dict"
|
||||||
|
|
||||||
import * as hardTotalApi from "/@/api/hard/hard-total"
|
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 queryRef = ref()
|
||||||
const showSearch = ref(true)
|
|
||||||
const productTotalTableRef = ref()
|
|
||||||
|
|
||||||
// 多选变量
|
// 多选变量
|
||||||
const selectObjs = ref([]) as any
|
const selectObjs = ref([]) as any
|
||||||
const multiple = ref(true)
|
const multiple = ref(true)
|
||||||
const draggableDepTreeRef = ref() // 树组件ref引用
|
const draggableDepTreeRef = ref() // 树组件ref引用
|
||||||
|
|
||||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
const state: BasicTableProps = reactive({
|
||||||
queryForm: {},
|
queryForm: {},
|
||||||
pageList: hardTotalApi.canteenProudctTotal,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// table hook
|
// 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 = () => {
|
const resetQuery = () => {
|
||||||
@@ -68,7 +172,6 @@ const resetQuery = () => {
|
|||||||
selectObjs.value = []
|
selectObjs.value = []
|
||||||
state.queryForm.deptId = ""
|
state.queryForm.deptId = ""
|
||||||
state.queryForm.userDeptIds = []
|
state.queryForm.userDeptIds = []
|
||||||
draggableDepTreeRef.value.resetData()
|
|
||||||
getDataList()
|
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 }[]) => {
|
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||||
selectObjs.value = objs.map(({ id }) => id)
|
selectObjs.value = objs.map(({ id }) => id)
|
||||||
@@ -89,17 +196,40 @@ const selectionChangHandle = (objs: { id: string }[]) => {
|
|||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
const doSearch = () => {
|
const doSearch = () => {
|
||||||
productTotalTableRef.value.updateQueryParams(state.queryForm)
|
deptPersonTotalTableRef.value.updateQueryParams(state.queryForm)
|
||||||
getDataList()
|
getDataList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 树节点选择时
|
const getSummaries = (param: any) => {
|
||||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
const { columns, data } = param
|
||||||
state.queryForm.deptId = curClickedNode.id
|
const totalColumns = ["payUserCount", "timeCount", "payCount", "totalPrice", "payUserCountByTable"]
|
||||||
state.queryForm.userDeptIds = checkedTreeNodes.map((item: any) => item.id)
|
const totalRow = Array.from({ length: columns.length })
|
||||||
state.queryForm.isInclude = !isDeepTree
|
totalRow[0] = "合计"
|
||||||
getDataList()
|
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>
|
</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-row>
|
||||||
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
|
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
|
||||||
:header-cell-style="tableStyle.headerCellStyle" :summary-method="getSummaries"
|
:header-cell-style="tableStyle.headerCellStyle" :summary-method="getSummaries"
|
||||||
:show-summary="true" @selection-change="selectionChangHandle" @sort-change="sortChangeHandle"
|
:show-summary="true" row-class-name="success-row" @selection-change="selectionChangHandle"
|
||||||
@expand-change="tableExpandChange">
|
@sort-change="sortChangeHandle" @expand-change="tableExpandChange">
|
||||||
<el-table-column v-if="false" type="selection" width="80" align="center" />
|
<el-table-column v-if="false" type="selection" width="80" align="center" />
|
||||||
|
|
||||||
<el-table-column type="expand" width="50">
|
<el-table-column type="expand" width="50">
|
||||||
@@ -43,9 +43,9 @@
|
|||||||
<div class="ml-[50px] my-2">
|
<div class="ml-[50px] my-2">
|
||||||
<el-table :data="getTableChildrenMap(row.uniqueCode)" border
|
<el-table :data="getTableChildrenMap(row.uniqueCode)" border
|
||||||
:cell-style="tableStyle.cellStyle"
|
: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 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">
|
<el-table-column label="用餐时间段" width="100" align="center" prop="hourType">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<dict-tag :options="daily_menu" :value="row.hourType" />
|
<dict-tag :options="daily_menu" :value="row.hourType" />
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column type="index" label="#" width="50" />
|
<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 }">
|
<template #default="{ row }">
|
||||||
<span>{{ parseTime(row.createTime, "{y}-{m}-{d}") }}</span>
|
<span>{{ parseTime(row.createTime, "{y}-{m}-{d}") }}</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column fixed="right" label="操作" width="200">
|
<el-table-column fixed="right" label="操作">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-button icon="Tickets" text type="primary"
|
<el-button icon="Tickets" text type="primary"
|
||||||
@click="productTotalTableRef.openDialog(parseTime(row.createTime, '{y}-{m}-{d}'), row.hourType)">
|
@click="productTotalTableRef.openDialog(parseTime(row.createTime, '{y}-{m}-{d}'), row.hourType)">
|
||||||
@@ -236,3 +236,13 @@ const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepT
|
|||||||
getDataList()
|
getDataList()
|
||||||
}
|
}
|
||||||
</script>
|
</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>
|
<template #default>
|
||||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-form-item style="width: 300px" label="用户" prop="userIds">
|
<el-form-item style="width: 300px" label="用户" prop="userId">
|
||||||
<select-user v-model="state.queryForm.userIds" />
|
<select-user v-model="state.queryForm.userId" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item style="width: 300px" label="商户类型" prop="merchantType">
|
<el-form-item style="width: 300px" label="商户类型" prop="merchantType">
|
||||||
<dict-select v-model="state.queryForm.merchantType" dict-code="merchant_type" />
|
<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 { displayPrice } from "/@/utils/formatMoney"
|
||||||
import { ElLoading, TableColumnCtx } from "element-plus"
|
import { ElLoading, TableColumnCtx } from "element-plus"
|
||||||
import { VNode } from "vue"
|
import { VNode } from "vue"
|
||||||
import { ro } from "element-plus/es/locale"
|
|
||||||
|
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
|
|
||||||
|
|||||||
@@ -113,9 +113,19 @@
|
|||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="selectedUnitObj" title="包装单位" :edit-render="{}">
|
<vxe-column field="selectedUnitObj" title="包装单位" :edit-render="{}">
|
||||||
<template #edit="{ row }">
|
<template #edit="{ row, $rowIndex }">
|
||||||
<el-select v-model="row.selectedUnitObj" value-key="id" placeholder="请选择包装单位">
|
<el-select
|
||||||
<el-option v-for="item in row.erpUnitVos" :key="item.id" :label="item.unit" :value="item" />
|
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>
|
||||||
<!-- <el-select v-else v-model="row.unitId" value-key="id" placeholder="请选择包装单位">
|
<!-- <el-select v-else v-model="row.unitId" value-key="id" placeholder="请选择包装单位">
|
||||||
<el-option :key="row.id" :label="row.unit" :value="row.unitId" />
|
<el-option :key="row.id" :label="row.unit" :value="row.unitId" />
|
||||||
@@ -126,11 +136,11 @@
|
|||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="quantity" title="数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
<vxe-column field="quantity" title="数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||||
<template #edit="{ row }">
|
<template #edit="{ row, $rowIndex }">
|
||||||
<el-input v-model.number="row.quantity" />
|
<el-input v-model.number="row.quantity" @change="reComputeTotalAmount(row, $rowIndex)" />
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="unitPrice" title="原进价">
|
<vxe-column field="purchasePrice" title="原进价">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ displayPrice(row.selectedUnitObj?.purchasePrice || 0) }}
|
{{ displayPrice(row.selectedUnitObj?.purchasePrice || 0) }}
|
||||||
</template>
|
</template>
|
||||||
@@ -139,15 +149,25 @@
|
|||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ row?.selectedUnitObj?.realPrice || 0 }}
|
{{ row?.selectedUnitObj?.realPrice || 0 }}
|
||||||
</template>
|
</template>
|
||||||
<template #edit="{ row }">
|
<template #edit="{ row, $rowIndex }">
|
||||||
<el-input-number v-if="row.selectedUnitObj" v-model="row.selectedUnitObj.realPrice" :min="0" :precision="2" />
|
<el-input-number
|
||||||
|
v-if="row.selectedUnitObj"
|
||||||
|
v-model="row.selectedUnitObj.realPrice"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
@change="reComputeTotalAmount(row, $rowIndex)"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="totalAmount" title="累计总金额">
|
<vxe-column field="totalAmount" title="累计总金额" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span v-if="row.selectedUnitObj && row.quantity">
|
{{ row?.selectedUnitObj?.totalAmount }}
|
||||||
{{ Number(row.quantity * parseFloat(row.selectedUnitObj.realPrice || 0)).toFixed(2) }}
|
<!-- <span v-if="row.selectedUnitObj && row.quantity">
|
||||||
</span>
|
{{ 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>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="remark" title="备注" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
<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)
|
const selectedUnitObj = item.erpUnitVos.find((unit: any) => unit.id === item.unitId)
|
||||||
return {
|
return {
|
||||||
...item,
|
...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]
|
// if (index !== -1) return state.erpSpuItemsMemo[index]
|
||||||
return {
|
return {
|
||||||
...addItem,
|
...addItem,
|
||||||
erpUnitVos: addItem.erpUnitVos.map((item: any) => ({ ...item, realPrice: displayPrice(item.purchasePrice, "") })),
|
erpUnitVos: addItem.erpUnitVos.map((item: any) => ({ ...item, realPrice: Number(displayPrice(item.purchasePrice, "")) })),
|
||||||
selectedUnitObj: addItem.erpUnitVos[0],
|
selectedUnitObj: {
|
||||||
|
...addItem.erpUnitVos[0],
|
||||||
|
realPrice: parseFloat(displayPrice(addItem.erpUnitVos[0].purchasePrice, "")),
|
||||||
|
totalAmount: 1 * parseFloat(displayPrice(addItem.erpUnitVos[0].purchasePrice, "")),
|
||||||
|
},
|
||||||
unitId: addItem.erpUnitVos[0].id,
|
unitId: addItem.erpUnitVos[0].id,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
isNew: true,
|
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数据
|
// 整理table数据
|
||||||
const settledTableItems = computed(() => {
|
const settledTableItems = computed(() => {
|
||||||
return vxeTableData.value.map((item: any) => {
|
return vxeTableData.value.map((item: any) => {
|
||||||
@@ -357,7 +390,7 @@ const settledTableItems = computed(() => {
|
|||||||
quantity: item.quantity,
|
quantity: item.quantity,
|
||||||
unitPrice: selectedUnitObj.purchasePrice ? Number(selectedUnitObj?.purchasePrice) : 0,
|
unitPrice: selectedUnitObj.purchasePrice ? Number(selectedUnitObj?.purchasePrice) : 0,
|
||||||
realPrice: selectedUnitObj.realPrice ? storePrice(selectedUnitObj?.realPrice) : 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,
|
remark: item.remark,
|
||||||
unitId: selectedUnitObj.id,
|
unitId: selectedUnitObj.id,
|
||||||
orderType: baseDataForm.orderType,
|
orderType: baseDataForm.orderType,
|
||||||
|
|||||||
Reference in new issue
Block a user