Commit 1aa8412c authored by 张子雨's avatar 张子雨

Merge branch 'feature/meal-3.0' of...

Merge branch 'feature/meal-3.0' of http://git.quantgroup.cn/ui/merchant-manage-ui into feature/meal-3.0
parents 97be610e 5141123b
const isProduction = process.env.NODE_ENV === 'production';
const isPre = process.env.PRE_ENV === 'pre';
const environment = 'sc';
// 从tob进入的判断接口前缀
const apiPrefix =
sessionStorage.getItem('role') === 'platform' ? '/api/consoles' : '/api/merchants';
const getUrlParams = name => {
const regArg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`);
const r = window.location.search.substr(1).match(regArg);
if (r != null) return decodeURIComponent(r[2]);
return null;
};
const isPlatForm = +getUrlParams('isMaster') === 1;
const apiPrefix = isPlatForm ? '/api/consoles' : '/api/merchants';
const envAPi = {
api: `https://security-${environment}.liangkebang.net`, //'https://security-xyqb.liangkebang.net',
kdspOpApi: `https://sc-merchant-api-${environment}.liangkebang.net`,
......@@ -16,6 +24,9 @@ const envAPi = {
wsApi: `wss://push-${environment}.liangkebang.net`,
msgApi: `https://msgapi-${environment}.liangkebang.net`,
keystoneApi: `https://sc-op-api-${environment}.liangkebang.net`,
roleApi: isPlatForm
? `https://sc-op-api-${environment}.liangkebang.net`
: `https://sc-merchant-api-${environment}.liangkebang.net`,
apiPrefix,
};
......@@ -35,6 +46,7 @@ const prodApi = {
wsApi: 'wss://push.q-gp.com',
msgApi: 'https://msgapi.q-gp.com',
keystoneApi: '//sc-op-api.q-gp.com',
roleApi: isPlatForm ? 'https://sc-op-api.q-gp.com' : 'https://sc-merchant-api-pre.q-gp.com',
apiPrefix,
};
......@@ -50,6 +62,7 @@ const preProdApi = {
wsApi: 'wss://push.q-gp.com',
msgApi: 'https://msgapi.q-gp.com',
keystoneApi: '//sc-op-api-pre.q-gp.com',
roleApi: isPlatForm ? 'https://sc-op-api-pre.q-gp.com' : 'https://sc-merchant-api-pre.q-gp.com',
apiPrefix,
};
......@@ -60,6 +73,7 @@ if (isPre) {
exportApi = prodApi;
}
module.exports = exportApi;
// let exportApi;
// isProduction ? (exportApi = prodApi) : (exportApi = envAPi);
......
......@@ -11,12 +11,6 @@ export default [
name: 'TakeawayGoods',
component: './businessGoods/takeawayGoods',
},
{
title: '商户管理后台-企业团餐-外卖商品',
path: '/takeawayGoods',
name: 'TakeawayGoods',
component: './businessGoods/takeawayGoods',
},
{
title: '商户管理后台-企业团餐-外卖商品-添加商品',
path: '/takeawayGoodsInfo',
......
......@@ -27,6 +27,7 @@ class SecurityLayout extends React.Component {
/* eslint-disable no-underscore-dangle */
render() {
// 判断是否从tob进入
console.log('getUrlSearchParams -- 1 :>> ', 1111);
const searchPrams = getUrlSearchParams();
const isTob = searchPrams.source === 'tob';
if (isTob) {
......
......@@ -46,6 +46,7 @@ const CustomerInfo = props => {
// 关闭分组信息弹窗
const handleCancel = () => {
props.reFresh();
props.handleClose(false);
};
......@@ -120,13 +121,17 @@ const CustomerInfo = props => {
});
params.mealLimit = limits;
console.log('params :>> ', params);
// let api = apiNewEnterprise;
// if (props.id) {
// params.id = props.id;
// api = apiEditEnterprise;
// }
// await api(params);
notification.success({ message: '保存成功!' });
let api = apiNewEnterprise;
if (props.id) {
params.id = props.id;
api = apiEditEnterprise;
}
const resp = await api(params);
if (resp) {
handleCancel();
props.reFresh();
notification.success({ message: '保存成功!' });
}
};
// 风险提示
......@@ -179,62 +184,70 @@ const CustomerInfo = props => {
};
// 改变餐段
const onChangeMealSection = e => {
console.log('e.target :>> ', e.target);
const { id, checked, label } = e.target;
const values = Object.assign({}, meals);
if (checked) {
values[id] = label;
// values.push(value);
// } else if (values.includes(value)) {
// const index = values.findIndex(v => v === value);
// values.splice(index, 1);
} else {
delete values[id];
}
console.log('values :>> ', values);
setMeals(values);
};
// 获取企业客户信息
const getInfo = async () => {
const res = await apiEnterpriseInfo(props.id);
const obj = Object.assign({}, res);
if (res.mealTimePeriod && res.mealTimePeriod.length) {
obj.mealTimePeriod = res.mealTimePeriod.map(item => ({
mealPeriodType: `${item.mealPeriodType}`,
time: [moment(item.beginTime), moment(item.endTime)],
}));
} else {
obj.mealTimePeriod = [];
}
if (res.mealLimit) {
if (res && res.data) {
const obj = Object.assign({}, res.data);
if (res.data.mealTimePeriod && res.data.mealTimePeriod.length) {
const m = moment().format('YYYY-MM-DD');
obj.mealTimePeriod = res.data.mealTimePeriod.map(item => ({
mealPeriodType: `${item.mealPeriodType}`,
time: [moment(`${m} ${item.beginTime}`), moment(`${m} ${item.endTime}`)],
}));
} else {
obj.mealTimePeriod = [];
}
obj.mealLimit = {};
res.mealLimit.forEach(item => {
obj.mealLimit[`limit${item.mealPeriodType}`] = {};
item.limit.forEach(limit => {
obj.mealLimit[`limit${item.mealPeriodType}`][limit.mealType] = limit.limit;
if (res.data.mealLimit) {
res.data.mealLimit.forEach(item => {
obj.mealLimit[`limit${item.mealPeriodType}`] = {};
item.limit.forEach(limit => {
obj.mealLimit[`limit${item.mealPeriodType}`][limit.mealType] = limit.limit;
});
});
}
obj.hideInfo = [];
if (+res.data.hidePrice) {
obj.hideInfo.push('hidePrice');
}
if (+res.data.hideImage) {
obj.hideInfo.push('hideImage');
}
obj.mealType = res.data.mealType.map(item => `${item}`);
console.log('obj :>> ', obj);
setMealTypes(obj.mealType);
const json = {};
res.data.mealTimePeriod.forEach(item => {
json[item.mealPeriodType] = mealSections[item.mealPeriodType];
});
setMeals(json);
form.setFieldsValue(obj);
}
obj.hideInfo = [];
if (+res.hidePrice) {
obj.hideInfo.push('hidePrice');
}
if (+res.hideImage) {
obj.hideInfo.push('hideImage');
}
obj.mealType = res.mealType.map(item => `${item}`);
form.setFieldsValue(obj);
};
// 获取自提点列表
const getPickSelf = async () => {
const res = await apiEnterprisePickSelf({});
setPickSelfList(
res.map(item => ({
[item.id]: { text: item.name },
})),
);
if (res && res.data && res.data.records) {
const data = res.data.records;
setPickSelfList(
data.map(item => ({
value: item.id,
label: item.pickselfName,
})),
);
}
};
useEffect(() => {
......@@ -242,9 +255,14 @@ const CustomerInfo = props => {
if (props.id) {
getInfo();
} else {
setMealTypes([]);
setMeals({});
form.resetFields();
getPickSelf();
}
} else {
setMealTypes([]);
setMeals({});
form.setFieldsValue({});
}
}, [props.visible]);
......@@ -274,7 +292,14 @@ const CustomerInfo = props => {
</Form.Item>
{!props.id && (
<Form.Item label="企业取餐点" name="pickselfIds">
<Select options={pickSelfList} />
<Select
options={pickSelfList}
mode="multiple"
showSearch
filterOption={(v, option) =>
(option?.label ?? '').toLowerCase().includes(v.toLowerCase())
}
/>
</Form.Item>
)}
<Form.Item
......@@ -284,9 +309,7 @@ const CustomerInfo = props => {
rules={[{ required: true, message: '请输入企业截止时间!' }]}
extra={<span>企业员工下单的截至时间,仅支持正整数,单位为分钟。</span>}
>
<Row>
<InputNumber min={0} max={600} addonAfter="分钟" />
</Row>
<InputNumber min={0} max={600} addonAfter="分钟" />
</Form.Item>
<Form.Item
label="餐品类型"
......
......@@ -9,16 +9,16 @@ const MealSection = props => (
<>
{Object.keys(mealSections).map((field, i) => (
<Space key={field} align="baseline">
<Form.Item label="" name={[fields[i].name, 'mealPeriodType']}>
<Form.Item label="" name={[i, 'mealPeriodType']}>
<MealCheckbox changeType={props.onChange} meals={props.meals} field={field} />
</Form.Item>
<Form.Item
name={[fields[i].name, 'time']}
rules={[
props.meals[field] ? { type: 'array', required: true, message: '请选择!' } : {},
]}
name={[i, 'time']}
rules={
props.meals[field] ? [{ type: 'array', required: true, message: '请选择!' }] : []
}
>
<TimePicker.RangePicker format="HH:mm" />
<TimePicker.RangePicker format="HH:mm" minuteStep={30} />
</Form.Item>
</Space>
))}
......
......@@ -7,20 +7,30 @@ import CustomerInfo from './components/CustomerInfo';
import { apiEnterpriseList } from './service';
const BusinessCustomer = () => {
const refTable = useRef();
const [visible, setVisible] = useState(false);
const [id, setId] = useState('');
const query = async params => {
const data = {
page: params.current,
size: params.pageSize,
data: params,
};
return apiEnterpriseList(data);
const res = await apiEnterpriseList(data);
return {
data: res.data.records,
total: res.data.total,
};
};
const onEdit = v => {
setId(v);
setVisible(true);
};
const onEdit = async () => {};
return (
<div>
<ProTable
actionRef={refTable}
search={{
collapsed: false,
collapseRender: () => null,
......@@ -32,13 +42,26 @@ const BusinessCustomer = () => {
bordered
options={false}
toolBarRender={() => [
<Button key="3" icon={<PlusOutlined />} type="primary" onClick={() => setVisible(!0)}>
<Button
key="3"
icon={<PlusOutlined />}
type="primary"
onClick={() => {
setId('');
setVisible(!0);
}}
>
添加企业客户
</Button>,
]}
scroll={{ x: '100%', y: 400 }}
/>
<CustomerInfo visible={visible} handleClose={setVisible} />
<CustomerInfo
visible={visible}
id={id}
reFresh={() => refTable.current.reload()}
handleClose={setVisible}
/>
</div>
);
};
......
......@@ -3,16 +3,16 @@ import config from '@/../config/env.config';
// import qs from 'qs';
const { kdspApi, goodsApi } = config;
const { roleApi, apiPrefix } = config;
/**
* 获取企业客户列表
* http://yapi.quantgroups.com/project/389/interface/api/65324
*/
export async function apiEnterpriseList(data) {
return request.post('/api/consoles/enterprise/pageList', {
return request.post(`${apiPrefix}/enterprise/pageList`, {
data,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -20,8 +20,8 @@ export async function apiEnterpriseList(data) {
* http://yapi.quantgroups.com/project/389/interface/api/65339
*/
export async function apiEnterpriseInfo(id) {
return request.get(`/api/consoles/enterprise/info?id=${id}`, {
prefix: goodsApi,
return request.get(`${apiPrefix}/enterprise/info?id=${id}`, {
prefix: roleApi,
});
}
/**
......@@ -29,9 +29,9 @@ export async function apiEnterpriseInfo(id) {
* http://yapi.quantgroups.com/project/389/interface/api/65329
*/
export async function apiNewEnterprise(data) {
return request.post('/api/consoles/enterprise/save', {
return request.post(`${apiPrefix}/enterprise/save`, {
data,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -39,9 +39,9 @@ export async function apiNewEnterprise(data) {
* http://yapi.quantgroups.com/project/389/interface/api/65334
*/
export async function apiEditEnterprise(data) {
return request.post('/api/consoles/enterprise/update', {
return request.post(`${apiPrefix}/enterprise/update`, {
data,
prefix: goodsApi,
prefix: roleApi,
});
}
......@@ -49,9 +49,8 @@ export async function apiEditEnterprise(data) {
* 查询自提点列表
* http://yapi.quantgroups.com/project/389/interface/api/65494
*/
export async function apiEnterprisePickSelf(data) {
return request.post('/api/consoles/selfPickUpLocation/list', {
data,
prefix: goodsApi,
export async function apiEnterprisePickSelf() {
return request.get(`${apiPrefix}/selfPickUpLocation/list`, {
prefix: roleApi,
});
}
......@@ -111,7 +111,7 @@ export const customerColumn = options => {
align: 'center',
fixed: 'right',
render: (val, r) => (
<Button key="edit" onClick={() => onEdit(r, 'edit')}>
<Button key="edit" onClick={() => onEdit(r.id)}>
编辑
</Button>
),
......
import React, { useState, useEffect } from 'react';
import { Select, Modal, Table, Input, Button, Pagination, notification } from 'antd';
import { SearchOutlined } from '@ant-design/icons';
import { apiSelGoodsList, apiSelVirtualGoodsList } from '../service';
import { apiSelGoodsList, apiSelVirtualGoodsList, apiShopListByPickSelfID } from '../service';
import { getShopListByPickSelf } from '../service/bll';
import { SelectGoodsColumn, productType } from '../staticData/goods';
import style from '../style/index.less';
......@@ -12,11 +12,12 @@ const SaleDateModal = props => {
const [searchType, setSearchType] = useState('1');
const [searchKeyword, setSearchKeyword] = useState('');
const [goodsType, setGoodsType] = useState('1');
const [shopId, setShopId] = useState('');
const [shopId, setShopId] = useState();
const [searchName, setSearchName] = useState('');
const [loading, setLoading] = useState(false);
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
const [total, setTotal] = useState(0);
const [dataSource, setDataSource] = useState([]);
const [shopList, setShopList] = useState(jsonToArray(productType));
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
......@@ -41,7 +42,7 @@ const SaleDateModal = props => {
data: Object.assign(
{
shopId,
productType,
productType: props.productType,
enterpriseId,
},
searchObj,
......@@ -54,7 +55,11 @@ const SaleDateModal = props => {
api = apiSelVirtualGoodsList;
}
const res = await api(data);
setDataSource(res);
console.log('res :>> ', res);
if (res && res.data && res.data.records) {
setDataSource(res.data.records);
setTotal(res.data.total);
}
setLoading(false);
};
......@@ -84,7 +89,11 @@ const SaleDateModal = props => {
notification.error({ message: '请选择要添加的商品' });
return;
}
props.onSelectChange(deepClone(selectedRows));
const arr = deepClone(selectedRows).map(item => ({
...item,
shopId,
}));
props.onSelectChange(arr);
handleCancel();
};
......@@ -147,11 +156,21 @@ const SaleDateModal = props => {
// 获取店铺列表
const getShopList = async () => {
const res = await getShopListByPickSelf({
const res = await apiShopListByPickSelfID({
enterpriseId: props.enterpriseId,
pickSelfIdList: props.pickSelfIdList,
});
setShopList(res);
if (res && res.data) {
console.log('getShopList res :>> ', res);
setShopList(
res.data.map(item => ({
label: item.name,
value: item.id,
})),
);
// searchList({});
}
// setShopList(res);
};
const rowSelection = {
......@@ -168,7 +187,7 @@ const SaleDateModal = props => {
const selectAfter = <SearchOutlined onClick={onSearch} />;
const footers = () => [
<div className={style.footers}>
<Pagination defaultCurrent={6} total={500} showQuickJumper onChange={onPageChange} />
<Pagination defaultCurrent={1} total={total} showQuickJumper onChange={onPageChange} />
<div className={style['footers-btn']}>
<div className={style['footers-desc']}>
已选商品(<span className={style['footers-num']}>{selectedRows.length}</span>)
......@@ -186,7 +205,6 @@ const SaleDateModal = props => {
useEffect(() => {
getShopList();
setGoodsType(props.productType);
searchList({});
}, []);
return (
......@@ -211,7 +229,7 @@ const SaleDateModal = props => {
<Select
placeholder="请选择商品类型"
disabled
value={goodsType}
value={`${props.productType}`}
options={jsonToArray(productType)}
className={style['select-goods-box--select']}
/>
......@@ -226,6 +244,7 @@ const SaleDateModal = props => {
rowSelection={rowSelection}
rowKey="skuId"
columns={SelectGoodsColumn}
pagination={false}
dataSource={dataSource}
/>
</Modal>
......
......@@ -2,34 +2,64 @@ import debounce from 'lodash/debounce';
import { apiEnterpriseList, apiShopList, apiShopListByPickSelfID } from './index';
// 获取企业列表
export const getEnterpriseList = async (name = '') => {
const res = await apiEnterpriseList({ name });
export const getEnterpriseList = async () => {
const res = await apiEnterpriseList({
page: 1,
size: 10000,
});
if (res && res.data && res.data.records) {
const data = res.data.records;
const json = {};
data.forEach(item => {
json[item.id] = { text: item.name };
});
return {
id: data[data.length - 1].id,
list: json,
};
}
return {
id: res[res.length - 1].id,
list: res.map(item => ({
[item.id]: { text: item.name },
})),
id: '',
list: {},
};
};
// 获取店铺列表
export const getShopList = debounce(async e => {
const { name } = e;
const res = await apiShopList({ name });
if (res && res.data && res.data.records) {
const data = res.data.records;
const json = {};
data.forEach(item => {
json[item.id] = { text: item.name };
});
return {
id: res[res.length - 1].id,
list: json,
};
}
return {
id: res[res.length - 1].id,
list: res.map(item => ({
[item.id]: { text: item.name },
})),
id: '',
list: {},
};
}, 300);
// 获取店铺列表通过自提点ID
export const getShopListByPickSelf = async e => {
const { name } = e;
const res = await apiShopListByPickSelfID({ name });
if (res && res.data && res.data.records) {
const data = res.data.records;
const json = {};
data.forEach(item => {
json[item.id] = { text: item.name };
});
return {
id: res[res.length - 1].id,
list: json,
};
}
return {
id: res[res.length - 1].id,
list: res.map(item => ({
[item.id]: { text: item.name },
})),
id: '',
list: {},
};
};
import request from '@/utils/request';
import config from '@/../config/env.config';
const { kdspApi, goodsApi, apiPrefix } = config;
const { roleApi, apiPrefix } = config;
/**
* 获取企业外卖商品列表
* http://yapi.quantgroups.com/project/389/interface/api/64794
*/
export async function apiTakeawayList(param) {
return request.post(`${apiPrefix}/product/enterprise/main/pageList`, {
const res = await request.post(`${apiPrefix}/product/enterprise/main/pageList`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
return res.data;
}
/**
* 获取企业虚拟商品列表
* http://yapi.quantgroups.com/project/389/interface/api/64794
*/
export async function apiVirtualList(param) {
return request.post('/api/consoles/product/enterprise/virtual/pageList', {
return request.post(`${apiPrefix}/product/enterprise/virtual/pageList`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -27,9 +28,9 @@ export async function apiVirtualList(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65324
*/
export async function apiEnterpriseList(param) {
return request.post('/api/consoles/enterprise/pageList', {
return request.post(`${apiPrefix}/enterprise/pageList`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -37,9 +38,9 @@ export async function apiEnterpriseList(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65289
*/
export async function apiShopList(param) {
return request.post('/api/consoles/shops/getListByName', {
return request.post(`${apiPrefix}/shops/getListByName`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -47,9 +48,9 @@ export async function apiShopList(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65444
*/
export async function apiMealTimePeriod(param) {
return request.post('/api/consoles/product/enterprise/getMealTimePeriod', {
return request.post(`${apiPrefix}/product/enterprise/getMealTimePeriod`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -57,9 +58,9 @@ export async function apiMealTimePeriod(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65099
*/
export async function apiMealInfoUpdate(param) {
return request.post('/api/consoles/product/enterprise/main/update', {
return request.post(`${apiPrefix}/product/enterprise/main/update`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -67,9 +68,9 @@ export async function apiMealInfoUpdate(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65109
*/
export async function apiMealInfoDel(param) {
return request.post('/api/consoles/product/enterprise/main/deleteById', {
return request.post(`${apiPrefix}/product/enterprise/main/deleteById`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -77,8 +78,8 @@ export async function apiMealInfoDel(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65494
*/
export async function apiPickSelfList() {
return request.get('/api/consoles/selfPickUpLocation/list', {
prefix: goodsApi,
return request.get(`${apiPrefix}/selfPickUpLocation/list`, {
prefix: roleApi,
});
}
/**
......@@ -86,9 +87,9 @@ export async function apiPickSelfList() {
* http://yapi.quantgroups.com/project/389/interface/api/65449
*/
export async function apiSelPickSelfList(param) {
return request.post('/api/consoles/product/enterprise/queryByEnterpriseId', {
return request.post(`${apiPrefix}/product/enterprise/queryByEnterpriseId`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -96,9 +97,9 @@ export async function apiSelPickSelfList(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65479
*/
export async function apiSelGoodsList(param) {
return request.post('/api/consoles/product/enterprise/sku/page', {
return request.post(`${apiPrefix}/product/enterprise/sku/page`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -106,9 +107,9 @@ export async function apiSelGoodsList(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65479
*/
export async function apiSelVirtualGoodsList(param) {
return request.post('/api/consoles/product/enterprise/virtual/sku/page', {
return request.post(`${apiPrefix}/product/enterprise/virtual/sku/page`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -116,9 +117,9 @@ export async function apiSelVirtualGoodsList(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65094
*/
export async function apiSaveGoodsList(param) {
return request.post('/api/consoles/product/enterprise/add', {
return request.post(`${apiPrefix}/product/enterprise/add`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -126,9 +127,9 @@ export async function apiSaveGoodsList(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65484
*/
export async function apiSaveVirtualGoodsList(param) {
return request.post('/api/consoles/products/enterprise/virtual/add', {
return request.post(`${apiPrefix}/products/enterprise/virtual/add`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -136,9 +137,9 @@ export async function apiSaveVirtualGoodsList(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65504
*/
export async function apiShopListByEnterpriseID(param) {
return request.post('/api/consoles/product/enterprise/virtual/shops', {
return request.post(`${apiPrefix}/product/enterprise/virtual/shops`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
/**
......@@ -146,8 +147,8 @@ export async function apiShopListByEnterpriseID(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65539
*/
export async function apiShopListByPickSelfID(param) {
return request.post('/api/consoles/product/enterprise/queryByEnterpriseIdAndPickSelfId', {
return request.post(`${apiPrefix}/product/enterprise/queryByEnterpriseIdAndPickSelfId`, {
data: param,
prefix: goodsApi,
prefix: roleApi,
});
}
......@@ -48,6 +48,7 @@ export const takeawayGoodsColumn = options => {
setVisiblePrice,
setVisibleSaleSection,
setVisibleSort,
onChangeEnterprise,
} = options;
return [
{
......@@ -57,6 +58,7 @@ export const takeawayGoodsColumn = options => {
fieldProps: {
showSearch: true,
filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()),
onChange: onChangeEnterprise,
},
valueEnum: enterprises, // companyEnum,
},
......@@ -67,7 +69,7 @@ export const takeawayGoodsColumn = options => {
fieldProps: {
showSearch: true,
},
request: getShopList,
// request: getShopList,
// valueEnum: {}, // shopEnum,
},
{
......@@ -255,7 +257,7 @@ export const GoodsInfoColumn = options => {
},
{
title: '商品售价',
dataIndex: 'price',
dataIndex: 'salePrice',
width: 120,
align: 'center',
},
......@@ -267,9 +269,16 @@ export const GoodsInfoColumn = options => {
},
{
title: '库存',
dataIndex: 'status',
dataIndex: 'stock',
width: 120,
align: 'center',
render(v, record) {
const arr = record.supplierProductItemList;
if (arr && arr.length) {
return arr[0].stock;
}
return '-';
},
},
{
title: '可售日期',
......@@ -324,8 +333,8 @@ export const GoodsInfoColumn = options => {
width: '100px',
align: 'center',
fixed: 'right',
render: (val, r) => (
<Button key="del" onClick={() => onDel(r, 'del')}>
render: (val, r, i) => (
<Button key="del" onClick={() => onDel(i)}>
删除
</Button>
),
......@@ -337,36 +346,43 @@ export const SelectGoodsColumn = [
{
title: '商品ID',
width: 120,
align: 'center',
dataIndex: 'skuId',
},
{
title: '商品名称',
dataIndex: 'skuName',
width: 120,
align: 'center',
},
{
title: '商品编号',
dataIndex: 'skuNo',
width: 120,
align: 'center',
},
// {
// title: '商品编号',
// dataIndex: 'skuNo',
// width: 120,
// align: 'center',
// },
{
title: '销售价',
dataIndex: 'price',
dataIndex: 'salePrice',
width: 120,
align: 'center',
},
{
title: '剩余库存',
dataIndex: 'status',
width: 120,
dataIndex: 'stock',
width: 100,
align: 'center',
render(v, record) {
const arr = record.supplierProductItemList;
if (arr && arr.length) {
return arr[0].stock;
}
return '-';
},
},
{
title: '已参与活动',
dataIndex: 'mealType',
dataIndex: 'activity',
align: 'center',
width: 110,
hideInSearch: true,
},
];
......@@ -19,6 +19,7 @@
text-align: right;
}
&--select {
width: 100%;
min-width: 200px;
}
&--btns {
......
......@@ -6,7 +6,7 @@ import { PlusOutlined } from '@ant-design/icons';
import { takeawayGoodsColumn } from './staticData/goods';
import utilStyle from '@/utils/utils.less';
import { apiTakeawayList, apiSelPickSelfList, apiMealInfoDel, apiMealInfoUpdate } from './service';
import { getEnterpriseList } from './service/bll';
import { getEnterpriseList, getShopList } from './service/bll';
import SaleDateModal from './components/SaleDateModal';
import SaleSectionModal from './components/SaleSectionModal';
import GoodPriceModal from './components/GoodPriceModal';
......@@ -22,9 +22,10 @@ const TakeawayGoods = () => {
const [visibleSaleSection, setVisibleSaleSection] = useState(false); // 可售餐段弹窗
const [visiblePrice, setVisiblePrice] = useState(false); // 修改企业商品价格弹窗
const [visibleSort, setVisibleSort] = useState(false); // 商品排序弹窗
const [enterprises, setEnterprises] = useState([]); // 企业列表
const [enterprises, setEnterprises] = useState({ 1: { text: '领红包' } }); // 企业列表
const [shopEnum, setShopEnum] = useState({}); // 店铺列表
const [activeKey, setActiveKey] = useState('');
const [enterpriseId, setEnterpriseId] = useState('');
const [enterpriseId, setEnterpriseId] = useState('1');
const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表
const [recordID, setRecordID] = useState(''); // 编辑的记录ID
......@@ -36,9 +37,18 @@ const TakeawayGoods = () => {
const data = {
page: params.current,
size: params.pageSize,
data: params,
data: Object.assign(
{
enterpriseId,
},
params,
),
};
const res = await apiTakeawayList(data);
return {
data: res.records,
total: res.total,
};
return apiTakeawayList(data);
};
const onDel = async id => {
await apiMealInfoDel({
......@@ -49,7 +59,14 @@ const TakeawayGoods = () => {
});
};
const onAdd = async () => {
const query = getToUrlQuery();
const params = getToUrlQuery();
const query = Object.assign(
{
id: enterpriseId,
name: enterprises[enterpriseId].text,
},
params,
);
history.push({
pathname: '/takeawayGoodsInfo',
query,
......@@ -65,45 +82,64 @@ const TakeawayGoods = () => {
notification.success({ message: '保存成功' });
};
const options = {
setVisibleSaleDate,
setVisibleSaleSection,
setVisiblePrice,
setVisibleSort,
onDel,
setRecordID,
enterprises,
onChangeFlag,
// 根据企业ID获取取餐点
const getPickSelf = async id => {
const res = await apiSelPickSelfList({ enterpriseId: id });
if (res) {
setPickSelfList(
res.map(item => ({
key: item.pickSelfId,
label: <span>{item.pickSelfName}</span>,
})),
);
setActiveKey(res[0].pickSelfId);
}
};
// 根据企业ID获取取餐点
const getPickSelf = async () => {
const res = await apiSelPickSelfList({});
setPickSelfList(
res.map(item => ({
key: item.pickSelfId,
label: <span>{item.pickSelfName}</span>,
})),
);
setActiveKey(res[0].pickSelfId);
// const getShops = async () => {
// const res = await getShopList({});
// setShopEnum(res.list);
// };
// 改变企业
const onChangeEnterprise = v => {
setEnterpriseId(v);
getPickSelf(v);
};
// 获取企业列表
const getList = async name => {
const obj = await getEnterpriseList(name);
setEnterprises(obj.list);
setEnterpriseId(obj.id);
getPickSelf(obj.id);
setPageLoading(true);
const getList = async () => {
const obj = await getEnterpriseList();
if (obj.list && Object.keys(obj.list).length) {
setEnterprises(obj.list);
setEnterpriseId(obj.id);
getPickSelf(obj.id);
setPageLoading(true);
}
};
useEffect(() => {
getList('');
getList();
// getShops();
// setTimeout(() => {
// // refTable.current.reload();
// }, 1000);
}, []);
const options = {
setVisibleSaleDate,
setVisibleSaleSection,
setVisiblePrice,
setVisibleSort,
onDel,
setRecordID,
enterprises,
onChangeEnterprise,
onChangeFlag,
shopEnum,
};
return (
<div>
{pageLoading && (
......
......@@ -11,7 +11,7 @@ import { apiSelPickSelfList, apiPickSelfList, apiSaveGoodsList } from './service
import style from './style/index.less';
const TakeawayGoodsInfo = props => {
const { id } = props.location.query;
const { id, name } = props.location.query;
const history = useHistory();
const [loading, setLoading] = useState(false);
const [visibleSaleDate, setVisibleSaleDate] = useState(false); // 可售日期弹窗
......@@ -51,31 +51,31 @@ const TakeawayGoodsInfo = props => {
// 删除
const onDel = i => {
const arr = dataSource.splice(i, 1);
const arr = [...dataSource];
arr.splice(i, 1);
setDataSource(arr);
};
// 根据企业ID获取取餐点
const getPickSelf = async () => {
const res = await apiPickSelfList();
setPickSelfList(
res.map(item => ({
key: item.pickSelfId,
label: <span>{item.pickSelfName}</span>,
})),
);
if (res && res.data && res.data.records) {
setPickSelfList(
res.data.records.map(item => ({
value: item.id,
label: item.pickselfName,
})),
);
}
};
// 根据企业ID获取已选取餐点
const getSelPickSelf = async () => {
const res = await apiSelPickSelfList({
enterpriseId: id,
});
setSelPickSelf(
res.map(item => ({
key: item.pickSelfId,
label: <span>{item.pickSelfName}</span>,
})),
);
if (res && res.data) {
setSelPickSelf(res.map(item => item.pickSelfId));
}
};
// 刷新列表数据
......@@ -93,6 +93,15 @@ const TakeawayGoodsInfo = props => {
setDataSource(arr);
};
// 显示选择商品弹窗
const onShowSelect = () => {
if (!slePickSelf || slePickSelf.length < 1) {
message.error('请选择取餐点!');
return;
}
setVisibleSelectGoods(true);
};
// const initData = async () => {
// setLoading(true);
// };
......@@ -116,7 +125,7 @@ const TakeawayGoodsInfo = props => {
<Col span={3} className={style['info-box--label']}>
企业名称:
</Col>
<Col span={20}>企业名称111</Col>
<Col span={20}>{name}</Col>
</Row>
<Row className={style['info-box--line']}>
<Col span={3} className={style['info-box--label']}>
......@@ -129,6 +138,7 @@ const TakeawayGoodsInfo = props => {
options={pickSelfList}
className={style['info-box--select']}
placeholder="清选择"
value={slePickSelf}
onChange={setSelPickSelf}
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
......@@ -141,7 +151,7 @@ const TakeawayGoodsInfo = props => {
添加商品:
</Col>
<Col span={20}>
<Button type="primary" onClick={() => setVisibleSelectGoods(true)}>
<Button type="primary" onClick={() => onShowSelect()}>
选择商品
</Button>
</Col>
......@@ -203,6 +213,9 @@ const TakeawayGoodsInfo = props => {
{visibleSelectGoods && (
<SelectGoodsModal
visible={visibleSelectGoods}
enterpriseId={id}
productType={5}
pickSelfIdList={slePickSelf}
onSelectChange={setDataSource}
handleClose={() => setVisibleSelectGoods(false)}
/>
......
......@@ -188,7 +188,7 @@ export const getUrlParams = name => {
return null;
};
// 获取地址栏所参数
// 获取地址栏所参数
export const getUrlSearchParams = () => {
const newObj = {};
const url = window.location.search; // 获取url中"?"符后的字符串
......@@ -212,11 +212,13 @@ export const getToken = () => {
// 获取跳转参数
export const getToUrlQuery = () => {
const params = getUrlSearchParams();
// 从消费地图后管过来
if (getUrlParams('source') === 'tob' && localStorage.get('tobToken')) {
if (params.source) {
return {
source: 'tob',
token: localStorage.get('tobToken'),
source: params.source,
token: params.token,
isMaster: params.isMaster,
};
}
return {};
......
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