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

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

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