|
|
@@ -9,18 +9,41 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
$stateProvider.state('index', {
|
|
|
url : "/index",
|
|
|
templateUrl : "static/tpl/index_mobile/home/index.html"
|
|
|
- }).state('saleOrder', {
|
|
|
- url : "/sale/order/:code",
|
|
|
- templateUrl : "static/tpl/index_mobile/sale/saleOrder.html"
|
|
|
- }).state('saleChange', {
|
|
|
- url: '/sale/change/:code',
|
|
|
- templateUrl: 'static/tpl/index_mobile/sale/saleChange.html'
|
|
|
- }).state('saleInquiry', {
|
|
|
- url: '/sale/inquiry/:itemId',
|
|
|
- templateUrl: 'static/tpl/index_mobile/sale/saleInquiry.html'
|
|
|
- }).state('saleNotice', {
|
|
|
- url: '/sale/notice/:id',
|
|
|
- templateUrl: 'static/tpl/index_mobile/sale/saleNotice.html'
|
|
|
+ }).state('sale', {// 销售
|
|
|
+ url : "/sale",
|
|
|
+ templateUrl : "static/tpl/index_mobile/sale/sale.html"
|
|
|
+ }).state('sale.order', {// 销售,订单列表
|
|
|
+ url : "/order",
|
|
|
+ templateUrl : "static/tpl/index_mobile/sale/order_list.html",
|
|
|
+ controller: 'SaleOrderListCtrl'
|
|
|
+ }).state('sale.change', {// 销售,变更单列表
|
|
|
+ url : "/change",
|
|
|
+ templateUrl : "static/tpl/index_mobile/sale/change_list.html",
|
|
|
+ controller: 'SaleChangeListCtrl'
|
|
|
+ }).state('sale.inquiry', {// 销售,询价单列表
|
|
|
+ url : "/inquiry",
|
|
|
+ templateUrl : "static/tpl/index_mobile/sale/inquiry_list.html",
|
|
|
+ controller: 'SaleInquiryListCtrl'
|
|
|
+ }).state('sale.notice', {// 销售,发货提醒列表
|
|
|
+ url : "/notice",
|
|
|
+ templateUrl : "static/tpl/index_mobile/sale/notice_list.html",
|
|
|
+ controller: 'SaleNoticeListCtrl'
|
|
|
+ }).state('sale.order_detail', {// 销售,订单详情
|
|
|
+ url : "/order/:id",
|
|
|
+ templateUrl : "static/tpl/index_mobile/sale/order_detail.html",
|
|
|
+ controller: 'SaleOrderCtrl'
|
|
|
+ }).state('sale.change_detail', {// 销售,变更单详情
|
|
|
+ url: '/change/:id',
|
|
|
+ templateUrl: 'static/tpl/index_mobile/sale/change_detail.html',
|
|
|
+ controller: 'SaleChangeCtrl'
|
|
|
+ }).state('sale.inquiry_detail', {// 销售,询价单详情
|
|
|
+ url: '/inquiry/:itemId',
|
|
|
+ templateUrl: 'static/tpl/index_mobile/sale/inquiry_detail.html',
|
|
|
+ controller: 'SaleInquiryCtrl'
|
|
|
+ }).state('sale.notice_detail', {// 销售,发货提醒详情
|
|
|
+ url: '/notice/:id',
|
|
|
+ templateUrl: 'static/tpl/index_mobile/sale/notice_detail.html',
|
|
|
+ controller: 'SaleNoticeCtrl'
|
|
|
});
|
|
|
}]);
|
|
|
|
|
|
@@ -42,11 +65,11 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
return statusConfig[code];
|
|
|
}
|
|
|
};
|
|
|
- }).filter('status', function(StatusCode){
|
|
|
+ }).filter('status', ['StatusCode', function(StatusCode){
|
|
|
return function(data) {
|
|
|
return StatusCode.get(data);
|
|
|
}
|
|
|
- });
|
|
|
+ }]);
|
|
|
|
|
|
app.factory('Symbol', function(){
|
|
|
return {
|
|
|
@@ -70,9 +93,22 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
});
|
|
|
}]);
|
|
|
app.controller('AuthCtrl', ['$scope', '$window', 'AuthenticationService', function($scope, $window, AuthenticationService) {
|
|
|
- $scope.isAuthed = AuthenticationService.isAuthed();
|
|
|
+ $scope.isAuthed = AuthenticationService.isAuthed(); //AuthenticationService模块在common/下
|
|
|
$scope.userInfo = {};
|
|
|
AuthenticationService.getAuthentication().success(function(data) {
|
|
|
+ if(data.enterprises) {
|
|
|
+ data.enterprise = data.enterprises[data.enterprises.length - 1];
|
|
|
+ if(data.enterprises.length > 1) {
|
|
|
+ var enSelect = [];
|
|
|
+ angular.forEach(data.enterprises, function(e){
|
|
|
+ if(e.current)
|
|
|
+ data.enterprise = e;
|
|
|
+ else
|
|
|
+ enSelect.push(e);
|
|
|
+ });
|
|
|
+ data.enSelect = enSelect;
|
|
|
+ }
|
|
|
+ }
|
|
|
$scope.userInfo = data;
|
|
|
if (data == null || !data.uu)
|
|
|
$scope.isAuthed = false;
|
|
|
@@ -82,7 +118,87 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
$window.location.reload();
|
|
|
});
|
|
|
};
|
|
|
+ $scope.switchto = function(enUU) {// 切换企业
|
|
|
+ AuthenticationService.reSignin(enUU).success(function(){
|
|
|
+ $window.location.reload();
|
|
|
+ });
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // 根据状态分类得到获取数据的方法
|
|
|
+ var getState = function(active) {
|
|
|
+ var fn = 'get';
|
|
|
+ switch(active) {
|
|
|
+ case 'done':
|
|
|
+ fn = 'getDone';break;
|
|
|
+ case 'todo':
|
|
|
+ fn = 'getTodo';break;
|
|
|
+ case 'end':
|
|
|
+ fn = 'getEnd';break;
|
|
|
+ case 'waiting':
|
|
|
+ fn = 'getWaiting';break;
|
|
|
+ }
|
|
|
+ return fn;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户采购订单列表
|
|
|
+ */
|
|
|
+ app.controller('SaleOrderListCtrl', ['$scope', 'BaseService', 'PurcOrderItem', 'toaster', function($scope, BaseService, PurcOrderItem, toaster) {
|
|
|
+ $scope.data = {};// 列表数据
|
|
|
+
|
|
|
+ var pageParams = { // 页面参数
|
|
|
+ page : 1,
|
|
|
+ count : 5,
|
|
|
+ sorting: {
|
|
|
+ date: 'desc'
|
|
|
+ },
|
|
|
+ searchFilter: { // 筛选条件
|
|
|
+ keyword: null
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope._state = 'all';
|
|
|
+
|
|
|
+ // 加载数据
|
|
|
+ var getData = function(add) {
|
|
|
+ $scope.loading = true;
|
|
|
+ PurcOrderItem[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
|
|
|
+ if(add) {
|
|
|
+ data.content = $scope.data.content.concat(data.content);
|
|
|
+ $scope.data = data;
|
|
|
+ } else {
|
|
|
+ $scope.data = data;
|
|
|
+ }
|
|
|
+ $scope.loading = false;
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '加载数据失败', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ getData();// 初始获取数据
|
|
|
+
|
|
|
+ // 加载更多数据
|
|
|
+ $scope.getMoreData = function() {
|
|
|
+ pageParams.page ++;
|
|
|
+ getData(true);
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取订单的总金额
|
|
|
+ $scope.getTotal = function(order) {
|
|
|
+ var total = 0;
|
|
|
+ angular.forEach(order.orderItems, function(item){
|
|
|
+ total += (item.qty||0) * (item.price||0);
|
|
|
+ });
|
|
|
+ return total;
|
|
|
+ };
|
|
|
+
|
|
|
}]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户采购订单详情
|
|
|
+ */
|
|
|
app.controller('SaleOrderCtrl', ['$scope', '$filter', '$stateParams', 'toaster', 'PurcOrder', 'PurcOrderItem', 'Symbol', function($scope, $filter, $stateParams, toaster, PurcOrder, PurcOrderItem, Symbol){
|
|
|
$scope.loading = true;
|
|
|
$scope.symbol = Symbol.currency;
|
|
|
@@ -95,14 +211,12 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
return parseFloat(sum).toFixed(2);//四舍五入取两位小数
|
|
|
};
|
|
|
|
|
|
- PurcOrder.get({id: $stateParams.code}, function(data) {
|
|
|
+ PurcOrder.get({id: $stateParams.id}, function(data) {
|
|
|
$scope.purcOrder = data;
|
|
|
$scope.loading = false;
|
|
|
});
|
|
|
|
|
|
- /**
|
|
|
- * 展开回复
|
|
|
- */
|
|
|
+ // 展开回复
|
|
|
$scope.expandReply = function(orderItem) {
|
|
|
if(!orderItem.replys) {
|
|
|
PurcOrderItem.getReply({orderItemId: orderItem.id}, function(data){
|
|
|
@@ -117,18 +231,14 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
orderItem.expand = !orderItem.expand;
|
|
|
};
|
|
|
|
|
|
- /**
|
|
|
- * 全选
|
|
|
- */
|
|
|
+ // 全选
|
|
|
$scope.checkAll = function(value) {
|
|
|
angular.forEach($scope.purcOrder.orderItems, function(item, index){
|
|
|
item.checked = value;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- /**
|
|
|
- * 选中一个
|
|
|
- */
|
|
|
+ // 选中一个
|
|
|
$scope.checkOne = function(value) {
|
|
|
if(value) {
|
|
|
// angular.forEach($scope.purcOrder.orderItems, function(item, index){
|
|
|
@@ -157,7 +267,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
reply.delivery = reply.delivery.getTime();
|
|
|
}
|
|
|
PurcOrderItem.reply({orderItemId: item.id}, reply, function(){
|
|
|
- PurcOrder.get({id: $stateParams.code}, function(data) {
|
|
|
+ PurcOrder.get({id: $stateParams.id}, function(data) {
|
|
|
$scope.purcOrder = data;
|
|
|
$scope.loading = false;
|
|
|
toaster.pop('success', '提示', '回复成功:' + reply.qty);
|
|
|
@@ -184,7 +294,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
str = str.substr(0, str.length-1);
|
|
|
PurcOrderItem.replyByBatch(str, function(){
|
|
|
$scope.loading = false;
|
|
|
- PurcOrder.get({id: $stateParams.code}, function(data) {
|
|
|
+ PurcOrder.get({id: $stateParams.id}, function(data) {
|
|
|
$scope.purcOrder = data;
|
|
|
$scope.loading = false;
|
|
|
toaster.pop('success', '提示', '回复成功');
|
|
|
@@ -202,7 +312,14 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
}]);
|
|
|
|
|
|
/**
|
|
|
- * 销售变更
|
|
|
+ * 客户采购变更列表
|
|
|
+ */
|
|
|
+ app.controller('SaleChangeListCtrl', ['$scope', function($scope) {
|
|
|
+
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户采购变更详情
|
|
|
*/
|
|
|
app.controller('SaleChangeCtrl', ['$scope', '$stateParams', 'toaster', 'PurcChange', function($scope, $stateParams, toaster, PurcChange){
|
|
|
$scope.loading = true;
|
|
|
@@ -236,6 +353,16 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
};
|
|
|
}]);
|
|
|
|
|
|
+ /**
|
|
|
+ * 客户询价单列表
|
|
|
+ */
|
|
|
+ app.controller('SaleInquiryListCtrl', ['$scope', function($scope) {
|
|
|
+
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户询价单详情
|
|
|
+ */
|
|
|
app.controller('SaleInquiryCtrl', ['$scope', '$stateParams', 'toaster', 'PurcInquiry', 'Symbol', function($scope, $stateParams, toaster, PurcInquiry, Symbol){
|
|
|
$scope.loading = true;
|
|
|
$scope.vendFromDateOpen = false;
|
|
|
@@ -321,6 +448,16 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ui.
|
|
|
};
|
|
|
}]);
|
|
|
|
|
|
+ /**
|
|
|
+ * 客户发货提醒列表
|
|
|
+ */
|
|
|
+ app.controller('SaleNoticeListCtrl', ['$scope', function($scope) {
|
|
|
+
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户发货提醒详情
|
|
|
+ */
|
|
|
app.controller('SaleNoticeCtrl', ['$scope', '$stateParams', 'toaster', 'PurcNotice', 'Symbol', function($scope, $stateParams, toaster, PurcNotice, Symbol){
|
|
|
$scope.loading = true;
|
|
|
$scope.symbol = Symbol.currency;//把币别转化为符号
|