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
3c966ed7
Commit
3c966ed7
authored
Jul 30, 2022
by
beisir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 批量修改表格
parent
dd1bd48b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
270 additions
and
56 deletions
+270
-56
CommonTemplate.tsx
src/pages/ServiceGoods/components/CommonTemplate.tsx
+15
-2
EditFormTable.jsx
src/pages/ServiceGoods/components/EditFormTable.jsx
+90
-4
FormPriceOrStock.jsx
src/pages/ServiceGoods/components/FormPriceOrStock.jsx
+49
-47
FormRuleVPictures.jsx
src/pages/ServiceGoods/components/FormRuleVPictures.jsx
+2
-0
config.js
src/pages/ServiceGoods/config.js
+19
-1
index.jsx
src/pages/ServiceGoods/index.jsx
+45
-2
service.js
src/pages/ServiceGoods/service.js
+9
-0
utils.js
src/pages/ServiceGoods/utils.js
+41
-0
No files found.
src/pages/ServiceGoods/components/CommonTemplate.tsx
View file @
3c966ed7
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
Select
,
Form
,
InputNumber
,
Input
,
Button
}
from
'
antd
'
;
import
{
Select
,
Form
,
InputNumber
,
Input
,
Button
,
Popover
}
from
'
antd
'
;
import
commonStyle
from
'
../common.less
'
;
import
commonStyle
from
'
../common.less
'
;
export
const
WrapperContainer
=
props
=>
(
export
const
WrapperContainer
=
props
=>
(
...
@@ -37,7 +37,11 @@ export const SelectTemplate = props => {
...
@@ -37,7 +37,11 @@ export const SelectTemplate = props => {
}
}
const
selectTemp
=
(
const
selectTemp
=
(
<
Select
allowClear
{
...
resetProps
}
>
<
Select
allowClear
{
...
resetProps
}
>
{
defaultOptionName
?
<
Select
.
Option
value=
{
0
}
>
{
defaultOptionName
}
</
Select
.
Option
>
:
null
}
{
defaultOptionName
?
(
<
Select
.
Option
key=
"default"
value=
{
0
}
>
{
defaultOptionName
}
</
Select
.
Option
>
)
:
null
}
{
dataList
.
map
((
item
,
index
)
=>
{
{
dataList
.
map
((
item
,
index
)
=>
{
const
val
=
fieldNames
?
item
[
fieldNames
.
value
]
:
item
;
const
val
=
fieldNames
?
item
[
fieldNames
.
value
]
:
item
;
const
lab
=
fieldNames
?
item
[
fieldNames
.
label
]
:
item
;
const
lab
=
fieldNames
?
item
[
fieldNames
.
label
]
:
item
;
...
@@ -64,6 +68,15 @@ export const CreateFormInput = props => {
...
@@ -64,6 +68,15 @@ export const CreateFormInput = props => {
if
(
type
===
'
input
'
)
{
if
(
type
===
'
input
'
)
{
return
<
Input
placeholder=
{
title
}
{
...
options
}
/>;
return
<
Input
placeholder=
{
title
}
{
...
options
}
/>;
}
}
if
(
type
===
'
btnText
'
)
{
return
(
<
Popover
content=
{
record
.
name
}
trigger=
"hover"
>
<
Button
type=
"text"
>
查看名称
</
Button
>
</
Popover
>
);
}
if
(
type
===
'
option
'
)
{
if
(
type
===
'
option
'
)
{
return
(
return
(
<>
<>
...
...
src/pages/ServiceGoods/components/EditFormTable.jsx
View file @
3c966ed7
import
{
InputNumber
,
Button
,
Form
,
Table
}
from
'
antd
'
;
import
{
InputNumber
,
Input
,
Modal
,
Button
,
Form
,
Table
}
from
'
antd
'
;
import
React
,
{
import
React
,
{
useContext
,
useContext
,
createContext
,
createContext
,
...
@@ -10,8 +10,40 @@ import React, {
...
@@ -10,8 +10,40 @@ import React, {
import
{
ServiceContext
}
from
'
../context
'
;
import
{
ServiceContext
}
from
'
../context
'
;
import
{
CreateFormInput
}
from
'
./CommonTemplate
'
;
import
{
CreateFormInput
}
from
'
./CommonTemplate
'
;
const
EditableContext
=
createContext
(
null
);
const
UpdateSkuName
=
({
skuVisble
,
value
,
confirmEvent
,
cancelEvent
})
=>
{
const
[
skuForm
]
=
Form
.
useForm
();
const
handleCancel
=
()
=>
{
skuForm
.
resetFields
();
cancelEvent
();
};
const
handleSaveEvent
=
async
()
=>
{
try
{
const
result
=
await
skuForm
.
validateFields
();
confirmEvent
({
skuName
:
result
.
skuName
,
rowIndex
:
value
.
rowIndex
});
handleCancel
();
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
return
(
<
Modal
title=
"修改SKU名称"
visible=
{
skuVisble
}
onOk=
{
handleSaveEvent
}
onCancel=
{
handleCancel
}
>
<
Form
form=
{
skuForm
}
name=
"skuRegister"
>
<
Form
.
Item
label=
"sku名称"
key=
"skuName"
name=
"skuName"
initialValue=
{
value
.
skuName
}
rules=
{
[{
required
:
true
,
message
:
'
请输入sku名称!
'
}]
}
>
<
Input
.
TextArea
autoSize=
{
{
minRows
:
2
,
maxRows
:
6
}
}
allowClear
/>
</
Form
.
Item
>
</
Form
>
</
Modal
>
);
};
const
EditableContext
=
createContext
(
null
);
const
EditableRow
=
({
index
,
...
props
})
=>
<
tr
{
...
props
}
/>;
const
EditableRow
=
({
index
,
...
props
})
=>
<
tr
{
...
props
}
/>;
const
EditableCell
=
props
=>
{
const
EditableCell
=
props
=>
{
const
{
const
{
...
@@ -23,11 +55,15 @@ const EditableCell = props => {
...
@@ -23,11 +55,15 @@ const EditableCell = props => {
record
,
record
,
roleProps
,
roleProps
,
handleSave
,
handleSave
,
roleHidden
,
rowOnClickEvent
,
roleRules
=
{},
...
restProps
...
restProps
}
=
props
;
}
=
props
;
// console.log('==============>', props);
// console.log('==============>', props);
const
form
=
useContext
(
EditableContext
);
const
form
=
useContext
(
EditableContext
);
const
customer
=
useContext
(
ServiceContext
);
const
save
=
async
()
=>
{
const
save
=
async
()
=>
{
try
{
try
{
const
tableList
=
form
.
getFieldValue
(
'
tableList
'
);
const
tableList
=
form
.
getFieldValue
(
'
tableList
'
);
...
@@ -36,13 +72,27 @@ const EditableCell = props => {
...
@@ -36,13 +72,27 @@ const EditableCell = props => {
console
.
log
(
'
Save failed:
'
,
errInfo
);
console
.
log
(
'
Save failed:
'
,
errInfo
);
}
}
};
};
const
onClickEvent
=
()
=>
{};
const
onClickEvent
=
(
type
,
row
)
=>
{
// 点击拉取京东图片功能
if
(
type
===
'
cloneImg
'
)
{
customer
.
onEventBus
(
type
,
row
);
return
;
}
// 修改sku名称
if
(
type
===
'
updateName
'
)
{
rowOnClickEvent
(
row
);
}
// console.log(type, row);
};
const
childNode
=
(
const
childNode
=
(
<
Form
.
Item
<
Form
.
Item
style=
{
{
margin
:
0
}
}
style=
{
{
margin
:
0
}
}
hidden=
{
roleHidden
}
name=
{
[
'
tableList
'
,
rowIndex
,
dataIndex
]
}
name=
{
[
'
tableList
'
,
rowIndex
,
dataIndex
]
}
rules=
{
[{
required
:
true
,
message
:
`${title} is required.`
}]
}
rules=
{
[{
required
:
roleRules
.
required
,
message
:
`${title} is required.`
}]
}
>
>
{
editable
?
(
{
editable
?
(
<
CreateFormInput
<
CreateFormInput
...
@@ -68,6 +118,11 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -68,6 +118,11 @@ const EditFormTable = forwardRef((props, ref) => {
const
{
initData
,
defaultColumns
,
setTableData
,
mergeTable
}
=
props
;
const
{
initData
,
defaultColumns
,
setTableData
,
mergeTable
}
=
props
;
const
customer
=
useContext
(
ServiceContext
);
const
customer
=
useContext
(
ServiceContext
);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
skuVisble
,
setSkuVisble
]
=
useState
(
false
);
const
[
skuNameItem
,
setSkuNameItem
]
=
useState
({
skuName
:
''
,
rowIndex
:
null
,
});
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
useEffect
(()
=>
{
useEffect
(()
=>
{
console
.
log
(
'
==============>坚听initData
'
,
initData
);
console
.
log
(
'
==============>坚听initData
'
,
initData
);
...
@@ -99,6 +154,27 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -99,6 +154,27 @@ const EditFormTable = forwardRef((props, ref) => {
}
}
};
};
const
rowOnClickEvent
=
row
=>
{
setSkuVisble
(
true
);
setSkuNameItem
({
skuName
:
row
.
name
,
rowIndex
:
row
.
rowIndex
,
});
};
const
cancelEvent
=
()
=>
{
setSkuVisble
(
false
);
};
const
confirmEvent
=
skuItem
=>
{
const
newDataSource
=
[...
dataSource
];
newDataSource
[
skuItem
.
rowIndex
].
name
=
skuItem
.
skuName
;
setDataSource
(
newDataSource
);
form
.
setFieldsValue
({
tableList
:
newDataSource
,
});
};
useImperativeHandle
(
ref
,
()
=>
({
useImperativeHandle
(
ref
,
()
=>
({
onCheck
,
onCheck
,
form
,
form
,
...
@@ -119,6 +195,7 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -119,6 +195,7 @@ const EditFormTable = forwardRef((props, ref) => {
rowSpan
,
rowSpan
,
record
,
record
,
rowIndex
,
rowIndex
,
roleRules
:
col
.
roleRules
||
{},
editable
:
col
.
editable
,
editable
:
col
.
editable
,
dataIndex
:
col
.
dataIndex
,
dataIndex
:
col
.
dataIndex
,
disabled
:
col
.
disabled
,
disabled
:
col
.
disabled
,
...
@@ -126,6 +203,7 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -126,6 +203,7 @@ const EditFormTable = forwardRef((props, ref) => {
roleProps
:
col
.
roleProps
||
{},
roleProps
:
col
.
roleProps
||
{},
title
:
col
.
title
,
title
:
col
.
title
,
handleSave
,
handleSave
,
rowOnClickEvent
,
};
};
},
},
}));
}));
...
@@ -153,6 +231,14 @@ const EditFormTable = forwardRef((props, ref) => {
...
@@ -153,6 +231,14 @@ const EditFormTable = forwardRef((props, ref) => {
Add a row
Add a row
</
Button
>
</
Button
>
</
Form
>
</
Form
>
<
Button
onClick=
{
()
=>
{}
}
></
Button
>
<
UpdateSkuName
skuVisble=
{
skuVisble
}
form=
{
form
}
value=
{
skuNameItem
}
confirmEvent=
{
confirmEvent
}
cancelEvent=
{
cancelEvent
}
/>
</
div
>
</
div
>
);
);
});
});
...
...
src/pages/ServiceGoods/components/FormPriceOrStock.jsx
View file @
3c966ed7
...
@@ -10,7 +10,7 @@ import React, {
...
@@ -10,7 +10,7 @@ import React, {
}
from
'
react
'
;
}
from
'
react
'
;
import
{
formItemLayout
,
StaticColumns
}
from
'
../config
'
;
import
{
formItemLayout
,
StaticColumns
}
from
'
../config
'
;
import
EditFormTable
from
'
./EditFormTable
'
;
import
EditFormTable
from
'
./EditFormTable
'
;
import
{
createProductData
,
cleanArray
}
from
'
../utils
'
;
import
{
createProductData
,
cleanArray
,
batchTableSourceData
}
from
'
../utils
'
;
import
{
ServiceContext
}
from
'
../context
'
;
import
{
ServiceContext
}
from
'
../context
'
;
import
{
SelectTemplate
}
from
'
./CommonTemplate
'
;
import
{
SelectTemplate
}
from
'
./CommonTemplate
'
;
...
@@ -53,14 +53,12 @@ const SpecificationTemplate = (props, _) => {
...
@@ -53,14 +53,12 @@ const SpecificationTemplate = (props, _) => {
};
};
const
inputOnblurEvent
=
event
=>
{
const
inputOnblurEvent
=
event
=>
{
console
.
log
(
event
.
target
.
value
);
if
(
event
.
target
.
value
)
{
if
(
event
.
target
.
value
)
{
onChange
();
onChange
();
}
}
};
};
const
bundlePlusAddSpecEvent
=
addCallback
=>
{
const
bundlePlusAddSpecEvent
=
addCallback
=>
{
console
.
log
(
formName
);
const
specId
=
form
.
getFieldValue
(
formName
);
const
specId
=
form
.
getFieldValue
(
formName
);
if
(
!
specId
)
{
if
(
!
specId
)
{
Modal
.
warning
({
Modal
.
warning
({
...
@@ -75,7 +73,10 @@ const SpecificationTemplate = (props, _) => {
...
@@ -75,7 +73,10 @@ const SpecificationTemplate = (props, _) => {
const
bundlePlusRemoveSpecEvent
=
(
removeCallback
,
fieldName
)
=>
{
const
bundlePlusRemoveSpecEvent
=
(
removeCallback
,
fieldName
)
=>
{
removeCallback
(
fieldName
);
removeCallback
(
fieldName
);
onChange
();
const
timer
=
setTimeout
(()
=>
{
onChange
();
clearTimeout
(
timer
);
},
500
);
};
};
return
(
return
(
...
@@ -114,7 +115,12 @@ const SpecificationTemplate = (props, _) => {
...
@@ -114,7 +115,12 @@ const SpecificationTemplate = (props, _) => {
message
:
'
规格名不能重复!
'
,
message
:
'
规格名不能重复!
'
,
validator
(
rule
,
value
,
callback
)
{
validator
(
rule
,
value
,
callback
)
{
const
checkList
=
form
.
getFieldValue
(
specName
);
const
checkList
=
form
.
getFieldValue
(
specName
);
const
check
=
validatorSpecValue
(
value
,
checkList
,
index
,
specName
);
const
check
=
validatorSpecValue
(
value
,
cleanArray
(
checkList
),
index
,
specName
,
);
return
check
?
callback
(
'
规格名不能重复!
'
)
:
callback
();
return
check
?
callback
(
'
规格名不能重复!
'
)
:
callback
();
},
},
},
},
...
@@ -160,28 +166,6 @@ const originItems = {
...
@@ -160,28 +166,6 @@ const originItems = {
secondDuplicate
:
[],
secondDuplicate
:
[],
};
};
// 编辑回显示时只获取用到的数据
const
filterItem
=
skuItem
=>
{
const
{
serviceItem
,
...
argsItem
}
=
skuItem
;
argsItem
.
disabled
=
true
;
return
argsItem
;
};
const
filterSpecData
=
skuList
=>
skuList
.
reduce
((
orgin
,
skuItem
)
=>
{
const
item
=
filterItem
(
skuItem
);
const
{
firstSpecValue
,
secondSpecValue
}
=
item
;
if
(
firstSpecValue
&&
!
orgin
.
firstDuplicate
.
includes
(
firstSpecValue
))
{
orgin
.
firstSpecValue
.
push
(
item
);
orgin
.
firstDuplicate
.
push
(
firstSpecValue
);
}
if
(
secondSpecValue
&&
!
orgin
.
secondDuplicate
.
includes
(
secondSpecValue
))
{
orgin
.
secondSpecValue
.
push
(
item
);
orgin
.
secondDuplicate
.
push
(
secondSpecValue
);
}
return
orgin
;
},
originItems
);
const
CreateBatchFormItems
=
({
specInitValue
,
batchChange
,
editRef
,
defaultColumns
})
=>
{
const
CreateBatchFormItems
=
({
specInitValue
,
batchChange
,
editRef
,
defaultColumns
})
=>
{
const
customer
=
useContext
(
ServiceContext
);
const
customer
=
useContext
(
ServiceContext
);
const
formItems
=
defaultColumns
const
formItems
=
defaultColumns
...
@@ -289,33 +273,51 @@ const FormPriceOrStock = forwardRef((props, ref) => {
...
@@ -289,33 +273,51 @@ const FormPriceOrStock = forwardRef((props, ref) => {
}
}
};
};
const
firstOnChangeEvent
=
()
=>
{
const
firstSpecValue
=
form
.
getFieldValue
(
'
firstSpecValue
'
);
const
firstSpecValueList
=
cleanArray
(
firstSpecValue
).
map
(
item
=>
item
.
firstSpecValue
);
onSpecChange
(
firstSpecValueList
);
};
const
batchChange
=
()
=>
{
const
batchChange
=
()
=>
{
const
batchItem
=
form
.
getFieldValue
(
'
batchItem
'
);
const
batchItem
=
form
.
getFieldValue
(
'
batchItem
'
);
const
batchItemKey
=
Object
.
keys
(
batchItem
);
const
bacthFirst
=
form
.
getFieldValue
(
'
bacthFirst
'
);
const
resetObject
=
tableData
.
map
((
item
,
index
)
=>
{
const
bacthSecon
=
form
.
getFieldValue
(
'
bacthSecon
'
);
console
.
log
(
item
);
const
resetObject
=
batchTableSourceData
({
batchItem
,
tableData
,
bacthSecon
,
bacthFirst
});
batchItemKey
.
forEach
(
key
=>
{
item
[
key
]
=
batchItem
[
key
]
||
null
;
// reset[`tableList[${index}]['${key}']`] = batchItem[key] || null;
});
return
item
;
});
setTableData
(
resetObject
);
setTableData
(
resetObject
);
console
.
log
(
resetObject
);
};
// editRef.current.form.setFieldsValue(resetObject);
// form.setFieldsValue(resetObject);
const
onSpecificationEvent
=
async
()
=>
{
try
{
const
values
=
await
form
.
validateFields
();
const
cleanValues
=
{
firstSpec
:
values
.
firstSpec
,
firstSpecId
:
values
.
firstSpecId
,
firstSpecValue
:
cleanArray
(
values
.
firstSpecValue
),
secondSpec
:
values
.
secondSpec
,
secondSpecId
:
values
.
secondSpecId
,
secondSpecValue
:
cleanArray
(
values
.
secondSpecValue
),
};
setSpecInitValue
(
cleanValues
);
CreateColumnsEvent
(
cleanValues
);
return
cleanValues
;
}
catch
(
error
)
{
console
.
log
(
error
);
}
return
null
;
};
const
firstOnChangeEvent
=
async
()
=>
{
const
cleanValues
=
await
onSpecificationEvent
();
if
(
cleanValues
)
{
const
firstSpecValueList
=
cleanArray
(
cleanValues
.
firstSpecValue
).
map
(
item
=>
item
.
firstSpecValue
,
);
onSpecChange
(
firstSpecValueList
);
}
};
const
seconOnChangeEvent
=
async
()
=>
{
await
onSpecificationEvent
();
};
};
useImperativeHandle
(
ref
,
()
=>
({
useImperativeHandle
(
ref
,
()
=>
({
onCheck
,
onCheck
,
reset
:
()
=>
{
reset
:
()
=>
{
console
.
log
(
'
============>cleaarn
'
,
initSpecReced
());
form
.
resetFields
();
form
.
resetFields
();
setDefaultColumns
([]);
setDefaultColumns
([]);
setTableData
([]);
setTableData
([]);
...
@@ -339,7 +341,6 @@ const FormPriceOrStock = forwardRef((props, ref) => {
...
@@ -339,7 +341,6 @@ const FormPriceOrStock = forwardRef((props, ref) => {
// secondSpecId: oneItem.secondSpecId,
// secondSpecId: oneItem.secondSpecId,
// secondSpecValue,
// secondSpecValue,
// };
// };
console
.
log
(
'
=============>editDataeditDataeditData
'
,
editData
);
form
.
setFieldsValue
(
editData
);
// 设置规格数据
form
.
setFieldsValue
(
editData
);
// 设置规格数据
setSpecInitValue
(
editData
);
// 缓存规格数据
setSpecInitValue
(
editData
);
// 缓存规格数据
...
@@ -369,6 +370,7 @@ const FormPriceOrStock = forwardRef((props, ref) => {
...
@@ -369,6 +370,7 @@ const FormPriceOrStock = forwardRef((props, ref) => {
<
SpecificationTemplate
<
SpecificationTemplate
form=
{
form
}
form=
{
form
}
label=
"二级规格"
label=
"二级规格"
onChange=
{
seconOnChangeEvent
}
formName=
"secondSpecId"
formName=
"secondSpecId"
selectName=
"secondSpec"
selectName=
"secondSpec"
specName=
"secondSpecValue"
specName=
"secondSpecValue"
...
...
src/pages/ServiceGoods/components/FormRuleVPictures.jsx
View file @
3c966ed7
...
@@ -67,6 +67,8 @@ const FormRuleVPictures = forwardRef((props, ref) => {
...
@@ -67,6 +67,8 @@ const FormRuleVPictures = forwardRef((props, ref) => {
useImperativeHandle
(
ref
,
()
=>
({
useImperativeHandle
(
ref
,
()
=>
({
onCheck
,
onCheck
,
setFieldsValue
:
form
.
setFieldsValue
,
getFieldsValue
:
form
.
getFieldsValue
,
reset
:
()
=>
{
reset
:
()
=>
{
form
.
resetFields
();
form
.
resetFields
();
setImageList
({});
setImageList
({});
...
...
src/pages/ServiceGoods/config.js
View file @
3c966ed7
...
@@ -75,6 +75,7 @@ export const StaticColumns = customer => [
...
@@ -75,6 +75,7 @@ export const StaticColumns = customer => [
precision
:
2
,
precision
:
2
,
min
:
0
,
min
:
0
,
},
},
roleRules
:
{
required
:
true
},
disabled
:
customer
.
isJDGoods
||
customer
.
isService
,
disabled
:
customer
.
isJDGoods
||
customer
.
isService
,
},
},
{
{
...
@@ -82,6 +83,7 @@ export const StaticColumns = customer => [
...
@@ -82,6 +83,7 @@ export const StaticColumns = customer => [
dataIndex
:
'
commissionRate
'
,
dataIndex
:
'
commissionRate
'
,
editable
:
true
,
editable
:
true
,
role
:
[
3
],
role
:
[
3
],
roleRules
:
{
required
:
true
},
},
},
{
{
title
:
'
市场价
'
,
title
:
'
市场价
'
,
...
@@ -92,6 +94,7 @@ export const StaticColumns = customer => [
...
@@ -92,6 +94,7 @@ export const StaticColumns = customer => [
precision
:
2
,
precision
:
2
,
min
:
0
,
min
:
0
,
},
},
roleRules
:
{
required
:
true
},
disabled
:
customer
.
isService
,
disabled
:
customer
.
isService
,
},
},
{
{
...
@@ -103,6 +106,7 @@ export const StaticColumns = customer => [
...
@@ -103,6 +106,7 @@ export const StaticColumns = customer => [
precision
:
3
,
precision
:
3
,
max
:
999999.999
,
max
:
999999.999
,
},
},
roleRules
:
{
required
:
true
},
disabled
:
customer
.
isService
,
disabled
:
customer
.
isService
,
},
},
{
{
...
@@ -110,13 +114,14 @@ export const StaticColumns = customer => [
...
@@ -110,13 +114,14 @@ export const StaticColumns = customer => [
dataIndex
:
'
salePrice
'
,
dataIndex
:
'
salePrice
'
,
editable
:
true
,
editable
:
true
,
role
:
[],
role
:
[],
roleRules
:
{
required
:
true
},
},
},
{
{
title
:
'
库存
'
,
title
:
'
库存
'
,
dataIndex
:
'
stock
'
,
dataIndex
:
'
stock
'
,
editable
:
true
,
editable
:
true
,
role
:
[
3
],
role
:
[
3
],
roleRules
:
{
required
:
true
},
// disabled: customer.isService,
// disabled: customer.isService,
},
},
{
{
...
@@ -135,6 +140,7 @@ export const StaticColumns = customer => [
...
@@ -135,6 +140,7 @@ export const StaticColumns = customer => [
precision
:
2
,
precision
:
2
,
min
:
0
,
min
:
0
,
},
},
roleRules
:
{
required
:
true
},
disabled
:
customer
.
isService
,
disabled
:
customer
.
isService
,
},
},
{
{
...
@@ -143,6 +149,7 @@ export const StaticColumns = customer => [
...
@@ -143,6 +149,7 @@ export const StaticColumns = customer => [
editable
:
true
,
editable
:
true
,
batchRole
:
[
1
],
batchRole
:
[
1
],
role
:
[
1
],
role
:
[
1
],
roleRules
:
{
required
:
true
},
disabled
:
customer
.
isService
,
disabled
:
customer
.
isService
,
},
},
{
{
...
@@ -152,6 +159,7 @@ export const StaticColumns = customer => [
...
@@ -152,6 +159,7 @@ export const StaticColumns = customer => [
role
:
[
1
,
2
],
role
:
[
1
,
2
],
inputType
:
'
input
'
,
inputType
:
'
input
'
,
disabled
:
customer
.
isService
,
disabled
:
customer
.
isService
,
roleRules
:
{
required
:
true
},
},
},
{
{
title
:
'
京东链接
'
,
title
:
'
京东链接
'
,
...
@@ -160,6 +168,15 @@ export const StaticColumns = customer => [
...
@@ -160,6 +168,15 @@ export const StaticColumns = customer => [
role
:
[
1
,
2
],
role
:
[
1
,
2
],
inputType
:
'
input
'
,
inputType
:
'
input
'
,
disabled
:
customer
.
isService
,
disabled
:
customer
.
isService
,
roleRules
:
{
required
:
false
},
},
{
title
:
'
sku名称
'
,
dataIndex
:
'
name
'
,
editable
:
true
,
role
:
customer
.
isEdit
&&
customer
.
isJDGoods
?
[
1
,
2
]
:
[],
inputType
:
'
btnText
'
,
roleRules
:
{
required
:
false
},
},
},
{
{
title
:
'
操作
'
,
title
:
'
操作
'
,
...
@@ -171,6 +188,7 @@ export const StaticColumns = customer => [
...
@@ -171,6 +188,7 @@ export const StaticColumns = customer => [
isJDGoods
:
customer
.
isJDGoods
,
isJDGoods
:
customer
.
isJDGoods
,
min
:
0
,
min
:
0
,
},
},
roleRules
:
{
required
:
false
},
disabled
:
customer
.
isService
,
disabled
:
customer
.
isService
,
},
},
];
];
src/pages/ServiceGoods/index.jsx
View file @
3c966ed7
import
React
,
{
useState
,
useRef
,
useEffect
,
useCallback
}
from
'
react
'
;
import
React
,
{
useState
,
useRef
,
useEffect
,
useCallback
}
from
'
react
'
;
import
{
Spin
,
Button
,
Modal
}
from
'
antd
'
;
import
{
Spin
,
Button
,
Modal
,
notification
}
from
'
antd
'
;
import
{
ConsoleSqlOutlined
}
from
'
@ant-design/icons
'
;
import
{
Title
,
WrapperContainer
}
from
'
./components/CommonTemplate
'
;
import
{
Title
,
WrapperContainer
}
from
'
./components/CommonTemplate
'
;
import
{
TaskTypeSelect
}
from
'
./components/TaskTypeSelect
'
;
import
{
TaskTypeSelect
}
from
'
./components/TaskTypeSelect
'
;
import
FormInformationBasic
from
'
./components/FormInformationBasic
'
;
import
FormInformationBasic
from
'
./components/FormInformationBasic
'
;
...
@@ -13,9 +14,10 @@ import {
...
@@ -13,9 +14,10 @@ import {
merchantBrandList
,
merchantBrandList
,
merchantSpecList
,
merchantSpecList
,
afterSalesAddrsPage
,
afterSalesAddrsPage
,
merchantgetJdPicList
,
}
from
'
./service
'
;
}
from
'
./service
'
;
import
{
isUrl
}
from
'
./utils
'
;
import
{
ServiceContext
}
from
'
./context
'
;
import
{
ServiceContext
}
from
'
./context
'
;
import
{
ConsoleSqlOutlined
}
from
'
@ant-design/icons
'
;
/**
/**
* 服务商品改造-商品模块
* 服务商品改造-商品模块
...
@@ -119,6 +121,24 @@ const ServiceGoods = options => {
...
@@ -119,6 +121,24 @@ const ServiceGoods = options => {
}
}
};
};
const
getMerchantgetJdPicList
=
async
params
=>
{
const
result
=
await
merchantgetJdPicList
(
params
);
if
(
result
)
{
const
{
detailImageList
,
imageList
}
=
picturesRef
.
current
.
getFieldsValue
();
const
detailList
=
result
.
detailList
||
[];
const
newImageList
=
imageList
[
result
.
firstSpecValue
];
const
carouseList
=
result
.
carouseList
||
[];
imageList
[
result
.
firstSpecValue
]
=
newImageList
?
[...
newImageList
,
...
carouseList
]
:
carouseList
;
picturesRef
.
current
.
setFieldsValue
({
// [`imageList[${data.firstSpecValue}]`]: this.state.colorImg[data.firstSpecValue],
imageList
,
detailImageList
:
[...
detailImageList
,
...
detailList
],
});
}
};
useEffect
(()
=>
{
useEffect
(()
=>
{
(
async
()
=>
{
(
async
()
=>
{
if
(
!
options
.
visible
)
{
if
(
!
options
.
visible
)
{
...
@@ -170,6 +190,28 @@ const ServiceGoods = options => {
...
@@ -170,6 +190,28 @@ const ServiceGoods = options => {
[
specKeyList
],
[
specKeyList
],
);
);
const
onEventBus
=
(
event
,
params
)
=>
{
if
(
event
===
'
cloneImg
'
)
{
if
(
!
isUrl
(
params
.
skuLink
))
{
notification
.
open
({
message
:
'
提示
'
,
description
:
'
请输入正确的URL!
'
,
});
return
;
}
getMerchantgetJdPicList
({
firstSpecId
:
params
.
firstSpecId
,
firstSpecValue
:
params
.
firstSpecValue
,
secondSpecId
:
params
.
secondSpecId
,
secondSpecValue
:
params
.
secondSpecValue
,
skuLink
:
params
.
skuLink
,
jdSkuInfoUrl
:
params
.
skuLink
,
});
}
console
.
log
(
event
,
params
);
};
const
providerValue
=
{
const
providerValue
=
{
pageId
,
pageId
,
isEdit
,
isEdit
,
...
@@ -177,6 +219,7 @@ const ServiceGoods = options => {
...
@@ -177,6 +219,7 @@ const ServiceGoods = options => {
isCard
:
productType
===
3
,
isCard
:
productType
===
3
,
isService
:
SourceData
.
state
&&
SourceData
.
state
!==
4
,
isService
:
SourceData
.
state
&&
SourceData
.
state
!==
4
,
isJDGoods
:
isEdit
&&
SourceData
.
pageProductType
&&
+
SourceData
.
pageProductType
!==
1
,
isJDGoods
:
isEdit
&&
SourceData
.
pageProductType
&&
+
SourceData
.
pageProductType
!==
1
,
onEventBus
,
};
};
return
(
return
(
...
...
src/pages/ServiceGoods/service.js
View file @
3c966ed7
...
@@ -57,3 +57,12 @@ export const afterSalesAddrsPage = () => {
...
@@ -57,3 +57,12 @@ export const afterSalesAddrsPage = () => {
});
});
return
data
;
return
data
;
};
};
export
const
merchantgetJdPicList
=
async
params
=>
{
const
{
data
}
=
await
request
.
post
(
'
/product/api/merchant/item/getJdPicList
'
,
{
data
:
stringify
(
params
),
prefix
:
goodsApi
,
headers
,
});
return
data
;
};
src/pages/ServiceGoods/utils.js
View file @
3c966ed7
...
@@ -23,6 +23,7 @@ const createInitProduct = (skuItem, isCreate) => {
...
@@ -23,6 +23,7 @@ const createInitProduct = (skuItem, isCreate) => {
stock
:
null
,
stock
:
null
,
thirdSkuNo
:
null
,
thirdSkuNo
:
null
,
skuLink
:
null
,
skuLink
:
null
,
name
:
null
,
};
};
};
};
...
@@ -34,6 +35,7 @@ const initData = {
...
@@ -34,6 +35,7 @@ const initData = {
stock
:
null
,
stock
:
null
,
thirdSkuNo
:
null
,
thirdSkuNo
:
null
,
skuLink
:
null
,
skuLink
:
null
,
name
:
null
,
};
};
const
createSecondProduct
=
(
secondSpecList
,
initItem
,
secondSpec
,
dataSource
,
callback
)
=>
{
const
createSecondProduct
=
(
secondSpecList
,
initItem
,
secondSpec
,
dataSource
,
callback
)
=>
{
...
@@ -85,3 +87,42 @@ export const createProductData = ({ firstValues, secondValues, firstSpecId, seco
...
@@ -85,3 +87,42 @@ export const createProductData = ({ firstValues, secondValues, firstSpecId, seco
console
.
log
(
'
dataSource===========>
'
,
dataSource
);
console
.
log
(
'
dataSource===========>
'
,
dataSource
);
return
dataSource
;
return
dataSource
;
};
};
export
const
isUrl
=
path
=>
{
// eslint-disable-next-line no-useless-escape
const
reg
=
/
(((
^https
?
:
(?:\/\/)?)(?:[
-;:&=
\+\$
,
\w]
+@
)?[
A-Za-z0-9.-
]
+
(?:
:
\d
+
)?
|
(?:
www.|
[
-;:&=
\+\$
,
\w]
+@
)[
A-Za-z0-9.-
]
+
)((?:\/[\+
~%
\/
.
\w
-_
]
*
)?\??(?:[
-
\+
=&;%@.
\w
_
]
*
)
#
?(?:[\w]
*
))?)
$/
;
return
reg
.
test
(
path
);
};
export
const
batchTableSourceData
=
({
batchItem
,
tableData
,
bacthSecon
,
bacthFirst
})
=>
{
const
batchItemKey
=
Object
.
keys
(
batchItem
);
return
tableData
.
map
((
item
,
index
)
=>
{
if
(
!
bacthFirst
&&
!
bacthSecon
)
{
batchItemKey
.
forEach
(
key
=>
{
item
[
key
]
=
batchItem
[
key
]
||
null
;
});
}
if
(
bacthFirst
&&
!
bacthSecon
)
{
batchItemKey
.
forEach
(
key
=>
{
if
(
item
.
firstSpecValue
===
bacthFirst
)
{
item
[
key
]
=
batchItem
[
key
]
||
null
;
}
});
}
if
(
!
bacthFirst
&&
bacthSecon
)
{
batchItemKey
.
forEach
(
key
=>
{
if
(
item
.
secondSpecValue
===
bacthSecon
)
{
item
[
key
]
=
batchItem
[
key
]
||
null
;
}
});
}
if
(
bacthFirst
&&
bacthSecon
)
{
batchItemKey
.
forEach
(
key
=>
{
if
(
item
.
firstSpecValue
===
bacthFirst
&&
item
.
secondSpecValue
===
bacthSecon
)
{
item
[
key
]
=
batchItem
[
key
]
||
null
;
}
});
}
return
item
;
});
};
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