|
|
@@ -49,7 +49,7 @@ define(['app/app'], function(app) {
|
|
|
angular.forEach($scope.goodsList, function (list) {
|
|
|
list.isChoosed = $scope.isChooseAll;
|
|
|
})
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
// 检查是否全选
|
|
|
var checkChoosedAll = function () {
|
|
|
@@ -67,10 +67,28 @@ define(['app/app'], function(app) {
|
|
|
checkChoosedAll();
|
|
|
};
|
|
|
|
|
|
+ //获取选中之后的信息
|
|
|
+ var getChooseBatch = function () {
|
|
|
+ $scope.choosedBatch = [];
|
|
|
+ angular.forEach($scope.goodsList, function (goods) {
|
|
|
+ if (goods.isChoosed) {
|
|
|
+ $scope.choosedBatch.push(goods.batchCode);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.batchDown = function () {
|
|
|
+ getChooseBatch();
|
|
|
+ if (!$scope.choosedBatch || $scope.choosedBatch.length == 0) {
|
|
|
+ toaster.pop("info", "您尚未选中任何产品");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $scope.soldOutProduct($scope.choosedBatch);
|
|
|
+ };
|
|
|
+
|
|
|
var initKindDataInfo = function () {
|
|
|
Commodity.getAllKindInfo({}, function (data) {
|
|
|
$scope.kindInfo = data;
|
|
|
- console.log(data)
|
|
|
})
|
|
|
};
|
|
|
initKindDataInfo();
|
|
|
@@ -228,14 +246,15 @@ define(['app/app'], function(app) {
|
|
|
|
|
|
})
|
|
|
};
|
|
|
+
|
|
|
// 下架事件
|
|
|
- $scope.soldOutProduct = function (data) {
|
|
|
+ $scope.soldOutProduct = function (batchArray) {
|
|
|
var modalInstance = $modal.open({
|
|
|
templateUrl: 'static/view/admin/modal/manage/ManageSoldOut.html',
|
|
|
controller: 'soleOutCtrl',
|
|
|
resolve: {
|
|
|
- account: function () {
|
|
|
- return angular.copy(data);
|
|
|
+ batchArray: function () {
|
|
|
+ return angular.copy(batchArray);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -326,6 +345,26 @@ define(['app/app'], function(app) {
|
|
|
$scope.errorType = type;
|
|
|
};
|
|
|
|
|
|
+ var countLength = function (string) {
|
|
|
+ return string.replace(/[^\x00-\xff]/g, '**').length;
|
|
|
+ };
|
|
|
+
|
|
|
+ var cutOutString = function (str, length) {
|
|
|
+ for (var i = 1; i <= str.length; i++) {
|
|
|
+ if (countLength(str.substr(0, i)) > length){
|
|
|
+ str = str.substr(0, i-1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.inputMessage = function () {
|
|
|
+ if ($scope.otherMessage) {
|
|
|
+ $scope.otherMessage = cutOutString($scope.otherMessage, 30);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
$scope.ensureAudit = function (pass) {
|
|
|
if (!pass) {
|
|
|
if (!$scope.errorType) {
|
|
|
@@ -333,7 +372,7 @@ define(['app/app'], function(app) {
|
|
|
return;
|
|
|
}
|
|
|
if ($scope.errorType == 5) {
|
|
|
- if (!$scope.otherMessage || $scope.otherMessage.length == 0) {
|
|
|
+ if (!$scope.otherMessage || countLength($scope.otherMessage) < 2) {
|
|
|
toaster.pop("info", "原因至少要填写2个字");
|
|
|
return;
|
|
|
}
|
|
|
@@ -386,10 +425,74 @@ define(['app/app'], function(app) {
|
|
|
$modalInstance.dismiss();
|
|
|
}
|
|
|
}]);
|
|
|
- app.register.controller('soleOutCtrl', ['$scope', 'account', '$modalInstance', function($scope, account, $modalInstance) {
|
|
|
+
|
|
|
+ app.register.controller('soleOutCtrl', ['$scope', 'batchArray', 'Goods', 'toaster', '$modalInstance', function($scope, batchArray, Goods, toaster, $modalInstance) {
|
|
|
+ $scope.errorMsg = '';
|
|
|
+ $scope.otherMessage = '';
|
|
|
+ $scope.errorArray = ['价格异常', '图片违规', '基本信息有误', '短缺货'];
|
|
|
+
|
|
|
+ var countLength = function (string) {
|
|
|
+ return string.replace(/[^\x00-\xff]/g, '**').length;
|
|
|
+ };
|
|
|
+
|
|
|
+ var cutOutString = function (str, length) {
|
|
|
+ for (var i = 1; i <= str.length; i++) {
|
|
|
+ if (countLength(str.substr(0, i)) > length){
|
|
|
+ str = str.substr(0, i-1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.inputMessage = function () {
|
|
|
+ if ($scope.otherMessage) {
|
|
|
+ $scope.otherMessage = cutOutString($scope.otherMessage, 30);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
$scope.cancel = function () {
|
|
|
$modalInstance.dismiss();
|
|
|
- }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.changeType = function (type) {
|
|
|
+ $scope.errorType = type;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.ensureDown = function () {
|
|
|
+ if (!$scope.errorType) {
|
|
|
+ toaster.pop("info", "您尚未选择下架原因");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($scope.errorType == 5) {
|
|
|
+ if (!$scope.otherMessage || countLength($scope.otherMessage) < 2) {
|
|
|
+ toaster.pop("info", "原因至少要填写2个字");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($scope.errorType == 5) {
|
|
|
+ $scope.errorMsg = $scope.otherMessage;
|
|
|
+ } else {
|
|
|
+ $scope.errorMsg = $scope.errorArray[$scope.errorType - 1];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$scope.errorMsg || $scope.errorMsg.length == 0) {
|
|
|
+ toaster.pop("info", "您尚未选择下架原因");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var batchs = batchArray.join(",");
|
|
|
+ Goods.offShelfGoodsByProvider({batchCodes:batchs, downMsg:$scope.errorMsg}, {}, function(map){
|
|
|
+ if (map.success) {
|
|
|
+ toaster.pop('success', '下架成功');
|
|
|
+ $scope.batchStatus = false;
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', map.message);
|
|
|
+ }
|
|
|
+ }, function() {
|
|
|
+ toaster.pop('error', '下架失败');
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
}]);
|
|
|
app.register.controller('showContrastImgCtrl', ['$scope', 'img', '$modalInstance', function ($scope, img, $modalInstance) {
|
|
|
$scope.showImgs = img;
|