|
|
@@ -1,6 +1,6 @@
|
|
|
define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
'use strict';
|
|
|
- app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', 'BrandSubmit', 'BrandActiveAPI', 'DistributionRule', 'prodRepositoryService', 'AuthenticationService', 'StoreInfo', 'ProductServiceQuery', 'StoreCms', 'ByteCountService', 'Goods', 'UASBatchPutOnPropertyServices', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI, BrandSubmit, BrandActiveAPI, DistributionRule, prodRepositoryService, AuthenticationService, StoreInfo, ProductServiceQuery, StoreCms, ByteCountService, Goods, UASBatchPutOnPropertyServices) {
|
|
|
+ app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', 'BrandSubmit', 'BrandActiveAPI', 'DistributionRule', 'prodRepositoryService', 'AuthenticationService', 'StoreInfo', 'ProductServiceQuery', 'StoreCms', 'ByteCountService', 'Goods', 'UASBatchPutOnPropertyServices', '$filter', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI, BrandSubmit, BrandActiveAPI, DistributionRule, prodRepositoryService, AuthenticationService, StoreInfo, ProductServiceQuery, StoreCms, ByteCountService, Goods, UASBatchPutOnPropertyServices, $filter) {
|
|
|
$rootScope.active = 'vendor_material';
|
|
|
document.title = '卖家产品库-优软商城';
|
|
|
$scope.tab = 'material';
|
|
|
@@ -210,7 +210,7 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
* 获取批量上架的配置信息
|
|
|
*/
|
|
|
UASBatchPutOnPropertyServices.get(null, function (data) {
|
|
|
- if (data) {
|
|
|
+ if (data && typeof data.fluctuateRate != 'undefined') {
|
|
|
$scope.uasBatchPutOnProperty = data;
|
|
|
$scope.uasBatchPutOnProperty.editFluctuateRate = NumberService.mul($scope.uasBatchPutOnProperty.fluctuateRate, 100) || 100;
|
|
|
$scope.uasBatchPutOnProperty.editMaxDelivery = $scope.uasBatchPutOnProperty.maxDelivery || 1;
|
|
|
@@ -474,12 +474,16 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
}
|
|
|
for(var i = 0; i < $scope.currenctMaterial.length; i++) {
|
|
|
if($scope.currenctMaterial[i].id == response.id) {
|
|
|
- $scope.currenctMaterial.splice(i, 1, response);
|
|
|
- if(response.batchCount > 0) {
|
|
|
- $scope.expandGoods($scope.currenctMaterial[i]);
|
|
|
- }else {
|
|
|
- $scope.currenctMaterial[i].exPandOper = false;
|
|
|
- }
|
|
|
+ $scope.currenctMaterial[i].batchCount--;
|
|
|
+ if ($scope.currenctMaterial[i].batchCount < 1) {
|
|
|
+ $scope.currenctMaterial[i].exPandOper = false;
|
|
|
+ }
|
|
|
+ for(var j = 0; j < $scope.currenctMaterial[i].goodsArr.length; j++) {
|
|
|
+ if ($scope.choosedIds[0] == $scope.currenctMaterial[i].goodsArr[j].id) {
|
|
|
+ $scope.currenctMaterial[i].goodsArr.splice(j, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // $scope.currenctMaterial.splice(i, 1, response);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -500,6 +504,21 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
}
|
|
|
material.exPandOper = false;
|
|
|
material.addGoodsOper = false;
|
|
|
+ });
|
|
|
+ $scope.goods.editReserve = material.erpReserve;
|
|
|
+ if ('ERP' == material.sourceApp) {
|
|
|
+ angular.forEach(material.goodsArr, function (goods) {
|
|
|
+ if (goods.status != 612) {
|
|
|
+ $scope.goods.editReserve = $scope.goods.editReserve - goods.reserve;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.goods.editReserve = $scope.goods.editReserve < 0 ? 0 : $scope.goods.editReserve;
|
|
|
+ $scope.goods.maxReserve = $scope.goods.editReserve;
|
|
|
+ $scope.goods.sourceApp = 'ERP';
|
|
|
+ }
|
|
|
+
|
|
|
+ angular.forEach(material.goodsArr, function (goods) {
|
|
|
+
|
|
|
});
|
|
|
material.exPandOper = true;
|
|
|
material.selected = true;
|
|
|
@@ -1390,12 +1409,17 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
}
|
|
|
for(var i = 0; i < $scope.currenctMaterial.length; i++) {
|
|
|
if($scope.currenctMaterial[i].id == response.id) {
|
|
|
- $scope.currenctMaterial.splice(i, 1, response);
|
|
|
- if(response.batchCount > 0) {
|
|
|
- $scope.expandGoods($scope.currenctMaterial[i]);
|
|
|
- }else {
|
|
|
- $scope.currenctMaterial[i].exPandOper = false;
|
|
|
- }
|
|
|
+ if (!$scope.currenctMaterial[i].batchCount) {
|
|
|
+ $scope.currenctMaterial[i].batchCount = 1;
|
|
|
+ } else {
|
|
|
+ $scope.currenctMaterial[i].batchCount++;
|
|
|
+ }
|
|
|
+ // if(response.batchCount > 0) {
|
|
|
+ // $scope.expandGoods($scope.currenctMaterial[i]);
|
|
|
+ // }else {
|
|
|
+ // $scope.currenctMaterial[i].exPandOper = false;
|
|
|
+ // }
|
|
|
+ $scope.expandGoods($scope.currenctMaterial[i]);
|
|
|
}
|
|
|
}
|
|
|
}, function (response) {
|
|
|
@@ -1699,22 +1723,30 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
*/
|
|
|
var getProductDetail = function (product) {
|
|
|
Material.getProductDetail({id : product.id}, function (data) {
|
|
|
- // $scope.goods.erpReserve = typeof data.reserve == 'undefined' ? 0 : data.reserve;
|
|
|
- // $scope.goods.b2cReserve = typeof data.b2cReserve == 'undefined' ? 0 : data.b2cReserve;
|
|
|
- // $scope.goods.packaging = data.packaging;
|
|
|
- // $scope.goods.produceDate = data.produceDate;
|
|
|
- // $scope.goods.minPackQty = data.minPackQty;
|
|
|
- // $scope.goods.breakUp = data.breakUp;
|
|
|
- // $scope.goods.minBuyQty = data.minBuyQty;
|
|
|
- // $scope.goods.minDelivery = data.minDelivery;
|
|
|
- // $scope.goods.maxDelivery = data.maxDelivery;
|
|
|
- // $scope.goods.prices = [];
|
|
|
- // product.selected = true;
|
|
|
- // if ('MAINLAND' == $scope.store.enType)
|
|
|
- // $scope.goods.prices.push({start : $scope.minReserve, end : $scope.maxReserve, rMBPrice: data.price});
|
|
|
- // if ('HK' == $scope.store.enType)
|
|
|
- // $scope.goods.prices.push({start : $scope.minReserve, end : $scope.maxReserve, uSDPrice: data.price});
|
|
|
-
|
|
|
+ $scope.goods.erpReserve = typeof data.reserve == 'undefined' ? 0 : data.reserve;
|
|
|
+ $scope.goods.editPackaging = (data && data.packaging) || product.packaging || '无';
|
|
|
+ $scope.goods.editProduceDate = (data && data.produceDate) || product.produceDate;
|
|
|
+ $scope.goods.editMinPackQty = (data && data.minPackQty) || product.minPackQty || $scope.goods.minBuyQty || 1;
|
|
|
+ $scope.goods.editMinBuyQty = (data && data.minBuyQty) || $scope.goods.minPackQty;
|
|
|
+ $scope.goods.editMinBuyQty = $scope.goods.editMinBuyQty - ($scope.goods.editMinBuyQty % $scope.goods.editMinPackQty);
|
|
|
+ if ($scope.goods.editMinBuyQty < $scope.goods.editMinPackQty) {
|
|
|
+ $scope.goods.editMinBuyQty = $scope.goods.editMinPackQty;
|
|
|
+ }
|
|
|
+ $scope.goods.editMinDelivery = (data && data.minDelivery) || $scope.uasBatchPutOnProperty.minDelivery;
|
|
|
+ $scope.goods.editMaxDelivery = (data && data.maxDelivery) || $scope.uasBatchPutOnProperty.maxDelivery;
|
|
|
+ product.selected = true;
|
|
|
+ product.averMonthSalePrice = (data && data.price) ? data.price : 0;
|
|
|
+ var goodQtyPrice = {start: $scope.goods.editMinBuyQty, end: $scope.maxReserve};
|
|
|
+ var price = (((data && data.price) ? data.price : 0) *
|
|
|
+ ($scope.uasBatchPutOnProperty.fluctuateRate ? $scope.uasBatchPutOnProperty.fluctuateRate : 1));
|
|
|
+ if ('MAINLAND' == $scope.store.enType) {
|
|
|
+ goodQtyPrice.rMBPrice = $filter('formateNumber')(price, 6);
|
|
|
+ }
|
|
|
+ if ('HK' == $scope.store.enType) {
|
|
|
+ goodQtyPrice.uSDPrice = $filter('formateNumber')(price, 6);
|
|
|
+ }
|
|
|
+ $scope.goods.editPrices = [];
|
|
|
+ $scope.goods.editPrices.push(goodQtyPrice);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -1766,25 +1798,28 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
});
|
|
|
material.addGoodsOper = true;
|
|
|
material.exPandOper = true;
|
|
|
+ $scope.goods = {};
|
|
|
+ $scope.goods.editBreakUp = false;
|
|
|
+ // 先保存产品id,方便去获取tag是否重复
|
|
|
+ $scope.goods.productid = material.id;
|
|
|
+ $scope.goods.prodNum = material.prodNum;
|
|
|
+ $scope.goods.editPrices = [];
|
|
|
+ if ($scope.store.enType === 'HK') {
|
|
|
+ $scope.goods.currencyName = 'USD';
|
|
|
+ } else {
|
|
|
+ $scope.goods.currencyName = 'RMB';
|
|
|
+ }
|
|
|
+ $scope.goods.editSelfSale = $scope.$$nonProduct.canSelfSale ? 1 : 2;
|
|
|
$scope.expandGoods(material, material.addGoodsOper);
|
|
|
- // if ('ERP' == material.sourceApp) {// 如果是erp上传物料获取物料交易信息
|
|
|
- // getProductDetail(material);
|
|
|
- // } else {
|
|
|
- $scope.goods = { editBreakUp: false, editSelfSale: 2};
|
|
|
- if($scope.store.enType === 'HK') {
|
|
|
- $scope.goods.currencyName = 'USD';
|
|
|
- }else {
|
|
|
- $scope.goods.currencyName = 'RMB';
|
|
|
- }
|
|
|
- // 先保存产品id,方便去获取tag是否重复
|
|
|
- $scope.goods.productid = material.id;
|
|
|
- $scope.goods.prodNum = material.prodNum;
|
|
|
- $scope.goods.editPrices = [];
|
|
|
- $scope.goods.editSelfSale = $scope.$$nonProduct.canSelfSale ? 1 : 2;
|
|
|
- $scope.goods.editPrices.push({start : $scope.minReserve, end : $scope.maxReserve});
|
|
|
+ if ('ERP' == material.sourceApp) {
|
|
|
+ // 如果是erp上传物料获取物料交易信息
|
|
|
+ getProductDetail(material);
|
|
|
+ } else {
|
|
|
+ $scope.goods.editPrices.push({start: $scope.minReserve, end: $scope.maxReserve});
|
|
|
// $scope.goods.isSelfSupport = $scope.store.status == 'OPENED' ? 1 : 0;
|
|
|
material.selected = true;
|
|
|
- // }
|
|
|
+ // }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1918,6 +1953,13 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+ if (goods.sourceApp == 'ERP') {
|
|
|
+ if (Number(goods.maxReserve) < goods.editReserve) {
|
|
|
+ goods.editReserve = goods.maxReserve;
|
|
|
+ toaster.pop('warning', '提示', '不能超过可用库存');
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
goods.editReservePre = goods.editReserve;
|
|
|
goods.editReserveInvalid = false;
|
|
|
if (!goods.breakUp) {
|
|
|
@@ -2120,14 +2162,14 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
|
|
|
toaster.pop('warning', '提示', '单价必须是大于0的数字');
|
|
|
return;
|
|
|
}
|
|
|
- if(price.indexOf('.') > -1) {
|
|
|
- var arr = price.split(".");
|
|
|
+ if(price.toString().indexOf('.') > -1) {
|
|
|
+ var arr = price.toString().split(".");
|
|
|
if(arr[0].length > 4 || arr[1].length > 6) {
|
|
|
prices[index].priceInvalid = true;
|
|
|
return ;
|
|
|
}
|
|
|
}else {
|
|
|
- if(price.toString().length > 4) {
|
|
|
+ if(price.toString().toString().length > 4) {
|
|
|
prices[index].priceInvalid = true;
|
|
|
return ;
|
|
|
}
|