|
|
@@ -1,6 +1,6 @@
|
|
|
define(['app/app'], function(app) {
|
|
|
'use strict';
|
|
|
- app.register.controller('productManageDetailCtrl', ['$scope', '$stateParams', 'Goods', function ($scope, $stateParams, Goods) {
|
|
|
+ app.register.controller('productManageDetailCtrl', ['$scope', '$stateParams', 'Goods', '$modal', function ($scope, $stateParams, Goods, $modal) {
|
|
|
$scope.goodId = $stateParams.id;
|
|
|
var initGoods = function () {
|
|
|
Goods.findOneById({goodsId:$scope.goodId}, function (data) {
|
|
|
@@ -30,5 +30,91 @@ define(['app/app'], function(app) {
|
|
|
613 : '新品未上架'
|
|
|
};
|
|
|
|
|
|
- }])
|
|
|
+ // 下架事件
|
|
|
+ $scope.soldOutProduct = function (batchArray) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/view/admin/modal/manage/ManageSoldOut.html',
|
|
|
+ controller: 'soleOutCtrl',
|
|
|
+ resolve: {
|
|
|
+ batchArray: function () {
|
|
|
+ return angular.copy(batchArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function () {
|
|
|
+ $scope.manageTableParams.reload();
|
|
|
+ }, function () {
|
|
|
+
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ }]);
|
|
|
+ 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', '下架成功');
|
|
|
+ $modalInstance.close();
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', map.message);
|
|
|
+ }
|
|
|
+ }, function() {
|
|
|
+ toaster.pop('error', '下架失败');
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ }]);
|
|
|
});
|