|
|
@@ -31,6 +31,18 @@ define(['app/app'], function (app) {
|
|
|
deadline: true
|
|
|
};
|
|
|
|
|
|
+ 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.nowDate = new Date();
|
|
|
|
|
|
$scope.deadDate = new Date();
|
|
|
@@ -47,11 +59,46 @@ define(['app/app'], function (app) {
|
|
|
return $scope.validObj.brand;
|
|
|
}
|
|
|
$scope.checkUnitPrice = function () {
|
|
|
- $scope.validObj.unitPrice = $scope.applyObj.unitPrice === '' ? true
|
|
|
+ $scope.validObj.unitPrice = ($scope.applyObj.unitPrice === '' || !$scope.applyObj.unitPrice ) ? true
|
|
|
: $scope.applyObj.unitPrice > 0 && $scope.applyObj.unitPrice
|
|
|
< 100000000;
|
|
|
return $scope.validObj.unitPrice;
|
|
|
}
|
|
|
+ $scope.onUnitPriceInput = function () {
|
|
|
+ var price = $scope.applyObj.unitPrice;
|
|
|
+ if (angular.isNumber(price)) {
|
|
|
+ if (price >= 9999) {
|
|
|
+ $scope.applyObj.unitPrice = Number(price.toString().substring(0, 4));
|
|
|
+ } else if (price.toString().indexOf('.') > -1) {
|
|
|
+ var arr = price.toString().split(".");
|
|
|
+ if (arr[0].length > 4) {
|
|
|
+ $scope.applyObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1]);
|
|
|
+ } else if (arr[1].length > 6) {
|
|
|
+ $scope.applyObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.onEncapsulationChange = function () {
|
|
|
+ if ($scope.applyObj.encapsulation && getRealLen($scope.applyObj.encapsulation) > 20) {
|
|
|
+ $scope.applyObj.encapsulation = $scope.applyObj.encapsulation.substring(0, $scope.applyObj.encapsulation.length - 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.onCodeChange = function () {
|
|
|
+ if ($scope.applyObj.code && getRealLen($scope.applyObj.code) > 30) {
|
|
|
+ $scope.applyObj.code = $scope.applyObj.code.substring(0, $scope.applyObj.code.length - 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.onBrandChange = function () {
|
|
|
+ if ($scope.applyObj.brand && getRealLen($scope.applyObj.brand) > 20) {
|
|
|
+ $scope.applyObj.brand = $scope.applyObj.brand.substring(0, $scope.applyObj.brand.length - 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.onProduceDateChange = function () {
|
|
|
+ if ($scope.sayPriceObj.produceDate && getRealLen($scope.sayPriceObj.produceDate) > 12) {
|
|
|
+ $scope.sayPriceObj.produceDate = $scope.sayPriceObj.produceDate.substring(0, $scope.sayPriceObj.produceDate.length - 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
$scope.checkAmount = function () {
|
|
|
$scope.validObj.amount = $scope.applyObj.amount === '' ? true
|
|
|
: $scope.applyObj.amount > 0 && $scope.applyObj.amount
|
|
|
@@ -87,7 +134,15 @@ define(['app/app'], function (app) {
|
|
|
toaster.pop('error', res.data);
|
|
|
});
|
|
|
} else {
|
|
|
- toaster.pop('error', '请输入正确的信息');
|
|
|
+ if (!$scope.validObj.code) {
|
|
|
+ toaster.pop('error', '型号不能为空');
|
|
|
+ } else if (!$scope.validObj.brand) {
|
|
|
+ toaster.pop('error', '品牌不能为空');
|
|
|
+ } else if (!$scope.validObj.deadline) {
|
|
|
+ toaster.pop('error', '截止日期不能为空');
|
|
|
+ } else if (!$scope.validObj.amount || !$scope.validObj.unitPrice) {
|
|
|
+ toaster.pop('error', '请输入正确的数值');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -398,12 +453,12 @@ define(['app/app'], function (app) {
|
|
|
newNum = parseInt(newNum);
|
|
|
if (breakUp) {
|
|
|
if (newNum < buy) {
|
|
|
- toaster.pop('error', '最小起订量为' + buy);
|
|
|
+ toaster.pop('info', '提示', '最小起订量为' + buy);
|
|
|
$scope.fragments[index].num = buy;
|
|
|
$scope.fragments[index].canSub = false;
|
|
|
$scope.fragments[index].canAdd = true;
|
|
|
} else if (newNum > reserve) {
|
|
|
- // $scope.$message.error('库存不足')
|
|
|
+ toaster.pop('info', '提示', '库存不足');
|
|
|
$scope.fragments[index].num = reserve;
|
|
|
$scope.fragments[index].canAdd = false;
|
|
|
$scope.fragments[index].canSub = true;
|
|
|
@@ -417,26 +472,25 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
} else {
|
|
|
if (newNum < buy) {
|
|
|
- toaster.pop('error', '最小起订量为' + buy);
|
|
|
+ toaster.pop('info', '提示', '最小起订量为' + buy);
|
|
|
$scope.fragments[index].num = buy;
|
|
|
$scope.fragments[index].canSub = false;
|
|
|
if (newNum > reserve) {
|
|
|
- toaster.pop('error', '库存不足');
|
|
|
+ toaster.pop('info', '提示', '库存不足');
|
|
|
$scope.fragments[index].num = reserve - (reserve % pack);
|
|
|
$scope.fragments[index].canAdd = false;
|
|
|
}
|
|
|
} else if (newNum > reserve) {
|
|
|
$scope.fragments[index].canSub = true;
|
|
|
$scope.fragments[index].canAdd = false;
|
|
|
- toaster.pop('error', '库存不足');
|
|
|
+ toaster.pop('info', '提示', '库存不足');
|
|
|
$scope.fragments[index].num = reserve - (reserve % pack);
|
|
|
} else {
|
|
|
$scope.fragments[index].canSub = true;
|
|
|
$scope.fragments[index].canAdd = true;
|
|
|
var remainder = newNum % pack;
|
|
|
if (remainder !== 0) {
|
|
|
- toaster.pop('error', '不支持拆包且包装量为' + pack);
|
|
|
- // 这个直接赋值的,应该给这个值进行判断(Math.floor(newNum / pack) + 1) * pack
|
|
|
+ toaster.pop('info', '提示', '不支持拆包且包装量为' + pack);
|
|
|
var res = (Math.floor(newNum / pack) + 1) * pack;
|
|
|
$scope.fragments[index].num = res > reserve
|
|
|
? Math.floor(newNum / pack) * pack : res;
|
|
|
@@ -463,6 +517,8 @@ define(['app/app'], function (app) {
|
|
|
$scope.changeNum(newNum, index)
|
|
|
getFragment($scope.goods[index], $scope.fragments[index]);
|
|
|
$scope.onInput(index);
|
|
|
+ } else {
|
|
|
+ toaster.pop('info', '提示', '该商品最少购买' + $scope.goods[index].minBuyQty + '件');
|
|
|
}
|
|
|
}
|
|
|
$scope.addNum = function (index) {
|
|
|
@@ -478,6 +534,8 @@ define(['app/app'], function (app) {
|
|
|
$scope.changeNum(newNum, index)
|
|
|
getFragment($scope.goods[index], $scope.fragments[index]);
|
|
|
$scope.onInput(index);
|
|
|
+ } else {
|
|
|
+ toaster.pop('info', '提示', '库存不足');
|
|
|
}
|
|
|
}
|
|
|
$scope.inputNum = function (index) {
|
|
|
@@ -485,7 +543,7 @@ define(['app/app'], function (app) {
|
|
|
$scope.changeNum($scope.fragments[index].num, index);
|
|
|
getFragment($scope.goods[index], $scope.fragments[index]);
|
|
|
} else {
|
|
|
- toaster.pop('error', '请输入整数');
|
|
|
+ toaster.pop('info', '提示', '请输入整数');
|
|
|
$scope.fragments[index].num = $scope.goods[index].minBuyQty;
|
|
|
}
|
|
|
$scope.onInput(index);
|