...
|
...
|
@@ -10,8 +10,7 @@ var limitDateFromObj; |
|
|
var limitDateToObj;
|
|
|
|
|
|
var Bll = {
|
|
|
__render:function() {
|
|
|
console.log(editBean);
|
|
|
__render: function () {
|
|
|
editBean.currTime = common.util.__dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss");
|
|
|
$("#basicForm").html(common.util.__template2($("#limitcodeEdit-template").html(), editBean));
|
|
|
e.init();
|
...
|
...
|
@@ -24,26 +23,26 @@ var Bll = { |
|
|
pickTime: true
|
|
|
}).data("datepicker");
|
|
|
limitDateFromObj.setEndDate(editBean.limitDateTo);
|
|
|
if(editBean.limitDateFrom) {
|
|
|
if (editBean.limitDateFrom) {
|
|
|
limitDateToObj.setStartDate(editBean.currTime);
|
|
|
} else if(new Date(editBean.currTime).getTime() < new Date(editBean.limitDateFrom)){
|
|
|
} else if (new Date(editBean.currTime).getTime() < new Date(editBean.limitDateFrom)) {
|
|
|
limitDateToObj.setStartDate(editBean.limitDateFrom);
|
|
|
} else {
|
|
|
limitDateToObj.setStartDate(editBean.currTime);
|
|
|
}
|
|
|
if(type == "edit") {
|
|
|
if (type == "edit") {
|
|
|
$('input[name="skn_sku"]').prop('disabled', true);
|
|
|
$(".noEdit").prop("disabled", true);
|
|
|
$('input[name="userTypeLimit"]').prop('disabled', true);
|
|
|
if((new Date(editBean.limitDateFrom).getTime() <= new Date().getTime()) && isFirst) {
|
|
|
if ((new Date(editBean.limitDateFrom).getTime() <= new Date().getTime()) && isFirst) {
|
|
|
$("#limitDateFrom").prop("disabled", true);
|
|
|
}
|
|
|
isFirst = false;
|
|
|
}
|
|
|
},
|
|
|
__checkSkn:function(callback) {
|
|
|
__checkSkn: function (callback) {
|
|
|
var flag = false;
|
|
|
if(editBean.limitSkn) {
|
|
|
if (editBean.limitSkn) {
|
|
|
common.util.__ajax2({
|
|
|
async: false,
|
|
|
url: "/limitCode/checkSknValidity",
|
...
|
...
|
@@ -63,7 +62,7 @@ var Bll = { |
|
|
common.util.__tip("SKN已上架,请先下架");
|
|
|
}
|
|
|
callback && callback(res);
|
|
|
}, function() {
|
|
|
}, function () {
|
|
|
flag = true;
|
|
|
common.util.__tip("网络请求异常");
|
|
|
});
|
...
|
...
|
@@ -72,28 +71,27 @@ var Bll = { |
|
|
}
|
|
|
};
|
|
|
|
|
|
if(type != "add") {
|
|
|
if (type != "add") {
|
|
|
var id = location.href.substring(location.href.lastIndexOf("/") + 1);
|
|
|
common.util.__ajax({
|
|
|
url: "/limitCode/getLimitCode",
|
|
|
data: {id: id}
|
|
|
}, function (res) {
|
|
|
editBean = res.data;
|
|
|
|
|
|
editBean.reqDepartment = editBean.reqDepartment.split("/");
|
|
|
if(!editBean.reqDepartment.length) {
|
|
|
editBean.reqDepartment = editBean.reqDepartment?editBean.reqDepartment.split("/"):"";
|
|
|
if (!editBean.reqDepartment.length) {
|
|
|
editBean.reqDepartment = [
|
|
|
"零售部",
|
|
|
"营销策划"
|
|
|
];
|
|
|
}
|
|
|
editBean.selected = editBean.skus ? "SKU" : "SKN";
|
|
|
editBean.updateType = type == "edit" ? "1":"2";
|
|
|
editBean.updateType = type == "edit" ? "1" : "2";
|
|
|
editBean.skusInfo = [];
|
|
|
if(editBean.skus) {
|
|
|
if (editBean.skus) {
|
|
|
var skuArr = editBean.skus.split(";");
|
|
|
var skuNumArr = editBean.skuTimes.split(";");
|
|
|
for(var i = 0; i < skuArr.length; i++) {
|
|
|
for (var i = 0; i < skuArr.length; i++) {
|
|
|
editBean.skusInfo.push({
|
|
|
"sku": skuArr[i],
|
|
|
"skuTimes": skuNumArr[i]
|
...
|
...
|
@@ -101,7 +99,7 @@ if(type != "add") { |
|
|
}
|
|
|
}
|
|
|
Bll.__render();
|
|
|
},true);
|
|
|
}, true);
|
|
|
} else {
|
|
|
Bll.__render();
|
|
|
}
|
...
|
...
|
@@ -114,8 +112,8 @@ $(document).on("change", ".observe", function () { |
|
|
editBean = common.util.__buildobj(name, '.', editBean, function (obj, name) {
|
|
|
obj[name] = $this.val();
|
|
|
});
|
|
|
if($this.prop("id") == "limitDateFrom" && new Date($this.val()).getTime() ) {
|
|
|
if(new Date(editBean.currTime).getTime() > new Date(editBean.limitDateFrom)) {
|
|
|
if ($this.prop("id") == "limitDateFrom" && new Date($this.val()).getTime()) {
|
|
|
if (new Date(editBean.currTime).getTime() > new Date(editBean.limitDateFrom)) {
|
|
|
limitDateToObj.setStartDate(editBean.currTime);
|
|
|
} else {
|
|
|
limitDateToObj.setStartDate(editBean.limitDateFrom);
|
...
|
...
|
@@ -124,12 +122,12 @@ $(document).on("change", ".observe", function () { |
|
|
});
|
|
|
|
|
|
//输入限制
|
|
|
$(document).on("keyup", ".number", function() {
|
|
|
$(document).on("keyup", ".number", function () {
|
|
|
$(this).val($(this).val().replace(/\D/g, ''));
|
|
|
});
|
|
|
|
|
|
//单选框点击事件
|
|
|
$(document).on("click", ".limitProduct", function() {
|
|
|
$(document).on("click", ".limitProduct", function () {
|
|
|
editBean.limitCodeType = $(this).val();
|
|
|
$("#limitSkn").attr("required", !(editBean.limitCodeType == "N"));
|
|
|
Bll.__render();
|
...
|
...
|
@@ -149,8 +147,8 @@ $(document).on("click", ".addSku", function () { |
|
|
Bll.__render();
|
|
|
});
|
|
|
|
|
|
$(document).on("blur", "#limitSkn", function() {
|
|
|
Bll.__checkSkn(function(res) {
|
|
|
$(document).on("blur", "#limitSkn", function () {
|
|
|
Bll.__checkSkn(function (res) {
|
|
|
if (res.data.skuList) {
|
|
|
editBean.skusInfo = [];
|
|
|
for (var i = 0; i < res.data.skuList.length; i++) {
|
...
|
...
|
@@ -168,45 +166,45 @@ $(document).on("blur", "#limitSkn", function() { |
|
|
/**
|
|
|
* 保存事件
|
|
|
*/
|
|
|
$(document).on("click","#save_brand", function() {
|
|
|
$(document).on("click", "#save_brand", function () {
|
|
|
// 限购码状态0:待审核 1:审核通过 2:驳回 3:过期 4:作废
|
|
|
if(e.validate() && (type == "add" ? (!editBean.limitSkn || !Bll.__checkSkn()) : true)) {
|
|
|
if(editBean.limitCodeType == "U") {
|
|
|
if (e.validate() && (type == "add" ? (!editBean.limitSkn || !Bll.__checkSkn()) : true)) {
|
|
|
if (editBean.limitCodeType == "U") {
|
|
|
for (var i in editBean.skusInfo) {
|
|
|
if(!editBean.skusInfo[i].skuTimes || editBean.skusInfo[i].skuTimes == "0") {
|
|
|
if (!editBean.skusInfo[i].skuTimes || editBean.skusInfo[i].skuTimes == "0") {
|
|
|
common.util.__tip("SKU数量不能为0");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(typeof editBean.reqDepartment=="string"){
|
|
|
editBean.reqDepartment=[editBean.reqDepartment];
|
|
|
if (typeof editBean.reqDepartment == "string") {
|
|
|
editBean.reqDepartment = [editBean.reqDepartment];
|
|
|
}
|
|
|
editBean.reqDepartment =editBean.reqDepartment.join("/");
|
|
|
editBean.reqDepartment = editBean.reqDepartment.join("/");
|
|
|
editBean.creatorId = $("#auth_id").val();
|
|
|
editBean.creatorName = $("#auth_name").val();
|
|
|
if (editBean.status != 1) {
|
|
|
editBean.status = 0;
|
|
|
}
|
|
|
if(editBean.limitCodeType == "U") {
|
|
|
if (editBean.limitCodeType == "U") {
|
|
|
editBean.skus = "";
|
|
|
editBean.skuTimes = "";
|
|
|
for(var item in editBean.skusInfo) {
|
|
|
if(item != 0) {
|
|
|
editBean.skus+=";";
|
|
|
editBean.skuTimes+=";";
|
|
|
for (var item in editBean.skusInfo) {
|
|
|
if (item != 0) {
|
|
|
editBean.skus += ";";
|
|
|
editBean.skuTimes += ";";
|
|
|
}
|
|
|
editBean.skus += editBean.skusInfo[item].sku;
|
|
|
editBean.skuTimes+=editBean.skusInfo[item].skuTimes;
|
|
|
editBean.skuTimes += editBean.skusInfo[item].skuTimes;
|
|
|
}
|
|
|
}
|
|
|
console.log("action",action);
|
|
|
console.log("action", action);
|
|
|
console.log(editBean);
|
|
|
common.util.__ajax({
|
|
|
url: action,
|
|
|
data: editBean
|
|
|
}, function (res) {
|
|
|
console.log("res",res);
|
|
|
console.log("res", res);
|
|
|
// location.href = "/market/limitcode/index";
|
|
|
});
|
|
|
}
|
...
|
...
|
|