// 会员账户管理 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, Col, Drawer, message, Modal, Row, 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, handleGetMEMBERGROWTHList, handleGetMEMBERSHIPList, handleGetPOINTRECORDList } from "../service"; import session from "@/utils/session"; import moment from 'moment' import Draggable from "react-draggable"; import ProForm, { ProFormSelect, ProFormText, ProFormTextArea } from "@ant-design/pro-form"; import './style.less' import memberInfoIcon from '@/assets/detail/memberInfoIcon.png' import closeIcon from '@/assets/detail/closeIcon.png' import memberDetailIcon from '@/assets/detail/memberDetailIcon.png' const memberInfor: React.FC<{ currentUser: CurrentUser }> = (props) => { const { currentUser } = props const downloadBtnRef = useRef() const draggleRef = React.createRef() const actionRef = useRef(); const formRef = useRef(); const modalRef = useRef(); const [reqDetailList, setReqDetailList] = useState(); // 合计项数据源 const [printOut, setPrintOut] = useState(); // 打印数据的内容 const [collapsible, setCollapsible] = useState(false) const [treeView, setTreeView] = useState() const [printIndex, setPrintIndex] = useState(new Date().getTime()) let MEMBERSHIP_TYPEObj = session.get('MEMBERSHIP_TYPEObj'); let MEMBERSHIP_LEVELObj = session.get('MEMBERSHIP_LEVELObj'); let MEMBERSHIP_LEVELList = session.get('MEMBERSHIP_LEVELList'); let COMPANY_STATEObj = session.get('COMPANY_STATEObj'); let COMPANY_STATEList = session.get('COMPANY_STATEList'); let CONSUMPTIONRECORDTYPEObj = session.get('CONSUMPTIONRECORDTYPEObj') // 树相关的属性和方法 const [selectedId, setSelectedId] = useState() // 导出的加载效果 const [showLoading, setShowLoading] = useState(false) // 是否显示打印的表格 const [showExportTable, setShowExportTable] = useState(false) // 查询的条件 const [searchParams, setSearchParams] = useState() // 表格数据 const [tableData, setTableData] = useState() // 表格的加载效果 const [tableLoading, setTableLoading] = useState(false) // 显示详情抽屉 const [showDetailDrawer, setShowDetailDrawer] = useState(false) // 当前行数据 const [currentRow, setCurrentRow] = useState() // 弹出框拖动效果 const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置 const [disabled, setDraggleDisabled] = useState() // 是否拖动 // 当前选中在详情里面要查看的内容 const [selectTab, setSelectTab] = useState(1) const [columnsStateMap, setColumnsStateMap] = useState({ MEMBERSHIP_CODE: { show: false }, MEMBERSHIP_CARD: { show: false }, MEMBERSHIP_ADDRESS: { show: false }, PLUS_EXPIRYDATE: { show: false }, RECOMMEND_NAME: { show: false }, ADDTIME: { show: false }, MEMBERSHIP_DESC: { show: false }, }); const onDraggaleStart = (event, uiData) => { const { clientWidth, clientHeight } = window.document.documentElement; const targetRect = draggleRef.current?.getBoundingClientRect(); if (!targetRect) { return; } setBounds({ left: -targetRect.left + uiData.x, right: clientWidth - (targetRect.right - uiData.x), top: -targetRect.top + uiData.y, bottom: clientHeight - (targetRect.bottom - uiData.y), }); }; const columns: any = [ { title: "查询内容", width: 200, dataIndex: "MEMBERSHIP_NAME", ellipsis: true, align: 'center', fixed: 'left', // render: (_, record) => { // return { // console.log('recordrecord', record); // setCurrentRow(record) // setShowDetailDrawer(true) // }}> // {record?.MEMBERSHIP_NAME || ""} // // } fieldProps: { placeholder: "请输入要查询的内容" } }, { title: "会员类型", width: 120, dataIndex: "MEMBERSHIP_TYPE", ellipsis: true, hideInTable: true, align: 'center', valueType: 'select', valueEnum: { ...MEMBERSHIP_TYPEObj, 0: '全部' }, initialValue: "0" }, { title: "会员类型", width: 120, dataIndex: "MEMBERSHIP_TYPE", ellipsis: true, hideInSearch: true, align: 'center', valueType: 'select', valueEnum: { ...MEMBERSHIP_TYPEObj, 0: '-' }, }, { title: "会员编码", width: 120, dataIndex: "MEMBERSHIP_CODE", hideInSearch: true, ellipsis: true, align: 'center', }, { title: "会员性别", width: 120, dataIndex: "MEMBERSHIP_SEX", hideInSearch: true, ellipsis: true, align: 'center', valueType: 'select', valueEnum: { 1: '男', 2: '女', 0: '-' } }, { title: "会员生日", width: 150, dataIndex: "MEMBERSHIP_BIRTHDAY", hideInSearch: true, ellipsis: true, align: 'center', render: (_, record) => { return record?.MEMBERSHIP_BIRTHDAY ? moment(record?.MEMBERSHIP_BIRTHDAY).format('YYYY-MM-DD') : '-' } }, { title: "联系电话", width: 120, dataIndex: "MEMBERSHIP_MOBILEPHONE", hideInSearch: true, ellipsis: true, align: 'center', }, { title: "证件号码", width: 150, dataIndex: "CERTIFICATE_NUMBER", hideInSearch: true, ellipsis: true, align: 'center', }, { title: "会员卡号", width: 120, dataIndex: "MEMBERSHIP_CARD", hideInSearch: true, ellipsis: true, align: 'center', }, // { // title: "会员头像", // width: 120, // dataIndex: "MEMBERSHIP_HEADIMAGEURL", // hideInSearch: true, // ellipsis: true, // align: 'center', // render: (_, record) => { // return record?.MEMBERSHIP_HEADIMAGEURL ? { // window.open(record?.MEMBERSHIP_HEADIMAGEURL) // }}>点击查看 : "" // } // }, { title: "联系地址", width: 180, dataIndex: "MEMBERSHIP_ADDRESS", hideInSearch: true, ellipsis: true, align: 'center', }, { title: "车牌号", width: 150, dataIndex: "LICENSEPLATE_NUMBER", hideInSearch: true, ellipsis: true, align: 'center', }, { title: "会员等级", width: 120, dataIndex: "MEMBERSHIP_LEVEL", ellipsis: true, align: 'center', valueType: 'select', valueEnum: { "0": "全部", ...MEMBERSHIP_LEVELObj, "9000": "VIP会员" }, initialValue: "0" }, { title: "会员积分", width: 120, dataIndex: "MEMBERSHIP_POINT", hideInSearch: true, ellipsis: true, align: 'center', }, { title: "付费会员", width: 120, dataIndex: "ISPLUS", hideInSearch: true, ellipsis: true, align: 'center', valueType: 'select', valueEnum: { 0: "否", 1: "是" } }, { title: "付费有效期", width: 120, dataIndex: "PLUS_EXPIRYDATE", hideInSearch: true, ellipsis: true, align: 'center', }, { title: "账户余额", width: 120, dataIndex: "ACCOUNT_BALANCE", hideInSearch: true, ellipsis: true, align: 'center', }, { title: "推荐人", width: 120, dataIndex: "RECOMMEND_NAME", hideInSearch: true, ellipsis: true, align: 'center', }, { title: "会员状态", width: 120, dataIndex: "MEMBERSHIP_STATE", ellipsis: true, align: 'center', valueType: 'select', valueEnum: COMPANY_STATEObj, initialValue: "1000" }, { title: "添加时间", width: 150, dataIndex: "ADDTIME", align: 'center', hideInSearch: true, ellipsis: true, align: 'center', render: (_, record) => { return record?.ADDTIME ? moment(record?.ADDTIME).format('YYYY-MM-DD') : '-' } }, { title: "备注", width: 120, dataIndex: "MEMBERSHIP_DESC", hideInSearch: true, ellipsis: true, }, { title: "操作", width: 120, dataIndex: "options", hideInSearch: true, align: 'center', ellipsis: true, fixed: "right", render: (_, record) => { return { setCurrentRow(record) setShowDetailDrawer(true) }}>详情 } } ] const exportTable = (e) => { e.stopPropagation(); // 防止Collapse组件收起 const main = document.getElementsByClassName(`saleReportHideBox${printIndex}`)[0] const thead = main.querySelector('thead').cloneNode(true); // 深克隆DOM节点 const tbody = main.querySelector('tbody').cloneNode(true); // 深克隆DOM节点 const container = document.querySelector('#hiddenBox'); const tempTable = document.createElement('table'); tempTable.appendChild(thead); tempTable.appendChild(tbody); tempTable.setAttribute('id', 'table-to-xls-memberInfor'); // 给table添加id,值与按钮上的table字段对应 container.appendChild(tempTable); // 把创建的节点添加到页面容器中 setShowLoading(false) downloadBtnRef.current.handleDownload(); setShowExportTable(false) tempTable.remove() // 防止重复打印一个内容 } // 消费的列表 let consumptionColumns: any = [ { title: "服务区名称", width: 150, dataIndex: "SERVERPART_NAME", hideInSearch: true, ellipsis: true, align: 'center' }, { title: "门店名称", width: 150, dataIndex: "SHOPNAME", hideInSearch: true, ellipsis: true, align: 'center' }, { title: "消费类型", width: 120, dataIndex: "CONSUMPTIONRECORD_TYPE", hideInSearch: true, ellipsis: true, valueType: 'select', valueEnum: CONSUMPTIONRECORDTYPEObj, align: 'center' }, { title: "订单金额", width: 120, dataIndex: "CONSUME_AMOUNT", hideInSearch: true, valueType: 'digit', ellipsis: true, align: 'center' }, { title: "消费金额", width: 120, dataIndex: "CONSUME_PRICE", hideInSearch: true, valueType: 'digit', ellipsis: true, align: 'center' }, { title: "消费积分", width: 120, dataIndex: "CONSUME_SCORE", hideInSearch: true, valueType: 'digit', ellipsis: true, align: 'center' }, { title: "实付金额", width: 120, dataIndex: "PAY_AMOUNT", hideInSearch: true, valueType: 'digit', ellipsis: true, align: 'center' }, { title: "优惠金额", width: 150, dataIndex: "COUPON_AMOUNT", hideInSearch: true, ellipsis: true, align: 'center' }, { title: "消费时间 ", width: 150, dataIndex: "CONSUMPTIONRECORD_DATE", hideInSearch: true, align: 'center', render: (_, record) => { return record?.CONSUMPTIONRECORD_DATE ? moment(record?.CONSUMPTIONRECORD_DATE).format('YYYY-MM-DD HH:mm:ss') : '-' } }, ] // 积分的列表 let PointColumns: any = [ { title: "服务区名称", width: 150, dataIndex: "SERVERPART_NAME", hideInSearch: true, ellipsis: true, align: 'center' }, { title: "门店名称", width: 150, dataIndex: "SHOPNAME", hideInSearch: true, ellipsis: true, align: 'center' }, { title: "积分方式", width: 120, dataIndex: "POINT_TYPE", hideInSearch: true, ellipsis: true, align: 'center', valueType: 'select', valueEnum: { "1": "累计", "-1": "消耗" } }, { title: "积分来源", width: 120, dataIndex: "POINT_TYPE", hideInSearch: true, ellipsis: true, align: 'center', valueType: 'select', valueEnum: { "1000": "消费赠送", "2000": "消费抵扣", "3000": "注册赠送" } }, { 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: 120, dataIndex: "CREATE_DATE", hideInSearch: true, align: 'center', ellipsis: true, }, ] // 成长值的列表 let GrowthValueColumns: any = [ { title: "服务区名称", width: 150, dataIndex: "SERVERPART_NAME", hideInSearch: true, align: 'center', ellipsis: true, }, { title: "门店名称", width: 150, dataIndex: "SHOPNAME", hideInSearch: true, align: 'center', ellipsis: true, }, { title: "累计成长值", width: 120, dataIndex: "MEMBERSHIP_GROWTH", hideInSearch: true, ellipsis: true, align: 'center', valueType: 'digit' }, { title: "本次成长值", width: 120, dataIndex: "CURRENT_GROWTH", hideInSearch: true, ellipsis: true, align: 'center', valueType: 'digit' }, { title: "成长来源", width: 120, dataIndex: "GROWTH_VALUE", hideInSearch: true, ellipsis: true, align: 'center', valueType: 'select', valueEnum: { "1000": "消费赠送", "2000": "消费抵扣", "3000": "注册赠送", } }, { title: "成长方式", width: 120, dataIndex: "GROWTH_TYPE", hideInSearch: true, align: 'center', ellipsis: true, valueType: 'select', valueEnum: { "1": "积累", "-1": "消耗", } }, { title: "操作时间", width: 120, dataIndex: "OPERATE_DATE", align: 'center', hideInSearch: true, render: (_, record) => { return record?.OPERATE_DATE ? moment(record?.OPERATE_DATE).format('YYYY-MM-DD') : "-" } }, ] // 悬浮框的关闭方法 const handleCloseModal = () => { setShowDetailDrawer(false) setCurrentRow(undefined); } return (
{ // 打印报表 if (!reqDetailList || reqDetailList.length === 0) return; setPrintOut(el); }} > { showLoading ?
数据导出中...
: '' }
{ showExportTable && reqDetailList && reqDetailList.length > 0 ? : '' }
} search={{ span: 6 }} request={async (params) => { console.log('paramsparamsparams', params); const req: any = { SearchParameter: { PROVINCE_CODE: currentUser?.ProvinceCode || "", OWNERUNIT_ID: 911, MEMBERSHIP_TYPE: params?.MEMBERSHIP_TYPE === "0" ? "" : params?.MEMBERSHIP_TYPE, MEMBERSHIP_LEVEL: params?.MEMBERSHIP_LEVEL === "0" ? "" : params?.MEMBERSHIP_LEVEL, MEMBERSHIP_STATE: params?.MEMBERSHIP_STATE }, keyWord: { Key: "MEMBERSHIP_NAME,MEMBERSHIP_MOBILEPHONE,CERTIFICATE_NUMBER,MEMBERSHIP_CARD,MEMBERSHIP_ADDRESS,LICENSEPLATE_NUMBER", value: params?.MEMBERSHIP_NAME || "" }, PageIndex: params.current || 1, PageSize: 20, } setSearchParams(params) const data = await handleGetMEMBERSHIPList(req) console.log('datadatadatadatadata', data); if (data.List && data.List.length > 0) { return { data: data.List, success: true, total: data.TotalCount } } return { data: [], success: true } // const allReq: any = { // SearchParameter: { // PROVINCE_CODE: currentUser?.ProvinceCode || "" // }, // PageIndex: 1, // PageSize: 99999 // } // const allData = await handleGetMEMBERSHIPList(allReq) // setTableData(allData) }} toolbar={{ actions: [] }} pagination={{ defaultPageSize: 20, showTotal: (total) => `共 ${total} 条记录` }} columnsState={{ value: columnsStateMap, onChange: setColumnsStateMap, }} />
{ // if (disabled) { // setDraggleDisabled(false) // } // }} // onMouseOut={() => { // setDraggleDisabled(true) // }} // onFocus={() => { }} // onBlur={() => { }} // > // {'会员详情'} //
// } closeIcon={
} destroyOnClose={true} width={1200} visible={showDetailDrawer} footer={false} afterClose={() => { modalRef.current?.resetFields(); setCurrentRow(undefined); }} onCancel={() => { setShowDetailDrawer(false) setCurrentRow(undefined); }} modalRender={(modal) => { return onDraggaleStart(event, uiData)} handle=".modal-drag-title" >
{modal}
}} >
会员详情
{ handleCloseModal() }} />
{currentRow?.MEMBERSHIP_NAME || "-"} {currentRow?.MEMBERSHIP_SEX === 1 ? '男' : currentRow?.MEMBERSHIP_SEX === 2 ? '女' : ''} { currentRow?.MEMBERSHIP_TYPE && MEMBERSHIP_TYPEObj && MEMBERSHIP_TYPEObj[currentRow?.MEMBERSHIP_TYPE] ? {MEMBERSHIP_TYPEObj[currentRow?.MEMBERSHIP_TYPE]} : "" }
{ setSelectTab(1) }}>详情信息 { setSelectTab(2) }}>消费记录 { setSelectTab(3) }}>积分记录 { setSelectTab(4) }}>成长值记录
{ selectTab === 2 ? 消费记录} search={false} options={false} bordered columns={consumptionColumns} scroll={{ x: '100%', y: '350px' }} request={async (params: any) => { const req: any = { SearchParameter: { MEMBERSHIP_IDS: currentRow?.MEMBERSHIP_ID, PROVINCE_CODE: currentUser?.ProvinceCode || "", OWNERUNIT_ID: 911 }, PageIndex: params.current, PageSize: 20, SortStr: "CONSUMPTIONRECORD_DATE desc" } const data = await handleGetCONSUMPTIONRECORDList(req) if (data.List && data.List.length > 0) { return { data: data.List, success: true, total: data.TotalCount } } return { data: [], success: true } }} /> : "" } { selectTab === 3 ? 积分记录} search={false} options={false} bordered scroll={{ x: '100%', y: '350px' }} columns={PointColumns} request={async (params: any) => { const req: any = { SearchParameter: { MEMBERSHIP_IDS: currentRow?.MEMBERSHIP_ID, PROVINCE_CODE: currentUser?.ProvinceCode || "", OWNERUNIT_ID: 911 }, PageIndex: params.current, PageSize: 20, SortStr: "OPERATE_DATE desc" } const data = await handleGetPOINTRECORDList(req) console.log('22222', data); if (data.List && data.List.length > 0) { return { data: data.List, success: true, total: data.TotalCount } } return { data: [], success: true } }} /> : "" } { selectTab === 4 ? 成长值记录} search={false} options={false} bordered scroll={{ x: '100%', y: '350px' }} columns={GrowthValueColumns} request={async (params: any) => { const req: any = { SearchParameter: { MEMBERSHIP_IDS: currentRow?.MEMBERSHIP_ID, PROVINCE_CODE: currentUser?.ProvinceCode || "", OWNERUNIT_ID: 911 }, PageIndex: params.current, PageSize: 20, SortStr: "OPERATE_DATE desc" } const data = await handleGetMEMBERGROWTHList(req) console.log('33333', data); if (data.List && data.List.length > 0) { return { data: data.List, success: true, total: data.TotalCount } } return { data: [], success: true } }} /> : '' }
{/* { setShowDetailDrawer(false); setCurrentRow(null) }} title={`${MEMBERSHIP_LEVELObj ? MEMBERSHIP_LEVELObj[currentRow?.MEMBERSHIP_LEVEL] ? MEMBERSHIP_LEVELObj[currentRow?.MEMBERSHIP_LEVEL] : "" : ''}${currentRow?.MEMBERSHIP_NAME}`} bodyStyle={{ padding: 0 }} footer={
} > 消费记录} search={false} options={false} bordered columns={consumptionColumns} scroll={{ x: '100%', y: '450px' }} request={async () => { const req: any = { SearchParameter: { MEMBERSHIP_IDS: currentRow?.MEMBERSHIP_ID, PROVINCE_CODE: currentUser?.ProvinceCode || "", OWNERUNIT_ID: 911 }, PageIndex: 1, PageSize: 20 } const data = await handleGetCONSUMPTIONRECORDList(req) console.log('11111', data); if (data.List && data.List.length > 0) { return { data: data.List, success: true, total: data.TotalCount } } return { data: [], success: true } }} /> 积分记录} search={false} options={false} bordered scroll={{ x: '100%', y: '450px' }} columns={PointColumns} request={async () => { const req: any = { SearchParameter: { MEMBERSHIP_IDS: currentRow?.MEMBERSHIP_ID, PROVINCE_CODE: currentUser?.ProvinceCode || "", OWNERUNIT_ID: 911 }, PageIndex: 1, PageSize: 20 } const data = await handleGetPOINTRECORDList(req) console.log('22222', data); if (data.List && data.List.length > 0) { return { data: data.List, success: true, total: data.TotalCount } } return { data: [], success: true } }} /> 成长值记录} search={false} options={false} bordered scroll={{ x: '100%', y: '450px' }} columns={GrowthValueColumns} request={async () => { const req: any = { SearchParameter: { MEMBERSHIP_IDS: currentRow?.MEMBERSHIP_ID, PROVINCE_CODE: currentUser?.ProvinceCode || "", OWNERUNIT_ID: 911 }, PageIndex: 1, PageSize: 20 } const data = await handleGetMEMBERGROWTHList(req) console.log('33333', data); if (data.List && data.List.length > 0) { return { data: data.List, success: true, total: data.TotalCount } } return { data: [], success: true } }} />
*/}
) } export default connect(({ user }: ConnectState) => ({ currentUser: user.currentUser }))(memberInfor);