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

feat: 接口联调

parent dc9da6aa
......@@ -111,7 +111,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
const pagination = {
...pageInfo,
total,
showTotal: t => `共 ${t} 项数据`,
showTotal: t => `共 ${t} `,
onChange,
onShowSizeChange: onChange,
};
......
......@@ -212,7 +212,7 @@ const StoreManagement = () => {
const pagination = {
...page,
total,
showTotal: t => `共 ${t} 项数据`,
showTotal: t => `共 ${t} `,
onChange,
onShowSizeChange: onChange,
};
......
......@@ -4,11 +4,13 @@ import styles from '../index.less';
import { apiSelectedList, apiSelectList, apiShopAdd } from '../service.js';
const AddModal = props => {
const [form] = Form.useForm();
const { addVisible, enterpriseId, name, onCancel } = props;
const [selectList, setSelectList] = useState([]);
const [options, setOptions] = useState([]);
const handleCancel = () => {
onCancel(false);
const handleCancel = status => {
form.resetFields();
onCancel(status, 'add');
};
const handleChange = value => {
setSelectList(value);
......@@ -25,7 +27,7 @@ const AddModal = props => {
notification.success({
message: '添加成功',
});
props.onCancel(true);
handleCancel(true);
}
};
const getSelectedList = async () => {
......@@ -36,6 +38,7 @@ const AddModal = props => {
data.forEach(item => {
list.push(item.shopId);
});
form.setFieldsValue({ shopIds: list });
setSelectList(list);
}
};
......@@ -59,22 +62,20 @@ const AddModal = props => {
return (
<>
<Modal title="添加企业店铺" onOk={onOk} visible={addVisible} onCancel={handleCancel}>
<Form>
<Form form={form}>
<Form.Item label="企业名称">
<span>{name}</span>
</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="添加微店" 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>
......
......@@ -17,6 +17,17 @@ export const repastTypeList = [
},
];
const repastType = list => {
if (list.includes(4) && list.length > 1) {
return list
.filter(item => item !== 4)
.map(item => {
const name = repastTypeList.find(i => i.value === item)?.label;
return name ? `${name}/到店` : null;
});
}
return '到店';
};
export const columns = props => [
{
title: '微店ID',
......@@ -36,14 +47,12 @@ export const columns = props => [
dataIndex: 'mealType',
align: 'center',
render: (_, row) => {
const status = !row?.pickselfName;
const status = !row?.pickNameList?.length;
const isArray = Array.isArray(row?.mealType);
if (isArray) {
return (
<Button type="text" disabled={status} onClick={() => props.editRepastType(row)}>
{row.mealType?.map((item, index) => (
<span>{repastTypeList.find(itm => itm.value === item)?.label}&nbsp;</span>
))}
{repastType(row?.mealType)}
<FormOutlined />
</Button>
);
......@@ -53,15 +62,15 @@ export const columns = props => [
},
{
title: '所属企业取餐点',
key: 'pickselfName',
dataIndex: 'pickselfName',
key: 'pickNameList',
dataIndex: 'pickNameList',
align: 'center',
render: (text, record) => {
if (record.pickselfName?.length) {
if (record.pickNameList?.length) {
return text.map((item, index) => (
<span>
<span key={item}>
{item}
{index < record.pickselfName.length - 1 && ','}
{index < record.pickNameList.length - 1 && ','}
</span>
));
}
......
import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle } from 'react';
import { Button, Modal, Radio, Form, Space, message, Checkbox, Col, Row } from 'antd';
import React, { useState } from 'react';
import { Modal, Radio, Form, Space, message, Checkbox } from 'antd';
import styles from '../index.less';
import { apiShopUpdate } from '../service.js';
import { apiShopUpdate, busineesTypeCheck } from '../service.js';
const EditRepastModal = props => {
const [form] = Form.useForm();
const { editVisible, repastType, id } = props;
const handleCancel = () => {
props.onCancel();
const { editVisible, repastType, id, enterpriseId, isStore } = props;
const handleCancel = status => {
form.resetFields();
props.onCancel(status, 'edit');
};
const onOk = () => {
form.validateFields().then(async values => {
console.log(values);
const store = values?.store || '';
const mealTypeList = [...values.mealTypeList, ...store];
const params = {
id,
mealTypeList: values.mealTypeList,
mealTypeList,
};
const res = await apiShopUpdate(params);
if (res.businessCode === '0000') {
......@@ -22,31 +27,42 @@ const EditRepastModal = props => {
}
});
};
return (
<>
<Modal title="餐饮类型" onOk={onOk} visible={editVisible} onCancel={() => handleCancel()}>
<Form layout="vertical" autoComplete="off" form={form}>
<Modal
title="餐饮类型"
onOk={onOk}
visible={editVisible}
onCancel={() => handleCancel(false)}
>
<Form layout="vertical" form={form}>
<Form.Item
label="取餐点下商户餐品类型"
rules={[{ required: true, message: '请选择商户餐品类型' }]}
name="mealTypeList"
>
<Checkbox.Group>
<Space direction="mealTypeList">
{(repastType.length &&
repastType.map((index, value) => <Checkbox>{index}</Checkbox>)) ||
''}
</Space>
</Checkbox.Group>
<p className={styles.tip}>切换餐品类型后,请及时维护商品</p>
</Form.Item>
<Form.Item label="是否开启餐品类型">
<Checkbox.Group>
<Space direction="vertical">
<Checkbox>到店</Checkbox>
{repastType.map(item => (
<Checkbox value={item.value} key={item.value}>
{item.label}
</Checkbox>
))}
</Space>
<p className={styles.tip}>切换餐品类型后,请及时维护商品</p>
</Checkbox.Group>
<p className={styles.tip}>关闭【到店】餐类时,关联到店企业商品将一并删除</p>
</Form.Item>
{isStore && (
<Form.Item label="是否开启餐品类型" name="store">
<Checkbox.Group>
<Space direction="vertical">
<Checkbox value={4}>到店</Checkbox>
</Space>
<p className={styles.tip}>关闭【到店】餐类时,关联到店企业商品将一并删除</p>
</Checkbox.Group>
</Form.Item>
)}
</Form>
</Modal>
</>
......
......@@ -2,6 +2,7 @@ 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 { da } from 'date-fns/locale';
import { columns, repastTypeList } from './data';
import EditRepastModal from './editRepastModal';
import AddModal from './addModal';
......@@ -32,7 +33,7 @@ const StoreManagement = () => {
const [enterprise, setEnterprise] = useState({});
const [dataList, setDataList] = useState([]);
const [name, setName] = useState('');
const [isStore, setIsStore] = useState(false);
const shopList = async params => {
const res = await setShopList(params);
if (res.businessCode === '0000') {
......@@ -63,25 +64,45 @@ const StoreManagement = () => {
}, []);
// 关闭弹框
const closeModal = value => {
if (value) {
shopList({ data: searchForm, ...page });
const closeModal = (status, val) => {
if (status) {
const pageInfo = {
page: 1,
size: 10,
};
setPage(pageInfo);
shopList({ data: searchForm, ...pageInfo });
}
if (val === 'edit') {
setIsStore(false);
setEditVisible(false);
setRepastType([]);
return;
}
setEditVisible(false);
setName(false);
setAddVisible(false);
};
const setMealTypeList = async () => {
setEditVisible(true);
const res = await mealTypeList({ id: repastId });
const setMealTypeList = async id => {
const res = await mealTypeList({ id });
if (res.businessCode === '0000') {
setRepastType(res.data);
const resData = res.data;
const data = [];
repastTypeList.forEach(item => {
if (resData.includes(item.value) && item.value !== 4) {
data.push(item);
}
});
if (resData.includes(4)) {
setIsStore(true);
}
setRepastType(data);
setEditVisible(true);
}
};
// 修改餐饮类型
const editRepastType = ({ id }) => {
setRepastId(id);
setMealTypeList();
setMealTypeList(id);
};
// 删除
const editShop = async id => {
......@@ -137,15 +158,20 @@ const StoreManagement = () => {
shopList({ data: { enterpriseId: firstEnterprise }, ...pageInfo });
};
// 分页
const handleTableChange = val => {
setPage(val);
const handleTableChange = (pageNo, size) => {
const pageInfo = {
page: pageNo,
size,
};
setPage(pageInfo);
shopList({ data: searchForm, ...pageInfo });
};
const pagination = {
...page,
total,
showTotal: t => `共 ${t} 项数据`,
handleTableChange,
showTotal: t => `共 ${t} `,
onChange: handleTableChange,
onShowSizeChange: handleTableChange,
};
......@@ -168,8 +194,6 @@ const StoreManagement = () => {
initialValue={firstEnterprise}
>
<Select
allowClear
showSearch
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
......@@ -223,7 +247,6 @@ const StoreManagement = () => {
dataSource={dataList}
rowKey={r => r.id}
bordered
// onChange={handleTableChange}
pagination={pagination}
/>
<EditRepastModal
......@@ -231,6 +254,8 @@ const StoreManagement = () => {
repastType={repastType}
id={repastId}
onCancel={closeModal}
enterpriseId={searchForm.enterpriseId}
isStore={isStore}
/>
<AddModal
addVisible={addVisible}
......
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