Commit 1515ae21 authored by 武广's avatar 武广

fix: 修改虚拟商品切换店铺没有清空问题

parent 9da949ff
...@@ -193,8 +193,12 @@ const SaleDateModal = props => { ...@@ -193,8 +193,12 @@ const SaleDateModal = props => {
onSelect: onSelectChange, onSelect: onSelectChange,
onSelectAll: onSelectAllChange, onSelectAll: onSelectAllChange,
}; };
const onChangeSearchType = v => {
setSearchType(v);
setSearchName('');
};
const selectBefore = ( const selectBefore = (
<Select defaultValue="1" onChange={setSearchType}> <Select defaultValue="1" onChange={onChangeSearchType}>
<Option value="1" key={1}> <Option value="1" key={1}>
名称 名称
</Option> </Option>
...@@ -264,7 +268,11 @@ const SaleDateModal = props => { ...@@ -264,7 +268,11 @@ const SaleDateModal = props => {
<Input <Input
addonBefore={selectBefore} addonBefore={selectBefore}
addonAfter={selectAfter} addonAfter={selectAfter}
value={searchName}
allowClear
type={+searchType === 2 ? 'number' : 'text'}
onChange={e => setSearchName(e.target.value)} onChange={e => setSearchName(e.target.value)}
onPressEnter={onSearch}
className={style['select-goods-box--txt']} className={style['select-goods-box--txt']}
/> />
</div> </div>
......
...@@ -9,18 +9,19 @@ export const getEnterpriseList = async (param = {}) => { ...@@ -9,18 +9,19 @@ export const getEnterpriseList = async (param = {}) => {
}); });
if (res && res.data && res.data.records) { if (res && res.data && res.data.records) {
const data = res.data.records; const data = res.data.records;
const json = {}; const arr = data.map(item => ({
data.forEach(item => { label: item.name,
json[item.id] = { text: item.name }; value: item.id,
}); key: item.id,
}));
return { return {
id: data[data.length - 1].id, id: data[0].id,
list: json, list: arr,
}; };
} }
return { return {
id: '', id: '',
list: {}, list: [],
}; };
}; };
// 获取店铺列表 // 获取店铺列表
...@@ -57,3 +58,15 @@ export const getShopListByPickSelf = async e => { ...@@ -57,3 +58,15 @@ export const getShopListByPickSelf = async e => {
list: {}, list: {},
}; };
}; };
// 获取店铺名称
export const getEnterpriseName = (arr, id) => {
let name = '';
if (arr && arr.length) {
arr.forEach(item => {
if (+item.value === +id) {
name = item.label;
}
});
}
return name;
};
...@@ -8,7 +8,7 @@ export const layout = { ...@@ -8,7 +8,7 @@ export const layout = {
labelCol: { span: 4 }, labelCol: { span: 4 },
wrapperCol: { span: 18 }, wrapperCol: { span: 18 },
}; };
// 0-推荐 1-早餐 2-午餐 3-下午茶 4-晚餐 // 餐段 0-推荐 1-早餐 2-午餐 3-下午茶 4-晚餐
export const mealColumn = { export const mealColumn = {
// 0: '推荐', // 0: '推荐',
1: '早餐', 1: '早餐',
...@@ -43,12 +43,14 @@ export const weekOptions = { ...@@ -43,12 +43,14 @@ export const weekOptions = {
7: '周日', 7: '周日',
}; };
// 外卖商品列表字段
export const takeawayGoodsColumn = options => { export const takeawayGoodsColumn = options => {
const { const {
onDel, onDel,
onChangeFlag, onChangeFlag,
setVisibleSaleDate, setVisibleSaleDate,
enterprises, enterprises,
enterpriseId,
setRecordID, setRecordID,
setEditItem, setEditItem,
setVisiblePrice, setVisiblePrice,
...@@ -61,12 +63,15 @@ export const takeawayGoodsColumn = options => { ...@@ -61,12 +63,15 @@ export const takeawayGoodsColumn = options => {
title: '企业名称', title: '企业名称',
dataIndex: 'enterpriseId', dataIndex: 'enterpriseId',
hideInTable: true, hideInTable: true,
valueType: 'select',
fieldProps: { fieldProps: {
value: +enterpriseId,
showSearch: true, showSearch: true,
filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()), filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()),
onChange: onChangeEnterprise, onChange: onChangeEnterprise,
options: enterprises,
allowClear: false,
}, },
valueEnum: enterprises,
}, },
{ {
title: '微店名称', title: '微店名称',
...@@ -80,6 +85,12 @@ export const takeawayGoodsColumn = options => { ...@@ -80,6 +85,12 @@ export const takeawayGoodsColumn = options => {
request: getShopList, request: getShopList,
valueEnum: {}, valueEnum: {},
}, },
{
title: '微店名称',
dataIndex: 'shopName',
hideInSearch: true,
align: 'center',
},
{ {
title: 'SKU编码', title: 'SKU编码',
dataIndex: 'skuId', dataIndex: 'skuId',
...@@ -268,6 +279,7 @@ export const takeawayGoodsColumn = options => { ...@@ -268,6 +279,7 @@ export const takeawayGoodsColumn = options => {
]; ];
}; };
// 添加商品列表字段
export const GoodsInfoColumn = options => { export const GoodsInfoColumn = options => {
const { const {
onDel, onDel,
...@@ -299,8 +311,9 @@ export const GoodsInfoColumn = options => { ...@@ -299,8 +311,9 @@ export const GoodsInfoColumn = options => {
align: 'center', align: 'center',
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
<span>{_}</span> <span key="1">{_}</span>
<span <span
key="2"
className={style.columnBtnEdit} className={style.columnBtnEdit}
onClick={() => { onClick={() => {
setEditItem(record); setEditItem(record);
...@@ -336,17 +349,18 @@ export const GoodsInfoColumn = options => { ...@@ -336,17 +349,18 @@ export const GoodsInfoColumn = options => {
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
{_ && _.length ? ( {_ && _.length ? (
<div> <div key="1">
{_.length === 7 ? ( {_.length === 7 ? (
'不限制' '不限制'
) : ( ) : (
<span>{_.map(item => weekOptions[item]).join('/')}</span> <span key="3">{_.map(item => weekOptions[item]).join('/')}</span>
)} )}
</div> </div>
) : ( ) : (
<span>-</span> <span key="2">-</span>
)} )}
<span <span
key="4"
className={style.columnBtnEdit} className={style.columnBtnEdit}
onClick={() => { onClick={() => {
setEditItem(record); setEditItem(record);
...@@ -366,11 +380,14 @@ export const GoodsInfoColumn = options => { ...@@ -366,11 +380,14 @@ export const GoodsInfoColumn = options => {
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
{_ && _.length ? ( {_ && _.length ? (
<span>{_.map(item => mealColumn[item]).join('/')}</span> <span key="1">{_.map(item => mealColumn[item]).join('/')}</span>
) : ( ) : (
<span className={style.columnTip}>请配置</span> <span key="2" className={style.columnTip}>
请配置
</span>
)} )}
<span <span
key="3"
className={style.columnBtnEdit} className={style.columnBtnEdit}
onClick={() => { onClick={() => {
setEditItem(record); setEditItem(record);
...@@ -411,6 +428,7 @@ export const GoodsInfoColumn = options => { ...@@ -411,6 +428,7 @@ export const GoodsInfoColumn = options => {
]; ];
}; };
// 选择商品弹窗字段
export const SelectGoodsColumn = [ export const SelectGoodsColumn = [
{ {
title: '商品ID', title: '商品ID',
...@@ -458,18 +476,21 @@ export const SelectGoodsColumn = [ ...@@ -458,18 +476,21 @@ export const SelectGoodsColumn = [
// 企业虚拟商品列表字段 // 企业虚拟商品列表字段
export const virtualGoodsColumn = options => { export const virtualGoodsColumn = options => {
const { onDel, enterprises, onChangeEnterprise } = options; const { onDel, enterprises, enterpriseId, onChangeEnterprise } = options;
return [ return [
{ {
title: '企业名称', title: '企业名称',
dataIndex: 'enterpriseId', dataIndex: 'enterpriseId',
hideInTable: true, hideInTable: true,
valueType: 'select',
fieldProps: { fieldProps: {
value: +enterpriseId,
showSearch: true, showSearch: true,
filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()), filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()),
onChange: onChangeEnterprise, onChange: onChangeEnterprise,
options: enterprises,
allowClear: false,
}, },
valueEnum: enterprises, // companyEnum,
}, },
{ {
title: '微店名称', title: '微店名称',
...@@ -483,6 +504,12 @@ export const virtualGoodsColumn = options => { ...@@ -483,6 +504,12 @@ export const virtualGoodsColumn = options => {
request: getShopList, request: getShopList,
valueEnum: {}, // shopEnum, valueEnum: {}, // shopEnum,
}, },
{
title: '微店名称',
dataIndex: 'shopName',
hideInSearch: true,
align: 'center',
},
{ {
title: 'SKU编码', title: 'SKU编码',
dataIndex: 'skuId', dataIndex: 'skuId',
...@@ -582,6 +609,13 @@ export const virtualGoodsColumn = options => { ...@@ -582,6 +609,13 @@ export const virtualGoodsColumn = options => {
return record.createDate; return record.createDate;
}, },
}, },
{
title: '可售餐段',
dataIndex: 'tabId',
align: 'center',
valueEnum: mealColumn,
hideInTable: true,
},
{ {
title: '操作', title: '操作',
hideInSearch: true, hideInSearch: true,
......
...@@ -39,7 +39,17 @@ ...@@ -39,7 +39,17 @@
width: 200px; width: 200px;
} }
.select-goods-box--txt { .select-goods-box--txt {
width: 260px; width: 300px;
:global {
.ant-input::-webkit-inner-spin-button,
.ant-input::-webkit-outer-spin-button {
margin: 0;
-webkit-appearance: none;
}
.ant-input {
-webkit-appearance: textfield;
}
}
} }
} }
.footers { .footers {
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
apiTakeawayGoodsDel, apiTakeawayGoodsDel,
apiMealInfoUpdate, apiMealInfoUpdate,
} from './service'; } from './service';
import { getEnterpriseList } from './service/bll'; import { getEnterpriseList, getEnterpriseName } from './service/bll';
import SaleDateModal from './components/SaleDateModal'; import SaleDateModal from './components/SaleDateModal';
import SaleSectionModal from './components/SaleSectionModal'; import SaleSectionModal from './components/SaleSectionModal';
import GoodPriceModal from './components/GoodPriceModal'; import GoodPriceModal from './components/GoodPriceModal';
...@@ -85,7 +85,7 @@ const TakeawayGoods = () => { ...@@ -85,7 +85,7 @@ const TakeawayGoods = () => {
const query = Object.assign( const query = Object.assign(
{ {
id: enterpriseId, id: enterpriseId,
name: enterprises[enterpriseId].text, name: getEnterpriseName(enterprises, enterpriseId),
}, },
params, params,
); );
...@@ -160,6 +160,7 @@ const TakeawayGoods = () => { ...@@ -160,6 +160,7 @@ const TakeawayGoods = () => {
onDel, onDel,
setRecordID, setRecordID,
setEditItem, setEditItem,
enterpriseId,
enterprises, enterprises,
onChangeEnterprise, onChangeEnterprise,
onChangeFlag, onChangeFlag,
......
...@@ -6,7 +6,7 @@ import { PlusOutlined } from '@ant-design/icons'; ...@@ -6,7 +6,7 @@ import { PlusOutlined } from '@ant-design/icons';
import { virtualGoodsColumn } from './staticData/goods'; import { virtualGoodsColumn } from './staticData/goods';
import utilStyle from '@/utils/utils.less'; import utilStyle from '@/utils/utils.less';
import { apiVirtualList, apiVirtualGoodsDel } from './service'; import { apiVirtualList, apiVirtualGoodsDel } from './service';
import { getEnterpriseList } from './service/bll'; import { getEnterpriseList, getEnterpriseName } from './service/bll';
import { getToUrlQuery } from '@/utils/utils'; import { getToUrlQuery } from '@/utils/utils';
// 企业虚拟商品 // 企业虚拟商品
...@@ -67,7 +67,7 @@ const VirtualGoods = () => { ...@@ -67,7 +67,7 @@ const VirtualGoods = () => {
const query = Object.assign( const query = Object.assign(
{ {
id: enterpriseId, id: enterpriseId,
name: enterprises[enterpriseId].text, name: getEnterpriseName(enterprises, enterpriseId),
}, },
params, params,
); );
...@@ -101,6 +101,7 @@ const VirtualGoods = () => { ...@@ -101,6 +101,7 @@ const VirtualGoods = () => {
const options = { const options = {
onDel, onDel,
enterprises, enterprises,
enterpriseId,
onChangeEnterprise, onChangeEnterprise,
}; };
......
...@@ -135,6 +135,8 @@ const VirtualGoodsInfo = props => { ...@@ -135,6 +135,8 @@ const VirtualGoodsInfo = props => {
}), }),
); );
setSelectedRowKeys(keys); setSelectedRowKeys(keys);
} else {
setDataSource([]);
} }
}; };
...@@ -212,7 +214,7 @@ const VirtualGoodsInfo = props => { ...@@ -212,7 +214,7 @@ const VirtualGoodsInfo = props => {
</Row> </Row>
<Row className={style['info-box--line']}> <Row className={style['info-box--line']}>
<Col span={24}> <Col span={24}>
<Table columns={GoodsInfoColumn(options)} dataSource={dataSource} /> <Table rowKey="skuId" columns={GoodsInfoColumn(options)} dataSource={dataSource} />
</Col> </Col>
</Row> </Row>
<Row className={style['info-box--btns']}> <Row className={style['info-box--btns']}>
......
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