Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
ecc5cf88
提交
ecc5cf88
authored
3月 17, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
前端:商品添加。提交部分,让小范帮忙看看~
上级
45dfd137
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
57 行增加
和
16 行删除
+57
-16
productSpuAddOrUpdate.js
admin-web/src/models/product/productSpuAddOrUpdate.js
+19
-4
ProductSpuAddOrUpdate.js
admin-web/src/pages/Product/ProductSpuAddOrUpdate.js
+38
-12
没有找到文件。
admin-web/src/models/product/productSpuAddOrUpdate.js
浏览文件 @
ecc5cf88
...
...
@@ -6,9 +6,7 @@ export default {
state
:
{
list
:
[],
attrTree
:
[{
}
attrTree
:
[
// {
// id: //
// name: //
...
...
@@ -73,17 +71,34 @@ export default {
},
});
},
*
selectAttr
({
payload
},
{
call
,
put
})
{
// const { queryParams } = payload;
// const response = yield call(productCategoryTree, queryParams);
message
.
info
(
'调试:添加规格成功!'
);
yield
put
({
type
:
'selectAttrSuccess'
,
payload
:
payload
,
});
},
},
reducers
:
{
addAttrSuccess
(
state
,
{
payload
})
{
// debugger;
console
.
log
(
state
.
attrTree
);
//
console.log(state.attrTree);
state
.
attrTree
.
push
(
payload
.
attrAdd
);
return
{
...
state
}
},
selectAttrSuccess
(
state
,
{
payload
})
{
// debugger;
// console.log(state.attrTree);
state
.
attrTree
[
payload
.
attrIndex
]
=
payload
.
attr
;
return
{
...
state
}
},
treeSuccess
(
state
,
{
payload
})
{
return
{
...
state
,
...
...
admin-web/src/pages/Product/ProductSpuAddOrUpdate.js
浏览文件 @
ecc5cf88
/* eslint-disable */
import
React
,
{
PureComponent
,
Fragment
}
from
'react'
;
import
React
,
{
PureComponent
,
Fragment
,
Component
}
from
'react'
;
import
{
connect
}
from
'dva'
;
import
moment
from
'moment'
;
import
{
Card
,
Form
,
Input
,
Radio
,
Button
,
Table
,
Select
}
from
'antd'
;
...
...
@@ -16,12 +16,14 @@ const Option = Select.Option;
@
connect
(({
productSpuList
,
productAttrList
,
productSpuAddOrUpdate
,
loading
})
=>
({
// list: productSpuList.list.spus,
// loading: loading.models.productSpuList,
productAttrList
,
productSpuAddOrUpdate
,
allAttrTree
:
productAttrList
.
tree
,
attrTree
:
productSpuAddOrUpdate
.
attrTree
}))
@
Form
.
create
()
class
ProductSpuAddOrUpdate
extends
Pure
Component
{
class
ProductSpuAddOrUpdate
extends
Component
{
state
=
{
modalVisible
:
false
,
modalType
:
'add'
,
//add update
...
...
@@ -65,9 +67,30 @@ class ProductSpuAddOrUpdate extends PureComponent {
});
}
handleSelectAttr
=
(
value
,
option
)
=>
{
console
.
log
(
value
);
console
.
log
(
option
);
debugger
;
const
{
dispatch
}
=
this
.
props
;
let
attrIndex
=
option
.
key
.
substring
(
option
.
key
.
indexOf
(
'option-attr-'
)
+
'option-attr-'
.
length
,
option
.
key
.
lastIndexOf
(
'-'
));
console
.
log
(
'attrIndex: '
+
attrIndex
);
debugger
;
dispatch
({
type
:
'productSpuAddOrUpdate/selectAttr'
,
payload
:
{
attrIndex
:
attrIndex
,
attr
:
{
id
:
option
.
props
.
value
,
name
:
option
.
props
.
children
,
}
},
});
}
render
()
{
// debugger;
const
{
form
,
data
,
attrTree
}
=
this
.
props
;
const
{
form
,
data
,
attrTree
,
allAttrTree
}
=
this
.
props
;
const
that
=
this
;
// 规格明细
const
columns
=
[
...
...
@@ -94,19 +117,22 @@ class ProductSpuAddOrUpdate extends PureComponent {
if
(
attrTree
&&
attrTree
.
length
>
0
)
{
for
(
let
i
in
attrTree
)
{
let
attr
=
attrTree
[
i
];
attr
=
<
div
>
<
Select
defaultValue
=
"lucy"
style
=
{{
width
:
120
}}
>
{
// console.log('i: ' + i);
// 1. 规格
let
options
=
[];
for
(
let
j
in
allAttrTree
)
{
let
attr
=
allAttrTree
[
j
];
options
.
push
(
<
Option
key
=
{
`option-attr-
${
i
}
-
${
attr
.
id
}
`
}
value
=
{
attr
.
id
}
>
{
attr
.
name
}
<
/Option>
)
;
}
<
Option
value
=
"jack"
>
Jack
<
/Option
>
<
Option
value
=
"lucy"
>
Lucy
<
/Option
>
<
Option
value
=
"disabled"
disabled
>
Disabled
<
/Option
>
<
Option
value
=
"Yiminghe"
>
yiminghe
<
/Option
>
// 2. 规格值
// 3. 拼装最终,添加到 attrTreeHTML 中
attr
=
<
div
key
=
{
`div-attr-
${
i
}
`
}
>
<
Select
key
=
{
`select-attr-
${
i
}
`
}
style
=
{{
width
:
120
}}
placeholder
=
'请选择规格'
onChange
=
{
that
.
handleSelectAttr
}
>
{
options
}
<
/Select
>
<
/div>
;
attrTreeHTML
.
push
(
attr
);
// debugger;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论