Authored by 王水玲

商品创建

@@ -6,26 +6,26 @@ @@ -6,26 +6,26 @@
6 <script src="/ufoPlatform/js/include.js"></script> 6 <script src="/ufoPlatform/js/include.js"></script>
7 <script src="/ufoPlatform/js/ajaxfileupload.js"></script> 7 <script src="/ufoPlatform/js/ajaxfileupload.js"></script>
8 <style> 8 <style>
9 - .product-detail-page ul, .product-detail-page li { 9 + .product-detail-page ul, .product-detail-page li {
10 list-style: none; 10 list-style: none;
11 padding: 0; 11 padding: 0;
12 margin: 0; 12 margin: 0;
13 - } 13 + }
14 14
15 - .product-detail-page .container > li { 15 + .product-detail-page .container > li {
16 border-bottom: 1px solid #eee; 16 border-bottom: 1px solid #eee;
17 padding-bottom: 20px; 17 padding-bottom: 20px;
18 - } 18 + }
19 19
20 - .product-detail-page .container { 20 + .product-detail-page .container {
21 padding: 0 30px; 21 padding: 0 30px;
22 - } 22 + }
23 23
24 .product-detail-page .base-info li, 24 .product-detail-page .base-info li,
25 .product-detail-page .keyword { 25 .product-detail-page .keyword {
26 display: flex; 26 display: flex;
27 - align-items: center;  
28 - margin-bottom: 10px; 27 + align-items: center;
  28 + margin-bottom: 10px;
29 } 29 }
30 30
31 .product-detail-page .label { 31 .product-detail-page .label {
@@ -34,23 +34,23 @@ @@ -34,23 +34,23 @@
34 text-align: right; 34 text-align: right;
35 } 35 }
36 36
37 - .product-detail-page .red {  
38 - color: red;  
39 - } 37 + .product-detail-page .red {
  38 + color: red;
  39 + }
40 40
41 - .product-detail-page .group-color, .product-detail-page .group-size {  
42 - display: flex;  
43 - align-items: center;  
44 - margin-bottom: 20px;  
45 - } 41 + .product-detail-page .group-color, .product-detail-page .group-size {
  42 + display: flex;
  43 + align-items: center;
  44 + margin-bottom: 20px;
  45 + }
46 46
47 .product-detail-page .group-color li { 47 .product-detail-page .group-color li {
48 margin-right: 5px; 48 margin-right: 5px;
49 - float: left;  
50 - line-height: 30px;  
51 - margin-left: 5px;  
52 - padding: 0 5px;  
53 - position: relative; 49 + float: left;
  50 + line-height: 30px;
  51 + margin-left: 5px;
  52 + padding: 0 5px;
  53 + position: relative;
54 } 54 }
55 55
56 .product-detail-page .group-color .actived:before { 56 .product-detail-page .group-color .actived:before {
@@ -60,9 +60,9 @@ @@ -60,9 +60,9 @@
60 display: block; 60 display: block;
61 position: absolute; 61 position: absolute;
62 top: 0; 62 top: 0;
63 - background: #000;  
64 - opacity: 0.5;  
65 - border-radius: 5px; 63 + background: #000;
  64 + opacity: 0.5;
  65 + border-radius: 5px;
66 } 66 }
67 67
68 .product-detail-page .group-size .size { 68 .product-detail-page .group-size .size {
@@ -70,18 +70,18 @@ @@ -70,18 +70,18 @@
70 margin-left: 10px; 70 margin-left: 10px;
71 } 71 }
72 72
73 - .product-detail-page .goods-image {  
74 - display: flex;  
75 - } 73 + .product-detail-page .goods-image {
  74 + display: flex;
  75 + }
76 76
77 .product-detail-page .goods-image .img { 77 .product-detail-page .goods-image .img {
78 width: 104px; 78 width: 104px;
79 height: 104px; 79 height: 104px;
80 margin-right: 10px; 80 margin-right: 10px;
81 background-size: cover; 81 background-size: cover;
82 - background-repeat: no-repeat;  
83 - background-position: center;  
84 - position: relative; 82 + background-repeat: no-repeat;
  83 + background-position: center;
  84 + position: relative;
85 } 85 }
86 86
87 .product-detail-page .goods-image .img:hover:before { 87 .product-detail-page .goods-image .img:hover:before {
@@ -105,7 +105,7 @@ @@ -105,7 +105,7 @@
105 </script> 105 </script>
106 </div> 106 </div>
107 <div region="center" style="overflow-y: scroll; top: 65px; padding-top: 10px;"> 107 <div region="center" style="overflow-y: scroll; top: 65px; padding-top: 10px;">
108 -<from id="productDetail"> 108 +<form id="productDetail">
109 <ul class="container"> 109 <ul class="container">
110 <li> 110 <li>
111 <h2>基本信息</h2> 111 <h2>基本信息</h2>
@@ -159,7 +159,7 @@ @@ -159,7 +159,7 @@
159 <h2>颜色尺码</h2> 159 <h2>颜色尺码</h2>
160 <div class="group-color"> 160 <div class="group-color">
161 <div class="label">*颜色</div> 161 <div class="label">*颜色</div>
162 - <ul style="float:left; margin-left: 10px;"> 162 + <ul style="float: left; margin-left: 10px;">
163 </ul> 163 </ul>
164 </div> 164 </div>
165 <div class="group-size"> 165 <div class="group-size">
@@ -189,10 +189,10 @@ @@ -189,10 +189,10 @@
189 </li> 189 </li>
190 <li style="text-align: center; margin-top: 20px;"> 190 <li style="text-align: center; margin-top: 20px;">
191 <a id="submitBtn" class="easyui-linkbutton btn-success">提交</a> 191 <a id="submitBtn" class="easyui-linkbutton btn-success">提交</a>
192 - <a id="cancelBtn" class="easyui-linkbutton btn-default">取消</a> 192 + <a id="cancelBtn" class="easyui-linkbutton btn-default">取消</a>
193 </li> 193 </li>
194 </ul> 194 </ul>
195 -</from> 195 +</form>
196 </div> 196 </div>
197 <script> 197 <script>
198 /* 新增,修改公用页面 198 /* 新增,修改公用页面
@@ -205,121 +205,135 @@ @@ -205,121 +205,135 @@
205 不可修改:品牌、分类、颜色、尺码、SKU(颜色展示名称除外:goodsName) 205 不可修改:品牌、分类、颜色、尺码、SKU(颜色展示名称除外:goodsName)
206 */ 206 */
207 var productDetail = { 207 var productDetail = {
208 - initData: function(detail) {  
209 - $("#editBrandId").combobox('select', detail.brandId)  
210 - $("#editProductName").textbox('setValue', detail.productName);  
211 - $("#editSaleTime").myDatebox('setValue', detail.saleTime); 208 + initDom: function() {
  209 + this.dom = {
  210 + editBrandId: $('#editBrandId'),
  211 + editProductName: $('#editProductName'),
  212 + editSaleTime: $('#editSaleTime'),
  213 + editMinPrice: $('#editMinPrice'),
  214 + editMaxPrice: $('#editMaxPrice'),
  215 + editProductCode: $('#editProductCode'),
  216 + editMaxSortId: $('#editMaxSortId'),
  217 + editMidSortId: $('#editMidSortId'),
  218 + editSeriesId: $('#editSeriesId'),
  219 + imageUpload: $('#imageUpload')
  220 + };
  221 + },
  222 + initFormData: function(detail) {
  223 + var that = this;
  224 +
  225 + this.dom.editBrandId.combobox('select', detail.brandId)
  226 + this.dom.editProductName.textbox('setValue', detail.productName);
  227 + this.dom.editSaleTime.myDatebox('setValue', detail.saleTime);
  228 + this.dom.editMinPrice.textbox('setValue', detail.minPrice);
  229 + this.dom.editMaxPrice.textbox('setValue', detail.maxPrice);
  230 + this.dom.editProductCode.textbox('setValue', detail.productCode);
  231 + this.dom.editMaxSortId.combobox('select', detail.maxSortId);
  232 + this.dom.editMidSortId.combobox('select', detail.midSortId);
  233 + this.dom.editSeriesId.combobox('select', detail.seriesId);
212 $('input[name=gender]').eq(detail.gender - 1).attr('checked','true'); 234 $('input[name=gender]').eq(detail.gender - 1).attr('checked','true');
213 - $('#editMinPrice').textbox('setValue', detail.minPrice);  
214 - $('#editMaxPrice').textbox('setValue', detail.maxPrice);  
215 - $('#editProductCode').textbox('setValue', detail.productCode);  
216 - $("#editMaxSortId").combobox('select', detail.maxSortId);  
217 - $("#editMidSortId").combobox('select', detail.midSortId);  
218 - $("#editSeriesId").combobox('select', detail.seriesId);  
219 -  
220 - $('.group-color li[data-id='+detail.colorId+']').addClass('actived');  
221 - 235 + $('.group-color li[data-id=' + detail.colorId + ']').addClass('actived');
  236 +
222 if (detail.imageUrlList.length > 0) { 237 if (detail.imageUrlList.length > 0) {
223 detail.imageUrlList.map(function(item) { 238 detail.imageUrlList.map(function(item) {
224 - $('#imageUpload').before('<div class="img" data-url="' + item + '" style="background-image:url(' + item + ');">'); 239 + that.dom.imageUpload.before('<div class="img" data-url="' + item + '" style="background-image:url(' + item + ');">');
225 }); 240 });
226 } 241 }
227 }, 242 },
228 initForm: function() { 243 initForm: function() {
229 - var that = this; 244 + var that = this;
230 245
231 - $("#editProductName").textbox({ 246 + this.dom.editProductName.textbox({
232 required: true, 247 required: true,
233 missingMessage: "商品名称不能为空", 248 missingMessage: "商品名称不能为空",
234 prompt: "商品名称", 249 prompt: "商品名称",
235 width: 460 250 width: 460
236 }); 251 });
237 -  
238 - $('#keyword').textbox({ 252 +
  253 + $('#keyword').textbox({
239 width: 700 254 width: 700
240 - });  
241 -  
242 - $("#editBrandId").combobox({ 255 + });
  256 +
  257 + this.dom.editBrandId.combobox({
243 editable: false, 258 editable: false,
244 prompt: "选择品牌", 259 prompt: "选择品牌",
245 width: 200, 260 width: 200,
246 valueField: "id", 261 valueField: "id",
247 textField: "text", 262 textField: "text",
248 onSelect: function(data) { 263 onSelect: function(data) {
249 - $('#editSeriesId').combobox('enable');  
250 - $("#editSeriesId").myCombobox('reload', contextPath + '/brandSeries/querySeriesByBrandId?brandId=' + data.id);  
251 - $("#editSeriesId").combobox('select') 264 + that.dom.editSeriesId.combobox('enable');
  265 + that.dom.editSeriesId.myCombobox('reload', contextPath + '/brandSeries/querySeriesByBrandId?brandId=' + data.id);
  266 + that.dom.editSeriesId.combobox('select')
252 } 267 }
253 - });  
254 -  
255 - $("#editSeriesId").myCombobox({  
256 - method: "get", 268 + });
  269 +
  270 + this.dom.editSeriesId.myCombobox({
  271 + method: "get",
257 editable: false, 272 editable: false,
258 prompt: "请选择", 273 prompt: "请选择",
259 width: 200, 274 width: 200,
260 valueField: "id", 275 valueField: "id",
261 textField: "text", 276 textField: "text",
262 loadFilter: function (data) { 277 loadFilter: function (data) {
263 - if (data && data.code == 200 && data.data.length > 0) {  
264 - $("#editSeriesId").combobox('select', data.data[0].id);  
265 - } 278 + if (data && data.code == 200 && data.data.length > 0) {
  279 + that.dom.editSeriesId.combobox('select', data.data[0].id);
  280 + }
266 281
267 return defaultLoadFilter(data); 282 return defaultLoadFilter(data);
268 } 283 }
269 }); 284 });
270 -  
271 - $('#editMaxSortId').myCombobox({ 285 +
  286 + this.dom.editMaxSortId.myCombobox({
272 editable: false, 287 editable: false,
273 valueField: 'id', 288 valueField: 'id',
274 textField: 'text', 289 textField: 'text',
275 prompt:"一级分类", 290 prompt:"一级分类",
276 onSelect: function (rec) { 291 onSelect: function (rec) {
277 - $('#editMidSortId').combobox('clear');  
278 - $('#editMidSortId').combobox('reload', contextPath + "/productSort/getLevel2SortBySortId?sortId=" + rec.id);  
279 - if (!that.productId) {  
280 - $('#editMidSortId').combobox('enable');  
281 - } 292 + that.dom.editMidSortId.combobox('clear');
  293 + that.dom.editMidSortId.combobox('reload', contextPath + "/productSort/getLevel2SortBySortId?sortId=" + rec.id);
  294 + if (!that.productId) {
  295 + that.dom.editMidSortId.combobox('enable');
  296 + }
282 } 297 }
283 }); 298 });
284 -  
285 - $("#editSaleTime").myDatebox({ 299 +
  300 + this.dom.editSaleTime.myDatebox({
286 prompt : "发售时间" 301 prompt : "发售时间"
287 }); 302 });
288 -  
289 - $('#editMidSortId').myCombobox({ 303 +
  304 + this.dom.editMidSortId.myCombobox({
290 method: 'get', 305 method: 'get',
291 editable: false, 306 editable: false,
292 valueField: 'id', 307 valueField: 'id',
293 textField: 'text', 308 textField: 'text',
294 prompt:"二级分类", 309 prompt:"二级分类",
295 loadFilter: function(data) { 310 loadFilter: function(data) {
296 - if (data && data.code == 200 && data.data.length > 0) {  
297 - $("#editMidSortId").combobox('select', data.data[0].id);  
298 - } 311 + if (data && data.code == 200 && data.data.length > 0) {
  312 + that.dom.editMidSortId.combobox('select', data.data[0].id);
  313 + }
299 314
300 - return defaultLoadFilter(data); 315 + return defaultLoadFilter(data);
301 }, 316 },
302 onSelect: function(opt) { 317 onSelect: function(opt) {
303 - that.getSizeInfo(opt.id); 318 + that.getSizeInfo(opt.id);
304 } 319 }
305 }); 320 });
306 321
307 - $("#editProductCode").textbox({ 322 + this.dom.editProductCode.textbox({
308 prompt : "请输入", 323 prompt : "请输入",
309 required: true, 324 required: true,
310 missingMessage: "货号不能为空" 325 missingMessage: "货号不能为空"
311 }); 326 });
312 - $("#editMinPrice").textbox({ 327 + this.dom.editMinPrice.textbox({
313 prompt : "最低价", 328 prompt : "最低价",
314 required: true, 329 required: true,
315 missingMessage: "最低价不能为空" 330 missingMessage: "最低价不能为空"
316 }); 331 });
317 - $("#editMaxPrice").textbox({ 332 + this.dom.editMaxPrice.textbox({
318 prompt : "最高价", 333 prompt : "最高价",
319 required: true, 334 required: true,
320 missingMessage: "最高价不能为空" 335 missingMessage: "最高价不能为空"
321 - });  
322 - 336 + });
323 $('#colorSizeTable').myDatagrid({ 337 $('#colorSizeTable').myDatagrid({
324 fit: false, 338 fit: false,
325 fitColumns: true, 339 fitColumns: true,
@@ -356,34 +370,35 @@ @@ -356,34 +370,35 @@
356 singleSelect: false, 370 singleSelect: false,
357 checkOnSelect: false, 371 checkOnSelect: false,
358 onLoadSuccess: function() { 372 onLoadSuccess: function() {
359 - $('.goods-name').textbox({  
360 - width: 100  
361 - }); 373 + $('.goods-name').textbox({
  374 + width: 100
  375 + });
362 } 376 }
363 }); 377 });
364 - 378 +
365 if (!this.productId) { 379 if (!this.productId) {
366 - $('#editSeriesId').combobox('disable');  
367 - $('#editMidSortId').combobox('disable'); 380 + this.dom.editSeriesId.combobox('disable');
  381 +
368 } else { 382 } else {
369 - $("#editBrandId").combobox('disable');  
370 - $("#editMaxSortId").combobox('disable');  
371 - $("#editMidSortId").combobox('disable'); 383 + this.dom.editBrandId.combobox('disable');
  384 + this.dom.editMaxSortId.combobox('disable');
372 } 385 }
  386 + this.dom.editMidSortId.combobox('disable');
373 }, 387 },
374 init: function() { 388 init: function() {
375 var that = this; 389 var that = this;
376 - this.productId = this.getUrlParam('id');  
377 390
  391 + this.productId = this.getUrlParam('id');
378 this.detailData = {}; 392 this.detailData = {};
379 this.submitFlag = false; 393 this.submitFlag = false;
380 this.colorSizeTableData = { 394 this.colorSizeTableData = {
381 total: 0, 395 total: 0,
382 rows: [] 396 rows: []
383 }; 397 };
  398 + this.initDom();
384 this.initForm(); 399 this.initForm();
385 -  
386 - $("#imageUpload").imageUpload({ 400 +
  401 + this.dom.imageUpload.imageUpload({
387 width: 104, 402 width: 104,
388 height: 104, 403 height: 104,
389 realInputName: "goodsImage", 404 realInputName: "goodsImage",
@@ -410,7 +425,7 @@ @@ -410,7 +425,7 @@
410 onLoadSuccess: function (data) { 425 onLoadSuccess: function (data) {
411 $.messager.progress("close"); 426 $.messager.progress("close");
412 $(document).find('.file-close').click(); 427 $(document).find('.file-close').click();
413 - $('#imageUpload').before('<div class="img" data-url="' + data.data.url + '" style="background-image:url(' + data.data.url + ');">'); 428 + that.dom.imageUpload.before('<div class="img" data-url="' + data.data.url + '" style="background-image:url(' + data.data.url + ');">');
414 return false; 429 return false;
415 } 430 }
416 }); 431 });
@@ -421,19 +436,19 @@ @@ -421,19 +436,19 @@
421 brand = brand[0]; 436 brand = brand[0];
422 maxSort = maxSort[0]; 437 maxSort = maxSort[0];
423 colors = colors[0] || []; 438 colors = colors[0] || [];
424 - 439 +
425 if (brand && brand.code == 200) { 440 if (brand && brand.code == 200) {
426 - $("#editBrandId").combobox({ 441 + that.dom.editBrandId.combobox({
427 data: brand.data || [] 442 data: brand.data || []
428 - }); 443 + });
429 } 444 }
430 - 445 +
431 if (maxSort && maxSort.code == 200) { 446 if (maxSort && maxSort.code == 200) {
432 - $("#editMaxSortId").combobox({ 447 + that.dom.editMaxSortId.combobox({
433 data: maxSort.data || [] 448 data: maxSort.data || []
434 - }); 449 + });
435 } 450 }
436 - 451 +
437 if (colors && colors.code == 200) { 452 if (colors && colors.code == 200) {
438 colors.data.map(function(item) { 453 colors.data.map(function(item) {
439 var color = item.colorValue ? 'background: url('+item.colorValue+')' : 'background:#' + item.colorCode; 454 var color = item.colorValue ? 'background: url('+item.colorValue+')' : 'background:#' + item.colorCode;
@@ -441,14 +456,14 @@ @@ -441,14 +456,14 @@
441 $('.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>'); 456 $('.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>');
442 }); 457 });
443 } 458 }
444 - 459 +
445 if (that.productId) { 460 if (that.productId) {
446 that.getDetailInfo(); 461 that.getDetailInfo();
447 } else { 462 } else {
448 that.getSizeInfo(); 463 that.getSizeInfo();
449 } 464 }
450 }); 465 });
451 - 466 +
452 $(document).on('click', '.group-color li', function() { 467 $(document).on('click', '.group-color li', function() {
453 if (that.productId) { 468 if (that.productId) {
454 $.messager.alert('操作提示', "颜色不可修改!"); 469 $.messager.alert('操作提示', "颜色不可修改!");
@@ -478,7 +493,7 @@ @@ -478,7 +493,7 @@
478 $(this).addClass('actived'); 493 $(this).addClass('actived');
479 } 494 }
480 }); 495 });
481 - 496 +
482 $(document).on('click', '.group-size input', function() { 497 $(document).on('click', '.group-size input', function() {
483 var colorName = goodsName = ''; 498 var colorName = goodsName = '';
484 499
@@ -491,7 +506,7 @@ @@ -491,7 +506,7 @@
491 $.messager.alert('操作提示', '请先选择颜色!'); 506 $.messager.alert('操作提示', '请先选择颜色!');
492 return false; 507 return false;
493 } 508 }
494 - 509 +
495 if (that.colorSizeTableData.rows.length > 0) { 510 if (that.colorSizeTableData.rows.length > 0) {
496 colorName = that.colorSizeTableData.rows[0].colorName; 511 colorName = that.colorSizeTableData.rows[0].colorName;
497 goodsName = that.colorSizeTableData.rows[0].goodsName; 512 goodsName = that.colorSizeTableData.rows[0].goodsName;
@@ -508,7 +523,7 @@ @@ -508,7 +523,7 @@
508 sku: '-' 523 sku: '-'
509 }); 524 });
510 }); 525 });
511 - 526 +
512 if ($('.size-item:checked').length == 0 && colorName) { 527 if ($('.size-item:checked').length == 0 && colorName) {
513 that.colorSizeTableData.rows.push({ 528 that.colorSizeTableData.rows.push({
514 colorName: colorName, 529 colorName: colorName,
@@ -519,116 +534,116 @@ @@ -519,116 +534,116 @@
519 } 534 }
520 that.mergeCells(); 535 that.mergeCells();
521 }); 536 });
522 - 537 +
523 $(document).on('click', '.goods-image .img', function() { 538 $(document).on('click', '.goods-image .img', function() {
524 $(this).remove(); 539 $(this).remove();
525 }); 540 });
526 - 541 +
527 $('#cancelBtn').linkbutton({ 542 $('#cancelBtn').linkbutton({
528 onClick: function() { 543 onClick: function() {
529 window.location.href = contextPath + "/html/product/productList.html"; 544 window.location.href = contextPath + "/html/product/productList.html";
530 } 545 }
531 }); 546 });
532 - 547 +
533 $('#submitBtn').linkbutton({ 548 $('#submitBtn').linkbutton({
534 onClick: function () { 549 onClick: function () {
535 - var imageUrlList = [];  
536 - var sizeIdList = [];  
537 - var editImage = 0;  
538 -  
539 - if (this.submitFlag) {  
540 - return;  
541 - }  
542 -  
543 - this.submitFlag = true;  
544 -  
545 - $('.goods-image .img').each(function(index, item) {  
546 - imageUrlList.push($(item).data('url'));  
547 - });  
548 -  
549 - if (that.productId) {  
550 - if (imageUrlList.length == that.detailData.imageUrlList.length) {  
551 - $.each(imageUrlList, function(index, item) {  
552 - if (item != that.detailData.imageUrlList[index]) {  
553 - editImage = 1;  
554 - }  
555 - });  
556 - } else {  
557 - editImage = 1;  
558 - }  
559 - } else {  
560 - editImage = 1;  
561 - $('.group-size input:checked').each(function(index, item) {  
562 - sizeIdList.push(+$(item).val());  
563 - });  
564 - }  
565 -  
566 - var ajaxData = {  
567 - brandId: +$('#editBrandId').textbox('getValue'),  
568 - colorId: +$('.group-color .actived').data('id'),  
569 - colorName: $('.group-color .actived').text(),  
570 - editImage: editImage,  
571 - gender: +$('input[name="gender"]:checked').val(),  
572 - goodsName: $('.goods-name').length>0 && $('.goods-name').textbox('getValue') || '',  
573 - imageUrlList: imageUrlList,  
574 - keyWords: $('#keyword').textbox('getValue'),  
575 - maxPrice: $('#editMaxPrice').textbox('getValue'),  
576 - maxSortId: +$('#editMaxSortId').combobox('getValue'),  
577 - midSortId: +$('#editMidSortId').combobox('getValue'),  
578 - minPrice: $('#editMinPrice').textbox('getValue'),  
579 - productCode: $('#editProductCode').textbox('getValue'),  
580 - productName: $('#editProductName').textbox('getValue'),  
581 - saleTime: $("#editSaleTime").myDatebox('getValue'),  
582 - seriesId: +$('#editSeriesId').combobox('getValue')  
583 - };  
584 -  
585 - if (!ajaxData.brandId) {  
586 - $.messager.alert('操作提示', '请选择品牌!');  
587 - return false;  
588 - }  
589 -  
590 - if (!ajaxData.saleTime) {  
591 - $.messager.alert('操作提示', '请选择发售时间!');  
592 - return false;  
593 - }  
594 -  
595 - if (!ajaxData.maxSortId) {  
596 - $.messager.alert('操作提示', '请选择一级分类!');  
597 - return false;  
598 - }  
599 -  
600 - if (!ajaxData.midSortId) {  
601 - $.messager.alert('错误提示', '请选择二级分类!');  
602 - return false;  
603 - }  
604 -  
605 - if (imageUrlList.length == 0) {  
606 - $.messager.alert('操作提示', '至少添加一张图片!');  
607 - return false;  
608 - }  
609 -  
610 - if (!$('#productDetail').form("validate")) {  
611 - return false;  
612 - }  
613 -  
614 - if (!that.productId) {  
615 - ajaxData.sizeIdList = sizeIdList;  
616 -  
617 - if (!ajaxData.colorName) {  
618 - $.messager.alert('错误提示', '请选择颜色!');  
619 - return false;  
620 - }  
621 -  
622 - if (sizeIdList.length ==0) {  
623 - $.messager.alert('错误提示', '请选择尺码!');  
624 - return false;  
625 - }  
626 - } else {  
627 - ajaxData.id = that.detailData.id;  
628 - ajaxData.goodsId = that.detailData.goodsId;  
629 - }  
630 -  
631 - $.messager.progress({ 550 + var imageUrlList = [];
  551 + var sizeIdList = [];
  552 + var editImage = 0;
  553 +
  554 + if (that.submitFlag) {
  555 + return;
  556 + }
  557 +
  558 + that.submitFlag = true;
  559 +
  560 + $('.goods-image .img').each(function(index, item) {
  561 + imageUrlList.push($(item).data('url'));
  562 + });
  563 +
  564 + if (that.productId) {
  565 + if (imageUrlList.length == that.detailData.imageUrlList.length) {
  566 + $.each(imageUrlList, function(index, item) {
  567 + if (item != that.detailData.imageUrlList[index]) {
  568 + editImage = 1;
  569 + }
  570 + });
  571 + } else {
  572 + editImage = 1;
  573 + }
  574 + } else {
  575 + editImage = 1;
  576 + $('.group-size input:checked').each(function(index, item) {
  577 + sizeIdList.push(+$(item).val());
  578 + });
  579 + }
  580 +
  581 + var ajaxData = {
  582 + brandId: +that.dom.editBrandId.textbox('getValue'),
  583 + colorId: +$('.group-color .actived').data('id'),
  584 + colorName: $('.group-color .actived').text(),
  585 + editImage: editImage,
  586 + gender: +$('input[name="gender"]:checked').val(),
  587 + goodsName: $('.goods-name').length>0 && $('.goods-name').textbox('getValue') || '',
  588 + imageUrlList: imageUrlList,
  589 + keyWords: $('#keyword').textbox('getValue'),
  590 + maxPrice: that.dom.editMaxPrice.textbox('getValue'),
  591 + maxSortId: +that.dom.editMaxSortId.combobox('getValue'),
  592 + midSortId: +that.dom.editMidSortId.combobox('getValue'),
  593 + minPrice: that.dom.editMinPrice.textbox('getValue'),
  594 + productCode: that.dom.editProductCode.textbox('getValue'),
  595 + productName: that.dom.editProductName.textbox('getValue'),
  596 + saleTime: that.dom.editSaleTime.myDatebox('getValue'),
  597 + seriesId: +that.dom.editSeriesId.combobox('getValue')
  598 + };
  599 +
  600 + if (!ajaxData.brandId) {
  601 + $.messager.alert('操作提示', '请选择品牌!');
  602 + return false;
  603 + }
  604 +
  605 + if (!ajaxData.saleTime) {
  606 + $.messager.alert('操作提示', '请选择发售时间!');
  607 + return false;
  608 + }
  609 +
  610 + if (!ajaxData.maxSortId) {
  611 + $.messager.alert('操作提示', '请选择一级分类!');
  612 + return false;
  613 + }
  614 +
  615 + if (!ajaxData.midSortId) {
  616 + $.messager.alert('错误提示', '请选择二级分类!');
  617 + return false;
  618 + }
  619 +
  620 + if (imageUrlList.length == 0) {
  621 + $.messager.alert('操作提示', '至少添加一张图片!');
  622 + return false;
  623 + }
  624 +
  625 + if (!$('#productDetail').form("validate")) {
  626 + return false;
  627 + }
  628 +
  629 + if (!that.productId) {
  630 + ajaxData.sizeIdList = sizeIdList;
  631 +
  632 + if (!ajaxData.colorName) {
  633 + $.messager.alert('错误提示', '请选择颜色!');
  634 + return false;
  635 + }
  636 +
  637 + if (sizeIdList.length ==0) {
  638 + $.messager.alert('错误提示', '请选择尺码!');
  639 + return false;
  640 + }
  641 + } else {
  642 + ajaxData.id = that.detailData.id;
  643 + ajaxData.goodsId = that.detailData.goodsId;
  644 + }
  645 +
  646 + $.messager.progress({
632 title: "正在执行", 647 title: "正在执行",
633 msg: "正在执行,请稍后...", 648 msg: "正在执行,请稍后...",
634 interval: 500, 649 interval: 500,
@@ -636,8 +651,8 @@ @@ -636,8 +651,8 @@
636 }); 651 });
637 652
638 $.ajax({ 653 $.ajax({
639 - url: contextPath + '/product/addOrUpdate',  
640 - contentType: "application/json", 654 + url: contextPath + '/product/addOrUpdate',
  655 + contentType: "application/json",
641 dataType: "json", 656 dataType: "json",
642 type: "POST", 657 type: "POST",
643 data: JSON.stringify(ajaxData), 658 data: JSON.stringify(ajaxData),
@@ -645,10 +660,11 @@ @@ -645,10 +660,11 @@
645 that.submitFlag = false; 660 that.submitFlag = false;
646 $.messager.progress("close"); 661 $.messager.progress("close");
647 $.messager.alert('操作提示', '提交成功!'); 662 $.messager.alert('操作提示', '提交成功!');
  663 + window.location.href = contextPath + "/html/product/productList.html";
648 }, 664 },
649 error: function(err) { 665 error: function(err) {
650 that.submitFlag = false; 666 that.submitFlag = false;
651 - $.messager.alert('操作提示', err.message); 667 + $.messager.alert('操作提示', err.message || '提交失败');
652 } 668 }
653 }); 669 });
654 } 670 }
@@ -680,7 +696,7 @@ @@ -680,7 +696,7 @@
680 if (ret && ret.code == 200) { 696 if (ret && ret.code == 200) {
681 ret = ret.data || {}; 697 ret = ret.data || {};
682 698
683 - that.initData(ret); 699 + that.initFormData(ret);
684 that.detailData = ret; 700 that.detailData = ret;
685 } 701 }
686 }); 702 });
@@ -710,15 +726,15 @@ @@ -710,15 +726,15 @@
710 726
711 if (that.detailData.sizeIdList) { 727 if (that.detailData.sizeIdList) {
712 that.detailData.sizeIdList.map(function(item) { 728 that.detailData.sizeIdList.map(function(item) {
713 - $('.group-size label[data-id=' + item + '] input').attr('checked','true');  
714 - that.colorSizeTableData.rows.push({  
715 - colorName: $('.group-color li[data-id='+that.detailData.colorId+']').text(),  
716 - goodsName: that.detailData.goodsName,  
717 - size: $('.group-size label[data-id=' + item + ']').text(),  
718 - sku: '-'  
719 - });  
720 - });  
721 - } 729 + $('.group-size label[data-id=' + item + '] input').attr('checked','true');
  730 + that.colorSizeTableData.rows.push({
  731 + colorName: $('.group-color li[data-id='+that.detailData.colorId+']').text(),
  732 + goodsName: that.detailData.goodsName,
  733 + size: $('.group-size label[data-id=' + item + ']').text(),
  734 + sku: '-'
  735 + });
  736 + });
  737 + }
722 that.mergeCells(); 738 that.mergeCells();
723 } 739 }
724 }); 740 });
@@ -730,7 +746,7 @@ @@ -730,7 +746,7 @@
730 }; 746 };
731 747
732 $(function () { 748 $(function () {
733 - productDetail.init(); 749 + productDetail.init();
734 }); 750 });
735 751
736 </script> 752 </script>