|
@@ -63,13 +63,18 @@ define(['app/app'], function (app) {
|
|
|
$scope.deadDate.setMonth($scope.deadDate.getMonth() + 3);
|
|
$scope.deadDate.setMonth($scope.deadDate.getMonth() + 3);
|
|
|
|
|
|
|
|
$scope.checkCode = function () {
|
|
$scope.checkCode = function () {
|
|
|
- $scope.validObj.code = $scope.applyObj.code && $scope.applyObj.code
|
|
|
|
|
- !== '';
|
|
|
|
|
|
|
+ $scope.validObj.code = $scope.applyObj.code && $scope.applyObj.code !== '';
|
|
|
|
|
+ if (!$scope.validObj.code) {
|
|
|
|
|
+ toaster.pop('error', '型号不能为空');
|
|
|
|
|
+ }
|
|
|
return this.validObj.code;
|
|
return this.validObj.code;
|
|
|
}
|
|
}
|
|
|
$scope.checkBrand = function () {
|
|
$scope.checkBrand = function () {
|
|
|
$scope.validObj.brand = $scope.applyObj.brand
|
|
$scope.validObj.brand = $scope.applyObj.brand
|
|
|
&& $scope.applyObj.brand !== '';
|
|
&& $scope.applyObj.brand !== '';
|
|
|
|
|
+ if (!$scope.validObj.brand) {
|
|
|
|
|
+ toaster.pop('error', '品牌不能为空');
|
|
|
|
|
+ }
|
|
|
return $scope.validObj.brand;
|
|
return $scope.validObj.brand;
|
|
|
}
|
|
}
|
|
|
$scope.checkUnitPrice = function () {
|
|
$scope.checkUnitPrice = function () {
|
|
@@ -97,23 +102,52 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$scope.onAmountChange = function () {
|
|
$scope.onAmountChange = function () {
|
|
|
- if ($scope.applyObj.amount.length > 8 || !(/^[0-9]*$/).test($scope.applyObj.amount)) {
|
|
|
|
|
- $scope.applyObj.amount = $scope.applyObj.amount.substring(0, $scope.applyObj.amount.length - 1)
|
|
|
|
|
|
|
+ if (!(/^[0-9]*$/).test($scope.applyObj.amount)) {
|
|
|
|
|
+ var chineseIndex = -1;
|
|
|
|
|
+ for (var i = 0; i < $scope.applyObj.amount.length; i++) {
|
|
|
|
|
+ if (!(/^[0-9]*$/).test($scope.applyObj.amount.charAt(i))) {
|
|
|
|
|
+ chineseIndex = i;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $scope.applyObj.amount = cutOutString($scope.applyObj.amount, chineseIndex);
|
|
|
|
|
+ } else if ($scope.applyObj.amount.length > 8) {
|
|
|
|
|
+ $scope.applyObj.amount = cutOutString($scope.applyObj.amount, 8);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$scope.onEncapsulationChange = function () {
|
|
$scope.onEncapsulationChange = function () {
|
|
|
if ($scope.applyObj.encapsulation && getRealLen($scope.applyObj.encapsulation) > 20) {
|
|
if ($scope.applyObj.encapsulation && getRealLen($scope.applyObj.encapsulation) > 20) {
|
|
|
- $scope.applyObj.encapsulation = $scope.applyObj.encapsulation.substring(0, $scope.applyObj.encapsulation.length - 1)
|
|
|
|
|
|
|
+ $scope.applyObj.encapsulation = cutOutString($scope.applyObj.encapsulation, 20);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$scope.onCodeChange = function () {
|
|
$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.applyObj.code = $scope.applyObj.code.trim();
|
|
|
|
|
+ if ((/[^\x00-\xff]/g).test($scope.applyObj.code)) {
|
|
|
|
|
+ var chineseIndex = -1;
|
|
|
|
|
+ for (var i = 0; i < $scope.applyObj.code.length; i++) {
|
|
|
|
|
+ if ((/[^\x00-\xff]/g).test($scope.applyObj.code.charAt(i))) {
|
|
|
|
|
+ chineseIndex = i;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $scope.applyObj.code = cutOutString($scope.applyObj.code, chineseIndex);
|
|
|
|
|
+ } else if ($scope.applyObj.code && getRealLen($scope.applyObj.code) > 100) {
|
|
|
|
|
+ $scope.applyObj.code = cutOutString($scope.applyObj.code, 100);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$scope.onBrandChange = function () {
|
|
$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.applyObj.brand = $scope.applyObj.brand.trim();
|
|
|
|
|
+ if ((/[^\x00-\xff]/g).test($scope.applyObj.brand)) {
|
|
|
|
|
+ var chineseIndex = -1;
|
|
|
|
|
+ for (var i = 0; i < $scope.applyObj.brand.length; i++) {
|
|
|
|
|
+ if ((/[^\x00-\xff]/g).test($scope.applyObj.brand.charAt(i))) {
|
|
|
|
|
+ chineseIndex = i;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $scope.applyObj.brand = cutOutString($scope.applyObj.brand, chineseIndex);
|
|
|
|
|
+ } else if ($scope.applyObj.brand && getRealLen($scope.applyObj.brand) > 50) {
|
|
|
|
|
+ $scope.applyObj.brand = cutOutString($scope.applyObj.brand, 50);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$scope.onProduceDateChange = function () {
|
|
$scope.onProduceDateChange = function () {
|