|
|
@@ -38,6 +38,88 @@ define(['app/app'], function (app) {
|
|
|
$scope.seekPurchaseTableParams.reload();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 输入价格校验
|
|
|
+ * */
|
|
|
+ $scope.onUnitPriceBlur = function () {
|
|
|
+ if (angular.isNumber($scope.offer.unitPrice)) {
|
|
|
+ if ($scope.offer.unitPrice < 0) {
|
|
|
+ $scope.offer.unitPrice = 0;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $scope.offer.unitPrice = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.onUnitPriceChange = function () {
|
|
|
+ var price = $scope.offer.unitPrice;
|
|
|
+ if (angular.isNumber(price)) {
|
|
|
+ if (price >= 9999) {
|
|
|
+ $scope.offer.unitPrice = Number(price.toString().substring(0, 4));
|
|
|
+ } else if (price.toString().indexOf('.') > -1) {
|
|
|
+ var arr = price.toString().split(".");
|
|
|
+ if (arr[0].length > 4) {
|
|
|
+ $scope.offer.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1]);
|
|
|
+ } else if (arr[1].length > 6) {
|
|
|
+ $scope.offer.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $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) {
|
|
|
+ toaster.pop('warning', '提示', '交期只能填写1-31之间的值');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.onMinDayChange = function () {
|
|
|
+ if (angular.isNumber($scope.offer.minDay) && $scope.offer.minDay.toString().length > 2) {
|
|
|
+ $scope.offer.minDay = Number($scope.offer.minDay.toString().substring(0, 2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $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', '提示', '最短交期必须小于最长交期');
|
|
|
+ }
|
|
|
+ if ($scope.offer.maxDay < 1 || $scope.offer.maxDay > 31) {
|
|
|
+ toaster.pop('warning', '提示', '交期只能填写1-31之间的值');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.onMaxDayChange = function () {
|
|
|
+ if (angular.isNumber($scope.offer.maxDay) && $scope.offer.maxDay.toString().length > 2) {
|
|
|
+ $scope.offer.maxDay = Number($scope.offer.maxDay.toString().substring(0, 2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var getRealLen = function (str) {
|
|
|
+ var len = 0
|
|
|
+ for (var i = 0; i < str.length; i++) {
|
|
|
+ if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
|
|
|
+ len += 2
|
|
|
+ } else {
|
|
|
+ len++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return len
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.onProduceDateChange = function () {
|
|
|
+ if ($scope.offer.produceDate && getRealLen($scope.offer.produceDate) > 12) {
|
|
|
+ $scope.offer.produceDate = $scope.offer.produceDate.substring(0, $scope.offer.produceDate.length - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 保存报价
|
|
|
$scope.saveOffer = function (seek) {
|
|
|
seekPurchase.saveOffer($scope.offer, function (data) {
|
|
|
@@ -130,7 +212,7 @@ define(['app/app'], function (app) {
|
|
|
seek.$active = flag;
|
|
|
console.info(seek);
|
|
|
if (flag) {
|
|
|
- $scope.offer.currency = seek.currency ? "RMB" : seek.currency;
|
|
|
+ $scope.offer.currency = seek.currency ? seek.currency : "RMB";
|
|
|
$scope.offer.spId = seek.spId;
|
|
|
}
|
|
|
}
|