|
|
@@ -7,7 +7,25 @@ define(['app/app'], function (app) {
|
|
|
document.title = '求购询价-优软商城';
|
|
|
$rootScope.active = 'vendor_seek_purchase';
|
|
|
$scope.seekPurchaseRate = {};
|
|
|
- $scope.inquiryItem = {};
|
|
|
+
|
|
|
+ $scope.initInquiryItem = function () {
|
|
|
+ $scope.inquiryItem = {
|
|
|
+ currency: 'RMB',
|
|
|
+ leadtime: '',
|
|
|
+ replies: [
|
|
|
+ {
|
|
|
+ lapQty: '',
|
|
|
+ price: ''
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ $scope.validSayPrice = {
|
|
|
+ leadtime: false,
|
|
|
+ repliesPrice: false,
|
|
|
+ repliesLapQty: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.initInquiryItem();
|
|
|
|
|
|
// 获取当前卖家求购推送列表
|
|
|
$scope.seekPurchaseTableParams = new ngTableParams({
|
|
|
@@ -48,8 +66,6 @@ define(['app/app'], function (app) {
|
|
|
$scope.seekPurchaseTableParams.reload();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
$scope.validOffer = {
|
|
|
unitPrice: false,
|
|
|
minDay: false,
|
|
|
@@ -148,25 +164,21 @@ define(['app/app'], function (app) {
|
|
|
return $scope.validOffer.unitPrice && $scope.validOffer.minDay && $scope.validOffer.maxDay;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- // 删除一列分段报价
|
|
|
- $scope.removeStep = function (inquiryItem, stepIndex) {
|
|
|
- inquiryItem.replies.splice(stepIndex, 1);
|
|
|
- $scope.replyPrices.splice(stepIndex, 1);
|
|
|
- $scope.replylapQtys.splice(stepIndex, 1);
|
|
|
- };
|
|
|
-
|
|
|
// 保存报价
|
|
|
$scope.saveOfferBtn = false;
|
|
|
$scope.saveOffer = function () {
|
|
|
- $scope.inquiryItem.vendUU = $scope.userInfo.enterprise.uu;
|
|
|
- $scope.inquiryItem.vendUserUU = $scope.userInfo.userUU;
|
|
|
- seekPurchase.saveOffer($scope.inquiryItem,function(){
|
|
|
- toaster.pop('success', '报价成功');
|
|
|
- $scope.isShowSayPriceBox = false;
|
|
|
- }, function (response) {
|
|
|
- toaster.pop('error', response.data.message);
|
|
|
- });
|
|
|
+ if ($scope.checkValid()) {
|
|
|
+ $scope.inquiryItem.vendUU = $scope.userInfo.enterprise.uu;
|
|
|
+ $scope.inquiryItem.vendUserUU = $scope.userInfo.userUU;
|
|
|
+ seekPurchase.saveOffer($scope.inquiryItem, function () {
|
|
|
+ toaster.pop('success', '报价成功');
|
|
|
+ $scope.isShowSayPriceBox = false;
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', response.data.detailedMessage);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', '请输入正确的报价信息');
|
|
|
+ }
|
|
|
// if ($scope.checkAllOffer()) {
|
|
|
// $scope.saveOfferBtn = true;
|
|
|
// seekPurchase.saveOffer($scope.offer, function (data) {
|
|
|
@@ -291,10 +303,118 @@ define(['app/app'], function (app) {
|
|
|
currency: seek.currency ? seek.currency : "RMB",
|
|
|
spId: seek.spId
|
|
|
}
|
|
|
+ } else {
|
|
|
+ $scope.initInquiryItem();
|
|
|
}
|
|
|
//seek.$active = flag;
|
|
|
- $scope.inquiryItem = seek;
|
|
|
$scope.isShowSayPriceBox = flag;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ $scope.onLeadtimeInput = function () {
|
|
|
+ if ($scope.inquiryItem.leadtime.length > 2) {
|
|
|
+ $scope.inquiryItem.leadtime = $scope.inquiryItem.leadtime.substring(0, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.onLeadtimeBlur = function () {
|
|
|
+ if (!$scope.inquiryItem.leadtime || $scope.inquiryItem.leadtime < 1 || $scope.inquiryItem.leadtime > 31 || $scope.inquiryItem.leadtime.toString().indexOf('.') !== -1) {
|
|
|
+ $scope.validSayPrice.leadtime = false;
|
|
|
+ toaster.pop('error', '交期只能填写1-31之间的整数值');
|
|
|
+ } else {
|
|
|
+ $scope.validSayPrice.leadtime = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.onReplyLapQtyBlur = function (index) {
|
|
|
+ var lapQty = $scope.inquiryItem.replies[index].lapQty;
|
|
|
+ var limitDownObj = $scope.getLimitDownQty();
|
|
|
+ if (!lapQty || lapQty < 1) {
|
|
|
+ $scope.inquiryItem.replies[index].lapQty = '';
|
|
|
+ toaster.pop('error', '输入值必须为正整数');
|
|
|
+ $scope.validSayPrice.repliesLapQty = false;
|
|
|
+ } else if (limitDownObj.index !== index && limitDownObj.lapQty > lapQty) {
|
|
|
+ toaster.pop('error', '输入值必须大于#该梯度的下限#');
|
|
|
+ $scope.inquiryItem.replies[index].lapQty = '';
|
|
|
+ $scope.validSayPrice.repliesLapQty = false;
|
|
|
+ } else if ((index - 1 >= 0 && $scope.inquiryItem.replies[index - 1].lapQty && $scope.inquiryItem.replies[index - 1].lapQty >= lapQty) || (index + 1 < $scope.inquiryItem.replies.length && $scope.inquiryItem.replies[index + 1].lapQty && $scope.inquiryItem.replies[index + 1].lapQty <= lapQty)) {
|
|
|
+ toaster.pop('error', '输入值会导致梯度重叠,请重新修改');
|
|
|
+ $scope.inquiryItem.replies[index].lapQty = '';
|
|
|
+ $scope.validSayPrice.repliesLapQty = false;
|
|
|
+ } else {
|
|
|
+ $scope.validSayPrice.repliesLapQty = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.getLimitDownQty = function () {
|
|
|
+ for (var i = 0; i < $scope.inquiryItem.replies.length; i++) {
|
|
|
+ if ($scope.inquiryItem.replies[i].lapQty) {
|
|
|
+ return {
|
|
|
+ lapQty: $scope.inquiryItem.replies[i].lapQty,
|
|
|
+ index: i
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {index: -1};
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.onReplyPriceInput = function (index) {
|
|
|
+ var price = $scope.inquiryItem.replies[index].price;
|
|
|
+ if (price >= 10000) {
|
|
|
+ $scope.inquiryItem.replies[index].price = price.substring(0, 4);
|
|
|
+ } else if (price.indexOf('.') > -1) {
|
|
|
+ var arr = price.split('.');
|
|
|
+ if (arr[0].length > 4) {
|
|
|
+ $scope.inquiryItem.replies[index].price = Number(arr[0].substring(0, 4) + '.' + arr[1]);
|
|
|
+ } else if (arr[1].length > 6) {
|
|
|
+ $scope.inquiryItem.replies[index].price = Number(arr[0] + '.' + arr[1].substring(0, 6));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.onReplyPriceBlur = function (index) {
|
|
|
+ var price = $scope.inquiryItem.replies[index].price;
|
|
|
+ var limitDownObj = $scope.getLimitDownPrice();
|
|
|
+ if (!price || price <= 0) {
|
|
|
+ $scope.inquiryItem.replies[index].price = '';
|
|
|
+ toaster.pop('error', '输入值必须为正整数');
|
|
|
+ $scope.validSayPrice.repliesPrice = false;
|
|
|
+ } else if (limitDownObj.index !== index && limitDownObj.price > price) {
|
|
|
+ toaster.pop('error', '输入值必须大于#该梯度的下限#');
|
|
|
+ $scope.inquiryItem.replies[index].price = '';
|
|
|
+ $scope.validSayPrice.repliesPrice = false;
|
|
|
+ } else if ((index - 1 >= 0 && $scope.inquiryItem.replies[index - 1].price && $scope.inquiryItem.replies[index - 1].price >= price) || (index + 1 < $scope.inquiryItem.replies.length && $scope.inquiryItem.replies[index + 1].price && $scope.inquiryItem.replies[index + 1].price <= price)) {
|
|
|
+ toaster.pop('error', '输入值会导致梯度重叠,请重新修改');
|
|
|
+ $scope.inquiryItem.replies[index].price = '';
|
|
|
+ $scope.validSayPrice.repliesPrice = false;
|
|
|
+ } else {
|
|
|
+ $scope.validSayPrice.repliesPrice = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.getLimitDownPrice = function () {
|
|
|
+ for (var i = 0; i < $scope.inquiryItem.replies.length; i++) {
|
|
|
+ if ($scope.inquiryItem.replies[i].price) {
|
|
|
+ return {
|
|
|
+ price: $scope.inquiryItem.replies[i].price,
|
|
|
+ index: i
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {index: -1};
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.checkValid = function () {
|
|
|
+ return $scope.validSayPrice.leadtime && $scope.validSayPrice.repliesLapQty && $scope.validSayPrice.repliesPrice;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.setReplies = function (type, index) {
|
|
|
+ if (type === 'add' && $scope.inquiryItem.replies.length < 5) {
|
|
|
+ $scope.inquiryItem.replies.splice(index + 1, 0, {
|
|
|
+ lapQty: '',
|
|
|
+ price: ''
|
|
|
+ });
|
|
|
+ } else if (type === 'sub' && $scope.inquiryItem.replies.length > 1) {
|
|
|
+ $scope.inquiryItem.replies.splice(index, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
}]);
|
|
|
});
|