Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
582837fe
提交
582837fe
authored
5月 02, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
前端:商品编辑,部分逻辑,解决 sku 编辑的 bug 。
上级
942d2c06
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
113 行增加
和
45 行删除
+113
-45
ProductAttrSelectFormItem.js
...n-web/src/components/Product/ProductAttrSelectFormItem.js
+74
-32
defaultSettings.js
admin-web/src/defaultSettings.js
+1
-1
UserLayout.js
admin-web/src/layouts/UserLayout.js
+1
-1
productAttrList.js
admin-web/src/models/product/productAttrList.js
+24
-1
ProductSpuAddOrUpdate.js
admin-web/src/pages/Product/ProductSpuAddOrUpdate.js
+5
-9
document.ejs
admin-web/src/pages/document.ejs
+1
-1
product.js
admin-web/src/services/product.js
+7
-0
没有找到文件。
admin-web/src/components/Product/ProductAttrSelectFormItem.js
浏览文件 @
582837fe
...
...
@@ -3,9 +3,72 @@ import {Select} from "antd";
const
Option
=
Select
.
Option
;
class
AttrValueSelect
extends
Select
{
handleSelectAttrValue
=
(
value
,
option
)
=>
{
};
render
()
{
const
{
index
,
attrValues
,
attrValueOptions
,
attr
}
=
this
.
props
;
const
handleChangeAttrValue
=
async
(
values
,
options
)
=>
{
let
attrValues
=
[];
const
{
dispatch
,
index
}
=
this
.
props
;
// debugger;
// console.log('x' + this.children[0]);
// let firstOption = this.children[0];
// let attrIndex = firstOption.key.substring(firstOption.key.indexOf('option-attr-value-') + 'option-attr-value-'.length, firstOption.key.lastIndexOf('-'));
for
(
let
i
in
options
)
{
let
option
=
options
[
i
];
// TODO 芋艿,这个做法很不优雅,后面看俺。需要问下 answer 。
let
attrValueId
=
undefined
;
if
(
option
.
key
.
indexOf
(
'option-attr-value-'
)
===
-
1
)
{
await
dispatch
({
type
:
'productAttrList/addValue'
,
payload
:
{
attrId
:
attr
.
id
,
name
:
option
.
props
.
children
,
},
callback
:
function
(
data
)
{
attrValueId
=
data
.
id
;
}
});
}
else
{
attrValueId
=
parseInt
(
option
.
props
.
value
);
}
// 添加到 attrValues 中。
// debugger;
attrValues
.
push
({
id
:
attrValueId
,
name
:
option
.
props
.
children
,
});
}
dispatch
({
type
:
'productSpuAddOrUpdate/selectAttrValues'
,
payload
:
{
attrIndex
:
index
,
attrValues
:
attrValues
,
},
});
// debugger;
// console.log(value);
};
return
<
Select
key
=
{
`select-attr-value-
${
index
}
`
}
mode
=
{
"tags"
}
style
=
{{
width
:
260
}}
value
=
{
attrValues
}
placeholder
=
'请选择规格值'
onChange
=
{
handleChangeAttrValue
}
onSelect
=
{
this
.
handleSelectAttrValue
}
>
{
attrValueOptions
}
<
/Select>
;
}
}
export
default
class
ProductAttrSelectFormItem
extends
PureComponent
{
handleSelectAttr
=
(
value
,
option
)
=>
{
debugger
;
// console.log(value);
// console.log(option);
// debugger;
...
...
@@ -26,34 +89,8 @@ export default class ProductAttrSelectFormItem extends PureComponent {
});
};
handleSelectAttrValue
=
(
values
,
options
)
=>
{
let
attrValues
=
[];
const
{
dispatch
,
index
}
=
this
.
props
;
// debugger;
// console.log('x' + this.children[0]);
// let firstOption = this.children[0];
// let attrIndex = firstOption.key.substring(firstOption.key.indexOf('option-attr-value-') + 'option-attr-value-'.length, firstOption.key.lastIndexOf('-'));
for
(
let
i
in
options
)
{
let
option
=
options
[
i
];
attrValues
.
push
({
id
:
parseInt
(
option
.
props
.
value
),
name
:
option
.
props
.
children
,
});
}
dispatch
({
type
:
'productSpuAddOrUpdate/selectAttrValues'
,
payload
:
{
attrIndex
:
index
,
attrValues
:
attrValues
,
},
});
// debugger;
// console.log(value);
}
render
()
{
const
{
attr
,
allAttrTree
,
selectedAttrIds
,
index
}
=
this
.
props
;
const
{
attr
,
allAttrTree
,
selectedAttrIds
,
index
,
dispatch
}
=
this
.
props
;
// console.log('i: ' + i);
// 1. 规格
let
attrOptions
=
[];
...
...
@@ -92,14 +129,19 @@ export default class ProductAttrSelectFormItem extends PureComponent {
for
(
let
i
in
attr
.
values
)
{
attrValues
.
push
(
attr
.
values
[
i
].
id
+
''
);
// Select 传入数组时,如果不 + '' ,选不中。
}
let
attrValueSelectProps
=
{
index
:
index
,
attrValues
:
attrValues
,
dispatch
:
dispatch
,
attrValueOptions
:
attrValueOptions
,
attr
:
attr
,
};
// TODO BUG ,规格不能搜索添加
return
<
div
key
=
{
`div-attr-
${
index
}
`
}
>
<
Select
key
=
{
`select-attr-
${
index
}
`
}
s
tyle
=
{{
width
:
120
}}
placeholder
=
'请选择规格'
value
=
{
attr
.
id
}
onChange
=
{
this
.
handleSelect
Attr
}
>
<
Select
key
=
{
`select-attr-
${
index
}
`
}
s
howSearch
optionFilterProp
=
"children"
style
=
{{
width
:
120
}}
placeholder
=
'请选择规格'
value
=
{
attr
.
id
}
onChange
=
{
this
.
handleSelectAttr
}
onSearch
=
{
this
.
handleSearch
Attr
}
>
{
attrOptions
}
<
/Select
>
<
Select
key
=
{
`select-attr-value-
${
index
}
`
}
mode
=
{
"tags"
}
style
=
{{
width
:
260
}}
value
=
{
attrValues
}
placeholder
=
'请选择规格值'
onChange
=
{
this
.
handleSelectAttrValue
}
>
{
attrValueOptions
}
<
/Select
>
<
AttrValueSelect
{...
attrValueSelectProps
}
/
>
<
/div>
;
}
...
...
admin-web/src/defaultSettings.js
浏览文件 @
582837fe
...
...
@@ -9,7 +9,7 @@ module.exports = {
menu
:
{
disableLocal
:
false
,
},
title
:
'
小
商城管理平台'
,
title
:
'
一个
商城管理平台'
,
pwa
:
true
,
// your iconfont Symbol Scrip Url
// eg://at.alicdn.com/t/font_1039637_btcrd5co4w.js
...
...
admin-web/src/layouts/UserLayout.js
浏览文件 @
582837fe
...
...
@@ -61,7 +61,7 @@ class UserLayout extends Component {
<
div
className
=
{
styles
.
header
}
>
<
Link
to
=
"/"
>
<
img
alt
=
"logo"
className
=
{
styles
.
logo
}
src
=
{
logo
}
/
>
<
span
className
=
{
styles
.
title
}
>
小
商城管理平台
<
/span
>
<
span
className
=
{
styles
.
title
}
>
一个
商城管理平台
<
/span
>
<
/Link
>
<
/div
>
{
/*<div className={styles.desc}>TODO....</div>*/
}
...
...
admin-web/src/models/product/productAttrList.js
浏览文件 @
582837fe
import
{
message
}
from
'antd'
;
import
{
productAttrTree
}
from
'../../services/product'
;
import
{
productAttrTree
,
productAttrValueAdd
}
from
'../../services/product'
;
export
default
{
namespace
:
'productAttrList'
,
...
...
@@ -62,6 +62,29 @@ export default {
},
});
},
*
addValue
({
payload
,
callback
},
{
call
,
put
})
{
// debugger;
// const {queryParams} = payload;
const
response
=
yield
call
(
productAttrValueAdd
,
payload
);
// message.info('查询成功!');
// yield put({
// type: 'treeSuccess',
// payload: {
// tree: response.data,
// },
// });
if
(
response
.
code
===
0
)
{
// 刷新规格列表
yield
put
({
type
:
'tree'
,
payload
:
{},
});
// 回调方法
if
(
callback
)
{
callback
(
response
.
data
);
}
}
}
},
reducers
:
{
...
...
admin-web/src/pages/Product/ProductSpuAddOrUpdate.js
浏览文件 @
582837fe
...
...
@@ -119,7 +119,7 @@ class ProductSpuAddOrUpdate extends Component {
}
// debugger;
this
.
props
.
form
.
validateFields
((
err
,
values
)
=>
{
debugger
;
//
debugger;
if
(
!
err
)
{
if
(
modalType
===
'add'
)
{
dispatch
({
...
...
@@ -228,14 +228,10 @@ class ProductSpuAddOrUpdate extends Component {
)}
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"商品规格"
>
{
form
.
getFieldDecorator
(
'visible'
,
{
initialValue
:
1
,
// TODO 修改
})(
<
div
>
{
attrTreeHTML
}
<
Button
onClick
=
{
this
.
handleAddAttr
}
>
添加规格项目
<
/Button
>
<
/div
>
)}
<
div
>
{
attrTreeHTML
}
<
Button
onClick
=
{
this
.
handleAddAttr
}
>
添加规格项目
<
/Button
>
<
/div
>
<
/FormItem
>
{
attrTree
.
length
>
0
?
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"规格明细"
>
...
...
admin-web/src/pages/document.ejs
浏览文件 @
582837fe
...
...
@@ -7,7 +7,7 @@
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/>
<title>
小
商城管理平台
</title>
<title>
一个
商城管理平台
</title>
<link
rel=
"icon"
href=
"/favicon.png"
type=
"image/x-icon"
/>
</head>
<body>
...
...
admin-web/src/services/product.js
浏览文件 @
582837fe
...
...
@@ -71,3 +71,10 @@ export async function productAttrTree(params) {
method
:
'GET'
,
});
}
export
async
function
productAttrValueAdd
(
params
)
{
return
request
(
`/product-api/admins//attr_value/add?
${
stringify
(
params
)}
`
,
{
method
:
'POST'
,
body
:
{},
});
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论