Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-01-22 12:03:53 +08:00
commit 21ee680405
5 files changed
+377 -3

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import request from "/@/utils/request"
export function pageListSb(query?: Object) {
return request({
url: "/hard/hard-total/page-list-sb",
method: "get",
params: query,
})
}
export function pageListCs(query?: Object) {
return request({
url: "/hard/hard-total/page-list-cs",
method: "get",
params: query,
})
}
@@ -62,6 +62,7 @@
import { BasicTableProps, useTable } from "/@/hooks/table"
import * as userFaceApi from "/@/api/admin/userFace"
import { useMessage } from "/@/hooks/message"
import { auth } from "/@/utils/authFunction"
// 定义刷新表格emit
const emit = defineEmits(["refresh"])
@@ -83,8 +84,15 @@ const formData = ref<any>({
})
const detailId = ref<any>(null)
onMounted(() => {
if (auth("userFace_sysUserFace_view")) {
getDataList()
}
})
// 定义表格查询、后台调用的API
const state: BasicTableProps = reactive<BasicTableProps>({
createdIsNeed: false,
queryForm: {
deptId: "",
username: "",
+88 -3
View File
@@ -44,8 +44,10 @@
:header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
show-summary
:summary-method="getSummaries"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="selection" width="60" align="center" />
<el-table-column type="index" label="#" width="50" />
<el-table-column width="200" label="用户">
<template #default="{ row }">
@@ -118,7 +120,7 @@
</div>
</template>
</el-table-column>
<el-table-column width="200px" label="付款信息">
<el-table-column width="200px" prop="paymentInformation" label="付款信息">
<template #default="{ row }">
<div class="status">
<span>商品总价</span>
@@ -236,7 +238,8 @@ import { getDicts } from "/@/api/admin/dict"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
import { displayPrice } from "/@/utils/formatMoney"
import { ElLoading } from "element-plus"
import { ElLoading, TableColumnCtx } from "element-plus"
import { VNode } from "vue"
const { push } = useRouter()
@@ -342,6 +345,88 @@ const handleDelete = async (ids: string[]) => {
useMessage().error(err.msg)
}
}
interface SummaryMethodProps<T = any> {
columns: TableColumnCtx<T>[]
data: T[]
}
// 表格行尾合计
const getSummaries = (param: SummaryMethodProps) => {
const { columns, data } = param
const sums: (string | VNode | number)[] = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = "合计"
return
}
if (column.property === "paymentInformation") {
const totalPriceValues = data.map((item) => Number(item.totalPrice))
const extraPriceValues = data.map((item) => Number(item.extraPrice))
const payPriceValues = data.map((item) => Number(item.payPrice))
if (
!totalPriceValues.every((value) => Number.isNaN(value)) &&
!extraPriceValues.every((value) => Number.isNaN(value)) &&
!payPriceValues.every((value) => Number.isNaN(value))
) {
// h("div", { style: { textDecoration: "underline" } }, ["Total Cost"])
sums[index] = h("div", { style: {} }, [
h("div", {}, [
h("span", { style: { marginRight: "40px", fontWeight: "bold" } }, ["商品总价"]),
h("span", { style: { color: "#67C260" } }, [
`${displayPrice(
totalPriceValues.reduce((prev, curr) => {
const value = Number(curr)
if (!Number.isNaN(value)) {
return prev + curr
} else {
return prev
}
}, 0),
)}`,
]),
]),
h("div", { style: {} }, [
h("span", { style: { marginRight: "40px", fontWeight: "bold" } }, ["额外支付"]),
h("span", { style: { color: "#F56E9B" } }, [
`${displayPrice(
extraPriceValues.reduce((prev, curr) => {
const value = Number(curr)
if (!Number.isNaN(value)) {
return prev + curr
} else {
return prev
}
}, 0),
)}`,
]),
]),
h("div", { style: {} }, [
h("span", { style: { marginRight: "40px", fontWeight: "bold" } }, ["实际支付"]),
h("span", { style: { color: "#355CF6" } }, [
`${displayPrice(
payPriceValues.reduce((prev, curr) => {
const value = Number(curr)
if (!Number.isNaN(value)) {
return prev + curr
} else {
return prev
}
}, 0),
)}`,
]),
]),
])
} else {
sums[index] = "N/A"
}
} else {
sums[index] = ""
}
})
return sums
}
</script>
<style scoped lang="scss">
+138
View File
@@ -0,0 +1,138 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row :gutter="24">
<el-col :span="5">
<el-form-item class="w100" label="创建时间" prop="payTimeList">
<el-date-picker v-model="state.queryForm.payTimeList" value-format="YYYY-MM-DD" type="daterange" />
</el-form-item>
</el-col>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">{{ $t("common.queryBtn") }}</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
</el-form-item>
</el-row>
</el-form>
<el-row>
<div class="mb8" style="width: 100%">
<right-toolbar
:search="false"
v-model:showSearch="showSearch"
:export="'hard_hardTotal_export_sb'"
@exportExcel="exportExcel"
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
></right-toolbar>
</div>
</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
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="50" />
<el-table-column label="设备" align="center">
<template #default="{ row }">
<div class="flex flex-row items-center justify-center">
<div class="mr-2">{{ row.hardName }}</div>
<dict-tag :options="hard_type" :value="row.hardType" />
</div>
</template>
</el-table-column>
<el-table-column label="商户" align="center" prop="merchantName" />
<el-table-column label="总消费金额" align="center" prop="totalPayPrice">
<template #default="{ row }">
<span class="color-success">
{{ displayPrice(row.totalPayPrice) }}
</span>
</template>
</el-table-column>
<el-table-column label="总消费次数" align="center" prop="totalPayCount">
<template #default="{ row }">
<span class="color-primary">
{{ row.totalPayCount }}
</span>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</div>
</div>
</template>
<script setup lang="ts" name="hard-sb">
import { BasicTableProps, useTable } from "/@/hooks/table"
import * as hardTotalApi from "/@/api/hard/hard-total"
import { displayPrice } from "/@/utils/formatMoney"
import { useDict } from "/@/hooks/dict"
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
// 定义查询字典
const { hard_type } = useDict("hard_type")
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: hardTotalApi.pageListSb,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } =
useTable(state)
// 导出excel
const exportExcel = () => {
downBlobFile("/wallet/hard-total/export-sb", Object.assign(state.queryForm), "设备交易记录.xlsx")
}
const getSummaries = (param: any) => {
const { columns, data } = param
const totalColumns = ["totalPayPrice", "totalPayCount"]
const totalRow = Array.from({ length: columns.length })
totalRow[2] = "合计"
columns.forEach((i: any, index: number) => {
if (totalColumns.includes(i.property)) {
const total = data
.filter((v: any) => v[i.property] != null)
.map((v: any) => 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 resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
getDataList()
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
</script>
+126
View File
@@ -0,0 +1,126 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row :gutter="24">
<el-col :span="5">
<el-form-item class="w100" label="创建时间" prop="createTimeList">
<el-date-picker v-model="state.queryForm.createTimeList" value-format="YYYY-MM-DD" type="daterange" />
</el-form-item>
</el-col>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">{{ $t("common.queryBtn") }}</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
</el-form-item>
</el-row>
</el-form>
<el-row>
<div class="mb8" style="width: 100%">
<right-toolbar
:search="false"
v-model:showSearch="showSearch"
:export="'wallet_walletTransaction_export'"
@exportExcel="exportExcel"
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
></right-toolbar>
</div>
</el-row>
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:summary-method="getSummaries"
show-summary
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="50" />
<el-table-column label="商户" align="center" prop="merchantName" />
<el-table-column label="总消费金额" align="center" prop="totalPayPrice">
<template #default="{ row }">
<span class="color-success">
{{ displayPrice(row.totalPayPrice) }}
</span>
</template>
</el-table-column>
<el-table-column label="总消费次数" align="center" prop="totalPayCount">
<template #default="{ row }">
<span class="color-primary">
{{ row.totalPayCount }}
</span>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</div>
</div>
</template>
<script setup lang="ts" name="hard-sb">
import { BasicTableProps, useTable } from "/@/hooks/table"
import { displayPrice } from "/@/utils/formatMoney"
import * as hardTotalApi from "/@/api/hard/hard-total"
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: hardTotalApi.pageListCs,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } =
useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile("/wallet/hard-total/export-cs", Object.assign(state.queryForm), "商户交易记录.xlsx")
}
const getSummaries = (param: any) => {
const { columns, data } = param
const totalColumns = ["totalPayPrice", "totalPayCount"]
const totalRow = Array.from({ length: columns.length })
totalRow[2] = "合计"
columns.forEach((i: any, index: number) => {
if (totalColumns.includes(i.property)) {
const total = data
.filter((v: any) => v[i.property] != null)
.map((v: any) => 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
}
</script>