Commit 45b05eb4 authored by 张子雨's avatar 张子雨

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

* feat/storeManagement:
  feat: 接口联调
parents 1053e968 dc9da6aa
...@@ -10,7 +10,7 @@ const getUrlParams = name => { ...@@ -10,7 +10,7 @@ const getUrlParams = name => {
return null; return null;
}; };
const isPlatForm = +getUrlParams('isMaster') === 1; const isPlatForm = +getUrlParams('isMaster') === 1;
const apiPrefix = isPlatForm ? '/api/consoles' : '/api/merchants'; const apiPrefix = isPlatForm ? '/api/consoles' : '/api/enterprises';
const envAPi = { const envAPi = {
api: `https://security-${environment}.liangkebang.net`, //'https://security-xyqb.liangkebang.net', api: `https://security-${environment}.liangkebang.net`, //'https://security-xyqb.liangkebang.net',
......
...@@ -140,7 +140,7 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -140,7 +140,7 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => {
</Dragger> </Dragger>
</Item> </Item>
<div className={styles.employees}> <div className={styles.employees}>
<a href="https://kdspstatic.q-gp.com/%E6%96%B0%E5%A2%9E%E5%91%98%E5%B7%A5.xlsx"> <a href="https://kdspstatic.q-gp.com/%E6%96%B0%E5%A2%9E%E9%83%A8%E9%97%A8.xlsx">
部门导入模版.xlsx 部门导入模版.xlsx
</a> </a>
</div> </div>
......
...@@ -27,6 +27,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -27,6 +27,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
}; };
const editName = row => { const editName = row => {
setName(row.name); setName(row.name);
refForm.setFieldsValue({ name: row.name });
setId(row.id); setId(row.id);
setNameVisible(true); setNameVisible(true);
}; };
...@@ -54,7 +55,6 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -54,7 +55,6 @@ 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 }, ...pageInfo }); getDepartmentList({ data: { enterpriseId }, ...pageInfo });
} }
...@@ -162,7 +162,6 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -162,7 +162,6 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
onCancel={onCancel} onCancel={onCancel}
> >
<Form form={refForm}> <Form form={refForm}>
{name && (
<Form.Item <Form.Item
label="部门名称" label="部门名称"
name="name" name="name"
...@@ -171,7 +170,6 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -171,7 +170,6 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
> >
<Input /> <Input />
</Form.Item> </Form.Item>
)}
</Form> </Form>
</Modal> </Modal>
</Modal> </Modal>
......
...@@ -26,6 +26,12 @@ export const columns = props => [ ...@@ -26,6 +26,12 @@ export const columns = props => [
dataIndex: 'staffName', dataIndex: 'staffName',
align: 'center', align: 'center',
}, },
{
title: '员工ID',
key: 'staffNo',
dataIndex: 'staffNo',
align: 'center',
},
{ {
title: '员工手机号', title: '员工手机号',
key: 'mobile', key: 'mobile',
......
...@@ -231,7 +231,6 @@ const StoreManagement = () => { ...@@ -231,7 +231,6 @@ const StoreManagement = () => {
initialValue={firstEnterprise} initialValue={firstEnterprise}
> >
<Select <Select
allowClear
showSearch showSearch
filterOption={(input, option) => filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()) (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
...@@ -341,7 +340,7 @@ const StoreManagement = () => { ...@@ -341,7 +340,7 @@ const StoreManagement = () => {
<Table <Table
columns={columns(res)} columns={columns(res)}
dataSource={staffList} dataSource={staffList}
rowKey={r => r.id} rowKey={r => r.staffNo}
bordered bordered
rowSelection={rowSelection} rowSelection={rowSelection}
pagination={pagination} pagination={pagination}
......
...@@ -4,11 +4,11 @@ import styles from '../index.less'; ...@@ -4,11 +4,11 @@ import styles from '../index.less';
import { apiSelectedList, apiSelectList, apiShopAdd } from '../service.js'; import { apiSelectedList, apiSelectList, apiShopAdd } from '../service.js';
const AddModal = props => { const AddModal = props => {
const { addVisible, enterpriseId, name } = props; const { addVisible, enterpriseId, name, onCancel } = props;
const [selectList, setSelectList] = useState([]); const [selectList, setSelectList] = useState([]);
const [options, setOptions] = useState([]); const [options, setOptions] = useState([]);
const handleCancel = () => { const handleCancel = () => {
props.onCancel(false); onCancel(false);
}; };
const handleChange = value => { const handleChange = value => {
setSelectList(value); setSelectList(value);
...@@ -34,34 +34,36 @@ const AddModal = props => { ...@@ -34,34 +34,36 @@ const AddModal = props => {
const { data } = res; const { data } = res;
const list = []; const list = [];
data.forEach(item => { data.forEach(item => {
list.push(item.id); list.push(item.shopId);
}); });
setSelectList(list); setSelectList(list);
} }
}; };
const getSelectList = async () => { const getSelectList = async () => {
const res = await apiSelectList({ id: enterpriseId }); const res = await apiSelectList({ enterpriseId });
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
const optionData = res.data.map(item => ({ const optionData = res.data.map(item => ({
value: item.id, value: item.shopId,
label: item.name, label: item.shopName,
})); }));
setOptions(optionData); setOptions(optionData);
getSelectedList();
} }
}; };
useEffect(() => { useEffect(() => {
if (addVisible) { if (addVisible) {
getSelectedList(); getSelectList();
} }
}, [addVisible]); }, [addVisible]);
return ( return (
<> <>
<Modal title="添加企业店铺" onOk={onOk} visible={addVisible} onCancel={() => handleCancel}> <Modal title="添加企业店铺" onOk={onOk} visible={addVisible} onCancel={handleCancel}>
<Form> <Form>
<Form.Item label="企业名称"> <Form.Item label="企业名称">
<span>{name}</span> <span>{name}</span>
</Form.Item> </Form.Item>
{selectList && selectList.length > 0 && (
<Form.Item label="添加微店" name="shopIds" initialValue={selectList}> <Form.Item label="添加微店" name="shopIds" initialValue={selectList}>
<Select <Select
mode="multiple" mode="multiple"
...@@ -72,6 +74,7 @@ const AddModal = props => { ...@@ -72,6 +74,7 @@ const AddModal = props => {
options={options} options={options}
/> />
</Form.Item> </Form.Item>
)}
<Form.Item label="餐饮类型"> <Form.Item label="餐饮类型">
<span>到店</span> <span>到店</span>
</Form.Item> </Form.Item>
......
...@@ -20,8 +20,8 @@ export const repastTypeList = [ ...@@ -20,8 +20,8 @@ export const repastTypeList = [
export const columns = props => [ export const columns = props => [
{ {
title: '微店ID', title: '微店ID',
key: 'id', key: 'shopId',
dataIndex: 'id', dataIndex: 'shopId',
align: 'center', align: 'center',
}, },
{ {
...@@ -37,7 +37,8 @@ export const columns = props => [ ...@@ -37,7 +37,8 @@ export const columns = props => [
align: 'center', align: 'center',
render: (_, row) => { render: (_, row) => {
const status = !row?.pickselfName; const status = !row?.pickselfName;
if (row?.mealType?.length) { const isArray = Array.isArray(row?.mealType);
if (isArray) {
return ( return (
<Button type="text" disabled={status} onClick={() => props.editRepastType(row)}> <Button type="text" disabled={status} onClick={() => props.editRepastType(row)}>
{row.mealType?.map((item, index) => ( {row.mealType?.map((item, index) => (
...@@ -75,8 +76,8 @@ export const columns = props => [ ...@@ -75,8 +76,8 @@ export const columns = props => [
}, },
{ {
title: '修改时间', title: '修改时间',
key: 'amount', key: 'createdAt',
dataIndex: 'amount', dataIndex: 'createdAt',
align: 'center', align: 'center',
}, },
{ {
......
import React, { useState, useRef, forwardRef, useEffect } from 'react'; import React, { useState, useRef, forwardRef, useEffect } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Modal, Form, Select, Table, Card, Row, Col, Input, Button, message } from 'antd'; import { Modal, Form, Select, Table, Card, Row, Col, Input, Button, message } from 'antd';
import { set } from 'lodash';
import { columns, repastTypeList } from './data'; import { columns, repastTypeList } from './data';
import EditRepastModal from './editRepastModal'; import EditRepastModal from './editRepastModal';
import AddModal from './addModal'; import AddModal from './addModal';
...@@ -19,6 +20,7 @@ const StoreManagement = () => { ...@@ -19,6 +20,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);
...@@ -31,14 +33,11 @@ const StoreManagement = () => { ...@@ -31,14 +33,11 @@ const StoreManagement = () => {
const [dataList, setDataList] = useState([]); const [dataList, setDataList] = useState([]);
const [name, setName] = useState(''); const [name, setName] = useState('');
const shopList = async () => { const shopList = async params => {
const params = {
...page,
data: searchForm,
};
const res = await setShopList(params); const res = await setShopList(params);
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
setDataList(res.data?.records); setDataList(res.data?.records);
setTotal(res.data?.total);
} }
}; };
...@@ -52,23 +51,21 @@ const StoreManagement = () => { ...@@ -52,23 +51,21 @@ const StoreManagement = () => {
value: item.id, value: item.id,
label: item.name, label: item.name,
})); }));
setEnterprise({ value: list[0].id, label: list[0].name });
setFirstEnterprise(firstOption); setFirstEnterprise(firstOption);
setEnterpriseList(optionData); setEnterpriseList(optionData);
setSearchForm({ enterpriseId: firstOption }); setSearchForm({ enterpriseId: firstOption });
shopList(); shopList({ data: { enterpriseId: firstOption }, ...page });
} }
}; };
useEffect(() => { useEffect(() => {
getEnterpriseList(); getEnterpriseList();
}, []); }, []);
useEffect(() => {
shopList();
}, [searchForm, page]);
// 关闭弹框 // 关闭弹框
const closeModal = value => { const closeModal = value => {
if (value) { if (value) {
shopList(); shopList({ data: searchForm, ...page });
} }
setEditVisible(false); setEditVisible(false);
setAddVisible(false); setAddVisible(false);
...@@ -91,7 +88,7 @@ const StoreManagement = () => { ...@@ -91,7 +88,7 @@ const StoreManagement = () => {
const res = await setShopDelete({ id }); const res = await setShopDelete({ id });
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
message.success('删除成功!'); message.success('删除成功!');
shopList(); shopList({ ...page, data: searchForm });
} }
}; };
// 删除 // 删除
...@@ -112,28 +109,46 @@ const StoreManagement = () => { ...@@ -112,28 +109,46 @@ const StoreManagement = () => {
}; };
// 添加商户 // 添加商户
const addShop = async () => { const addShop = async () => {
const res = await busineesTypeCheck({ id: searchForm.id }); const res = await busineesTypeCheck({ enterpriseId: searchForm.enterpriseId });
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
const val = enterpriseList.find(item => item.value === searchForm.enterpriseId).label; setName(enterprise.label);
setName(val);
setAddVisible(true); setAddVisible(true);
} }
}; };
// 搜索 // 搜索
const onFinish = async values => { const onFinish = async values => {
setSearchForm(values); setSearchForm(values);
setPage({ current: 1, pageSize: 10 }); const pageInfo = {
page: 1,
size: 10,
};
setPage(pageInfo);
shopList({ data: values, ...pageInfo });
}; };
// 重置 // 重置
const onReset = () => { const onReset = () => {
formRef.current.resetFields(); formRef.current.resetFields();
const pageInfo = {
page: 1,
size: 10,
};
setPage(pageInfo);
setSearchForm({ enterpriseId: firstEnterprise }); setSearchForm({ enterpriseId: firstEnterprise });
shopList({ data: { enterpriseId: firstEnterprise }, ...pageInfo });
}; };
// 分页 // 分页
const handleTableChange = val => { const handleTableChange = val => {
setPage(val); setPage(val);
}; };
const pagination = {
...page,
total,
showTotal: t => `共 ${t} 项数据`,
handleTableChange,
onShowSizeChange: handleTableChange,
};
const res = { const res = {
editRepastType, editRepastType,
delShop, delShop,
...@@ -206,9 +221,10 @@ const StoreManagement = () => { ...@@ -206,9 +221,10 @@ const StoreManagement = () => {
<Table <Table
columns={columns(res)} columns={columns(res)}
dataSource={dataList} dataSource={dataList}
rowKey={r => r.appealNo} rowKey={r => r.id}
bordered bordered
onChange={handleTableChange} // onChange={handleTableChange}
pagination={pagination}
/> />
<EditRepastModal <EditRepastModal
editVisible={editVisible} editVisible={editVisible}
...@@ -216,7 +232,12 @@ const StoreManagement = () => { ...@@ -216,7 +232,12 @@ const StoreManagement = () => {
id={repastId} id={repastId}
onCancel={closeModal} onCancel={closeModal}
/> />
<AddModal addVisible={addVisible} name={name} onCancel={closeModal} /> <AddModal
addVisible={addVisible}
enterpriseId={searchForm.enterpriseId}
name={name}
onCancel={closeModal}
/>
</PageHeaderWrapper> </PageHeaderWrapper>
); );
}; };
......
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