ylj20011123 158052ef6e update
2025-07-28 19:37:31 +08:00

706 lines
30 KiB
TypeScript

// 会员详情组件
import { connect } from "umi";
import type { ConnectState } from "@/models/connect";
import { Button, Col, FormInstance, message, Modal, Row } from "antd";
import { useEffect, useRef, useState } from "react";
import Draggable from "react-draggable";
import React from "react";
import ProForm, { ProFormSelect, ProFormText, ProFormTextArea } from "@ant-design/pro-form";
import moment from 'moment';
import memberInfoIcon from '@/assets/detail/memberInfoIcon.png'
import closeIcon from '@/assets/detail/closeIcon.png'
import session from "@/utils/session";
import memberDetailIcon from '@/assets/detail/memberDetailIcon.png'
import ProTable from "@ant-design/pro-table";
import { handeDeleteMembershipRecord, handeGetMEMBERSHIPDetail, handleGetCONSUMPTIONRECORDList, handleGetMEMBERGROWTHList, handleGetPOINTRECORDList } from "../../service";
import AddressDetail from "../../MemberAddress/components/addressDetail";
import './style.less'
import ConsumptionRecordSearch from "../../ConsumptionRecordSearch";
import GrowthValueRecordSearch from "../../GrowthValueRecordSearch";
import PointsRecordSearch from "../../PointsRecordSearch";
import RegistrationRetentionAnalysis from "../../RegistrationRetentionAnalysis";
import LicensePlateManage from "./LicensePlateManage";
import MemberDiscounts from "./MemberDiscounts";
import CollectProducts from "./CollectProducts";
import MerchantEvaluationManage from "../../MerchantEvaluationManage";
import MallEvaluationManage from "../../MallEvaluationManage";
import { handleSetlogSave } from "@/utils/format";
type DetailProps = {
showDetailDrawer: boolean
currentRow: any
handleCloseModal: any
currentUser: any
}
const MemberDetail = ({ showDetailDrawer, currentRow, handleCloseModal, currentUser }: DetailProps) => {
const { confirm } = Modal;
const modalRef = useRef<FormInstance>();
const draggleRef = React.createRef<any>()
// 弹出框拖动效果
const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置
const [disabled, setDraggleDisabled] = useState<boolean>() // 是否拖动
let MEMBERSHIPTYPEYNObj = session.get('MEMBERSHIPTYPEYNObj');
let MEMBERSHIPLEVELYNObj = session.get('MEMBERSHIPLEVELYNObj');
let MEMBERSHIPLEVELYNList = session.get('MEMBERSHIPLEVELYNList');
let COMPANY_STATEList = session.get('COMPANY_STATEList');
let SCORETYPETree = session.get('SCORETYPETree')
let CONSUMPTIONRECORDTYPEObj = session.get('CONSUMPTIONRECORDTYPEObj')
// 会员详情信息
const [userDetailInfo, setUserDetailInfo] = useState<any>({})
// 当前选中在详情里面要查看的内容
const [selectTab, setSelectTab] = useState<number>(1)
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),
});
};
// 消费的列表
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_SOURCE",
hideInSearch: true,
ellipsis: true,
valueType: 'treeSelect',
align: 'center',
request: () => {
return SCORETYPETree
}
},
{
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_SOURCE",
hideInSearch: true,
ellipsis: true,
valueType: 'treeSelect',
align: 'center',
request: () => {
return SCORETYPETree
}
},
{
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') : "-"
}
},
]
useEffect(() => {
if (showDetailDrawer) {
setSelectTab(1)
}
}, [showDetailDrawer])
return (
<Modal
className="memberInfoDetailModal"
title={false}
closeIcon={<div></div>}
destroyOnClose={true}
width={1200}
visible={showDetailDrawer}
footer={false}
afterClose={() => {
modalRef.current?.resetFields();
// setCurrentRow(undefined);
}}
maskClosable={true}
bodyStyle={{
maxHeight: '850px', // 你可以根据需要调整高度
overflowY: 'auto',
}}
onCancel={() => {
setSelectTab(0)
handleCloseModal()
}}
modalRender={(modal) => {
return <Draggable
disabled={disabled}
bounds={bounds}
onStart={(event, uiData) => onDraggaleStart(event, uiData)}
handle=".modalTop"
>
<div ref={draggleRef}>{modal}</div>
</Draggable>
}}
>
<ProForm
layout={'horizontal'}
formRef={modalRef}
submitter={false}
// initialValues={currentRow ? {
// ...currentRow,
// MEMBERSHIP_BIRTHDAY: currentRow?.MEMBERSHIP_BIRTHDAY ? moment(currentRow?.MEMBERSHIP_BIRTHDAY).format('YYYY-MM-DD') : '',
// ADDTIME: currentRow?.ADDTIME ? moment(currentRow?.ADDTIME).format('YYYY-MM-DD') : '',
// } : {}}
request={async () => {
if (currentRow?.MEMBERSHIP_ID || currentRow?.USER_ID) {
const req: any = {
MEMBERSHIPId: currentRow?.MEMBERSHIP_ID || currentRow?.USER_ID
}
const data = await handeGetMEMBERSHIPDetail(req)
console.log('userDetailData', data);
let obj: any = {
...data,
OPERATE_DATE: data.OPERATE_DATE ? moment(data.OPERATE_DATE).format('YYYY-MM-DD HH:mm:ss') : '',
ADDTIME: data.ADDTIME ? moment(data.ADDTIME).format('YYYY-MM-DD HH:mm:ss') : '',
MEMBERSHIP_BIRTHDAY: currentRow?.MEMBERSHIP_BIRTHDAY ? moment(currentRow?.MEMBERSHIP_BIRTHDAY).format('YYYY-MM-DD') : '',
}
setUserDetailInfo(obj)
return obj
} else {
return {}
}
}}
>
<div className="modalTop" style={{ position: 'fixed', background: '#fff', borderTopLeftRadius: "16px", borderTopRightRadius: "16px", zIndex: 999, borderBottom: '1px solid #D5D8DE' }}>
<div className="modalTopLeft">
<img className="memberIcon" src={memberInfoIcon} />
<span className="modalTitle"></span>
</div>
<div className="modalTopRight">
<img className="memberIcon" src={closeIcon} onClick={() => {
setSelectTab(0)
handleCloseModal()
}} />
</div>
</div>
<div className="topDetail" style={{ paddingTop: '90px' }}>
<div className="topDetailLeft">
<img className="headerImage" src={userDetailInfo?.MEMBERSHIP_HEADIMAGEURL || "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132"} />
</div>
<div className="topDetailRight">
<div className="topDetailRightTop">
<span className="detailName" style={{ marginRight: '8px' }}>{userDetailInfo?.MEMBERSHIP_NAME || "-"}</span>
{/* <span className="detailSex" style={{ marginRight: '8px' }}>{userDetailInfo?.MEMBERSHIP_SEX === 0 ? '男' : userDetailInfo?.MEMBERSHIP_SEX === 1 ? '女' : ''}</span> */}
{
userDetailInfo?.MEMBERSHIP_TYPE && MEMBERSHIPTYPEYNObj && MEMBERSHIPTYPEYNObj[userDetailInfo?.MEMBERSHIP_TYPE] ?
<span className="memberType">{MEMBERSHIPTYPEYNObj[userDetailInfo?.MEMBERSHIP_TYPE]}</span> : ""
}
{
userDetailInfo?.MEMBERSHIP_LEVEL && MEMBERSHIPLEVELYNObj && MEMBERSHIPLEVELYNObj[userDetailInfo?.MEMBERSHIP_LEVEL] ?
<span className="memberType" style={{ marginLeft: '8px' }}>{MEMBERSHIPLEVELYNObj[userDetailInfo?.MEMBERSHIP_LEVEL]}</span> : ""
}
</div>
<div className="topDetailItem">
<Row gutter={8}>
<Col span={8} className="memberInfoDetailItem">
<ProFormSelect
name={"MEMBERSHIP_SEX"}
label={"性别"}
readonly
options={[{ label: "男", value: 0 }, { label: "女", value: 1 }]}
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={8} className="memberInfoDetailItem">
<ProFormText
name={"CERTIFICATE_NUMBER"}
label={"身份证号"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={8} className="memberInfoDetailItem">
<ProFormText
name={"MEMBERSHIP_MOBILEPHONE"}
label={"联系电话"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={8} className="memberInfoDetailItem">
<ProFormText
name={"PLATE_NUMBER"}
label={"车牌号"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={8} className="memberInfoDetailItem">
<ProFormText
name={"MEMBERSHIP_BIRTHDAY"}
label={"会员生日"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={8} className="memberInfoDetailItem">
<ProFormText
name={"ADDTIME"}
label={"注册时间"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
{/* <Col span={16} className="memberInfoDetailItem">
<ProFormText
name={"MEMBERSHIP_ADDRESS"}
label={"联系地址"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col> */}
</Row>
</div>
</div>
</div>
<div className="carNavBox">
<img className="carNavIcon" src={memberDetailIcon} />
<span className={selectTab === 1 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(1)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】详细信息`)
}}></span>
<span className={selectTab === 2 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(2)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】消费记录`)
}}></span>
<span className={selectTab === 3 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(3)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】成长值记录`)
}}></span>
<span className={selectTab === 4 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(4)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】积分记录`)
}}></span>
<span className={selectTab === 5 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(5)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】地址管理`)
}}></span>
<span className={selectTab === 6 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(6)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】活动轨迹`)
}}></span>
<span className={selectTab === 7 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(7)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】车牌管理`)
}}></span>
<span className={selectTab === 8 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(8)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】优惠券管理`)
}}></span>
<span className={selectTab === 9 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(9)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】收藏商品`)
}}></span>
<span className={selectTab === 10 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(10)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】商家评价`)
}}></span>
<span className={selectTab === 11 ? "carNavTitle selectCarNavTitle" : "carNavTitle"} onClick={() => {
setSelectTab(11)
handleSetlogSave(`查看【${userDetailInfo?.MEMBERSHIP_NAME}】商城评价`)
}}></span>
</div>
<div style={{ height: '400px' }}>
<div className="bottomDetailBox" style={{ display: selectTab === 1 ? 'block' : "none" }}>
<Row gutter={8}>
<Col span={6} className="memberInfoDetailItem">
<ProFormText
name={"MEMBERSHIP_CARD"}
label={"会员卡号"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={6} className="memberInfoDetailItem">
<ProFormText
name={"MEMBERSHIP_CODE"}
label={"会员编码"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={6} className="memberInfoDetailItem">
<ProFormSelect
name={"MEMBERSHIP_LEVEL"}
label={"会员等级"}
readonly
style={{ marginBottom: '16px' }}
options={[
...MEMBERSHIPLEVELYNList
]}
/>
</Col>
<Col span={6} className="memberInfoDetailItem">
<ProFormText
name={"ACCOUNT_BALANCE"}
label={"账户余额"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={6} className="memberInfoDetailItem">
<ProFormText
name={"MEMBERSHIP_POINT"}
label={"会员积分"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={6} className="memberInfoDetailItem">
<ProFormSelect
name={"MEMBERSHIP_STATE"}
label={"会员状态"}
readonly
style={{ marginBottom: '16px' }}
options={COMPANY_STATEList}
/>
</Col>
<Col span={6} className="memberInfoDetailItem">
<ProFormSelect
name={"ISPLUS"}
label={"付费会员"}
readonly
style={{ marginBottom: '16px' }}
options={[{ label: "是", value: 1 }, { label: "否", value: 0 }]}
/>
</Col>
<Col span={6} className="memberInfoDetailItem">
<ProFormText
name={"PLUS_EXPIRYDATE"}
label={"付费有效期"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
<Col span={6} className="memberInfoDetailItem">
<ProFormText
name={"RECOMMEND_NAME"}
label={"推荐人"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
{/* <Col span={18} className="memberInfoDetailItem">
<ProFormText
name={"ADDTIME"}
label={"添加时间"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col> */}
<Col span={24} className="memberInfoDetailItem">
<ProFormTextArea
name={"MEMBERSHIP_DESC"}
label={"备注说明"}
readonly
style={{ marginBottom: '16px' }}
/>
</Col>
</Row>
</div>
{/* 消费记录 */}
{
selectTab === 2 ? <ConsumptionRecordSearch isComponent={true} parentDetail={userDetailInfo} /> : ""
}
{/* 成长值记录 */}
{
selectTab === 3 ?
<GrowthValueRecordSearch isComponent={true} parentDetail={userDetailInfo} /> : ''
}
{/* 积分记录 */}
{
selectTab === 4 ?
<PointsRecordSearch isComponent={true} parentDetail={userDetailInfo} />
: ''
}
{/* 地址管理 */}
{
selectTab === 5 ? <AddressDetail currentBigRow={userDetailInfo} currentUser={currentUser} /> : ''
}
{/* 活动轨迹 */}
{
selectTab === 6 ? <RegistrationRetentionAnalysis isComponent={true} parentDetail={userDetailInfo} /> : ""
}
{/* 车牌管理 */}
{
selectTab === 7 ? <LicensePlateManage parentDetail={userDetailInfo} /> : ""
}
{/* 会员优惠券 */}
{
selectTab === 8 ? <MemberDiscounts parentDetail={userDetailInfo} /> : ""
}
{/* 会员收藏 */}
{
selectTab === 9 ? <CollectProducts parentDetail={userDetailInfo} /> : ""
}
{/* 商家评价 */}
{
selectTab === 10 ? <MerchantEvaluationManage isComponent={true} parentDetail={userDetailInfo} /> : ""
}
{/* 商城评价 */}
{
selectTab === 11 ? <MallEvaluationManage isComponent={true} parentDetail={userDetailInfo} /> : ""
}
</div>
<div style={{ width: '100%', boxSizing: 'border-box', padding: '0 24px' }}>
{
userDetailInfo?.MEMBERSHIP_TYPE === 9999 ?
<Button danger onClick={() => {
confirm({
width: 500,
content: <div>
{`删除该消费记录将清除用户的积分与成长值,且该操作无法恢复。是否确认删除?`}
</div>,
onOk: async () => {
console.log('currentRowcurrentRowcurrentRowcurrentRow', userDetailInfo);
const req: any = {
MembershipId: userDetailInfo?.MEMBERSHIP_ID
}
const data = await handeDeleteMembershipRecord(req)
if (data.Result_Code === 100) {
message.success('删除成功!')
setSelectTab(0)
handleCloseModal()
} else {
message.error(data.Result_Data)
}
}
});
}}></Button> : ""
}
</div>
</ProForm>
</Modal>
)
}
export default connect(({ user, }: ConnectState) => ({
currentUser: user.currentUser,
}))(MemberDetail);