|
|
@@ -169,6 +169,18 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
url : "/purcinquiry",
|
|
|
templateUrl : "static/tpl/index/purc/inquiry_new.html",
|
|
|
controller: 'PurcInquiryCtrl'
|
|
|
+ }).state('purc.inquiry', {
|
|
|
+ url : "/purchaseinquiry",
|
|
|
+ templateUrl : "static/tpl/index/purc/inquiry.html",
|
|
|
+ controller: 'PurchaseInquiryCtrl'
|
|
|
+ }).state('purc.inquiry_detail', {
|
|
|
+ url : "/purcinquirydetail",
|
|
|
+ templateUrl : "static/tpl/index/purc/inquiry_detail.html",
|
|
|
+ controller: 'PurcInquiryDetailCtrl'
|
|
|
+ }).state('purc.inquiry_unapply', {
|
|
|
+ url : "/inquiry_unapply",
|
|
|
+ templateUrl : "static/tpl/index/purc/inquiry_unapply.html",
|
|
|
+ controller: 'UnapplyInquiryCtrl'
|
|
|
}).state('sale.tenderlist', {
|
|
|
url : "/tender",
|
|
|
templateUrl : "static/tpl/index/sale/tenderlist.html",
|
|
|
@@ -803,7 +815,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
/**
|
|
|
* 顶部搜索
|
|
|
*/
|
|
|
- app.controller('TopSearchCtrl', ['$scope', '$rootScope', 'getAccountUserSpace', 'ngTableParams', 'toaster', 'BaseService', 'AddPartner', '$filter', '$stateParams', 'SearchProd', '$sce', function($scope, $rootScope, getAccountUserSpace, ngTableParams, toaster, BaseService, AddPartner, $filter, $stateParams, SearchProd, $sce) {
|
|
|
+ app.controller('TopSearchCtrl', ['$scope', '$rootScope', 'getAccountUserSpace', 'ngTableParams', 'toaster', 'BaseService', 'AddPartner', '$filter', '$stateParams', 'SearchProd', '$sce', '$modal', 'InvitationRecord', function($scope, $rootScope, getAccountUserSpace, ngTableParams, toaster, BaseService, AddPartner, $filter, $stateParams, SearchProd, $sce, $modal, InvitationRecord) {
|
|
|
BaseService.scrollBackToTop();
|
|
|
$scope.active = 'all';
|
|
|
$scope.tip = $rootScope.searchKeyword;
|
|
|
@@ -901,6 +913,47 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
$rootScope.prodId = id;
|
|
|
window.location.hash = "#/purc/addOrder";
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 邀请注册商务平台
|
|
|
+ */
|
|
|
+ $scope.invite = function(name) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
|
|
|
+ controller: 'InviteCtrl',
|
|
|
+ resolve: {
|
|
|
+ enname: function(){return name}
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function(data) {
|
|
|
+ InvitationRecord.invite({formStore: data}, {}, function(data) {
|
|
|
+ if(data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ }
|
|
|
+ if(data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.controller('InviteCtrl', ['$scope', 'toaster', '$modalInstance', 'enname', function($scope, toaster, $modalInstance, enname) {
|
|
|
+ $scope.enter = {
|
|
|
+ vendname: enname
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.save = function(enter) {
|
|
|
+ $modalInstance.close(enter);
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.cancel = function() {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ }
|
|
|
}]);
|
|
|
|
|
|
app.controller('AuthCtrl', ['$scope', '$window', 'AuthenticationService', 'toaster', 'BaseService', '$modal', function($scope, $window, AuthenticationService, toaster, BaseService, $modal) {
|
|
|
@@ -2484,7 +2537,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
}]);
|
|
|
|
|
|
// 平台新增的询价单
|
|
|
- app.controller('PurcInquiryCtrl', ['$scope', 'PurchaseInquiry', 'toaster', 'BaseService', '$upload', '$filter', '$modal', '$rootScope', 'ngTableParams', 'GetProductInfo', function($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, GetProductInfo) {
|
|
|
+ app.controller('PurcInquiryCtrl', ['$scope', 'PurchaseInquiry', 'toaster', 'BaseService', '$upload', '$filter', '$modal', '$rootScope', 'ngTableParams', 'GetProductInfo', '$timeout', function($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, GetProductInfo, $timeout) {
|
|
|
BaseService.scrollBackToTop();
|
|
|
$scope.active = 'all';
|
|
|
var getService = function() {
|
|
|
@@ -2627,22 +2680,291 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
|
|
|
// toaster.pop('error', '操作失败', data.error);
|
|
|
// });
|
|
|
PurchaseInquiry.save({inquiry: $scope.inquiry}, $scope.vendors, function(data) {
|
|
|
-
|
|
|
+ if(data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ $timeout(function() {
|
|
|
+ window.loaction.hash = "#/purc/inquiry_unapply";
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ if(data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
}, function(response) {
|
|
|
-
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 保存并提交
|
|
|
$scope.submit = function() {
|
|
|
PurchaseInquiry.submit({inquiry: $scope.inquiry}, $scope.vendors, function(data) {
|
|
|
-
|
|
|
+ if(data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ $timeout(function() {
|
|
|
+ window.loaction.hash = "#/purc/purchaseinquiry";
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ if(data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
}, function(response) {
|
|
|
-
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
});
|
|
|
}
|
|
|
}]);
|
|
|
|
|
|
+ // 平台询价单(已提交)
|
|
|
+ app.controller('PurchaseInquiryCtrl', ['$scope', '$filter', 'ngTableParams', 'toaster', 'BaseService', 'PurchaseInquiry', function($scope, $filter, ngTableParams, toaster, BaseService, PurchaseInquiry) {
|
|
|
+
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+ $scope.active = 'todo';
|
|
|
+ $scope.agreedText = '全部';
|
|
|
+ $scope.dateZoneText = '一个月内';
|
|
|
+ $scope.condition = {dateZone: 1};
|
|
|
+ $scope.changeAgreed = function(agreed) {
|
|
|
+ $scope.condition.agreed = agreed;
|
|
|
+ $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
|
|
|
+ $scope.condition.$agreedOpen = false;
|
|
|
+ };
|
|
|
+ $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 PurchaseInquiry;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page : 1,
|
|
|
+ count : 5,
|
|
|
+ sorting: {
|
|
|
+ 'inquiry.date': 'desc',
|
|
|
+ 'inquiry.enterprise.enName': 'asc',
|
|
|
+ 'inquiry.code': 'asc'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total : 0,
|
|
|
+ counts: [5, 10, 25, 50],
|
|
|
+ getData : function($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ var realActive = {};
|
|
|
+ pageParams.keyword = $scope.keyword;
|
|
|
+ if ($scope.active == 'overdue') {
|
|
|
+ $scope.active = 'end';
|
|
|
+ }
|
|
|
+ getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
|
|
|
+ $scope.loading = false;
|
|
|
+ if(page) {
|
|
|
+ params.total(page.totalElement);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
|
|
|
+ }
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.openDatePicker = function($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ };
|
|
|
+
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function() {
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 采纳
|
|
|
+ $scope.accept = function(id) {
|
|
|
+ PurchaseInquiry.accept({id: id}, {}, function(data) {
|
|
|
+ if(data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ }
|
|
|
+ if(data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
+
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ // 拒绝
|
|
|
+ $scope.refuse = function(id) {
|
|
|
+ PurchaseInquiry.refuse({id: id}, {}, function(data) {
|
|
|
+ if(data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ }
|
|
|
+ if(data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // 平台询价单(未提交)
|
|
|
+ app.controller('UnapplyInquiryCtrl', ['$scope', 'PurchaseInquiry', 'ngTableParams', 'BaseService', 'toaster', function($scope, PurchaseInquiry, ngTableParams, BaseService, toaster) {
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page : 1,
|
|
|
+ count : 5,
|
|
|
+ sorting: {
|
|
|
+ 'inquiry.date': 'desc',
|
|
|
+ 'inquiry.enterprise.enName': 'asc',
|
|
|
+ 'inquiry.code': 'asc'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total : 0,
|
|
|
+ counts: [5, 10, 25, 50],
|
|
|
+ getData : function($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ var realActive = {};
|
|
|
+ if ($scope.active == 'overdue') {
|
|
|
+ $scope.active = 'end';
|
|
|
+ }
|
|
|
+ PurchaseInquiry.getUnapply(null, BaseService.parseParams(pageParams), function(page){
|
|
|
+ $scope.loading = false;
|
|
|
+ if(page) {
|
|
|
+ params.total(page.totalElements);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ }
|
|
|
+ }, function(response){
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 删除明细
|
|
|
+ $scope.deleteById = function(id) {
|
|
|
+ PurchaseInquiry.deleteById({id: id}, {}, function(data) {
|
|
|
+ toaster.pop('success', '提示', '删除成功');
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除主表
|
|
|
+ $scope.clearOrder = function(id) {
|
|
|
+ PurchaseInquiry.clearOrder({id: id}, {}, function(data) {
|
|
|
+ toaster.pop('success', '提示', '删除成功');
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提交
|
|
|
+ $scope.submit = function(id) {
|
|
|
+ PurchaseInquiry.submitUnapply({id: id}, {}, function(data) {
|
|
|
+ toaster.pop('success', '提示', '单据提交成功');
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+ // 询价单明细
|
|
|
+ app.controller('PurcInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry','$filter', 'toaster', function($scope, $stateParams, PurcInquiry,$filter, toaster){
|
|
|
+ var loadData = function() {
|
|
|
+ PurcInquiry.getAll({id: $stateParams.id}, function(data){
|
|
|
+ $scope.newinquiryItems = data;
|
|
|
+ var inquiry = data[0].inquiry;
|
|
|
+ //inquiry.inquiryItems = data;
|
|
|
+ angular.forEach(inquiry.attachs, function(attach){
|
|
|
+ attach.type = attach.name.substr(attach.name.lastIndexOf('.')+1);
|
|
|
+ });
|
|
|
+ $scope.inquiry = inquiry;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ loadData();
|
|
|
+ $scope.getMinDate = function(item) {
|
|
|
+ return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.addStep = function(inquiryItem) {
|
|
|
+ if(inquiryItem.replies.length >= 10) {
|
|
|
+ toaster.pop('warning', '提示', '最多支持10个分段!');
|
|
|
+ } else
|
|
|
+ inquiryItem.replies.push({});
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.removeStep = function(inquiryItem, stepIndex) {
|
|
|
+ inquiryItem.replies.splice(stepIndex, 1);
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.openDatePicker = function($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ };
|
|
|
+
|
|
|
+ $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.onReplyClick = function(item, withSteps) {
|
|
|
+ if(item.vendFromDate instanceof Date) {
|
|
|
+ item.vendFromDate = item.vendFromDate.getTime();
|
|
|
+ }
|
|
|
+ if(item.vendToDate instanceof Date) {
|
|
|
+ item.vendToDate = item.vendToDate.getTime();
|
|
|
+ }
|
|
|
+ if(item.vendFromDate > item.vendToDate) {
|
|
|
+ toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var replies = [];
|
|
|
+ angular.forEach(item.replies, function(r, i){
|
|
|
+ if((i > 0 ? r.lapQty : 1) || r.price)
|
|
|
+ replies.push(r);
|
|
|
+ });
|
|
|
+ item.replies = replies;
|
|
|
+ if(withSteps) {
|
|
|
+ PurcInquiry.reply({itemId: item.id}, item, function(){
|
|
|
+ toaster.pop('info', '提示', '报价成功');
|
|
|
+ loadData();
|
|
|
+ }, function(response){
|
|
|
+ toaster.pop('error', '报价失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
// 模具询价管理
|
|
|
app.controller('SaleInquiryMouldCtrl',['$scope', '$filter', 'PurcInquiryMould', 'ngTableParams', 'toaster', 'BaseService', '$upload', function($scope, $filter, PurcInquiryMould, ngTableParams, toaster, BaseService, $upload){
|
|
|
BaseService.scrollBackToTop();
|