Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ufo
/
ufo-platform
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
caoyan
7 years ago
Commit
88ef5248f2a40de4f7e77b108ab03bbf468c7056
2 parents
99309a64
b0672d92
Merge branch 'master' of
http://git.yoho.cn/ufo/ufo-platform
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
644 additions
and
251 deletions
common/pom.xml
common/src/main/java/com/yoho/ufo/service/impl/InboxService.java
pom.xml
product/pom.xml
product/src/main/java/com/yoho/ufo/service/impl/ProductServiceImpl.java
web/src/main/webapp/html/goods/storage/storageDetail.html
web/src/main/webapp/html/goods/storage/storageList.html
web/src/main/webapp/html/product/productEdit.html
web/src/main/webapp/html/product/productList.html
common/pom.xml
View file @
88ef524
...
...
@@ -53,6 +53,9 @@
<artifactId>
poi-ooxml
</artifactId>
<version>
3.16
</version>
</dependency>
<dependency>
<artifactId>
yohoufo-fore-inboxclient
</artifactId>
<groupId>
com.yohoufo.fore
</groupId>
</dependency>
</dependencies>
</project>
...
...
common/src/main/java/com/yoho/ufo/service/impl/InboxService.java
0 → 100644
View file @
88ef524
package
com
.
yoho
.
ufo
.
service
.
impl
;
import
com.yohoufo.inboxclient.model.InBoxResponse
;
import
com.yohoufo.inboxclient.model.InboxReqVO
;
import
com.yohoufo.inboxclient.sdk.InBoxSDK
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* Created by li.ma on 2018/9/26.
* 发消息推送的接口
*/
@Service
public
class
InboxService
{
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
InboxService
.
class
);
@Autowired
private
InBoxSDK
inBoxSDK
;
// 场景的枚举值参考 com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum
public
InBoxResponse
addInbox
(
Integer
businessType
,
Integer
type
,
String
params
,
int
uid
){
log
.
info
(
"addInbox with businessType is {}, type is {}, params is {}, uid is {}"
,
businessType
,
type
,
params
,
uid
);
InboxReqVO
reqVO
=
new
InboxReqVO
();
reqVO
.
setBusinessType
(
businessType
);
reqVO
.
setParams
(
params
);
reqVO
.
setType
(
type
);
reqVO
.
setUid
(
uid
);
InBoxResponse
inBoxResponse
=
inBoxSDK
.
addInbox
(
reqVO
);
log
.
info
(
"addInbox call result is {}"
,
inBoxResponse
);
return
inBoxResponse
;
}
}
...
...
pom.xml
View file @
88ef524
...
...
@@ -19,6 +19,7 @@
<project-name>
ufo-platform
</project-name>
<spring.version>
4.3.8.RELEASE
</spring.version>
<ufo.model.version>
1.0-SNAPSHOT
</ufo.model.version>
<inboxclient.version>
1.0.0-SNAPSHOT
</inboxclient.version>
</properties>
<dependencyManagement>
...
...
@@ -79,7 +80,11 @@
<artifactId>
pinyin4j
</artifactId>
<version>
2.5.0
</version>
</dependency>
<dependency>
<artifactId>
yohoufo-fore-inboxclient
</artifactId>
<groupId>
com.yohoufo.fore
</groupId>
<version>
${inboxclient.version}
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
product/pom.xml
View file @
88ef524
...
...
@@ -52,6 +52,4 @@
<artifactId>
mybatis-spring
</artifactId>
</dependency>
</dependencies>
</project>
...
...
product/src/main/java/com/yoho/ufo/service/impl/ProductServiceImpl.java
View file @
88ef524
...
...
@@ -71,6 +71,8 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
private
StoragePriceMapper
storagePriceMapper
;
@Autowired
private
UfoSizeMapper
sizeMapper
;
@Autowired
private
InboxService
inboxService
;
@Override
public
ApiResponse
<
Void
>
addOrUpdate
(
ProductRequestBo
bo
)
{
...
...
@@ -142,12 +144,14 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
private
List
<
Storage
>
getStoragesFromBo
(
ProductRequestBo
bo
)
{
List
<
Storage
>
storageList
=
new
ArrayList
<>();
for
(
Integer
id
:
bo
.
getSizeIdList
())
{
Storage
s
=
new
Storage
();
s
.
setCreateTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
));
s
.
setSizeId
(
id
);
s
.
setStorageNum
(
0
);
storageList
.
add
(
s
);
if
(
CollectionUtils
.
isNotEmpty
(
bo
.
getSizeIdList
()))
{
for
(
Integer
id
:
bo
.
getSizeIdList
())
{
Storage
s
=
new
Storage
();
s
.
setCreateTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
));
s
.
setSizeId
(
id
);
s
.
setStorageNum
(
0
);
storageList
.
add
(
s
);
}
}
return
storageList
;
}
...
...
@@ -230,7 +234,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
if
(
bo
.
getColorId
()
==
null
||
bo
.
getColorId
()
<
1
)
{
throw
new
CommonException
(
400
,
"请选择颜色"
);
}
if
(
CollectionUtils
.
isEmpty
(
bo
.
getSizeIdList
()))
{
if
(
(
bo
.
getId
()
==
null
||
bo
.
getId
()
<
1
)
&&
CollectionUtils
.
isEmpty
(
bo
.
getSizeIdList
()))
{
throw
new
CommonException
(
400
,
"请选择至少选择一个尺寸"
);
}
if
(
CollectionUtils
.
isEmpty
(
bo
.
getImageUrlList
()))
{
...
...
@@ -506,17 +510,13 @@ public static void main(String[] args) {
applicationContext
.
publishEvent
(
new
StorageNumEvent
(
sp
.
getStorageId
()));
}
// TODO 发推送给商家端
LOGGER
.
info
(
"send info to seller, product_name is {}"
,
bo
.
getProductName
());
InboxBusinessTypeEnum
.
SALE_NOTIFIED_UNSHELF
.
getType
();
InboxBusinessTypeEnum
.
SALE_NOTIFIED_UNSHELF
.
getBusinessType
();
bo
.
getProductName
();
LOGGER
.
info
(
"send info to seller, product_name is {}, seller_uid is {}"
,
bo
.
getProductName
(),
sp
.
getSellerUid
());
inboxService
.
addInbox
(
InboxBusinessTypeEnum
.
SALE_NOTIFIED_UNSHELF
.
getBusinessType
(),
InboxBusinessTypeEnum
.
SALE_NOTIFIED_UNSHELF
.
getType
(),
bo
.
getProductName
(),
sp
.
getSellerUid
());
// TODO 调用银联接口退保证金
LOGGER
.
info
(
"send refund info to payment, seller_uid is {}, skup is {}"
,
sp
.
getSellerUid
(),
sp
.
getSkup
());
return
new
ApiResponse
<>(
200
,
"操作成功"
);
}
return
new
ApiResponse
<>(
400
,
"SKUP取消失败,状态已变更!"
);
...
...
web/src/main/webapp/html/goods/storage/storageDetail.html
View file @
88ef524
...
...
@@ -36,6 +36,20 @@
</div>
<script
type=
"text/javascript"
>
var
ENUM
=
{
sku_p_status
:
{
0
:
'待付保证金'
,
1
:
'出售中'
,
2
:
'卖家取消支付'
,
3
:
'卖家支付超时'
,
4
:
'卖家取消出售'
,
100
:
'已出售'
,
101
:
'买家手动取消'
,
102
:
'买家超时未支付'
,
200
:
'平台取消出售'
,
201
:
'鉴定失败'
}
};
function
parseURL
(
url
){
var
url
=
url
.
split
(
"?"
)[
1
];
var
para
=
url
.
split
(
"&"
);
...
...
@@ -57,12 +71,19 @@
location
.
href
=
contextPath
+
"/html/goods/storage/storageList.html"
;
}
});
// /** 1:可售,2卖出,3鉴定失败,4卖家取消, 5客服取消. */
//
// * 卖家操作
//* 0:初始(未支付保证金),*1:可售(已经支付保证金),2:卖家取消支付保证金,3:卖家超时未支付保证金,4:卖家支付保证金后取消售卖
//* 买家操作
//* 100:购买使得商品卖出(可能下单未支付,且未超时,或者已支付),101:取消卖出(买家手动),102:取消卖出(超时未支付)
//* 平台操作
//* 200:客服取消,201:鉴定失败
$
(
"#status"
).
myCombobox
({
prompt
:
"状态"
,
width
:
200
,
data
:
[{
id
:
'1'
,
text
:
'待付保证金'
},
{
id
:
'2'
,
text
:
'卖家取消支付'
},
{
id
:
'2'
,
text
:
'卖家支付超时'
},
{
id
:
'2'
,
text
:
'出售中'
}
,
{
id
:
'2'
,
text
:
'卖家取消出售'
},
{
id
:
'2'
,
text
:
'平台取消出售'
},
{
id
:
'2'
,
text
:
'已出售'
}],
data
:
[{
id
:
'0'
,
text
:
'待付保证金'
},
{
id
:
'2'
,
text
:
'卖家取消支付'
},
{
id
:
'3'
,
text
:
'卖家支付超时'
},
{
id
:
'1'
,
text
:
'出售中'
},
{
id
:
'4'
,
text
:
'卖家取消出售'
},
{
id
:
'200'
,
text
:
'平台取消出售'
},
{
id
:
'100'
,
text
:
'已出售'
},
{
id
:
'101'
,
text
:
'买家手动取消'
},
{
id
:
'102'
,
text
:
'买家超时未支付'
},
{
id
:
'201'
,
text
:
'鉴定失败'
}],
valueField
:
"id"
,
textField
:
"text"
});
...
...
@@ -147,10 +168,7 @@
width
:
50
,
align
:
"center"
,
formatter
:
function
(
value
,
rowData
)
{
if
(
value
==
1
)
{
return
'开启'
;
}
return
'关闭'
;
return
ENUM
.
sku_p_status
[
value
];
},
},
{
title
:
"创建时间"
,
...
...
web/src/main/webapp/html/goods/storage/storageList.html
View file @
88ef524
...
...
@@ -62,7 +62,7 @@
$
(
"#storageNum"
).
myCombobox
({
prompt
:
"商品库存"
,
width
:
200
,
data
:
[{
id
:
'1'
,
text
:
'有库存'
},
{
id
:
'
2
'
,
text
:
'无库存'
}],
data
:
[{
id
:
'1'
,
text
:
'有库存'
},
{
id
:
'
0
'
,
text
:
'无库存'
}],
valueField
:
"id"
,
textField
:
"text"
});
...
...
web/src/main/webapp/html/product/productEdit.html
View file @
88ef524
...
...
@@ -6,63 +6,96 @@
<script
src=
"/ufoPlatform/js/include.js"
></script>
<script
src=
"/ufoPlatform/js/ajaxfileupload.js"
></script>
<style>
.product-detail-page
ul
,
.product-detail-page
li
{
.product-detail-page
ul
,
.product-detail-page
li
{
list-style
:
none
;
padding
:
0
;
margin
:
0
;
}
}
.product-detail-page
.container
>
li
{
.product-detail-page
.container
>
li
{
border-bottom
:
1px
solid
#eee
;
}
padding-bottom
:
20px
;
}
.product-detail-page
.container
{
.product-detail-page
.container
{
padding
:
0
30px
;
}
.product-detail-page
.base-info
{
border-bottom
:
1px
solid
#eee
;
}
.product-detail-page
.base-info
li
{
.product-detail-page
.base-info
li
,
.product-detail-page
.keyword
{
display
:
flex
;
align-items
:
center
;
margin-bottom
:
10px
;
align-items
:
center
;
margin-bottom
:
10px
;
}
.product-detail-page
.
base-info
.
label
{
.product-detail-page
.label
{
width
:
120px
;
font-size
:
14px
;
text-align
:
right
;
}
.product-detail-page
.base-info
.red
{
color
:
red
;
}
.product-detail-page
.red
{
color
:
red
;
}
.product-detail-page
.group-color
,
.product-detail-page
.group-size
{
display
:
flex
;
align-items
:
center
;
margin-bottom
:
10px
;
}
.product-detail-page
.group-color
,
.product-detail-page
.group-size
{
display
:
flex
;
align-items
:
center
;
margin-bottom
:
20px
;
}
.product-detail-page
.group-color
li
{
margin-right
:
5px
;
float
:
left
;
line-height
:
30px
;
margin-left
:
5px
;
padding
:
0
5px
;
float
:
left
;
line-height
:
30px
;
margin-left
:
5px
;
padding
:
0
5px
;
position
:
relative
;
}
.product-detail-page
.group-color
.actived
{
background
:
#8fa9bb
;
color
:
#fff
;
border-radius
:
5px
;
.product-detail-page
.group-color
.actived
:before
{
content
:
''
;
width
:
100%
;
height
:
100%
;
display
:
block
;
position
:
absolute
;
top
:
0
;
background
:
#000
;
opacity
:
0.5
;
border-radius
:
5px
;
}
.product-detail-page
.group-size
.size
{
float
:
left
;
margin-left
:
10px
;
}
.product-detail-page
.goods-image
{
display
:
flex
;
}
.product-detail-page
.goods-image
.img
{
width
:
104px
;
height
:
104px
;
margin-right
:
10px
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-position
:
center
;
position
:
relative
;
}
.product-detail-page
.goods-image
.img
:hover:before
{
content
:
"删除"
;
width
:
100%
;
display
:
block
;
position
:
absolute
;
top
:
0
;
background
:
#000
;
opacity
:
0.5
;
color
:
#fff
;
text-align
:
center
;
line-height
:
104px
;
}
</style>
</head>
<body
class=
"easyui-layout product-detail-page"
fit=
"true"
>
...
...
@@ -72,37 +105,52 @@
</script>
</div>
<div
region=
"center"
style=
"overflow-y: scroll; top: 65px; padding-top: 10px;"
>
<form
id=
"productDetail"
>
<ul
class=
"container"
>
<li>
<h2>
基本信息
</h2>
<ul
class=
"base-info"
>
<li>
<div
class=
"label"
>
品牌
<span
class=
"red"
>
*
</span>
:
</div>
<div
class=
"base-info-item"
><input
id=
"editBrandId"
type=
"text"
>
系列:
<input
id=
"editSeriesId"
type=
"text"
></div>
<div
class=
"base-info-item"
>
<input
id=
"editBrandId"
type=
"text"
name=
"brandId"
>
系列:
<input
id=
"editSeriesId"
name=
"seriesId"
type=
"text"
>
</div>
</li>
<li>
<div
class=
"label"
>
商品名称
<span
class=
"red"
>
*
</span>
:
</div>
<div
class=
"base-info-item"
><input
id=
"editProductName"
type=
"text"
/></div>
<div
class=
"base-info-item"
>
<input
id=
"editProductName"
type=
"text"
name=
"productName"
/>
</div>
</li>
<li>
<div
class=
"label"
>
发售日期
<span
class=
"red"
>
*
</span>
:
</div>
<div
class=
"base-info-item"
><input
id=
"editSaleTime"
type=
"text"
/></div>
<div
class=
"base-info-item"
>
<input
id=
"editSaleTime"
type=
"text"
name=
"saleTime"
/>
</div>
</li>
<li>
<div
class=
"label"
>
性别
<span
class=
"red"
>
*
</span>
:
</div>
<div
class=
"base-info-item"
>
<label
for=
"boy"
><input
id=
"boy"
type=
"radio"
value=
"1"
name=
"sex"
checked
>
男
</label>
<label
for=
"girl"
><input
id=
"girl"
type=
"radio"
value=
"2"
name=
"sex"
>
女
</label>
<label
for=
"all"
><input
id=
"all"
type=
"radio"
value=
"3"
name=
"sex"
>
通用
</label>
<label
for=
"boy"
><input
id=
"boy"
type=
"radio"
value=
"1"
name=
"gender"
checked
>
男
</label>
<label
for=
"girl"
><input
id=
"girl"
type=
"radio"
value=
"2"
name=
"gender"
>
女
</label>
<label
for=
"all"
><input
id=
"all"
type=
"radio"
value=
"3"
name=
"gender"
>
通用
</label>
</div>
</li>
<li>
<div
class=
"label"
>
分类
<span
class=
"red"
>
*
</span>
:
</div>
<div
class=
"base-info-item"
><input
id=
"editMaxSortId"
type=
"text"
/><input
id=
"editMidSortId"
type=
"text"
/>
货号
<span
class=
"red"
>
*
</span>
:
<input
id=
"editProductCode"
type=
"text"
/></div>
<div
class=
"base-info-item"
>
<input
id=
"editMaxSortId"
type=
"text"
name=
"maxSortId"
/>
<input
id=
"editMidSortId"
type=
"text"
name=
"midSortId"
/>
货号
<span
class=
"red"
>
*
</span>
:
<input
id=
"editProductCode"
type=
"text"
name=
"productCode"
/>
</div>
</li>
<li>
<div
class=
"label"
>
商品价格限制
<span
class=
"red"
>
*
</span>
:
</div>
<div
class=
"base-info-item"
><input
id=
"editMinPrice"
type=
"text"
/><span
style=
"margin-right: 20px;c"
>
~
</span><input
id=
"editMaxPrice"
type=
"text"
/></div>
<div
class=
"base-info-item"
>
<input
id=
"editMinPrice"
type=
"text"
name=
"minPrice"
/>
<span
style=
"margin-right: 20px;c"
>
~
</span>
<input
id=
"editMaxPrice"
type=
"text"
name=
"maxPrice"
/>
</div>
</li>
</ul>
</li>
...
...
@@ -111,7 +159,7 @@
<h2>
颜色尺码
</h2>
<div
class=
"group-color"
>
<div
class=
"label"
>
*颜色
</div>
<ul
style=
"float:left; margin-left: 10px;"
>
<ul
style=
"float:
left; margin-left: 10px;"
>
</ul>
</div>
<div
class=
"group-size"
>
...
...
@@ -119,25 +167,32 @@
<div
class=
"size"
></div>
</div>
<table
id=
"colorSizeTable"
></table>
<table
id=
"colorSizeTable"
style=
"width:100%;height:auto"
></table>
</li>
<li>
<h2>
商品图片
</h2>
<div
class=
"goods-image"
>
<div
id=
"imageUpload"
></div>
</div>
</li>
<li>
<h2>
商品关键词
</h2>
<div
class=
"keyword"
>
<div
class=
"label"
style=
"width: 120px;"
>
商品关键词:
</div>
<div
class=
"keyword-right"
>
<input
type=
"text"
id=
"keyword"
name=
"keyWords"
>
</div>
</div>
<div
class=
"red"
style=
"margin-left:120px;"
>
*每个关键词用英文逗号隔开
</div>
</li>
<li
style=
"text-align: center; margin-top: 20px;"
>
<a
id=
"submitBtn"
class=
"easyui-linkbutton btn-success"
>
提交
</a>
<a
id=
"cancelBtn"
class=
"easyui-linkbutton btn-default"
>
取消
</a>
</li>
</ul>
<!-- <input id="editGender" type="text"/>
<input id="editColorId" type="text"/>
<input id="editColorName" type="text"/>
<input id="editGoodsName" type="text"/>
<input id="editSizeIdList" type="text"/>
<input id="editImageUrlList" type="text"/>
<input id="editKeyWords" type="text"/>
<input id="editGoodsId" type="hidden"/>
<input id="editId" type="hidden"/> -->
</form>
</div>
<script>
/* 新增,修改公用页面
...
...
@@ -148,170 +203,164 @@
2.修改:首先根据传进来的id,获取商品信息把页面控件填写好。hidden记录id、goodsId、等参数
提交参数:{"brandId":78,"colorId":2,"colorName":"蓝色","editImage":1,"gender":3,"goodsId":6,"goodsName":"自定义蓝色","id":10000004,"imageUrlList":["https://img10.static.yhbimg.com/goodsimg/2018/08/25/16/01e99496407347514356e5fe327d1f661d.jpg","https://img12.static.yhbimg.com/goodsimg/2018/08/25/16/0292fcebd071444401e6de340bcf2d8c19.jpg"],"keyWords":"球鞋,adidas2","maxPrice":"898","maxSortId":10,"midSortId":18,"minPrice":"598","productCode":"009-009-009-e","productName":"测试商品009-e","saleTime":"2018-11-12","seriesId":8}
不可修改:品牌、分类、颜色、尺码、SKU(颜色展示名称除外:goodsName)
*/
*/
var
productDetail
=
{
initData
:
function
(
detail
)
{
initDom
:
function
()
{
this
.
dom
=
{
editBrandId
:
$
(
'#editBrandId'
),
editProductName
:
$
(
'#editProductName'
),
editSaleTime
:
$
(
'#editSaleTime'
),
editMinPrice
:
$
(
'#editMinPrice'
),
editMaxPrice
:
$
(
'#editMaxPrice'
),
editProductCode
:
$
(
'#editProductCode'
),
editMaxSortId
:
$
(
'#editMaxSortId'
),
editMidSortId
:
$
(
'#editMidSortId'
),
editSeriesId
:
$
(
'#editSeriesId'
),
imageUpload
:
$
(
'#imageUpload'
)
};
},
initFormData
:
function
(
detail
)
{
var
that
=
this
;
$
(
"#editSeriesId"
).
myCombobox
({
url
:
contextPath
+
'/brandSeries/querySeriesByBrandId?brandId='
+
detail
.
brandId
,
method
:
"get"
,
editable
:
false
,
prompt
:
"请选择"
,
width
:
200
,
valueField
:
"id"
,
textField
:
"text"
,
loadFilter
:
function
(
data
)
{
return
defaultLoadFilter
(
data
);
}
});
$
(
"#editBrandId"
).
combobox
(
'select'
,
detail
.
brandId
)
$
(
"#editProductName"
).
textbox
(
'setValue'
,
detail
.
productName
);
$
(
"#editSaleTime"
).
myDatebox
(
'setValue'
,
detail
.
saleTime
);
$
(
'input[name=sex]'
).
eq
(
detail
.
gender
-
1
).
attr
(
'checked'
,
'true'
);
$
(
'#editMinPrice'
).
textbox
(
'setValue'
,
detail
.
minPrice
);
$
(
'#editMaxPrice'
).
textbox
(
'setValue'
,
detail
.
maxPrice
);
$
(
'#editProductCode'
).
textbox
(
'setValue'
,
detail
.
productCode
);
$
(
"#editMaxSortId"
).
combobox
(
'select'
,
detail
.
maxSortId
);
$
(
"#editMidSortId"
).
combobox
(
'select'
,
detail
.
midSortId
);
$
(
"#editSeriesId"
).
combobox
(
'select'
,
detail
.
seriesId
)
this
.
getSizeInfo
(
detail
.
midSortId
);
this
.
dom
.
editBrandId
.
combobox
(
'select'
,
detail
.
brandId
)
this
.
dom
.
editProductName
.
textbox
(
'setValue'
,
detail
.
productName
);
this
.
dom
.
editSaleTime
.
myDatebox
(
'setValue'
,
detail
.
saleTime
);
this
.
dom
.
editMinPrice
.
textbox
(
'setValue'
,
detail
.
minPrice
);
this
.
dom
.
editMaxPrice
.
textbox
(
'setValue'
,
detail
.
maxPrice
);
this
.
dom
.
editProductCode
.
textbox
(
'setValue'
,
detail
.
productCode
);
this
.
dom
.
editMaxSortId
.
combobox
(
'select'
,
detail
.
maxSortId
);
this
.
dom
.
editMidSortId
.
combobox
(
'select'
,
detail
.
midSortId
);
this
.
dom
.
editSeriesId
.
combobox
(
'select'
,
detail
.
seriesId
);
$
(
'input[name=gender]'
).
eq
(
detail
.
gender
-
1
).
attr
(
'checked'
,
'true'
);
$
(
'.group-color li[data-id='
+
detail
.
colorId
+
']'
).
addClass
(
'actived'
);
if
(
detail
.
imageUrlList
.
length
>
0
)
{
detail
.
imageUrlList
.
map
(
function
(
item
)
{
that
.
dom
.
imageUpload
.
before
(
'<div class="img" data-url="'
+
item
+
'" style="background-image:url('
+
item
+
');">'
);
});
}
},
initForm
:
function
()
{
$
(
"#editProductName"
).
textbox
({
var
that
=
this
;
this
.
dom
.
editProductName
.
textbox
({
required
:
true
,
missingMessage
:
"商品名称不能为空"
,
prompt
:
"商品名称"
,
width
:
460
});
$
(
"#editBrandId"
).
combobox
({
$
(
'#keyword'
).
textbox
({
width
:
700
});
this
.
dom
.
editBrandId
.
combobox
({
editable
:
false
,
prompt
:
"选择品牌"
,
width
:
200
,
valueField
:
"id"
,
textField
:
"text"
});
$
(
'#editMaxSortId'
).
myCombobox
({
textField
:
"text"
,
onSelect
:
function
(
data
)
{
that
.
dom
.
editSeriesId
.
combobox
(
'enable'
);
that
.
dom
.
editSeriesId
.
myCombobox
(
'reload'
,
contextPath
+
'/brandSeries/querySeriesByBrandId?brandId='
+
data
.
id
);
that
.
dom
.
editSeriesId
.
combobox
(
'select'
)
}
});
this
.
dom
.
editSeriesId
.
myCombobox
({
method
:
"get"
,
editable
:
false
,
prompt
:
"请选择"
,
width
:
200
,
valueField
:
"id"
,
textField
:
"text"
,
loadFilter
:
function
(
data
)
{
if
(
data
&&
data
.
code
==
200
&&
data
.
data
.
length
>
0
)
{
that
.
dom
.
editSeriesId
.
combobox
(
'select'
,
data
.
data
[
0
].
id
);
}
return
defaultLoadFilter
(
data
);
}
});
this
.
dom
.
editMaxSortId
.
myCombobox
({
editable
:
false
,
valueField
:
'id'
,
textField
:
'text'
,
prompt
:
"一级分类"
,
onSelect
:
function
(
rec
)
{
if
(
0
===
rec
.
id
)
{
try
{
$
(
'#midSortId'
).
combobox
(
'disable'
);
}
catch
(
e
)
{
}
return
;
}
try
{
$
(
'#editMidSortId'
).
combobox
(
'clear'
);
$
(
'#editMidSortId'
).
combobox
(
'reload'
,
contextPath
+
"/productSort/getLevel2SortBySortId?sortId="
+
rec
.
id
);
$
(
'#editMidSortId'
).
combobox
(
'enable'
);
}
catch
(
e
)
{
}
that
.
dom
.
editMidSortId
.
combobox
(
'clear'
);
that
.
dom
.
editMidSortId
.
combobox
(
'reload'
,
contextPath
+
"/productSort/getLevel2SortBySortId?sortId="
+
rec
.
id
);
if
(
!
that
.
productId
)
{
that
.
dom
.
editMidSortId
.
combobox
(
'enable'
);
}
}
});
$
(
"#editSaleTime"
).
myDatebox
({
this
.
dom
.
editSaleTime
.
myDatebox
({
prompt
:
"发售时间"
});
$
(
'#editMidSortId'
).
myCombobox
({
this
.
dom
.
editMidSortId
.
myCombobox
({
method
:
'get'
,
editable
:
false
,
valueField
:
'id'
,
textField
:
'text'
,
multiple
:
true
,
prompt
:
"二级分类"
,
loadFilter
:
function
(
data
)
{
console
.
log
(
data
)
return
defaultLoadFilter
(
data
);
if
(
data
&&
data
.
code
==
200
&&
data
.
data
.
length
>
0
)
{
that
.
dom
.
editMidSortId
.
combobox
(
'select'
,
data
.
data
[
0
].
id
);
}
return
defaultLoadFilter
(
data
);
},
onSelect
:
function
(
opt
)
{
that
.
getSizeInfo
(
opt
.
id
);
}
});
$
(
"#editProductCode"
).
textbox
({
prompt
:
"请输入"
});
$
(
"#editMinPrice"
).
textbox
({
prompt
:
"最低价"
});
$
(
"#editMaxPrice"
).
textbox
({
prompt
:
"最高价"
});
$
(
"#editKeyWords"
).
textbox
({
prompt
:
"请输入"
});
},
init
:
function
()
{
var
that
=
this
;
var
productId
=
this
.
getUrlParam
(
'id'
);
var
ajaxList
=
[];
var
colorSizeSelected
=
{}
this
.
initForm
();
this
.
getColorInfo
();
$
.
when
(
this
.
getBrandList
(),
this
.
getMaxSortList
()).
then
(
function
(
brand
,
maxSort
)
{
var
brandId
=
''
;
brand
=
brand
[
0
];
maxSort
=
maxSort
[
0
];
if
(
brand
&&
brand
.
code
==
200
)
{
$
(
"#editBrandId"
).
combobox
({
data
:
brand
.
data
||
[]
});
}
if
(
maxSort
&&
maxSort
.
code
==
200
)
{
$
(
"#editMaxSortId"
).
combobox
({
data
:
maxSort
.
data
||
[]
});
}
if
(
productId
)
{
that
.
getDetailInfo
(
productId
);
}
else
{
this
.
getSizeInfo
();
}
this
.
dom
.
editProductCode
.
textbox
({
prompt
:
"请输入"
,
required
:
true
,
missingMessage
:
"货号不能为空"
});
this
.
changeColorOrSize
();
$
(
document
).
on
(
'click'
,
'.group-color li'
,
function
()
{
$
(
this
).
siblings
().
removeClass
(
'actived'
);
$
(
this
).
addClass
(
'actived'
);
this
.
dom
.
editMinPrice
.
textbox
({
prompt
:
"最低价"
,
required
:
true
,
missingMessage
:
"最低价不能为空"
});
},
changeColorOrSize
:
function
()
{
$
(
"#colorSizeTable"
).
myDatagrid
({
fit
:
true
,
this
.
dom
.
editMaxPrice
.
textbox
({
prompt
:
"最高价"
,
required
:
true
,
missingMessage
:
"最高价不能为空"
});
$
(
'#colorSizeTable'
).
myDatagrid
({
fit
:
false
,
fitColumns
:
true
,
autoRowHeight
:
true
,
nowrap
:
false
,
columns
:
[[{
title
:
"色系名称"
,
field
:
"
id
"
,
field
:
"
colorName
"
,
width
:
40
,
align
:
"center"
},
{
title
:
"颜色展示名称"
,
field
:
"
colorImag
e"
,
field
:
"
goodsNam
e"
,
width
:
80
,
height
:
50
,
align
:
"center"
,
formatter
:
function
(
value
)
{
return
'<i
mg src="'
+
value
+
'" style="width: 48px; height: 48px;vertical-align: middle;">'
return
'<i
nput type="text" class="goods-name" value="'
+
value
+
'">'
;
}
},
{
title
:
"尺码"
,
field
:
"
productNam
e"
,
field
:
"
siz
e"
,
width
:
100
,
align
:
"center"
},
{
title
:
"SKU"
,
field
:
"s
ortName
"
,
field
:
"s
ku
"
,
width
:
80
,
align
:
"center"
}]],
...
...
@@ -320,33 +369,315 @@
idField
:
"id"
,
singleSelect
:
false
,
checkOnSelect
:
false
,
onLoadSuccess
:
function
()
{
// 编辑
$
(
this
).
myDatagrid
(
"getPanel"
).
find
(
"a[role='edit']"
).
linkbutton
({
iconCls
:
"icon-edit"
,
onClick
:
function
()
{
var
id
=
$
(
this
).
attr
(
"dataId"
);
editRow
(
id
);
}
});
// 关闭品牌
$
(
this
).
myDatagrid
(
"getPanel"
).
find
(
"a[role='closeBrandSeries']"
).
linkbutton
({
iconCls
:
"icon-more"
,
onClick
:
function
()
{
updateBrandSeriesStatus
(
$
(
this
).
attr
(
"dataId"
),
2
);
}
onLoadSuccess
:
function
()
{
$
(
'.goods-name'
).
textbox
({
width
:
100
});
}
});
if
(
!
this
.
productId
)
{
this
.
dom
.
editSeriesId
.
combobox
(
'disable'
);
}
else
{
this
.
dom
.
editBrandId
.
combobox
(
'disable'
);
this
.
dom
.
editMaxSortId
.
combobox
(
'disable'
);
}
this
.
dom
.
editMidSortId
.
combobox
(
'disable'
);
},
init
:
function
()
{
var
that
=
this
;
this
.
productId
=
this
.
getUrlParam
(
'id'
);
this
.
detailData
=
{};
this
.
submitFlag
=
false
;
this
.
colorSizeTableData
=
{
total
:
0
,
rows
:
[]
};
this
.
initDom
();
this
.
initForm
();
this
.
dom
.
imageUpload
.
imageUpload
({
width
:
104
,
height
:
104
,
realInputName
:
"goodsImage"
,
url
:
contextPath
+
'/fileupload/uploadFile'
,
queryParams
:
{
bucket
:
"goodsimg"
},
onBeforeSubmit
:
function
()
{
$
.
messager
.
progress
({
title
:
"正在执行"
,
msg
:
"正在执行,请稍后..."
,
interval
:
500
,
text
:
""
});
},
filterFileName
:
function
(
data
)
{
if
(
!
data
||
data
.
code
!=
200
)
{
$
.
messager
.
progress
(
"close"
);
$
.
messager
.
alert
(
"错误"
,
data
.
message
);
return
""
;
}
return
data
.
data
.
url
;
},
onLoadSuccess
:
function
(
data
)
{
$
.
messager
.
progress
(
"close"
);
$
(
document
).
find
(
'.file-close'
).
click
();
that
.
dom
.
imageUpload
.
before
(
'<div class="img" data-url="'
+
data
.
data
.
url
+
'" style="background-image:url('
+
data
.
data
.
url
+
');">'
);
return
false
;
}
});
$
.
when
(
this
.
getBrandList
(),
this
.
getMaxSortList
(),
this
.
getColorInfo
()).
then
(
function
(
brand
,
maxSort
,
colors
)
{
var
brandId
=
''
;
brand
=
brand
[
0
];
maxSort
=
maxSort
[
0
];
colors
=
colors
[
0
]
||
[];
if
(
brand
&&
brand
.
code
==
200
)
{
that
.
dom
.
editBrandId
.
combobox
({
data
:
brand
.
data
||
[]
});
}
if
(
maxSort
&&
maxSort
.
code
==
200
)
{
that
.
dom
.
editMaxSortId
.
combobox
({
data
:
maxSort
.
data
||
[]
});
}
if
(
colors
&&
colors
.
code
==
200
)
{
colors
.
data
.
map
(
function
(
item
)
{
var
color
=
item
.
colorValue
?
'background: url('
+
item
.
colorValue
+
')'
:
'background:#'
+
item
.
colorCode
;
$
(
'.group-color ul'
).
append
(
'<li data-id="'
+
item
.
id
+
'"><i style="float: left;width: 30px; height: 30px;border-radius: 50%; margin-right: 3px;'
+
color
+
';background-size: contain;"></i>'
+
item
.
colorName
+
'</li>'
);
});
}
if
(
that
.
productId
)
{
that
.
getDetailInfo
();
}
else
{
that
.
getSizeInfo
();
}
});
$
(
document
).
on
(
'click'
,
'.group-color li'
,
function
()
{
if
(
that
.
productId
)
{
$
.
messager
.
alert
(
'操作提示'
,
"颜色不可修改!"
);
return
;
}
if
(
!
$
(
this
).
hasClass
(
'actived'
))
{
var
colorName
=
$
(
this
).
text
();
if
(
that
.
colorSizeTableData
.
rows
.
length
>
0
)
{
that
.
colorSizeTableData
.
rows
.
map
(
function
(
item
)
{
item
.
colorName
=
colorName
;
item
.
goodsName
=
colorName
;
});
}
else
{
that
.
colorSizeTableData
.
rows
.
push
({
colorName
:
colorName
,
goodsName
:
colorName
,
size
:
''
,
sku
:
'-'
});
}
that
.
mergeCells
();
$
(
this
).
siblings
().
removeClass
(
'actived'
);
$
(
this
).
addClass
(
'actived'
);
}
});
$
(
document
).
on
(
'click'
,
'.group-size input'
,
function
()
{
var
colorName
=
goodsName
=
''
;
if
(
that
.
productId
)
{
$
.
messager
.
alert
(
'操作提示'
,
'尺码不可修改!'
);
return
false
;
}
if
(
$
(
'.group-color .actived'
).
length
==
0
)
{
$
.
messager
.
alert
(
'操作提示'
,
'请先选择颜色!'
);
return
false
;
}
if
(
that
.
colorSizeTableData
.
rows
.
length
>
0
)
{
colorName
=
that
.
colorSizeTableData
.
rows
[
0
].
colorName
;
goodsName
=
that
.
colorSizeTableData
.
rows
[
0
].
goodsName
;
}
else
{
colorName
=
goodsName
=
$
(
'.group-color .actived'
).
text
();
}
that
.
colorSizeTableData
.
rows
=
[];
$
(
'.size-item:checked'
).
each
(
function
(
index
,
item
)
{
that
.
colorSizeTableData
.
rows
.
push
({
colorName
:
colorName
,
goodsName
:
goodsName
,
size
:
$
(
item
).
parent
().
text
(),
sku
:
'-'
});
});
if
(
$
(
'.size-item:checked'
).
length
==
0
&&
colorName
)
{
that
.
colorSizeTableData
.
rows
.
push
({
colorName
:
colorName
,
goodsName
:
goodsName
,
size
:
''
,
sku
:
'-'
});
}
that
.
mergeCells
();
});
$
(
document
).
on
(
'click'
,
'.goods-image .img'
,
function
()
{
$
(
this
).
remove
();
});
$
(
'#cancelBtn'
).
linkbutton
({
onClick
:
function
()
{
window
.
location
.
href
=
contextPath
+
"/html/product/productList.html"
;
}
});
$
(
'#submitBtn'
).
linkbutton
({
onClick
:
function
()
{
var
imageUrlList
=
[];
var
sizeIdList
=
[];
var
editImage
=
0
;
if
(
that
.
submitFlag
)
{
return
;
}
that
.
submitFlag
=
true
;
$
(
'.goods-image .img'
).
each
(
function
(
index
,
item
)
{
imageUrlList
.
push
(
$
(
item
).
data
(
'url'
));
});
if
(
that
.
productId
)
{
if
(
imageUrlList
.
length
==
that
.
detailData
.
imageUrlList
.
length
)
{
$
.
each
(
imageUrlList
,
function
(
index
,
item
)
{
if
(
item
!=
that
.
detailData
.
imageUrlList
[
index
])
{
editImage
=
1
;
}
});
}
else
{
editImage
=
1
;
}
}
else
{
editImage
=
1
;
$
(
'.group-size input:checked'
).
each
(
function
(
index
,
item
)
{
sizeIdList
.
push
(
+
$
(
item
).
val
());
});
}
var
ajaxData
=
{
brandId
:
+
that
.
dom
.
editBrandId
.
textbox
(
'getValue'
),
colorId
:
+
$
(
'.group-color .actived'
).
data
(
'id'
),
colorName
:
$
(
'.group-color .actived'
).
text
(),
editImage
:
editImage
,
gender
:
+
$
(
'input[name="gender"]:checked'
).
val
(),
goodsName
:
$
(
'.goods-name'
).
length
>
0
&&
$
(
'.goods-name'
).
textbox
(
'getValue'
)
||
''
,
imageUrlList
:
imageUrlList
,
keyWords
:
$
(
'#keyword'
).
textbox
(
'getValue'
),
maxPrice
:
that
.
dom
.
editMaxPrice
.
textbox
(
'getValue'
),
maxSortId
:
+
that
.
dom
.
editMaxSortId
.
combobox
(
'getValue'
),
midSortId
:
+
that
.
dom
.
editMidSortId
.
combobox
(
'getValue'
),
minPrice
:
that
.
dom
.
editMinPrice
.
textbox
(
'getValue'
),
productCode
:
that
.
dom
.
editProductCode
.
textbox
(
'getValue'
),
productName
:
that
.
dom
.
editProductName
.
textbox
(
'getValue'
),
saleTime
:
that
.
dom
.
editSaleTime
.
myDatebox
(
'getValue'
),
seriesId
:
+
that
.
dom
.
editSeriesId
.
combobox
(
'getValue'
)
};
if
(
!
ajaxData
.
brandId
)
{
$
.
messager
.
alert
(
'操作提示'
,
'请选择品牌!'
);
return
false
;
}
if
(
!
ajaxData
.
saleTime
)
{
$
.
messager
.
alert
(
'操作提示'
,
'请选择发售时间!'
);
return
false
;
}
if
(
!
ajaxData
.
maxSortId
)
{
$
.
messager
.
alert
(
'操作提示'
,
'请选择一级分类!'
);
return
false
;
}
if
(
!
ajaxData
.
midSortId
)
{
$
.
messager
.
alert
(
'错误提示'
,
'请选择二级分类!'
);
return
false
;
}
if
(
imageUrlList
.
length
==
0
)
{
$
.
messager
.
alert
(
'操作提示'
,
'至少添加一张图片!'
);
return
false
;
}
if
(
!
$
(
'#productDetail'
).
form
(
"validate"
))
{
return
false
;
}
if
(
!
that
.
productId
)
{
ajaxData
.
sizeIdList
=
sizeIdList
;
if
(
!
ajaxData
.
colorName
)
{
$
.
messager
.
alert
(
'错误提示'
,
'请选择颜色!'
);
return
false
;
}
if
(
sizeIdList
.
length
==
0
)
{
$
.
messager
.
alert
(
'错误提示'
,
'请选择尺码!'
);
return
false
;
}
}
else
{
ajaxData
.
id
=
that
.
detailData
.
id
;
ajaxData
.
goodsId
=
that
.
detailData
.
goodsId
;
}
// 开启品牌
$
(
this
).
myDatagrid
(
"getPanel"
).
find
(
"a[role='openBrandSeries']"
).
linkbutton
({
iconCls
:
"icon-more"
,
onClick
:
function
()
{
updateBrandSeriesStatus
(
$
(
this
).
attr
(
"dataId"
),
1
);
}
$
.
messager
.
progress
({
title
:
"正在执行"
,
msg
:
"正在执行,请稍后..."
,
interval
:
500
,
text
:
""
});
$
.
ajax
({
url
:
contextPath
+
'/product/addOrUpdate'
,
contentType
:
"application/json"
,
dataType
:
"json"
,
type
:
"POST"
,
data
:
JSON
.
stringify
(
ajaxData
),
success
:
function
(
data
)
{
that
.
submitFlag
=
false
;
$
.
messager
.
progress
(
"close"
);
$
.
messager
.
alert
(
'操作提示'
,
'提交成功!'
);
window
.
location
.
href
=
contextPath
+
"/html/product/productList.html"
;
},
error
:
function
(
err
)
{
that
.
submitFlag
=
false
;
$
.
messager
.
alert
(
'操作提示'
,
err
.
message
||
'提交失败'
);
}
});
}
});
},
mergeCells
:
function
()
{
this
.
colorSizeTableData
.
total
=
this
.
colorSizeTableData
.
rows
.
length
;
$
(
'#colorSizeTable'
).
datagrid
(
'loadData'
,
this
.
colorSizeTableData
);
$
(
'#colorSizeTable'
).
datagrid
(
'mergeCells'
,
{
index
:
0
,
field
:
'colorName'
,
rowspan
:
this
.
colorSizeTableData
.
total
});
$
(
'#colorSizeTable'
).
datagrid
(
'mergeCells'
,
{
index
:
0
,
field
:
'goodsName'
,
rowspan
:
this
.
colorSizeTableData
.
total
});
$
(
'#colorSizeTable'
).
datagrid
(
'resize'
);
},
getUrlParam
:
function
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
...
...
@@ -357,13 +688,16 @@
return
null
;
},
getDetailInfo
:
function
(
productId
)
{
getDetailInfo
:
function
()
{
var
that
=
this
;
// 编辑的情况需要根据id查询商品信息
$
.
get
(
contextPath
+
'/product/find?id='
+
productId
).
then
(
function
(
ret
)
{
$
.
get
(
contextPath
+
'/product/find?id='
+
this
.
productId
).
then
(
function
(
ret
)
{
if
(
ret
&&
ret
.
code
==
200
)
{
that
.
initData
(
ret
.
data
);
ret
=
ret
.
data
||
{};
that
.
initFormData
(
ret
);
that
.
detailData
=
ret
;
}
});
...
...
@@ -376,48 +710,43 @@
// 获取一级分类
return
$
.
get
(
contextPath
+
"/productSort/getLevel1SortIdAndName"
);
},
getMinSortList
:
function
()
{
// 获取二级分类
return
$
.
get
(
contextPath
+
"/productSort/getLevel1SortIdAndName"
);
},
getSizeInfo
:
function
(
sortId
)
{
var
that
=
this
;
sortId
=
sortId
||
0
;
// 获取所有尺寸
$
.
ajax
({
contentType
:
'application/json'
,
dataType
:
'json'
,
type
:
'GET'
,
url
:
contextPath
+
'/size/queryAllSize4Goods?sortId='
+
sortId
,
success
:
function
(
ret
)
{
if
(
ret
&&
ret
.
code
==
200
)
{
$
.
each
(
ret
.
data
||
[],
function
(
index
,
item
)
{
$
(
'.group-size .size'
).
append
(
'<label for="size" style="margin-right: 5px;"><input type="checkbox" name="size">'
+
item
.
text
+
'</label>'
);
});
}
}
});
$
.
get
(
contextPath
+
'/size/queryAllSize4Goods?sortId='
+
sortId
,
function
(
ret
)
{
if
(
ret
&&
ret
.
code
==
200
)
{
$
(
'.group-size .size'
).
html
(
''
);
$
.
each
(
ret
.
data
||
[],
function
(
index
,
item
)
{
if
(
item
.
id
)
{
$
(
'.group-size .size'
).
append
(
'<label for="size" style="margin-right: 5px;" data-id="'
+
item
.
id
+
'"><input type="checkbox" value="'
+
item
.
id
+
'" class="size-item">'
+
item
.
text
+
'</label>'
);
}
});
if
(
that
.
detailData
.
sizeIdList
)
{
that
.
detailData
.
sizeIdList
.
map
(
function
(
item
)
{
$
(
'.group-size label[data-id='
+
item
+
'] input'
).
attr
(
'checked'
,
'true'
);
that
.
colorSizeTableData
.
rows
.
push
({
colorName
:
$
(
'.group-color li[data-id='
+
that
.
detailData
.
colorId
+
']'
).
text
(),
goodsName
:
that
.
detailData
.
goodsName
,
size
:
$
(
'.group-size label[data-id='
+
item
+
']'
).
text
(),
sku
:
'-'
});
});
}
that
.
mergeCells
();
}
});
},
getColorInfo
:
function
()
{
// 获取所有颜色
$
.
ajax
({
contentType
:
'application/json'
,
dataType
:
'json'
,
type
:
'GET'
,
url
:
contextPath
+
'/productColor/getAllColor'
,
success
:
function
(
ret
)
{
if
(
ret
&&
ret
.
code
==
200
)
{
$
.
each
(
ret
.
data
||
[],
function
(
index
,
item
)
{
var
color
=
item
.
colorValue
?
'background: url('
+
item
.
colorValue
+
')'
:
'background:#'
+
item
.
colorCode
;
$
(
'.group-color ul'
).
append
(
'<li data-color="'
+
color
+
'"><i style="float: left;width: 30px; height: 30px;border-radius: 50%; margin-right: 3px;'
+
color
+
';background-size: contain;"></i>'
+
item
.
colorName
+
'</li>'
)
});
}
}
})
return
$
.
get
(
contextPath
+
'/productColor/getAllColor'
);
}
};
$
(
function
()
{
productDetail
.
init
();
productDetail
.
init
();
});
</script>
...
...
web/src/main/webapp/html/product/productList.html
View file @
88ef524
...
...
@@ -226,6 +226,12 @@
$
(
"#productTable"
).
myDatagrid
(
"load"
,
param
);
}
});
$
(
'#addProduct'
).
linkbutton
({
onClick
:
function
()
{
window
.
location
.
href
=
contextPath
+
"/html/product/productEdit.html"
;
}
});
function
editRow
(
id
)
{
brandSeriesId
=
id
;
...
...
Please
register
or
login
to post a comment