|
|
@@ -1,4 +1,4 @@ |
|
|
|
import React, { useRef, useState } from "react"; |
|
|
|
import React, { useRef, useState, useEffect } from "react"; |
|
|
|
import styles from "./index.less"; |
|
|
|
import { PageContainer } from '@ant-design/pro-layout'; |
|
|
|
import { PlusOutlined, UserOutlined } from '@ant-design/icons'; |
|
|
@@ -13,7 +13,11 @@ import cardAPI from "../service"; |
|
|
|
const memberAccount = () => { |
|
|
|
const actionRef = useRef(); |
|
|
|
const [isModalOpen, setIsModalOpen] = useState(false); |
|
|
|
const [currentOption, setCurrentOption] = useState(); |
|
|
|
const [currentOption, setCurrentOption] = useState({ |
|
|
|
functionName: '', |
|
|
|
record: {}, |
|
|
|
type: 0 |
|
|
|
}); |
|
|
|
const [current, setCurrent] = useState(1); |
|
|
|
const [pageSize, setPageSize] = useState(10); |
|
|
|
const [total, setTotal] = useState(0); |
|
|
@@ -37,6 +41,11 @@ const memberAccount = () => { |
|
|
|
"type": type |
|
|
|
} |
|
|
|
const response = await cardAPI.GetMemberAccountCardConsRecord(jsonData); |
|
|
|
setCurrentOption({ |
|
|
|
functionName: 'onFetchAccountConsRecord', |
|
|
|
record: JSON.parse(JSON.stringify(record)), |
|
|
|
type |
|
|
|
}); |
|
|
|
if (response.statusCode === 200) { |
|
|
|
setConsList(response.data.data); |
|
|
|
setConsTotal(response.data.total); |
|
|
@@ -59,6 +68,11 @@ const memberAccount = () => { |
|
|
|
"type": type |
|
|
|
} |
|
|
|
const response = await cardAPI.GetMemberAccountCardConsRecord(jsonData); |
|
|
|
setCurrentOption({ |
|
|
|
functionName: 'onFetchCardConsRecord', |
|
|
|
record: JSON.parse(JSON.stringify(record)), |
|
|
|
type |
|
|
|
}); |
|
|
|
if (response.statusCode === 200) { |
|
|
|
setConsList(response.data.data); |
|
|
|
setConsTotal(response.data.total); |
|
|
@@ -170,6 +184,11 @@ const memberAccount = () => { |
|
|
|
|
|
|
|
//消费列表 |
|
|
|
const consColumns = [ |
|
|
|
{ |
|
|
|
title: '时间', |
|
|
|
dataIndex: 'createAt', |
|
|
|
width: 200 |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '类型', |
|
|
|
dataIndex: 'type', |
|
|
@@ -182,21 +201,43 @@ const memberAccount = () => { |
|
|
|
</div> |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '消费金额', |
|
|
|
dataIndex: 'money', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '之前余额', |
|
|
|
dataIndex: 'beforeMoney', |
|
|
|
render: (_, record) => { |
|
|
|
return <div style={{ color: 'green' }}> |
|
|
|
{record.beforeMoney} |
|
|
|
</div> |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '消费金额', |
|
|
|
dataIndex: 'money', |
|
|
|
render: (_, record) => { |
|
|
|
return <div style={{ color: 'red' }}> |
|
|
|
{record.money} |
|
|
|
</div> |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '之后余额', |
|
|
|
dataIndex: 'afterMoney', |
|
|
|
render: (_, record) => { |
|
|
|
return <div style={{ color: 'blue' }}> |
|
|
|
{record.afterMoney} |
|
|
|
</div> |
|
|
|
} |
|
|
|
} |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (consCurrent === 1) return; |
|
|
|
if (currentOption.functionName === 'onFetchAccountConsRecord') { |
|
|
|
onFetchAccountConsRecord(currentOption.record, currentOption.type); |
|
|
|
} else if (currentOption.functionName === 'onFetchCardConsRecord') { |
|
|
|
onFetchCardConsRecord(currentOption.record, currentOption.type); |
|
|
|
} |
|
|
|
}, [consCurrent]) |
|
|
|
|
|
|
|
return ( |
|
|
|
<PageContainer> |
|
|
@@ -239,7 +280,7 @@ const memberAccount = () => { |
|
|
|
dateFormatter="string" |
|
|
|
headerTitle="储值卡账户管理" |
|
|
|
/> |
|
|
|
<Modal width={800} title='消费记录' visible={isModalOpen} footer={false} onCancel={() => setIsModalOpen(false)}> |
|
|
|
<Modal width={800} title='消费记录' visible={isModalOpen} footer={false} onCancel={() => {setIsModalOpen(false); setConsCurrent(1)}}> |
|
|
|
<Table columns={consColumns} dataSource={consList} pagination={{ |
|
|
|
current: consCurrent, |
|
|
|
pageSize: consPageSize, |
|
|
|