productUpdateCtrl.js 28.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
(function (angular) {
    function productUpdateCtrl($scope, productService, baseDataService, supplierService, $stateParams, $state, $http, $sce, $filter) {
        $scope.productId = $stateParams.id;
        $scope.type = $stateParams.type;
        $scope.carBrandOptions_copy = []
        $scope.ueditorConfig = {
            initialFrameHeight: 320
        }
        $scope.saveProductInfo = function () {
            //console.log(UE.getEditor('description').getContent());
            var formInfo = $scope.productForm;
            if (formInfo.$invalid) {
                $scope.isInValidate = true;
                return false;
            }
            ;
            $scope.submitUpdate();
        };
        $scope.backClickEvent = function () {
            $state.go('electronicDirectory.productDetail', {id: $scope.productId, type: $scope.type});
        };
        $scope.selectUserDefinedVal = function (parentIndex, index) {
            if ($scope.userDefinedOptions[parentIndex].attrValList[index].selected) {
                $scope.userDefinedOptions[parentIndex].attrValList[index].selected = false;
                var hasOneSelect = false;
                for (var i = 0; i < $scope.userDefinedOptions[parentIndex].attrValList.length; i++) {
                    if ($scope.userDefinedOptions[parentIndex].attrValList[i].selected) {
                        hasOneSelect = true;
                        break;
                    }
                }
                console.log(hasOneSelect)
                $scope.userDefinedOptions[parentIndex].hasOneSelect = hasOneSelect;
            } else {
                $scope.userDefinedOptions[parentIndex].attrValList[index].selected = true;
                $scope.userDefinedOptions[parentIndex].hasOneSelect = true;
            }
        };
        $scope.submitUpdate = function () {
            if (!$scope.productInfo.productImg) {
                $scope.isInValidate = true;
                return;
            }
            var params = {};
            if ($scope.productId) {
                params.id = $scope.productId;
            }
            if ($scope.productInfo.productCode) {
                params.productCode = $scope.productInfo.productCode;
            }

            if ($scope.productInfo.productName) {
                params.productName = $scope.productInfo.productName;
            }

            if ($scope.productInfo.procuctModel) {
                params.procuctModel = $scope.productInfo.procuctModel;
            }

            if ($scope.productInfo.supplierCode.supplierCode) {
                params.supplierCode = $scope.productInfo.supplierCode.supplierCode;
            }

            if ($scope.productInfo.brandId) {
                params.brandId = $scope.productInfo.brandId.id;
            }

            if ($scope.productInfo.brandId) {
                params.brandName = $scope.productInfo.brandId.brandName;
            }
            if ($scope.productInfo.countryId) {
                params.countryId = $scope.productInfo.countryId.id;
                params.countryName = $scope.productInfo.countryId.name;
                params.provinceId = -1;
                params.provinceName = '';
                params.cityId = -1;
                params.cityName = '';
                if ($scope.productInfo.countryId.code == 37) {//表示中国
                    if ($scope.productInfo.provinceId) {
                        params.provinceId = $scope.productInfo.provinceId.pid;
                        params.provinceName = $scope.productInfo.provinceId.province;
                    }
                    if ($scope.productInfo.cityId) {
                        params.cityId = $scope.productInfo.cityId.cityCode;
                        params.cityName = $scope.productInfo.cityId.city;
                    }
                }
            }

            if ($scope.productInfo.productImg) {
                params.productImg = $scope.productInfo.productImg;
            }

            if ($scope.productInfo.minQuantity) {
                params.minQuantity = $scope.productInfo.minQuantity;
            }

            if ($scope.productInfo.qualityPeriod) {
                params.qualityPeriod = $scope.productInfo.qualityPeriod;
            }
            if ($scope.productInfo.specification) {
                params.specification = $scope.productInfo.specification;
            }
            if ($scope.productInfo.unit) {
                params.unit = $scope.productInfo.unit;
            }
            params.description = UE.getEditor('description').getContent();
            params.userDefinedList = [];
            console.log($scope.userDefinedOptions);
            for (var i = 0; i < $scope.userDefinedOptions.length; i++) {
                var attr = $scope.userDefinedOptions[i];
                if (attr.attrType == 1 && attr.productAttrValList) {//文本属性
                    params.userDefinedList.push({
                        'categoryAttrId': attr.id,
                        'valueType': 0,//自定义属性
                        'attrId': 0,
                        'attrValId': 0,
                        'attrValName': attr.productAttrValList[0].attrValName
                    });
                } else if (attr.attrType == 2) {//2选项属性
                    var hasNotSelect = true;
                    for (var j = 0; j < attr.attrValList.length; j++) {
                        var attrVal = attr.attrValList[j];
                        if (attrVal.selected) {
                            hasNotSelect = false;
                            params.userDefinedList.push({
                                'categoryAttrId': attr.id,
                                'valueType': 0,//自定义属性
                                'attrId': attrVal.attrId,
                                'attrValId': attrVal.attrValId,
                                'attrValName': attrVal.attrValName
                            });
                        }
                    }
                    /*if(hasNotSelect){
                     $scope.isInValidate = true;
                     return;
                     }*/
                }
            }
            if ($scope.carSelectType == 1) {//车型全部适用
                params.userDefinedList.push({
                    'categoryAttrId': 0,
                    'valueType': 1,//车品牌
                    'attrId': 0,
                    'attrValId': -1,
                    'attrValName': '全部适用'
                });
                params.userDefinedList.push({
                    'categoryAttrId': 0,
                    'valueType': 2,//车系
                    'attrId': 0,
                    'attrValId': -1,
                    'attrValName': '全部适用'
                });
                params.userDefinedList.push({
                    'categoryAttrId': 0,
                    'valueType': 5,//车子品牌
                    'attrId': 0,
                    'attrValId': -1,
                    'attrValName': '全部适用'
                });
            } else {
                $scope.addCarSeries();
                //    			if(!$scope.selectCarSeriesArr || $scope.selectCarSeriesArr.length == 0){
                //    				$scope.isInValidate = true;
                //    				return;
                //    			}

                angular.forEach($scope.selectCarBrandArr, function (carBrand) {
                    params.userDefinedList.push({
                        'categoryAttrId': 0,
                        'valueType': 1,//车品牌
                        'attrId': 0,
                        'attrValId': carBrand.id,
                        'attrValName': carBrand.name
                    });
                });
                angular.forEach($scope.selectCarSmallBrandArr, function (carSmallBrand) {
                    params.userDefinedList.push({
                        'categoryAttrId': 0,
                        'valueType': 5,//车子品牌
                        'attrId': 0,
                        'attrValId': carSmallBrand.id,
                        'attrValName': carSmallBrand.name,
                        'parentAttrValId': carSmallBrand.brandId
                    });
                });
                angular.forEach($scope.selectCarSeriesArr, function (carSeries) {
                    params.userDefinedList.push({
                        'categoryAttrId': 0,
                        'valueType': 2,//车系
                        'attrId': 0,
                        'attrValId': carSeries.id,
                        'attrValName': carSeries.name,
                        'parentAttrValId': carSeries.brandId
                    });
                });
            }
            console.log("到当前");
            productService.update(params, function (res) {
                if (res.returnCode == 0) {
                    swal({
                        type: 'success',
                        title: '',
                        text: res.message || '操作成功',
                        showConfirmButton: false,
                        timer: 1500
                    }, function () {
                        window.sweetAlert.close();
                        $scope.backClickEvent();
                    });
                } else {
                    swal({type: 'error', title: '', text: res.message || '操作失败', timer: 1500}, function () {
                        window.sweetAlert.close();
                    });
                }
            });
        };
        /**
         * 选择上传文件
         * */
        $scope.choseUploadFile = function (file) {
            if ($(file).val()) {
                $scope.uploadFileName = $(file).val();
                $scope.$apply();
                $scope.sendUploadFile();
            }
            ;
        };

        $scope.sendUploadFile = function () {
            var fileName = $scope.uploadFileName;
            var b = '';
            if (fileName) {
                var a = fileName.split('.');
                b = a[a.length - 1];
            }
            $scope.showLoadingImg = true;
            $http({
                url: 'common/uploadImage',
                method: 'POST',
                headers: {
                    'Content-Type': undefined
                },
                transformRequest: function () {
                    var formData = new FormData();
                    formData.append('file', $('#upfile')[0].files[0]);
                    return formData;
                }
            }).success(function (res) {
                $scope.showValidate = false;
                $scope.showLoadingImg = false;
                console.log("上传结果" + res.returnCode);
                if (res.returnCode == 0) {
                    $scope.productInfo.productImg = res.data;
                } else {
                    swal({
                        type: 'error',
                        title: '',
                        text: res.message || '操作失败',
                        showConfirmButton: false,
                        timer: 1500
                    }, function () {
                        swal.close();
                    });
                }
                ;
            });

        };

        $scope.getProductById = function () {
            return new Promise(function (resolve, reject) {
                productService.getProductById({'id': $scope.productId}, function (res) {
                    $scope.productInfo = res.data;
                    $scope.userDefinedOptions = $scope.productInfo.attrList;
                    angular.forEach($scope.userDefinedOptions, function (i) {
                        angular.forEach(i.attrValList, function (j) {
                            angular.forEach(i.productAttrValList, function (k) {
                                if (k.attrValId == j.attrValId) {
                                    j.selected = true;
                                    i.hasOneSelect = true;
                                }
                            });
                        });
                    });
                    $scope.getSupplier().then(function () {
                        for (var i = 0; i < $scope.supplierOptions.length; i++) {
                            if ($scope.supplierOptions[i].supplierCode == $scope.productInfo.supplierCode) {
                                $scope.productInfo.supplierCode = $scope.supplierOptions[i];
                                break;
                            }
                        }
                    });
                    $scope.getBrandBySupplierCode($scope.productInfo.supplierCode).then(function () {
                        angular.forEach($scope.brandOptions, function (k) {
                            if (k.id == $scope.productInfo.brandId) {
                                $scope.productInfo.brandId = k;
                            }
                        });
                    });
                    if (!$scope.productInfo.countryId) {
                        $scope.productInfo.countryId = 37;//默认中国
                    }
                    for (var i = 0; i < $scope.countryOptions.length; i++) {
                        if ($scope.countryOptions[i].id == $scope.productInfo.countryId) {
                            $scope.productInfo.countryId = $scope.countryOptions[i];
                            break;
                        }
                    }

                    for (var i = 0; i < $scope.provinceOptions.length; i++) {
                        if ($scope.provinceOptions[i].pid == $scope.productInfo.provinceId) {
                            $scope.productInfo.provinceId = $scope.provinceOptions[i];
                            var cityId = $scope.productInfo.cityId;
                            $scope.getCityByProvinceId($scope.productInfo.provinceId.pid).then(function () {
                                for(var j = 0; j < $scope.cityOptions.length; j++){
                                    if($scope.cityOptions[j].cityCode == cityId){
                                        $scope.productInfo.cityId = $scope.cityOptions[j];
                                        break;
                                    }
                                }
                            });
                            break;
                        }
                    }
                    if ($scope.productInfo.carSeriesList && $scope.productInfo.carSeriesList[0] && $scope.productInfo.carSeriesList[0].attrValId != -1) {
                        $scope.carSelectType = 2;
                        angular.forEach($scope.productInfo.carSeriesList, function (k) {
                            $scope.selectCarSeriesArr.push({
                                'brandId': k.parentAttrValId,
                                'id': k.attrValId,
                                'name': k.attrValName
                            });
                        });
                    }

                    if ($scope.productInfo.carChildBrandList && $scope.productInfo.carChildBrandList[0] && $scope.productInfo.carChildBrandList[0].attrValId != -1) {
                        $scope.carSelectType = 2;
                        angular.forEach($scope.productInfo.carChildBrandList, function (k) {
                            $scope.selectCarSmallBrandArr.push({
                                'brandId': k.parentAttrValId,
                                'id': k.attrValId,
                                'name': k.attrValName
                            });
                        });
                    }

                    if ($scope.productInfo.carBrandList && $scope.productInfo.carBrandList.length) {
                        angular.forEach($scope.productInfo.carBrandList, function (i) {
                            angular.forEach($scope.carBrandOptions, function (j, index) {
                                if (i.attrValId == j.id) {
                                    j.checked = true;
                                    $scope.selectCarBrandArr.push({'id': j.id, 'name': j.name});
                                    $scope.getSmallBrandByBrandId(j.id, index);
                                }
                            });
                        });
                    }

                    resolve();
                });
            });

        };

        $scope.selectSupplier = function (val) {
            $scope.productInfo.brandId = '';
            $scope.brandOptions = '';
            $scope.getBrandBySupplierCode(val.supplierCode);
        };
        $scope.getCarBrand = function () {
            return new Promise(function (resolve, reject) {
                baseDataService.getCarBrand(function (res) {
                    $scope.carBrandOptions = res.data
                    $scope.carBrandOptions_copy = res.data
                    resolve();
                });
            });
        };
        $scope.chosenSelect = function (index) {
            $scope.selectCarSeriesArr[index].selected = !$scope.selectCarSeriesArr[index].selected;
        }
        $scope.deleteChosen = function () {
            var selectCarSeriesArr = [];
            angular.forEach($scope.selectCarSeriesArr, function (item) {
                if (!item.selected) {
                    selectCarSeriesArr.push(item);
                }
            });
            $scope.selectCarSeriesArr = selectCarSeriesArr;
        }

        $scope.addCarSeries = function () {
            var selectCarBrandArr = [];
            var selectCarSmallBrandArr = [];
            var selectCarSeriesArr = [];
            var carBrandSelectItems = $filter('filter')($scope.carBrandOptions, {checked: true}, true);
            angular.forEach(carBrandSelectItems, function (k) {
                selectCarBrandArr.push({'id': k.id, 'name': k.name});

                var carSmallBrandSelectItems = $filter('filter')(k.childs1, {checked: true}, true);
                angular.forEach(carSmallBrandSelectItems, function (e) {
                    selectCarSmallBrandArr.push({'brandId': k.id, 'id': e.id, 'name': e.name});

                    var carSeriesSelectItems = $filter('filter')(e.childs, {checked: true}, true);
                    angular.forEach(carSeriesSelectItems, function (s) {
                        selectCarSeriesArr.push({'brandId': e.id, 'id': s.id, 'name': s.name});
                    });
                });
            });
            $scope.selectCarBrandArr = selectCarBrandArr;
            $scope.selectCarSmallBrandArr = selectCarSmallBrandArr;
            $scope.selectCarSeriesArr = selectCarSeriesArr;
        };

        $scope.toggleCarBrand = function (index, type) {
            console.log("传入的参数:" + "index : " + index + " type : " + type);
            if (type == 2) {
                $scope.carBrandOptions[index].toggle = !$scope.carBrandOptions[index].toggle;
            }
            console.log($scope.carBrandOptions[index].carSeresList_copy)
            if (!$scope.carBrandOptions[index].carSeresList_copy) {
                $scope.carBrandOptions[index].childs1 = $scope.carBrandOptions[index].childs;
                $scope.carBrandOptions[index].carSeresList_copy = $scope.carBrandOptions[index].childs;
                angular.element(`#search-${index}`)[0].addEventListener('input', function (val) {
                    var value = val.target.value;
                    $scope.carBrandOptions[index].childs1 = [];
                    $scope.carBrandOptions[index].carSeresList_copy.forEach(function (el) {
                        if (el.name.indexOf(value) !== -1) {
                            $scope.carBrandOptions[index].childs1.push(el)
                        }
                        $scope.$apply();
                    })
                })
                if (type == 1) {
                    angular.forEach($scope.carBrandOptions[index].childs1, function (k) {
                        k.checked = $scope.carBrandOptions[index].checked;
                        angular.forEach(k.childs, function (e) {
                            e.checked = k.checked;
                        });
                    });
                }
            } else {
                if (type == 1) {
                    angular.forEach($scope.carBrandOptions[index].childs1, function (k) {
                        k.checked = $scope.carBrandOptions[index].checked;
                        angular.forEach(k.childs, function (e) {
                            e.checked = k.checked;
                        });
                    });
                }
                if (type == 3) {
                    var ifOneChecked = false;
                    for (var i = 0; i < $scope.carBrandOptions[index].childs1.length; i++) {
                        if ($scope.carBrandOptions[index].childs1[i].checked) {
                            ifOneChecked = true;
                            angular.forEach($scope.carBrandOptions[index].childs1[i].childs, function (k) {
                                k.checked = $scope.carBrandOptions[index].childs1[i].checked;
                            });
                            break;
                        } else {
                            angular.forEach($scope.carBrandOptions[index].childs1[i].childs, function (k) {
                                k.checked = $scope.carBrandOptions[index].childs1[i].checked;
                            });
                        }
                    }
                    if (ifOneChecked) {
                        $scope.carBrandOptions[index].checked = true;
                    } else {
                        $scope.carBrandOptions[index].checked = false;
                    }
                }
            }
        }

        $scope.toggleSmallCarBrand = function (pIndex, index, type) {
            console.log("传入的参数:" + "车品牌index : " + pIndex + "车子品牌index : " + index + " type : " + type);
            if (type == 4) {
                $scope.carBrandOptions[pIndex].childs1[index].toggle = !$scope.carBrandOptions[pIndex].childs1[index].toggle;
            }
            if (!$scope.carBrandOptions[pIndex].childs1[index].carSeriesList_copy) {
                $scope.carBrandOptions[pIndex].childs1[index].carSeriesList_copy = $scope.carBrandOptions[pIndex].childs1[index].childs;
                angular.element(`#search1-${index}`)[0].addEventListener('input', function (val) {
                    var value = val.target.value
                    $scope.carBrandOptions[pIndex].childs1[index].childs = [];
                    $scope.carBrandOptions[pIndex].childs1[index].carSeriesList_copy.forEach(function (el) {
                        console.log(el.name);
                        if (el.name.indexOf(value) !== -1) {
                            $scope.carBrandOptions[pIndex].childs1[index].childs.push(el)
                        }
                        $scope.$apply();
                    })
                })
            } else {
                if (type == 5) {
                    var ifOneChecked = false;
                    for (var i = 0; i < $scope.carBrandOptions[pIndex].childs1[index].childs.length; i++) {
                        if ($scope.carBrandOptions[pIndex].childs1[index].childs[i].checked) {
                            ifOneChecked = true;
                            break;
                        }
                    }
                    if (ifOneChecked) {
                        $scope.carBrandOptions[pIndex].checked = true;
                        $scope.carBrandOptions[pIndex].childs1[index].checked = true;
                    } else {
                        var parentChecked = false;
                        $scope.carBrandOptions[pIndex].childs1[index].checked = false;
                        for (var i = 0; i < $scope.carBrandOptions[pIndex].childs1.length; i++) {
                            if ($scope.carBrandOptions[pIndex].childs1[i].checked) {
                                parentChecked = true;
                                break;
                            }
                        }
                        if (!parentChecked) {
                            $scope.carBrandOptions[pIndex].checked = false;
                        }
                    }
                }
            }
        }

        $scope.getCarSeriesByBrandId = function (index, index1) {
            return new Promise(function (resolve, reject) {
                angular.forEach($scope.selectCarSeriesArr, function (i) {
                    angular.forEach($scope.carBrandOptions[index].childs1[index1].childs, function (j) {
                        if (i.id == j.id) {
                            j.checked = true;
                        }
                    });
                });
                resolve();
            });
        };

        $scope.getSmallBrandByBrandId = function (carBrandId, index) {
            return new Promise(function (resolve, reject) {
                $scope.carBrandOptions[index].childs1 = $scope.carBrandOptions[index].childs;
                $scope.carBrandOptions[index].carSeresList_copy = $scope.carBrandOptions[index].childs;
                angular.forEach($scope.selectCarSmallBrandArr, function (i) {
                    angular.forEach($scope.carBrandOptions[index].childs1, function (j, index1) {
                        if (i.id == j.id) {
                            j.checked = true;
                            $scope.getCarSeriesByBrandId(index, index1);
                        }
                    });
                });
                resolve();
            });
        };

        $scope.changeProvince = function (provinceId) {
            $scope.cityOptions = '';
            $scope.productInfo.cityId = '';
            $scope.getCityByProvinceId(provinceId)
        };
        $scope.getCityByProvinceId = function (provinceId) {
            return new Promise(function (resolve, reject) {
                baseDataService.getCityByProvinceId({provinceId: provinceId}, function (res) {
                    $scope.cityOptions = res.data;
                    resolve();
                });
            });
        };
        $scope.getProvince = function () {
            return new Promise(function (resolve, reject) {
                baseDataService.getProvince(function (res) {
                    $scope.provinceOptions = res.data;
                    resolve();
                });
            });
        };
        $scope.getCountry = function () {
            return new Promise(function (resolve, reject) {
                baseDataService.getCountry(function (res) {
                    $scope.countryOptions = res.data;
                    resolve();
                });
            });
        };
        $scope.getSupplier = function () {
            return new Promise(function (resolve, reject) {
                supplierService.getSupplier(function (res) {
                    $scope.supplierOptions = res.data;
                    resolve();
                });
            });
        };
        $scope.getBrandBySupplierCode = function (supplierCode) {
            return new Promise(function (resolve, reject) {
                var obj = {
                    condition:{
                        supplierCode:supplierCode
                    }
                };
                supplierService.listBrand(obj, function (res) {
                    $scope.brandOptions = res.data.list;
                    resolve();
                });
            });
        };
        $scope.searchCar = '';
        $scope.$watch('searchCar', function (newValue) {
            $scope.carBrandOptions = [];
            $scope.carBrandOptions_copy.forEach(function (el) {
                if (el.name.indexOf(newValue) !== -1) {
                    $scope.carBrandOptions.push(el)
                }
            })
        })

        $scope.init = function () {
            $scope.selectCarBrandArr = [];
            $scope.selectCarSmallBrandArr = [];
            $scope.selectCarSeriesArr = [];
            $scope.carSelectType = 1;
            Promise.all([$scope.getCountry(),$scope.getProvince(),$scope.getCarBrand()]).then(function () {
                $scope.getProductById().then(function () {
                    UE.delEditor('description');
                    var ue = UE.getEditor('description', {
                        initialFrameHeight: 320
                    });
                    ue.addListener("ready", function () {
                        if($scope.productInfo.description){
                            ue.setContent($scope.productInfo.description);
                        }
                    });
                });
            })
        };
        $scope.init();
    }

    angular.module('electronicDirectory', ['ng.ueditor'])
        .controller('productUpdateCtrl', productUpdateCtrl);
})(angular);