Files
pj_admin_cloud/src/views/hard/hard-sh/index.vue
T
2025-10-23 20:43:39 +08:00

195 lines
7.2 KiB
Vue

<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" :props="{
label: 'name',
children: 'children',
value: 'id',
disabled: 'isLockNone',
}">
<template #default>
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row>
<el-form-item style="width: 200px" 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="merchantType">
<dict-select v-model="state.queryForm.merchantType" dict-code="merchant_type" />
</el-form-item>
<el-form-item style="width: 250px" label="商户" prop="merchantId">
<select-mch v-model="state.queryForm.merchantId" :apiParams="{ parentIsNull: false }" />
</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="datetimerange" />
</el-form-item>
<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="80" 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 || 0 }}
</span>
</template>
</el-table-column>
<el-table-column label="退款金额" align="center" prop="totalRefundPrice">
<template #default="{ row }">
<span class="color-danger">
{{ displayPrice(row.totalRefundPrice) }}
</span>
</template>
</el-table-column>
<el-table-column label="退款次数" align="center" prop="totalRefundCount">
<template #default="{ row }">
<span class="color-danger">
{{ row.totalRefundCount || 0 }}
</span>
</template>
</el-table-column>
<el-table-column label="消费净金额" align="center" prop="totalProfitPrice" min-width="120">
<template #default="{ row }">
<span class="color-success">
{{ displayPrice(row.totalProfitPrice) }}
</span>
</template>
</el-table-column>
<el-table-column label="消费净次数" align="center" prop="totalProfitCount" min-width="120">
<template #default="{ row }">
<span class="color-success">
{{ row.totalProfitCount || 0 }}
</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="250">
<template #default="{ row }">
<el-tooltip class="box-item" effect="dark" content="只有合作商家能结账" placement="top">
<el-button icon="Tickets" text :disabled="row.merchantType != 2" type="primary"
@click="doCheckout(row)">
商户结账
</el-button>
</el-tooltip>
<el-button icon="Tickets" type="primary" text @click="exportMchExcel(row)">
导出商户流水
</el-button>
</template>
</el-table-column>
</el-table>
</template>
</DraggableDepTree>
</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 { push } = useRouter()
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const draggableDepTreeRef = ref() // 树组件ref引用
const state: BasicTableProps = reactive<BasicTableProps>({
isPage: false,
queryForm: {},
pageList: hardTotalApi.pageListCs,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, postDownBlobFile, tableStyle } = useTable(state)
// 导出excel
const exportExcel = () => {
postDownBlobFile("/hard/hard-total/export-cs", Object.assign(state.queryForm), "商户交易记录.xlsx")
}
const doCheckout = (row: any) => {
push({ path: "/mch/mch-checkout/index", query: { mchId: row.merchantId } })
}
const exportMchExcel = (row: any) => {
postDownBlobFile("/hard/hard-total/export-mch-cs", { ...state.queryForm, merchantId: row.merchantId }, "商户流水.xlsx")
}
const getSummaries = (param: any) => {
const { columns, data } = param
const totalColumns = ["totalPayPrice", "totalPayCount", "totalRefundPrice", "totalRefundCount", "totalProfitPrice", "totalProfitCount"]
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) => v[i.property])
.reduce((pren: number, next: number) => pren + next, 0)
if (i.property.includes("Price")) {
totalRow[index] = displayPrice(total)
} else {
totalRow[index] = total
}
}
})
return totalRow
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
state.queryForm.deptId = ""
state.queryForm.userDeptIds = []
draggableDepTreeRef.value.resetData()
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()
}
</script>