|
|
@@ -2187,7 +2187,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
// return;
|
|
|
// }
|
|
|
// 获取当前用户在当前企业是否被转移权限
|
|
|
- AccountUser.getDistribute ({custUU: customer.myEnterprise.uu}, function(data) {
|
|
|
+ AccountUser.getDistribute ({id: customer.id}, function(data) {
|
|
|
customer.enDistribute = data.result;
|
|
|
//是管理员,或者被分配时
|
|
|
if ($scope.enabled || customer.enDistribute) {
|
|
|
@@ -2477,8 +2477,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
}
|
|
|
}]);
|
|
|
|
|
|
- app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', 'type',
|
|
|
- function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService, type) {
|
|
|
+ app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', 'type', 'ngTableParams', 'BaseService',
|
|
|
+ function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService, type, ngTableParams, BaseService) {
|
|
|
AuthenticationService.getAuthentication().success(function (data) {
|
|
|
$scope.thisUser = data;
|
|
|
});
|
|
|
@@ -2491,10 +2491,10 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
urlData = 'findSaleUsers';
|
|
|
uuData = customer.id;
|
|
|
} else {
|
|
|
- params = {uu : customer.myEnterprise.uu};
|
|
|
+ params = {id : customer.id};
|
|
|
urlSaveData = 'addUserToVendor';
|
|
|
urlData = 'findUsers';
|
|
|
- uuData = customer.myEnterprise.uu;
|
|
|
+ uuData = customer.id;
|
|
|
}
|
|
|
|
|
|
$scope.checkboxes = {
|
|
|
@@ -2502,7 +2502,53 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
};
|
|
|
$scope.loading = true;
|
|
|
$scope.distribute = [];
|
|
|
- AccountUser[urlData](params, null, function (data) {
|
|
|
+
|
|
|
+ $scope.userParams = new ngTableParams({ // ng-Table参数
|
|
|
+ page: 1,
|
|
|
+ count: 10,
|
|
|
+ sorting: {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ counts: [5, 10, 15, 25, 50],
|
|
|
+ getData: function ($defer, params) {// 获取数据的方法
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ pageParams.keyword = $scope.keyword;
|
|
|
+ pageParams.id = uuData;
|
|
|
+ AccountUser[urlData].call(null, BaseService.parseParams(pageParams), function (page) {
|
|
|
+ $scope.loading = false;
|
|
|
+ if (page) {
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ $scope.userinfos = page.content;
|
|
|
+ var distribute = [];
|
|
|
+ angular.forEach($scope.userinfos, function (user, index) {
|
|
|
+ if (user.distribute) {
|
|
|
+ distribute.push({num: index});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.distribute = distribute;
|
|
|
+ $scope.havedone = angular.copy($scope.distribute);
|
|
|
+ $scope.total = page.totalElement;
|
|
|
+ params.total(page.totalElement);
|
|
|
+ $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function () {
|
|
|
+ $scope.userParams.page(1);
|
|
|
+ $scope.userParams.reload();
|
|
|
+ $scope.isChanged = false;
|
|
|
+ $scope.isChangedAll = false;
|
|
|
+ };
|
|
|
+
|
|
|
+ /*AccountUser[urlData](params, null, function (data) {
|
|
|
$scope.userinfos = data;
|
|
|
var distribute = [];
|
|
|
angular.forEach($scope.userinfos, function (user, index) {
|
|
|
@@ -2516,8 +2562,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
}, function (res) {
|
|
|
$scope.loading = false;
|
|
|
toaster.pop('error', res.data);
|
|
|
- });
|
|
|
-
|
|
|
+ });*/
|
|
|
var checkStatus = function (userinfos) {
|
|
|
var distribute = [];
|
|
|
angular.forEach(userinfos, function (user, index) {
|
|
|
@@ -2583,19 +2628,20 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
}]);
|
|
|
|
|
|
// 转移权限
|
|
|
- app.controller('TransferUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', 'type', function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService, type) {
|
|
|
+ app.controller('TransferUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', 'type', 'ngTableParams', 'BaseService',
|
|
|
+ function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService, type, ngTableParams, BaseService) {
|
|
|
var urlData, urlSaveData, uuData;
|
|
|
var params = {};
|
|
|
if (type === 'sale') {
|
|
|
params = {id : customer.id};
|
|
|
urlSaveData = 'transferSaleUserToVendor';
|
|
|
urlData = 'findSaleUsers';
|
|
|
- uuData = customer.vendorEnterprise.uu;
|
|
|
+ uuData = customer.id;
|
|
|
} else {
|
|
|
- params = {uu : customer.myEnterprise.uu};
|
|
|
+ params = {id : customer.id};
|
|
|
urlSaveData = 'transferUserToVendor';
|
|
|
urlData = 'findUsers';
|
|
|
- uuData = customer.myEnterprise.uu;
|
|
|
+ uuData = customer.id;
|
|
|
}
|
|
|
|
|
|
AuthenticationService.getAuthentication().success(function (data) {
|
|
|
@@ -2607,7 +2653,58 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
};
|
|
|
$scope.loading = true;
|
|
|
$scope.transfer = [];
|
|
|
- AccountUser[urlData](params, {}, function (data) {
|
|
|
+ $scope.userParams = new ngTableParams({ // ng-Table参数
|
|
|
+ page: 1,
|
|
|
+ count: 10,
|
|
|
+ sorting: {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ counts: [5, 10, 15, 25, 50],
|
|
|
+ getData: function ($defer, params) {// 获取数据的方法
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ pageParams.keyword = $scope.keyword;
|
|
|
+ pageParams.id = uuData;
|
|
|
+ AccountUser[urlData].call(null, BaseService.parseParams(pageParams), function (page) {
|
|
|
+ $scope.loading = false;
|
|
|
+ if (page) {
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ $scope.userinfos = page.content;
|
|
|
+ var transfer = [];
|
|
|
+ angular.forEach($scope.userinfos, function (user, index) {
|
|
|
+ // 当前用户是被管理员转移权限时,转移的是被管理员转移的权限。
|
|
|
+ if ($scope.thisUser.userUU === user.userUU && user.transfer) {
|
|
|
+ $scope.thisUser.transfer = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ angular.forEach($scope.userinfos, function (user, index) {
|
|
|
+ if ($scope.thisUser.sys || $scope.thisUser.transfer) {
|
|
|
+ if (user.transfer) {
|
|
|
+ transfer.push({num: index});
|
|
|
+ user.checked = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (user.distribute) {
|
|
|
+ transfer.push({num: index});
|
|
|
+ user.checked = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.transfer = transfer;
|
|
|
+ $scope.havedone = angular.copy($scope.transfer);
|
|
|
+ $scope.total = page.totalElement;
|
|
|
+ params.total(page.totalElement);
|
|
|
+ $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ /*AccountUser[urlData](params, {}, function (data) {
|
|
|
$scope.userinfos = data;
|
|
|
var transfer = [];
|
|
|
angular.forEach($scope.userinfos, function (user, index) {
|
|
|
@@ -2634,7 +2731,15 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.loading = false;
|
|
|
}, function (res) {
|
|
|
toaster.pop('error', res.data);
|
|
|
- });
|
|
|
+ });*/
|
|
|
+
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function () {
|
|
|
+ $scope.userParams.page(1);
|
|
|
+ $scope.userParams.reload();
|
|
|
+ $scope.isChanged = false;
|
|
|
+ $scope.isChangedAll = false;
|
|
|
+ };
|
|
|
|
|
|
var checkStatus = function (userinfos) {
|
|
|
var transfer = [];
|
|
|
@@ -9522,7 +9627,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.condition = {dateZone: 1};
|
|
|
$scope.currency = Symbol.currency;//将币别转化为对应的符号
|
|
|
$scope.active = 'all';
|
|
|
-
|
|
|
+ $scope.apCheckCondition = {
|
|
|
+ $open: false
|
|
|
+ }
|
|
|
/* 时间筛选初始化*/
|
|
|
var fromDate = new Date();
|
|
|
var toDate = new Date();
|
|
|
@@ -9554,6 +9661,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.tableParams.page(1);
|
|
|
$scope.showNotCheck = false
|
|
|
}
|
|
|
+ $scope.condition.$open = false
|
|
|
+ $scope.apCheckCondition.$open = false
|
|
|
};
|
|
|
$scope.changeDateZone = function (zone) {
|
|
|
$scope.condition.dateZone = zone;
|
|
|
@@ -9585,6 +9694,16 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
pageParams.keyword = $scope.keyword;
|
|
|
if ($scope.active === 'all') {
|
|
|
pageParams.keyword = $scope.keyword
|
|
|
+ var _fromDate = $scope.thisMouthOut + '-01 00:00:00'
|
|
|
+ var _d = new Date(_fromDate)
|
|
|
+ _d.setDate(1)
|
|
|
+ _d.setMonth(_d.getMonth() + 1)
|
|
|
+ _d.setDate(_d.getDate() - 1)
|
|
|
+ var _endDate = _d.getFullYear() + '-' + (_d.getMonth() + 1) + '-' + _d.getDate() + ' 00:00:00'
|
|
|
+ _endDate = new Date(_endDate).getTime()
|
|
|
+ _fromDate = new Date(_fromDate).getTime()
|
|
|
+ pageParams.searchFilter.fromDate = _fromDate
|
|
|
+ pageParams.searchFilter.endDate = _endDate
|
|
|
FaApCheck.customer(BaseService.parseParams(pageParams), function (page) {
|
|
|
$scope.loading = false;
|
|
|
if (page) {
|
|
|
@@ -9746,6 +9865,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
});
|
|
|
modalInstance.result.then(function (customer) {
|
|
|
$scope.suuorname = customer.myEnterprise.enName;
|
|
|
+ $scope.customerUU = customer.myEnterprise.uu;
|
|
|
});
|
|
|
|
|
|
}
|
|
|
@@ -9755,6 +9875,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.chooseItem = item;
|
|
|
$scope.showNotCheck = true
|
|
|
$scope.suuorname = item.myEnterprise.enName
|
|
|
+ $scope.customerUU = item.myEnterprise.uu
|
|
|
this.searchOrder()
|
|
|
}
|
|
|
|
|
|
@@ -9763,6 +9884,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.sdateTo = new Date();
|
|
|
$scope.sdateFrom = new Date($scope.sdateTo.getFullYear(), $scope.sdateTo.getMonth(), 1);
|
|
|
$scope.thisMouth = $scope.sdateTo.getFullYear() +'-'+ ($scope.sdateTo.getMonth())
|
|
|
+ $scope.thisMouthOut = $scope.sdateTo.getFullYear() +'-'+ ($scope.sdateTo.getMonth())
|
|
|
$scope.condition.uuorname = '';
|
|
|
// $scope.condition.dateFrom = '';
|
|
|
// $scope.condition.dateTo = '';
|
|
|
@@ -9773,6 +9895,10 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
|
|
|
$scope.searchOrder = function (check) {
|
|
|
$scope.data = [];
|
|
|
+ $scope.dataInfo = {
|
|
|
+ totalCount: [],
|
|
|
+ thisMonthCount: []
|
|
|
+ }
|
|
|
$scope.checkboxes.checked = false;
|
|
|
$scope.totalMoney = 0;
|
|
|
$scope.condition.uuorname = $scope.suuorname;
|
|
|
@@ -9797,7 +9923,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
prodTitle: $scope.prodTitle,
|
|
|
prodSpec: $scope.prodSpec,
|
|
|
taxRate: $scope.taxRate,
|
|
|
- suuorname: $scope.suuorname
|
|
|
+ suuorname: $scope.suuorname,
|
|
|
+ customerUU: $scope.customerUU
|
|
|
}
|
|
|
$scope.exportKeywords = encodeURIComponent($scope.searchKeyWord);
|
|
|
// $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
|
|
|
@@ -9806,23 +9933,57 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
// toaster.pop('warning', '提示', '请先选择客户');
|
|
|
// document.getElementById('suuorname').focus();//光标默认在客户
|
|
|
// } else {
|
|
|
+ $scope.fromDate = $scope.apCheckCondition.dateFrom ? $scope.apCheckCondition.dateFrom.getTime() : null;
|
|
|
+ $scope.endDate = $scope.apCheckCondition.dateTo ? $scope.apCheckCondition.dateTo.getTime() : null;
|
|
|
$scope.loading = true;
|
|
|
- FaApCheck.getAllByKeywords({
|
|
|
- // fromDate: $scope.fromDate,
|
|
|
- // endDate: $scope.endDate,
|
|
|
+ var _params = {}
|
|
|
+ if ($scope.apCheckCondition.$open) {
|
|
|
+ _params = {
|
|
|
+ fromDate: $scope.fromDate,
|
|
|
+ endDate: $scope.endDate,
|
|
|
receiveName: $scope.receiveName,
|
|
|
factory: $scope.factory,
|
|
|
prodTitle: $scope.prodTitle,
|
|
|
prodSpec: $scope.prodSpec,
|
|
|
taxRate: $scope.taxRate,
|
|
|
checkDate: $scope.thisMouth,
|
|
|
- suuorname: $scope.suuorname
|
|
|
- }, function (data) {
|
|
|
- if (data.length > 0) {
|
|
|
- angular.forEach(data, function (item) {
|
|
|
+ suuorname: $scope.suuorname,
|
|
|
+ customerUU: $scope.customerUU,
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _params = {
|
|
|
+ receiveName: $scope.receiveName,
|
|
|
+ factory: $scope.factory,
|
|
|
+ prodTitle: $scope.prodTitle,
|
|
|
+ prodSpec: $scope.prodSpec,
|
|
|
+ taxRate: $scope.taxRate,
|
|
|
+ checkDate: $scope.thisMouth,
|
|
|
+ suuorname: $scope.suuorname,
|
|
|
+ customerUU: $scope.customerUU,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FaApCheck.getAllByKeywords(_params, function (data) {
|
|
|
+ $scope.checkMain = data;
|
|
|
+ if (data.details.length > 0) {
|
|
|
+ angular.forEach(data.details, function (item) {
|
|
|
item.$selected = true;
|
|
|
});
|
|
|
- $scope.data = data;
|
|
|
+ var _mouthArr = []
|
|
|
+ data.thisMonthCount.forEach(function(item) {
|
|
|
+ if (item.amount > 0) {
|
|
|
+ _mouthArr.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ data.thisMonthCount = _mouthArr
|
|
|
+ var _totalArr = []
|
|
|
+ data.totalCount.forEach(function(item) {
|
|
|
+ if (item.amount > 0) {
|
|
|
+ _totalArr.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ data.totalCount = _totalArr
|
|
|
+ $scope.dataInfo = data
|
|
|
+ $scope.data = data.details;
|
|
|
$scope.checkboxes.checked = true;
|
|
|
$scope.getTotalMoney();
|
|
|
} else {
|
|
|
@@ -9844,7 +10005,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
url = url + '&fromDate=' + $scope.fromDate + '&endDate=' + $scope.endDate;
|
|
|
}
|
|
|
if (angular.isDefined($scope.thisMouth)) {
|
|
|
- url = url + '&checkDate=' + $scope.thisMouth;x
|
|
|
+ url = url + '&checkDate=' + $scope.thisMouth;
|
|
|
}
|
|
|
if (angular.isDefined($scope.receiveName)) {
|
|
|
url = url + '&receiveName=' + $scope.receiveName;
|
|
|
@@ -10096,8 +10257,51 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
if ($scope.sameCust && $scope.validQty) {
|
|
|
$scope.saveApCheck();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ // 新增
|
|
|
+
|
|
|
+ $scope.apCheckopenFilterDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ if ($scope.apCheckCondition.dateFrom && $scope.apCheckCondition.dateTo && !item[openParam]) {
|
|
|
+ $scope.searchOrder()
|
|
|
+ }
|
|
|
+ };
|
|
|
+ $scope.addMouth = function(val) {
|
|
|
+ var _time = new Date($scope.thisMouth)
|
|
|
+ _time.setMonth(_time.getMonth() + val)
|
|
|
+ $scope.thisMouth = _time.getFullYear() + '-' + (_time.getMonth() + 1)
|
|
|
+ $scope.apCheckCondition.$open = false
|
|
|
+ $scope.searchOrder()
|
|
|
}
|
|
|
|
|
|
+ $scope.addMouthOut = function(val) {
|
|
|
+ var _time = new Date($scope.thisMouthOut)
|
|
|
+ _time.setMonth(_time.getMonth() + val)
|
|
|
+ $scope.thisMouthOut = _time.getFullYear() + '-' + (_time.getMonth() + 1)
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.hideshowNotCheck = function() {
|
|
|
+ $scope.showNotCheck = false
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.$watch('thisMouthOut', function(newVal, oldVal) {
|
|
|
+ if (newVal !== oldVal) {
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $scope.$watch('thisMouth', function(newVal, oldVal) {
|
|
|
+ if (newVal !== oldVal) {
|
|
|
+ $scope.searchOrder()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
}]);
|
|
|
|
|
|
|
|
|
@@ -10396,6 +10600,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
|
|
|
// 点击其中一个明细的复选框
|
|
|
$scope.checkOne = function (check) {
|
|
|
+ check.$selected = !check.$selected
|
|
|
var result = true;
|
|
|
angular.forEach($scope.data, function (item) {
|
|
|
if (item.$selected != true) {
|
|
|
@@ -14774,38 +14979,6 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
}
|
|
|
$scope.customerParams.reload();
|
|
|
});
|
|
|
- // if (!$scope.enabled) {
|
|
|
- // toaster.pop('error', '您没有为当前客户分配用户的权限!');
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // 获取当前用户在当前企业是否被转移权限
|
|
|
- // AccountUser.getEnTransfer({custUU: customer.myEnterprise.uu}, function (data) {
|
|
|
- // customer.enTransfer = data.result;
|
|
|
- // //是管理员,或者被转移了权限时
|
|
|
- // if ($scope.enabled || customer.enTransfer) {
|
|
|
- // var modalInstance = $modal.open({
|
|
|
- // animation: true,
|
|
|
- // templateUrl: 'static/tpl/index/account/add_userInfo.html',
|
|
|
- // controller: 'AddUserInfoCtrl',
|
|
|
- // resolve: {
|
|
|
- // customer: function () {
|
|
|
- // return customer;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- // modalInstance.result.then(function (changed, checked) {
|
|
|
- // if (changed) {
|
|
|
- // if (checked)
|
|
|
- // $scope.newUser.roles = checked;
|
|
|
- // else
|
|
|
- // loadUsers();
|
|
|
- // }
|
|
|
- // $scope.customerParams.reload();
|
|
|
- // });
|
|
|
- // } else {
|
|
|
- // toaster.pop('error', '您没有为当前客户分配用户的权限!');
|
|
|
- // }
|
|
|
- // });
|
|
|
};
|
|
|
|
|
|
// 转移权限
|
|
|
@@ -24146,44 +24319,20 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
*/
|
|
|
app.controller('SearchCtrl', ['$scope', '$http', '$rootScope', 'SessionService', 'AccountEnterprise', function($scope, $http, $rootScope, SessionService, AccountEnterprise) {
|
|
|
$scope.hotwords = new Array();
|
|
|
- var hasBrand = false;
|
|
|
- var hasComponent = false;
|
|
|
|
|
|
- // 热词搜索品牌
|
|
|
- var hotBrand = function () {
|
|
|
- $http.get($scope.toB2cLink + '/api/product/brand/mostSearchBrands'
|
|
|
+ // 热词搜索
|
|
|
+ var hotSearchList = function () {
|
|
|
+ $http.get('https://mall.usoftchina.com/cmsApi?method=queryContentPage&module=index_hotModels&orderBy=order_number%20ASC'
|
|
|
).success(function(data){
|
|
|
- hasBrand = true;
|
|
|
-
|
|
|
- angular.forEach(data, function (value) {
|
|
|
- $scope.hotwords.push({name: value.nameEn, url: $scope.toB2cLink + '/search?w='+ value.nameEn +'&type=brand'})
|
|
|
- })
|
|
|
- if (hasBrand) {
|
|
|
- hotComponent();
|
|
|
- }
|
|
|
- }).error(function(response) {
|
|
|
- console.log(response)
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- // 热词搜索器件
|
|
|
- var hotComponent = function () {
|
|
|
- $http.get($scope.toB2cLink + '/api/product/component/mostSearchComponent'
|
|
|
- ).success(function(data){
|
|
|
- hasComponent = true;
|
|
|
- if (hasBrand && hasComponent) {
|
|
|
- angular.forEach(data, function (value) {
|
|
|
- $scope.hotwords.push({name: value.code, url: $scope.toB2cLink + '/search?w='+ value.code +'&type=component'})
|
|
|
- })
|
|
|
- }
|
|
|
+ $scope.hotwords = data.data
|
|
|
}).error(function(response) {
|
|
|
console.log(response)
|
|
|
});
|
|
|
};
|
|
|
|
|
|
AccountEnterprise.getB2cUrl({}, function(data) {
|
|
|
- $scope.toB2cLink = data.url
|
|
|
- hotBrand();
|
|
|
+ $scope.toB2cLink = data.url;
|
|
|
+ hotSearchList();
|
|
|
});
|
|
|
|
|
|
// 默认搜索类型
|