Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
merchant-manage-ui
Commits
6dc8ec9b
Commit
6dc8ec9b
authored
Jun 13, 2023
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改虚拟商品列表逻辑
parent
81e54fd6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
230 additions
and
163 deletions
+230
-163
bll.js
src/pages/businessGoods/service/bll.js
+12
-14
goods.js
src/pages/businessGoods/staticData/goods.js
+134
-4
takeawayGoods.jsx
src/pages/businessGoods/takeawayGoods.jsx
+2
-2
takeawayGoodsInfo.jsx
src/pages/businessGoods/takeawayGoodsInfo.jsx
+1
-0
virtualGoods.jsx
src/pages/businessGoods/virtualGoods.jsx
+65
-116
virtualGoodsInfo.jsx
src/pages/businessGoods/virtualGoodsInfo.jsx
+16
-27
No files found.
src/pages/businessGoods/service/bll.js
View file @
6dc8ec9b
...
...
@@ -25,23 +25,21 @@ export const getEnterpriseList = async () => {
};
// 获取店铺列表
export
const
getShopList
=
debounce
(
async
e
=>
{
const
{
name
}
=
e
;
const
res
=
await
apiShopList
({
name
});
const
res
=
await
apiShopList
({
name
:
e
});
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
,
};
// const json = {};
// data.forEach(item => {
// json[item.id] = { text: item.name };
// });
// return json;
return
data
.
map
(
item
=>
({
value
:
item
.
id
,
text
:
item
.
name
,
}));
}
return
{
id
:
''
,
list
:
{},
};
// return {};
return
[];
},
300
);
// 获取店铺列表通过自提点ID
export
const
getShopListByPickSelf
=
async
e
=>
{
...
...
src/pages/businessGoods/staticData/goods.js
View file @
6dc8ec9b
...
...
@@ -72,11 +72,13 @@ export const takeawayGoodsColumn = options => {
title
:
'
微店名称
'
,
dataIndex
:
'
shopId
'
,
hideInTable
:
true
,
// fieldProps: {
// showSearch: true,
// },
fieldProps
:
{
showSearch
:
true
,
filterOption
:
false
,
onSearch
:
getShopList
,
},
// request: getShopList,
//
valueEnum: {}, // shopEnum,
valueEnum
:
{},
// shopEnum,
},
{
title
:
'
SKU编码
'
,
...
...
@@ -413,3 +415,131 @@ export const SelectGoodsColumn = [
hideInSearch
:
true
,
},
];
// 企业虚拟商品列表字段
export
const
virtualGoodsColumn
=
options
=>
{
const
{
onDel
,
enterprises
,
onChangeEnterprise
}
=
options
;
return
[
{
title
:
'
企业名称
'
,
dataIndex
:
'
enterpriseId
'
,
hideInTable
:
true
,
fieldProps
:
{
showSearch
:
true
,
filterOption
:
(
v
,
option
)
=>
(
option
?.
label
??
''
).
toLowerCase
().
includes
(
v
.
toLowerCase
()),
onChange
:
onChangeEnterprise
,
},
valueEnum
:
enterprises
,
// companyEnum,
},
{
title
:
'
微店名称
'
,
dataIndex
:
'
shopId
'
,
hideInTable
:
true
,
fieldProps
:
{
showSearch
:
true
,
filterOption
:
false
,
onSearch
:
getShopList
,
},
// request: getShopList,
valueEnum
:
{},
// shopEnum,
},
{
title
:
'
SKU编码
'
,
dataIndex
:
'
skuId
'
,
width
:
160
,
align
:
'
center
'
,
},
{
title
:
'
商品名称
'
,
dataIndex
:
'
skuName
'
,
align
:
'
center
'
,
},
{
title
:
'
商品图片
'
,
dataIndex
:
'
primaryImage
'
,
width
:
80
,
align
:
'
center
'
,
hideInSearch
:
true
,
valueType
:
'
image
'
,
},
{
title
:
'
可售日期
'
,
dataIndex
:
'
saleTimeType
'
,
width
:
120
,
align
:
'
center
'
,
hideInSearch
:
true
,
render
:
(
_
,
record
)
=>
<
span
>
{
_
}
<
/span>
,
},
{
title
:
'
可售餐段
'
,
dataIndex
:
'
tabCateList
'
,
width
:
120
,
align
:
'
center
'
,
hideInSearch
:
true
,
render
:
(
_
,
record
)
=>
(
<
Space
>
{
_
&&
_
.
length
&&
<
span
>
{
_
.
map
(
item
=>
item
.
tabName
).
join
(
'
/
'
)}
<
/span>}</
Space
>
),
},
{
title
:
'
企业价格
'
,
dataIndex
:
'
activityPrice
'
,
width
:
100
,
align
:
'
center
'
,
hideInSearch
:
true
,
render
:
(
_
,
record
)
=>
(
<
Space
>
<
span
>
{
_
}
<
/span
>
<
/Space
>
),
},
{
title
:
'
商品销售价
'
,
dataIndex
:
'
price
'
,
width
:
100
,
align
:
'
center
'
,
hideInSearch
:
true
,
},
{
title
:
'
状态
'
,
dataIndex
:
'
status
'
,
width
:
80
,
align
:
'
center
'
,
hideInSearch
:
true
,
valueEnum
:
{
1
:
'
生效中
'
,
2
:
'
已下架
'
,
3
:
'
已售罄
'
,
},
},
{
title
:
'
餐品类型
'
,
dataIndex
:
'
mealType
'
,
width
:
80
,
align
:
'
center
'
,
hideInSearch
:
true
,
},
{
title
:
'
添加时间
'
,
dataIndex
:
'
createDate
'
,
width
:
120
,
valueType
:
'
dateRange
'
,
align
:
'
center
'
,
render
(
v
,
record
)
{
return
record
.
createDate
;
},
},
{
title
:
'
操作
'
,
hideInSearch
:
true
,
dataIndex
:
'
action
'
,
width
:
'
100px
'
,
align
:
'
center
'
,
fixed
:
'
right
'
,
render
:
(
val
,
r
)
=>
(
<
Button
key
=
"
del
"
onClick
=
{()
=>
onDel
(
r
.
id
)}
>
删除
<
/Button
>
),
},
];
};
src/pages/businessGoods/takeawayGoods.jsx
View file @
6dc8ec9b
...
...
@@ -70,7 +70,7 @@ const TakeawayGoods = () => {
});
};
// 跳转添加商品
const
on
Add
=
async
()
=>
{
const
to
Add
=
async
()
=>
{
const
params
=
getToUrlQuery
();
const
query
=
Object
.
assign
(
{
...
...
@@ -184,7 +184,7 @@ const TakeawayGoods = () => {
},
},
actions
:
[
<
Button
key=
"1"
icon=
{
<
PlusOutlined
/>
}
type=
"primary"
onClick=
{
on
Add
}
>
<
Button
key=
"1"
icon=
{
<
PlusOutlined
/>
}
type=
"primary"
onClick=
{
to
Add
}
>
添加外卖商品
</
Button
>,
],
...
...
src/pages/businessGoods/takeawayGoodsInfo.jsx
View file @
6dc8ec9b
...
...
@@ -235,6 +235,7 @@ const TakeawayGoodsInfo = props => {
enterpriseId=
{
id
}
productType=
{
5
}
pickSelfIdList=
{
slePickSelf
}
shopID=
{
shopId
}
onChangeShop=
{
setShopId
}
onSelectChange=
{
setDataSource
}
handleClose=
{
()
=>
setVisibleSelectGoods
(
false
)
}
...
...
src/pages/businessGoods/virtualGoods.jsx
View file @
6dc8ec9b
...
...
@@ -3,112 +3,105 @@ import { useHistory } from 'react-router-dom';
import
{
ProTable
}
from
'
@ant-design/pro-components
'
;
import
{
Button
,
notification
}
from
'
antd
'
;
import
{
PlusOutlined
}
from
'
@ant-design/icons
'
;
import
{
takeaway
GoodsColumn
}
from
'
./staticData/goods
'
;
import
{
virtual
GoodsColumn
}
from
'
./staticData/goods
'
;
import
utilStyle
from
'
@/utils/utils.less
'
;
import
{
apiVirtualList
,
apiSelPickSelfList
,
apiMealInfoDel
,
apiMealInfoUpdate
}
from
'
./service
'
;
import
{
getEnterpriseList
}
from
'
./service/bll
'
;
import
SaleDateModal
from
'
./components/SaleDateModal
'
;
import
SaleSectionModal
from
'
./components/SaleSectionModal
'
;
import
GoodPriceModal
from
'
./components/GoodPriceModal
'
;
import
GoodSortModal
from
'
./components/GoodSortModal
'
;
import
{
apiVirtualList
,
apiSelPickSelfList
,
apiMealInfoDel
}
from
'
./service
'
;
import
{
getEnterpriseList
,
getShopList
}
from
'
./service/bll
'
;
import
{
getToUrlQuery
}
from
'
@/utils/utils
'
;
// 企业虚拟商品
const
VirtualGoods
=
()
=>
{
const
history
=
useHistory
();
const
refTable
=
useRef
();
const
[
pageLoading
,
setPageLoading
]
=
useState
(
true
);
// 可售日期弹窗
const
[
visibleSaleDate
,
setVisibleSaleDate
]
=
useState
(
false
);
// 可售日期弹窗
const
[
visibleSaleSection
,
setVisibleSaleSection
]
=
useState
(
false
);
// 可售餐段弹窗
const
[
visiblePrice
,
setVisiblePrice
]
=
useState
(
false
);
// 修改企业商品价格弹窗
const
[
visibleSort
,
setVisibleSort
]
=
useState
(
false
);
// 商品排序弹窗
const
[
enterprises
,
setEnterprises
]
=
useState
([]);
// 企业列表
const
[
pageLoaded
,
setPageLoaded
]
=
useState
(
false
);
const
[
enterprises
,
setEnterprises
]
=
useState
({});
// 企业列表
const
[
activeKey
,
setActiveKey
]
=
useState
(
''
);
const
[
enterpriseId
,
setEnterpriseId
]
=
useState
(
''
);
const
[
pickSelfList
,
setPickSelfList
]
=
useState
([]);
// 取餐点列表
const
[
recordID
,
setRecordID
]
=
useState
(
''
);
// 编辑的记录ID
const
[
enterpriseId
,
setEnterpriseId
]
=
useState
();
// 刷新列表
// const onRefresh = () => {
// if (pageLoaded) {
// refTable.current.reloadAndRest();
// // refTable.current.reload();
// }
// };
// 搜索商品列表
const
searchList
=
async
params
=>
{
if
(
params
.
enterpriseId
&&
params
.
enterpriseId
!==
enterpriseId
)
{
setEnterpriseId
(
params
.
enterpriseId
);
const
data
=
{
page
:
params
.
current
||
1
,
size
:
params
.
pageSize
||
10
,
data
:
Object
.
assign
({},
params
,
{
enterpriseId
,
pickSelfId
:
activeKey
,
}),
};
const
res
=
await
apiVirtualList
(
data
);
if
(
res
&&
res
.
records
)
{
return
{
data
:
res
.
records
||
[],
total
:
res
.
total
||
0
,
};
}
// const data = {
// page: params.current,
// size: params.pageSize,
// data: params,
// };
// return apiVirtualList(data);
return
{
data
:
[],
total
:
0
,
};
};
// 删除商品
const
onDel
=
async
id
=>
{
await
apiMealInfoDel
({
id
,
});
refTable
.
current
.
reload
();
notification
.
success
({
message
:
'
删除成功
'
,
});
};
const
onAdd
=
async
()
=>
{
const
query
=
getToUrlQuery
();
// 跳转添加商品
const
toAdd
=
async
()
=>
{
const
params
=
getToUrlQuery
();
const
query
=
Object
.
assign
(
{
id
:
enterpriseId
,
name
:
enterprises
[
enterpriseId
].
text
,
},
params
,
);
history
.
push
({
pathname
:
'
/takeawayGoodsInfo
'
,
query
,
});
};
const
onChangeFlag
=
async
(
id
,
checked
)
=>
{
const
params
=
{
id
,
showFlag
:
checked
?
1
:
0
,
};
await
apiMealInfoUpdate
(
params
);
notification
.
success
({
message
:
'
保存成功
'
});
};
const
options
=
{
setVisibleSaleDate
,
setVisibleSaleSection
,
setVisiblePrice
,
setVisibleSort
,
onDel
,
setRecordID
,
enterprises
,
onChangeFlag
,
};
// 根据企业ID获取取餐点
const
getPickSelf
=
async
()
=>
{
const
res
=
await
apiSelPickSelfList
({});
if
(
res
&&
res
.
data
)
{
setPickSelfList
(
res
.
data
.
map
(
item
=>
({
key
:
item
.
pickSelfId
,
label
:
<
span
>
{
item
.
pickSelfName
}
</
span
>,
})),
);
setActiveKey
(
res
.
data
[
0
].
pickSelfId
);
}
// 改变企业
const
onChangeEnterprise
=
v
=>
{
setEnterpriseId
(
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
}
`
);
setPageLoaded
(
true
);
}
};
useEffect
(()
=>
{
getList
(
''
);
// setTimeout(() => {
// // refTable.current.reload();
// }, 1000);
getList
();
},
[]);
const
options
=
{
onDel
,
enterprises
,
onChangeEnterprise
,
};
return
(
<
div
className=
{
utilStyle
.
formPageBox
}
>
{
pageLoad
ing
&&
(
{
pageLoad
ed
&&
(
<
ProTable
search=
{
{
span
:
6
,
...
...
@@ -118,7 +111,7 @@ const VirtualGoods = () => {
}
}
actionRef=
{
refTable
}
tableClassName=
{
utilStyle
.
formTable
}
columns=
{
takeaway
GoodsColumn
(
options
)
}
columns=
{
virtual
GoodsColumn
(
options
)
}
request=
{
params
=>
searchList
({
...
params
})
}
rowKey=
{
r
=>
r
.
id
}
expandIconColumnIndex=
{
10
}
...
...
@@ -126,59 +119,15 @@ const VirtualGoods = () => {
options=
{
false
}
form=
{
{
initialValues
:
{
enterpriseId
}
}
}
toolbar=
{
{
menu
:
{
type
:
'
tab
'
,
activeKey
,
items
:
pickSelfList
,
onChange
:
key
=>
{
setActiveKey
(
key
);
},
},
actions
:
[
<
Button
key=
"1"
icon=
{
<
PlusOutlined
/>
}
type=
"primary"
onClick=
{
on
Add
}
>
添加
外卖
商品
<
Button
key=
"1"
icon=
{
<
PlusOutlined
/>
}
type=
"primary"
onClick=
{
to
Add
}
>
添加
虚拟
商品
</
Button
>,
],
}
}
scroll=
{
{
x
:
'
100%
'
,
y
:
400
}
}
/>
)
}
{
/* 可售日期弹窗 */
}
{
visibleSaleDate
&&
(
<
SaleDateModal
visible=
{
visibleSaleDate
}
id=
{
recordID
}
handleRefresh=
{
()
=>
searchList
({})
}
handleClose=
{
()
=>
setVisibleSaleDate
(
false
)
}
/>
)
}
{
/* 可售餐段弹窗 */
}
{
visibleSaleSection
&&
(
<
SaleSectionModal
visible=
{
visibleSaleSection
}
id=
{
recordID
}
handleRefresh=
{
()
=>
searchList
({})
}
handleClose=
{
()
=>
setVisibleSaleSection
(
false
)
}
/>
)
}
{
/* 修改企业商品价格弹窗 */
}
{
visiblePrice
&&
(
<
GoodPriceModal
visible=
{
visiblePrice
}
id=
{
recordID
}
handleRefresh=
{
()
=>
searchList
({})
}
handleClose=
{
()
=>
setVisiblePrice
(
false
)
}
/>
)
}
{
/* 商品排序弹窗 */
}
{
visibleSort
&&
(
<
GoodSortModal
visible=
{
visibleSort
}
id=
{
recordID
}
handleRefresh=
{
()
=>
searchList
({})
}
handleClose=
{
()
=>
setVisibleSort
(
false
)
}
/>
)
}
</
div
>
);
};
...
...
src/pages/businessGoods/virtualGoodsInfo.jsx
View file @
6dc8ec9b
...
...
@@ -11,7 +11,7 @@ import { apiSaveVirtualGoodsList, apiShopListByEnterpriseID } from './service';
import
style
from
'
./style/index.less
'
;
const
VirtualGoodsInfo
=
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
);
// 可售日期弹窗
...
...
@@ -35,22 +35,25 @@ const VirtualGoodsInfo = props => {
const
skuInfoList
=
dataSource
.
map
(
item
=>
({
skuId
:
item
.
skuId
,
enterprisePrice
:
item
.
enterprisePrice
,
mealTypeList
:
item
.
mealType
,
mealTypeList
:
item
.
mealType
List
.
map
(
m
=>
m
.
code
)
,
saleDateList
:
item
.
saleDate
,
tabCateList
:
item
.
tabCate
.
map
(
t
=>
({
tabId
:
t
})),
}));
const
params
=
{
shopId
:
sleShopID
,
enterpriseId
:
id
,
skuInfoList
,
};
await
apiSaveVirtualGoodsList
(
params
);
notification
.
success
({
message
:
'
添加成功
'
});
onCancel
();
const
res
=
await
apiSaveVirtualGoodsList
(
params
);
if
(
res
&&
res
.
success
)
{
notification
.
success
({
message
:
'
添加成功
'
});
onCancel
();
}
};
// 删除
const
onDel
=
i
=>
{
const
arr
=
dataSource
.
splice
(
i
,
1
);
const
arr
=
[...
dataSource
];
arr
.
splice
(
i
,
1
);
setDataSource
(
arr
);
};
...
...
@@ -62,7 +65,7 @@ const VirtualGoodsInfo = props => {
if
(
res
&&
res
.
data
)
{
setShopList
(
res
.
data
.
map
(
item
=>
({
key
:
item
.
id
,
value
:
item
.
id
,
label
:
item
.
name
,
})),
);
...
...
@@ -106,7 +109,7 @@ const VirtualGoodsInfo = 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
'
]
}
>
...
...
@@ -118,6 +121,7 @@ const VirtualGoodsInfo = props => {
options=
{
shopList
}
className=
{
style
[
'
info-box--select
'
]
}
placeholder=
"清选择"
value=
{
sleShopID
}
onChange=
{
setSelShopID
}
filterOption=
{
(
input
,
option
)
=>
(
option
?.
label
??
''
).
toLowerCase
().
includes
(
input
.
toLowerCase
())
...
...
@@ -137,24 +141,6 @@ const VirtualGoodsInfo = props => {
</
Row
>
<
Row
className=
{
style
[
'
info-box--line
'
]
}
>
<
Col
span=
{
24
}
>
<
div
className=
{
style
[
'
info-box--batch-btn
'
]
}
>
<
Button
onClick=
{
()
=>
{
setEditID
(
''
);
setVisibleSaleDate
(
true
);
}
}
>
批量配置日期
</
Button
>
<
Button
onClick=
{
()
=>
{
setEditID
(
''
);
setVisibleSaleSection
(
true
);
}
}
>
批量配置餐段
</
Button
>
</
div
>
<
Table
columns=
{
GoodsInfoColumn
(
options
)
}
dataSource=
{
dataSource
}
/>
</
Col
>
</
Row
>
...
...
@@ -193,6 +179,9 @@ const VirtualGoodsInfo = props => {
<
SelectGoodsModal
visible=
{
visibleSelectGoods
}
type=
"virtual"
enterpriseId=
{
id
}
productType=
{
2
}
shopID=
{
sleShopID
}
onSelectChange=
{
setDataSource
}
handleClose=
{
()
=>
setVisibleSelectGoods
(
false
)
}
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment