|
|
@@ -1,6 +1,6 @@
|
|
|
-define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'service/Account', 'service/Alert', 'ui.router', 'ui.bootstrap' , 'file-upload', 'ngSanitize'], function() {
|
|
|
+define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'service/Make', 'service/Account', 'service/Alert', 'ui.router', 'ui.bootstrap' , 'file-upload', 'ngSanitize'], function() {
|
|
|
'use strict';
|
|
|
- var app = angular.module('myApp', [ 'toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'PurcServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize']);
|
|
|
+ var app = angular.module('myApp', [ 'toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'PurcServices', 'MakeServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize']);
|
|
|
app.init = function() {
|
|
|
angular.bootstrap(document, [ 'myApp' ]);
|
|
|
};
|
|
|
@@ -212,6 +212,27 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
url : "/apBill",
|
|
|
templateUrl : "static/tpl/index/fa/apBill.html",
|
|
|
controller: 'SaleApBillCtrl'
|
|
|
+ }).state('make', {
|
|
|
+ url : "/make",
|
|
|
+ views : {
|
|
|
+ "left-view" : {
|
|
|
+ templateUrl : "static/tpl/index/make/left.html"
|
|
|
+ },
|
|
|
+ "right-view" : {
|
|
|
+ templateUrl : "static/tpl/index/make/right.html"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).state('make.index', {
|
|
|
+ url : "",
|
|
|
+ templateUrl : "static/tpl/index/make/index.html"
|
|
|
+ }).state('make.order', {
|
|
|
+ url : "/order",
|
|
|
+ templateUrl : "static/tpl/index/make/order.html",
|
|
|
+ controller: 'MakeOrderCtrl'
|
|
|
+ }).state('make.order_detail', {
|
|
|
+ url : "/order/:id",
|
|
|
+ templateUrl : "static/tpl/index/make/order_detail.html",
|
|
|
+ controller: 'SaleOrderDetailCtrl'
|
|
|
});
|
|
|
}]);
|
|
|
|
|
|
@@ -3151,6 +3172,139 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
};
|
|
|
}]);
|
|
|
|
|
|
+ /**
|
|
|
+ * 委外订单
|
|
|
+ */
|
|
|
+ app.controller('MakeOrderCtrl', ['$scope', '$filter', 'MakeOrder', 'ngTableParams', 'toaster', 'BaseService',
|
|
|
+ function($scope, $filter, MakeOrder, ngTableParams, toaster, BaseService){
|
|
|
+ $scope.active = 'all';
|
|
|
+ $scope.dateZoneText = '一个月内';
|
|
|
+ $scope.condition = {dateZone: 1};
|
|
|
+ $scope.changeDateZone = function(zone) {
|
|
|
+ $scope.condition.dateZone = zone;
|
|
|
+ $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
|
|
|
+ $scope.condition.$dateZoneOpen = false;
|
|
|
+ getDateCondition(zone, $scope.condition);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+ $scope.setActive = function(state) {
|
|
|
+ if($scope.active != state) {
|
|
|
+ $scope.active = state;
|
|
|
+ if($scope.tableParams.page() == 1)
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ else
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ var getService = function() {
|
|
|
+ return MakeOrder;
|
|
|
+ };
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page : 1,
|
|
|
+ count : 5,
|
|
|
+ sorting: {
|
|
|
+ date: 'desc'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total : 0,
|
|
|
+ counts: [5, 10, 25, 50],
|
|
|
+ getData : function($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ pageParams.keyword = $scope.keyword;
|
|
|
+ getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
|
|
|
+ $scope.loading = false;
|
|
|
+ if(page) {
|
|
|
+ params.total(page.totalElements);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
|
|
|
+ }
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.getOrderTotal = function(items) {
|
|
|
+ var sum = 0;
|
|
|
+ angular.forEach(items, function(item){
|
|
|
+ sum += item.qty * item.price;
|
|
|
+ });
|
|
|
+ return sum;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.openDatePicker = function($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.parseDate = function(dateStr) {
|
|
|
+ if(dateStr)
|
|
|
+ return Date.parse(dateStr, 'yyyy-MM-dd');
|
|
|
+ return new Date();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 打开回复
|
|
|
+ $scope.openReply = function(order) {
|
|
|
+ if(!order.reply) {
|
|
|
+ order.reply = {
|
|
|
+ qty: order.qty - (order.replyQty ? order.replyQty : 0),
|
|
|
+ delivery: order.delivery
|
|
|
+ }
|
|
|
+ }
|
|
|
+ order.$editing = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 关闭回复
|
|
|
+ $scope.closeReply = function(order) {
|
|
|
+ order.$editing = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function() {
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 点击回复
|
|
|
+ $scope.onReplyClick = function(order, inverse) {
|
|
|
+ if(order.reply) {
|
|
|
+ if(!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
|
|
|
+ toaster.pop('warning', '提示', '请填写有效的回复数量!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var reply = angular.copy(order.reply);
|
|
|
+ if(reply.delivery) {
|
|
|
+ if(typeof reply.delivery == 'object')
|
|
|
+ reply.delivery = reply.delivery.getTime();
|
|
|
+ } else {
|
|
|
+ reply.delivery = order.delivery;
|
|
|
+ }
|
|
|
+ if(inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
|
|
|
+ $scope.loading = true;
|
|
|
+ MakeOrder.reply({orderId: order.id}, reply, function(){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('info', '提示', (inverse == -1 ? '撤销成功':'回复成功'));
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '回复失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取回复记录
|
|
|
+ $scope.getReply = function(order) {
|
|
|
+ if(!order.replies) {
|
|
|
+ MakeOrder.getReply({orderId: order.id}, function(replies){
|
|
|
+ order.replies = replies;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
/**
|
|
|
* 计算时间差
|
|
|
*/
|