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
ad5992ff
Commit
ad5992ff
authored
Jun 10, 2023
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 对接企业外卖、虚拟商品接口
parent
04c231d7
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1020 additions
and
183 deletions
+1020
-183
CustomerInfo.jsx
src/pages/businessCustomer/components/CustomerInfo.jsx
+157
-28
service.js
src/pages/businessCustomer/service.js
+11
-0
GoodPriceModal.jsx
src/pages/businessGoods/components/GoodPriceModal.jsx
+19
-3
GoodSortModal.jsx
src/pages/businessGoods/components/GoodSortModal.jsx
+18
-10
SaleDateModal.jsx
src/pages/businessGoods/components/SaleDateModal.jsx
+24
-7
SaleSectionModal.jsx
src/pages/businessGoods/components/SaleSectionModal.jsx
+24
-6
SelectGoodsModal.jsx
src/pages/businessGoods/components/SelectGoodsModal.jsx
+149
-21
bll.js
src/pages/businessGoods/service/bll.js
+16
-2
index.js
src/pages/businessGoods/service/index.js
+52
-2
goods.js
src/pages/businessGoods/staticData/goods.js
+76
-19
takeawayGoods.jsx
src/pages/businessGoods/takeawayGoods.jsx
+76
-32
takeawayGoodsInfo.jsx
src/pages/businessGoods/takeawayGoodsInfo.jsx
+100
-25
virtualGoods.jsx
src/pages/businessGoods/virtualGoods.jsx
+184
-0
virtualGoodsInfo.jsx
src/pages/businessGoods/virtualGoodsInfo.jsx
+114
-28
No files found.
src/pages/businessCustomer/components/CustomerInfo.jsx
View file @
ad5992ff
...
@@ -12,9 +12,11 @@ import {
...
@@ -12,9 +12,11 @@ import {
Modal
,
Modal
,
Select
,
Select
,
message
,
message
,
notification
,
}
from
'
antd
'
;
}
from
'
antd
'
;
import
{
ExclamationCircleOutlined
}
from
'
@ant-design/icons
'
;
import
{
ExclamationCircleOutlined
}
from
'
@ant-design/icons
'
;
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
import
moment
from
'
moment
'
;
import
{
import
{
layout
,
layout
,
mealType
,
mealType
,
...
@@ -23,7 +25,12 @@ import {
...
@@ -23,7 +25,12 @@ import {
infoOptions
,
infoOptions
,
mealSections
,
mealSections
,
}
from
'
../staticData/index
'
;
}
from
'
../staticData/index
'
;
import
{
apiEnterpriseInfo
,
apiNewEnterprise
,
apiEditEnterprise
}
from
'
../service
'
;
import
{
apiEnterpriseInfo
,
apiNewEnterprise
,
apiEditEnterprise
,
apiEnterprisePickSelf
,
}
from
'
../service
'
;
import
style
from
'
../style/info.less
'
;
import
style
from
'
../style/info.less
'
;
import
MealSection
from
'
./MealSection
'
;
import
MealSection
from
'
./MealSection
'
;
import
MealLimit
from
'
./MealLimit
'
;
import
MealLimit
from
'
./MealLimit
'
;
...
@@ -35,29 +42,91 @@ const CustomerInfo = props => {
...
@@ -35,29 +42,91 @@ const CustomerInfo = props => {
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
[
meals
,
setMeals
]
=
useState
({});
const
[
meals
,
setMeals
]
=
useState
({});
const
[
mealTypes
,
setMealTypes
]
=
useState
([]);
const
[
mealTypes
,
setMealTypes
]
=
useState
([]);
const
[
pickSelfList
,
setPickSelfList
]
=
useState
([]);
// 关闭分组信息弹窗
// 关闭分组信息弹窗
const
handleCancel
=
()
=>
{
const
handleCancel
=
()
=>
{
props
.
handleClose
(
false
);
props
.
handleClose
(
false
);
};
};
// 添加/保存分组
// 校验时间
const
checkTime
=
(
arr
,
curren
)
=>
{
let
valid
=
false
;
arr
.
forEach
(
item
=>
{
if
(
curren
>
item
.
beginTime
&&
curren
<
item
.
endTime
)
{
valid
=
true
;
}
});
return
valid
;
};
// 提交
const
handleConfirm
=
async
()
=>
{
const
handleConfirm
=
async
()
=>
{
const
res
=
await
form
.
validateFields
();
const
res
=
await
form
.
validateFields
();
console
.
log
(
'
res :>>
'
,
res
);
// const res = await form.getFieldsValue();
// const res = await form.getFieldsValue();
if
(
res
.
mealTimePeriod
.
length
<
1
)
{
if
(
res
.
mealTimePeriod
.
length
<
1
)
{
message
.
warn
(
'
请选择餐段
'
);
message
.
warn
(
'
请选择餐段
'
);
return
;
return
;
}
}
const
params
=
Object
.
assign
({},
res
);
const
params
=
Object
.
assign
(
{
hideImage
:
0
,
},
res
,
);
const
arr
=
[];
const
arr
=
[];
let
validTime
=
false
;
res
.
mealTimePeriod
.
forEach
(
item
=>
{
res
.
mealTimePeriod
.
forEach
(
item
=>
{
if
(
item
.
mealPeriodType
)
{
if
(
item
.
mealPeriodType
)
{
arr
.
push
(
item
);
const
obj
=
Object
.
assign
({},
item
);
obj
.
beginTime
=
moment
(
obj
.
time
[
0
]).
format
(
'
HH:mm
'
);
obj
.
endTime
=
moment
(
obj
.
time
[
1
]).
format
(
'
HH:mm
'
);
delete
obj
.
time
;
if
(
checkTime
(
arr
,
obj
.
beginTime
)
||
checkTime
(
arr
,
obj
.
endTime
))
{
validTime
=
true
;
}
arr
.
push
(
obj
);
}
}
});
});
if
(
validTime
)
{
notification
.
error
({
message
:
'
时间段不能交叉!
'
});
return
;
}
params
.
mealTimePeriod
=
arr
;
params
.
mealTimePeriod
=
arr
;
console
.
log
(
'
res :>>
'
,
res
);
if
(
res
.
hideInfo
&&
res
.
hideInfo
.
length
)
{
params
.
hidePrice
=
res
.
hideInfo
.
includes
(
'
hidePrice
'
)
?
1
:
0
;
params
.
hideImage
=
res
.
hideInfo
.
includes
(
'
hideImage
'
)
?
1
:
0
;
delete
params
.
hideInfo
;
}
const
limits
=
[];
if
(
!
res
.
mealLimit
)
{
notification
.
error
({
message
:
'
请输入限额!
'
});
return
;
}
// 处理限额
Object
.
keys
(
res
.
mealLimit
).
forEach
(
item
=>
{
const
json
=
{
mealPeriodType
:
item
.
replace
(
'
limit
'
,
''
),
limit
:
[],
};
Object
.
keys
(
res
.
mealLimit
[
item
]).
forEach
(
t
=>
{
json
.
limit
.
push
({
mealType
:
t
,
limit
:
res
.
mealLimit
[
item
][
t
],
});
});
limits
.
push
(
json
);
});
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
:
'
保存成功!
'
});
};
};
// 风险提示
// 风险提示
...
@@ -86,25 +155,25 @@ const CustomerInfo = props => {
...
@@ -86,25 +155,25 @@ const CustomerInfo = props => {
}
}
if
(
mealTypes
.
includes
(
'
1
'
)
&&
mealTypes
.
includes
(
'
2
'
))
{
if
(
mealTypes
.
includes
(
'
1
'
)
&&
mealTypes
.
includes
(
'
2
'
))
{
if
(
!
(
ms
.
includes
(
'
1
'
)
&&
ms
.
includes
(
'
2
'
)))
{
if
(
!
(
ms
.
includes
(
'
1
'
)
&&
ms
.
includes
(
'
2
'
)))
{
if
(
ms
.
includes
(
'
3
'
))
{
if
(
ms
.
includes
(
'
4
'
))
{
ms
=
[
'
3
'
];
ms
=
[
'
4
'
];
}
else
{
}
else
{
ms
=
[];
ms
=
[];
}
}
}
}
}
else
if
(
ms
.
length
<
3
&&
ms
.
length
)
{
}
else
if
(
ms
.
length
<
3
&&
ms
.
length
)
{
ms
=
[
'
1
'
,
'
2
'
];
ms
=
[
'
1
'
,
'
2
'
];
if
(
ms
.
includes
(
'
3
'
))
{
if
(
ms
.
includes
(
'
4
'
))
{
ms
.
push
(
'
3
'
);
ms
.
push
(
'
4
'
);
}
}
}
}
form
.
setFieldsValue
({
form
.
setFieldsValue
({
types
:
ms
,
mealType
:
ms
,
});
});
setMealTypes
(
ms
);
setMealTypes
(
ms
);
}
catch
{
}
catch
{
form
.
setFieldsValue
({
form
.
setFieldsValue
({
types
:
mealTypes
,
mealType
:
mealTypes
,
});
});
}
}
};
};
...
@@ -126,14 +195,57 @@ const CustomerInfo = props => {
...
@@ -126,14 +195,57 @@ const CustomerInfo = props => {
setMeals
(
values
);
setMeals
(
values
);
};
};
// 获取企业客户
新
// 获取企业客户
信息
const
getInfo
=
async
()
=>
{
const
getInfo
=
async
()
=>
{
const
res
=
await
apiEnterpriseInfo
(
1
);
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
)
{
obj
.
mealLimit
=
{};
res
.
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
.
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
},
})),
);
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
props
.
visible
)
{
if
(
props
.
visible
)
{
if
(
props
.
id
)
{
getInfo
();
getInfo
();
}
else
{
getPickSelf
();
}
}
else
{
form
.
setFieldsValue
({});
}
}
},
[
props
.
visible
]);
},
[
props
.
visible
]);
...
@@ -143,7 +255,7 @@ const CustomerInfo = props => {
...
@@ -143,7 +255,7 @@ const CustomerInfo = props => {
open=
{
props
.
visible
}
open=
{
props
.
visible
}
destroyOnClose
destroyOnClose
maskClosable=
{
false
}
maskClosable=
{
false
}
width=
"
88
0px"
width=
"
90
0px"
onOk=
{
handleConfirm
}
onOk=
{
handleConfirm
}
onCancel=
{
handleCancel
}
onCancel=
{
handleCancel
}
>
>
...
@@ -160,9 +272,11 @@ const CustomerInfo = props => {
...
@@ -160,9 +272,11 @@ const CustomerInfo = props => {
>
>
<
Input
/>
<
Input
/>
</
Form
.
Item
>
</
Form
.
Item
>
{
!
props
.
id
&&
(
<
Form
.
Item
label=
"企业取餐点"
name=
"pickselfIds"
>
<
Form
.
Item
label=
"企业取餐点"
name=
"pickselfIds"
>
<
Select
/>
<
Select
options=
{
pickSelfList
}
/>
</
Form
.
Item
>
</
Form
.
Item
>
)
}
<
Form
.
Item
<
Form
.
Item
label=
"企业截止时间"
label=
"企业截止时间"
name=
"endOrderTime"
name=
"endOrderTime"
...
@@ -194,17 +308,32 @@ const CustomerInfo = props => {
...
@@ -194,17 +308,32 @@ const CustomerInfo = props => {
<
Divider
orientation=
"left"
plain
>
<
Divider
orientation=
"left"
plain
>
企业单笔消费限额
企业单笔消费限额
</
Divider
>
</
Divider
>
<
Form
.
List
name=
"mealLimit"
>
{
fields
=>
(
<>
{
Object
.
keys
(
meals
).
map
(
meal
=>
(
{
Object
.
keys
(
meals
).
map
(
meal
=>
(
<
Form
.
Item
label=
{
meals
[
meal
]
}
key=
{
meal
}
required
wrapperCol=
{
{
span
:
20
}
}
>
<
Form
.
Item
label=
{
`${mealSections[meal]}订单`
}
required
wrapperCol=
{
{
span
:
20
}
}
>
<
Row
>
<
Form
.
List
name=
{
`limit${meal}`
}
key=
{
`${meal}limit`
}
required
wrapperCol=
{
{
span
:
20
}
}
>
{
fs
=>
(
<
Row
key=
{
`row${meal}`
}
>
{
mealTypes
.
map
((
t
,
i
)
=>
(
{
mealTypes
.
map
((
t
,
i
)
=>
(
<
Col
span=
{
7
}
offset=
{
i
?
1
:
0
}
key=
{
t
}
>
<
Col
span=
{
7
}
offset=
{
i
?
1
:
0
}
key=
{
t
}
>
<
MealLimit
value=
{
t
}
label=
{
mealType
[
t
]
}
name=
{
`${meal}-${t.value
}`
}
/>
<
MealLimit
value=
{
t
}
label=
{
mealType
[
t
]
}
name=
{
`${t
}`
}
/>
</
Col
>
</
Col
>
))
}
))
}
</
Row
>
</
Row
>
)
}
</
Form
.
List
>
</
Form
.
Item
>
</
Form
.
Item
>
))
}
))
}
</>
)
}
</
Form
.
List
>
<
Form
.
Item
label=
"商品隐藏信息"
name=
"hideInfo"
>
<
Form
.
Item
label=
"商品隐藏信息"
name=
"hideInfo"
>
<
CheckboxGroup
options=
{
hideOptions
}
/>
<
CheckboxGroup
options=
{
hideOptions
}
/>
</
Form
.
Item
>
</
Form
.
Item
>
...
...
src/pages/businessCustomer/service.js
View file @
ad5992ff
...
@@ -44,3 +44,14 @@ export async function apiEditEnterprise(data) {
...
@@ -44,3 +44,14 @@ export async function apiEditEnterprise(data) {
prefix
:
goodsApi
,
prefix
:
goodsApi
,
});
});
}
}
/**
* 查询自提点列表
* http://yapi.quantgroups.com/project/389/interface/api/65494
*/
export
async
function
apiEnterprisePickSelf
(
data
)
{
return
request
.
post
(
'
/api/consoles/selfPickUpLocation/list
'
,
{
data
,
prefix
:
goodsApi
,
});
}
src/pages/businessGoods/components/GoodPriceModal.jsx
View file @
ad5992ff
import
React
,
{
use
State
}
from
'
react
'
;
import
React
,
{
use
Effect
}
from
'
react
'
;
import
{
Form
,
InputNumber
,
Modal
}
from
'
antd
'
;
import
{
Form
,
InputNumber
,
Modal
,
notification
}
from
'
antd
'
;
import
{
layout
}
from
'
../staticData/goods
'
;
import
{
layout
}
from
'
../staticData/goods
'
;
import
{
isCheckPriceTwoDecimal
}
from
'
@/utils/validator
'
;
import
{
isCheckPriceTwoDecimal
}
from
'
@/utils/validator
'
;
import
{
apiMealInfoUpdate
}
from
'
../service
'
;
const
SaleDateModal
=
props
=>
{
const
SaleDateModal
=
props
=>
{
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
...
@@ -15,7 +16,21 @@ const SaleDateModal = props => {
...
@@ -15,7 +16,21 @@ const SaleDateModal = props => {
const
handleConfirm
=
async
()
=>
{
const
handleConfirm
=
async
()
=>
{
const
res
=
await
form
.
validateFields
();
const
res
=
await
form
.
validateFields
();
console
.
log
(
'
res :>>
'
,
res
);
console
.
log
(
'
res :>>
'
,
res
);
const
params
=
{
id
:
props
.
id
,
enterprisePrice
:
res
.
price
,
};
};
await
apiMealInfoUpdate
(
params
);
notification
.
success
({
message
:
'
保存成功
'
});
handleCancel
();
props
.
handleRefresh
();
};
useEffect
(()
=>
{
if
(
props
.
visible
)
{
form
.
setFieldsValue
({
price
:
null
});
}
},
[
props
.
visible
]);
return
(
return
(
<
Modal
<
Modal
...
@@ -24,13 +39,14 @@ const SaleDateModal = props => {
...
@@ -24,13 +39,14 @@ const SaleDateModal = props => {
destroyOnClose
destroyOnClose
maskClosable=
{
false
}
maskClosable=
{
false
}
width=
"300px"
width=
"300px"
okText=
"保存"
onOk=
{
handleConfirm
}
onOk=
{
handleConfirm
}
onCancel=
{
handleCancel
}
onCancel=
{
handleCancel
}
>
>
<
Form
name=
"basicInfo"
{
...
layout
}
form=
{
form
}
>
<
Form
name=
"basicInfo"
{
...
layout
}
form=
{
form
}
>
<
Form
.
Item
<
Form
.
Item
label=
"企业商品价格"
label=
"企业商品价格"
name=
"
types
"
name=
"
price
"
rules=
{
[
rules=
{
[
{
required
:
true
,
message
:
'
请输入企业商品价格!
'
},
{
required
:
true
,
message
:
'
请输入企业商品价格!
'
},
{
validator
:
isCheckPriceTwoDecimal
,
message
:
'
请输入正确的价格
'
},
{
validator
:
isCheckPriceTwoDecimal
,
message
:
'
请输入正确的价格
'
},
...
...
src/pages/businessGoods/components/GoodSortModal.jsx
View file @
ad5992ff
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
{
Form
,
InputNumber
,
Modal
}
from
'
antd
'
;
import
{
Form
,
InputNumber
,
Modal
,
notification
}
from
'
antd
'
;
import
{
ExclamationCircleOutlined
}
from
'
@ant-design/icons
'
;
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
import
{
layout
}
from
'
../staticData/goods
'
;
import
{
layout
}
from
'
../staticData/goods
'
;
import
{
isCheckPriceTwoDecimal
}
from
'
@/utils/validator
'
;
import
{
apiMealInfoUpdate
}
from
'
../service
'
;
const
SaleDateModal
=
props
=>
{
const
SaleDateModal
=
props
=>
{
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
[
value
,
setValue
]
=
useState
(
1
);
// 关闭弹窗
// 关闭弹窗
const
handleCancel
=
()
=>
{
const
handleCancel
=
()
=>
{
props
.
handleClose
(
false
);
props
.
handleClose
(
false
);
};
};
const
onChangeWeek
=
e
=>
{
setValue
(
e
.
target
.
value
);
};
// 提交
// 提交
const
handleConfirm
=
async
()
=>
{
const
handleConfirm
=
async
()
=>
{
const
res
=
await
form
.
validateFields
();
const
res
=
await
form
.
validateFields
();
console
.
log
(
'
res :>>
'
,
res
);
console
.
log
(
'
res :>>
'
,
res
);
const
params
=
{
id
:
props
.
id
,
sort
:
res
.
sort
,
};
};
await
apiMealInfoUpdate
(
params
);
notification
.
success
({
message
:
'
保存成功
'
});
handleCancel
();
props
.
handleRefresh
();
};
useEffect
(()
=>
{
if
(
props
.
visible
)
{
form
.
setFieldsValue
({
sort
:
null
});
}
},
[
props
.
visible
]);
return
(
return
(
<
Modal
<
Modal
...
@@ -31,6 +38,7 @@ const SaleDateModal = props => {
...
@@ -31,6 +38,7 @@ const SaleDateModal = props => {
destroyOnClose
destroyOnClose
maskClosable=
{
false
}
maskClosable=
{
false
}
width=
"300px"
width=
"300px"
okText=
"保存"
onOk=
{
handleConfirm
}
onOk=
{
handleConfirm
}
onCancel=
{
handleCancel
}
onCancel=
{
handleCancel
}
>
>
...
...
src/pages/businessGoods/components/SaleDateModal.jsx
View file @
ad5992ff
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Form
,
Checkbox
,
Space
,
Col
,
Row
,
Modal
}
from
'
antd
'
;
import
{
Checkbox
,
Space
,
message
,
Modal
,
notification
}
from
'
antd
'
;
import
{
ExclamationCircleOutlined
}
from
'
@ant-design/icons
'
;
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
import
{
weekOptions
}
from
'
../staticData/goods
'
;
import
{
weekOptions
}
from
'
../staticData/goods
'
;
import
{
apiMealInfoUpdate
}
from
'
../service
'
;
const
SaleDateModal
=
props
=>
{
const
SaleDateModal
=
props
=>
{
const
[
form
]
=
Form
.
useForm
();
const
[
value
,
setValue
]
=
useState
([]);
const
[
value
,
setValue
]
=
useState
([]);
// 关闭弹窗
// 关闭弹窗
...
@@ -19,9 +17,27 @@ const SaleDateModal = props => {
...
@@ -19,9 +17,27 @@ const SaleDateModal = props => {
// 提交
// 提交
const
handleConfirm
=
async
()
=>
{
const
handleConfirm
=
async
()
=>
{
const
res
=
await
form
.
validateFields
();
if
(
!
value
||
value
.
length
<
1
)
{
console
.
log
(
'
res :>>
'
,
res
);
message
.
error
(
'
请选择可售日期
'
);
return
;
}
if
(
props
.
id
)
{
const
params
=
{
id
:
props
.
id
,
saleDateList
:
value
,
};
};
await
apiMealInfoUpdate
(
params
);
notification
.
success
({
message
:
'
保存成功
'
});
}
handleCancel
();
props
.
handleRefresh
(
value
);
};
useEffect
(()
=>
{
if
(
props
.
visible
)
{
setValue
([]);
}
},
[
props
.
visible
]);
return
(
return
(
<
Modal
<
Modal
...
@@ -30,6 +46,7 @@ const SaleDateModal = props => {
...
@@ -30,6 +46,7 @@ const SaleDateModal = props => {
destroyOnClose
destroyOnClose
maskClosable=
{
false
}
maskClosable=
{
false
}
width=
"200px"
width=
"200px"
okText=
"保存"
onOk=
{
handleConfirm
}
onOk=
{
handleConfirm
}
onCancel=
{
handleCancel
}
onCancel=
{
handleCancel
}
>
>
...
...
src/pages/businessGoods/components/SaleSectionModal.jsx
View file @
ad5992ff
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Form
,
Input
,
Checkbox
,
Space
,
Col
,
Row
,
Modal
}
from
'
antd
'
;
import
{
Form
,
Checkbox
,
Space
,
Modal
,
notification
,
message
}
from
'
antd
'
;
import
{
ExclamationCircleOutlined
}
from
'
@ant-design/icons
'
;
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
import
{
mealColumn
}
from
'
../staticData/goods
'
;
import
{
mealColumn
}
from
'
../staticData/goods
'
;
import
{
apiMealInfoUpdate
}
from
'
../service
'
;
const
SaleDateModal
=
props
=>
{
const
SaleDateModal
=
props
=>
{
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
...
@@ -19,9 +18,27 @@ const SaleDateModal = props => {
...
@@ -19,9 +18,27 @@ const SaleDateModal = props => {
// 提交
// 提交
const
handleConfirm
=
async
()
=>
{
const
handleConfirm
=
async
()
=>
{
const
res
=
await
form
.
validateFields
();
if
(
!
value
||
value
.
length
<
1
)
{
console
.
log
(
'
res :>>
'
,
res
);
message
.
error
(
'
请选择餐段
'
);
return
;
}
if
(
props
.
id
)
{
const
params
=
{
id
:
props
.
id
,
tabIds
:
value
,
};
};
await
apiMealInfoUpdate
(
params
);
notification
.
success
({
message
:
'
保存成功
'
});
}
handleCancel
();
props
.
handleRefresh
(
value
);
};
useEffect
(()
=>
{
if
(
props
.
visible
)
{
setValue
([]);
}
},
[
props
.
visible
]);
return
(
return
(
<
Modal
<
Modal
...
@@ -30,6 +47,7 @@ const SaleDateModal = props => {
...
@@ -30,6 +47,7 @@ const SaleDateModal = props => {
destroyOnClose
destroyOnClose
maskClosable=
{
false
}
maskClosable=
{
false
}
width=
"200px"
width=
"200px"
okText=
"保存"
onOk=
{
handleConfirm
}
onOk=
{
handleConfirm
}
onCancel=
{
handleCancel
}
onCancel=
{
handleCancel
}
>
>
...
...
src/pages/businessGoods/components/SelectGoodsModal.jsx
View file @
ad5992ff
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Form
,
Select
,
Modal
,
Table
,
Input
,
Button
,
Pagin
ation
}
from
'
antd
'
;
import
{
Select
,
Modal
,
Table
,
Input
,
Button
,
Pagination
,
notific
ation
}
from
'
antd
'
;
import
{
SearchOutlined
}
from
'
@ant-design/icons
'
;
import
{
SearchOutlined
}
from
'
@ant-design/icons
'
;
import
{
apiTakeawayList
}
from
'
../service
'
;
import
{
apiSelGoodsList
,
apiSelVirtualGoodsList
}
from
'
../service
'
;
import
{
SelectGoodsColumn
}
from
'
../staticData/goods
'
;
import
{
getShopListByPickSelf
}
from
'
../service/bll
'
;
import
{
SelectGoodsColumn
,
productType
}
from
'
../staticData/goods
'
;
import
style
from
'
../style/index.less
'
;
import
style
from
'
../style/index.less
'
;
import
{
jsonToArray
,
deepClone
}
from
'
@/utils/utils
'
;
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
const
SaleDateModal
=
props
=>
{
const
SaleDateModal
=
props
=>
{
const
[
form
]
=
Form
.
useForm
();
const
[
searchType
,
setSearchType
]
=
useState
(
'
1
'
);
const
[
searchType
,
setSearchType
]
=
useState
(
'
1
'
);
const
[
searchKeyword
,
setSearchKeyword
]
=
useState
(
''
);
const
[
goodsType
,
setGoodsType
]
=
useState
(
'
1
'
);
const
[
shopId
,
setShopId
]
=
useState
(
''
);
const
[
searchName
,
setSearchName
]
=
useState
(
''
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
page
,
setPage
]
=
useState
(
1
);
const
[
page
,
setPage
]
=
useState
(
1
);
const
[
pageSize
,
setPageSize
]
=
useState
(
10
);
const
[
pageSize
,
setPageSize
]
=
useState
(
10
);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
shopList
,
setShopList
]
=
useState
(
jsonToArray
(
productType
));
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
([]);
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
([]);
const
[
selectedRows
,
setSelectedRows
]
=
useState
([]);
const
searchList
=
async
params
=>
{
const
searchList
=
async
params
=>
{
console
.
log
(
'
params :>>
'
,
params
);
console
.
log
(
'
params :>>
'
,
params
);
console
.
log
(
'
searchType :>>
'
,
searchType
);
console
.
log
(
'
searchType :>>
'
,
searchType
);
// const data = {
console
.
log
(
'
shopId :>>
'
,
shopId
);
// page: params.current,
const
{
enterpriseId
}
=
props
;
// size: params.pageSize,
const
searchObj
=
{};
// data: params,
if
(
searchKeyword
&&
searchType
&&
!
params
.
search
)
{
// };
if
(
searchType
===
'
1
'
)
{
// return apiTakeawayList(data);
searchObj
.
name
=
searchKeyword
;
}
else
{
searchObj
.
skuId
=
searchKeyword
;
}
}
const
data
=
{
page
:
params
.
current
||
page
,
size
:
params
.
pageSize
||
pageSize
,
data
:
Object
.
assign
(
{
shopId
,
productType
,
enterpriseId
,
},
searchObj
,
params
,
),
};
setLoading
(
true
);
let
api
=
apiSelGoodsList
;
if
(
props
.
type
===
'
virtual
'
)
{
api
=
apiSelVirtualGoodsList
;
}
const
res
=
await
api
(
data
);
setDataSource
(
res
);
setLoading
(
false
);
};
// 点击搜索
const
onSearch
=
()
=>
{
setSearchKeyword
(
searchName
);
searchList
({
[
searchType
===
'
1
'
?
'
name
'
:
'
skuId
'
]:
searchName
});
};
// 切换店铺
const
onChangeShop
=
v
=>
{
setShopId
(
v
);
searchList
({
shopId
:
v
,
});
setSelectedRowKeys
([]);
};
};
// 关闭弹窗
// 关闭弹窗
...
@@ -33,23 +80,84 @@ const SaleDateModal = props => {
...
@@ -33,23 +80,84 @@ const SaleDateModal = props => {
// 提交
// 提交
const
handleConfirm
=
async
()
=>
{
const
handleConfirm
=
async
()
=>
{
const
res
=
await
form
.
validateFields
();
if
(
!
selectedRows
||
selectedRows
.
length
<
1
)
{
console
.
log
(
'
res :>>
'
,
res
);
notification
.
error
({
message
:
'
请选择要添加的商品
'
});
return
;
}
props
.
onSelectChange
(
deepClone
(
selectedRows
));
handleCancel
();
};
};
const
onSelectChange
=
newSelectedRowKeys
=>
{
// 商品单选
console
.
log
(
'
selectedRowKeys changed:
'
,
newSelectedRowKeys
);
const
onSelectChange
=
(
record
,
selected
)
=>
{
setSelectedRowKeys
(
newSelectedRowKeys
);
const
{
skuId
}
=
record
;
if
(
selected
)
{
const
keys
=
[...
selectedRowKeys
,
skuId
];
const
arr
=
[...
selectedRows
,
record
];
setSelectedRowKeys
(
keys
);
setSelectedRows
(
arr
);
}
else
{
const
rows
=
[];
const
keys
=
[];
selectedRows
.
forEach
(
item
=>
{
if
(
item
.
skuId
!==
skuId
)
{
rows
.
push
(
item
);
keys
.
push
(
item
.
skuId
);
}
});
setSelectedRowKeys
(
keys
);
setSelectedRows
(
rows
);
}
};
// 商品全选
const
onSelectAllChange
=
(
selected
,
rows
)
=>
{
const
keys
=
[...
selectedRowKeys
];
const
arr
=
[...
selectedRows
];
if
(
selected
)
{
rows
.
forEach
(
item
=>
{
if
(
!
keys
.
includes
(
item
.
skuId
))
{
keys
.
push
(
item
.
skuId
);
arr
.
push
(
item
);
}
});
setSelectedRowKeys
(
keys
);
setSelectedRows
(
arr
);
}
else
{
dataSource
.
forEach
(
item
=>
{
const
index
=
keys
.
findIndex
(
k
=>
k
===
item
.
skuId
);
if
(
index
>
-
1
)
{
keys
.
splice
(
index
,
1
);
arr
.
splice
(
index
,
1
);
}
});
setSelectedRowKeys
(
keys
);
setSelectedRows
(
arr
);
}
};
};
// 切换页码
const
onPageChange
=
(
current
,
size
)
=>
{
const
onPageChange
=
(
current
,
size
)
=>
{
setPage
(
current
);
setPage
(
current
);
setPageSize
(
size
);
setPageSize
(
size
);
searchList
({
current
,
pageSize
:
size
,
});
};
// 获取店铺列表
const
getShopList
=
async
()
=>
{
const
res
=
await
getShopListByPickSelf
({
enterpriseId
:
props
.
enterpriseId
,
pickSelfIdList
:
props
.
pickSelfIdList
,
});
setShopList
(
res
);
};
};
const
rowSelection
=
{
const
rowSelection
=
{
selectedRowKeys
,
selectedRowKeys
,
onChange
:
onSelectChange
,
onSelect
:
onSelectChange
,
onSelectAll
:
onSelectAllChange
,
};
};
const
selectBefore
=
(
const
selectBefore
=
(
<
Select
defaultValue=
"1"
onChange=
{
setSearchType
}
>
<
Select
defaultValue=
"1"
onChange=
{
setSearchType
}
>
...
@@ -57,13 +165,13 @@ const SaleDateModal = props => {
...
@@ -57,13 +165,13 @@ const SaleDateModal = props => {
<
Option
value=
"2"
>
SKU
</
Option
>
<
Option
value=
"2"
>
SKU
</
Option
>
</
Select
>
</
Select
>
);
);
const
selectAfter
=
<
SearchOutlined
onClick=
{
searchList
}
/>;
const
selectAfter
=
<
SearchOutlined
onClick=
{
onSearch
}
/>;
const
footers
=
()
=>
[
const
footers
=
()
=>
[
<
div
className=
{
style
.
footers
}
>
<
div
className=
{
style
.
footers
}
>
<
Pagination
defaultCurrent=
{
6
}
total=
{
500
}
showQuickJumper
onChange=
{
onPageChange
}
/>
<
Pagination
defaultCurrent=
{
6
}
total=
{
500
}
showQuickJumper
onChange=
{
onPageChange
}
/>
<
div
className=
{
style
[
'
footers-btn
'
]
}
>
<
div
className=
{
style
[
'
footers-btn
'
]
}
>
<
div
className=
{
style
[
'
footers-desc
'
]
}
>
<
div
className=
{
style
[
'
footers-desc
'
]
}
>
已选商品(
<
span
className=
{
style
[
'
footers-num
'
]
}
>
0
</
span
>
)
已选商品(
<
span
className=
{
style
[
'
footers-num
'
]
}
>
{
selectedRows
.
length
}
</
span
>
)
</
div
>
</
div
>
<
Button
key=
"back"
onClick=
{
handleCancel
}
>
<
Button
key=
"back"
onClick=
{
handleCancel
}
>
取消
取消
...
@@ -75,6 +183,12 @@ const SaleDateModal = props => {
...
@@ -75,6 +183,12 @@ const SaleDateModal = props => {
</
div
>,
</
div
>,
];
];
useEffect
(()
=>
{
getShopList
();
setGoodsType
(
props
.
productType
);
searchList
({});
},
[]);
return
(
return
(
<
Modal
<
Modal
title=
"选择商品"
title=
"选择商品"
...
@@ -87,19 +201,33 @@ const SaleDateModal = props => {
...
@@ -87,19 +201,33 @@ const SaleDateModal = props => {
footer=
{
footers
()
}
footer=
{
footers
()
}
>
>
<
div
className=
{
style
[
'
select-goods-box
'
]
}
>
<
div
className=
{
style
[
'
select-goods-box
'
]
}
>
<
Select
placeholder=
"请选择店铺"
className=
{
style
[
'
select-goods-box--select
'
]
}
/>
<
Select
placeholder=
"请选择店铺"
options=
{
shopList
}
value=
{
shopId
}
onChange=
{
onChangeShop
}
className=
{
style
[
'
select-goods-box--select
'
]
}
/>
<
Select
<
Select
placeholder=
"请选择商品类型"
placeholder=
"请选择商品类型"
disabled
disabled
value=
{
goodsType
}
options=
{
jsonToArray
(
productType
)
}
className=
{
style
[
'
select-goods-box--select
'
]
}
className=
{
style
[
'
select-goods-box--select
'
]
}
/>
/>
<
Input
<
Input
addonBefore=
{
selectBefore
}
addonBefore=
{
selectBefore
}
addonAfter=
{
selectAfter
}
addonAfter=
{
selectAfter
}
onChange=
{
e
=>
setSearchName
(
e
.
target
.
value
)
}
className=
{
style
[
'
select-goods-box--txt
'
]
}
className=
{
style
[
'
select-goods-box--txt
'
]
}
/>
/>
</
div
>
</
div
>
<
Table
rowSelection=
{
rowSelection
}
columns=
{
SelectGoodsColumn
}
dataSource=
{
dataSource
}
/>
<
Table
rowSelection=
{
rowSelection
}
rowKey=
"skuId"
columns=
{
SelectGoodsColumn
}
dataSource=
{
dataSource
}
/>
</
Modal
>
</
Modal
>
);
);
};
};
...
...
src/pages/businessGoods/service/bll.js
View file @
ad5992ff
import
{
apiEnterpriseList
,
apiShopList
}
from
'
./index
'
;
import
debounce
from
'
lodash/debounce
'
;
import
{
apiEnterpriseList
,
apiShopList
,
apiShopListByPickSelfID
}
from
'
./index
'
;
// 获取企业列表
// 获取企业列表
export
const
getEnterpriseList
=
async
(
name
=
''
)
=>
{
export
const
getEnterpriseList
=
async
(
name
=
''
)
=>
{
const
res
=
await
apiEnterpriseList
({
name
});
const
res
=
await
apiEnterpriseList
({
name
});
...
@@ -10,7 +12,8 @@ export const getEnterpriseList = async (name = '') => {
...
@@ -10,7 +12,8 @@ export const getEnterpriseList = async (name = '') => {
};
};
};
};
// 获取店铺列表
// 获取店铺列表
export
const
getShopList
=
async
(
name
=
''
)
=>
{
export
const
getShopList
=
debounce
(
async
e
=>
{
const
{
name
}
=
e
;
const
res
=
await
apiShopList
({
name
});
const
res
=
await
apiShopList
({
name
});
return
{
return
{
id
:
res
[
res
.
length
-
1
].
id
,
id
:
res
[
res
.
length
-
1
].
id
,
...
@@ -18,4 +21,15 @@ export const getShopList = async (name = '') => {
...
@@ -18,4 +21,15 @@ export const getShopList = async (name = '') => {
[
item
.
id
]:
{
text
:
item
.
name
},
[
item
.
id
]:
{
text
:
item
.
name
},
})),
})),
};
};
},
300
);
// 获取店铺列表通过自提点ID
export
const
getShopListByPickSelf
=
async
e
=>
{
const
{
name
}
=
e
;
const
res
=
await
apiShopListByPickSelfID
({
name
});
return
{
id
:
res
[
res
.
length
-
1
].
id
,
list
:
res
.
map
(
item
=>
({
[
item
.
id
]:
{
text
:
item
.
name
},
})),
};
};
};
src/pages/businessGoods/service/index.js
View file @
ad5992ff
...
@@ -13,6 +13,16 @@ export async function apiTakeawayList(param) {
...
@@ -13,6 +13,16 @@ export async function apiTakeawayList(param) {
prefix
:
goodsApi
,
prefix
:
goodsApi
,
});
});
}
}
/**
* 获取企业虚拟商品列表
* http://yapi.quantgroups.com/project/389/interface/api/64794
*/
export
async
function
apiVirtualList
(
param
)
{
return
request
.
post
(
'
/api/consoles/product/enterprise/virtual/pageList
'
,
{
data
:
param
,
prefix
:
goodsApi
,
});
}
/**
/**
* 企业客户列表
* 企业客户列表
* http://yapi.quantgroups.com/project/389/interface/api/65324
* http://yapi.quantgroups.com/project/389/interface/api/65324
...
@@ -74,7 +84,7 @@ export async function apiSelPickSelfList(param) {
...
@@ -74,7 +84,7 @@ export async function apiSelPickSelfList(param) {
});
});
}
}
/**
/**
* 企业团餐->查询商品 - 选择商品弹窗
* 企业团餐->查询
外卖
商品 - 选择商品弹窗
* http://yapi.quantgroups.com/project/389/interface/api/65479
* http://yapi.quantgroups.com/project/389/interface/api/65479
*/
*/
export
async
function
apiSelGoodsList
(
param
)
{
export
async
function
apiSelGoodsList
(
param
)
{
...
@@ -84,7 +94,17 @@ export async function apiSelGoodsList(param) {
...
@@ -84,7 +94,17 @@ 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
'
,
{
data
:
param
,
prefix
:
goodsApi
,
});
}
/**
* 企业团餐->添加外卖商品保存
* http://yapi.quantgroups.com/project/389/interface/api/65094
* http://yapi.quantgroups.com/project/389/interface/api/65094
*/
*/
export
async
function
apiSaveGoodsList
(
param
)
{
export
async
function
apiSaveGoodsList
(
param
)
{
...
@@ -93,3 +113,33 @@ export async function apiSaveGoodsList(param) {
...
@@ -93,3 +113,33 @@ export async function apiSaveGoodsList(param) {
prefix
:
goodsApi
,
prefix
:
goodsApi
,
});
});
}
}
/**
* 企业团餐->添加虚拟商品保存
* http://yapi.quantgroups.com/project/389/interface/api/65484
*/
export
async
function
apiSaveVirtualGoodsList
(
param
)
{
return
request
.
post
(
'
/api/consoles/products/enterprise/virtual/add
'
,
{
data
:
param
,
prefix
:
goodsApi
,
});
}
/**
* 企业团餐->虚拟品->根据企业ID查询店铺列表
* http://yapi.quantgroups.com/project/389/interface/api/65504
*/
export
async
function
apiShopListByEnterpriseID
(
param
)
{
return
request
.
post
(
'
/api/consoles/product/enterprise/virtual/shops
'
,
{
data
:
param
,
prefix
:
goodsApi
,
});
}
/**
* 企业团餐->根据企业ID+自提点列表查询店铺列表
* http://yapi.quantgroups.com/project/389/interface/api/65539
*/
export
async
function
apiShopListByPickSelfID
(
param
)
{
return
request
.
post
(
'
/api/consoles/product/enterprise/queryByEnterpriseIdAndPickSelfId
'
,
{
data
:
param
,
prefix
:
goodsApi
,
});
}
src/pages/businessGoods/staticData/goods.js
View file @
ad5992ff
...
@@ -2,6 +2,7 @@ import React from 'react';
...
@@ -2,6 +2,7 @@ import React from 'react';
import
{
Button
,
Space
,
Switch
}
from
'
antd
'
;
import
{
Button
,
Space
,
Switch
}
from
'
antd
'
;
import
{
FormOutlined
}
from
'
@ant-design/icons
'
;
import
{
FormOutlined
}
from
'
@ant-design/icons
'
;
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
import
{
getShopList
}
from
'
../service/bll
'
;
export
const
layout
=
{
export
const
layout
=
{
labelCol
:
{
span
:
4
},
labelCol
:
{
span
:
4
},
...
@@ -16,6 +17,15 @@ export const mealColumn = {
...
@@ -16,6 +17,15 @@ export const mealColumn = {
4
:
'
晚餐
'
,
4
:
'
晚餐
'
,
};
};
// 商品类型
export
const
productType
=
{
1
:
'
实物商品
'
,
2
:
'
虚拟商品
'
,
// 3: '电子卡券'(废弃)
4
:
'
服务类商品
'
,
5
:
'
外卖商品
'
,
};
export
const
weekOptions
=
{
export
const
weekOptions
=
{
1
:
'
周一
'
,
1
:
'
周一
'
,
2
:
'
周二
'
,
2
:
'
周二
'
,
...
@@ -27,19 +37,38 @@ export const weekOptions = {
...
@@ -27,19 +37,38 @@ export const weekOptions = {
};
};
export
const
takeawayGoodsColumn
=
options
=>
{
export
const
takeawayGoodsColumn
=
options
=>
{
const
{
onDel
,
companyEnum
,
shopEnum
,
onChangeFlag
,
setVisibleSaleDate
,
enterprises
}
=
options
;
const
{
onDel
,
companyEnum
,
shopEnum
,
onChangeFlag
,
setVisibleSaleDate
,
enterprises
,
setRecordID
,
setVisiblePrice
,
setVisibleSaleSection
,
setVisibleSort
,
}
=
options
;
return
[
return
[
{
{
title
:
'
企业名称
'
,
title
:
'
企业名称
'
,
dataIndex
:
'
enterpriseId
'
,
dataIndex
:
'
enterpriseId
'
,
hideInTable
:
true
,
hideInTable
:
true
,
fieldProps
:
{
showSearch
:
true
,
filterOption
:
(
v
,
option
)
=>
(
option
?.
label
??
''
).
toLowerCase
().
includes
(
v
.
toLowerCase
()),
},
valueEnum
:
enterprises
,
// companyEnum,
valueEnum
:
enterprises
,
// companyEnum,
},
},
{
{
title
:
'
微店名称
'
,
title
:
'
微店名称
'
,
dataIndex
:
'
shopId
'
,
dataIndex
:
'
shopId
'
,
hideInTable
:
true
,
hideInTable
:
true
,
valueEnum
:
{},
// shopEnum,
fieldProps
:
{
showSearch
:
true
,
},
request
:
getShopList
,
// valueEnum: {}, // shopEnum,
},
},
{
{
title
:
'
SKU编码
'
,
title
:
'
SKU编码
'
,
...
@@ -70,7 +99,12 @@ export const takeawayGoodsColumn = options => {
...
@@ -70,7 +99,12 @@ export const takeawayGoodsColumn = options => {
render
:
(
_
,
record
)
=>
(
render
:
(
_
,
record
)
=>
(
<
Space
>
<
Space
>
<
span
>
{
_
}
<
/span
>
<
span
>
{
_
}
<
/span
>
<
span
onClick
=
{
setVisibleSaleDate
(
true
)}
>
<
span
onClick
=
{()
=>
{
setRecordID
(
record
.
id
);
setVisibleSaleDate
(
true
);
}}
>
<
FormOutlined
/>
<
FormOutlined
/>
<
/span
>
<
/span
>
<
/Space
>
<
/Space
>
...
@@ -85,7 +119,12 @@ export const takeawayGoodsColumn = options => {
...
@@ -85,7 +119,12 @@ export const takeawayGoodsColumn = options => {
render
:
(
_
,
record
)
=>
(
render
:
(
_
,
record
)
=>
(
<
Space
>
<
Space
>
<
span
>
{
_
}
<
/span
>
<
span
>
{
_
}
<
/span
>
<
span
>
<
span
onClick
=
{()
=>
{
setRecordID
(
record
.
id
);
setVisibleSaleSection
(
true
);
}}
>
<
FormOutlined
/>
<
FormOutlined
/>
<
/span
>
<
/span
>
<
/Space
>
<
/Space
>
...
@@ -100,7 +139,12 @@ export const takeawayGoodsColumn = options => {
...
@@ -100,7 +139,12 @@ export const takeawayGoodsColumn = options => {
render
:
(
_
,
record
)
=>
(
render
:
(
_
,
record
)
=>
(
<
Space
>
<
Space
>
<
span
>
{
_
}
<
/span
>
<
span
>
{
_
}
<
/span
>
<
span
>
<
span
onClick
=
{()
=>
{
setRecordID
(
record
.
id
);
setVisiblePrice
(
true
);
}}
>
<
FormOutlined
/>
<
FormOutlined
/>
<
/span
>
<
/span
>
<
/Space
>
<
/Space
>
...
@@ -134,7 +178,12 @@ export const takeawayGoodsColumn = options => {
...
@@ -134,7 +178,12 @@ export const takeawayGoodsColumn = options => {
render
:
(
_
,
record
)
=>
(
render
:
(
_
,
record
)
=>
(
<
Space
>
<
Space
>
<
span
>
{
_
}
<
/span
>
<
span
>
{
_
}
<
/span
>
<
span
>
<
span
onClick
=
{()
=>
{
setRecordID
(
record
.
id
);
setVisibleSort
(
true
);
}}
>
<
FormOutlined
/>
<
FormOutlined
/>
<
/span
>
<
/span
>
<
/Space
>
<
/Space
>
...
@@ -149,7 +198,7 @@ export const takeawayGoodsColumn = options => {
...
@@ -149,7 +198,7 @@ export const takeawayGoodsColumn = options => {
render
:
(
_
,
record
)
=>
(
render
:
(
_
,
record
)
=>
(
<
Space
>
<
Space
>
<
span
>
<
span
>
<
Switch
onChange
=
{
onChangeFlag
}
/
>
<
Switch
checked
=
{
+
_
===
1
}
onChange
=
{
e
=>
onChangeFlag
(
record
.
id
,
e
)
}
/
>
<
/span
>
<
/span
>
<
/Space
>
<
/Space
>
),
),
...
@@ -184,7 +233,7 @@ export const takeawayGoodsColumn = options => {
...
@@ -184,7 +233,7 @@ export const takeawayGoodsColumn = options => {
align
:
'
center
'
,
align
:
'
center
'
,
fixed
:
'
right
'
,
fixed
:
'
right
'
,
render
:
(
val
,
r
)
=>
(
render
:
(
val
,
r
)
=>
(
<
Button
key
=
"
del
"
onClick
=
{()
=>
onDel
(
r
,
'
del
'
)}
>
<
Button
key
=
"
del
"
onClick
=
{()
=>
onDel
(
r
.
id
)}
>
删除
删除
<
/Button
>
<
/Button
>
),
),
...
@@ -193,7 +242,7 @@ export const takeawayGoodsColumn = options => {
...
@@ -193,7 +242,7 @@ export const takeawayGoodsColumn = options => {
};
};
export
const
GoodsInfoColumn
=
options
=>
{
export
const
GoodsInfoColumn
=
options
=>
{
const
{
onDel
,
companyEnum
,
shopEnum
,
onChangeFlag
,
setVisibleSaleDate
}
=
options
;
const
{
onDel
,
setVisibleSaleDate
,
setVisibleSaleSection
,
setEditID
}
=
options
;
return
[
return
[
{
{
title
:
'
微店名称
'
,
title
:
'
微店名称
'
,
...
@@ -202,7 +251,6 @@ export const GoodsInfoColumn = options => {
...
@@ -202,7 +251,6 @@ export const GoodsInfoColumn = options => {
{
{
title
:
'
商品名称
'
,
title
:
'
商品名称
'
,
dataIndex
:
'
skuName
'
,
dataIndex
:
'
skuName
'
,
width
:
120
,
align
:
'
center
'
,
align
:
'
center
'
,
},
},
{
{
...
@@ -225,14 +273,19 @@ export const GoodsInfoColumn = options => {
...
@@ -225,14 +273,19 @@ export const GoodsInfoColumn = options => {
},
},
{
{
title
:
'
可售日期
'
,
title
:
'
可售日期
'
,
dataIndex
:
'
saleTimeType
'
,
dataIndex
:
'
saleDate
'
,
width
:
120
,
align
:
'
center
'
,
align
:
'
center
'
,
hideInSearch
:
true
,
hideInSearch
:
true
,
render
:
(
_
,
record
)
=>
(
render
:
(
_
,
record
)
=>
(
<
Space
>
<
Space
>
<
span
>
{
_
}
<
/span
>
{
_
&&
<
span
onClick
=
{
setVisibleSaleDate
(
true
)}
>
(
_
.
length
===
7
?
'
不限制
'
:
<
span
>
{
_
.
map
(
item
=>
weekOptions
[
item
]).
join
(
'
/
'
)}
<
/span>
)
}
<
span
onClick
=
{()
=>
{
setEditID
(
record
.
skuId
);
setVisibleSaleDate
(
true
);
}}
>
<
FormOutlined
/>
<
FormOutlined
/>
<
/span
>
<
/span
>
<
/Space
>
<
/Space
>
...
@@ -240,14 +293,18 @@ export const GoodsInfoColumn = options => {
...
@@ -240,14 +293,18 @@ export const GoodsInfoColumn = options => {
},
},
{
{
title
:
'
可售餐段
'
,
title
:
'
可售餐段
'
,
dataIndex
:
'
saleDate
'
,
dataIndex
:
'
mealType
'
,
width
:
120
,
align
:
'
center
'
,
align
:
'
center
'
,
hideInSearch
:
true
,
hideInSearch
:
true
,
render
:
(
_
,
record
)
=>
(
render
:
(
_
,
record
)
=>
(
<
Space
>
<
Space
>
<
span
>
{
_
}
<
/span
>
<
span
>
{
_
&&
_
.
map
(
item
=>
mealColumn
[
item
]).
join
(
'
/
'
)}
<
/span
>
<
span
>
<
span
onClick
=
{()
=>
{
setEditID
(
record
.
skuId
);
setVisibleSaleSection
(
true
);
}}
>
<
FormOutlined
/>
<
FormOutlined
/>
<
/span
>
<
/span
>
<
/Space
>
<
/Space
>
...
@@ -280,7 +337,7 @@ export const SelectGoodsColumn = [
...
@@ -280,7 +337,7 @@ export const SelectGoodsColumn = [
{
{
title
:
'
商品ID
'
,
title
:
'
商品ID
'
,
width
:
120
,
width
:
120
,
dataIndex
:
'
i
d
'
,
dataIndex
:
'
skuI
d
'
,
},
},
{
{
title
:
'
商品名称
'
,
title
:
'
商品名称
'
,
...
...
src/pages/businessGoods/takeawayGoods.jsx
View file @
ad5992ff
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'
react
'
;
import
{
useHistory
}
from
'
react-router-dom
'
;
import
{
useHistory
}
from
'
react-router-dom
'
;
import
{
ProTable
}
from
'
@ant-design/pro-components
'
;
import
{
ProTable
}
from
'
@ant-design/pro-components
'
;
import
{
Button
,
Space
}
from
'
antd
'
;
import
{
Button
,
notification
}
from
'
antd
'
;
import
{
PlusOutlined
}
from
'
@ant-design/icons
'
;
import
{
PlusOutlined
}
from
'
@ant-design/icons
'
;
import
{
takeawayGoodsColumn
}
from
'
./staticData/goods
'
;
import
{
takeawayGoodsColumn
}
from
'
./staticData/goods
'
;
import
utilStyle
from
'
@/utils/utils.less
'
;
import
utilStyle
from
'
@/utils/utils.less
'
;
import
{
apiTakeawayList
}
from
'
./service
'
;
import
{
apiTakeawayList
,
apiSelPickSelfList
,
apiMealInfoDel
,
apiMealInfoUpdate
}
from
'
./service
'
;
import
{
getEnterpriseList
}
from
'
./service/bll
'
;
import
{
getEnterpriseList
}
from
'
./service/bll
'
;
import
SaleDateModal
from
'
./components/SaleDateModal
'
;
import
SaleDateModal
from
'
./components/SaleDateModal
'
;
import
SaleSectionModal
from
'
./components/SaleSectionModal
'
;
import
SaleSectionModal
from
'
./components/SaleSectionModal
'
;
...
@@ -13,26 +13,41 @@ import GoodPriceModal from './components/GoodPriceModal';
...
@@ -13,26 +13,41 @@ import GoodPriceModal from './components/GoodPriceModal';
import
GoodSortModal
from
'
./components/GoodSortModal
'
;
import
GoodSortModal
from
'
./components/GoodSortModal
'
;
import
{
getToUrlQuery
}
from
'
@/utils/utils
'
;
import
{
getToUrlQuery
}
from
'
@/utils/utils
'
;
const
BusinessCustomer
=
()
=>
{
// 企业外卖商品
const
TakeawayGoods
=
()
=>
{
const
history
=
useHistory
();
const
history
=
useHistory
();
const
refTable
=
useRef
();
const
refTable
=
useRef
();
const
[
pageLoading
,
setPageLoading
]
=
useState
(
fals
e
);
// 可售日期弹窗
const
[
pageLoading
,
setPageLoading
]
=
useState
(
tru
e
);
// 可售日期弹窗
const
[
visibleSaleDate
,
setVisibleSaleDate
]
=
useState
(
false
);
// 可售日期弹窗
const
[
visibleSaleDate
,
setVisibleSaleDate
]
=
useState
(
false
);
// 可售日期弹窗
const
[
visibleSaleSection
,
setVisibleSaleSection
]
=
useState
(
false
);
// 可售餐段弹窗
const
[
visibleSaleSection
,
setVisibleSaleSection
]
=
useState
(
false
);
// 可售餐段弹窗
const
[
visiblePrice
,
setVisiblePrice
]
=
useState
(
false
);
// 修改企业商品价格弹窗
const
[
visiblePrice
,
setVisiblePrice
]
=
useState
(
false
);
// 修改企业商品价格弹窗
const
[
visibleSort
,
setVisibleSort
]
=
useState
(
false
);
// 商品排序弹窗
const
[
visibleSort
,
setVisibleSort
]
=
useState
(
false
);
// 商品排序弹窗
const
[
enterprises
,
setEnterprises
]
=
useState
([]);
// 企业列表
const
[
enterprises
,
setEnterprises
]
=
useState
([]);
// 企业列表
const
[
activeKey
,
setActiveKey
]
=
useState
(
'
tab1
'
);
const
[
activeKey
,
setActiveKey
]
=
useState
(
''
);
const
[
enterpriseId
,
setEnterpriseId
]
=
useState
(
'
10
'
);
const
[
enterpriseId
,
setEnterpriseId
]
=
useState
(
''
);
const
[
pickSelfList
,
setPickSelfList
]
=
useState
([]);
// 取餐点列表
const
[
recordID
,
setRecordID
]
=
useState
(
''
);
// 编辑的记录ID
// 搜索商品列表
const
searchList
=
async
params
=>
{
const
searchList
=
async
params
=>
{
const
data
=
{
if
(
params
.
enterpriseId
&&
params
.
enterpriseId
!==
enterpriseId
)
{
page
:
params
.
current
,
setEnterpriseId
(
params
.
enterpriseId
);
size
:
params
.
pageSize
,
}
data
:
params
,
// const data = {
// page: params.current,
// size: params.pageSize,
// data: params,
// };
// return apiTakeawayList(data);
};
};
return
apiTakeawayList
(
data
);
const
onDel
=
async
id
=>
{
await
apiMealInfoDel
({
id
,
});
notification
.
success
({
message
:
'
删除成功
'
,
});
};
};
const
onDel
=
async
()
=>
{};
const
onAdd
=
async
()
=>
{
const
onAdd
=
async
()
=>
{
const
query
=
getToUrlQuery
();
const
query
=
getToUrlQuery
();
history
.
push
({
history
.
push
({
...
@@ -40,20 +55,45 @@ const BusinessCustomer = () => {
...
@@ -40,20 +55,45 @@ const BusinessCustomer = () => {
query
,
query
,
});
});
};
};
const
onChangeFlag
=
async
(
id
,
checked
)
=>
{
const
params
=
{
id
,
showFlag
:
checked
?
1
:
0
,
};
await
apiMealInfoUpdate
(
params
);
notification
.
success
({
message
:
'
保存成功
'
});
};
const
options
=
{
const
options
=
{
setVisibleSaleDate
,
setVisibleSaleDate
,
setVisibleSaleSection
,
setVisibleSaleSection
,
setVisiblePrice
,
setVisiblePrice
,
setVisibleSort
,
setVisibleSort
,
onDel
,
onDel
,
setRecordID
,
enterprises
,
enterprises
,
onChangeFlag
,
};
// 根据企业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
getList
=
async
name
=>
{
const
getList
=
async
name
=>
{
const
obj
=
getEnterpriseList
(
name
);
const
obj
=
await
getEnterpriseList
(
name
);
setEnterprises
(
obj
.
list
);
setEnterprises
(
obj
.
list
);
setEnterpriseId
(
obj
.
id
);
setEnterpriseId
(
obj
.
id
);
getPickSelf
(
obj
.
id
);
setPageLoading
(
true
);
setPageLoading
(
true
);
};
};
...
@@ -87,20 +127,7 @@ const BusinessCustomer = () => {
...
@@ -87,20 +127,7 @@ const BusinessCustomer = () => {
menu
:
{
menu
:
{
type
:
'
tab
'
,
type
:
'
tab
'
,
activeKey
,
activeKey
,
items
:
[
items
:
pickSelfList
,
{
key
:
'
tab1
'
,
label
:
<
span
>
取餐点1
</
span
>,
},
{
key
:
'
tab2
'
,
label
:
<
span
>
取餐点2
</
span
>,
},
{
key
:
'
tab3
'
,
label
:
<
span
>
取餐点3
</
span
>,
},
],
onChange
:
key
=>
{
onChange
:
key
=>
{
setActiveKey
(
key
);
setActiveKey
(
key
);
},
},
...
@@ -116,25 +143,42 @@ const BusinessCustomer = () => {
...
@@ -116,25 +143,42 @@ const BusinessCustomer = () => {
)
}
)
}
{
/* 可售日期弹窗 */
}
{
/* 可售日期弹窗 */
}
{
visibleSaleDate
&&
(
{
visibleSaleDate
&&
(
<
SaleDateModal
visible=
{
visibleSaleDate
}
handleClose=
{
()
=>
setVisibleSaleDate
(
false
)
}
/>
<
SaleDateModal
visible=
{
visibleSaleDate
}
id=
{
recordID
}
handleRefresh=
{
()
=>
searchList
({})
}
handleClose=
{
()
=>
setVisibleSaleDate
(
false
)
}
/>
)
}
)
}
{
/* 可售餐段弹窗 */
}
{
/* 可售餐段弹窗 */
}
{
visibleSaleSection
&&
(
{
visibleSaleSection
&&
(
<
SaleSectionModal
<
SaleSectionModal
visible=
{
visibleSaleSection
}
visible=
{
visibleSaleSection
}
id=
{
recordID
}
handleRefresh=
{
()
=>
searchList
({})
}
handleClose=
{
()
=>
setVisibleSaleSection
(
false
)
}
handleClose=
{
()
=>
setVisibleSaleSection
(
false
)
}
/>
/>
)
}
)
}
{
/* 修改企业商品价格弹窗 */
}
{
/* 修改企业商品价格弹窗 */
}
{
visiblePrice
&&
(
{
visiblePrice
&&
(
<
GoodPriceModal
visible=
{
visiblePrice
}
handleClose=
{
()
=>
setVisiblePrice
(
false
)
}
/>
<
GoodPriceModal
visible=
{
visiblePrice
}
id=
{
recordID
}
handleRefresh=
{
()
=>
searchList
({})
}
handleClose=
{
()
=>
setVisiblePrice
(
false
)
}
/>
)
}
)
}
{
/* 商品排序弹窗 */
}
{
/* 商品排序弹窗 */
}
{
visibleSort
&&
(
{
visibleSort
&&
(
<
GoodSortModal
visible=
{
visibleSort
}
handleClose=
{
()
=>
setVisibleSort
(
false
)
}
/>
<
GoodSortModal
visible=
{
visibleSort
}
id=
{
recordID
}
handleRefresh=
{
()
=>
searchList
({})
}
handleClose=
{
()
=>
setVisibleSort
(
false
)
}
/>
)
}
)
}
</
div
>
</
div
>
);
);
};
};
export
default
BusinessCustomer
;
export
default
TakeawayGoods
;
src/pages/businessGoods/takeawayGoodsInfo.jsx
View file @
ad5992ff
import
React
,
{
useRef
,
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useRef
,
useState
,
useEffect
}
from
'
react
'
;
import
{
import
{
Button
,
notification
,
Spin
,
Select
,
Row
,
Col
,
Table
,
message
}
from
'
antd
'
;
Input
,
import
{
useHistory
}
from
'
react-router-dom
'
;
Checkbox
,
Radio
,
Button
,
notification
,
Spin
,
Select
,
Row
,
Col
,
Form
,
Table
,
}
from
'
antd
'
;
import
{
PageHeaderWrapper
}
from
'
@ant-design/pro-layout
'
;
import
{
PageHeaderWrapper
}
from
'
@ant-design/pro-layout
'
;
import
{
GoodsInfoColumn
}
from
'
./staticData/goods
'
;
import
{
GoodsInfoColumn
}
from
'
./staticData/goods
'
;
import
SaleDateModal
from
'
./components/SaleDateModal
'
;
import
SaleDateModal
from
'
./components/SaleDateModal
'
;
import
SaleSectionModal
from
'
./components/SaleSectionModal
'
;
import
SaleSectionModal
from
'
./components/SaleSectionModal
'
;
import
SelectGoodsModal
from
'
./components/SelectGoodsModal
'
;
import
SelectGoodsModal
from
'
./components/SelectGoodsModal
'
;
import
{
apiSelPickSelfList
,
apiSaveGoodsList
}
from
'
./service
'
;
import
style
from
'
./style/index.less
'
;
import
style
from
'
./style/index.less
'
;
const
TakeawayGoodsInfo
=
props
=>
{
const
TakeawayGoodsInfo
=
props
=>
{
const
{
id
}
=
props
.
location
.
query
;
const
{
id
}
=
props
.
location
.
query
;
const
history
=
useHistory
();
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
visibleSaleDate
,
setVisibleSaleDate
]
=
useState
(
false
);
// 可售日期弹窗
const
[
visibleSaleDate
,
setVisibleSaleDate
]
=
useState
(
false
);
// 可售日期弹窗
const
[
visibleSaleSection
,
setVisibleSaleSection
]
=
useState
(
false
);
// 可售餐段弹窗
const
[
visibleSaleSection
,
setVisibleSaleSection
]
=
useState
(
false
);
// 可售餐段弹窗
const
[
visibleSelectGoods
,
setVisibleSelectGoods
]
=
useState
(
false
);
// 选择商品弹窗
const
[
visibleSelectGoods
,
setVisibleSelectGoods
]
=
useState
(
false
);
// 选择商品弹窗
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
pickSelfList
,
setPickSelfList
]
=
useState
([]);
// 取餐点列表
const
[
slePickSelf
,
setSelPickSelf
]
=
useState
([]);
// 选中的取餐点列表
const
[
editID
,
setEditID
]
=
useState
(
''
);
// 编辑ID
// 取消
const
onCancel
=
()
=>
{
history
.
goBack
();
};
// 提交
// 提交
// const onSubmit = () => {
const
onSubmit
=
async
()
=>
{
// };
if
(
!
dataSource
||
dataSource
.
length
<
1
)
{
message
.
error
(
'
请添加商品
'
);
return
;
}
const
skuInfoList
=
dataSource
.
map
(
item
=>
({
skuId
:
item
.
skuId
,
enterprisePrice
:
item
.
enterprisePrice
,
mealTypeList
:
item
.
mealType
,
saleDateList
:
item
.
saleDate
,
}));
const
params
=
{
shopId
:
id
,
enterpriseId
:
id
,
pickSelfIdList
:
slePickSelf
,
skuInfoList
,
};
await
apiSaveGoodsList
(
params
);
notification
.
success
({
message
:
'
添加成功
'
});
onCancel
();
};
// 提交
// 删除
const
onDel
=
()
=>
{};
const
onDel
=
i
=>
{
const
arr
=
dataSource
.
splice
(
i
,
1
);
setDataSource
(
arr
);
};
// 根据企业ID获取取餐点
const
getPickSelf
=
async
()
=>
{
const
res
=
await
apiSelPickSelfList
({
enterpriseId
:
id
,
});
setPickSelfList
(
res
.
map
(
item
=>
({
key
:
item
.
pickSelfId
,
label
:
<
span
>
{
item
.
pickSelfName
}
</
span
>,
})),
);
};
// 刷新列表数据
const
refreshList
=
(
type
,
v
)
=>
{
const
arr
=
dataSource
.
map
(
item
=>
{
if
(
editID
)
{
if
(
item
.
skuId
===
editID
)
{
item
[
type
]
=
v
;
}
}
else
{
item
[
type
]
=
v
;
}
return
item
;
});
setDataSource
(
arr
);
};
// const initData = async () => {
// const initData = async () => {
// setLoading(true);
// setLoading(true);
// };
// };
//
useEffect(() => {
useEffect
(()
=>
{
// initData
();
getPickSelf
();
//
}, []);
},
[]);
const
options
=
{
const
options
=
{
setVisibleSaleDate
,
setVisibleSaleDate
,
setVisibleSaleSection
,
setVisibleSaleSection
,
setEditID
,
onDel
,
onDel
,
};
};
...
@@ -66,8 +115,10 @@ const TakeawayGoodsInfo = props => {
...
@@ -66,8 +115,10 @@ const TakeawayGoodsInfo = props => {
<
Select
<
Select
mode=
"multiple"
mode=
"multiple"
showSearch
showSearch
options=
{
pickSelfList
}
className=
{
style
[
'
info-box--select
'
]
}
className=
{
style
[
'
info-box--select
'
]
}
placeholder=
"清选择"
placeholder=
"清选择"
onChange=
{
setSelPickSelf
}
filterOption=
{
(
input
,
option
)
=>
filterOption=
{
(
input
,
option
)
=>
(
option
?.
label
??
''
).
toLowerCase
().
includes
(
input
.
toLowerCase
())
(
option
?.
label
??
''
).
toLowerCase
().
includes
(
input
.
toLowerCase
())
}
}
...
@@ -87,8 +138,22 @@ const TakeawayGoodsInfo = props => {
...
@@ -87,8 +138,22 @@ const TakeawayGoodsInfo = props => {
<
Row
className=
{
style
[
'
info-box--line
'
]
}
>
<
Row
className=
{
style
[
'
info-box--line
'
]
}
>
<
Col
span=
{
24
}
>
<
Col
span=
{
24
}
>
<
div
className=
{
style
[
'
info-box--batch-btn
'
]
}
>
<
div
className=
{
style
[
'
info-box--batch-btn
'
]
}
>
<
Button
>
批量配置日期
</
Button
>
<
Button
<
Button
>
批量配置餐段
</
Button
>
onClick=
{
()
=>
{
setEditID
(
''
);
setVisibleSaleDate
(
true
);
}
}
>
批量配置日期
</
Button
>
<
Button
onClick=
{
()
=>
{
setEditID
(
''
);
setVisibleSaleSection
(
true
);
}
}
>
批量配置餐段
</
Button
>
</
div
>
</
div
>
<
Table
columns=
{
GoodsInfoColumn
(
options
)
}
dataSource=
{
dataSource
}
/>
<
Table
columns=
{
GoodsInfoColumn
(
options
)
}
dataSource=
{
dataSource
}
/>
</
Col
>
</
Col
>
...
@@ -96,21 +161,30 @@ const TakeawayGoodsInfo = props => {
...
@@ -96,21 +161,30 @@ const TakeawayGoodsInfo = props => {
<
Row
className=
{
style
[
'
info-box--btns
'
]
}
>
<
Row
className=
{
style
[
'
info-box--btns
'
]
}
>
<
Col
span=
{
4
}
/>
<
Col
span=
{
4
}
/>
<
Col
span=
{
20
}
>
<
Col
span=
{
20
}
>
<
Button
type=
"primary"
className=
{
style
[
'
info-box--btns__confirm
'
]
}
>
<
Button
type=
"primary"
onClick=
{
onSubmit
}
className=
{
style
[
'
info-box--btns__confirm
'
]
}
>
确定
确定
</
Button
>
</
Button
>
<
Button
>
取消
</
Button
>
<
Button
onClick=
{
onCancel
}
>
取消
</
Button
>
</
Col
>
</
Col
>
</
Row
>
</
Row
>
</
Spin
>
</
Spin
>
{
/* 可售日期弹窗 */
}
{
/* 可售日期弹窗 */
}
{
visibleSaleDate
&&
(
{
visibleSaleDate
&&
(
<
SaleDateModal
visible=
{
visibleSaleDate
}
handleClose=
{
()
=>
setVisibleSaleDate
(
false
)
}
/>
<
SaleDateModal
visible=
{
visibleSaleDate
}
handleRefresh=
{
v
=>
refreshList
(
'
saleDate
'
,
v
)
}
handleClose=
{
()
=>
setVisibleSaleDate
(
false
)
}
/>
)
}
)
}
{
/* 可售餐段弹窗 */
}
{
/* 可售餐段弹窗 */
}
{
visibleSaleSection
&&
(
{
visibleSaleSection
&&
(
<
SaleSectionModal
<
SaleSectionModal
visible=
{
visibleSaleSection
}
visible=
{
visibleSaleSection
}
handleRefresh=
{
v
=>
refreshList
(
'
mealType
'
,
v
)
}
handleClose=
{
()
=>
setVisibleSaleSection
(
false
)
}
handleClose=
{
()
=>
setVisibleSaleSection
(
false
)
}
/>
/>
)
}
)
}
...
@@ -118,6 +192,7 @@ const TakeawayGoodsInfo = props => {
...
@@ -118,6 +192,7 @@ const TakeawayGoodsInfo = props => {
{
visibleSelectGoods
&&
(
{
visibleSelectGoods
&&
(
<
SelectGoodsModal
<
SelectGoodsModal
visible=
{
visibleSelectGoods
}
visible=
{
visibleSelectGoods
}
onSelectChange=
{
setDataSource
}
handleClose=
{
()
=>
setVisibleSelectGoods
(
false
)
}
handleClose=
{
()
=>
setVisibleSelectGoods
(
false
)
}
/>
/>
)
}
)
}
...
...
src/pages/businessGoods/virtualGoods.jsx
View file @
ad5992ff
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'
react
'
;
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
{
takeawayGoodsColumn
}
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
{
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
[
activeKey
,
setActiveKey
]
=
useState
(
''
);
const
[
enterpriseId
,
setEnterpriseId
]
=
useState
(
''
);
const
[
pickSelfList
,
setPickSelfList
]
=
useState
([]);
// 取餐点列表
const
[
recordID
,
setRecordID
]
=
useState
(
''
);
// 编辑的记录ID
// 搜索商品列表
const
searchList
=
async
params
=>
{
if
(
params
.
enterpriseId
&&
params
.
enterpriseId
!==
enterpriseId
)
{
setEnterpriseId
(
params
.
enterpriseId
);
}
// const data = {
// page: params.current,
// size: params.pageSize,
// data: params,
// };
// return apiVirtualList(data);
};
const
onDel
=
async
id
=>
{
await
apiMealInfoDel
({
id
,
});
notification
.
success
({
message
:
'
删除成功
'
,
});
};
const
onAdd
=
async
()
=>
{
const
query
=
getToUrlQuery
();
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
({});
setPickSelfList
(
res
.
map
(
item
=>
({
key
:
item
.
pickSelfId
,
label
:
<
span
>
{
item
.
pickSelfName
}
</
span
>,
})),
);
setActiveKey
(
res
[
0
].
pickSelfId
);
};
// 获取企业列表
const
getList
=
async
name
=>
{
const
obj
=
await
getEnterpriseList
(
name
);
setEnterprises
(
obj
.
list
);
setEnterpriseId
(
obj
.
id
);
getPickSelf
(
obj
.
id
);
setPageLoading
(
true
);
};
useEffect
(()
=>
{
getList
(
''
);
// setTimeout(() => {
// // refTable.current.reload();
// }, 1000);
},
[]);
return
(
<
div
>
{
pageLoading
&&
(
<
ProTable
search=
{
{
span
:
6
,
className
:
utilStyle
.
formSearch
,
collapsed
:
false
,
collapseRender
:
()
=>
null
,
}
}
actionRef=
{
refTable
}
tableClassName=
{
utilStyle
.
formTable
}
columns=
{
takeawayGoodsColumn
(
options
)
}
request=
{
params
=>
searchList
({
...
params
})
}
rowKey=
{
r
=>
r
.
id
}
expandIconColumnIndex=
{
10
}
bordered
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=
{
onAdd
}
>
添加外卖商品
</
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
>
);
};
export
default
VirtualGoods
;
src/pages/businessGoods/virtualGoodsInfo.jsx
View file @
ad5992ff
import
React
,
{
useRef
,
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useRef
,
useState
,
useEffect
}
from
'
react
'
;
import
{
import
{
Button
,
notification
,
Spin
,
Select
,
Row
,
Col
,
Table
,
message
}
from
'
antd
'
;
Input
,
import
{
useHistory
}
from
'
react-router-dom
'
;
Checkbox
,
Radio
,
Button
,
notification
,
Spin
,
Select
,
Row
,
Col
,
Form
,
Table
,
}
from
'
antd
'
;
import
{
PageHeaderWrapper
}
from
'
@ant-design/pro-layout
'
;
import
{
PageHeaderWrapper
}
from
'
@ant-design/pro-layout
'
;
import
{
GoodsInfoColumn
}
from
'
./staticData/goods
'
;
import
{
GoodsInfoColumn
}
from
'
./staticData/goods
'
;
import
SaleDateModal
from
'
./components/SaleDateModal
'
;
import
SaleDateModal
from
'
./components/SaleDateModal
'
;
import
SaleSectionModal
from
'
./components/SaleSectionModal
'
;
import
SaleSectionModal
from
'
./components/SaleSectionModal
'
;
import
SelectGoodsModal
from
'
./components/SelectGoodsModal
'
;
import
SelectGoodsModal
from
'
./components/SelectGoodsModal
'
;
import
{
apiSaveVirtualGoodsList
,
apiShopListByEnterpriseID
}
from
'
./service
'
;
import
style
from
'
./style/index.less
'
;
import
style
from
'
./style/index.less
'
;
const
Takeaway
GoodsInfo
=
props
=>
{
const
Virtual
GoodsInfo
=
props
=>
{
const
{
id
}
=
props
.
location
.
query
;
const
{
id
}
=
props
.
location
.
query
;
const
history
=
useHistory
();
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
visibleSaleDate
,
setVisibleSaleDate
]
=
useState
(
false
);
// 可售日期弹窗
const
[
visibleSaleDate
,
setVisibleSaleDate
]
=
useState
(
false
);
// 可售日期弹窗
const
[
visibleSaleSection
,
setVisibleSaleSection
]
=
useState
(
tru
e
);
// 可售餐段弹窗
const
[
visibleSaleSection
,
setVisibleSaleSection
]
=
useState
(
fals
e
);
// 可售餐段弹窗
const
[
visibleSelectGoods
,
setVisibleSelectGoods
]
=
useState
(
tru
e
);
// 选择商品弹窗
const
[
visibleSelectGoods
,
setVisibleSelectGoods
]
=
useState
(
fals
e
);
// 选择商品弹窗
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
shopList
,
setShopList
]
=
useState
([]);
// 店铺列表
const
[
sleShopID
,
setSelShopID
]
=
useState
(
''
);
// 选中的店铺
const
[
editID
,
setEditID
]
=
useState
(
''
);
// 编辑ID
// 取消
const
onCancel
=
()
=>
{
history
.
goBack
();
};
// 提交
// 提交
// const onSubmit = () => {
const
onSubmit
=
async
()
=>
{
// };
if
(
!
dataSource
||
dataSource
.
length
<
1
)
{
message
.
error
(
'
请添加商品
'
);
return
;
}
const
skuInfoList
=
dataSource
.
map
(
item
=>
({
skuId
:
item
.
skuId
,
enterprisePrice
:
item
.
enterprisePrice
,
mealTypeList
:
item
.
mealType
,
saleDateList
:
item
.
saleDate
,
}));
const
params
=
{
shopId
:
sleShopID
,
enterpriseId
:
id
,
skuInfoList
,
};
await
apiSaveVirtualGoodsList
(
params
);
notification
.
success
({
message
:
'
添加成功
'
});
onCancel
();
};
// 提交
// 删除
const
onDel
=
()
=>
{};
const
onDel
=
i
=>
{
const
arr
=
dataSource
.
splice
(
i
,
1
);
setDataSource
(
arr
);
};
// 根据企业ID获取店铺列表
const
getShopList
=
async
()
=>
{
const
res
=
await
apiShopListByEnterpriseID
({
enterpriseId
:
id
,
});
setShopList
(
res
.
map
(
item
=>
({
key
:
item
.
id
,
label
:
<
span
>
{
item
.
name
}
</
span
>,
})),
);
};
// 刷新列表数据
const
refreshList
=
(
type
,
v
)
=>
{
const
arr
=
dataSource
.
map
(
item
=>
{
if
(
editID
)
{
if
(
item
.
skuId
===
editID
)
{
item
[
type
]
=
v
;
}
}
else
{
item
[
type
]
=
v
;
}
return
item
;
});
setDataSource
(
arr
);
};
// const initData = async () => {
// const initData = async () => {
// setLoading(true);
// setLoading(true);
// };
// };
//
useEffect(() => {
useEffect
(()
=>
{
// initData
();
getShopList
();
//
}, []);
},
[]);
const
options
=
{
const
options
=
{
setVisibleSaleDate
,
setVisibleSaleDate
,
setVisibleSaleSection
,
setVisibleSaleSection
,
setEditID
,
onDel
,
onDel
,
};
};
...
@@ -63,7 +111,16 @@ const TakeawayGoodsInfo = props => {
...
@@ -63,7 +111,16 @@ const TakeawayGoodsInfo = props => {
选择店铺:
选择店铺:
</
Col
>
</
Col
>
<
Col
span=
{
20
}
>
<
Col
span=
{
20
}
>
<
Select
className=
{
style
[
'
info-box--select
'
]
}
placeholder=
"清选择"
/>
<
Select
showSearch
options=
{
shopList
}
className=
{
style
[
'
info-box--select
'
]
}
placeholder=
"清选择"
onChange=
{
setSelShopID
}
filterOption=
{
(
input
,
option
)
=>
(
option
?.
label
??
''
).
toLowerCase
().
includes
(
input
.
toLowerCase
())
}
/>
</
Col
>
</
Col
>
</
Row
>
</
Row
>
<
Row
className=
{
style
[
'
info-box--line
'
]
}
>
<
Row
className=
{
style
[
'
info-box--line
'
]
}
>
...
@@ -78,27 +135,54 @@ const TakeawayGoodsInfo = props => {
...
@@ -78,27 +135,54 @@ const TakeawayGoodsInfo = props => {
</
Row
>
</
Row
>
<
Row
className=
{
style
[
'
info-box--line
'
]
}
>
<
Row
className=
{
style
[
'
info-box--line
'
]
}
>
<
Col
span=
{
24
}
>
<
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
}
/>
<
Table
columns=
{
GoodsInfoColumn
(
options
)
}
dataSource=
{
dataSource
}
/>
</
Col
>
</
Col
>
</
Row
>
</
Row
>
<
Row
className=
{
style
[
'
info-box--btns
'
]
}
>
<
Row
className=
{
style
[
'
info-box--btns
'
]
}
>
<
Col
span=
{
4
}
/>
<
Col
span=
{
4
}
/>
<
Col
span=
{
20
}
>
<
Col
span=
{
20
}
>
<
Button
type=
"primary"
className=
{
style
[
'
info-box--btns__confirm
'
]
}
>
<
Button
type=
"primary"
onClick=
{
onSubmit
}
className=
{
style
[
'
info-box--btns__confirm
'
]
}
>
确定
确定
</
Button
>
</
Button
>
<
Button
>
取消
</
Button
>
<
Button
onClick=
{
onCancel
}
>
取消
</
Button
>
</
Col
>
</
Col
>
</
Row
>
</
Row
>
</
Spin
>
</
Spin
>
{
/* 可售日期弹窗 */
}
{
/* 可售日期弹窗 */
}
{
visibleSaleDate
&&
(
{
visibleSaleDate
&&
(
<
SaleDateModal
visible=
{
visibleSaleDate
}
handleClose=
{
()
=>
setVisibleSaleDate
(
false
)
}
/>
<
SaleDateModal
visible=
{
visibleSaleDate
}
handleRefresh=
{
v
=>
refreshList
(
'
saleDate
'
,
v
)
}
handleClose=
{
()
=>
setVisibleSaleDate
(
false
)
}
/>
)
}
)
}
{
/* 可售餐段弹窗 */
}
{
/* 可售餐段弹窗 */
}
{
visibleSaleSection
&&
(
{
visibleSaleSection
&&
(
<
SaleSectionModal
<
SaleSectionModal
visible=
{
visibleSaleSection
}
visible=
{
visibleSaleSection
}
handleRefresh=
{
v
=>
refreshList
(
'
mealType
'
,
v
)
}
handleClose=
{
()
=>
setVisibleSaleSection
(
false
)
}
handleClose=
{
()
=>
setVisibleSaleSection
(
false
)
}
/>
/>
)
}
)
}
...
@@ -106,6 +190,8 @@ const TakeawayGoodsInfo = props => {
...
@@ -106,6 +190,8 @@ const TakeawayGoodsInfo = props => {
{
visibleSelectGoods
&&
(
{
visibleSelectGoods
&&
(
<
SelectGoodsModal
<
SelectGoodsModal
visible=
{
visibleSelectGoods
}
visible=
{
visibleSelectGoods
}
type=
"virtual"
onSelectChange=
{
setDataSource
}
handleClose=
{
()
=>
setVisibleSelectGoods
(
false
)
}
handleClose=
{
()
=>
setVisibleSelectGoods
(
false
)
}
/>
/>
)
}
)
}
...
@@ -114,4 +200,4 @@ const TakeawayGoodsInfo = props => {
...
@@ -114,4 +200,4 @@ const TakeawayGoodsInfo = props => {
);
);
};
};
export
default
Takeaway
GoodsInfo
;
export
default
Virtual
GoodsInfo
;
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