Authored by liuyue

网销上架bug fix

@@ -37,8 +37,8 @@ var ENUM = { @@ -37,8 +37,8 @@ var ENUM = {
37 }, 37 },
38 isVIP: { 38 isVIP: {
39 "Y": "是", 39 "Y": "是",
40 - "N": "否",  
41 - "B": "品牌设置" 40 + "N": "否",
  41 + "B": "品牌设置"
42 } 42 }
43 }; 43 };
44 44
@@ -163,7 +163,8 @@ var g = new common.grid({ @@ -163,7 +163,8 @@ var g = new common.grid({
163 163
164 } 164 }
165 }, { 165 }, {
166 - display: '商品信息',width:'30%', 166 + display: '商品信息',
  167 + width: '30%',
167 render: function(item) { 168 render: function(item) {
168 var productName = item.productName ? item.productName : '', 169 var productName = item.productName ? item.productName : '',
169 brandName = item.brandName ? item.brandName : '', 170 brandName = item.brandName ? item.brandName : '',
@@ -398,31 +399,32 @@ var shelveTable = new common.grid({ @@ -398,31 +399,32 @@ var shelveTable = new common.grid({
398 display: 'SKC上架操作(状态)', 399 display: 'SKC上架操作(状态)',
399 render: function(item) { 400 render: function(item) {
400 if (item.status == 0) { 401 if (item.status == 0) {
401 - return '<a class="btn btn-success btnskc" data-type="1" data-index="'+item.__index+'" href="javascript:;">点击上架</a>'; 402 + return '<a class="btn btn-success btnskc" data-type="1" data-index="' + item.__index + '" href="javascript:;">点击上架</a>';
402 } else { 403 } else {
403 - return '<a class="btn btn-danger btnskc" data-type="0" data-index="'+item.__index+'" href="javascript:;">点击下架</a>'; 404 + return '<a class="btn btn-danger btnskc" data-type="0" data-index="' + item.__index + '" href="javascript:;">点击下架</a>';
404 } 405 }
405 } 406 }
406 }, { 407 }, {
407 display: '<div class="subhhead"><span>SKU</span><span>尺码</span><span>库存</span><span>SKU上架操作</span><span>SKU上架操作</span></div>', 408 display: '<div class="subhhead"><span>SKU</span><span>尺码</span><span>库存</span><span>SKU上架操作</span><span>SKU上架操作</span></div>',
408 - render: function(item){ 409 + render: function(item) {
409 console.log(item); 410 console.log(item);
410 - return common.util.__template2($("#template2").html(),item) 411 + return common.util.__template2($("#template2").html(), item)
411 } 412 }
412 }] 413 }]
413 }); 414 });
414 415
415 /*代码优惠*/ 416 /*代码优惠*/
416 -var goodsList={},shelveLayer=null; 417 +var goodsList = {},
  418 + shelveLayer = null;
417 //单个sku,skc上下架 419 //单个sku,skc上下架
418 $('#basicTable').on('click', '.shelve-btn', function() { 420 $('#basicTable').on('click', '.shelve-btn', function() {
419 - var item=g.rows[$(this).data("index")]; 421 + var item = g.rows[$(this).data("index")];
420 422
421 var that = this; 423 var that = this;
422 424
423 $(that).addClass('disabled'); 425 $(that).addClass('disabled');
424 426
425 - getdata(item.productSkn,function(res){ 427 + getdata(item.productSkn, function(res) {
426 shelveLayer = common.dialog.open({ 428 shelveLayer = common.dialog.open({
427 title: '上/下架', 429 title: '上/下架',
428 width: 900, 430 width: 900,
@@ -430,78 +432,86 @@ $('#basicTable').on('click', '.shelve-btn', function() { @@ -430,78 +432,86 @@ $('#basicTable').on('click', '.shelve-btn', function() {
430 }); 432 });
431 433
432 $(that).removeClass('disabled'); 434 $(that).removeClass('disabled');
433 - goodsList=res.data.goodsList; 435 + goodsList = res.data.goodsList;
434 shelveTable.init(goodsList); 436 shelveTable.init(goodsList);
435 }); 437 });
436 438
437 }); 439 });
438 440
439 -function getdata(Skn,callback){ 441 +function getdata(Skn, callback) {
440 common.util.__ajax({ 442 common.util.__ajax({
441 url: '/goods/netsale/getdata', 443 url: '/goods/netsale/getdata',
442 data: { 444 data: {
443 param: Skn 445 param: Skn
444 } 446 }
445 }, function(res) { 447 }, function(res) {
446 - callback&&callback(res);  
447 - },true); 448 + callback && callback(res);
  449 + }, true);
448 } 450 }
449 451
450 452
451 453
452 -$(document).on("click",".btnskc",function(){  
453 - var item=goodsList[$(this).data("index")]; 454 +$(document).on("click", ".btnskc", function() {
  455 + var item = goodsList[$(this).data("index")];
454 console.log(item); 456 console.log(item);
455 common.util.__ajax({ 457 common.util.__ajax({
456 - url: '/goods/product/updateGoodsStatus',  
457 - data: {productSkc:item.productSkc,targetStatus:item.status} 458 + url: '/goods/product/updateGoodsStatus',
  459 + data: {
  460 + productSkc: item.productSkc,
  461 + targetStatus: item.status ? 0 : 1
  462 + }
458 }, function(res) { 463 }, function(res) {
459 if (res.code == 200) { 464 if (res.code == 200) {
460 - getdata(item.productSkc,function(res){  
461 - goodsList=res.data.goodsList;  
462 - shelveTable.reload(); 465 + getdata(item.productSkn, function(res) {
  466 + goodsList = res.data.goodsList;
  467 + shelveTable.init(res.data.goodsList);
463 }); 468 });
464 - 469 +
465 } 470 }
466 }) 471 })
467 }); 472 });
468 473
469 -$(document).on("click",".btnsku",function(){  
470 - var item=goodsList[$(this).data("index")]  
471 - var item1=item.goodsSizeList[$(this).data("subindex")]; 474 +$(document).on("click", ".btnsku", function() {
  475 + var item = goodsList[$(this).data("index")]
  476 + var item1 = item.goodsSizeList[$(this).data("subindex")];
472 common.util.__ajax({ 477 common.util.__ajax({
473 - url: '/goods/product/updateProductSkuStatus',  
474 - data: {productSkc:item1.productSku,targetStatus:item.status} 478 + url: '/goods/product/updateProductSkuStatus',
  479 + data: {
  480 + productSku: item1.productSku,
  481 + targetStatus: item1.status ? 0 : 1
  482 + }
475 }, function(res) { 483 }, function(res) {
476 if (res.code == 200) { 484 if (res.code == 200) {
477 - getdata(item.productSkc,function(res){  
478 - goodsList=res.data.goodsList; 485 + getdata(item.productSkn, function(res) {
  486 + goodsList = res.data.goodsList;
479 console.log(goodsList); 487 console.log(goodsList);
480 - shelveTable.reload(); 488 + shelveTable.init(res.data.goodsList);
481 }); 489 });
482 } 490 }
483 }) 491 })
484 }); 492 });
485 493
486 -$(document).on("change",".wqt_checkbox,.wqt_all",function(){  
487 - var _count1=0,_count2=0;  
488 - $.each(g.selected,function(index,item){  
489 - console.log(item.status); 494 +$(document).on("change", ".wqt_checkbox,.wqt_all", function() {
  495 + var _count1 = 0,
  496 + _count2 = 0;
  497 + $.each(g.selected, function(index, item) {
490 /*添加兼容逻辑*/ 498 /*添加兼容逻辑*/
491 - if(item.status){  
492 - _count1++;//上  
493 - }else{  
494 - _count2++;//下 499 + if (item.status == 8 || item.status == 3 || item.status == 2 || item.status == 0) {
  500 + _count1++; //上
  501 + } else {
  502 + _count2++; //下
495 } 503 }
496 }); 504 });
497 - if(_count2==g.selected.length){  
498 - $("#offshelve").addClass("btn-info").removeClass("btn-default").prop("disabled",false);  
499 - }else{  
500 - $("#offshelve").addClass("btn-default").removeClass("btn-info").prop("disabled",true); 505 +
  506 + if (_count1 == g.selected.length) {
  507 + $('#onshelve').removeClass('disabled');
  508 + } else {
  509 + $('#onshelve').addClass('disabled');
501 } 510 }
502 - if(_count1==g.selected.length){  
503 - $("#onshelve").addClass("btn-info").removeClass("btn-default").prop("disabled",false);  
504 - }else{  
505 - $("#onshelve").addClass("btn-default").removeClass("btn-info").prop("disabled",true); 511 +
  512 + if (_count2 == g.selected.length) {
  513 + $('#offshelve').removeClass('disabled');
  514 + } else {
  515 + $('#offshelve').addClass('disabled');
506 } 516 }
507 -})  
  517 +});
@@ -142,8 +142,8 @@ @@ -142,8 +142,8 @@
142 </div> 142 </div>
143 143
144 <div class="row" style="margin: 0 0 0 -5px;"> 144 <div class="row" style="margin: 0 0 0 -5px;">
145 - <a id="onshelve" href="javascript:;" class="btn btn-default" >上架</a>  
146 - <a id="offshelve" href="javascript:;" class="btn btn-default">下架</a> 145 + <a id="onshelve" href="javascript:;" class="btn btn-info disabled" >上架</a>
  146 + <a id="offshelve" href="javascript:;" class="btn btn-info disabled">下架</a>
147 <a id="export-btn" href="javascript:;" class="btn btn-info">导出</a> 147 <a id="export-btn" href="javascript:;" class="btn btn-info">导出</a>
148 <a id="import-btn" href="/goods/netsale/batch" class="btn btn-info">批量(排序、款型系列)</a> 148 <a id="import-btn" href="/goods/netsale/batch" class="btn btn-info">批量(排序、款型系列)</a>
149 </div> 149 </div>
@@ -225,10 +225,10 @@ @@ -225,10 +225,10 @@
225 <span>[[item.stock]]</span> 225 <span>[[item.stock]]</span>
226 <span>[[ ["下架","上架"][item.status] ]]</span> 226 <span>[[ ["下架","上架"][item.status] ]]</span>
227 <span> 227 <span>
228 - [[if item.state]]  
229 - <a class="btn btn-success btnsku" data-subindex='[[index]]' data-index=[[__index]] href="javascript:;">上架</a>  
230 - [[else]] 228 + [[if item.status]]
231 <a class="btn btn-danger btnsku" data-subindex='[[index]]' data-index=[[__index]] href="javascript:;">下架</a> 229 <a class="btn btn-danger btnsku" data-subindex='[[index]]' data-index=[[__index]] href="javascript:;">下架</a>
  230 + [[else]]
  231 + <a class="btn btn-success btnsku" data-subindex='[[index]]' data-index=[[__index]] href="javascript:;">上架</a>
232 [[/if]] 232 [[/if]]
233 </span> 233 </span>
234 </div> 234 </div>