goods.netsale.Index.js 34.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
webpackJsonp([47],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	'use strict';
	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);

	var refreshHelper = new common.refreshHelper();
	refreshHelper.init($("#filter-btn"));

	// 存储批量上下架中,选中的SKN列表
	window.batchOperateShelve = [];

	// 存储批量上下架中,选中的商品详情
	window.batchShelveProduct = [];

	var ENUM = {
	    gender: {
	        1: '男',
	        2: '女',
	        3: '通用'
	    },
	    status: {
	        '0': '已下架',
	        '1': '已上架',
	        '2': '待审核',
	        '3': '上架驳回',
	        '4': '通过',
	        '5': '再上架待审核',
	        '6': '再上架驳回',
	        '7': '再上架通过',
	        '8': '待上架',
	        '9': '下架驳回',
	        '10':'下架待审核'
	    },
	    attribute: {
	        1: '普通',
	        2: '赠品',
	        3: '虚拟商品'
	    },
	    tab: {
	        '1': 0,
	        '2': 0,
	        '3': 0,
	        '4': 0,
	        '5': 0,
	        'all': 0
	    },
	    isVIP: {
	        "Y": "是",
	        "N": "否",
	        "B": "品牌设置"
	    },
	    isJIT: {
	        "Y": "JIT",
	        "N": "非JIT"
	    },
	    APPType: {
	        0: "非BLK",
	        1: "BLK"
	    },
	    isOutLets: {
	        'Y': "奥莱",
	        'N': "非奥莱",
	        'B':"非奥莱"
	    },
	    isLimited: {
	        'Y': "限量",
	        'N': "非限量"
	    },
	    isLimitbuy: {
	        'Y': "限购",
	        'N': "非限购"
	    },
	    suppledFlag: {   // 是否补货,1可补货,2不可补货 3部分可补货
	        '1': "可补货",
	        '2': "不可补货",
	        '3': "部分可补货"
	    },
	    traderFlag : {
	        '1':'量贩',
	        '0':'非量贩'
	    },
	    salePlatform : {
	        '1':'线上线下均可售',
	        '2':'仅线上可售',
	        '3':'仅线下可售'
	    }
	};

	var tabTree = new common.tabTree("#sortTree");
	tabTree.init();


	var shopId = new common.dropDown({
	    el: '#shopId',
	    ajax: 'shopsRest',
	    hash: true
	});

	var brandId = new common.dropDown({
	    el: '#brandId',
	    ajax: 'brand',
	    hash: true,
	    params:function(){
	        return {userLimitFlag:true};
	    }
	});

	var editPostion = '', isInfoMiss, sortFlag, activeTab = 5;

	var t = new common.tab2({
	    el: "#basicTab",
	    active: refreshHelper.inputHelper("tab"),
	    click: function () {
	        var columnname = t.options.columns[t.options.active].name;
	        activeTab = t.options.active;
	       
	        g.options.columns[12].hidden = true;
	        g.options.columns[9].hidden = false;   // 搜索与便签每个标签都显示
	        if (columnname == 3) {
	            isInfoMiss = 'Y';
	            g.options.columns[12].hidden = false;
	        } else {
	            isInfoMiss = '';
	            //g.options.columns[9].hidden = false;  // 
	        }

	        if (columnname == 1 || columnname == 2 || columnname == 3 || columnname == 4) {
	            sortFlag = 2;
	        } else {
	            sortFlag = 1;
	        }
	        batchOperateShelve = [];

	        batchShelveProduct = [];

	        pageSkn = [];
	        g.init("/goods/netsale/getList");
	        refreshHelper.inputFocusHelper("tab", activeTab);
	        window.location.href = window.location.href.replace(/tab=\d/, 'tab=' + activeTab);
	    },
	    columns: [{
	        name: "0",
	        value: '8',
	        display: "新品待上架({1})"
	    }, {
	        name: "1",
	        value: '1',
	        display: "上架({2})"
	    }, {
	        name: "2",
	        value: '1',
	        display: "搜索/标签({3})"
	    }, {
	        name: "3",
	        value: '1',
	        display: "上架后信息缺失({4})"
	    },  {
	        name: "4",
	        value: '0',
	        display: "下架({5})"
	    },{
	        name: "all",
	        value: 'all',
	        display: "全部商品({all})"
	    }]
	}).init(ENUM.tab);

	var pageSkn = [];
	var g = new common.grid({
	    el: "#basicTable",
	    usepagesize:true,
	    page: refreshHelper.pageHelper(),
	    size: refreshHelper.pageSizeHelper(g),
	    parms: function () {
	        return {
	            productSkn: refreshHelper.inputHelper("productSkn"),
	            productSkc: refreshHelper.inputHelper("productSkc"),
	            productSku: refreshHelper.inputHelper("productSku"),
	            productName: refreshHelper.inputHelper("productName"),
	            shopId: refreshHelper.dropDownHelper(shopId),
	            brandId: refreshHelper.dropDownHelper(brandId),
	            isJit: refreshHelper.inputHelper("isJit"),
	            stock: refreshHelper.inputHelper("stock"),
	            isScreen: refreshHelper.inputHelper("isScreen"),
	            isMeasure: refreshHelper.inputHelper("isMeasure"),
	            gender: refreshHelper.inputHelper("gender"),
	            maxSortId: refreshHelper.tabTreeHelper(tabTree, 0),
	            middleSortId: refreshHelper.tabTreeHelper(tabTree, 1),
	            smallSortId: refreshHelper.tabTreeHelper(tabTree, 2),
	            isOutLets: refreshHelper.inputHelper("isOutLets"),
	            productStatus: refreshHelper.inputHelper("productStatus"),
	            productStatusStr: t.options.columns[t.options.active].value,
	            tab: refreshHelper.inputHelper("tab"),
	            isInfoMiss: isInfoMiss,
	            sortFlag: sortFlag,
	            skcOnsaleStatus: refreshHelper.inputHelper("skcOnsaleStatus"),
	            isAdvance: refreshHelper.inputHelper("isAdvance"),
	            factoryCode: refreshHelper.inputHelper("factoryCode"),
	            skuFactoryCode: refreshHelper.inputHelper("skuFactoryCode"),
	            appType: refreshHelper.inputHelper("appType"),
	            salePlatform: refreshHelper.inputHelper("salePlatform")
	        };
	    },
	    columns: [{
	        display: '',
	        type: 'checkbox',
	        render: function (item) {
	            var htmlContent = "";
	            if(batchOperateShelve.length == 0 ){
	                htmlContent = "<input type='checkbox'  class='wqt_checkbox' data-index='"+item.__index+"'>";
	            }else{
	                $.each(batchOperateShelve,function(n,value) {
	                    if(item.productSkn == value){
	                        htmlContent = "<input type='checkbox' checked='checked'  class='wqt_checkbox' data-index='"+item.__index+"'>";
	                        return false
	                    }else{
	                        htmlContent = "<input type='checkbox'  class='wqt_checkbox'data-index='"+item.__index+"'>";
	                    }
	                })
	            }
	            return htmlContent;
	        }
	    }, {
	        display: 'skn',
	        name: 'productSkn',
	        render: function (item) {
	            pageSkn.push(item.productSkn);
	            return '<a target="_blank" href="/goods/netsale/info/' + item.productSkn + editPostion + '">' + item.productSkn + '</a>'
	        }
	    }, {
	        display: '图片',
	        name: 'picImgUrl',
	        render: function (item) {
	            if (item.picImgUrl) {
	                return '<a class="list-img" target="_blank" href="' + item.productUrl + '">' +
	                    '<img src="' + item.picImgUrl + '"></a>';
	            } else {
	                return '';
	            }

	        }
	    }, {
	        display: '商品信息',
	        width: '25%',
	        render: function (item) {
	            var productName = item.productName ? item.productName : '',
	                brandName = item.brandName ? item.brandName : '',
	                sortName = '',
	                html = '';

	            if (item.smallSortName) {
	                sortName = item.smallSortName;
	            } 
	            if (item.middleSortName) {
	                sortName = item.middleSortName+"/"+sortName;
	            } 
	            if (item.maxSortName) {
	                sortName = item.maxSortName+"/"+sortName;
	            }
	            html += '<strong>名称:</strong><a target="_blank" href="' + item.productUrl + '">' + productName + '</a></br>';
	            html += '<strong>品牌:</strong>' + brandName + '</br>';
	            html += '<strong>类目:</strong>' + sortName + '</br>';
	            html += '<strong>店铺:</strong>' + item.shopName + '</br>';
	            html += '<strong>经营模式:</strong>' + (item.sellType ? item.sellType : '') + '</br>';
	            html += '<strong>可售平台:</strong>' + (ENUM.salePlatform[item.salePlatform] ? ENUM.salePlatform[item.salePlatform] : '');
	            return html;
	        }
	    }, {
	        display: '售价',
	        render: function (item) {
	            var vip = ENUM.isVIP[item.isVIP] ? ENUM.isVIP[item.isVIP] : '',
	                retailPrice = item.retailPrice ? item.retailPrice : '',
	                salesPrice = item.salesPrice ? item.salesPrice : '';

	            var html = '<strong>吊牌价:</strong>' + retailPrice + '</br>' +
	                '<strong>销售价:</strong>' + salesPrice + '</br>' +
	                '<strong>是否VIP:</strong>' + vip + '</br>';

	            if (item.returnCoinMoney) {
	                html += "<strong>返yoho币金额:</strong>" + item.returnCoinMoney;
	            } else {
	                html += "<strong>返yoho币金额:</strong>0";
	            }
	            return html;
	        }
	    }, {
	        display: '可售库存',
	        name: 'stock'
	    }, {
	        display: '年龄层/性别',
	        render: function (item) {
	            var html = '';
	            if (item.ageLevel) {
	                html += common.config.__ageLevel(item.ageLevel);
	            }
	            if (html && item.gender) {
	                html += '/';
	            }
	            if (ENUM.gender[item.gender]) {
	                html += ENUM.gender[item.gender]
	            }
	            return html;
	        }
	    }, {
	         display: '商品页签',
	        //name: 'attribute', //商品属性(1普通、2赠品等)   商品类别
	        width: '5%',
	        render: function (item) {
	            var html = [];
	            if (item.attribute) {
	                 html.push(ENUM.attribute[item.attribute]+"</br>");
	            }
	            if (item.isJit) {
	                html.push(ENUM.isJIT[item.isJit]+"</br>");
	            }
	            if (item.appType || item.appType == 0) {
	                html.push(ENUM.APPType[item.appType]+"</br>");
	            }
	            if (item.isOutlets) {
	                html.push(ENUM.isOutLets[item.isOutlets]+"</br>");
	            }
	            if (item.isLimited) {
	                html.push(ENUM.isLimited[item.isLimited] + "</br>");
	            }
	            if (item.isLimitbuy) {
	                html.push(ENUM.isLimitbuy[item.isLimitbuy] + "</br>");
	            }
	            return '<div id="property_'+ item.__index + '" data-skn="'+ item.productSkn + '">' + html.join('') + '</div>';
	        }
	    },{
	        display: "是否预售",
	        render: function(item) {
	            var html = [];
	            //判断是否是预售商品
	            if (item.isAdvance === "Y") {
	                var formatted = "";
	                if (item.expectArrivalTime) {
	                    var t = new Date(item.expectArrivalTime * 1000);
	                    formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
	                }

	                if (item.isDepositAdvance === 'Y') {
	                    html.push("<p>定金预售</p>");
	                } else {
	                    html.push("<p>普通预售</p>");
	                }
	                if (item.isDepositAdvance === 'Y') {
	                    html.push("<p>定金:"+item.deposit+"</p>");
	                }

	                html.push("<p>预计到货时间:" + formatted + "</p>");
	            } else {
	                html.push("<p>否</p>");
	            }

	            return html.join('');
	        }
	    },  {
	        display: '搜索/标签',
	        width: '10%',
	        hidden: false,
	        render: function (item) {
	            var searchAndLabel = item.searchAndLabel ? item.searchAndLabel : '',
	                searchKeys = item.searchKeys ? item.searchKeys : '',
	                style = item.style ? item.style : '',
	                pattern = item.pattern ? item.pattern : '',
	                makeCrafts = item.makeCrafts ? item.makeCrafts : '';
	            if(searchKeys.length>50){
	                searchKeys=searchKeys.substr(0,50)+"...";
	            }
	            return '<strong>关键词:</strong>' + searchKeys + '<br>' +
	                '<strong>风格:</strong>' + style + '<br>' +
	                '<strong>纹理:</strong>' + pattern + '<br>' +
	                '<strong>工艺:</strong>' + makeCrafts + '<br>';
	        }
	    }, {
	        display: '操作信息',
	        render: function (item) {
	            var html = '';
	            if (item.founderName) {
	                html += '<p>' + item.founderName + '</p>';
	            }

	            if (item.editTime) {
	                html += '<p>' + item.editTime + '</p>';
	            }

	            return html;
	        }
	    }, {
	        display: '上下架状态',
	        name: 'status', // 8待上架,2待审核,3驳回,4通过,1已上架,0已下架,5再上架待审核,6再上架驳回,7再上架通过。
	        render: function (item) {
	            var html = '';
	            if (ENUM.status[item.status]) {
	                html += ENUM.status[item.status];
	            }

	            if (item.status == 3 || item.status == 6 ||item.status == 9) {
	                html += '<p style="color:red;">(' + item.rejectReason + ')</p>'
	            }
	            if (item.isAdvance == "Y") {
	                if (item.advanceBeginTime) {
	                    html += '<br>预售开始时间' + item.advanceBeginTime;
	                }
	                if (item.advanceEndTime) {
	                    html += '<br>预售结束时间' + item.advanceEndTime;
	                }
	            } else {
	                if (item.shelveTime&&item.status==1) {
	                    html += '<br>上架时间' + item.shelveTime;
	                } else if(item.preShelveTime&&(item.status==4||item.status==7)){
	                    html += '<br>预上架时间' + item.preShelveTime;
	                }
	            }
	            //商品为预售商品,上架状态为通过,在【上架状态】列表栏,显示上架时间(为设置的【预售开始时间】)、下架时间(为设置的【预售结束时间】)
	            //2)    商品为预上架商品,上架状态为通过,在【上架状态】列表栏,显示上架时间(为设置的【预上架时间】)
	            return html;
	        }
	    }, {
	        display: '缺失信息',
	        hidden: true,
	        render: function (item) {
	            var html = [];
	            html.push('<p style="color: red;">');
	            var arr = item.missInfo ? item.missInfo.split(',') : '';
	            for (var i in arr) {
	                var item1 = $.trim(arr[i]);
	                if (item) {
	                    html.push('<a target="_blank" href="/goods/netsale/edit/' + item.productSkn + editPostion + '#' + item1 + '">' + item1 + '</a>');
	                }
	            }
	            html.push('</p>');
	            return html.join('');
	        }
	    },  {
	        display: 'SKC个数',
	        name: 'skcNum'
	    },{
	        display: '操作',
	        width: '10%',
	        render: function (item) {
	            var HtmArr = [];
	            var intValue ;
	            var intVal_shopsSearchSort;
	            if (item.status == 4 || item.status == 1 || item.status == 5 || item.status == 6 || item.status == 7 || item.status == 9 || item.status == 10) {
	                HtmArr.push('<a target="_blank" href="/goods/netsale/edit/' + item.productSkn + editPostion + '" class="btn btn-info btn-xs edit-btn">编辑</a>');
	                // HtmArr.push('<a href="javascript:;" class="btn btn-danger btn-xs shelve-btn" data-index="' + item.__index + '">下架</a>');
	            } else if (item.status == 3 || item.status == 8 || item.status == 2 || item.status == 0) {
	                HtmArr.push('<a target="_blank" href="/goods/netsale/edit/' + item.productSkn + editPostion + '" class="btn btn-info btn-xs edit-btn">编辑</a>');
	                // HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs shelve-btn" data-index="' + item.__index + '">上架</a>');
	            }
	            HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs shelve-btn" data-index="' + item.__index + '">上/下架</a>');
	            HtmArr.push('<a target="_blank" href="/goods/netsale/info/' + item.productSkn + editPostion + '" class="btn btn-info btn-xs info-btn">查看</a>');
	            HtmArr.push('<br><a href="javascript:;" class="btn btn-success btn-xs chima-btn" data-index="' + item.__index + '">尺码</a>');
	            // HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs status-log-btn" data-value="' + item.productSkn + '">操作日志</a>');
	            if(typeof(item.productSearch) == "undefined"){
	                intValue = 0;
	            }else{
	                intValue=item.productSearch.intValue;
	            }
	            HtmArr.push('<br><input type="text" style="width:50px" name="brandSort"  id="brandSortId" class="brandSortText"  data-index="' + item.__index + '" value='+intValue+'>');
	            HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs brandSort-btn" data-index="' + item.__index + '" >品牌排序</a>');

	            if(typeof(item.shopsSearchSort) == "undefined"){
	                intVal_shopsSearchSort = 0;
	            }else{
	                intVal_shopsSearchSort = item.shopsSearchSort.intValue;
	            }
	            HtmArr.push('<br><input type="text" style="width:50px" name="shopsSort" id="shopsSortId" class="brandSortText"  data-index="' + item.__index + '" value='+ intVal_shopsSearchSort+'>');
	            HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs shopsSort-btn" data-index="' + item.__index + '" >店铺排序</a>');
	            return HtmArr.join('');
	        }
	    }],
	    selectedCallback:function(item){
	        if($.inArray(item.productSkn, batchOperateShelve) == -1 ){
	            batchOperateShelve.push(item.productSkn);
	            batchShelveProduct.push(item);
	        }         
	    },
	    unselectedCallback:function(item){
	        var _index = $.inArray(item.productSkn, batchOperateShelve);
	        if(_index != -1 ){
	            batchOperateShelve.splice(_index,1);
	            batchShelveProduct.splice(_index,1);
	        }
	    },
	    complete:function(){
	        //渲染表头是否勾选
	        $.each(pageSkn, function (i, pageItem) {
	            if($.inArray(pageItem, batchOperateShelve) == -1 ) {

	                $(".wqt_all").prop("checked", false);

	                return false;
	            }
	            $(".wqt_all").prop("checked", true);
	        });

	        getProductLabeldata(pageSkn);  // 异步查询商品标签的填充到商品标签那一列

	        pageSkn = [];
	    }
	});
	g.init("/goods/netsale/getList");


	//tab
	var loadtab = function () {
	    // t.active = undefined;
	    setTimeout(function () {
	        common.util.__ajax({
	            url: '/goods/product/queryTabProductNum',
	            data: g.options.parms()
	        }, function (res) {
	            var __dt = $.extend({}, ENUM.tab, res.data);
	            t.setData(__dt);
	            t.render(__dt);
	        }, true);
	    }, 400);
	}
	loadtab();


	//筛选
	$("#filter-btn").click(function () {
	    loadtab();
	    //$('#basicTab li:eq(5)').click();   // 每次点击筛选,需要先跳转到“全部”页签下面
	    g.reload(1);
	});


	/*
	 * 上架下架弹框
	 * params: title(弹框标题), html(弹框内容html)
	 */
	function shelveModal(title, html) {
	    var selectedArr = g.selected,
	        len = selectedArr.length,
	        productSknList = [],
	        shelveLayer = null,
	        shelveData = {};
	    // $.each(selectedArr, function (i, value) {
	    //     // productSknList.push(value['productSkn']);
	    // });

	    if (batchOperateShelve.length <= 0) {
	        common.util.__tip('请选择要' + title + '的商品', 'warning');
	        return;
	    }
	    shelveData.num=batchOperateShelve.length;
	    //详情skn不要展示
	/*    if(batchOperateShelve.length > 0) {
	        var s="";
	        $.each(batchOperateShelve, function (key, value) {
	            if(key != 0 && key%6 == 0){
	                s = s +"<br>";
	            }
	            s = s + value+",";
	        });
	        shelveData.skns=s.substr(0,s.length-1);
	    }*/

	    shelveLayer = common.dialog.open({
	        title: title,
	      //  content: html,
	        content: common.util.__template(html, shelveData),
	    });


	    // if (len === 1) {
	    //  if(g.selected[0].isAdvance === 'N'){
	    //      $('#advanceBeginTime, #advanceEndTime').prop('disabled', true);
	    //      $('#advanceBeginTime').parents('.form-group').find('.btn').addClass('disabled');
	    //  }else{
	    //      $('#shelveTime').prop('disabled', true);
	    //      $('#shelveTime').parents('.form-group').next(".form-group").find('.btn').addClass('disabled');
	    //  }
	    // }
	    //普通预售置灰购买按钮
	    if(batchOperateShelve.length > 0) {
	            $.each(batchShelveProduct, function (index, item) {
	            if(item.isAdvance=='Y'&&item.isDepositAdvance == 'N') {
	                $('#buyTime').prop('disabled', true);
	            }
	        });
	    };

	    var e = new common.edit('.shelve-form');
	    e.init();

	    //取消
	    var nocancel=true;
	    $('#cancelShelve').on('click', function () {
	        nocancel=false;
	     });

	    $('.shelve-form').on('click', '.btn', function () {
	        var type = $(this).data('type');
	        $(this).closest('.form-group').find('input').attr('required', true)
	            .end().siblings('.form-group').find('input').attr('required', false);
	        var data = {}, isValidate = false;

	        data.productSknList = JSON.stringify(batchOperateShelve);
	        if (type == "5") {
	            data.advanceBeginTime = $("#advanceBeginTime").val();
	            data.advanceEndTime = $("#advanceEndTime").val();
	            data.buyTime = $("#buyTime").val();
	            if (!(data.advanceEndTime && data.advanceEndTime)) {
	                isValidate = true;
	                e.$tip("请填写预售时间");
	                return;
	            }
	            data.type = 5;
	        } else {
	            if ($("#shelveTime").val()) {
	                if (type == "1") {
	                    data.shelveTime = $("#shelveTime").val();
	                    data.type = 3;
	                } else {
	                    data.onNewTime = $("#shelveTime").val();
	                    data.type = 4;
	                }

	            } else {
	                data.type = type;
	            }
	        }
	        if (!isValidate&&nocancel) {
	            common.util.__ajax({
	                url: '/goods/product/updateProductSknTimingInfo',
	                data: data
	            }, function (res) {
	                batchOperateShelve = [] ;
	                batchShelveProduct = [];
	                shelveLayer.close();
	                loadtab();
	                g.reload();
	            });
	        }
	    });
	}


	//批量上架需要确认
	$('#onshelve,#onshelveEx').on('click', function () {

	    if (batchOperateShelve.length == 0) {
	        common.util.__tip("未选中任何SKN, 请核实!", 'warning');
	        return false;
	    } else {
	        if (batchShelveProduct[0].isAdvance === 'N') {
	            shelveModal('普通商品上架', $('#common-onshelve-template').html());
	        } else {
	            shelveModal('预售商品上架', $('#presell-onshelve-template').html());
	        }
	    }
	});



	//批量skn下架
	$('#offshelve,#offshelveEx').on('click', function () {
	    shelveModal('下架', $('#offshelve-template').html());
	});


	//导出
	$('#export-btn').on('click', function () {
	    var count = 0,
	        selectedArr = g.selected,
	        len = selectedArr.length,
	        data = g.options.parms();

	    $.each(data, function (key, value) {
	        if (value && value != '' && key != 'size' && key != 'tab') {
	            count++;
	        }
	    });

	    if (count == 0 && len <= 0) {
	        common.util.__tip('请选择导出商品的条件', 'warning');
	        return;
	    }

	    if (len > 0) {
	        data.productSknList = [];
	        $.each(selectedArr, function (i, value) {
	            data.productSknList.push(value['productSkn']);
	        });
	    }


	    window.open("/ajax/down?queryConf=" + JSON.stringify(data) + "&type=netSale");
	});

	//sku skc上架表格
	var shelveTable = new common.grid({
	    el: "#shelve-table",
	    secondIndex: 2,
	    columns: [{
	        display: '默认封面图',
	        render: function (item) {
	            if (item.initGoodsImageUrl) {
	                return '<img src="' + item.initGoodsImageUrl + '" width=120 height=80>';
	            }
	        }
	    }, {
	        display: 'SKC(商品信息)',
	        render: function (item) {
	            var factoryGoodsName="";
	            if(item.factoryGoodsName!=undefined&&item.factoryGoodsName!=null){
	                 factoryGoodsName=item.factoryGoodsName;
	            }
	            return 'SKC:' + item.productSkc + '<br>' +
	                '颜色:' + item.goodsName+ '<br>' +
	                '厂家颜色:' + factoryGoodsName;
	        }
	    }, {
	        display: 'SKC上架操作(状态)',
	        render: function (item) {
	            if (item.status == 0) {
	                return '<a class="btn btn-success btnskc" data-type="1" data-index="' + item.__index + '" href="javascript:;">点击上架</a>';
	            } else {
	                return '<a class="btn btn-danger btnskc" data-type="0" data-index="' + item.__index + '"  href="javascript:;">点击下架</a>';
	            }
	        }
	    }, {
	        display: '<div class="subhhead"><span>SKU</span><span>尺码</span><span>库存</span><span>SKU状态</span><span>SKU上架操作</span></div>',
	        render: function (item) {
	            return common.util.__template2($("#template2").html(), item)
	        }
	    }]
	});

	/*代码优惠*/
	var goodsList = {},
	    shelveLayer = null;
	//单个sku,skc上下架
	$('#basicTable').on('click', '.shelve-btn', function () {
	    var item = g.rows[$(this).data("index")];

	    var that = this;

	    $(that).addClass('disabled');

	    getdata(item.productSkn, function (res) {
	        shelveLayer = common.dialog.open({
	            title: '上/下架',
	            width: 900,
	            content: common.util.__template($('#template').html(), res.data.baseProductInfo.baseProduct),

	            // add by xueyin: 增加支持点击背影关闭对话框功能
	            backdrop: true
	        });

	        $(that).removeClass('disabled');
	        goodsList = res.data.goodsList;
	        shelveTable.init(goodsList);
	    });

	});

	function getdata(Skn, callback) {
	    common.util.__ajax({
	        url: '/goods/netsale/getdata',
	        data: {
	            param: Skn
	        }
	    }, function (res) {
	        callback && callback(res);
	    }, true);
	}


	$(document).on("click", ".btnskc", function () {
	    var item = goodsList[$(this).data("index")];
	    common.util.__ajax({
	        url: '/goods/product/updateGoodsStatus',
	        data: {
	            productSkc: item.productSkc,
	            targetStatus: item.status ? 0 : 1
	        }
	    }, function (res) {
	        if (res.code == 200) {
	            getdata(item.productSkn, function (res) {
	                goodsList = res.data.goodsList;
	                shelveTable.init(res.data.goodsList);
	            });
	            // g.init("/goods/netsale/getList");
	        }
	    })
	});

	$(document).on("click", ".btnsku", function () {
	    var item = goodsList[$(this).data("index")]
	    var item1 = item.goodsSizeList[$(this).data("subindex")];
	    common.util.__ajax({
	        url: '/goods/product/updateProductSkuStatus',
	        data: {
	            productSku: item1.productSku,
	            targetStatus: item1.status ? 0 : 1
	        }
	    }, function (res) {
	        if (res.code == 200) {
	            getdata(item.productSkn, function (res) {
	                goodsList = res.data.goodsList;
	                console.log(goodsList);
	                shelveTable.init(res.data.goodsList);
	            });
	        }
	    })
	});


	$(document).on("change", ".wqt_checkbox,.wqt_all", function () {
	    var _isAdvance0 = 0,
	        _isAdvance1 = 0,
	        _count1 = 0,
	        _count2 = 0;
	    $.each(batchShelveProduct, function (index, item) {
	        /*添加兼容逻辑*/
	        if (item.status == 8 || item.status == 3 || item.status == 2 || item.status == 0) {
	            _count1++; //上
	        } else {
	            _count2++; //下
	        }
	        if (item.isAdvance == "N") {
	            _isAdvance0++;
	        }
	        if (item.isAdvance == "Y") {
	            _isAdvance1++;
	        }

	    });
	    if (_isAdvance0 && _isAdvance1) {
	        $('#onshelve').addClass('disabled');

	        common.util.__tip("选中的商品中,不能同时包含普通商品和预售商品,请确认!", "warning");
	        return;
	    }

	    $('#onshelve').removeClass('disabled');

	    if (_count2 > 0) {
	        $('#offshelve').removeClass('disabled');
	    } else {
	        $('#offshelve').addClass('disabled');
	    }
	});
	/**
	 * 尺码信息
	 */
	$(document).on("click", ".chima-btn", function () {
	    var item = g.rows[$(this).data("index")];
	    common.util.__ajax({
	        url: '/meterManage/productSize/queryProdSizeList',
	        data: {
	            productSkn: item.productSkn
	        }
	    }, function (res) {
	        if (res.data.list && res.data.list.length > 0) {
	            var dataList = res.data.list[0];
	            var a = dataList.productType.replace(/<br>/g, "/");
	            dataList.productType = a.substring(0, a.length - 1);
	            common.sizeInfo.toast("/meterManage/productSize/saveProdSizeInfo", dataList, true, g);
	        }
	    }, true);
	});
	/**
	 *品牌排序
	 */

	/*验证 hack*/
	$(document).on('keyup', '#brandSortId', function() {
	    $(this).val($(this).val().replace(/\D/g, ''));
	});

	$(document).on("click", ".brandSort-btn", function () {
	    var item = g.rows[$(this).data("index")];
	    var num = $("input:text[name='brandSort']").eq($(this).data("index")).val();
	    var searchSortList = [];
	    for (var i = 0; i < 1; i++) {
	        searchSortList[i] = {
	            productSkn: item.productSkn,
	            modelId: i + 1,
	            projectId: 1,
	            intValue: $.trim(num)
	        };
	    }
	    common.util.__ajax({
	            url: '/netSale/saveSearchSort',
	            data: {
	                searchSortList: JSON.stringify(searchSortList)
	            }
	        }
	    );
	});

	/**
	 *店铺商品排序
	 */
	/*验证 hack*/
	$(document).on('keyup', '#shopsSortId', function() {
	    $(this).val($(this).val().replace(/\D/g, ''));
	});

	$(document).on("click", ".shopsSort-btn", function () {
	    var item = g.rows[$(this).data("index")];
	    var num = $("input:text[name='shopsSort']").eq($(this).data("index")).val();
	    var searchSortList = [];

	    searchSortList.push({
	        productSkn: item.productSkn,
	        modelId: 1,
	        projectId: 5,
	        intValue: $.trim(num)
	    });

	    common.util.__ajax({
	            url: '/netSale/saveShopsSearchSort',
	            data: {
	                searchSortList: JSON.stringify(searchSortList)
	            }
	        }
	    );
	});

	//当点击“无需测量”,该列输入框不可编辑
	common.sizeInfo.check();



	//状态操作日志表格
	var statusLogTable = new common.grid({
	    el: "#status-log-table",
	    secondIndex: 2,
	    columns: [{
	        display: 'SKN',
	        render: function (item) {
	                return item.productSkn;
	        }
	    }, {
	        display: '上架/下架',
	        render: function (item) {
	            return item.operateTypeStr;
	        }
	    }, {
	        display: '操作人',
	        render: function (item) {
	            return item.founderName;
	        }
	    }, {
	        display: '操作时间',
	        render: function (item) {
	            return item.createTimeStr;
	        }
	    }]
	});

	var statusLogList = {};

	// 状态操作日志点击事件
	$(document).on("click", ".status-log-btn", function () {
	   var skn = $(this).attr("data-value");
	    common.util.__ajax({
	        url: '/goods/product/queryStatusOperateLog',
	        data: {
	            param : skn
	        }
	    }, function (res) {
	        if (res.code == 200) {
	            //common.util.__template2($("#status-log-template").html(), res);
	            common.dialog.open({
	                title: '状态操作日志',
	                width: 600,
	                content: common.util.__template($('#status-log-template').html(), res),
	                // add by xueyin: 增加支持点击背影关闭对话框功能
	                backdrop: true
	            });
	            statusLogList = res.data;
	            statusLogTable.init(statusLogList);
	        }
	    }, true);
	});

	// 查询商品标签的异步请求
	function getProductLabeldata(SknList) {
	    var dataObj = {}
	    dataObj.productSknList = JSON.stringify(SknList);

	    if ($('div[flag=true]').length > 0) {
	        return;   // 如果已经加载,不能重复加载
	    }

	    common.util.__ajax({
	                url: '/basegoods/queryProductLabels',
	                data: dataObj
	            }, function (res) {
	               if (res.code == 200) {
	                    $.each(res.data, function (i, value) {
	                        var itemObj = $("div[data-skn=" + value.productSkn + "]");
	                        if (ENUM.suppledFlag["" + value.suppledFlag]) {
	                            itemObj.append(ENUM.suppledFlag["" + value.suppledFlag]);
	                        }
	                        if (ENUM.traderFlag["" + value.traderFlag]) {
	                            itemObj.append("</br><div flag='true'>" + ENUM.traderFlag["" + value.traderFlag] + "</div>");
	                        }// 量贩/非量贩 traderFlag   1 或者 0

	                        // 支持货到付款/不支持货到付款  specialFlag
	                        // 支持退换货/不支持退换货/超过七天不支持退换货   codFlag


	                    });
	                }
	            }, true);
	}

/***/ }
]);