productViewCtrl.js 34.4 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
(function (angular) {
    function productViewCtrl($scope, productService,baseDataService,categoryAttrService,$uibModal,$http,$compile,publicSession,$resource, DTOptionsBuilder, DTColumnBuilder, localStorageService, $location, $rootScope,$state) {
        $scope.detailType = 2;//产品查看
        $scope.serchInfo = {};
        //产品查看查询参数
        $scope.productViewParam = {};
        //产品查看查询参数缓存
        $scope.productViewParamStorage = localStorageService.get('productViewParam');
        $scope.statusOptions=[
            {id:0,name:'待发送供应商'},
            {id:1,name:'待供应商完善'},
            {id:2,name:'待总部审核'},
            {id:3,name:'审核不通过'},
            {id:4,name:'待上架'},
            {id:5,name:'已上架'},
            {id:6,name:'已下架'}
        ];
        $scope.buttonList = [
            [{'name':'发送供应商'},{'name':'查看与修改'},{'name':'意见反馈'}],//0待发送供应商
            [{'name':'查看与修改'},{'name':'意见反馈'}],//1待供应商完善
            [{'name':'审核'},{'name':'查看与修改'},{'name':'意见反馈'}],//2待总部审核
            [{'name':'查看与修改'},{'name':'意见反馈'}],//3审核不通过
            [{'name':'发送供应商'},{'name':'上架'},{'name':'查看与修改'},{'name':'意见反馈'}],//4待上架
            [{'name':'下架'},{'name':'查看'},{'name':'意见反馈'}],//5已上架
            [{'name':'发送供应商'},{'name':'上架'},{'name':'查看与修改'},{'name':'意见反馈'}] //6已下架
        ];
        $scope.complainOptions = [
            {id: null, name: '全部'},
            {id: 1, name: '有投诉'},
            {id: 0, name: '无投诉'}
        ];
        $scope.collectOptions = [
            {id: null, name: '全部'},
            {id: true, name: '已收藏'},
            {id: false, name: '未收藏'}
        ];
        $scope.buttonClickEvcent=function(name,id){
            if(name){
                switch(name){
                    case '查看':
                        $scope.productViewParam.scrollTop = $(window).scrollTop();
                        $scope.productViewParam.scrollLeft = $(window).scrollLeft();
                        localStorageService.set("productViewParam",$scope.productViewParam);
                        $state.go('electronicDirectory.productExamineDetail',{id:id,type:$scope.detailType});
                        break;
                    case '收藏':
                        $scope.collect('收藏',id);
                        break;
                    case '取消收藏':
                        $scope.collect('取消收藏',id);
                        break;
                }
            }
        };

        $scope.collect = function (name,id) {
            var obj = {
                productId:id,
                userId:$rootScope.loginUser.userId,
                createdBy:$rootScope.loginUser.userId,
                collectStatus:name
            };
            productService.collect(obj,function (res) {
                if(res && res.data){
                    swal({
                        type: 'success',
                        title: '',
                        html: true,
                        text: name + '成功',
                        showConfirmButton: false,
                        timer: 2000
                    });
                    $scope.getProductList();
                }else {
                    swal({
                        type: 'error',
                        title: '',
                        html: true,
                        text: name + '失败 ' + (res.message || ''),
                        confirmButtonText: "确定"
                    });
                }
            })
        };

        $scope.openImportModal=function(){
            var modalInstance = $uibModal.open({
                templateUrl : 'biz/electronicDirectory/view/importModal.html',
                controller : 'importModalCtrl',
                size : 'md',
                scope:$scope,
                resolve : {
                    pagetType : function() {
                        return {
                            source: 'productManager'
                        };
                    }
                }
            });
            modalInstance.result.then(function() {
                // 模态窗口打开之后执行的函数
            },function(){
                //关闭弹框后执行方法
                $scope.getProductList();
            });
        };
        $scope.changeCarBrand = function (id) {
            return new Promise(function (resolve,reject) {
                $scope.carSeriesOptions = [];
                $scope.serchInfo.carSmallBrand = '';
                $scope.carSmallBrandOptions = '';
                $scope.serchInfo.carSeries = '';
                if(!id){
                    return;
                }
                for(var i =0; i<$scope.carBrandOptions.length;i++){
                    if($scope.carBrandOptions[i].id == id){
                        $scope.carSmallBrandOptions = JSON.parse(JSON.stringify($scope.carBrandOptions[i].childs));
                        $scope.carSmallBrandOptions.unshift({
                            name: '全部'
                        })
                        break;
                    }
                }
                resolve();
            })
        };

        $scope.changeCarSmallBrand = function (id) {
            return new Promise(function (resolve,reject) {
                $scope.serchInfo.carSeries = '';
                $scope.carSeriesOptions = '';
                if(!id){
                    return;
                }
                for(var i = 0; i < $scope.carSmallBrandOptions.length;i++){
                    if($scope.carSmallBrandOptions[i].id == id){
                        $scope.carSeriesOptions = JSON.parse(JSON.stringify($scope.carSmallBrandOptions[i].childs));
                        $scope.carSeriesOptions.unshift({
                            name: '全部'
                        });
                        break;
                    }
                }
                resolve();
            })
        };
        $scope.changeProvince=function(provinceId){
            return new Promise(function (resolve,reject) {
                if(!provinceId){
                    resolve();
                    return;
                }
                $scope.cityOptions = '';
                baseDataService.getCityByProvinceId({provinceId:provinceId},function(res){
                    $scope.cityOptions = res.data;
                    $scope.cityOptions.unshift({
                        city:'全部'
                    })
                    $scope.serchInfo.cityId = '';
                    resolve();
                });
            })
        };
        $scope.changeCategory=function(categoryType,parentCategoryCode){
            return new Promise(function (resolve,reject) {
                switch(categoryType){
                    case 1:
                        $scope.bigCategoryOptions = '';
                        $scope.serchInfo.bigCategoryCode = '';
                        $scope.productCategoryOptions = '';
                        $scope.serchInfo.productCategoryCode = '';
                        $scope.subCategoryOptions = '';
                        $scope.serchInfo.subCategoryCode = '';
                        $scope.userDefinedOptions = '';
                        break;
                    case 2:
                        $scope.productCategoryOptions = '';
                        $scope.serchInfo.productCategoryCode = '';
                        $scope.subCategoryOptions = '';
                        $scope.serchInfo.subCategoryCode = '';
                        $scope.userDefinedOptions = '';
                        break;
                    case 3:
                        $scope.subCategoryOptions = '';
                        $scope.serchInfo.subCategoryCode = '';
                        $scope.userDefinedOptions = '';
                        break;
                    case 4:
                        categoryAttrService.getListByCategoryCode({'categoryCode':parentCategoryCode},function(res){
                            var _data = [];
                            angular.forEach(res.data, function(o){
                                if (o.attrType == 2) {
                                    _data.push(o);
                                }
                            });
                            $scope.userDefinedOptions = _data;
                            //$scope.userDefinedOptions = res.data;
                        });
                        return;
                    default:
                        return;
                }
                if(!parentCategoryCode){
                    return;
                }
                baseDataService.getCategoryLibrarys({'parentCategoryCode':parentCategoryCode},function(res){
                    switch(categoryType){
                        case 1:
                            $scope.bigCategoryOptions = res.data;
                            $scope.bigCategoryOptions.unshift({
                                categoryName:'全部'
                            })
                            break;
                        case 2:
                            $scope.productCategoryOptions = res.data;
                            $scope.productCategoryOptions.unshift({
                                categoryName:'全部'
                            })
                            break;
                        case 3:
                            $scope.subCategoryOptions = res.data;
                            $scope.subCategoryOptions.unshift({
                                categoryName:'全部'
                            })
                            break;
                        default:
                            break;
                    }
                    resolve();
                });
            })
        };
        $scope.selectUserDefinedVal = function(parentIndex,index){
            if($scope.userDefinedOptions[parentIndex].attrValList[index].selected){
                $scope.userDefinedOptions[parentIndex].attrValList[index].selected = false;
            }else{
                $scope.userDefinedOptions[parentIndex].attrValList[index].selected = true;
            }
        };
        /**
         * 获取查询参数
         * */
        $scope.getParam = function(){
            var oInfo = $scope.serchInfo;
            var options = {};
            var productInfo = {};
            if($scope.fieldName && $scope.fieldText){
                productInfo.fieldName = $scope.fieldName;
            	productInfo[$scope.fieldName] = $scope.fieldText;
            };
            if(oInfo){
                if(oInfo.status){
                	productInfo.status = oInfo.status.id;
                }
                if(oInfo.procuctModel){
                	productInfo.procuctModel = oInfo.procuctModel
                }
                if(oInfo.hasComplain){
                	productInfo.hasComplain = oInfo.hasComplain.id;
                }
                if(oInfo.collectStatus){
                    productInfo.collectStatus = oInfo.collectStatus.id;
                }
                if(oInfo.brandName){
                	productInfo.brandName = oInfo.brandName
                }
                if(oInfo.categoryCode){
                	productInfo.categoryCode = oInfo.categoryCode
                }
                if(oInfo.countryId){
                	productInfo.countryId = oInfo.countryId.id;
                	productInfo.provinceId = '';
                	productInfo.cityId = '';
        			if(oInfo.countryId.code == 37){//表示中国
                		if(oInfo.provinceId){
                        	productInfo.provinceId = oInfo.provinceId.pid
                        }
                        if(oInfo.cityId){
                        	productInfo.cityId = oInfo.cityId.cid
                        }
        			}
        		}
                if(oInfo.bizCategoryCode){
                	productInfo.bizCategoryCode = oInfo.bizCategoryCode.code;
                }
                if(oInfo.bigCategoryCode){
                	productInfo.bigCategoryCode = oInfo.bigCategoryCode.code;
                }
                if(oInfo.productCategoryCode){
                	productInfo.productCategoryCode = oInfo.productCategoryCode.code;
                }
                if(oInfo.subCategoryCode){
                	productInfo.subCategoryCode = oInfo.subCategoryCode.categoryCode;
                	if($scope.userDefinedOptions){
                		var attrValIdSelectList = new Array();
                		for(var i = 0;i < $scope.userDefinedOptions.length;i++){
                			var attrValList = $scope.userDefinedOptions[i].attrValList;
                			if(!attrValList || attrValList.length == 0){
                				continue;
                			}
                			var attrValSelect = {};
                			attrValSelect.attrId = $scope.userDefinedOptions[i].attrId;
                			var attrValId = new Array();
                			for(var j = 0;j<attrValList.length;j++){
                				if(attrValList[j].selected){
                					attrValId.push(attrValList[j].attrValId);
                				}
                			}
                			if(attrValId.length > 0){
                				attrValSelect.attrValueIdList = attrValId;
                				attrValIdSelectList.push(attrValSelect);
                    		}
                		}
                		if(attrValIdSelectList.length > 0){
                			productInfo.attrValIdSelectList = attrValIdSelectList;
                		}
                	}
                }
                if(oInfo.carBrand){
                    productInfo.carBrandId = oInfo.carBrand.id;
                }
                if(oInfo.carSmallBrand){
                    productInfo.carSmallBrandId = oInfo.carSmallBrand.id;
                }
                if(oInfo.carSeries){
                    productInfo.carSeriesId = oInfo.carSeries.id;
                }
            };
            productInfo.querySource = 2;
            options.condition = productInfo;
            return options;
        };
        /**
         * 导出excel
         * */
        $scope.exportExcel=function(){
        	var option = $scope.getParam();
            var options = option.productInfo;
            options.querySource = 2;
            $http({
                url: 'setmining/productInfo/export',
                method: "GET",//接口方法
                params: options,
                headers: {
                    'Content-type': 'application/json'
                },
                responseType: 'arraybuffer'
            }).success(function (data, status, headers, config) {
                var blob = new Blob([data], {type: "application/vnd.ms-excel"});
                var objectUrl = URL.createObjectURL(blob);
                var a = document.createElement('a');
                document.body.appendChild(a);
                a.setAttribute('style', 'display:none');
                a.setAttribute('href', objectUrl);
                var filename="产品列表.xlsx";
                a.setAttribute('download', filename);
                a.click();
                URL.revokeObjectURL(objectUrl);
            }).error(function (data, status, headers, config) {
            });
        };
        /**
         * 获取产品列表数据
         */
        $scope.getProductList=function(){
            var param = $scope.getParam();
            $scope.dtInstance.query(param);
        };

        $scope.dtColumns = [
            DTColumnBuilder.newColumn('id').withOption('width',30).withTitle('编号'),
            DTColumnBuilder.newColumn('productCode').withOption('width',50).withTitle('产品编号'),
            DTColumnBuilder.newColumn('productName').withOption('width',50).withTitle('产品名称'),
            DTColumnBuilder.newColumn('procuctModel').withOption('width',80).withTitle('产品生产型号'),
            DTColumnBuilder.newColumn('minQuantity').withOption('width',50).withTitle('起订量'),
            DTColumnBuilder.newColumn('qualityPeriod').withOption('width',50).withTitle('质保期'),
            DTColumnBuilder.newColumn('specification').withOption('width',80).withTitle('规格/容量'),
            DTColumnBuilder.newColumn('unit').withOption('width',50).withTitle('单位'),
            DTColumnBuilder.newColumn('produce').withOption('width',100).withTitle('主图').renderWith(function(e, dt, node, config){
                if(node.productImg){
                    return '<img ng-src="'+ node.productImg + '" style="width: 100%;height:60px;"/>';
                }
                return '';
            }),
            DTColumnBuilder.newColumn('subCategoryCode').withOption('width',50).withTitle('类目代码'),
            DTColumnBuilder.newColumn('subCategoryCode').withOption('width',100).withTitle('类目').renderWith(function(e, dt, node, config){
            	if(!node.categoryLibrary){
            		return "";
            	}
            	return node.categoryLibrary.service + "-" + node.categoryLibrary.big + "-" +
                    node.categoryLibrary.produce + "-" + node.categoryLibrary.categoryName;
            }),
            DTColumnBuilder.newColumn('supplierCode').withOption('width',70).withTitle('供应商SAP代码'),
            DTColumnBuilder.newColumn('supplierName').withOption('width',70).withTitle('供应商SAP名称'),
            DTColumnBuilder.newColumn('brandName').withOption('width',50).withTitle('品牌'),
            DTColumnBuilder.newColumn('cityName').withOption('width',50).withTitle('产地').renderWith(function(e, dt, node, config){
            	var name = '';
            	if(node.countryName){
            		name = node.countryName;
            	}
            	if(node.provinceName){
            		name += node.provinceName;
            		if(node.cityName && node.provinceName != node.cityName){
                		name += node.cityName;
                	}
            	}
            	return name;
            }),
            DTColumnBuilder.newColumn('complainPer').withOption('width',60).withTitle('投诉率').renderWith(function(e, dt, node, config){
            	return (node.complainShopCount ? node.complainShopCount :'0') + '/' + (node.saleShopCount ? node.saleShopCount :'0');
            }),
            DTColumnBuilder.newColumn(null).withTitle(function(){
                return '操作';
            }).withOption('width', 60).withClass('text-center').renderWith(function(e, dt, node, config) {
                var str = '';
                str += '<a href="javascript:void(0)" ng-click="buttonClickEvcent(\'查看\',' + node.id + ')">查看</a> ';
                if(!node.collectStatus){
                    str += '<a href="javascript:void(0)" ng-click="buttonClickEvcent(\'收藏\',' + node.id + ')">收藏</a> ';
                }else {
                    str += '<a href="javascript:void(0)" ng-click="buttonClickEvcent(\'取消收藏\',' + node.id + ')">取消收藏</a> ';
                }
                return str;
            })
        ];

        $scope.dtOptions = DTOptionsBuilder.newOptions()
            .withOption('id','id')
            .withFixedColumns({
                leftColumns: 1,
                rightColumns: 1
            })
            .withOption('lengthMenu', [20,40,60,100])
            .withOption('num', false)
            .withOption('completeCb', function() {
                //使table头部自定义内容能够绑定到当前scope
                setTimeout(function(){
                    $compile(angular.element('.dt-head-ctrl').contents())($scope);
                },0)
            });

        $scope.dtInstance = {
            serverData : function(param){
                if($scope.productViewParamStorage){
                    param.condition = $scope.productViewParamStorage.condition;
                }
                if(param.condition){
                    param.condition.querySource = 2;
                }else {
                    param.condition = {
                        querySource: 2
                    }
                }
                $scope.productViewParam = param;
                localStorageService.remove('productViewParam');
                return productService.getProductList(param);
        	}
        };

        $scope.batchOperate=function(status,message){
            var _selectedItems = $scope.dtInstance.getSelectItems();
            if(_selectedItems.length == 0){
                swal({type: 'error',title: '',html: true,text: '请勾选要' + message + '的数据 <br/>' ,confirmButtonText: "确定"});
                return;
            }
            var _ids = [];
            angular.forEach(_selectedItems, function(o){
                _ids.push(o.id);
            });
            $scope.openConfirmDialog(status,message,_ids.join(','));

        };
        $scope.openConfirmDialog = function(status,message,ids){
            var params = {};
            params.status = status;
            params.message = message;
            params.ids = ids;
            var modalInstance = $uibModal.open({
                animation: true,
                templateUrl: 'productManagerOperateModal',
                controller: 'productManagerOperateCtrl',
                size: 'sm',
                resolve: {
                    params: params,
                    dtInstance: $scope.dtInstance,
                    queryParams: $scope.getParam()
                }
            });
        };
        $scope.openAuditDialog = function(id){
            var params = {};
            params.ids = id;
            var modalInstance = $uibModal.open({
                animation: true,
                templateUrl: 'productManagerAuditModal',
                controller: 'productManagerAuditCtrl',
                size: '40sm',
                resolve: {
                    params: params,
                    dtInstance: $scope.dtInstance,
                    queryParams: $scope.getParam()
                }
            });
        };
        
        $scope.getCarBrand = function () {
            return new Promise(function (resolve,reject) {
                baseDataService.getCarBrand(function(res){
                    $scope.carBrandOptions = res.data;
                    $scope.carBrandOptions.unshift({
                        name:'全部'
                    });
                    resolve();
                })
            })
        };
        $scope.getCountry = function () {
            return new Promise(function (resolve,reject) {
                baseDataService.getCountry(function(res){
                    $scope.countryOptions = res.data;
                    $scope.countryOptions.unshift({
                        name:'全部'
                    });
                    resolve();
                });
            })
        };
        $scope.getProvince = function () {
            return new Promise(function (resolve,reject) {
                baseDataService.getProvince(function(res){
                    if(res.data){
                        $scope.provinceOptions = res.data;
                        $scope.provinceOptions.unshift({
                            province:'全部'
                        });
                        resolve();
                    }
                });
            })
        };
        $scope.getCategoryLibrarys = function () {
            return new Promise(function (resolve,reject) {
                baseDataService.getCategoryLibrarys({'categoryType':1},function(res){
                    $scope.bizCategoryOptions = res.data;
                    $scope.bizCategoryOptions.unshift({
                        categoryName:'全部'
                    });
                    resolve();
                });
            })
        };
        
        $scope.init=function(){
            $scope.fieldName='productCode';
            Promise.all([$scope.getCarBrand(),$scope.getCountry(),$scope.getProvince(),$scope.getCategoryLibrarys()]).then(function (result) {
                if ($scope.productViewParamStorage) {
                    var productInfo = $scope.productViewParamStorage.condition;
                    if(productInfo.procuctModel){
                        $scope.serchInfo.procuctModel = productInfo.procuctModel
                    }
                    if(productInfo.brandName){
                        $scope.serchInfo.brandName = productInfo.brandName
                    }
                    if(productInfo.fieldName && productInfo[productInfo.fieldName]){
                        $scope.fieldName = productInfo.fieldName;
                        $scope.fieldText = productInfo[productInfo.fieldName];
                    }
                    if(productInfo.categoryCode){
                        $scope.serchInfo.categoryCode = productInfo.categoryCode
                    }
                    if(productInfo.countryId){
                        for(var i in $scope.countryOptions){
                            if(productInfo.countryId == $scope.countryOptions[i].id){
                                $scope.serchInfo.countryId = $scope.countryOptions[i];
                                break;
                            }
                        }
                    }
                    if(productInfo.provinceId){
                        for(var i in $scope.provinceOptions){
                            if(productInfo.provinceId == $scope.provinceOptions[i].pid){
                                $scope.serchInfo.provinceId = $scope.provinceOptions[i];
                                break;
                            }
                        }
                        $scope.changeProvince(productInfo.provinceId).then(function () {
                            console.log($scope.cityOptions);
                            if(productInfo.cityId){
                                for(var i in $scope.cityOptions){
                                    if(productInfo.cityId == $scope.cityOptions[i].cid){
                                        $scope.serchInfo.cityId = $scope.cityOptions[i];
                                        break;
                                    }
                                }
                            }
                        })
                    }
                    if(productInfo.bizCategoryCode){
                        for(var i in $scope.bizCategoryOptions){
                            if(productInfo.bizCategoryCode == $scope.bizCategoryOptions[i].code){
                                $scope.serchInfo.bizCategoryCode = $scope.bizCategoryOptions[i];
                                break;
                            }
                        }
                    }
                    if(productInfo.bizCategoryCode){
                        for(var i in $scope.bizCategoryOptions){
                            if(productInfo.bizCategoryCode == $scope.bizCategoryOptions[i].code){
                                $scope.serchInfo.bizCategoryCode = $scope.bizCategoryOptions[i];
                                break;
                            }
                        }
                        $scope.changeCategory(1,productInfo.bizCategoryCode).then(function () {
                            if(productInfo.bigCategoryCode){
                                for(var i in $scope.bigCategoryOptions){
                                    if(productInfo.bigCategoryCode == $scope.bigCategoryOptions[i].code){
                                        $scope.serchInfo.bigCategoryCode = $scope.bigCategoryOptions[i];
                                        break;
                                    }
                                }
                                $scope.changeCategory(2,productInfo.bizCategoryCode + productInfo.bigCategoryCode).then(function () {
                                    if(productInfo.productCategoryCode){
                                        for(var i in $scope.productCategoryOptions){
                                            if(productInfo.productCategoryCode == $scope.productCategoryOptions[i].code){
                                                $scope.serchInfo.productCategoryCode = $scope.productCategoryOptions[i];
                                                break;
                                            }
                                        }
                                        $scope.changeCategory(3,productInfo.bizCategoryCode + productInfo.bigCategoryCode + productInfo.productCategoryCode).then(function () {
                                            if(productInfo.subCategoryCode){
                                                for(var i in $scope.subCategoryOptions){
                                                    if(productInfo.subCategoryCode == $scope.subCategoryOptions[i].categoryCode){
                                                        $scope.serchInfo.subCategoryCode = $scope.subCategoryOptions[i];
                                                        break;
                                                    }
                                                }
                                            }
                                        })
                                    }
                                })
                            }
                        })
                    }

                    if(productInfo.carBrandId){
                        for(var i in $scope.carBrandOptions){
                            if(productInfo.carBrandId == $scope.carBrandOptions[i].id){
                                $scope.serchInfo.carBrand = $scope.carBrandOptions[i];
                                break;
                            }
                        }
                        $scope.changeCarBrand(productInfo.carBrandId).then(function () {
                            if(productInfo.carSmallBrandId){
                                for(var i in $scope.carSmallBrandOptions){
                                    if(productInfo.carSmallBrandId == $scope.carSmallBrandOptions[i].id){
                                        $scope.serchInfo.carSmallBrand = $scope.carSmallBrandOptions[i];
                                        break;
                                    }
                                }
                                $scope.changeCarSmallBrand(productInfo.carSmallBrandId).then(function () {
                                    if(productInfo.carSeriesId){
                                        for(var i in $scope.carSeriesOptions){
                                            if(productInfo.carSeriesId == $scope.carSeriesOptions[i].id){
                                                $scope.serchInfo.carSeries = $scope.carSeriesOptions[i];
                                                break;
                                            }
                                        }
                                    }
                                })
                            }
                        })
                    }
                    if(productInfo.hasComplain != null){
                        for(var i in $scope.complainOptions){
                            if(productInfo.hasComplain == $scope.complainOptions[i].id){
                                $scope.serchInfo.hasComplain = $scope.complainOptions[i];
                                break;
                            }
                        }
                    }
                    var pageSizeSelect = $('#productView select option');
                    if(pageSizeSelect[0].value != $scope.productViewParamStorage.pageSize){
                        pageSizeSelect.each(function () {
                            if($(this).val() == $scope.productViewParamStorage.pageSize){
                                $(this).attr("selected","selected");
                            }
                        });
                        pageSizeSelect.change();
                    }
                    setTimeout(function () {
                        $("#productView .paginate_input").val($scope.productViewParamStorage.pageNum);
                        $rootScope.PressKey(13, $("#productView .paginate_input")[0]);
                        window.scrollTo($scope.productViewParamStorage.scrollLeft,$scope.productViewParamStorage.scrollTop);
                        $scope.productViewParamStorage = '';
                    }, $scope.productViewParamStorage.pageSize * 18);
                }
            })
        };

        $scope.init();
    }

    function productManagerOperateCtrl($scope, $uibModalInstance, productService, params, dtInstance, queryParams){
        $scope.message = params.message;
        $scope.confirm = function(queryParams) {
            $scope.isWorking = true;
            productService.changeStatus(params, function(result){
                if(result.returnCode == '0'){
                    $uibModalInstance.close();
                    swal({type: 'success',title: '',text: result.message,closeOnConfirm: false,confirmButtonText: "确定",timer: 3000});
                    dtInstance.query();
                }else{
                    $uibModalInstance.close();
                    swal({type: 'error',title: '',text: result.message,closeOnConfirm: false,confirmButtonText: "确定",timer: 3000 });
                }
                $scope.isWorking = false;
            });

        };
        $scope.cancel = function() {
            $uibModalInstance.dismiss('cancel');
            dtInstance.query();
        };
    }

    function productManagerAuditCtrl($scope, $uibModalInstance, productService, params, dtInstance, queryParams){
        $scope.auditSelect = '4';
        $scope.confirm = function(queryParams) {
            $scope.isWorking = true;
            params.status = $scope.auditSelect;
            params.auditReason = $scope.auditReason;
            productService.changeStatus(params, function(result){
                if(result.returnCode == '0'){
                    $uibModalInstance.close();
                    swal({type: 'success',title: '',text: result.message,closeOnConfirm: false,confirmButtonText: "确定",timer: 3000});
                    dtInstance.query();
                }else{
                    $uibModalInstance.close();
                    swal({type: 'error',title: '',text: result.message,closeOnConfirm: false,confirmButtonText: "确定",timer: 3000 });
                }
                $scope.isWorking = false;
            });

        };
        $scope.cancel = function() {
            $uibModalInstance.dismiss('cancel');
            dtInstance.query();
        };
    }
    angular.module('electronicDirectory').controller('productViewCtrl', productViewCtrl)
        .controller('productManagerOperateCtrl', productManagerOperateCtrl)
        .controller('productManagerAuditCtrl', productManagerAuditCtrl);
})(angular);