|
|
@@ -2901,6 +2901,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
|
|
|
// 保存
|
|
|
$scope.save = function() {
|
|
|
+ console.log($scope.inquiry);
|
|
|
// var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
|
|
|
// $upload.upload({
|
|
|
// url: 'product/baseInfo/updateProdInfo',
|
|
|
@@ -2921,36 +2922,71 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
// $scope.loadingShow = false;
|
|
|
// 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);
|
|
|
- });
|
|
|
+ if( $scope.vendors.length > 0) { // 指定询价
|
|
|
+ PurchaseInquiry.save({inquiry: $scope.inquiry}, $scope.vendors, function(data) {
|
|
|
+ if(data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ $timeout(function() {
|
|
|
+ window.location.hash = "#/purc/inquiry_unapply";
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ if(data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ PurchaseInquiry.saveWithoutVendor({inquiry: $scope.inquiry}, {}, function(data) {
|
|
|
+ if(data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ $timeout(function() {
|
|
|
+ window.location.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.location.hash = "#/purc/inquiry_unapply";
|
|
|
- }, 500);
|
|
|
- }
|
|
|
- if(data.error) {
|
|
|
- toaster.pop('error', '提示', data.error);
|
|
|
+ if( $scope.isOpen == 0) { // 指定询价
|
|
|
+ if($scope.vendors.length > 0) {
|
|
|
+ PurchaseInquiry.submit({inquiry: $scope.inquiry}, $scope.vendors, function(data) {
|
|
|
+ if(data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ $timeout(function() {
|
|
|
+ window.location.hash = "#/purc/purchaseinquiry";
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ if(data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
- }, function(response) {
|
|
|
- toaster.pop('error', '提示', response.data);
|
|
|
- });
|
|
|
+ } else {
|
|
|
+ PurchaseInquiry.saveAndSubmitWithoutVendor({inquiry: $scope.inquiry}, {}, function(data) {
|
|
|
+ if(data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ $timeout(function() {
|
|
|
+ window.location.hash = "#/purc/purchaseinquiry";
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ if(data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}]);
|
|
|
|