customersInfoCtrl.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. define(['app/app'], function (app) {
  2. "use strict";
  3. /**
  4. * 客户
  5. */
  6. app.register.controller('CustomersInfoCtrl', ['$scope', 'B2bVendorService', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', 'B2bVendorInfo', function ($scope, VendorService, BaseService, AuthenticationService, ngTableParams, $modal, toaster, VendorInfo) {
  7. BaseService.scrollBackToTop();
  8. $scope.status = 'customer';
  9. $scope.userInfoResult = true;
  10. AuthenticationService.getAuthentication().success(function (data) {
  11. $scope.loading = false;
  12. $scope.thisUser = data;
  13. });
  14. $scope.customerParams = new ngTableParams({
  15. page: 1,
  16. count: 20
  17. }, {
  18. total: 0,
  19. counts: [],
  20. getData: function ($defer, params) {
  21. $scope.loading = true;
  22. var pageParams = params.url();
  23. pageParams.keyword = $scope.keyword;
  24. VendorService.customer.get.call(null, BaseService.parseParams(pageParams), function (page) {
  25. $scope.loading = false;
  26. if (page) {
  27. params.total(page.totalElement);
  28. $scope.total = page.totalElement;
  29. $scope.infoCommon = page
  30. $scope.infoCommon.all = page.content.length
  31. $defer.resolve(page.content);
  32. }
  33. $scope.totalCount = page.totalElement;
  34. }, function (response) {
  35. $scope.loading = false;
  36. toaster.pop('error', '数据加载失败', response.data);
  37. });
  38. }
  39. });
  40. // 搜索框回车
  41. $scope.onSearch = function (keyword) {
  42. $scope.customerParams.page(1);
  43. $scope.customerParams.reload();
  44. $scope.tip = keyword;
  45. };
  46. // 查看详情
  47. $scope.viewDetail = function (id) {
  48. window.location.hash = "#/sale/customer/" + id;
  49. }
  50. // 取消合作关系
  51. $scope.disableCust = function (id) {
  52. VendorInfo.disableCust({id: id}, {}, function (data) {
  53. if (data.success) {
  54. toaster.pop('success', '提示', data.success);
  55. }
  56. // $scope.customerParams.page(1);
  57. $scope.customerParams.reload();
  58. }, function (response) {
  59. toaster.pop('error', '提示', response.data);
  60. });
  61. }
  62. // 解除禁用
  63. $scope.activeCust = function (id) {
  64. VendorInfo.activeCust({id: id}, {}, function (data) {
  65. if (data.success) {
  66. toaster.pop('success', '提示', data.success);
  67. }
  68. // $scope.customerParams.page(1);
  69. $scope.customerParams.reload();
  70. }, function (response) {
  71. toaster.pop('error', '提示', response.data);
  72. });
  73. }
  74. }]);
  75. });