|
|
@@ -27,6 +27,7 @@ define(['app/app'], function (app) {
|
|
|
seekPurchase.getSeekPushGoodsPageInfo(param, function (data) {
|
|
|
params.total(data.totalElements);
|
|
|
$defer.resolve(data.content);
|
|
|
+ $scope.seekListData = data.content;
|
|
|
}, function (response) {
|
|
|
toaster.pop('error', response.data);
|
|
|
});
|
|
|
@@ -39,16 +40,28 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ $scope.validOffer = {
|
|
|
+ unitPrice: false,
|
|
|
+ minDay: false,
|
|
|
+ maxDay: false
|
|
|
+ // produceDate: true
|
|
|
+ };
|
|
|
+
|
|
|
/*
|
|
|
* 输入价格校验
|
|
|
* */
|
|
|
$scope.onUnitPriceBlur = function () {
|
|
|
if (angular.isNumber($scope.offer.unitPrice)) {
|
|
|
if ($scope.offer.unitPrice < 0) {
|
|
|
- $scope.offer.unitPrice = 0;
|
|
|
+ toaster.pop('warning', '提示', '单价必须是大于0的数字');
|
|
|
+ $scope.validOffer.unitPrice = false;
|
|
|
+ } else {
|
|
|
+ $scope.validOffer.unitPrice = true;
|
|
|
}
|
|
|
} else {
|
|
|
- $scope.offer.unitPrice = 0;
|
|
|
+ toaster.pop('warning', '提示', '单价必须是大于0的数字');
|
|
|
+ $scope.validOffer.unitPrice = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -69,14 +82,14 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
|
|
|
$scope.onMinDayInput = function () {
|
|
|
- $scope.offer.minDay = Math.floor($scope.offer.minDay)
|
|
|
- if ($scope.offer.maxDay && $scope.offer.maxDay < $scope.offer.minDay) {
|
|
|
- $scope.offer.minDay = $scope.offer.maxDay;
|
|
|
- toaster.pop('warning', '提示', '最短交期必须小于最长交期');
|
|
|
- }
|
|
|
- if ($scope.offer.minDay < 1 || $scope.offer.minDay > 31) {
|
|
|
- $scope.offer.minDay = $scope.offer.minDay < 1 ? 1 : 31;
|
|
|
- toaster.pop('warning', '提示', '交期只能填写1-31之间的值');
|
|
|
+ if ($scope.offer.minDay < 1 || $scope.offer.minDay > 31 || $scope.offer.minDay.toString().indexOf('.') !== -1) {
|
|
|
+ $scope.validOffer.minDay = false;
|
|
|
+ toaster.pop('warning', '提示', '交期只能填写1-31之间的整数值');
|
|
|
+ } else if ($scope.offer.maxDay && $scope.offer.maxDay < $scope.offer.minDay) {
|
|
|
+ $scope.validOffer.minDay = false;
|
|
|
+ toaster.pop('warning', '提示', '最短交期应小于等于最长交期');
|
|
|
+ } else {
|
|
|
+ $scope.validOffer.minDay = true;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -87,13 +100,14 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
|
|
|
$scope.onMaxDayInput = function () {
|
|
|
- $scope.offer.maxDay = Math.floor($scope.offer.maxDay)
|
|
|
- if ($scope.offer.minDay && $scope.offer.maxDay < $scope.offer.minDay) {
|
|
|
- $scope.offer.maxDay = $scope.offer.minDay;
|
|
|
- toaster.pop('warning', '提示', '最短交期必须小于最长交期');
|
|
|
- } else if ($scope.offer.maxDay < 1 || $scope.offer.maxDay > 31) {
|
|
|
- $scope.offer.maxDay = $scope.offer.maxDay < 1 ? 1 : 31;
|
|
|
- toaster.pop('warning', '提示', '交期只能填写1-31之间的值');
|
|
|
+ if ($scope.offer.maxDay < 1 || $scope.offer.maxDay > 31 || $scope.offer.maxDay.toString().indexOf('.') !== -1) {
|
|
|
+ $scope.validOffer.maxDay = false;
|
|
|
+ toaster.pop('warning', '提示', '交期只能填写1-31之间的整数值');
|
|
|
+ } else if ($scope.offer.minDay && $scope.offer.maxDay < $scope.offer.minDay) {
|
|
|
+ $scope.validOffer.maxDay = false;
|
|
|
+ toaster.pop('warning', '提示', '最短交期应小于等于最长交期');
|
|
|
+ } else {
|
|
|
+ $scope.validOffer.maxDay = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -121,19 +135,44 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ $scope.checkAllOffer = function () {
|
|
|
+ return $scope.validOffer.unitPrice && $scope.validOffer.minDay && $scope.validOffer.maxDay;
|
|
|
+ }
|
|
|
+
|
|
|
// 保存报价
|
|
|
$scope.saveOffer = function (seek) {
|
|
|
- seekPurchase.saveOffer($scope.offer, function (data) {
|
|
|
- if (data.success) {
|
|
|
- $scope.setSeekActive(seek, false);
|
|
|
- $scope.seekPurchaseTableParams.reload();
|
|
|
- toaster.pop('success', '报价成功');
|
|
|
- } else {
|
|
|
- toaster.pop('error', data.message);
|
|
|
+ if ($scope.checkAllOffer()) {
|
|
|
+ seekPurchase.saveOffer($scope.offer, function (data) {
|
|
|
+ if (data.success) {
|
|
|
+ $scope.setSeekActive(seek, false);
|
|
|
+ $scope.seekPurchaseTableParams.reload();
|
|
|
+ toaster.pop('success', '报价成功');
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', data.message);
|
|
|
+ }
|
|
|
+ }, function (res) {
|
|
|
+ toaster.pop('error', res.data);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (!$scope.validOffer.unitPrice) {
|
|
|
+ if (!$scope.offer.unitPrice) {
|
|
|
+ toaster.pop('warning', '提示', '单价不能为空');
|
|
|
+ } else {
|
|
|
+ toaster.pop('warning', '提示', '单价必须是大于0的数字');
|
|
|
+ }
|
|
|
+ } else if (!$scope.validOffer.minDay || !$scope.validOffer.maxDay) {
|
|
|
+ if (!$scope.offer.minDay || !$scope.offer.maxDay) {
|
|
|
+ toaster.pop('warning', '提示', '交期不能为空');
|
|
|
+ } else {
|
|
|
+ if ($scope.offer.minDay > 31 || $scope.offer.minDay < 1 || $scope.offer.minDay.toString().indexOf('.') !== -1
|
|
|
+ || $scope.offer.maxDay > 31 || $scope.offer.maxDay < 1 || $scope.offer.maxDay.toString().indexOf('.') !== -1) {
|
|
|
+ toaster.pop('warning', '提示', '交期只能填写1-31之间的整数值');
|
|
|
+ } else {
|
|
|
+ toaster.pop('warning', '提示', '最短交期应小于等于最长交期');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }, function (res) {
|
|
|
- toaster.pop('error', res.data);
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$scope.condition = {endDateOpen: false, startDateOpen: false};
|
|
|
@@ -214,12 +253,16 @@ define(['app/app'], function (app) {
|
|
|
|
|
|
/*设置列表状态*/
|
|
|
$scope.setSeekActive = function (seek, flag) {
|
|
|
- seek.$active = flag;
|
|
|
- console.info(seek);
|
|
|
if (flag) {
|
|
|
- $scope.offer.currency = seek.currency ? seek.currency : "RMB";
|
|
|
- $scope.offer.spId = seek.spId;
|
|
|
+ angular.forEach($scope.seekListData, function (item) {
|
|
|
+ item.$active = false;
|
|
|
+ });
|
|
|
+ $scope.offer = {
|
|
|
+ currency: seek.currency ? seek.currency : "RMB",
|
|
|
+ spId: seek.spId
|
|
|
+ }
|
|
|
}
|
|
|
+ seek.$active = flag;
|
|
|
}
|
|
|
}]);
|
|
|
});
|