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

feat: 接口联调

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