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
47ad8c79
Commit
47ad8c79
authored
Mar 23, 2023
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 处理批量操作接口参数
parent
822b7558
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
204 additions
and
22 deletions
+204
-22
ActionBar.jsx
src/pages/GoodsManage/Takeaway/components/ActionBar.jsx
+3
-2
MinimumPurchase.jsx
...pages/GoodsManage/Takeaway/components/MinimumPurchase.jsx
+5
-0
SendModal.jsx
src/pages/GoodsManage/Takeaway/components/SendModal.jsx
+5
-0
StockModal.jsx
src/pages/GoodsManage/Takeaway/components/StockModal.jsx
+63
-8
SwitchGroupModal.jsx
...ages/GoodsManage/Takeaway/components/SwitchGroupModal.jsx
+6
-0
WeekTime.jsx
src/pages/GoodsManage/Takeaway/components/WeekTime.jsx
+18
-2
index.jsx
src/pages/GoodsManage/Takeaway/index.jsx
+74
-7
service.js
src/pages/GoodsManage/service.js
+8
-0
staticdata.js
src/pages/GoodsManage/staticdata.js
+8
-3
style.less
src/pages/GoodsManage/style.less
+14
-0
No files found.
src/pages/GoodsManage/Takeaway/components/ActionBar.jsx
View file @
47ad8c79
...
...
@@ -3,7 +3,7 @@ import { Button, Dropdown, Menu, message, Modal } from 'antd';
import
{
PlusOutlined
,
DownOutlined
,
ExclamationCircleOutlined
}
from
'
@ant-design/icons
'
;
import
{
batchAction
}
from
'
../../staticdata
'
;
import
styles
from
'
../../style.less
'
;
import
{
api
ChangeStateGoods
}
from
'
../../service
'
;
import
{
api
GoodsActionBatch
}
from
'
../../service
'
;
const
ActionBar
=
options
=>
{
// 上下架
...
...
@@ -12,8 +12,9 @@ const ActionBar = options => {
icon
:
<
ExclamationCircleOutlined
/>,
content
:
`确认
${
+
state
===
6
?
'
下架
'
:
'
上架
'
}
商品?`
,
onOk
:
async
()
=>
{
const
res
=
await
api
ChangeStateGoods
({
const
res
=
await
api
GoodsActionBatch
({
ids
:
options
.
selectedRowKeys
,
type
:
2
,
productState
:
+
state
===
6
?
7
:
6
,
// 6:上架,7:下架
});
if
(
res
.
businessCode
===
'
0000
'
&&
res
.
code
===
'
0000
'
)
{
...
...
src/pages/GoodsManage/Takeaway/components/MinimumPurchase.jsx
View file @
47ad8c79
...
...
@@ -9,6 +9,10 @@ const MinimumPurchase = forwardRef(options => {
const
handleOk
=
async
()
=>
{
const
values
=
await
form
.
validateFields
();
console
.
log
(
'
values :>>
'
,
values
);
options
.
confirm
({
type
:
5
,
...
values
,
});
};
return
(
...
...
@@ -17,6 +21,7 @@ const MinimumPurchase = forwardRef(options => {
title=
"修改最少购买数量"
onOk=
{
handleOk
}
maskClosable=
{
false
}
confirmLoading=
{
options
.
loading
}
destroyOnClose
onCancel=
{
handleCancel
}
>
...
...
src/pages/GoodsManage/Takeaway/components/SendModal.jsx
View file @
47ad8c79
...
...
@@ -9,6 +9,10 @@ const SendModal = forwardRef(options => {
const
handleOk
=
async
()
=>
{
const
values
=
await
form
.
validateFields
();
console
.
log
(
'
values :>>
'
,
values
);
options
.
confirm
({
type
:
6
,
...
values
,
});
};
const
radioOptions
=
[{
label
:
'
是
'
,
value
:
1
},
{
label
:
'
否
'
,
value
:
0
}];
...
...
@@ -20,6 +24,7 @@ const SendModal = forwardRef(options => {
title=
"设置单点不送"
onOk=
{
handleOk
}
maskClosable=
{
false
}
confirmLoading=
{
options
.
loading
}
destroyOnClose
onCancel=
{
handleCancel
}
>
...
...
src/pages/GoodsManage/Takeaway/components/StockModal.jsx
View file @
47ad8c79
import
React
,
{
forwardRef
,
useState
}
from
'
react
'
;
import
{
Modal
,
Form
}
from
'
antd
'
;
import
React
,
{
forwardRef
,
useState
,
useEffect
}
from
'
react
'
;
import
{
Modal
,
Form
,
Input
,
Checkbox
,
Radio
,
Switch
}
from
'
antd
'
;
import
{
deepClone
}
from
'
@/utils/utils
'
;
import
styles
from
'
../../style.less
'
;
const
StockModal
=
forwardRef
(
options
=>
{
const
[
stockType
,
setStockType
]
=
useState
(
0
);
const
[
maxStock
,
setMaxStock
]
=
useState
(
0
);
const
[
form
]
=
Form
.
useForm
();
const
onChangeType
=
v
=>
{
setStockType
(
v
===
stockType
?
0
:
v
);
if
(
v
===
1
)
{
form
.
setFieldsValue
({
productStock
:
0
,
});
}
};
const
onChangeMaxStock
=
({
target
:
{
value
}
})
=>
{
setMaxStock
(
value
);
};
const
handleCancel
=
()
=>
{
options
.
cancel
(
false
);
};
const
handleOk
=
async
()
=>
{
const
values
=
await
form
.
validateFields
();
const
params
=
deepClone
(
values
);
params
.
autoStock
=
values
.
autoStock
?
1
:
0
;
console
.
log
(
'
values :>>
'
,
values
);
options
.
confirm
({
type
:
7
,
...
values
,
});
};
const
initialValues
=
Object
.
assign
(
{
saleTimeType
:
1
,
saleDates
:
[]
,
saleTimes
:
[[]]
,
productStock
:
''
,
autoStockStep
:
''
,
autoStock
:
false
,
},
options
.
initialValues
,
);
useEffect
(()
=>
{
if
(
stockType
===
2
)
{
form
.
setFieldsValue
({
productStock
:
maxStock
,
});
}
},
[
maxStock
,
stockType
]);
return
(
<
Modal
visible=
{
options
.
visible
}
title=
"
售卖时间
"
title=
"
修改库存
"
onOk=
{
handleOk
}
maskClosable=
{
false
}
confirmLoading=
{
options
.
loading
}
destroyOnClose
onCancel=
{
handleCancel
}
>
...
...
@@ -36,15 +69,37 @@ const StockModal = forwardRef(options => {
wrapperCol=
{
{
span
:
16
}
}
initialValues=
{
initialValues
}
autoComplete=
"off"
className=
{
styles
[
'
stock-box
'
]
}
>
<
Form
.
Item
label=
"剩余库存"
name=
"saleTimeType"
name=
"productStock"
labelCol=
{
{
span
:
6
}
}
wrapperCol=
{
{
span
:
8
}
}
rules=
{
[{
required
:
true
,
message
:
'
请输入剩余库存!
'
}]
}
>
<
div
>
1
</
div
>
<
Input
type=
"number"
disabled=
{
stockType
>
0
}
/>
</
Form
.
Item
>
<
div
className=
{
styles
[
'
stock-box--btns
'
]
}
>
<
Checkbox
checked=
{
stockType
===
1
}
onChange=
{
()
=>
onChangeType
(
1
)
}
>
清零
</
Checkbox
>
<
Checkbox
checked=
{
stockType
===
2
}
onChange=
{
()
=>
onChangeType
(
2
)
}
>
最大
</
Checkbox
>
</
div
>
<
Form
.
Item
label=
"最大库存"
name=
"autoStockStep"
rules=
{
[{
required
:
true
,
message
:
'
请输入最大库存!
'
}]
}
>
<
Input
type=
"number"
onChange=
{
onChangeMaxStock
}
/>
</
Form
.
Item
>
<
Form
.
Item
label=
"自动补足"
name=
"autoStock"
>
<
Switch
checkedChildren=
"开启"
unCheckedChildren=
"关闭"
/>
</
Form
.
Item
>
</
Form
>
<
div
className=
{
styles
[
'
stock-box--red
'
]
}
>
修改成功后,原库存将被替换,请谨慎操作
</
div
>
</
Modal
>
);
});
...
...
src/pages/GoodsManage/Takeaway/components/SwitchGroupModal.jsx
View file @
47ad8c79
...
...
@@ -9,6 +9,11 @@ const SwitchGroupModal = forwardRef(options => {
const
handleOk
=
async
()
=>
{
const
values
=
await
form
.
validateFields
();
console
.
log
(
'
values :>>
'
,
values
);
options
.
confirm
({
type
:
3
,
...
values
,
});
};
const
radioOptions
=
[{
label
:
'
是
'
,
value
:
1
},
{
label
:
'
否
'
,
value
:
0
}];
...
...
@@ -20,6 +25,7 @@ const SwitchGroupModal = forwardRef(options => {
title=
"更改分组"
onOk=
{
handleOk
}
maskClosable=
{
false
}
confirmLoading=
{
options
.
loading
}
destroyOnClose
onCancel=
{
handleCancel
}
>
...
...
src/pages/GoodsManage/Takeaway/components/WeekTime.jsx
View file @
47ad8c79
import
React
,
{
forwardRef
,
useState
}
from
'
react
'
;
import
{
Modal
,
Radio
,
Form
,
TimePicker
,
Checkbox
}
from
'
antd
'
;
import
{
MinusSquareOutlined
,
PlusSquareOutlined
}
from
'
@ant-design/icons
'
;
import
moment
from
'
moment
'
;
import
{
deepClone
}
from
'
@/utils/utils
'
;
import
{
saleWeeks
}
from
'
../../staticdata
'
;
import
styles
from
'
../../style.less
'
;
...
...
@@ -35,9 +37,22 @@ const WeekTime = forwardRef(options => {
options
.
cancel
(
false
);
};
const
handleOk
=
async
()
=>
{
console
.
log
(
'
111 :>>
'
,
111
);
const
values
=
await
form
.
validateFields
();
console
.
log
(
'
values :>>
'
,
values
);
const
params
=
deepClone
(
values
);
if
(
params
.
saleTimes
&&
params
.
saleTimes
.
length
)
{
params
.
saleTimes
=
values
.
saleTimes
.
map
(
item
=>
{
if
(
item
&&
item
.
length
>
1
)
{
item
[
0
]
=
moment
(
item
[
0
]).
format
(
'
HH:mm
'
);
item
[
1
]
=
moment
(
item
[
1
]).
format
(
'
HH:mm
'
);
}
return
item
;
});
}
options
.
confirm
({
type
:
4
,
...
params
,
});
};
const
initialValues
=
Object
.
assign
(
...
...
@@ -55,6 +70,7 @@ const WeekTime = forwardRef(options => {
title=
"售卖时间"
onOk=
{
handleOk
}
maskClosable=
{
false
}
confirmLoading=
{
options
.
loading
}
destroyOnClose
onCancel=
{
handleCancel
}
>
...
...
src/pages/GoodsManage/Takeaway/index.jsx
View file @
47ad8c79
...
...
@@ -4,7 +4,7 @@ import { MenuOutlined, HolderOutlined, FormOutlined, CloseCircleOutlined } from
import
{
SortableContainer
,
SortableElement
,
SortableHandle
}
from
'
react-sortable-hoc
'
;
import
{
arrayMoveImmutable
}
from
'
array-move
'
;
import
GoodsGroup
from
'
./components/GoodsGroup
'
;
import
{
searchList
}
from
'
../service
'
;
import
{
searchList
,
apiGoodsActionBatch
}
from
'
../service
'
;
import
styles
from
'
../style.less
'
;
import
{
takeawayColumn
}
from
'
../staticdata
'
;
// import VirtualTable from './components/VirtualTable';
...
...
@@ -13,11 +13,14 @@ import WeekTime from './components/WeekTime';
import
StockModal
from
'
./components/StockModal
'
;
import
SendModal
from
'
./components/SendModal
'
;
import
MinimumPurchaseModal
from
'
./components/MinimumPurchase
'
;
import
SwitchGroupModal
from
'
./components/SwitchGroupModal
'
;
const
Takeaway
=
options
=>
{
const
[
tableData
,
setTableData
]
=
useState
([]);
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
([]);
const
[
shopId
,
setShopId
]
=
useState
(
0
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
actionLoading
,
setActionLoading
]
=
useState
(
false
);
const
[
visibleWeekTime
,
setVisibleWeekTime
]
=
useState
(
false
);
const
[
visibleStock
,
setVisibleStock
]
=
useState
(
false
);
const
[
visibleBuy
,
setVisibleBuy
]
=
useState
(
false
);
...
...
@@ -64,6 +67,24 @@ const Takeaway = options => {
}
};
// 批量操作 type 1-是否列出 2-修改上下架 3-改货架 4-售卖时间更新 5-调整商品起购数量 6-调整商品是否单点不送 7-修改库存
const
handleBatchAction
=
async
params
=>
{
const
json
=
{
skuIds
:
selectedRowKeys
,
shopId
,
};
// setActionLoading(true);
// const params2 = {
// ...json,
// ...params,
// };
// console.log('params2 :>> ', params2);
// const res = await apiGoodsActionBatch(Object.assign({}, json, params));
// setActionLoading(false);
// getDataList();
message
.
success
(
'
处理成功!
'
);
};
// 显示弹窗
const
openModal
=
type
=>
{
type
===
'
time
'
&&
setVisibleWeekTime
(
true
);
...
...
@@ -73,19 +94,39 @@ const Takeaway = options => {
type
===
'
send
'
&&
setVisibleSend
(
true
);
};
// 单商品修改库存
const
onShowStockModal
=
({
skuId
})
=>
{
setSelectedRowKeys
([
skuId
]);
openModal
(
'
stock
'
);
};
// 编辑
const
onEdit
=
row
=>
{};
// 置顶
const
toTop
=
row
=>
{};
useEffect
(()
=>
{
getDataList
();
},
[]);
const
actions
=
{
onShowStockModal
,
toTop
,
onEdit
,
};
return
(
<
div
className=
{
styles
.
takeawayBox
}
>
<
Spin
spinning=
{
loading
}
>
<
GoodsGroup
/>
<
ActionBar
selectedRowKeys=
{
selectedRowKeys
}
openModal=
{
openModal
}
/>
<
ActionBar
selectedRowKeys=
{
selectedRowKeys
}
handleSearch=
{
getDataList
}
openModal=
{
openModal
}
/>
<
Table
dataSource=
{
tableData
}
bordered
columns=
{
takeawayColumn
.
call
(
thi
s
)
}
columns=
{
takeawayColumn
(
action
s
)
}
rowKey=
{
record
=>
record
.
skuId
}
pagination=
{
false
}
scroll=
{
{
x
:
'
100%
'
,
y
:
1000
}
}
...
...
@@ -98,10 +139,36 @@ const Takeaway = options => {
}
}
/>
</
Spin
>
<
WeekTime
visible=
{
visibleWeekTime
}
cancel=
{
setVisibleWeekTime
}
/>
<
StockModal
visible=
{
visibleStock
}
cancel=
{
setVisibleStock
}
/>
<
SendModal
visible=
{
visibleSend
}
cancel=
{
setVisibleSend
}
/>
<
MinimumPurchaseModal
visible=
{
visibleBuy
}
cancel=
{
setVisibleBuy
}
/>
<
WeekTime
visible=
{
visibleWeekTime
}
loading=
{
actionLoading
}
confirm=
{
handleBatchAction
}
cancel=
{
setVisibleWeekTime
}
/>
<
StockModal
visible=
{
visibleStock
}
loading=
{
actionLoading
}
confirm=
{
handleBatchAction
}
cancel=
{
setVisibleStock
}
/>
<
SendModal
visible=
{
visibleSend
}
loading=
{
actionLoading
}
confirm=
{
handleBatchAction
}
cancel=
{
setVisibleSend
}
/>
<
MinimumPurchaseModal
visible=
{
visibleBuy
}
loading=
{
actionLoading
}
confirm=
{
handleBatchAction
}
cancel=
{
setVisibleBuy
}
/>
<
SwitchGroupModal
visible=
{
visibleSwitchGroup
}
loading=
{
actionLoading
}
confirm=
{
handleBatchAction
}
cancel=
{
setVisibleSwitchGroup
}
/>
</
div
>
);
};
...
...
src/pages/GoodsManage/service.js
View file @
47ad8c79
...
...
@@ -289,3 +289,11 @@ export async function apiDraftList(data) {
data
,
});
}
// 批量操作
export
async
function
apiGoodsActionBatch
(
data
)
{
return
request
.
post
(
'
/api/merchants/products/sku/batchOperation
'
,
{
prefix
:
goodsApi
,
data
,
});
}
src/pages/GoodsManage/staticdata.js
View file @
47ad8c79
...
...
@@ -325,7 +325,12 @@ export function takeawayColumn(actions) {
render
:
(
_
,
row
,
index
)
=>
(
<
div
className
=
{
styles
.
actionBtn
}
>
{(
row
.
state
===
4
||
(
row
.
state
>=
5
&&
row
.
updateState
!==
1
))
&&
(
<
Button
key
=
"
edit
"
type
=
"
primary
"
className
=
{
styles
.
button
}
>
<
Button
key
=
"
edit
"
type
=
"
primary
"
className
=
{
styles
.
button
}
onClick
=
{()
=>
actions
.
onEdit
(
row
)}
>
编辑
<
/Button
>
)}
...
...
@@ -341,12 +346,12 @@ export function takeawayColumn(actions) {
key
=
"
log
"
type
=
"
primary
"
className
=
{
styles
.
button
}
onClick
=
{()
=>
thi
s
.
onShowStockModal
(
row
)}
onClick
=
{()
=>
action
s
.
onShowStockModal
(
row
)}
>
修改库存
<
/Button
>
{
index
>
0
&&
(
<
Button
key
=
"
top
"
className
=
{
styles
.
button
}
>
<
Button
key
=
"
top
"
className
=
{
styles
.
button
}
onClick
=
{()
=>
actions
.
toTop
(
row
)}
>
置顶
<
/Button
>
)}
...
...
src/pages/GoodsManage/style.less
View file @
47ad8c79
...
...
@@ -259,3 +259,17 @@
.error {
color: #ff4d4f;
}
.stock-box {
position: relative;
&--btns {
position: absolute;
top: 0;
right: 0;
height: 32px;
padding-right: 8%;
line-height: 32px;
}
&--red {
color: #ff1616;
}
}
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