Commit 97e42a3b authored by 武广's avatar 武广

fix: 修改获取企业餐段问题

parent 10f7fb21
......@@ -65,7 +65,7 @@ export const takeawayGoodsColumn = options => {
hideInTable: true,
valueType: 'select',
fieldProps: {
value: +enterpriseId,
value: enterpriseId ? +enterpriseId : null,
showSearch: true,
filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()),
onChange: onChangeEnterprise,
......@@ -484,7 +484,7 @@ export const virtualGoodsColumn = options => {
hideInTable: true,
valueType: 'select',
fieldProps: {
value: +enterpriseId,
value: enterpriseId ? +enterpriseId : null,
showSearch: true,
filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()),
onChange: onChangeEnterprise,
......
......@@ -27,9 +27,9 @@ 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(null); // 企业列表
const [activeKey, setActiveKey] = useState(''); // 自提点ID
const [enterpriseId, setEnterpriseId] = useState(); // 企业ID
const [enterpriseId, setEnterpriseId] = useState(''); // 企业ID
const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表
const [recordID, setRecordID] = useState(''); // 编辑的记录ID
const [editItem, setEditItem] = useState({}); // 编辑的记录信息
......@@ -137,8 +137,10 @@ const TakeawayGoods = () => {
setEnterprises(obj.list);
setEnterpriseId(`${obj.id}`);
await getPickSelf(obj.id);
setPageLoaded(true);
} else if (!enterpriseId) {
notification.error({ message: '未找到企业' });
}
setPageLoaded(true);
};
useEffect(() => {
......@@ -160,6 +162,14 @@ const TakeawayGoods = () => {
onRefresh,
};
let request = () => ({
data: [],
total: 0,
});
if (enterpriseId) {
request = params => searchList({ ...params });
}
return (
<div className={utilStyle.formPageBox}>
{pageLoaded && (
......@@ -173,7 +183,7 @@ const TakeawayGoods = () => {
actionRef={refTable}
tableClassName={utilStyle.formTable}
columns={takeawayGoodsColumn(options)}
request={params => searchList({ ...params })}
request={request}
rowKey={r => r.id}
bordered
options={false}
......
......@@ -14,8 +14,8 @@ const VirtualGoods = () => {
const history = useHistory();
const refTable = useRef();
const [pageLoaded, setPageLoaded] = useState(false);
const [enterprises, setEnterprises] = useState({}); // 企业列表
const [enterpriseId, setEnterpriseId] = useState();
const [enterprises, setEnterprises] = useState(null); // 企业列表
const [enterpriseId, setEnterpriseId] = useState(''); // 选中企业ID
// 刷新列表
const onRefresh = () => {
......@@ -90,8 +90,10 @@ const VirtualGoods = () => {
if (obj.list && Object.keys(obj.list).length) {
setEnterprises(obj.list);
setEnterpriseId(`${obj.id}`);
setPageLoaded(true);
} else if (!enterpriseId) {
notification.error({ message: '未找到企业' });
}
setPageLoaded(true);
};
useEffect(() => {
......@@ -105,7 +107,10 @@ const VirtualGoods = () => {
onChangeEnterprise,
};
let request = () => [];
let request = () => ({
data: [],
total: 0,
});
if (enterpriseId) {
request = params => searchList({ ...params });
}
......
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