Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
admin
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
admin
Commits
f1c0ad15
提交
f1c0ad15
authored
8月 11, 2023
作者:
龚洪江
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复:商城商品sku新增,编辑问题修复
上级
fc0118ea
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
46 行增加
和
27 行删除
+46
-27
index.tsx
src/components/EditableCell/index.tsx
+12
-4
index.tsx
...Goods/goodsAddOrEditOrDetail/components/skuInfo/index.tsx
+32
-21
index.tsx
...ges/mallManage/mallGoods/goodsAddOrEditOrDetail/index.tsx
+2
-2
没有找到文件。
src/components/EditableCell/index.tsx
浏览文件 @
f1c0ad15
...
@@ -20,6 +20,7 @@ const EditableCell: React.FC<
...
@@ -20,6 +20,7 @@ const EditableCell: React.FC<
uploadSuccess
?:
(
record
:
any
,
result
:
any
)
=>
void
;
uploadSuccess
?:
(
record
:
any
,
result
:
any
)
=>
void
;
rules
?:
any
;
rules
?:
any
;
maxLength
?:
number
;
maxLength
?:
number
;
placeholder
?:
string
;
}
}
>
=
({
>
=
({
editing
,
editing
,
...
@@ -34,15 +35,16 @@ const EditableCell: React.FC<
...
@@ -34,15 +35,16 @@ const EditableCell: React.FC<
children
,
children
,
rules
,
rules
,
maxLength
,
maxLength
,
placeholder
,
...
restProps
...
restProps
})
=>
{
})
=>
{
const
inputNode
=
()
=>
{
const
inputNode
=
()
=>
{
switch
(
inputType
)
{
switch
(
inputType
)
{
case
'number'
:
case
'number'
:
return
<
InputNumber
placeholder=
{
`请输入${title}`
}
maxLength=
{
maxLength
}
/>;
return
<
InputNumber
placeholder=
{
`请输入${
placeholder ||
title}`
}
maxLength=
{
maxLength
}
/>;
case
'select'
:
case
'select'
:
return
(
return
(
<
Select
placeholder=
{
`请选择${title}`
}
style=
{
{
textAlign
:
'start'
}
}
>
<
Select
placeholder=
{
`请选择${
placeholder ||
title}`
}
style=
{
{
textAlign
:
'start'
}
}
>
{
selectOption
&&
{
selectOption
&&
selectOption
.
map
((
v
)
=>
(
selectOption
.
map
((
v
)
=>
(
<
Select
.
Option
value=
{
v
.
id
}
key=
{
v
.
id
}
>
<
Select
.
Option
value=
{
v
.
id
}
key=
{
v
.
id
}
>
...
@@ -73,9 +75,15 @@ const EditableCell: React.FC<
...
@@ -73,9 +75,15 @@ const EditableCell: React.FC<
</
Radio
.
Group
>
</
Radio
.
Group
>
);
);
case
'textArea'
:
case
'textArea'
:
return
<
Input
.
TextArea
placeholder=
{
`请输入${title}`
}
maxLength=
{
maxLength
}
showCount
/>;
return
(
<
Input
.
TextArea
placeholder=
{
`请输入${placeholder || title}`
}
maxLength=
{
maxLength
}
showCount
/>
);
default
:
default
:
return
<
Input
placeholder=
{
`请输入${title}`
}
maxLength=
{
maxLength
}
/>;
return
<
Input
placeholder=
{
`请输入${
placeholder ||
title}`
}
maxLength=
{
maxLength
}
/>;
}
}
};
};
return
(
return
(
...
...
src/pages/mallManage/mallGoods/goodsAddOrEditOrDetail/components/skuInfo/index.tsx
浏览文件 @
f1c0ad15
...
@@ -98,6 +98,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -98,6 +98,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
rules
?:
any
;
rules
?:
any
;
maxLength
?:
number
;
maxLength
?:
number
;
children
?:
any
;
children
?:
any
;
placeholder
?:
string
;
})[]
})[]
>
([
>
([
{
{
...
@@ -113,19 +114,27 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -113,19 +114,27 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
inputType
:
'uploader'
,
inputType
:
'uploader'
,
},
},
{
{
title
:
'sku编号'
,
title
:
'sku编号
(料号)
'
,
align
:
'center'
,
align
:
'center'
,
editable
:
true
,
editable
:
true
,
dataIndex
:
'skuNo'
,
dataIndex
:
'skuNo'
,
maxLength
:
30
,
maxLength
:
30
,
width
:
'15%'
,
},
},
{
{
title
:
'销售价'
,
title
:
(
<
div
>
<
span
style=
{
{
color
:
'red'
}
}
>
*
</
span
>
<
span
>
销售价
</
span
>
</
div
>
),
align
:
'center'
,
align
:
'center'
,
editable
:
true
,
editable
:
true
,
dataIndex
:
'salePrice'
,
dataIndex
:
'salePrice'
,
rules
:
[{
required
:
true
,
validator
:
salePriceValidator
}],
rules
:
[{
required
:
true
,
validator
:
salePriceValidator
}],
inputType
:
'number'
,
inputType
:
'number'
,
onHeaderCell
:
()
=>
({
className
:
'custom-header-cell'
}),
placeholder
:
'销售价'
,
},
},
{
{
title
:
'渠道价'
,
title
:
'渠道价'
,
...
@@ -160,6 +169,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -160,6 +169,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
inputType
:
col
.
inputType
,
inputType
:
col
.
inputType
,
uploadSuccess
:
col
.
inputType
===
'uploader'
?
uploadSuccess
:
undefined
,
uploadSuccess
:
col
.
inputType
===
'uploader'
?
uploadSuccess
:
undefined
,
rules
:
col
.
rules
,
rules
:
col
.
rules
,
placeholder
:
col
.
placeholder
,
}),
}),
};
};
});
});
...
@@ -196,6 +206,8 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -196,6 +206,8 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
};
};
// 删除规格项目
// 删除规格项目
const
deleteSpecificationClick
=
(
index
:
number
)
=>
{
const
deleteSpecificationClick
=
(
index
:
number
)
=>
{
console
.
log
(
'数据-->'
,
specificationFormList
[
index
]);
form
.
setFieldValue
(
specificationFormList
[
index
].
name
,
undefined
);
specificationFormList
.
splice
(
index
,
1
);
specificationFormList
.
splice
(
index
,
1
);
combineSpecificationValue
();
combineSpecificationValue
();
setSpecificationFormList
([...
specificationFormList
]);
setSpecificationFormList
([...
specificationFormList
]);
...
@@ -205,9 +217,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -205,9 +217,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
specificationFormList
[
index
].
optionList
=
e
.
target
.
value
specificationFormList
[
index
].
optionList
=
e
.
target
.
value
?
[{
label
:
e
.
target
.
value
,
value
:
e
.
target
.
value
}]
?
[{
label
:
e
.
target
.
value
,
value
:
e
.
target
.
value
}]
:
[];
:
[];
const
obj
=
Object
.
create
(
null
);
form
.
setFieldValue
(
specificationFormList
[
index
].
name
,
e
.
target
.
value
);
obj
[
specificationFormList
[
index
].
name
]
=
e
.
target
.
value
||
undefined
;
form
.
setFieldsValue
(
obj
);
setSpecificationFormList
([...
specificationFormList
]);
setSpecificationFormList
([...
specificationFormList
]);
};
};
//规格值添加
//规格值添加
...
@@ -248,25 +258,29 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -248,25 +258,29 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
const
combineSpecificationValue
=
()
=>
{
const
combineSpecificationValue
=
()
=>
{
let
combineSpecificationList
:
any
=
[];
let
combineSpecificationList
:
any
=
[];
let
tableDataList
:
any
=
[];
let
tableDataList
:
any
=
[];
if
(
specificationFormList
.
length
>
1
)
{
//过滤规格值为空的
const
combineList
=
specificationFormList
.
reduce
((
pre
:
any
,
cur
,
currentIndex
)
=>
{
const
filterSpecificationFormList
=
specificationFormList
.
filter
(
(
v
)
=>
v
.
specificationValueList
.
length
,
);
if
(
filterSpecificationFormList
.
length
>
1
)
{
const
combineList
=
filterSpecificationFormList
.
reduce
((
pre
:
any
,
cur
,
currentIndex
)
=>
{
// 首次组合两个数据
// 首次组合两个数据
if
(
currentIndex
===
0
&&
s
pecificationFormList
.
length
>
1
)
{
if
(
currentIndex
===
0
&&
filterS
pecificationFormList
.
length
>
1
)
{
combineSpecificationList
=
combineEvent
(
combineSpecificationList
=
combineEvent
(
cur
.
specificationValueList
,
cur
.
specificationValueList
,
s
pecificationFormList
[
currentIndex
+
1
].
specificationValueList
,
filterS
pecificationFormList
[
currentIndex
+
1
].
specificationValueList
,
);
);
//二维数组拆分为对象
//二维数组拆分为对象
combineSpecificationList
=
getCombineObj
(
combineSpecificationList
);
combineSpecificationList
=
getCombineObj
(
combineSpecificationList
);
// 两个数据以上的组合
// 两个数据以上的组合
}
else
if
(
}
else
if
(
currentIndex
<
s
pecificationFormList
.
length
-
1
&&
currentIndex
<
filterS
pecificationFormList
.
length
-
1
&&
s
pecificationFormList
[
currentIndex
+
1
].
specificationValueList
.
length
filterS
pecificationFormList
[
currentIndex
+
1
].
specificationValueList
.
length
)
{
)
{
// 上一次的组合作为下一次组合的参数
// 上一次的组合作为下一次组合的参数
combineSpecificationList
=
combineEvent
(
combineSpecificationList
=
combineEvent
(
combineSpecificationList
,
combineSpecificationList
,
s
pecificationFormList
[
currentIndex
+
1
].
specificationValueList
,
filterS
pecificationFormList
[
currentIndex
+
1
].
specificationValueList
,
);
);
//二维数组拆分为对象
//二维数组拆分为对象
combineSpecificationList
=
getCombineObj
(
combineSpecificationList
);
combineSpecificationList
=
getCombineObj
(
combineSpecificationList
);
...
@@ -291,9 +305,9 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -291,9 +305,9 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
});
});
return
pre
;
return
pre
;
},
[]);
},
[]);
}
else
{
}
else
if
(
filterSpecificationFormList
.
length
===
1
)
{
//当存在一个规格项时
//当存在一个规格项时
tableDataList
=
s
pecificationFormList
[
0
].
specificationValueList
.
map
((
v
)
=>
{
tableDataList
=
filterS
pecificationFormList
[
0
].
specificationValueList
.
map
((
v
)
=>
{
const
obj
=
Object
.
create
(
null
);
const
obj
=
Object
.
create
(
null
);
obj
[
'name1'
]
=
v
.
name
;
obj
[
'name1'
]
=
v
.
name
;
obj
[
'specificationName1'
]
=
v
.
specificationName
;
obj
[
'specificationName1'
]
=
v
.
specificationName
;
...
@@ -306,10 +320,6 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -306,10 +320,6 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
});
});
}
}
if
(
tableDataList
.
length
)
{
if
(
tableDataList
.
length
)
{
//过滤规格值为空的
const
filterSpecificationFormList
=
specificationFormList
.
filter
(
(
v
)
=>
v
.
specificationValueList
.
length
,
);
setTableFormDefault
(
tableDataList
);
setTableFormDefault
(
tableDataList
);
mergeTableRow
(
filterSpecificationFormList
);
mergeTableRow
(
filterSpecificationFormList
);
}
}
...
@@ -391,11 +401,11 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -391,11 +401,11 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
form
form
.
validateFields
()
.
validateFields
()
.
then
(()
=>
{
.
then
(()
=>
{
const
specificationFormItem
Index
=
specificationFormList
.
findIndex
(
const
specificationFormItem
=
specificationFormList
.
find
(
(
v
)
=>
!
v
.
specificationValueList
.
length
,
(
v
)
=>
!
v
.
specificationValueList
.
length
,
);
);
if
(
specificationFormItem
Index
!==
-
1
)
{
if
(
specificationFormItem
)
{
re
turn
message
.
warning
(
`请为规格项
${
specificationFormItemIndex
}
添加规格值`
);
re
ject
(
`请为规格项
${
specificationFormItem
.
optionList
[
0
].
value
}
添加规格值`
);
}
else
{
}
else
{
//规格项数据转化
//规格项数据转化
const
specAttrList
=
specificationFormList
.
map
((
v
)
=>
({
const
specAttrList
=
specificationFormList
.
map
((
v
)
=>
({
...
@@ -580,6 +590,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
...
@@ -580,6 +590,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ goodsDetailsInfo }, ref) => {
<
Input
<
Input
placeholder=
'请输入规格值,按回车键完成'
placeholder=
'请输入规格值,按回车键完成'
onPressEnter=
{
(
e
)
=>
specificationValuePressEnter
(
e
,
index
)
}
onPressEnter=
{
(
e
)
=>
specificationValuePressEnter
(
e
,
index
)
}
maxLength=
{
30
}
/>
/>
)
:
(
)
:
(
<
Button
<
Button
...
...
src/pages/mallManage/mallGoods/goodsAddOrEditOrDetail/index.tsx
浏览文件 @
f1c0ad15
...
@@ -74,8 +74,8 @@ const GoodsAddOrEditOrDetail = () => {
...
@@ -74,8 +74,8 @@ const GoodsAddOrEditOrDetail = () => {
.
then
(()
=>
{
.
then
(()
=>
{
setTabSelectKeys
((
Number
(
tabSelectKeys
)
+
1
).
toString
());
setTabSelectKeys
((
Number
(
tabSelectKeys
)
+
1
).
toString
());
})
})
.
catch
(()
=>
{
.
catch
((
error
:
any
)
=>
{
message
.
warning
(
'请添加规格'
);
message
.
warning
(
error
?.
errorFields
?.[
0
].
errors
[
0
]
||
error
);
});
});
break
;
break
;
case
'3'
:
case
'3'
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论