391 lines
15 KiB
TypeScript
391 lines
15 KiB
TypeScript
// 消费记录查询
|
|
import { connect } from "umi";
|
|
import type { CurrentUser } from "umi";
|
|
import type { ConnectState } from "@/models/connect";
|
|
import React, { useRef, useState } from "react";
|
|
import ProCard from "@ant-design/pro-card";
|
|
import { MenuFoldOutlined } from "@ant-design/icons";
|
|
import type { FormInstance } from "antd";
|
|
import { Button, message, Space, Spin, Tree } from "antd";
|
|
import useRequest from "@ahooksjs/use-request";
|
|
import { getServerpartTree } from "@/services/options";
|
|
import type { ActionType } from "@ant-design/pro-table";
|
|
import ProTable from "@ant-design/pro-table";
|
|
import ReactHTMLTableToExcel from "react-html-table-to-excel";
|
|
import LeftSelectTree from "@/pages/reports/settlementAccount/component/leftSelectTree";
|
|
import PageTitleBox from "@/components/PageTitleBox";
|
|
import { handleGetCONSUMPTIONRECORDList } from "../service";
|
|
import moment from 'moment'
|
|
import session from "@/utils/session";
|
|
import OrderDetailModal from "../BookingMealOrder/components/orderDetailModal";
|
|
import { handleSetlogSave } from "@/utils/format";
|
|
import MemberDetail from "../memberInfor/component/memberDetail";
|
|
|
|
|
|
const ConsumptionRecordSearch: React.FC<{ currentUser: CurrentUser, isComponent?: boolean, parentDetail?: any }> = (props) => {
|
|
const { currentUser, isComponent, parentDetail } = props
|
|
const downloadBtnRef = useRef<any>()
|
|
const actionRef = useRef<ActionType>();
|
|
const formRef = useRef<FormInstance>();
|
|
const [reqDetailList, setReqDetailList] = useState<any>(); // 合计项数据源
|
|
const [printOut, setPrintOut] = useState<any>(); // 打印数据的内容
|
|
const [collapsible, setCollapsible] = useState<boolean>(false)
|
|
const [treeView, setTreeView] = useState<any>()
|
|
const [printIndex, setPrintIndex] = useState<number>(new Date().getTime())
|
|
// 显示订单详情的悬浮框
|
|
const [showOrderModal, setShowOrderModal] = useState<boolean>(false)
|
|
const [currentRow, setCurrentRow] = useState<any>()
|
|
|
|
let MEMBERSHIPTYPEYNObj = session.get('MEMBERSHIPTYPEYNObj');
|
|
let CONSUMPTIONRECORDTYPEObj = session.get('CONSUMPTIONRECORDTYPEObj')
|
|
let MEMBERSHIPLEVELYNObj = session.get('MEMBERSHIPLEVELYNObj')
|
|
|
|
// 树相关的属性和方法
|
|
const [selectedId, setSelectedId] = useState<string>()
|
|
// 导出的加载效果
|
|
const [showLoading, setShowLoading] = useState<boolean>(false)
|
|
// 是否显示打印的表格
|
|
const [showExportTable, setShowExportTable] = useState<boolean>(false)
|
|
// 查询的条件
|
|
const [searchParams, setSearchParams] = useState<any>()
|
|
// 显示详情抽屉
|
|
const [showDetailDrawer, setShowDetailDrawer] = useState<boolean>(false)
|
|
|
|
const columns: any = [
|
|
{
|
|
title: '查询内容',
|
|
dataIndex: 'searchText',
|
|
hideInTable: true,
|
|
fieldProps: {
|
|
placeholder: '请输入用户昵称/手机号码/订单编号'
|
|
}
|
|
},
|
|
{
|
|
title: '查询时间',
|
|
dataIndex: 'search_date',
|
|
valueType: 'dateRange',
|
|
hideInTable: true,
|
|
hideInDescriptions: true,
|
|
search: {
|
|
transform: (value) => {
|
|
return {
|
|
CONSUMPTIONRECORD_DATE_Start: value[0],
|
|
CONSUMPTIONRECORD_DATE_End: value[1],
|
|
};
|
|
},
|
|
},
|
|
fieldProps: {
|
|
ranges: {
|
|
"本月": [moment().startOf('M'), moment()],
|
|
"上月": [moment().subtract(1, 'M').startOf('M'), moment().subtract(1, 'M').endOf('M')],
|
|
"近三月": [moment().subtract(3, 'M').startOf('M'), moment().endOf('M')],
|
|
"近半年": [moment().subtract(6, 'M').startOf('M'), moment().endOf('M')],
|
|
}
|
|
},
|
|
// initialValue: [moment().subtract(1, 'M').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')],
|
|
initialValue: [moment().startOf('M'), moment()],
|
|
},
|
|
// {
|
|
// title: "服务区名称",
|
|
// width: 150,
|
|
// dataIndex: "SERVERPART_NAME",
|
|
// hideInSearch: true,
|
|
// align: 'center',
|
|
// ellipsis: true,
|
|
// },
|
|
{
|
|
title: "用户昵称",
|
|
width: 150,
|
|
dataIndex: "MEMBERSHIP_NAME",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
render: (_, record) => {
|
|
return isComponent ? record?.MEMBERSHIP_NAME || "" : record?.MEMBERSHIP_NAME ? <a onClick={() => {
|
|
setCurrentRow(record)
|
|
setShowDetailDrawer(true)
|
|
handleSetlogSave(`查看${record?.MEMBERSHIP_NAME}【${record?.MEMBERSHIP_ID}】会员信息`)
|
|
}}>
|
|
{record?.MEMBERSHIP_NAME}
|
|
</a> : "-"
|
|
}
|
|
},
|
|
{
|
|
title: "手机号码",
|
|
width: 150,
|
|
dataIndex: "MEMBERSHIP_MOBILEPHONE",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "会员等级",
|
|
width: 150,
|
|
dataIndex: "MEMBERSHIP_LEVEL",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
valueType: 'select',
|
|
valueEnum: MEMBERSHIPLEVELYNObj
|
|
},
|
|
{
|
|
title: "会员类型",
|
|
width: 120,
|
|
dataIndex: "MEMBERSHIP_TYPE",
|
|
ellipsis: true,
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
valueType: 'select',
|
|
valueEnum: {
|
|
...MEMBERSHIPTYPEYNObj,
|
|
},
|
|
},
|
|
{
|
|
title: "订单编号",
|
|
width: 200,
|
|
dataIndex: "TICKET_CODE",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
render: (_, record) => {
|
|
return record?.TICKET_CODE ? <a onClick={() => {
|
|
setCurrentRow(record)
|
|
setShowOrderModal(true)
|
|
}}>{record?.TICKET_CODE}</a> : "-"
|
|
}
|
|
},
|
|
{
|
|
title: "消费时间",
|
|
width: 150,
|
|
align: 'center',
|
|
dataIndex: "CONSUMPTIONRECORD_DATE",
|
|
hideInSearch: true,
|
|
render: (_, record) => {
|
|
return record?.CONSUMPTIONRECORD_DATE ? moment(record?.CONSUMPTIONRECORD_DATE).format('YYYY-MM-DD HH:mm:ss') : '-'
|
|
}
|
|
},
|
|
{
|
|
title: "消费类型",
|
|
width: 120,
|
|
dataIndex: "CONSUMPTIONRECORD_TYPE",
|
|
align: 'center',
|
|
ellipsis: true,
|
|
valueType: 'select',
|
|
valueEnum: {
|
|
"0": "全部",
|
|
...CONSUMPTIONRECORDTYPEObj
|
|
},
|
|
initialValue: "0"
|
|
},
|
|
{
|
|
title: "订单状态",
|
|
width: 120,
|
|
dataIndex: "CONSUMPTIONRECORD_STATE",
|
|
align: 'center',
|
|
ellipsis: true,
|
|
valueType: 'select',
|
|
valueEnum: {
|
|
"1005": "订单待支付",
|
|
"1010": "订单待发货",
|
|
"2000": "订单待取餐",
|
|
"3000": "订单已完成",
|
|
"8000": "退款申请中",
|
|
"8900": "订单已退款",
|
|
"9000": "订单已关闭",
|
|
"9999": "订单已撤销",
|
|
},
|
|
},
|
|
{
|
|
title: "获得积分",
|
|
width: 120,
|
|
dataIndex: "CURRENT_SCORE",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "获得成长值",
|
|
width: 120,
|
|
dataIndex: "MEMBERGROWTH_VALUE",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "订单金额",
|
|
width: 120,
|
|
dataIndex: "CONSUME_AMOUNT",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
valueType: 'digit',
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "消费金额",
|
|
width: 120,
|
|
dataIndex: "CONSUME_PRICE",
|
|
hideInSearch: true,
|
|
valueType: 'digit',
|
|
align: 'center',
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "消费积分",
|
|
width: 120,
|
|
dataIndex: "CONSUME_SCORE",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
valueType: 'digit',
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "实付金额",
|
|
width: 120,
|
|
dataIndex: "PAY_AMOUNT",
|
|
hideInSearch: true,
|
|
valueType: 'digit',
|
|
align: 'center',
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "优惠金额",
|
|
width: 120,
|
|
dataIndex: "COUPON_AMOUNT",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
},
|
|
|
|
{
|
|
title: "服务区名称",
|
|
width: 150,
|
|
dataIndex: "SERVERPART_NAME",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "门店名称",
|
|
width: 150,
|
|
dataIndex: "SHOPNAME",
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
},
|
|
]
|
|
const handleCloseModal = () => {
|
|
setShowOrderModal(false)
|
|
setCurrentRow(null)
|
|
setShowDetailDrawer(false)
|
|
}
|
|
|
|
return (
|
|
<div ref={(el) => {
|
|
// 打印报表
|
|
if (!reqDetailList || reqDetailList.length === 0) return;
|
|
setPrintOut(el);
|
|
}} >
|
|
|
|
<div style={{ backgroundColor: '#fff', display: 'flex' }}>
|
|
|
|
{
|
|
isComponent ? '' : <LeftSelectTree setSelectedId={setSelectedId} setCollapsible={setCollapsible} collapsible={collapsible} showYN={true} />
|
|
}
|
|
|
|
<div style={{
|
|
width: isComponent ? '100%' : !collapsible ? 'calc(100% - 300px)' : 'calc(100% - 60px)',
|
|
paddingTop: 0,
|
|
paddingBottom: 0,
|
|
paddingRight: 0
|
|
}}>
|
|
<ProTable
|
|
actionRef={actionRef}
|
|
formRef={formRef}
|
|
columns={columns}
|
|
bordered
|
|
expandable={{
|
|
expandRowByClick: true
|
|
}}
|
|
headerTitle={<PageTitleBox props={props} />}
|
|
scroll={{ x: '100%', y: isComponent ? '300px' : 'calc(100vh - 430px)' }}
|
|
search={isComponent ? false : { span: 6 }}
|
|
options={isComponent ? false : {
|
|
density: true,
|
|
reload: true,
|
|
setting: true
|
|
}}
|
|
request={async (params) => {
|
|
let req: any = {}
|
|
|
|
if (isComponent) {
|
|
req = {
|
|
SearchParameter: {
|
|
PROVINCE_CODE: currentUser?.ProvinceCode || "",
|
|
OWNERUNIT_ID: 911,
|
|
MEMBERSHIP_ID: parentDetail?.MEMBERSHIP_ID,
|
|
CONSUMPTIONRECORD_STATES: '1010,2000,2010,3000,8000,8010,8020,8900,8999'
|
|
},
|
|
PageIndex: params?.current,
|
|
PageSize: params?.pageSize,
|
|
sortStr: "CONSUMPTIONRECORD_DATE desc"
|
|
}
|
|
} else {
|
|
if (!selectedId) {
|
|
return
|
|
}
|
|
req = {
|
|
SearchParameter: {
|
|
SERVERPART_IDS: selectedId,
|
|
PROVINCE_CODE: currentUser?.ProvinceCode || "",
|
|
OWNERUNIT_ID: 911,
|
|
CONSUMPTIONRECORD_DATE_Start: params?.CONSUMPTIONRECORD_DATE_Start || "",
|
|
CONSUMPTIONRECORD_DATE_End: params?.CONSUMPTIONRECORD_DATE_End || "",
|
|
CONSUMPTIONRECORD_TYPE: params?.CONSUMPTIONRECORD_TYPE === '0' ? '' : params?.CONSUMPTIONRECORD_TYPE,
|
|
CONSUMPTIONRECORD_STATES: '1010,2000,2010,3000,8000,8010,8020,8900,8999'
|
|
},
|
|
PageIndex: params?.current,
|
|
PageSize: params?.pageSize,
|
|
keyWord: {
|
|
Key: "MEMBERSHIP_NAME,MEMBERSHIP_MOBILEPHONE,TICKET_CODE",
|
|
Value: params?.searchText || ""
|
|
},
|
|
sortStr: "CONSUMPTIONRECORD_DATE desc"
|
|
}
|
|
}
|
|
|
|
const data = await handleGetCONSUMPTIONRECORDList(req)
|
|
handleSetlogSave(`点击查询按钮`)
|
|
if (data.List && data.List.length > 0) {
|
|
return { data: data.List, success: true, total: data.TotalCount }
|
|
}
|
|
return { data: [], success: true }
|
|
}}
|
|
toolbar={{
|
|
actions: [
|
|
|
|
]
|
|
}}
|
|
pagination={{
|
|
defaultPageSize: 20,
|
|
showTotal: (total) => `共 ${total} 条记录`
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<OrderDetailModal modalVisible={showOrderModal} handleCloseModal={handleCloseModal} currentRow={currentRow} />
|
|
|
|
{/* 会员详情 */}
|
|
<MemberDetail showDetailDrawer={showDetailDrawer}
|
|
currentRow={currentRow}
|
|
handleCloseModal={handleCloseModal}
|
|
currentUser={currentUser} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default connect(({ user }: ConnectState) => ({
|
|
currentUser: user.currentUser
|
|
}))(ConsumptionRecordSearch);
|