|
|
@@ -33,19 +33,43 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
$scope.isEditName = flag;
|
|
|
}
|
|
|
-
|
|
|
- $scope.saveBomName = function () {
|
|
|
- seekPurchase.saveBomName({id: $scope.bomInfo.bomId, name: $scope.bomName}, function (data) {
|
|
|
- if (data.success) {
|
|
|
- toaster.pop('success', '修改成功');
|
|
|
- $scope.bomInfo.name = $scope.bomName;
|
|
|
- $scope.setIsEditName(false);
|
|
|
+
|
|
|
+ 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 {
|
|
|
- toaster.pop('error', data.message);
|
|
|
+ len++;
|
|
|
}
|
|
|
- }, function (response) {
|
|
|
- toaster.pop('error', response.data);
|
|
|
- })
|
|
|
+ }
|
|
|
+ return len;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.onBomNameChange = function () {
|
|
|
+ if (getRealLen($scope.bomName) > 40) {
|
|
|
+ $scope.bomName = $scope.bomName.substring(0, $scope.bomName.length - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.saveBomName = function () {
|
|
|
+ if (!$scope.bomName.length) {
|
|
|
+ toaster.pop('info', 'bom名称不能为空');
|
|
|
+ } else if (getRealLen($scope.bomName) > 40) {
|
|
|
+ toaster.pop('info', 'bom名称不能超过40个字符');
|
|
|
+ } else {
|
|
|
+ seekPurchase.saveBomName({id: $scope.bomInfo.bomId, name: $scope.bomName}, function (data) {
|
|
|
+ if (data.success) {
|
|
|
+ toaster.pop('success', '修改成功');
|
|
|
+ $scope.bomInfo.name = $scope.bomName;
|
|
|
+ $scope.setIsEditName(false);
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', data.message);
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', response.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
var enIdFilter = $filter('EncryptionFilter');
|