|
|
@@ -1,9 +1,10 @@
|
|
|
define([ 'app/app' ], function(app) {
|
|
|
'use strict';
|
|
|
- app.register.controller('vendor_onSaleCtrl', ['$scope', '$rootScope', 'Goods', '$modal', 'toaster', 'Loading', 'StoreInfo', 'AuthenticationService', '$q', 'StoreCms', 'Enterprise', function ($scope, $rootScope, Goods, $modal, toaster, Loading, StoreInfo, AuthenticationService, $q, StoreCms, Enterprise) {
|
|
|
+ app.register.controller('vendor_onSaleCtrl', ['$scope', '$rootScope', 'Goods', '$modal', 'toaster', 'Loading', 'StoreInfo', 'AuthenticationService', '$q', 'StoreCms', function ($scope, $rootScope, Goods, $modal, toaster, Loading, StoreInfo, AuthenticationService, $q, StoreCms) {
|
|
|
$rootScope.active = 'vendor_goods';
|
|
|
$scope.keyword = '';
|
|
|
$scope.tab = 'onSale';
|
|
|
+ $scope.isInt = /^[0-9]*[1-9][0-9]*$/;
|
|
|
|
|
|
$scope.param = {
|
|
|
page : 1,
|
|
|
@@ -11,21 +12,9 @@ define([ 'app/app' ], function(app) {
|
|
|
sorting : {
|
|
|
createdDate: 'DESC'
|
|
|
},
|
|
|
- status : '601-602'
|
|
|
+ status : 601
|
|
|
};
|
|
|
|
|
|
- $scope.$$onSale = {};
|
|
|
-
|
|
|
- Enterprise.getCurrencyByRegisterAddress(null, function (data) {
|
|
|
- if(data.code == 1) {
|
|
|
- $scope.$$onSale.currency = data.data;
|
|
|
- }else {
|
|
|
- toaster.pop('warning', '提示', data.message);
|
|
|
- }
|
|
|
- }, function (response) {
|
|
|
- toaster.pop('error', '根据注册地址确定的币别失败');
|
|
|
- });
|
|
|
-
|
|
|
// 商品分页数据
|
|
|
$scope.goodsPageParams = {};
|
|
|
$scope.selfSupportType = {
|
|
|
@@ -55,52 +44,7 @@ define([ 'app/app' ], function(app) {
|
|
|
}).error(function(response) {
|
|
|
toaster.pop('info', '获取定单的信息' + response);
|
|
|
});
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据数量增加一个分段
|
|
|
- */
|
|
|
- $scope.addFragment = function (commodity) {
|
|
|
- if(!$scope.$$onSale.qty) {
|
|
|
- toaster.pop('warning', '提示', '请输入插入的分段');
|
|
|
- return ;
|
|
|
- }
|
|
|
- var fragmentPrices = commodity.editPrices;
|
|
|
- if(fragmentPrices.length > 2) {
|
|
|
- toaster.pop('warning', '提示', '分段数不能超过三个');
|
|
|
- return ;
|
|
|
- }
|
|
|
- if(isNaN($scope.$$onSale.qty)) {
|
|
|
- toaster.pop('warning', '提示', '输入的分段数量中包含了不是数字的字符');
|
|
|
- return ;
|
|
|
- }
|
|
|
- var qty = Number($scope.$$onSale.qty);
|
|
|
- if(qty <= fragmentPrices[0].start) {
|
|
|
- toaster.pop('warning', '提示', '输入的分段数量小于等于第一个分段的起始值');
|
|
|
- return ;
|
|
|
- }
|
|
|
- if(qty >= fragmentPrices[fragmentPrices.length - 1].end) {
|
|
|
- toaster.pop('warning', '提示', '输入的分段数量大于等于最后一个分段的结束值');
|
|
|
- return ;
|
|
|
- }
|
|
|
- for(var i = 0; i< fragmentPrices.length; i++) {
|
|
|
- var price = fragmentPrices[i];
|
|
|
- if(qty == price.start) {
|
|
|
- toaster.pop('warning', '提示', '输入的分段数量等于第'+ (i+1)+'分段的起始值');
|
|
|
- return ;
|
|
|
- }else if(qty == price.end) {
|
|
|
- toaster.pop('warning', '提示', '输入的分段数量等于第'+ (i+1)+'分段的结束值');
|
|
|
- return ;
|
|
|
- }else if(qty < price.end) {
|
|
|
- var end = price.end;
|
|
|
- price.end = qty - 1;
|
|
|
- var obj = {start : qty, end : end, rMBPrice : null, uSDPrice : null};
|
|
|
- commodity.editPrices.splice(i + 1 , 0 , obj);
|
|
|
- $scope.$$onSale.qty = null;
|
|
|
- return ;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
//判断是否是商城管理公司,是否可以选择自营。
|
|
|
$q.all([getAuthentication()]).then(function() {
|
|
|
@@ -387,6 +331,28 @@ define([ 'app/app' ], function(app) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 增加对应的分段。
|
|
|
+ * @param commodity
|
|
|
+ */
|
|
|
+ $scope.addFragment = function (commodity) {
|
|
|
+ if(commodity.editPrices.length > 2) {
|
|
|
+ toaster.pop('warning', "提示", "批次最多只能有三个分段");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ var price = {};
|
|
|
+ price.start = null;
|
|
|
+ price.startPre = null;
|
|
|
+ price.end = commodity.editPrices[commodity.editPrices.length - 1].end;
|
|
|
+ price.endPre = price.end;
|
|
|
+ price.uSDPrice = null;
|
|
|
+ price.uSDPricePre = null;
|
|
|
+ price.rMBPrice = null;
|
|
|
+ price.rMBPricePre = null;
|
|
|
+ commodity.editPrices[commodity.editPrices.length - 1].end = null;
|
|
|
+ commodity.editPrices[commodity.editPrices.length - 1].endPre = null;
|
|
|
+ commodity.editPrices.push(price);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 删除对应的分段.
|
|
|
@@ -398,13 +364,13 @@ define([ 'app/app' ], function(app) {
|
|
|
toaster.pop('warning', "提示", "批次至少需要一个分段");
|
|
|
return ;
|
|
|
}
|
|
|
- if(index < commodity.editPrices.length - 1) { //不是最后一个分段
|
|
|
- var price = commodity.editPrices.splice(index, 1);
|
|
|
- commodity.editPrices[index].start = price[0].start;
|
|
|
- }else if(index == commodity.editPrices.length - 1) { //如果删除的是最后一个分段,
|
|
|
- var price = commodity.editPrices.splice(index, 1);
|
|
|
- commodity.editPrices[index -1].end = price[0].end;
|
|
|
- }
|
|
|
+ if(index < commodity.editPrices.length - 1) { //不是最后一个分段
|
|
|
+ var price = commodity.editPrices.splice(index, 1);
|
|
|
+ commodity.editPrices[index].start = price[0].start;
|
|
|
+ }else if(index == commodity.editPrices.length - 1) { //如果删除的是最后一个分段,
|
|
|
+ var price = commodity.editPrices.splice(index, 1);
|
|
|
+ commodity.editPrices[index -1].end = price[0].end;
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -423,88 +389,258 @@ define([ 'app/app' ], function(app) {
|
|
|
commodity.edit = true;
|
|
|
commodity.editPic = commodity.img;
|
|
|
commodity.editPrices = angular.copy(commodity.prices);
|
|
|
+ angular.forEach(commodity.editPrices, function (price) {
|
|
|
+ price.startPre = price.start;
|
|
|
+ price.startDirty = false;
|
|
|
+
|
|
|
+ price.endPre = price.end;
|
|
|
+ price.endDirty = false;
|
|
|
+
|
|
|
+ price.rMBPricePre = price.rMBPrice;
|
|
|
+ price.rMBPriceDirty = false;
|
|
|
+
|
|
|
+ price.uSDPricePre = price.uSDPrice;
|
|
|
+ price.uSDPriceDirty = false;
|
|
|
+ });
|
|
|
+ commodity.editPrices[commodity.editPrices.length - 1].end = commodity.reserve;
|
|
|
+ commodity.editPrices[commodity.editPrices.length - 1].endPre = commodity.reserve;
|
|
|
+
|
|
|
+ commodity.editReserve = commodity.reserve;
|
|
|
+ commodity.editReservePre = commodity.reserve;
|
|
|
+ commodity.editReserveDirty = false;
|
|
|
+
|
|
|
commodity.editMinBuyQty = commodity.minBuyQty;
|
|
|
- commodity.editMaxDelivery = commodity.maxDelivery;
|
|
|
- commodity.editMinDelivery = commodity.minDelivery;
|
|
|
- $scope.$$onSale.qty = null;
|
|
|
+ commodity.editMinBuyQtyPre = commodity.minBuyQty;
|
|
|
+ commodity.editMinBuyQtyDirty = false;
|
|
|
+
|
|
|
+ commodity.editMinPackQty = commodity.minPackQty;
|
|
|
+ commodity.editMinPackQtyPre = commodity.minPackQty;
|
|
|
+ commodity.editMinPackQtyDirty = false;
|
|
|
+
|
|
|
+ commodity.editPackaging = commodity.packaging;
|
|
|
+ commodity.editPackagingPre = commodity.packaging;
|
|
|
+ commodity.editPackagingDirty = false;
|
|
|
+
|
|
|
+ commodity.editProduceDate = new String(commodity.produceDate);
|
|
|
+ commodity.editProduceDatePre = commodity.produceDate;
|
|
|
+ commodity.editProduceDateDirty = false;
|
|
|
+
|
|
|
+ commodity.editSelfDeliveryHKMinTime = commodity.selfDeliveryHKMinTime;
|
|
|
+ commodity.editSelfDeliveryHKMinTimePre = commodity.selfDeliveryHKMinTime;
|
|
|
+ commodity.editSelfDeliveryHKMinTimeDirty = false;
|
|
|
+
|
|
|
+ commodity.editSelfDeliveryHKMaxTime = commodity.selfDeliveryHKMaxTime;
|
|
|
+ commodity.editSelfDeliveryHKMaxTimePre = commodity.selfDeliveryHKMaxTime;
|
|
|
+ commodity.editSelfDeliveryHKMaxTimeDirty = false;
|
|
|
+
|
|
|
+ commodity.editSelfDeliveryDemMinTime = commodity.selfDeliveryDemMinTime;
|
|
|
+ commodity.editSelfDeliveryDemMinTimePre = commodity.selfDeliveryDemMinTime;
|
|
|
+ commodity.editSelfDeliveryDemMinTimeDirty = false;
|
|
|
+
|
|
|
+ commodity.editSelfDeliveryDemMaxTime = commodity.selfDeliveryDemMaxTime;
|
|
|
+ commodity.editSelfDeliveryDemMaxTimePre = commodity.selfDeliveryDemMaxTime;
|
|
|
+ commodity.editSelfDeliveryDemMaxTimeDirty = false;
|
|
|
+
|
|
|
+ commodity.editSelfSale = $scope.storeInfo.uuid != 'undefind' && commodity.storeid == $scope.storeInfo.uuid && $scope.storeInfo.storeName.indexOf('优软测试二') < 0 && $scope.storeInfo.storeName.indexOf('优软商城') < 0 ? 1 : 2;
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改commodity的系列的dirty属性 为true;
|
|
|
+ * @param commodity
|
|
|
+ */
|
|
|
+ $scope.initDirtyTrue = function(commodity) {
|
|
|
+ angular.forEach(commodity.editPrices, function (price) {
|
|
|
+ price.startDirty = false;
|
|
|
+ price.endDirty = false;
|
|
|
+ price.rMBPriceDirty = false;
|
|
|
+ price.uSDPriceDirty = false;
|
|
|
+ });
|
|
|
+ commodity.editReserveDirty = false;
|
|
|
+ commodity.editMinBuyQtyDirty = false;
|
|
|
+ commodity.editMinPackQtyDirty = false;
|
|
|
+ commodity.editPackagingDirty = false;
|
|
|
+ commodity.editProduceDateDirty = false;
|
|
|
+ commodity.editSelfDeliveryHKMinTimeDirty = false;
|
|
|
+ commodity.editSelfDeliveryHKMaxTimeDirty = false;
|
|
|
+ commodity.editSelfDeliveryDemMinTimeDirty = false;
|
|
|
+ commodity.editSelfDeliveryDemMaxTimeDirty = false;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改分段的数量
|
|
|
+ * @param commodity 批次信息
|
|
|
+ * @param index 索引值
|
|
|
+ * @param isEnd 是否是结束值
|
|
|
+ */
|
|
|
+ $scope.editQty = function (commodity, index, isEnd, num) {
|
|
|
+ commodity.editPrices[index].endInValid = false;
|
|
|
+ commodity.editPrices[index].startInValid = false;
|
|
|
+ if(commodity.editPrices.length < index || index < 0) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if(!num) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if(!$scope.isInt.test(num)) {
|
|
|
+ if(isEnd) {
|
|
|
+ commodity.editPrices[index].end = commodity.editPrices[index].endPre;
|
|
|
+ }else {
|
|
|
+ commodity.editPrices[index].start = commodity.editPrices[index].startPre;
|
|
|
+ }
|
|
|
+ toaster.pop('warning', '提示', '分段数量必须为正整数');
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if(isEnd) {
|
|
|
+ if(index < commodity.editPrices.length - 1) {
|
|
|
+ if(commodity.editPrices[index].end <= commodity.editPrices[index].start) {
|
|
|
+ toaster.pop('warning', '提示', '修改之后当前分段的结束值' + parseInt(commodity.editPrices[index].end) + '小于' + commodity.editPrices[index].start);
|
|
|
+ commodity.editPrices[index].end = commodity.editPrices[index].endPre;
|
|
|
+ }else if((commodity.editPrices[index + 1].end)&&(parseInt(commodity.editPrices[index].end) + 1) >= parseInt(commodity.editPrices[index + 1].end)) {
|
|
|
+ toaster.pop('warning', '提示', '修改本分段之后,导致后面一个分段起始值'+(parseInt(commodity.editPrices[index].end) + 1)+'大于结束值' + commodity.editPrices[index + 1].end);
|
|
|
+ commodity.editPrices[index].end = commodity.editPrices[index].endPre;
|
|
|
+ } else {
|
|
|
+ commodity.editPrices[index + 1].start = parseInt(commodity.editPrices[index].end) + 1;
|
|
|
+ commodity.editPrices[index].endPre = commodity.editPrices[index].end;
|
|
|
+ commodity.editPrices[index + 1].startPre = commodity.editPrices[index + 1].start;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(commodity.editPrices[index].end > commodity.editMinBuyQty) {
|
|
|
+ if(commodity.editPrices[index].end > commodity.reserve) {
|
|
|
+ toaster.pop('warning', '提示', '修改最后一个分段的结束值之后,新的库存量大于原有的库存量');
|
|
|
+ commodity.editPrices[index].end = commodity.editPrices[index].endPre;
|
|
|
+ }else {
|
|
|
+ commodity.editReserve = commodity.editPrices[index].end;
|
|
|
+ commodity.editPrices[index].endPre = commodity.editPrices[index].end;
|
|
|
+ commodity.editReservePre = commodity.editReserve;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ toaster.pop('warning', '提示', '修改最后一个分段的结束值之后导致库存量小于起拍量');
|
|
|
+ commodity.editPrices[index].end = commodity.editPrices[index].endPre;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(index != 0) {
|
|
|
+ if(parseInt(commodity.editPrices[index].start) >= parseInt(commodity.editPrices[index].end)) {
|
|
|
+ toaster.pop('warning', '提示', '修改本分段之后,会导致分段的起始值' + commodity.editPrices[index ].start + '大于等于结束值' + parseInt(commodity.editPrices[index].end));
|
|
|
+ commodity.editPrices[index].start = commodity.editPrices[index].startPre;
|
|
|
+ }else if((parseInt(commodity.editPrices[index].start) - 1) <= commodity.editPrices[index - 1].start) {
|
|
|
+ toaster.pop('warning', '提示', '修改本分段之后,会导致前一个分段的起始值' + commodity.editPrices[index - 1].start + '大于等于结束值' + (parseInt(commodity.editPrices[index].start) - 1));
|
|
|
+ commodity.editPrices[index].start = commodity.editPrices[index].startPre;
|
|
|
+ }else {
|
|
|
+ commodity.editPrices[index - 1].end = parseInt(commodity.editPrices[index].start) - 1;
|
|
|
+ commodity.editPrices[index].startPre = commodity.editPrices[index].start;
|
|
|
+ commodity.editPrices[index - 1].endPre = commodity.editPrices[index - 1].end;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(commodity.editMinPackQty) {
|
|
|
+ if(commodity.editPrices[index].start % commodity.editMinPackQty != 0) {
|
|
|
+ commodity.editPrices[index].startInValid = false;
|
|
|
+ commodity.editPrices[index].start = commodity.editMinBuyQty;
|
|
|
+ commodity.editPrices[index].startPre = commodity.editMinBuyQty;
|
|
|
+ toaster.pop('warning', '提示', '第一个分段的起始量必须是倍数(' + commodity.editMinPackQty + ")的整数倍");
|
|
|
+ }else {
|
|
|
+ commodity.editMinBuyQty = commodity.editPrices[index].start;
|
|
|
+ commodity.editMinBuyQtyPre = commodity.editPrices[index].start;
|
|
|
+ commodity.editMinBuyQtyInValid = false;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ commodity.editMinBuyQty = commodity.editPrices[index].start;
|
|
|
+ commodity.editMinBuyQtyPre = commodity.editMinBuyQty;
|
|
|
+ commodity.editPrices[index].startPre = commodity.editPrices[index].start;
|
|
|
+ commodity.editMinBuyQtyInValid = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param commodity 需要验证的批次的信息
|
|
|
* @returns {boolean}
|
|
|
*/
|
|
|
var changeQtyPrice = function(commodity) {
|
|
|
- var result = false;
|
|
|
- var lastEnd = -1;
|
|
|
- for (var i = 0; i < commodity.editPrices.length; i++) {
|
|
|
- var price = commodity.editPrices[i];
|
|
|
- if(isNaN(price.start)) {
|
|
|
- toaster.pop('warning', '第' +(i + 1)+'个分段的起始值必须是数字');
|
|
|
- return result;
|
|
|
- }
|
|
|
- if(Number(price.start) <= lastEnd) {
|
|
|
- toaster.pop('warning', "存在分段的起始值小于等于上一个分段的结束值");
|
|
|
- return result;
|
|
|
+ var price = commodity.editPrices;
|
|
|
+ var previousEnd = -1;
|
|
|
+ for(var i = 0; i < price.length; i++){
|
|
|
+ price[i].startInValid = false;
|
|
|
+ price[i].endInValid = false;
|
|
|
+ if(isNaN(price[i].start)) {
|
|
|
+ price[i].startInValid = true;
|
|
|
+ toaster.pop('warning', "提示", "分段数量必须是数字");
|
|
|
+ return false;
|
|
|
}
|
|
|
- if(isNaN(price.end)) {
|
|
|
- toaster.pop('warning', '第' +(i + 1)+'个分段的结束值必须是数字');
|
|
|
- return result;
|
|
|
+ if(parseInt(price[i].start) <= previousEnd) {
|
|
|
+ price[i].startInValid = true;
|
|
|
+ toaster.pop('warning', "提示", "存在上一个分段的结束值大于下一个分段的起始值");
|
|
|
+ return false;
|
|
|
}
|
|
|
- if(Number(price.start) >= Number(price.end)) {
|
|
|
- toaster.pop('warning', '第' +(i + 1)+'个分段的起始值大于等于分段的结束值');
|
|
|
- return result;
|
|
|
+ if(isNaN(price[i].end)) {
|
|
|
+ price[i].endInValid = true;
|
|
|
+ toaster.pop('warning', "提示", "分段数量必须是数字");
|
|
|
+ return false;
|
|
|
}
|
|
|
- //目前系统中存在双币别,与现有的逻辑冲突,暂时先用企业地址确定币别
|
|
|
- if($scope.$$onSale.currency.indexOf('USD') > -1) {
|
|
|
- if(!price.uSDPrice) {
|
|
|
- toaster.pop('warning', '第' +(i + 1)+'个分段的单价($)为空,请填写后再次提交!');
|
|
|
- return result;
|
|
|
- }else if(isNaN(price.uSDPrice)){
|
|
|
- toaster.pop('warning', '第' +(i + 1)+'个分段的单价($)信息必须是数字');
|
|
|
- return result;
|
|
|
- }
|
|
|
+ if(parseInt(price[i].start) >= parseInt(price[i].end)) {
|
|
|
+ price[i].startInValid = true;
|
|
|
+ toaster.pop('warning', "提示", "存在分段的起始值大于等于分段的结束值");
|
|
|
+ return false;
|
|
|
}
|
|
|
- if($scope.$$onSale.currency.indexOf('RMB') > -1) {
|
|
|
- if(!price.rMBPrice) {
|
|
|
- toaster.pop('warning', '第' +(i + 1)+'个分段的单价(¥)为空,请填写后再次提交!');
|
|
|
- return result;
|
|
|
- }else if(isNaN(price.rMBPrice)){
|
|
|
- toaster.pop('warning', '第' +(i + 1)+'个分段的单价(¥)信息必须是数字');
|
|
|
- return result;
|
|
|
- }
|
|
|
+ if(parseInt(price[i].end) > parseInt(commodity.editReserve)){
|
|
|
+ price[i].endInValid = true;
|
|
|
+ toaster.pop('warning', "提示", "存在分段的结束值大于新库存数量");
|
|
|
+ return false;
|
|
|
}
|
|
|
+ previousEnd = price[i].end;
|
|
|
}
|
|
|
-
|
|
|
+ commodity.editPrices[0].start = commodity.editMinBuyQty || 0;
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
- * 验证是否合理
|
|
|
- * @param num 需要验证的数据
|
|
|
- * @param price 当前的分段
|
|
|
- * @param isRMB 是否是人民币
|
|
|
+ * commodity,
|
|
|
+ * 验证库存量是否大于原有的库存量
|
|
|
*/
|
|
|
- $scope.validPrice = function (price, num ,isRMB) {
|
|
|
- if(!num) {
|
|
|
- return ;
|
|
|
- }else if(isNaN(num)){
|
|
|
- toaster.pop('warning', '价格的信息必须只能包含数字');
|
|
|
- if(isRMB) {
|
|
|
- price.rMBPrice = null;
|
|
|
- }else {
|
|
|
- price.uSDPrice = null;
|
|
|
- }
|
|
|
- return ;
|
|
|
- }else if(Number(num) <= 0) {
|
|
|
- toaster.pop('warning', '价格的信息必须是大于零的数字');
|
|
|
- if(isRMB) {
|
|
|
- price.rMBPrice = null;
|
|
|
- }else {
|
|
|
- price.uSDPrice = null;
|
|
|
- }
|
|
|
- return ;
|
|
|
+ $scope.changeReserve = function (commodity) {
|
|
|
+ commodity.editReserveInvalid = true;
|
|
|
+ if(!commodity.editReserve) {
|
|
|
+ commodity.editReserveInvalid = false;
|
|
|
+ return false;
|
|
|
}
|
|
|
- };
|
|
|
+ if(!$scope.isInt.test(commodity.editReserve)) {
|
|
|
+ commodity.editReserve = commodity.editReservePre;
|
|
|
+ commodity.editReserveInvalid = false;
|
|
|
+ toaster.pop('warning', '提示', '库存量必须是正整数');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(parseInt(commodity.editReserve) > parseInt(commodity.reserve)) {
|
|
|
+ commodity.editReserve = commodity.editReservePre;
|
|
|
+ commodity.editReserveInvalid = false;
|
|
|
+ toaster.pop('warning', '提示', '修改的库存只能减少库存量');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(parseInt(commodity.editReserve) <= parseInt(commodity.editMinBuyQty)) {
|
|
|
+ commodity.editReserve = commodity.editReservePre;
|
|
|
+ commodity.editReserveInvalid = false;
|
|
|
+ toaster.pop('warning', '提示', '起拍量不能大于库存量');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(parseInt(commodity.editReserve) > 99999999 || commodity.editReserve < 1) {
|
|
|
+ commodity.editReserve = commodity.editReservePre;
|
|
|
+ commodity.editReserveInvalid = false;
|
|
|
+ toaster.pop('warning', '提示', '总库存量的数量必须介于1 ~ 99999999');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(parseInt(commodity.editPrices[commodity.editPrices.length - 1].start) >= parseInt(commodity.editReserve)) {
|
|
|
+ commodity.editReserve = commodity.editReservePre;
|
|
|
+ commodity.editReserveInvalid = false;
|
|
|
+ toaster.pop('warning', '提示', '最新库存量必须要大于最后一个分段的起始量。');
|
|
|
+ return false;
|
|
|
+ }else {
|
|
|
+ commodity.editPrices[commodity.editPrices.length - 1].end = commodity.editReserve;
|
|
|
+ commodity.editPrices[commodity.editPrices.length - 1].endPre = commodity.editPrices[commodity.editPrices.length - 1].end;
|
|
|
+ commodity.editReservePre = commodity.editReserve;
|
|
|
+ commodity.editReserveInvalid = false;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
@@ -512,116 +648,235 @@ define([ 'app/app' ], function(app) {
|
|
|
* 验证库存的最小起订量是否大于库存量
|
|
|
*/
|
|
|
$scope.changeMinBuyQty = function (commodity) {
|
|
|
+ commodity.editMinBuyQtyInValid = true;
|
|
|
if(!commodity.editMinBuyQty) {
|
|
|
+ commodity.editMinBuyQtyInValid = false;
|
|
|
return false;
|
|
|
}
|
|
|
- if(isNaN(commodity.editMinBuyQty)) {
|
|
|
- commodity.editMinBuyQty = commodity.minPackQty;
|
|
|
- toaster.pop('warning', '提示', '起订量必须是数字');
|
|
|
+ if(!$scope.isInt.test(commodity.editMinBuyQty)) {
|
|
|
+ commodity.editMinBuyQty = null;
|
|
|
+ toaster.pop('warning', '提示', '起拍量必须是数字');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(commodity.editMinBuyQty > commodity.editReserve) {
|
|
|
+ commodity.editMinBuyQty = null;
|
|
|
+ toaster.pop('warning', '提示', '起拍量不能大于库存量');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(commodity.editMinBuyQty < 1) {
|
|
|
+ commodity.editMinBuyQty = null;
|
|
|
+ toaster.pop('warning', '提示', '起拍量必须大于0');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(commodity.editMinPackQty) {
|
|
|
+ if(commodity.editMinBuyQty % commodity.editMinPackQty != 0) {
|
|
|
+ commodity.editMinBuyQty = null;
|
|
|
+ toaster.pop('warning', '提示', '起拍量必须是倍数的整数倍');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!commodity.editPrices[0].end || commodity.editMinBuyQty < commodity.editPrices[0].end) {
|
|
|
+ commodity.editPrices[0].start = commodity.editMinBuyQty;
|
|
|
+ commodity.editPrices[0].startPre = commodity.editPrices[0].start;
|
|
|
+ commodity.editMinBuyQtyPre = commodity.editMinBuyQty;
|
|
|
+ commodity.editMinBuyQtyInValid = false;
|
|
|
+ }else {
|
|
|
+ toaster.pop('warning', '提示', '修改起拍量之后导致第一个分段的起始值'+ commodity.editMinBuyQty +'大于结束值' + commodity.editPrices[0].end);
|
|
|
+ commodity.editMinBuyQty = commodity.editMinBuyQtyPre;
|
|
|
+ commodity.editMinBuyQtyInValid = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改批次信息的包装个数
|
|
|
+ * @param commodity
|
|
|
+ */
|
|
|
+ $scope.changeMinPackQty = function(commodity) {
|
|
|
+ commodity.editMinPackQtyInValid = true;
|
|
|
+ if(!commodity.editMinPackQty) {
|
|
|
+ commodity.editMinPackQtyInValid = false;
|
|
|
return false;
|
|
|
}
|
|
|
- if(Number(commodity.editMinBuyQty) <= 0) {
|
|
|
- commodity.editMinBuyQty = commodity.minPackQty;
|
|
|
- toaster.pop('warning', '提示', '起订量必须大于0');
|
|
|
+ if(!$scope.isInt.test(commodity.editMinPackQty)) {
|
|
|
+ commodity.editMinPackQty = null;
|
|
|
+ toaster.pop('warning', '提示', '倍数必须是正整数');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(commodity.editMinPackQty < 1) {
|
|
|
+ commodity.editMinPackQty = null;
|
|
|
+ toaster.pop('warning', '提示', '倍数必须大于0');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(commodity.editMinPackQty > commodity.editReserve) {
|
|
|
+ commodity.editMinPackQty = null;
|
|
|
+ toaster.pop('warning', '提示', '倍数必须是起拍量的整数倍且小于起拍量。');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if((Number(commodity.editMinBuyQty) % Number(commodity.minPackQty)) != 0) {
|
|
|
- var i = Math.floor(Number(commodity.editMinBuyQty) / Number(commodity.minPackQty));
|
|
|
- i = (i == 0 ? 1 : i);
|
|
|
- commodity.editMinBuyQty = (i * commodity.minPackQty);
|
|
|
- toaster.pop('warning','提示', '起订量必须是包装数的倍数');
|
|
|
+ if(commodity.editMinBuyQty) {
|
|
|
+ if(commodity.editMinBuyQty % commodity.editMinPackQty != 0) {
|
|
|
+ commodity.editMinPackQty = null;
|
|
|
+ toaster.pop('warning', '提示', '倍数必须是起拍量的整数倍且小于起拍量。');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
+ commodity.editMinPackQtyPre = commodity.editMinPackQty;
|
|
|
+ commodity.editMinPackQtyInValid = false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 比较交货周期的大小
|
|
|
* @param min 本来是最小值
|
|
|
* @param max 本来是最大值
|
|
|
- * @param standard 批次信息
|
|
|
+ * @param type 2 表示当前验证的香港交期, 1表示当前验证的是大陆交期
|
|
|
+ * @param commodity 批次信息
|
|
|
* @returns {boolean} true 表示验证通过,false 表示验证失败。
|
|
|
*/
|
|
|
- $scope.compareNum = function(min, max) {
|
|
|
- if(!min || !max) {
|
|
|
- toaster.pop('warning', '交期存在空值,请填写对应的信息');
|
|
|
+ $scope.compareNum = function(min, max, type, commodity) {
|
|
|
+ if(!min) {
|
|
|
+ if(type == 1) {
|
|
|
+ commodity.selfDemMinTimeinValid = true;
|
|
|
+ toaster.pop('warning', '大陆交期存在空值,请重新操作');
|
|
|
+ }else if(type == 2){
|
|
|
+ commodity.selfHkMinTimeinValid = true;
|
|
|
+ toaster.pop('warning', '香港交期存在空值,请重新操作');
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }else if(!max) {
|
|
|
+ if(type == 1) {
|
|
|
+ commodity.selfDemMaxTimeinValid = true;
|
|
|
+ toaster.pop('warning', '大陆交期存在空值,请重新操作');
|
|
|
+ }else if(type == 2){
|
|
|
+ commodity.selfHkMaxTimeinValid = true;
|
|
|
+ toaster.pop('warning', '香港交期存在空值,请重新操作');
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
if(isNaN(min)) {
|
|
|
+ if(type == 1) {
|
|
|
+ commodity.selfDemMinTimeinValid = true;
|
|
|
+ }else {
|
|
|
+ commodity.selfHkMinTimeinValid = true;
|
|
|
+ }
|
|
|
toaster.pop('warning', '最小交期必须是数字');
|
|
|
return false;
|
|
|
}
|
|
|
if(isNaN(max)) {
|
|
|
+ if(type == 1) {
|
|
|
+ commodity.selfDemMaxTimeinValid = true;
|
|
|
+ }else {
|
|
|
+ commodity.selfHkMaxTimeinValid = true;
|
|
|
+ }
|
|
|
toaster.pop('warning', '最大交期必须是数字');
|
|
|
return false;
|
|
|
}
|
|
|
- if(Number(min) < 1 || Number(max) < 1) {
|
|
|
- toaster.pop('warning', '交期的时间必须大于0');
|
|
|
+ if(min < 1 || min > 9) {
|
|
|
+ if(type == 1) {
|
|
|
+ commodity.selfDemMinTimeinValid = true;
|
|
|
+ }else {
|
|
|
+ commodity.selfHkMinTimeinValid = true;
|
|
|
+ }
|
|
|
+ toaster.pop('warning', '交期的时间必须是1-9天之内');
|
|
|
return false;
|
|
|
}
|
|
|
- /* if(Number(min) > Number(max)) {
|
|
|
- toaster.pop('warning', '最短交期必须小于等于最大交期');
|
|
|
+ if(max < 1 || max > 9) {
|
|
|
+ if(type == 1) {
|
|
|
+ commodity.selfDemMaxTimeinValid = true;
|
|
|
+ }else {
|
|
|
+ commodity.selfHkMaxTimeinValid = true;
|
|
|
+ }
|
|
|
+ toaster.pop('warning', '交期的时间必须是1-9天之内');
|
|
|
return false;
|
|
|
- }*/
|
|
|
+ }
|
|
|
+ if(min > max) {
|
|
|
+ if(type == 1) {
|
|
|
+ commodity.selfDemMaxTimeinValid = true;
|
|
|
+ commodity.selfDemMinTimeinValid = true;
|
|
|
+ toaster.pop('warning', '大陆交期最短交期大于最大交期');
|
|
|
+ }else if(type == 2){
|
|
|
+ commodity.selfHkMaxTimeinValid = true;
|
|
|
+ commodity.selfHkMinTimeinValid = true;
|
|
|
+ toaster.pop('warning', '香港交期最短交期大于最大交期');
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return true;
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* @param min 最小值
|
|
|
* @param max 最大值
|
|
|
* @param isMin 传入的是否是最小值
|
|
|
+ * @param isHk 是否是香港交货周期
|
|
|
+ * @param commodity 批次信息
|
|
|
*/
|
|
|
- $scope.blurDelivery = function(min, max, isMin, commodity) {
|
|
|
+ $scope.changeDelivery = function(min, max, isMin, isHk, commodity) {
|
|
|
+ commodity.selfDemMinTimeinValid = false;
|
|
|
+ commodity.selfDemMaxTimeinValid = false;
|
|
|
+ commodity.selfHkMinTimeinValid = false;
|
|
|
+ commodity.selfHkMaxTimeinValid = false;
|
|
|
var day = -1;
|
|
|
if(isMin) {
|
|
|
if(min && !isNaN(min)) {
|
|
|
day = min;
|
|
|
}else {
|
|
|
- if(!min) {
|
|
|
- return ;
|
|
|
+ if(isNaN(min)) {
|
|
|
+ toaster.pop('warning', '提示', '交期请输入1~9的数字');
|
|
|
+ }
|
|
|
+ if(isHk) {
|
|
|
+ commodity.selfHkMinTimeinValid = true;
|
|
|
}else {
|
|
|
- if(isMin) {
|
|
|
- commodity.editMinDelivery = null;
|
|
|
- }else {
|
|
|
- commodity.editMaxDelivery = null;
|
|
|
- }
|
|
|
- toaster.pop('warning', '提示', '交期必须为大于0数字');
|
|
|
- return ;
|
|
|
+ commodity.selfDemMinTimeinValid = true;
|
|
|
}
|
|
|
+ return ;
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
if(max && !isNaN(max)) {
|
|
|
day = max;
|
|
|
}else {
|
|
|
- if(!max) {
|
|
|
- return
|
|
|
+ if(isNaN(max)) {
|
|
|
+ toaster.pop('warning', '提示', '交期请输入1~9的数字');
|
|
|
+ }
|
|
|
+ if(isHk) {
|
|
|
+ commodity.selfHkMaxTimeinValid = true;
|
|
|
}else {
|
|
|
- if(isMin) {
|
|
|
- commodity.editMinDelivery = null;
|
|
|
- }else {
|
|
|
- commodity.editMaxDelivery = null;
|
|
|
- }
|
|
|
- toaster.pop('warning', '提示', '交期必须为大于0数字');
|
|
|
- return ;
|
|
|
+ commodity.selfDemMaxTimeinValid = true;
|
|
|
}
|
|
|
+ return ;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- if(day < 1) {
|
|
|
- if(isMin) {
|
|
|
- commodity.editMinDelivery = null;
|
|
|
+ if(day > 9 || day < 1) {
|
|
|
+ if(isHk) {
|
|
|
+ if(isMin) {
|
|
|
+ commodity.selfHkMinTimeinValid = true;
|
|
|
+ }else {
|
|
|
+ commodity.selfHkMaxTimeinValid = true;
|
|
|
+ }
|
|
|
}else {
|
|
|
- commodity.editMaxDelivery = null;
|
|
|
+ if(isMin) {
|
|
|
+ commodity.selfDemMinTimeinValid = true;
|
|
|
+ }else {
|
|
|
+ commodity.selfDemMaxTimeinValid = true;
|
|
|
+ }
|
|
|
}
|
|
|
- toaster.pop('warning', '提示', '交期必须为大于0数字');
|
|
|
+ toaster.pop('warning', '提示', '交期的值必须在1~9天');
|
|
|
return ;
|
|
|
}
|
|
|
- if((min && !isNaN(min)) && (max && !isNaN(max))) {
|
|
|
- if(Number(min) > Number(max)) {
|
|
|
- toaster.pop('warning', '提示', '最小交期必须小于最大交期');
|
|
|
- return ;
|
|
|
+ if(min > max) {
|
|
|
+ if(isHk) {
|
|
|
+ commodity.selfHkMinTimeinValid = true;
|
|
|
+ commodity.selfHkMaxTimeinValid = true;
|
|
|
+ }else {
|
|
|
+ commodity.selfDemMinTimeinValid = true;
|
|
|
+ commodity.selfDemMaxTimeinValid = true;
|
|
|
}
|
|
|
+ toaster.pop('warning', '提示', '最小交期必须小于最大交期');
|
|
|
+ return ;
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 验证库存信息的正确性,
|
|
|
@@ -636,25 +891,125 @@ define([ 'app/app' ], function(app) {
|
|
|
toaster.pop('warning', '库存信息丢失,请重新操作');
|
|
|
return result;
|
|
|
}
|
|
|
- if(!commodity.editMinBuyQty) {
|
|
|
- toaster.pop('warning', '请填写起订量');
|
|
|
+
|
|
|
+ if(!commodity.editPackaging) {
|
|
|
+ commodity.editPackagingInvalid = true;
|
|
|
+ toaster.pop('warning', '请填写包装方式');
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(!commodity.editProduceDate) {
|
|
|
+ commodity.editProduceDateInvalid = true;
|
|
|
+ toaster.pop('warning', '请填写生产日期');
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(isNaN(commodity.editReserve)) {
|
|
|
+ commodity.editReserveInvalid = true;
|
|
|
+ toaster.pop('warning', '最新库存必须是数字');
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(commodity.editReserve < 1) {
|
|
|
+ commodity.editReserveInvalid = true;
|
|
|
+ toaster.pop('warning', '最新库存必须大于0');
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(commodity.editReserve > commodity.reserve) {
|
|
|
+ commodity.editReserveInvalid = true;
|
|
|
+ toaster.pop('warning', '最新库存量只能小于原有库存');
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(commodity.editReserve > 99999999) {
|
|
|
+ commodity.editReserveInvalid = true;
|
|
|
+ toaster.pop('warning', '最新库存量不能大于99999999');
|
|
|
return result;
|
|
|
}
|
|
|
if(isNaN(commodity.editMinBuyQty)) {
|
|
|
+ commodity.editMinBuyQtyInValid = true;
|
|
|
toaster.pop('warning', '最小起拍量必须是数字');
|
|
|
return result;
|
|
|
}
|
|
|
- if(commodity.editMinBuyQty % commodity.minPackQty != 0) {
|
|
|
- toaster.pop('warning', '起订量必须是倍数的整数倍');
|
|
|
+ if(commodity.editReserve < commodity.editMinBuyQty) {
|
|
|
+ commodity.editReserveInvalid = true;
|
|
|
+ commodity.editMinBuyQtyInValid = true;
|
|
|
+ toaster.pop('warning', '最新库存必须大于最小起拍量');
|
|
|
return result;
|
|
|
}
|
|
|
- if(!changeQtyPrice(commodity)) {
|
|
|
+ if(isNaN(commodity.editMinPackQty)) {
|
|
|
+ commodity.editMinPackQtyInValid = true;
|
|
|
+ toaster.pop('warning', '倍数必须是数字');
|
|
|
return result;
|
|
|
}
|
|
|
- if(!$scope.compareNum(commodity.editMinDelivery, commodity.editMaxDelivery)) {
|
|
|
+ if(!commodity.editMinBuyQty) {
|
|
|
+ commodity.editMinBuyQtyInValid = true;
|
|
|
+ toaster.pop('warning', '请填写起拍量之后再提交');
|
|
|
return result;
|
|
|
}
|
|
|
- return true;
|
|
|
+ if(!commodity.editMinPackQty) {
|
|
|
+ commodity.editMinPackQtyInValid = true;
|
|
|
+ toaster.pop('warning', '请填写倍数之后再提交');
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(commodity.editMinBuyQty % commodity.editMinPackQty != 0) {
|
|
|
+ commodity.editMinBuyQtyInValid = true;
|
|
|
+ commodity.editMinPackQtyInValid = true;
|
|
|
+ toaster.pop('warning', '起拍量必须是倍数的整数倍');
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ var lastEnd = -1;
|
|
|
+ for (var i = 0; i < commodity.editPrices.length; i++) {
|
|
|
+ if(isNaN(commodity.editPrices[i].start)) {
|
|
|
+ commodity.editPrices[i].startInValid = true;
|
|
|
+ toaster.pop('warning', '分段数量必须是数字');
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(commodity.editPrices[i].start <= lastEnd) {
|
|
|
+ commodity.editPrices[i].startInValid = true;
|
|
|
+ toaster.pop('warning', "存在分段的起始值小于等于上一个分段的结束值");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(isNaN(commodity.editPrices[i].end)) {
|
|
|
+ commodity.editPrices[i].endInValid = true;
|
|
|
+ toaster.pop('warning', '分段数量必须是数字');
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(commodity.editPrices[i].start >= commodity.editPrices[i].end) {
|
|
|
+ commodity.editPrices[i].startInValid = true;
|
|
|
+ commodity.editPrices[i].endInValid = true;
|
|
|
+ toaster.pop('warning', "存在分段的起始值大于等于分段的结束值");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(commodity.currencyName.indexOf('USD') > -1) {
|
|
|
+ if(!commodity.editPrices[i].uSDPrice) {
|
|
|
+ commodity.editPrices[i].usdPriceInvalid = true;
|
|
|
+ toaster.pop('warning', "香港交货($)为空,请填写后再次提交!");
|
|
|
+ return result;
|
|
|
+ }else if(isNaN(commodity.editPrices[i].uSDPrice)){
|
|
|
+ commodity.editPrices[i].usdPriceInvalid = true;
|
|
|
+ toaster.pop('warning', "香港交货($)信息必须是数字");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(commodity.currencyName.indexOf('RMB') > -1) {
|
|
|
+ if(!commodity.editPrices[i].rMBPrice) {
|
|
|
+ commodity.editPrices[i].rmbPriceInvalid = true;
|
|
|
+ toaster.pop('warning', "大陆交货(¥)为空,请填写后再次提交!");
|
|
|
+ return result;
|
|
|
+ }else if(isNaN(commodity.editPrices[i].rMBPrice)){
|
|
|
+ commodity.editPrices[i].rmbPriceInvalid = true;
|
|
|
+ toaster.pop('warning', "大陆交货(¥)信息必须是数字");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(commodity.currencyName.indexOf('USD') > -1 && !$scope.compareNum(commodity.editSelfDeliveryHKMinTime, commodity.editSelfDeliveryHKMaxTime, 2, commodity)) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(commodity.currencyName.indexOf('RMB') > -1 && !$scope.compareNum(commodity.editSelfDeliveryDemMinTime, commodity.editSelfDeliveryDemMaxTime, 1, commodity)) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ result = true;
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -666,6 +1021,12 @@ define([ 'app/app' ], function(app) {
|
|
|
if(!$scope.checkGoodsInfo(commodity)) {
|
|
|
return ;
|
|
|
}
|
|
|
+ //更新分段信息
|
|
|
+ if(!changeQtyPrice(commodity)) {
|
|
|
+ return ;
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//将修改的信息映射到对应的字段
|
|
|
inserseCommodity(commodity);
|
|
|
@@ -682,13 +1043,85 @@ define([ 'app/app' ], function(app) {
|
|
|
};
|
|
|
|
|
|
var inserseCommodity = function (commodity) {
|
|
|
+ commodity.packaging = commodity.editPackaging;
|
|
|
+ commodity.produceDate = commodity.editProduceDate;
|
|
|
+ commodity.oldReserve = commodity.reserve;
|
|
|
+ commodity.reserve = commodity.editReserve;
|
|
|
commodity.minBuyQty = commodity.editMinBuyQty;
|
|
|
commodity.prices = commodity.editPrices;
|
|
|
- commodity.maxDelivery = commodity.editMaxDelivery;
|
|
|
- commodity.minDelivery = commodity.editMinDelivery;
|
|
|
+ commodity.selfDeliveryHKMinTime = commodity.editSelfDeliveryHKMinTime;
|
|
|
+ commodity.selfDeliveryHKMaxTime = commodity.editSelfDeliveryHKMaxTime;
|
|
|
+ commodity.selfDeliveryDemMinTime = commodity.editSelfDeliveryDemMinTime;
|
|
|
+ commodity.selfDeliveryDemMaxTime = commodity.editSelfDeliveryDemMaxTime;
|
|
|
+ commodity.selfSale = commodity.editSelfSale;
|
|
|
+ commodity.minPackQty = commodity.editMinPackQty;
|
|
|
commodity.img = commodity.editPic;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 验证价格是否是合理的,
|
|
|
+ * @param price 当前的分段,
|
|
|
+ * @param isUsd 是美金吗?
|
|
|
+ */
|
|
|
+ $scope.priceValid = function (price, isUsd) {
|
|
|
+ if(isUsd) {
|
|
|
+ price.usdPriceInvalid = false;
|
|
|
+ if(this.usdForm) {
|
|
|
+ var viewValue = this.usdForm.usd.$viewValue;
|
|
|
+ if(viewValue) {
|
|
|
+ if(validPriceDotBeforeAndAfter(viewValue)) {
|
|
|
+ this.usdForm.usd.$viewValue = this.usdForm.usd.$modelValue;
|
|
|
+ this.usdForm.usd.$render();
|
|
|
+ }
|
|
|
+ if(isNaN(viewValue)) {
|
|
|
+ price.usdPriceInvalid = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ price.rmbPriceInvalid = false;
|
|
|
+ if(this.rmbForm) {
|
|
|
+ var viewValue = this.rmbForm.rmb.$viewValue;
|
|
|
+ if(viewValue) {
|
|
|
+ if(validPriceDotBeforeAndAfter(viewValue)) {
|
|
|
+ this.rmbForm.rmb.$viewValue = this.rmbForm.rmb.$modelValue;
|
|
|
+ this.rmbForm.rmb.$render();
|
|
|
+ }
|
|
|
+ if(isNaN(viewValue)) {
|
|
|
+ price.rmbPriceInvalid = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 输入value 如果超过了数据长度,则不能添加
|
|
|
+ * @param value
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ var validPriceDotBeforeAndAfter = function(value) {
|
|
|
+ if(!value) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(value.indexOf('.') > -1) {
|
|
|
+ var arr = value.split(".");
|
|
|
+ if(arr[0].length > 4) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if(arr[1].length > 6) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(value.length > 4) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+
|
|
|
/**
|
|
|
* 修改批次信息的图片
|
|
|
*/
|
|
|
@@ -832,7 +1265,7 @@ define([ 'app/app' ], function(app) {
|
|
|
sorting : {
|
|
|
createdDate: 'DESC'
|
|
|
},
|
|
|
- status : '601-602'
|
|
|
+ status : 601
|
|
|
};
|
|
|
loadData();
|
|
|
};
|
|
|
@@ -850,4 +1283,21 @@ define([ 'app/app' ], function(app) {
|
|
|
loadDataReload();
|
|
|
};
|
|
|
}]);
|
|
|
+
|
|
|
+ app.register.controller('editPictureCtrl', ['$scope', 'pic', '$modalInstance', function ($scope, pic, $modalInstance) {
|
|
|
+ console.log('log')
|
|
|
+ $scope.pic = pic;
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.close();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 图片上传成功之后
|
|
|
+ $scope.onUploadSuccess = function(data){
|
|
|
+ $scope.pic = data.path;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.confirm = function() {
|
|
|
+ $modalInstance.close($scope.pic);
|
|
|
+ }
|
|
|
+ }]);
|
|
|
});
|