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

feat: 修改传参

parent 6cc6cdaf
...@@ -54,8 +54,9 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -54,8 +54,9 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
const res = await apiDepartmentUpdate(params); const res = await apiDepartmentUpdate(params);
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
message.success('修改成功'); message.success('修改成功');
refForm.resetFields();
setNameVisible(false); setNameVisible(false);
getDepartmentList({ data: { enterpriseId: values.enterpriseId }, ...pageInfo }); getDepartmentList({ data: { enterpriseId }, ...pageInfo });
} }
}); });
}; };
...@@ -94,8 +95,9 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -94,8 +95,9 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
}, },
]; ];
const onCancel = () => { const onCancel = () => {
setNameVisible(false); refForm.resetFields();
setName(''); setName('');
setNameVisible(false);
}; };
const onChange = (page, size) => { const onChange = (page, size) => {
...@@ -160,14 +162,16 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -160,14 +162,16 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
onCancel={onCancel} onCancel={onCancel}
> >
<Form form={refForm}> <Form form={refForm}>
<Form.Item {name && (
label="部门名称" <Form.Item
name="name" label="部门名称"
initialValue={name} name="name"
rules={[{ required: true, message: '请填写部门名称' }]} initialValue={name}
> rules={[{ required: true, message: '请填写部门名称' }]}
<Input /> >
</Form.Item> <Input />
</Form.Item>
)}
</Form> </Form>
</Modal> </Modal>
</Modal> </Modal>
......
...@@ -27,10 +27,14 @@ import { ...@@ -27,10 +27,14 @@ import {
} from './service.js'; } from './service.js';
import NewEmployeeModal from './components/newEmployeeModal'; import NewEmployeeModal from './components/newEmployeeModal';
import DepartmentModal from './components/departmentModal'; import DepartmentModal from './components/departmentModal';
import ViewDepartmentModal from './components/ViewDepartmentModal'; import ViewDepartmentModal from './components/viewDepartmentModal';
import BlacklistModal from './components/BlacklistModal'; import BlacklistModal from './components/blacklistModal';
import RechargeDetailsModal from './components/RechargeDetailsModal'; import RechargeDetailsModal from './components/RechargeDetailsModal';
const layout = {
labelCol: { span: 6 },
wrapperCol: { span: 8 },
};
const { confirm } = Modal; const { confirm } = Modal;
const StoreManagement = () => { const StoreManagement = () => {
const [modalVisible, setModalVisible] = useState(false); const [modalVisible, setModalVisible] = useState(false);
...@@ -48,6 +52,7 @@ const StoreManagement = () => { ...@@ -48,6 +52,7 @@ const StoreManagement = () => {
page: 1, page: 1,
size: 10, size: 10,
}); });
const [total, setTotal] = useState(0);
const [searchForm, setSearchForm] = useState({}); const [searchForm, setSearchForm] = useState({});
const formRef = useRef(null); const formRef = useRef(null);
const [editVisible, setEditVisible] = useState(false); const [editVisible, setEditVisible] = useState(false);
...@@ -55,10 +60,11 @@ const StoreManagement = () => { ...@@ -55,10 +60,11 @@ const StoreManagement = () => {
const [repastType, setRepastType] = useState([]); const [repastType, setRepastType] = useState([]);
const [repastId, setRepastId] = useState(null); const [repastId, setRepastId] = useState(null);
const shopList = async () => { const shopList = async params => {
const res = await apiStaffList({ ...page, data: searchForm }); const res = await apiStaffList(params);
if (res.businessCode === '0000' && res.data?.records) { if (res.businessCode === '0000' && res.data?.records) {
const list = res.data.records; const list = res.data.records;
setTotal(res.data.total);
setStaffList(list); setStaffList(list);
} }
}; };
...@@ -92,7 +98,7 @@ const StoreManagement = () => { ...@@ -92,7 +98,7 @@ const StoreManagement = () => {
setRechargeDetailsVisible(false); setRechargeDetailsVisible(false);
if (val) { if (val) {
getDepartmentList(searchForm.enterpriseId); getDepartmentList(searchForm.enterpriseId);
shopList(); shopList({ ...page, data: searchForm });
setSelectedRowKeys([]); setSelectedRowKeys([]);
} }
}; };
...@@ -111,8 +117,10 @@ const StoreManagement = () => { ...@@ -111,8 +117,10 @@ const StoreManagement = () => {
setFirstEnterprise(firstOption); setFirstEnterprise(firstOption);
getDepartmentList(firstOption); getDepartmentList(firstOption);
setSearchForm({ enterpriseId: firstOption }); setSearchForm({ enterpriseId: firstOption });
shopList({ ...page, data: { enterpriseId: firstOption } });
} }
}; };
// 设置黑名单 // 设置黑名单
const getBlacklist = () => { const getBlacklist = () => {
if (!selectedRowKeys.length) { if (!selectedRowKeys.length) {
...@@ -124,17 +132,12 @@ const StoreManagement = () => { ...@@ -124,17 +132,12 @@ const StoreManagement = () => {
useEffect(() => { useEffect(() => {
getEnterpriseList(); getEnterpriseList();
}, []); }, []);
useEffect(() => {
if (searchForm.enterpriseId) {
shopList();
}
}, [searchForm, page]);
// 删除 // 删除
const deleteEmployee = async id => { const deleteEmployee = async id => {
const res = await apiStaffDelete({ id, enterpriseId: searchForm.enterpriseId, state: 0 }); const res = await apiStaffDelete({ id, enterpriseId: searchForm.enterpriseId, state: 0 });
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
message.success('删除成功!'); message.success('删除成功!');
shopList(); shopList({ ...page, data: searchForm });
} }
}; };
// 删除 // 删除
...@@ -157,16 +160,27 @@ const StoreManagement = () => { ...@@ -157,16 +160,27 @@ const StoreManagement = () => {
// 搜索 // 搜索
const onFinish = values => { const onFinish = values => {
setSearchForm(values); setSearchForm(values);
setPage({ current: 1, pageSize: 10 }); const pageInfo = {
page: 1,
size: 10,
};
setPage(pageInfo);
shopList({ ...pageInfo, data: values });
}; };
// 重置 // 重置
const onReset = () => { const onReset = () => {
formRef.current.resetFields(); formRef.current.resetFields();
setSearchForm({ enterpriseId: firstEnterprise }); setSearchForm({ enterpriseId: firstEnterprise });
shopList({ ...page, data: { enterpriseId: firstEnterprise } });
}; };
// 分页 // 分页
const handleTableChange = val => { const onChange = (pageNo, size) => {
setPage(val); const pageInfo = {
page: pageNo,
size,
};
setPage(pageInfo);
shopList({ data: searchForm, ...pageInfo });
}; };
const goDetails = async ({ staffNo }) => { const goDetails = async ({ staffNo }) => {
setRechargeDetailsVisible(true); setRechargeDetailsVisible(true);
...@@ -184,7 +198,7 @@ const StoreManagement = () => { ...@@ -184,7 +198,7 @@ const StoreManagement = () => {
}); });
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
message.success('设置成功'); message.success('设置成功');
shopList(); shopList({ ...page, data: searchForm });
} }
}; };
const enterpriseOnChange = val => { const enterpriseOnChange = val => {
...@@ -195,11 +209,18 @@ const StoreManagement = () => { ...@@ -195,11 +209,18 @@ const StoreManagement = () => {
goDetails, goDetails,
handleLimitChange, handleLimitChange,
}; };
const pagination = {
...page,
total,
showTotal: t => `共 ${t} 项数据`,
onChange,
onShowSizeChange: onChange,
};
return ( return (
<PageHeaderWrapper> <PageHeaderWrapper>
<Card className={styles.card}> <Card className={styles.card}>
{firstEnterprise && ( {firstEnterprise && (
<Form ref={formRef} onFinish={onFinish}> <Form ref={formRef} onFinish={onFinish} {...layout}>
<Row gutter={24}> <Row gutter={24}>
<Col span={8}> <Col span={8}>
<Form.Item <Form.Item
...@@ -270,7 +291,7 @@ const StoreManagement = () => { ...@@ -270,7 +291,7 @@ const StoreManagement = () => {
<Input maxLength="8" allowClear /> <Input maxLength="8" allowClear />
</Form.Item> </Form.Item>
</Col> </Col>
<Col> <Col span={24}>
<Form.Item> <Form.Item>
<Button type="primary" htmlType="submit"> <Button type="primary" htmlType="submit">
搜索 搜索
...@@ -322,8 +343,8 @@ const StoreManagement = () => { ...@@ -322,8 +343,8 @@ const StoreManagement = () => {
dataSource={staffList} dataSource={staffList}
rowKey={r => r.id} rowKey={r => r.id}
bordered bordered
onChange={handleTableChange}
rowSelection={rowSelection} rowSelection={rowSelection}
pagination={pagination}
/> />
<NewEmployeeModal <NewEmployeeModal
visible={modalVisible} visible={modalVisible}
......
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