|
@@ -3,7 +3,8 @@ import styles from "./index.less"; |
|
|
import { PageContainer } from '@ant-design/pro-layout'; |
|
|
import { PageContainer } from '@ant-design/pro-layout'; |
|
|
import { PlusOutlined } from '@ant-design/icons'; |
|
|
import { PlusOutlined } from '@ant-design/icons'; |
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
import { Button, Form, Input, DatePicker, Modal, Select, Popconfirm } from 'antd'; |
|
|
|
|
|
|
|
|
import { Button, Form, Input, message, Modal, Select, Popconfirm } from 'antd'; |
|
|
|
|
|
import cardAPI from "../service"; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 储值卡管理 |
|
|
* 储值卡管理 |
|
@@ -11,24 +12,30 @@ import { Button, Form, Input, DatePicker, Modal, Select, Popconfirm } from 'antd |
|
|
*/ |
|
|
*/ |
|
|
const storedValueCard = () => { |
|
|
const storedValueCard = () => { |
|
|
const actionRef = useRef(); |
|
|
const actionRef = useRef(); |
|
|
const modalForm = Form.useForm(); |
|
|
|
|
|
|
|
|
const [modalForm] = Form.useForm(); |
|
|
const [isModalOpen, setIsModalOpen] = useState(false); |
|
|
const [isModalOpen, setIsModalOpen] = useState(false); |
|
|
const [currentOption, setCurrentOption] = useState({ id: '' }); |
|
|
const [currentOption, setCurrentOption] = useState({ id: '' }); |
|
|
|
|
|
|
|
|
|
|
|
const [current, setCurrent] = useState(1); |
|
|
|
|
|
const [pageSize, setPageSize] = useState(10); |
|
|
|
|
|
const [total, setTotal] = useState(0); |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 点击编辑按钮 |
|
|
* 点击编辑按钮 |
|
|
* @param {*} record |
|
|
* @param {*} record |
|
|
*/ |
|
|
*/ |
|
|
const onEditTableRow = (record) => { |
|
|
const onEditTableRow = (record) => { |
|
|
|
|
|
modalForm.setFieldsValue(record); |
|
|
setCurrentOption(record); |
|
|
setCurrentOption(record); |
|
|
setIsModalOpen(true); |
|
|
setIsModalOpen(true); |
|
|
// modalForm.setFieldsValue(record); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 点击新建 |
|
|
* 点击新建 |
|
|
*/ |
|
|
*/ |
|
|
const onCreateTableRow = () => { |
|
|
const onCreateTableRow = () => { |
|
|
|
|
|
modalForm.resetFields(); |
|
|
|
|
|
setCurrentOption({id: ''}) |
|
|
setIsModalOpen(true); |
|
|
setIsModalOpen(true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -43,12 +50,32 @@ const storedValueCard = () => { |
|
|
/** |
|
|
/** |
|
|
* 提交表单 |
|
|
* 提交表单 |
|
|
*/ |
|
|
*/ |
|
|
const onFinish = (values) => { |
|
|
|
|
|
console.log('value', values); |
|
|
|
|
|
|
|
|
const onFinish = async (values) => { |
|
|
if (values.id) { |
|
|
if (values.id) { |
|
|
console.log('更新') |
|
|
|
|
|
|
|
|
const response = await cardAPI.UpdateMemberCardState({ |
|
|
|
|
|
id: values.id, |
|
|
|
|
|
type: values.type, |
|
|
|
|
|
state: values.state |
|
|
|
|
|
}); |
|
|
|
|
|
if (response.statusCode === 200) { |
|
|
|
|
|
message.success('更新成功'); |
|
|
|
|
|
setIsModalOpen(false); |
|
|
|
|
|
actionRef.current.reload(); |
|
|
|
|
|
} else { |
|
|
|
|
|
message.error(response.errors || '更新储值卡失败'); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
console.log('创建') |
|
|
|
|
|
|
|
|
const response = await cardAPI.AddMemberCard({ |
|
|
|
|
|
type: values.type, |
|
|
|
|
|
state: values.state |
|
|
|
|
|
}); |
|
|
|
|
|
if (response.statusCode === 200) { |
|
|
|
|
|
message.success('添加成功'); |
|
|
|
|
|
setIsModalOpen(false); |
|
|
|
|
|
actionRef.current.reload(); |
|
|
|
|
|
} else { |
|
|
|
|
|
message.error(response.errors || '添加储值卡失败'); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -64,14 +91,8 @@ const storedValueCard = () => { |
|
|
ellipsis: true, |
|
|
ellipsis: true, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: '会员ID', |
|
|
|
|
|
dataIndex: 'cardId', |
|
|
|
|
|
ellipsis: true, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
disable: true, |
|
|
|
|
|
title: '状态', |
|
|
title: '状态', |
|
|
dataIndex: 'status', |
|
|
|
|
|
|
|
|
dataIndex: 'state', |
|
|
valueType: 'select', |
|
|
valueType: 'select', |
|
|
valueEnum: { |
|
|
valueEnum: { |
|
|
0: { |
|
|
0: { |
|
@@ -117,14 +138,6 @@ const storedValueCard = () => { |
|
|
key: 'option', |
|
|
key: 'option', |
|
|
render: (text, record, _, action) => [ |
|
|
render: (text, record, _, action) => [ |
|
|
<a onClick={() => onEditTableRow(record)}>编辑</a>, |
|
|
<a onClick={() => onEditTableRow(record)}>编辑</a>, |
|
|
<Popconfirm |
|
|
|
|
|
title="你确定要删除此条数据吗?" |
|
|
|
|
|
onConfirm={() => onDeleteTableRow(record)} |
|
|
|
|
|
okText="确定" |
|
|
|
|
|
cancelText="取消" |
|
|
|
|
|
> |
|
|
|
|
|
<a href="#">删除</a> |
|
|
|
|
|
</Popconfirm> |
|
|
|
|
|
], |
|
|
], |
|
|
}, |
|
|
}, |
|
|
]; |
|
|
]; |
|
@@ -137,27 +150,15 @@ const storedValueCard = () => { |
|
|
columns={columns} |
|
|
columns={columns} |
|
|
actionRef={actionRef} |
|
|
actionRef={actionRef} |
|
|
request={ |
|
|
request={ |
|
|
() => { |
|
|
|
|
|
const data = [ |
|
|
|
|
|
{ |
|
|
|
|
|
id: '1008611', |
|
|
|
|
|
cardNum: '100546549568', |
|
|
|
|
|
cardId: '1008611-100111', |
|
|
|
|
|
type: 0, |
|
|
|
|
|
status: 0, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
id: '10086112', |
|
|
|
|
|
cardNum: '111彭于213123asdf晏2', |
|
|
|
|
|
cardId: '21008611-100111', |
|
|
|
|
|
status: 1, |
|
|
|
|
|
type: 1, |
|
|
|
|
|
}, |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
async () => { |
|
|
|
|
|
const response = await cardAPI.GetMemberCardPageList({ |
|
|
|
|
|
current, |
|
|
|
|
|
pageSize |
|
|
|
|
|
}); |
|
|
return { |
|
|
return { |
|
|
data: data, |
|
|
|
|
|
|
|
|
data: response.data.data, |
|
|
success: true, |
|
|
success: true, |
|
|
total: 2, |
|
|
|
|
|
|
|
|
total: response.data.total, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -166,17 +167,15 @@ const storedValueCard = () => { |
|
|
type: 'multiple', |
|
|
type: 'multiple', |
|
|
}} |
|
|
}} |
|
|
rowKey="id" |
|
|
rowKey="id" |
|
|
search={{ |
|
|
|
|
|
labelWidth: 'auto', |
|
|
|
|
|
}} |
|
|
|
|
|
|
|
|
search={false} |
|
|
options={{ |
|
|
options={{ |
|
|
setting: { |
|
|
setting: { |
|
|
listsHeight: 400, |
|
|
listsHeight: 400, |
|
|
}, |
|
|
}, |
|
|
}} |
|
|
}} |
|
|
pagination={{ |
|
|
pagination={{ |
|
|
pageSize: 5, |
|
|
|
|
|
onChange: (page) => console.log(page), |
|
|
|
|
|
|
|
|
pageSize: pageSize, |
|
|
|
|
|
onChange: (page) => setCurrent(page), |
|
|
}} |
|
|
}} |
|
|
dateFormatter="string" |
|
|
dateFormatter="string" |
|
|
headerTitle="储值卡账户管理" |
|
|
headerTitle="储值卡账户管理" |
|
@@ -186,10 +185,12 @@ const storedValueCard = () => { |
|
|
</Button> |
|
|
</Button> |
|
|
]} |
|
|
]} |
|
|
/> |
|
|
/> |
|
|
<Modal width={600} title={currentOption.id ? '编辑会员' : '添加会员'} visible={isModalOpen} footer={false} onCancel={() => setIsModalOpen(false)}> |
|
|
|
|
|
|
|
|
<Modal width={600} title={currentOption.id ? '编辑储值卡' : '添加储值卡'} visible={isModalOpen} footer={false} onCancel={() => setIsModalOpen(false)}> |
|
|
<Form |
|
|
<Form |
|
|
name="basic" |
|
|
name="basic" |
|
|
onFinish={onFinish} |
|
|
onFinish={onFinish} |
|
|
|
|
|
form={modalForm} |
|
|
|
|
|
labelCol={{span: 4}} |
|
|
> |
|
|
> |
|
|
|
|
|
|
|
|
<Form.Item |
|
|
<Form.Item |
|
@@ -203,32 +204,13 @@ const storedValueCard = () => { |
|
|
<Form.Item |
|
|
<Form.Item |
|
|
label="卡号" |
|
|
label="卡号" |
|
|
name="cardNum" |
|
|
name="cardNum" |
|
|
rules={[ |
|
|
|
|
|
{ |
|
|
|
|
|
required: true, |
|
|
|
|
|
message: '请输入卡号!', |
|
|
|
|
|
}, |
|
|
|
|
|
]} |
|
|
|
|
|
> |
|
|
|
|
|
<Input /> |
|
|
|
|
|
</Form.Item> |
|
|
|
|
|
|
|
|
|
|
|
<Form.Item |
|
|
|
|
|
label="会员ID" |
|
|
|
|
|
name="cardId" |
|
|
|
|
|
rules={[ |
|
|
|
|
|
{ |
|
|
|
|
|
required: true, |
|
|
|
|
|
message: '请输入会员ID!', |
|
|
|
|
|
}, |
|
|
|
|
|
]} |
|
|
|
|
|
> |
|
|
> |
|
|
<Input /> |
|
|
|
|
|
|
|
|
<Input disabled={true} /> |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
|
|
|
|
|
|
|
<Form.Item |
|
|
<Form.Item |
|
|
label="状态" |
|
|
label="状态" |
|
|
name="status" |
|
|
|
|
|
|
|
|
name="state" |
|
|
rules={[ |
|
|
rules={[ |
|
|
{ |
|
|
{ |
|
|
required: true, |
|
|
required: true, |
|
|