Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
91d47503
提交
91d47503
authored
5月 02, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
前端:商品编辑,部分逻辑,解决 sku 编辑的 bug 。
上级
e05f19dd
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
107 行增加
和
56 行删除
+107
-56
PicturesWall.js
admin-web/src/components/Image/PicturesWall.js
+21
-1
ProductAttrSelectFormItem.js
...n-web/src/components/Product/ProductAttrSelectFormItem.js
+9
-5
ProductSkuAddOrUpdateTable.js
...-web/src/components/Product/ProductSkuAddOrUpdateTable.js
+6
-3
productSpuAddOrUpdate.js
admin-web/src/models/product/productSpuAddOrUpdate.js
+31
-12
productSpuList.js
admin-web/src/models/product/productSpuList.js
+0
-22
ProductSpuAddOrUpdate.js
admin-web/src/pages/Product/ProductSpuAddOrUpdate.js
+32
-11
product.js
admin-web/src/services/product.js
+7
-1
AdminsProductSpuController.java
...ication/controller/admins/AdminsProductSpuController.java
+1
-1
没有找到文件。
admin-web/src/components/Image/PicturesWall.js
浏览文件 @
91d47503
...
...
@@ -137,6 +137,25 @@ class PicturesWall extends React.Component {
return
urls
;
};
setUrls
=
(
urls
)
=>
{
// let urls = this.props.urls;
if
(
urls
)
{
let
fileList
=
[];
for
(
let
i
in
urls
)
{
let
url
=
urls
[
i
];
fileList
.
push
({
uid
:
-
i
,
name
:
url
,
status
:
'done'
,
url
,
});
}
this
.
setState
({
fileList
:
fileList
,
})
}
};
render
()
{
const
{
previewVisible
,
previewImage
,
fileList
}
=
this
.
state
;
const
uploadButton
=
(
...
...
@@ -168,7 +187,8 @@ class PicturesWall extends React.Component {
};
PicturesWall
.
propTypes
=
{
maxLength
:
Number
,
maxLength
:
Number
,
// 最大照片墙图片数量
// urls: String[], // 初始图片列表
};
export
default
PicturesWall
;
admin-web/src/components/Product/ProductAttrSelectFormItem.js
浏览文件 @
91d47503
...
...
@@ -24,7 +24,7 @@ export default class ProductAttrSelectFormItem extends PureComponent {
}
},
});
}
}
;
handleSelectAttrValue
=
(
values
,
options
)
=>
{
let
attrValues
=
[];
...
...
@@ -87,15 +87,20 @@ export default class ProductAttrSelectFormItem extends PureComponent {
}
}
// 3. 拼装最终,添加到 attrTreeHTML 中
// debugger;
let
attrValues
=
[];
// 选中的规格值集合
for
(
let
i
in
attr
.
values
)
{
attrValues
.
push
(
attr
.
values
[
i
].
id
+
''
);
// Select 传入数组时,如果不 + '' ,选不中。
}
return
<
div
key
=
{
`div-attr-
${
index
}
`
}
>
<
Select
key
=
{
`select-attr-
${
index
}
`
}
style
=
{{
width
:
120
}}
placeholder
=
'请选择规格'
onChange
=
{
this
.
handleSelectAttr
}
>
<
Select
key
=
{
`select-attr-
${
index
}
`
}
style
=
{{
width
:
120
}}
placeholder
=
'请选择规格'
value
=
{
attr
.
id
}
onChange
=
{
this
.
handleSelectAttr
}
>
{
attrOptions
}
<
/Select
>
<
Select
key
=
{
`select-attr-value-
${
index
}
`
}
mode
=
{
"tags"
}
style
=
{{
width
:
260
}}
placeholder
=
'请选择规格值'
<
Select
key
=
{
`select-attr-value-
${
index
}
`
}
mode
=
{
"tags"
}
style
=
{{
width
:
260
}}
value
=
{
attrValues
}
placeholder
=
'请选择规格值'
onChange
=
{
this
.
handleSelectAttrValue
}
>
{
attrValueOptions
}
<
/Select
>
<
/div>
;
}
}
\ No newline at end of file
}
admin-web/src/components/Product/ProductSkuAddOrUpdateTable.js
浏览文件 @
91d47503
...
...
@@ -29,7 +29,8 @@ class SkuInputNumber extends PureComponent {
}
render
()
{
return
<
InputNumber
placeholder
=
"请输入"
onChange
=
{
this
.
handleChange
}
/
>
const
{
value
}
=
this
.
props
;
return
<
InputNumber
placeholder
=
"请输入"
value
=
{
value
}
onChange
=
{
this
.
handleChange
}
/
>
}
}
...
...
@@ -60,7 +61,8 @@ export default class ProductSkuAddOrUpdateTable extends PureComponent {
record
:
record
,
index
:
index
,
dispatch
:
dispatch
,
dataIndex
:
'price'
dataIndex
:
'price'
,
value
:
record
.
price
,
};
return
<
SkuInputNumber
{...
props
}
/>
;
}
...
...
@@ -73,7 +75,8 @@ export default class ProductSkuAddOrUpdateTable extends PureComponent {
record
:
record
,
index
:
index
,
dispatch
:
dispatch
,
dataIndex
:
'quantity'
dataIndex
:
'quantity'
,
value
:
record
.
quantity
,
};
return
<
SkuInputNumber
{...
props
}
/>
;
}
...
...
admin-web/src/models/product/productSpuAddOrUpdate.js
浏览文件 @
91d47503
import
{
message
}
from
'antd'
;
import
{
productCategoryTree
,
productSpuAdd
,
productCategoryUpdate
,
productCategoryUpdateStatus
,
productCategoryDelete
,
productSpuUpdate
,
productSpuInfo
}
from
'../../services/product'
;
import
{
bool
}
from
"prop-types"
;
export
default
{
namespace
:
'productSpuAddOrUpdate'
,
...
...
@@ -52,7 +50,7 @@ export default {
// payload: {},
// });
// },
*
info
({
payload
},
{
call
,
put
})
{
*
info
({
payload
,
callback
},
{
call
,
put
})
{
// 显示加载中
yield
put
({
type
:
'changeLoading'
,
...
...
@@ -109,10 +107,20 @@ export default {
};
attrTree
.
push
(
attrTreeNode
);
}
else
{
// let values = attrTreeNode.values;
// for (let k in ) {
//
// }
let
attrValueExists
=
false
;
let
values
=
attrTreeNode
.
values
;
for
(
let
k
in
values
)
{
if
(
values
[
k
].
id
===
attr
.
attrValueId
)
{
attrValueExists
=
true
;
break
;
}
}
if
(
!
attrValueExists
)
{
values
.
push
({
id
:
attr
.
attrValueId
,
name
:
attr
.
attrValueName
,
});
}
}
}
}
...
...
@@ -127,6 +135,11 @@ export default {
},
});
// 如果有回调,则执行回调方法
if
(
callback
)
{
callback
(
response
.
data
);
}
// 隐藏加载中
yield
put
({
type
:
'changeLoading'
,
...
...
@@ -190,7 +203,7 @@ export default {
},
*
update
({
payload
},
{
call
,
put
})
{
const
{
callback
,
body
}
=
payload
;
const
response
=
yield
call
(
productSpu
Add
,
body
);
const
response
=
yield
call
(
productSpu
Update
,
body
);
if
(
callback
)
{
callback
(
response
);
}
...
...
@@ -238,7 +251,13 @@ export default {
quantity
:
undefined
,
});
}
// let interval = skuSize; // 该间隔,用于下面规格组合
for
(
let
i
=
0
;
i
<
state
.
attrTree
.
length
;
i
++
)
{
// 初始化 sku 格子里的 attrs
if
(
i
===
1
)
{
// debugger;
}
let
values
=
state
.
attrTree
[
i
].
values
;
let
interval
=
skuSize
/
values
.
length
;
for
(
let
j
=
0
;
j
<
skuSize
;
j
++
)
{
// let values = state.attrTree[i].values;
// let attr = values[j % values.length];
...
...
@@ -246,8 +265,8 @@ export default {
// id: attr.id,
// name: attr.name,
// });
let
values
=
state
.
attrTree
[
i
].
values
;
let
attr
=
values
[
j
%
values
.
length
];
// let attr = values[j % values.length]
;
let
attr
=
values
[
parseInt
(
j
/
interval
)
];
skus
[
j
].
attrs
.
push
({
id
:
attr
.
id
,
name
:
attr
.
name
,
...
...
admin-web/src/models/product/productSpuList.js
浏览文件 @
91d47503
...
...
@@ -10,28 +10,6 @@ export default {
},
effects
:
{
// *add({ payload }, { call, put }) {
// const { callback, body } = payload;
// const response = yield call(productCategoryAdd, body);
// if (callback) {
// callback(response);
// }
// yield put({
// type: 'tree',
// payload: {},
// });
// },
// *update({ payload }, { call, put }) {
// const { callback, body } = payload;
// const response = yield call(productCategoryUpdate, body);
// if (callback) {
// callback(response);
// }
// yield put({
// type: 'tree',
// payload: {},
// });
// },
// *updateStatus({ payload }, { call, put }) {
// const { callback, body } = payload;
// const response = yield call(productCategoryUpdateStatus, body);
...
...
admin-web/src/pages/Product/ProductSpuAddOrUpdate.js
浏览文件 @
91d47503
...
...
@@ -44,16 +44,21 @@ class ProductSpuAddOrUpdate extends Component {
componentDidMount
()
{
const
{
dispatch
}
=
this
.
props
;
const
that
=
this
;
// 判断是否是更新
const
params
=
new
URLSearchParams
(
this
.
props
.
location
.
search
);
if
(
params
.
get
(
"id"
))
{
let
id
=
params
.
get
(
"id"
);
this
.
setState
({
modalType
:
'update'
,
id
:
id
,
})
dispatch
({
type
:
'productSpuAddOrUpdate/info'
,
payload
:
parseInt
(
id
),
callback
:
function
(
data
)
{
that
.
refs
.
picturesWall
.
setUrls
(
data
.
picUrls
);
// TODO 后续找找,有没更合适的做法
}
})
}
// 获得规格列表
...
...
@@ -84,8 +89,9 @@ class ProductSpuAddOrUpdate extends Component {
handleSubmit
=
e
=>
{
e
.
preventDefault
();
const
{
skus
,
dispatch
}
=
this
.
props
;
const
{
modalType
,
id
}
=
this
.
state
;
// 获得图片
let
picUrls
=
this
.
refs
.
picturesWall
.
getUrls
();
let
picUrls
=
this
.
refs
.
picturesWall
.
getUrls
();
// TODO 芋艿,后续找找其他做法
if
(
picUrls
.
length
===
0
)
{
alert
(
'请必须上传一张图片!'
);
return
;
...
...
@@ -113,17 +119,32 @@ class ProductSpuAddOrUpdate extends Component {
}
// debugger;
this
.
props
.
form
.
validateFields
((
err
,
values
)
=>
{
debugger
;
if
(
!
err
)
{
dispatch
({
type
:
'productSpuAddOrUpdate/add'
,
payload
:
{
body
:
{
...
values
,
picUrls
:
picUrls
.
join
(
','
),
skuStr
:
JSON
.
stringify
(
skuStr
)
}
},
});
if
(
modalType
===
'add'
)
{
dispatch
({
type
:
'productSpuAddOrUpdate/add'
,
payload
:
{
body
:
{
...
values
,
picUrls
:
picUrls
.
join
(
','
),
skuStr
:
JSON
.
stringify
(
skuStr
)
}
},
});
}
else
if
(
modalType
===
'update'
)
{
dispatch
({
type
:
'productSpuAddOrUpdate/update'
,
payload
:
{
body
:
{
...
values
,
id
,
picUrls
:
picUrls
.
join
(
','
),
skuStr
:
JSON
.
stringify
(
skuStr
)
}
},
});
}
}
});
// console.log(fields);
...
...
admin-web/src/services/product.js
浏览文件 @
91d47503
...
...
@@ -39,7 +39,6 @@ export async function productCategoryDelete(params) {
// product spu + sku
export
async
function
productSpuPage
(
params
)
{
debugger
;
return
request
(
`/product-api/admins/spu/page?
${
stringify
(
params
)}
`
,
{
method
:
'GET'
,
});
...
...
@@ -52,6 +51,13 @@ export async function productSpuAdd(params) {
});
}
export
async
function
productSpuUpdate
(
params
)
{
return
request
(
`/product-api/admins/spu/update?
${
stringify
(
params
)}
`
,
{
method
:
'POST'
,
body
:
{},
});
}
export
async
function
productSpuInfo
(
params
)
{
return
request
(
`/product-api/admins/spu/info?
${
stringify
(
params
)}
`
,
{
method
:
'GET'
,
...
...
product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java
浏览文件 @
91d47503
...
...
@@ -84,7 +84,7 @@ public class AdminsProductSpuController {
@RequestParam
(
"sellPoint"
)
String
sellPoint
,
@RequestParam
(
"description"
)
String
description
,
@RequestParam
(
"cid"
)
Integer
cid
,
@RequestParam
(
"picU
RL
s"
)
List
<
String
>
picUrls
,
@RequestParam
(
"picU
rl
s"
)
List
<
String
>
picUrls
,
@RequestParam
(
"visible"
)
Boolean
visible
,
@RequestParam
(
"skuStr"
)
String
skuStr
)
{
// TODO 芋艿,因为考虑不使用 json 接受参数,所以这里手动转。
// 创建 ProductSpuUpdateDTO 对象
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论