This commit is contained in:
ctw committed 2025-01-22 15:44:27 +08:00
commit 5f2f63b5eb
5 files changed
+302 -13

No files matched your search

+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("/hard/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="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="'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("/hard/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>