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