ylj20011123 b3eba7b8bd update
2025-07-14 19:31:26 +08:00

202 lines
7.1 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 { handleGetCONSUMPTIONRECORDList, handleGetPOINTRECORDList } from "../service";
import PageTitleBox from "@/components/PageTitleBox";
import moment from 'moment'
import session from "@/utils/session";
const PointsRecordSearch: React.FC<{ currentUser: CurrentUser }> = (props) => {
const { currentUser } = 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())
let POINTTYPEObj = session.get('POINTTYPEObj')
let SCORETYPETree = session.get('SCORETYPETree')
// 树相关的属性和方法
const [selectedId, setSelectedId] = useState<string>()
// 导出的加载效果
const [showLoading, setShowLoading] = useState<boolean>(false)
// 是否显示打印的表格
const [showExportTable, setShowExportTable] = useState<boolean>(false)
// 查询的条件
const [searchParams, setSearchParams] = useState<any>()
const columns: any = [
{
title: '查询时间',
dataIndex: 'search_date',
valueType: 'dateRange',
hideInTable: true,
hideInDescriptions: true,
search: {
transform: (value) => {
return {
OPERATE_DATE_Start: value[0],
OPERATE_DATE_End: value[1],
};
},
},
initialValue: [moment().subtract(1, 'M').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')],
},
{
title: "服务区名称",
width: 150,
dataIndex: "SERVERPART_NAME",
hideInSearch: true,
align: 'center',
ellipsis: true,
},
{
title: "门店名称",
width: 150,
dataIndex: "SHOPNAME",
hideInSearch: true,
ellipsis: true,
align: 'center',
},
{
title: "积分方式",
width: 120,
dataIndex: "POINT_TYPE",
ellipsis: true,
valueType: 'select',
align: 'center',
valueEnum: {
"-2": "全部",
"1": "累计",
"-1": "消耗"
},
initialValue: "-2"
},
{
title: "积分来源",
width: 120,
dataIndex: "POINT_SOURCE",
ellipsis: true,
valueType: 'treeSelect',
align: 'center',
request: () => {
return SCORETYPETree
}
// valueEnum: {
// "0": "全部",
// "1000": "消费赠送",
// "2000": "消费抵扣",
// "3000": "注册赠送"
// },
// initialValue: "0"
},
{
title: "本次积分",
width: 120,
dataIndex: "CURRENT_POINT",
hideInSearch: true,
ellipsis: true,
align: 'center',
valueType: "digit"
},
{
title: "累计积分",
width: 120,
dataIndex: "MEMBERSHIP_POINT",
hideInSearch: true,
ellipsis: true,
align: 'center',
valueType: "digit"
},
{
title: "获取时间",
width: 150,
dataIndex: "CREATE_DATE",
hideInSearch: true,
align: 'center',
ellipsis: true,
render: (_, record) => {
return record?.CREATE_DATE ? moment(record?.CREATE_DATE).format('YYYY-MM-DD') : "-"
}
},
]
return (
<div ref={(el) => {
// 打印报表
if (!reqDetailList || reqDetailList.length === 0) return;
setPrintOut(el);
}} >
<div style={{ backgroundColor: '#fff', display: 'flex' }}>
<div style={{
width: '100%',
paddingTop: 0,
paddingBottom: 0,
paddingRight: 0
}}>
<ProTable
actionRef={actionRef}
formRef={formRef}
columns={columns}
bordered
expandable={{
expandRowByClick: true
}}
headerTitle={<PageTitleBox props={props} />}
search={{ span: 6 }}
request={async (params) => {
const req: any = {
SearchParameter: {
// PROVINCE_CODE: currentUser?.ProvinceCode || "",
OPERATE_DATE_Start: params?.OPERATE_DATE_Start || "",
OPERATE_DATE_End: params?.OPERATE_DATE_End || "",
OWNERUNIT_ID: 911,
POINT_TYPE: params?.POINT_TYPE === '-2' ? '' : params?.POINT_TYPE,
POINT_SOURCE: params?.POINT_SOURCE === '0' ? '' : params?.POINT_SOURCE
},
PageIndex: params?.current,
PageSize: 20,
sortstr: "OPERATE_DATE desc",
}
const data = await handleGetPOINTRECORDList(req)
if (data.List && data.List.length > 0) {
return { data: data.List, success: true, total: data.TotalCount }
}
return { data: [], success: true }
}}
toolbar={{
actions: [
]
}}
/>
</div>
</div>
</div>
)
}
export default connect(({ user }: ConnectState) => ({
currentUser: user.currentUser
}))(PointsRecordSearch);