|
|
@@ -69,6 +69,10 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
url : "/customer",
|
|
|
templateUrl : "static/tpl/index/sale/customer.html",
|
|
|
controller: 'CustomerCtrl'
|
|
|
+ }).state('sale.customerProduct', {
|
|
|
+ url : "/customerProduct",
|
|
|
+ templateUrl : "static/tpl/index/sale/customer.html",
|
|
|
+ controller: 'CustomerCtrl'
|
|
|
}).state('sale.inquiry', {
|
|
|
url : "/inquiry",
|
|
|
templateUrl : "static/tpl/index/sale/inquiry.html",
|
|
|
@@ -79,8 +83,19 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
controller: 'SaleInquiryDetailCtrl'
|
|
|
}).state('sale.quotation', {
|
|
|
url : "/quotation",
|
|
|
- templateUrl : "static/tpl/index/sale/quotation.html",
|
|
|
- controller: 'SaleInquiryCtrl'
|
|
|
+ templateUrl : "static/tpl/index/sale/quotation.html"
|
|
|
+ }).state('sale.quotation.new', {
|
|
|
+ url : "/new",
|
|
|
+ templateUrl : "static/tpl/index/sale/quotation_new.html",
|
|
|
+ controller: 'SaleQuotationNewCtrl'
|
|
|
+ }).state('sale.quotation.list', {
|
|
|
+ url : "/list",
|
|
|
+ templateUrl : "static/tpl/index/sale/quotation_list.html",
|
|
|
+ controller: 'SaleQuotationListCtrl'
|
|
|
+ }).state('sale.quotation.item', {
|
|
|
+ url : "/:id",
|
|
|
+ templateUrl : "static/tpl/index/sale/quotation_new.html",
|
|
|
+ controller: 'SaleQuotationNewCtrl'
|
|
|
}).state('sale.order', {
|
|
|
url : "/order",
|
|
|
templateUrl : "static/tpl/index/sale/order.html",
|
|
|
@@ -1128,6 +1143,8 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
$scope.tableParams.reload();
|
|
|
};
|
|
|
}]);
|
|
|
+
|
|
|
+ // 询价单明细
|
|
|
app.controller('SaleInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry', 'toaster', function($scope, $stateParams, PurcInquiry, toaster){
|
|
|
var loadData = function() {
|
|
|
PurcInquiry.getAll({id: $stateParams.id}, function(data){
|
|
|
@@ -1213,6 +1230,312 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
}
|
|
|
};
|
|
|
}]);
|
|
|
+
|
|
|
+ // 主动报价 - 列表
|
|
|
+ app.controller('SaleQuotationListCtrl', ['$scope', '$filter', 'Quotation', 'PurcInquiry', 'ngTableParams', 'toaster', 'BaseService', function($scope, $filter, Quotation, PurcInquiry, ngTableParams, toaster, BaseService){
|
|
|
+ $scope.active = 'todo';
|
|
|
+ $scope.agreedText = '全部';
|
|
|
+ $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;
|
|
|
+ };
|
|
|
+ $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 Quotation;
|
|
|
+ };
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page : 1,
|
|
|
+ count : 5,
|
|
|
+ sorting: {
|
|
|
+ 'quotation.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.getHistory = function(item) {
|
|
|
+ if(!item.history) {
|
|
|
+ PurcInquiry.getHistory({itemId: item.id}, function(data){
|
|
|
+ item.history = data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.isValid = function(item, withSteps) {
|
|
|
+ var bool = item.leadtime && item.replies && item.replies[0].price > 0;
|
|
|
+ if(!withSteps || !bool)
|
|
|
+ return bool;
|
|
|
+ angular.forEach(item.replies, function(r, i){
|
|
|
+ bool = (i > 0 ? r.lapQty : 1) && r.price;
|
|
|
+ });
|
|
|
+ return bool;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function() {
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // Controller 主动报价 - 新增
|
|
|
+ app.controller('SaleQuotationNewCtrl', ['$scope', '$stateParams', '$filter', 'ngTableParams', 'toaster', 'BaseService', '$modal', 'Quotation', function($scope, $stateParams, $filter, ngTableParams, toaster, BaseService, $modal, Quotation){
|
|
|
+ var staticItem = null;
|
|
|
+
|
|
|
+ if( ! angular.isUndefined($stateParams.id)) {// 查看模式
|
|
|
+ $scope.loading = true;
|
|
|
+ Quotation.getItem({id: $stateParams.id}, function(data){
|
|
|
+ data.$editing = false;
|
|
|
+ $scope.item = data;
|
|
|
+ staticItem = angular.copy(data);
|
|
|
+ $scope.loading = false;
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ } else {// 新增模式
|
|
|
+ $scope.item = {
|
|
|
+ quotation: {
|
|
|
+ currency: 'RMB',
|
|
|
+ taxrate: 17,
|
|
|
+ date: new Date()
|
|
|
+ },
|
|
|
+ product: {},
|
|
|
+ prices: [{lapQty: 0}],
|
|
|
+ minOrderQty: 1,
|
|
|
+ minPackQty: 1,
|
|
|
+ $endDateOpen: false,
|
|
|
+ $editing: true
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.getMinDate = function(item) {
|
|
|
+ return $filter('date')(new Date, 'yyyy-MM-dd');
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.openDatePicker = function($event, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ $scope.item.$endDateOpen = !openParam;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 增加一个分段
|
|
|
+ $scope.addPrice = function(){
|
|
|
+ if($scope.item.prices.length >= 10) {
|
|
|
+ toaster.pop('warning', '提示', '最多支持10个分段!');
|
|
|
+ } else
|
|
|
+ $scope.item.prices.push({});
|
|
|
+ };
|
|
|
+
|
|
|
+ // 删除一个分段
|
|
|
+ $scope.removePrice = function(index) {
|
|
|
+ $scope.item.prices.splice(index, 1);
|
|
|
+ };
|
|
|
+
|
|
|
+ // 查找客户
|
|
|
+ $scope.dbfindCust = function(){
|
|
|
+ if($scope.item.$editing) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/tpl/index/sale/quotation_new_cust.html',
|
|
|
+ controller: 'DbfindCustCtrl',
|
|
|
+ size: 'lg',
|
|
|
+ resolve: {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function(data){
|
|
|
+ $scope.item.quotation.cust = data.myEnterprise;
|
|
|
+ $scope.item.quotation.custUser = data.myUser;
|
|
|
+ $scope.item.product = null;
|
|
|
+ }, function(){
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 查找客户物料
|
|
|
+ $scope.dbfindCustProd = function(){
|
|
|
+ if($scope.item.$editing) {
|
|
|
+ if($scope.item.quotation.cust.uu) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/tpl/index/sale/quotation_new_custProd.html',
|
|
|
+ controller: 'DbfindCustProdCtrl',
|
|
|
+ size: 'lg',
|
|
|
+ resolve: {
|
|
|
+ custUU: function(){return $scope.item.quotation.cust.uu}
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function(data){
|
|
|
+ $scope.item.product = data;
|
|
|
+ }, function(){
|
|
|
+
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', '错误', '请先选择客户');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 保存
|
|
|
+ $scope.save = function(){
|
|
|
+ $scope.loading = true;
|
|
|
+ if(!$scope.item.quotation.code) //新增,设单号
|
|
|
+ $scope.item.quotation.code = 'BJ' + $filter('date')(new Date(), 'yyMMddHHmmss_sss');
|
|
|
+ $scope.item.quotation.custUU = $scope.item.quotation.cust.uu;
|
|
|
+ $scope.item.quotation.custUserUU = $scope.item.quotation.custUser.userUU;
|
|
|
+ $scope.item.productId = $scope.item.product.id;
|
|
|
+ $scope.item.quotation.status = 100;//在录入
|
|
|
+ if($scope.item.quotation.date instanceof Date) {
|
|
|
+ $scope.item.quotation.date = $scope.item.quotation.date.getTime();
|
|
|
+ }
|
|
|
+ if($scope.item.quotation.endDate instanceof Date) {
|
|
|
+ $scope.item.quotation.endDate = $scope.item.quotation.endDate.getTime();
|
|
|
+ }
|
|
|
+ Quotation.save({}, $scope.item, function(data){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('success', '成功', '保存成功');
|
|
|
+ if($stateParams.id)
|
|
|
+ window.location.reload();
|
|
|
+ else
|
|
|
+ window.location.hash = '#/sale/quotation/' + data.id;
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '保存失败', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ // 更新
|
|
|
+ $scope.update = function(){
|
|
|
+ $scope.item.$editing = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 取消
|
|
|
+ $scope.cancel = function(){
|
|
|
+ $scope.item.$editing = false;
|
|
|
+ $scope.item = angular.copy(staticItem);
|
|
|
+ };
|
|
|
+
|
|
|
+ // 提交
|
|
|
+ $scope.submit = function(){
|
|
|
+ $scope.loading = true;
|
|
|
+ $scope.item.quotation.status = 101;//在录入
|
|
|
+ Quotation.save({}, $scope.item, function(data){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('success', '成功', '提交成功');
|
|
|
+ window.location.hash = '#/sale/quotation/' + data.id;
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '保存失败', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // 查找客户
|
|
|
+ app.controller('DbfindCustCtrl', ['$scope', 'Customer', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', function($scope, Customer, BaseService, ngTableParams, toaster, $modalInstance){
|
|
|
+ $scope.customerParams = new ngTableParams({
|
|
|
+ page : 1,
|
|
|
+ count : 10
|
|
|
+ }, {
|
|
|
+ total : 0,
|
|
|
+ counts: [5, 10, 25, 50],
|
|
|
+ getData : function($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ Customer.get(BaseService.parseParams(params.url()), function(page){
|
|
|
+ $scope.loading = false;
|
|
|
+ if(page) {
|
|
|
+ params.total(page.totalElements);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ }
|
|
|
+ $scope.totalCount = page.totalElements;
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.cancel = function() {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.check = function(cust){
|
|
|
+ $modalInstance.close(cust);
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // 查找客户物料
|
|
|
+ app.controller('DbfindCustProdCtrl', ['$scope', 'Product', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'custUU', function($scope, Product, BaseService, ngTableParams, toaster, $modalInstance, custUU){
|
|
|
+ $scope.customerParams = 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.keyword = $scope.keyword;
|
|
|
+ pageParams.custUU = custUU;
|
|
|
+ Product.get.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.cancel = function() {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 选择
|
|
|
+ $scope.check = function(cust){
|
|
|
+ $modalInstance.close(cust);
|
|
|
+ };
|
|
|
+
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function() {
|
|
|
+ $scope.customerParams.reload();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // 发货提醒
|
|
|
app.controller('SaleNoticeCtrl', ['$scope', '$rootScope', '$filter', 'PurcNotice', 'ngTableParams', 'toaster', 'BaseService', 'PurcNoticeHis', '$modal', 'SaleTruck', 'Symbol', function($scope, $rootScope, $filter, PurcNotice, ngTableParams, toaster, BaseService, PurcNoticeHis, $modal, SaleTruck, Symbol){
|
|
|
$scope.active = 'todo';
|
|
|
$scope.dateZoneText = '一个月内';
|