Commit a6bf4d34 authored by 张子雨's avatar 张子雨

Merge branch 'feat/storeManagement' into feature/meal-3.0

* feat/storeManagement:
  feat: 代码优化
parents db23ce44 2d3a0026
...@@ -5,29 +5,39 @@ const RechargeDetailsModal = ({ visible, onClose, list }) => { ...@@ -5,29 +5,39 @@ const RechargeDetailsModal = ({ visible, onClose, list }) => {
const columns = [ const columns = [
{ {
title: '员工ID', title: '员工ID',
dataIndex: 'id', dataIndex: 'staffNo',
key: 'id', key: 'staffNo',
align: 'center',
}, },
{ {
title: '员工姓名', title: '员工姓名',
dataIndex: 'staffName', dataIndex: 'staffName',
key: 'staffName', key: 'staffName',
align: 'center',
}, },
{ {
title: '充值余额', title: '充值余额',
dataIndex: 'rechargeAmount', dataIndex: 'rechargeAmount',
key: 'rechargeAmount', key: 'rechargeAmount',
align: 'center',
}, },
{ {
title: '充值时间', title: '充值时间',
dataIndex: 'generateDate', dataIndex: 'generateDate',
key: 'generateDate', key: 'generateDate',
align: 'center',
}, },
]; ];
return ( return (
<Modal visible={visible} title="充值明细" onCancel={onClose} footer={null}> <Modal
<Table dataSource={list} columns={columns} pagination={false} border /> width="800px"
visible={visible}
title="充值明细"
onCancel={() => onClose(false, 'rechargeDetails')}
footer={null}
>
<Table dataSource={list} columns={columns} pagination={false} bordered />
</Modal> </Modal>
); );
}; };
......
...@@ -19,14 +19,19 @@ const BlacklistModal = ({ visible, onClose, list, enterpriseId }) => { ...@@ -19,14 +19,19 @@ const BlacklistModal = ({ visible, onClose, list, enterpriseId }) => {
apiStaffBlack(params).then(res => { apiStaffBlack(params).then(res => {
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
message.success('设置成功'); message.success('设置成功');
onClose(true); onClose(true, 'blacklist');
} }
}); });
}); });
}; };
return ( return (
<Modal visible={visible} title="设置员工黑名单" onCancel={onClose} onOk={handleSave}> <Modal
visible={visible}
title="设置员工黑名单"
onCancel={() => onClose(false, 'blacklist')}
onOk={handleSave}
>
<Form form={form} layout="vertical"> <Form form={form} layout="vertical">
<Item name="ids" label="您确定要把员工ID:"> <Item name="ids" label="您确定要把员工ID:">
{list.length && list.map(item => <span>{item},</span>)} {list.length && list.map(item => <span>{item},</span>)}
......
...@@ -17,7 +17,7 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -17,7 +17,7 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => {
const handleCancel = val => { const handleCancel = val => {
form.resetFields(); form.resetFields();
setImportMode(false); setImportMode(false);
onClose(val); onClose(val, 'department');
}; };
const handleImportChange = info => { const handleImportChange = info => {
...@@ -68,7 +68,7 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -68,7 +68,7 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => {
visible={visible} visible={visible}
onCancel={() => handleCancel(false)} onCancel={() => handleCancel(false)}
footer={[ footer={[
<Button key="cancel" onClick={onClose}> <Button key="cancel" onClick={() => handleCancel(false)}>
取消 取消
</Button>, </Button>,
<Button key="save" type="primary" onClick={() => handleSave()}> <Button key="save" type="primary" onClick={() => handleSave()}>
...@@ -151,7 +151,7 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -151,7 +151,7 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => {
name="name" name="name"
rules={[{ required: true, message: '请输入部门名称' }]} rules={[{ required: true, message: '请输入部门名称' }]}
> >
<Input /> <Input maxLength={20} />
</Item> </Item>
)} )}
</Form> </Form>
......
...@@ -19,7 +19,7 @@ const NewEmployeeModal = props => { ...@@ -19,7 +19,7 @@ const NewEmployeeModal = props => {
const handleCancel = val => { const handleCancel = val => {
form.resetFields(); form.resetFields();
setImportMode(false); setImportMode(false);
onClose(val); onClose(val, 'newEmployee');
}; };
const handleSave = () => { const handleSave = () => {
form.validateFields().then(async values => { form.validateFields().then(async values => {
...@@ -64,15 +64,16 @@ const NewEmployeeModal = props => { ...@@ -64,15 +64,16 @@ const NewEmployeeModal = props => {
setDepartmentList([]); setDepartmentList([]);
}; };
const onChange = value => { const onChange = value => {
form.setFieldsValue({ departmentId: undefined });
getDepartmentList(value); getDepartmentList(value);
}; };
return ( return (
<Modal <Modal
visible={visible} visible={visible}
title="添加新员工" title="添加新员工"
onCancel={onClose} onCancel={handleCancel}
footer={[ footer={[
<Button key="cancel" onClick={onClose}> <Button key="cancel" onClick={handleCancel}>
取消 取消
</Button>, </Button>,
<Button key="save" type="primary" onClick={handleSave}> <Button key="save" type="primary" onClick={handleSave}>
...@@ -177,9 +178,13 @@ const NewEmployeeModal = props => { ...@@ -177,9 +178,13 @@ const NewEmployeeModal = props => {
required: true, required: true,
message: '请输入员工ID', message: '请输入员工ID',
}, },
{
pattern: /^[a-zA-Z0-9]+$/,
message: '员工ID由数字与英文大小写字母组成',
},
]} ]}
> >
<Input /> <Input maxLength={15} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="staffName" name="staffName"
......
...@@ -23,7 +23,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -23,7 +23,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
setDataSource([]); setDataSource([]);
setPageInfo({ page: 1, size: 10 }); setPageInfo({ page: 1, size: 10 });
setTotal(0); setTotal(0);
onClose(); onClose(false, 'viewDepartment');
}; };
const editName = row => { const editName = row => {
setName(row.name); setName(row.name);
...@@ -168,7 +168,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -168,7 +168,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
initialValue={name} initialValue={name}
rules={[{ required: true, message: '请填写部门名称' }]} rules={[{ required: true, message: '请填写部门名称' }]}
> >
<Input /> <Input maxLength={20} />
</Form.Item> </Form.Item>
</Form> </Form>
</Modal> </Modal>
......
...@@ -67,8 +67,8 @@ export const columns = props => [ ...@@ -67,8 +67,8 @@ export const columns = props => [
}, },
{ {
title: '员工企业余额', title: '员工企业余额',
key: 'balanceBackFlag', key: 'balance',
dataIndex: 'balanceBackFlag', dataIndex: 'balance',
align: 'center', align: 'center',
}, },
{ {
......
...@@ -90,16 +90,30 @@ const StoreManagement = () => { ...@@ -90,16 +90,30 @@ const StoreManagement = () => {
setDepartmentList([]); setDepartmentList([]);
}; };
// 关闭弹框 // 关闭弹框
const handleCloseModal = val => { const handleCloseModal = (status, val) => {
setModalVisible(false); switch (val) {
setDepartmentVisible(false); case 'newEmployee':
setViewDepartmentVisible(false); setModalVisible(false);
setBlacklistVisible(false); break;
setRechargeDetailsVisible(false); case 'viewDepartment':
if (val) { setViewDepartmentVisible(false);
getDepartmentList(searchForm.enterpriseId); getDepartmentList(searchForm.enterpriseId);
break;
case 'department':
setDepartmentVisible(false);
break;
case 'blacklist':
setBlacklistVisible(false);
setSelectedRowKeys([]);
break;
case 'rechargeDetails':
setRechargeDetailsVisible(false);
break;
default:
break;
}
if (status) {
shopList({ ...page, data: searchForm }); shopList({ ...page, data: searchForm });
setSelectedRowKeys([]);
} }
}; };
...@@ -337,14 +351,16 @@ const StoreManagement = () => { ...@@ -337,14 +351,16 @@ const StoreManagement = () => {
</Button> </Button>
</div> </div>
</Card> </Card>
<Table <Card>
columns={columns(res)} <Table
dataSource={staffList} columns={columns(res)}
rowKey={r => r.staffNo} dataSource={staffList}
bordered rowKey={r => r.id}
rowSelection={rowSelection} bordered
pagination={pagination} rowSelection={rowSelection}
/> pagination={pagination}
/>
</Card>
<NewEmployeeModal <NewEmployeeModal
visible={modalVisible} visible={modalVisible}
enterpriseList={enterpriseList} enterpriseList={enterpriseList}
......
...@@ -23,10 +23,13 @@ const repastType = list => { ...@@ -23,10 +23,13 @@ const repastType = list => {
.filter(item => item !== 4) .filter(item => item !== 4)
.map(item => { .map(item => {
const name = repastTypeList.find(i => i.value === item)?.label; const name = repastTypeList.find(i => i.value === item)?.label;
return name ? `${name}/到店` : null; return name ? `${name}/到店 ` : null;
}); });
} }
return '到店'; return list.map(item => {
const name = repastTypeList.find(i => i.value === item)?.label;
return name ? `${name} ` : null;
});
}; };
export const columns = props => [ export const columns = props => [
{ {
......
...@@ -242,13 +242,15 @@ const StoreManagement = () => { ...@@ -242,13 +242,15 @@ const StoreManagement = () => {
</Form> </Form>
)} )}
</Card> </Card>
<Table <Card>
columns={columns(res)} <Table
dataSource={dataList} columns={columns(res)}
rowKey={r => r.id} dataSource={dataList}
bordered rowKey={r => r.id}
pagination={pagination} bordered
/> pagination={pagination}
/>
</Card>
<EditRepastModal <EditRepastModal
editVisible={editVisible} editVisible={editVisible}
repastType={repastType} repastType={repastType}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment