cusAddCtrl.js 26.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
(function (angular) {
    function cusAddCtrl($scope, $rootScope, Utils, $stateParams, $state, qualityUpgradeService, carMsgService, $uibModal, SweetAlertX) {
        $scope.loginUser = $rootScope.loginUser
        console.log($scope.loginUser);
        $scope.isSuper = $rootScope.loginUser.isSuper
        $scope.detail = JSON.parse(sessionStorage.getItem('detail'));
        $scope.model = {newCarFlag:'Y'};

        //选中的标签和推荐人
        $scope.activeTarget = '';
        $scope.choosePeople = null;

        $scope.carBrandOptions = []
        $scope.carSmallBrandOptions = []

        $scope.selected = [];

        
        //获取园区店
        function listYqMerchantList() {
            return new Promise(function (resolve, reject) {
                qualityUpgradeService.listYqMerchantList(function (res) {
                    $scope.sellerMerchantList = res.data;
                    resolve();
                    // if($scope.detail){
                    //     $scope.model.sellerMerchant = $scope.detail.sellerMerchantId + ''
                    // }
                });
            })
        }

        //获取园区店的服务门店列表
       $scope.changeSellerMerchant = function (merchantId) {
            if(!$scope.model.sellerMerchant){
            return;
            }
            $scope.sellerUserList = []
            $scope.baseGoodsList = []
            $scope.selected = []
            $scope.model.employee = null
            return new Promise(function (resolve, reject) {
                /**流量来源 */
                qualityUpgradeService.listMerchantList({'yqMerchantId': $scope.model.sellerMerchant},function (res) {
                    $scope.merchantList = res.data;
                    if(merchantId){
                        $scope.model.merchant = merchantId + ''
                    }else{
                        $scope.model.merchant = ''
                    }
                    // $scope.merchantList.unshift({merchantId:'',merchantName:'请选择'})
                    resolve();
                });

                /**查找预录员列表 */
                // qualityUpgradeService.listByMerchantId({'merchantId':  $scope.model.sellerMerchant},function (res) {
                //     $scope.prerecordedUserList = res.data;
                //     // $scope.prerecordedUserList = [{id:1,name:'111'},{id:2,name:'222555555555555555555555555555555555555555555555555555'},{id:3,name:'333'},{id:4,name:'444'},{id:5,name:'555'},{id:6,name:'666'},{id:7,name:'777'},{id:8,name:'888'},{id:9,name:'96666666666666666666666666666699'},{id:10,name:'1010'},{id:11,name:'1111'},{id:12,name:'1212'},{id:13,name:'1313'},{id:14,name:'1414'},{id:15,name:'1515'},{id:16,name:'1616'},{id:17,name:'1717'},{id:18,name:'1818'},{id:19,name:'1919'},{id:20,name:'2020'}];
                //     if($scope.prerecordedUserList && $scope.prerecordedUserList.length > 0){
                //         $scope.prerecordedTips = {show:false,message:'请检查是否配置预录员工名片!'};
                //     }else{
                //         $scope.prerecordedTips = {show:true,message:'请检查是否配置预录员工名片!'};
                //     }
                //     resolve();
                // });
            })
        }

      //选去流量来源时加载基础商品和推荐人下拉框数据
      $scope.getGoodsAndEmployee = function (merchantId) {
         if(!merchantId && !$scope.model.merchant){
           return;
         }

         $scope.sellerUserList = []
         $scope.baseGoodsList = []
         $scope.selected = []
         $scope.model.employee = null
         return new Promise(function (resolve, reject) {
             /**查找基础商品列表 */
             qualityUpgradeService.listBaseGoods({'merchantId': merchantId?merchantId:$scope.model.merchant },function (res) {
                 $scope.baseGoodsList = res.data;
                //   $scope.baseGoodsList = [{goodsInfo:{goodsName:'111111111111111111111111111111111111111111111',goodsCode:'code11111111111111',goodsTypeName:'类型11111111111111111111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}},{goodsInfo:{goodsName:'111',goodsCode:'code111',goodsTypeName:'类型111',thumbUrl:'http://qcimg01.glsx.net/dj-smartcarlife-img/20201116144824263298c29bc02bc4e31a7673768ae67487e.jpg'}}];
                 if($scope.baseGoodsList && $scope.baseGoodsList.length > 0){
                    $scope.goodsTips = {show:false,message:'该门店无分配商品'};
                 }else{
                    $scope.goodsTips = {show:true,message:'该门店无分配商品'};
                 }
                 resolve();
             });
             /**查找推荐人列表 */
             qualityUpgradeService.listByMerchantId({'merchantId': merchantId?merchantId:$scope.model.merchant  },function (res) {
                 $scope.sellerUserList = res.data;
                //  $scope.sellerUserList = [{id:1,name:'111'},{id:2,name:'222555555555555555555555555555555555555555555555555555'},{id:3,name:'333'},{id:4,name:'444'},{id:5,name:'555'},{id:6,name:'666'},{id:7,name:'777'},{id:8,name:'888'},{id:9,name:'96666666666666666666666666666699'},{id:10,name:'1010'},{id:11,name:'1111'},{id:12,name:'1212'},{id:13,name:'1313'},{id:14,name:'1414'},{id:15,name:'1515'},{id:16,name:'1616'},{id:17,name:'1717'},{id:18,name:'1818'},{id:19,name:'1919'},{id:20,name:'2020'}];
                 if($scope.sellerUserList && $scope.sellerUserList.length > 0){
                    $scope.labelTips = {show:false,message:'请检查是否配置推荐人员工名片!'};
                 }else{
                    $scope.labelTips = {show:true,message:'请检查是否配置推荐人员工名片!'};
                 }
                 resolve();
             });
         })

     }

        /**
         * 标签点击事件
         */
        $scope.tagEvent = function (item, index) {

            $scope.labelTips = {show:false,message:'请选择标签'};

            if($scope.activeTarget == item.name){
                $scope.activeTarget = '';
                $scope.choosePeople = null;
            }else{
                $scope.activeTarget = item.name;
                $scope.choosePeople = item;
            }
            console.log($scope.choosePeople);

        }

        /**
         * 推荐人单选按钮change事件
         */
        $scope.changeEmployee = function (item) {
            console.log(item);
            console.log($scope.model.employee);
            if(item){
                $scope.labelTips = {show:false};
            }
        }

        $scope.updateSelection = function (id) {
            console.log($scope.operStatus)
            $scope.goodsErrTips = {show:false};
            // if($scope.operStatus > 1){//不允许修改值
            //     return
            // }
            if ($scope.selected.indexOf(id) == -1) {
                $scope.selected.push(id);
                return true
            } 
            if($scope.selected.indexOf(id) != -1) {
                var idx = $scope.selected.indexOf(id);
                $scope.selected.splice(idx, 1);
            }
        }
        //判断是在集合$scope.selected里去掉此id,还是加上id
        // $scope.updateSelection = function ($event,id) {
        //     var checkbox = $event.target;
        //     var action = (checkbox.checked ? 'add' : 'remove');
        //     updateSelected(action, id);
        // }
        //设置复选框的选中状态
        $scope.isSelected = function (id) {
            return $scope.selected.indexOf(id) >= 0;
        }

        // 设置默认值
        $scope.model.effectDate = {
            startDate: moment(),
            endDate: moment()
        };
        //交车日期时间选择器
        $scope.takeeffectTimeOptions = {
            format: 'YYYY-MM-DD',
            singleDatePicker: true,
            showDropdowns: true,
            drops: 'up',
            // maxDate: new Date()
        };

        //获取品牌车型
        function getAllVehicleBrand(detail) {
            return new Promise(function (resolve, reject) {
                carMsgService.getAllVehicleBrand(function (res) {
                    $scope.carBrandOptions = res.data;
                    if(detail && detail.carBrandId){//编辑时装值并选中
                        for (var i = 0; i < $scope.carBrandOptions.length; i++) {
                            if ($scope.carBrandOptions[i].id == detail.carBrandId) {
                                $scope.model.carBrand = $scope.carBrandOptions[i];
                                break;
                            }
                        }
                        $scope.changeCarBrand($scope.model.carBrand.id);
                        if ($scope.carBrandOptions) {
                            for (var i = 0; i < $scope.carSmallBrandOptions.length; i++) {
                                if ($scope.carSmallBrandOptions[i].id == detail.carChildsBrandId) {
                                    $scope.model.carSmallBrand = $scope.carSmallBrandOptions[i];
                                    break;
                                }
                            }
                        }
    
                        $scope.changeCarSmallBrand($scope.model.carSmallBrand.id);
                        for (var i = 0; i < $scope.carSeriesOptions.length; i++) {
                            if ($scope.carSeriesOptions[i].id == detail.carSeriesId) {
                                $scope.model.carSeries = $scope.carSeriesOptions[i];
                                break;
                            }
                        }
    
                        // $scope.changeCarSeries($scope.model.carSeries.id).then(function () {
                        //     if (detail.carTypeId) {
                        //         for (var i = 0; i < $scope.carTypes.length; i++) {
                        //             if ($scope.carTypes[i].id == detail.carTypeId) {
                        //                 $scope.model.carType = $scope.carTypes[i];
                        //                 console.log($scope.model.carType);
                        //                 break;
                        //             }
                        //         }
                        //     }
                        // });

                    }
                    resolve();
                });
            })
        }

        //车辆子品牌值改变事件
        $scope.changeCarBrand = function (id) {
            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));
                    break;
                }
            }
            $scope.carSeriesOptions = [];
            $scope.model.carSmallBrand = '';
            $scope.model.carSeries = '';
            $scope.carTypes = [];
            $scope.model.carType = '';
        };

        //车辆车系值改变事件
        $scope.changeCarSmallBrand = function (id) {
            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));
                    break;
                }
            }
            $scope.model.carSeries = '';
            $scope.carTypes = [];
            $scope.model.carType = '';
        };

        //车辆类型值改变事件
        $scope.changeCarSeries = function (id) {
            // $scope.carTypes = '';
            // $scope.model.carType = '';
            // return new Promise(function (resolve, reject) {
            //     carMsgService.getCardType({carSeriesId: id}, function (res) {
            //         if (res.data) {
            //             $scope.carTypes = res.data;
            //             resolve();
            //         }
            //     });
            // })

        };

        // /**
        //  * 特别约定值改变事件
        //  * 获取相应的内容
        //  * @param spid
        //  */
        // $scope.pickSP = function (spid) {
        //     setSpecialContent(spid);
        // };

        //返回
        $scope.backTo = function () {
            $state.go('qualityUpgrade.prerecordedCusManage');
        };

        function getDateString(objField,format) {
        	format = format || 'YYYY-MM-DD HH:mm:ss';
            if (objField) {
                return (typeof objField == 'string') ? objField : objField.format(format);
            } else {
                return '';
            }
        }

        /**
         * 下拉框绑定的值是一个对象,需要获取值
         * @param fieldName
         * @returns {*}
         */
        function getSelectValue(objName, id) {
            var obj = $scope.model[objName];
            return (obj && obj[id]) ? obj[id] : '';
        };

        /**
         * 获取参数(所有查询都从此获取)
         */
        function getSelectParams() {
            var params = {}
            params.carBrandId = getSelectValue('carBrand', 'id');
            params.vehicleBrand = getSelectValue('carBrand', 'name');
            params.carChildsBrandId = getSelectValue('carSmallBrand', 'id');
            params.vehicleChildsBrandName = getSelectValue('carSmallBrand', 'name');
            params.carSeriesId = getSelectValue('carSeries', 'id');
            params.vehicleSeriesName = getSelectValue('carSeries', 'name');
            params.carTypeId = getSelectValue('carType', 'id');
            params.carTypeName = getSelectValue('carType', 'name');
            return params;
        };

        //设置日期信息
        function setDate(obj, filedName, objFieldName) {
            objFieldName = objFieldName || filedName;
            var oField = obj[objFieldName];
            if (oField) {
                $scope.model[filedName] = {
                    startDate: oField,
                    endDate: oField
                };
            }
        }

        //提交
        $scope.handleConfirm = function () {
            var flag = true
            if(!$scope.model.employee){
                $scope.labelTips = {show:true,message:'请选择推荐人!'};
                flag = false
            }else{
                $scope.labelTips = {show:false};
            }
            if($scope.selected && $scope.selected.length > 0){
                $scope.goodsErrTips = {show:false};
            }else{
                $scope.goodsErrTips = {show:true,message:'请选择商品!'};
                flag = false
            }

            if ($scope.cusAddForm.$valid) {
                if(!flag){
                    return
                }
                var obj = {
                    baseGoodsIds: $scope.selected, //基础商品
                    remark: $scope.model.remark   //备注
                };
                var customer = {
                    customerName: $scope.model.cusName,  //客户名称
                    customerPhone: $scope.model.mobile,  //客户电话
                    standNo: $scope.model.standNo        //车架号
                }
                // var item_prerecorded = $scope.prerecordedUserList.find(item => item.userId === $scope.model.prerecorded)
                // var item_prerecorded = null
                // for(var key in $scope.prerecordedUserList){
                //     if($scope.prerecordedUserList[key].userId === $scope.model.prerecorded){
                //         item_prerecorded = $scope.prerecordedUserList[key]
                //     }
                // }

                // var item_employee = $scope.sellerUserList.find(item => item.userId === $scope.model.employee)
                var item_employee = null
                for(var key in $scope.sellerUserList){
                    if($scope.sellerUserList[key].userId === $scope.model.employee){
                        item_employee = $scope.sellerUserList[key]
                    }
                }
                if($scope.isSuper){//如果是超管,传选择的信息
                    obj.sellerMerchantId = $scope.model.sellerMerchant  //预录员所属商户号
                    obj.merchantId = $scope.model.merchant              //门店商户号
                    // obj.sellerUserId = $scope.model.prerecorded      //预录员用户id
                    // obj.sellerName = item_prerecorded.name      //预录员名称
                    obj.userId = $scope.model.employee              //销售顾问用户id
                    obj.employeeName = item_employee.name       //销售顾问用户名
                }else{//不是超管则取登录信息
                    // obj.sellerMerchantId = $scope.loginUser.merchantId
                    obj.merchantId = $scope.model.merchant
                    // obj.sellerUserId = $scope.loginUser.userId
                    // obj.sellerName = $scope.loginUser.accountName
                    obj.userId = $scope.model.employee
                    obj.employeeName = item_employee.name
                }
                if($scope.model.sexType){//性别
                    customer.customerSex = $scope.model.sexType
                }
                if($scope.model.customerType){//客户类型
                    customer.customerType = $scope.model.customerType
                }
                if($scope.model.customerProfession){//客户职业
                    customer.customerProfession = $scope.model.customerProfession
                }
                var selectParams = getSelectParams()
                if($scope.model.carBrand){// 品牌
                    customer.carBrandId = selectParams.carBrandId
                    customer.carBrand = selectParams.vehicleBrand
                }
                if($scope.model.carSmallBrand){// 子品牌
                    customer.carChildsBrandId = selectParams.carChildsBrandId
                    customer.carChildsBrandName = selectParams.vehicleChildsBrandName
                }
                if($scope.model.carSeries){// 车系
                    customer.carSeriesId = selectParams.carSeriesId
                    customer.carSeriesName = selectParams.vehicleSeriesName
                }
                // if($scope.model.carType){// 车型
                //     customer.carTypeId = selectParams.carTypeId
                //     customer.carTypeName = selectParams.carTypeName
                // }
                if($scope.model.carKeyNo){//钥匙号
                    customer.carKeyNo = $scope.model.carKeyNo
                }
                if($scope.model.effectDate){//交车日期
                    customer.buyTimeStr = getDateString($scope.model.effectDate.startDate,'YYYY-MM-DD')
                }
                customer.newCarFlag = $scope.model.newCarFlag //是否新车
                
                obj.customer = customer
                if($scope.detail){
                    obj.customer.customerId = $scope.customerId
                    obj.orderCode = $scope.detail.orderCode
                    qualityUpgradeService.updateOrder(obj,function (data) {
                        if (data.returnCode == '0') {
                            SweetAlertX.alert('编辑成功', '', 'success');
                            $state.go('qualityUpgrade.prerecordedCusManage');
                        } else {
                            SweetAlertX.alert('编辑失败', data.message, 'error');
                        }
                    });
                }else{
                    qualityUpgradeService.createOrder(obj,function (data) {
                        if (data.returnCode == '0') {
                            SweetAlertX.alert('创建成功', '', 'success');
                            $state.go('qualityUpgrade.prerecordedCusManage');
                        } else {
                            SweetAlertX.alert('创建失败', data.message, 'error');
                        }
                    });
                }
            }else {
                $scope.submitted = true;
            }
        };

        (function () {
            console.log($scope.detail);
            if($scope.detail){//编辑
                $scope.operStatus = $scope.detail.operStatus
                $scope.customerId = $scope.detail.customerId
                $scope.model.sellerMerchant = $scope.detail.yqMerchantId + ''
                // $scope.model.prerecorded = $scope.detail.sellerUserId
                $scope.model.merchant = $scope.detail.merchantId + ''
                $scope.changeSellerMerchant($scope.detail.merchantId)
                // $scope.getGoodsAndEmployee($scope.model.merchant)
                // $scope.model.employee = $scope.detail.userId

                $scope.model.cusName = $scope.detail.customerName
                $scope.model.sexType = $scope.detail.customerSex + ''
                $scope.model.mobile = $scope.detail.customerPhone
                $scope.model.customerType = $scope.detail.customerType + ''
                $scope.model.customerProfession = $scope.detail.customerProfession

                if ($scope.detail.carBrandId) {
                    getAllVehicleBrand($scope.detail)
                }else{
                    getAllVehicleBrand()
                }

                $scope.model.standNo = $scope.detail.standNo
                $scope.model.carKeyNo = $scope.detail.carKeyNo
                $scope.model.newCarFlag = $scope.detail.newCarFlag
                $scope.model.effectDate = {
                    startDate: $scope.detail.buyTimeStr,
                    endDate: $scope.detail.buyTimeStr
                };
                // $scope.selected = $scope.detail.baseGoodsIds
                $scope.model.remark = $scope.detail.remark
                
                if($scope.isSuper){
                    listYqMerchantList()
                    $scope.getGoodsAndEmployee($scope.model.merchant)
                    $scope.model.employee = $scope.detail.userId
                    $scope.selected = $scope.detail.baseGoodsIds
                }else{
                    /**流量来源 */
                    $scope.model.merchant = $scope.loginUser.merchantId + ''
                    $scope.merchantList = [{merchantId: $scope.loginUser.merchantId, merchantName: $scope.loginUser.merchantName}];
                    $scope.getGoodsAndEmployee($scope.loginUser.merchantId)
                    $scope.model.employee = $scope.detail.userId
                    $scope.selected = $scope.detail.baseGoodsIds
                }
            }else{
                if($scope.isSuper){
                    listYqMerchantList()
                }else{
                    /**流量来源 */
                    $scope.model.merchant = $scope.loginUser.merchantId + ''
                    $scope.merchantList = [{merchantId: $scope.loginUser.merchantId, merchantName: $scope.loginUser.merchantName}];
                    $scope.getGoodsAndEmployee($scope.loginUser.merchantId)
                }
                getAllVehicleBrand()
            }
            // if($scope.isSuper){ 
            //     listYqMerchantList()
            //     $scope.getGoodsAndEmployee($scope.model.merchant)
            //     $scope.model.employee = $scope.detail.userId
            //     $scope.selected = $scope.detail.baseGoodsIds
            // }else{
            //     /**流量来源 */
            //     $scope.model.merchant = $scope.loginUser.merchantId + ''
            //     $scope.merchantList = [{merchantId: $scope.loginUser.merchantId, merchantName: $scope.loginUser.merchantName}];
            //     $scope.getGoodsAndEmployee($scope.loginUser.merchantId)
            //     $scope.model.employee = $scope.detail.userId
            //     $scope.selected = $scope.detail.baseGoodsIds
            // }
        })();
    }

    angular.module('qualityUpgrade').controller('cusAddCtrl', cusAddCtrl)

})(angular);