|
|
@@ -232,6 +232,10 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
url : "/customer",
|
|
|
templateUrl : "static/tpl/index/sale/customer.html",
|
|
|
controller: 'CustomerCtrl'
|
|
|
+ }).state('sale.customer_detail', {
|
|
|
+ url : "/customer/:id",
|
|
|
+ templateUrl : "static/tpl/index/sale/customer_detail.html",
|
|
|
+ controller: 'CustomerDetailCtrl'
|
|
|
}).state('sale.customerProduct', {
|
|
|
url : "/customerProduct",
|
|
|
templateUrl : "static/tpl/index/sale/customer.html",
|
|
|
@@ -1394,6 +1398,8 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
$scope.count = date;
|
|
|
});
|
|
|
}]);
|
|
|
+
|
|
|
+ // 客户
|
|
|
app.controller('CustomerCtrl', ['$scope', 'VendorService', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', function($scope, VendorService, BaseService, AuthenticationService,ngTableParams,$modal, toaster){
|
|
|
BaseService.scrollBackToTop();
|
|
|
$scope.userInfoResult = true;
|
|
|
@@ -1499,7 +1505,191 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
$scope.customerParams.reload();
|
|
|
$scope.tip = keyword;
|
|
|
};
|
|
|
+
|
|
|
+ // 查看详情
|
|
|
+ $scope.viewDetail = function(id) {
|
|
|
+ console.log(id);
|
|
|
+ window.location.hash = "#/sale/customer/" + id;
|
|
|
+ }
|
|
|
+
|
|
|
}]);
|
|
|
+
|
|
|
+ // 客户详情
|
|
|
+ app.controller('CustomerDetailCtrl', ['$scope', 'toaster', '$stateParams', 'Vendor', '$modal', 'Product', 'ngTableParams', 'BaseService', '$rootScope', 'VendorService', 'AuthenticationService', function($scope, toaster, $stateParams, Vendor, $modal, Product, ngTableParams, BaseService, $rootScope, VendorService, AuthenticationService) {
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+ $scope.userInfoResult = true;
|
|
|
+ AuthenticationService.getAuthentication().success(function(data) {
|
|
|
+ $scope.loading = false;
|
|
|
+ $scope.thisUser = data;
|
|
|
+ });
|
|
|
+ $scope.vendorContacts = [];
|
|
|
+ var loadData = function() {
|
|
|
+ Vendor.getVendorDetail({id: $stateParams.id}, {}, function(data) {
|
|
|
+ $scope.customer = data.myEnterprise;
|
|
|
+ $scope.customerInfo = data;
|
|
|
+ Vendor.custContacts({enuu: $scope.customer.uu}, {}, function(data) {
|
|
|
+ $scope.Contacts = data;
|
|
|
+ });
|
|
|
+
|
|
|
+ // 查看已分配人员
|
|
|
+ VendorService.userInfo.query({uu: $scope.customer.uu},null,function(data) {
|
|
|
+ $scope.custInfos = data;
|
|
|
+ var getPage = function(page, size){
|
|
|
+ if($scope.custInfos) {
|
|
|
+ var result = {};
|
|
|
+ result.totalCount = $scope.custInfos.length;
|
|
|
+ result.content = $scope.custInfos.slice((page - 1)*size, page * size);
|
|
|
+ if($scope.custInfos.length % size == 0) {
|
|
|
+ result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
|
|
|
+ }else {
|
|
|
+ result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
|
|
|
+ }
|
|
|
+ result.first = page == 1;
|
|
|
+ result.last = page == result.totalPage;
|
|
|
+ result.page = page;
|
|
|
+ result.next = page - 0 + 1;
|
|
|
+ result.pre = page - 1;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.userdata = getPage(1,4);
|
|
|
+ $scope.first = function (){
|
|
|
+ $scope.userdata = getPage($scope.userdata.pre,4);
|
|
|
+ }
|
|
|
+ $scope.last = function (){
|
|
|
+ $scope.userdata = getPage($scope.userdata.next,4);
|
|
|
+ }
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+ loadData();
|
|
|
+
|
|
|
+ // 新增客户联系人
|
|
|
+ $scope.addContact = function(uu) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/sale/contact_person_modal.html',
|
|
|
+ controller: 'AddContacCtrl',
|
|
|
+ resolve: {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function(data) {
|
|
|
+ $scope.contact = data;
|
|
|
+ $scope.contact.myenuu = uu;
|
|
|
+ Vendor.saveCustContact({}, $scope.contact, function(data) {
|
|
|
+ toaster.pop('success', '提示', '联系人保存成功');
|
|
|
+ $scope.Contacts.push(data);
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '失败', response.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 编辑客户联系人
|
|
|
+ $scope.edit = function(contact) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
|
|
|
+ controller: 'EditContacCtrl',
|
|
|
+ resolve: {
|
|
|
+ contact: function() {
|
|
|
+ return contact;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function(data) {
|
|
|
+ $scope.contact = data;
|
|
|
+ Vendor.saveContact({}, $scope.contact, function(data) {
|
|
|
+ toaster.pop('success', '提示', '联系人修改成功');
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '失败', response.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除客户联系人
|
|
|
+ $scope.deleteById = function(id, index) {
|
|
|
+ $scope.Contacts.splice(index, 1);
|
|
|
+ Vendor.deleteContact({id: id}, {}, function(data) {
|
|
|
+ toaster.pop('success', '提示', '供应商联系人删除成功');
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 供应商物料信息
|
|
|
+ $scope.viewProdList = function(uu){
|
|
|
+ $scope.uu = uu;
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function(keyword) {
|
|
|
+ $scope.keyword = keyword;
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 供应商物料信息
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page : 1,
|
|
|
+ count : 10
|
|
|
+ }, {
|
|
|
+ total : 0,
|
|
|
+ counts: [5, 10, 25, 50],
|
|
|
+ getData : function($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ pageParams.custUU = $scope.uu;
|
|
|
+ pageParams.keyword = $scope.keyword;
|
|
|
+ $scope.tip = $scope.keyword;
|
|
|
+ Product.get.call(null, BaseService.parseParams(pageParams), function(page){
|
|
|
+ $scope.loading = false;
|
|
|
+ if(page) {
|
|
|
+ params.total(page.totalElement);
|
|
|
+ $scope.total = page.totalElement;
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
|
|
|
+ }
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.addUserInfo = function() {
|
|
|
+ //TODO
|
|
|
+ if ($scope.thisUser.sys) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/account/add_userInfo.html',
|
|
|
+ controller: 'AddUserInfoCtrl',
|
|
|
+ resolve: {
|
|
|
+ customer: function() {
|
|
|
+ return $scope.customerInfo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function(changed, checked){
|
|
|
+ if(changed) {
|
|
|
+ if(checked)
|
|
|
+ $scope.newUser.roles = checked;
|
|
|
+ else
|
|
|
+ loadUsers();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', '您不是管理员,无权限分配用户!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', function($scope, $modalInstance, customer, AccountUser, toaster){
|
|
|
$scope.checkboxes = {
|
|
|
checked : false
|
|
|
@@ -1554,6 +1744,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
$modalInstance.close(false);
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
}]);
|
|
|
|
|
|
/**
|