Authored by 陶雨

限购码添加流程跑通

... ... @@ -76,6 +76,14 @@ e.on("file_onComplete", function (obj) {
fn(drawlineBean);
console.log(drawlineBean);
});
var onlyNumber = function(event){
var keyCode = event.keyCode;
console.log(keyCode);
if(keyCode<48 || keyCode>57){
event.keyCode = 0;
}
}
$(document).on("keydown", ".numberbox",onlyNumber);
common.edit.ajaxfileupload("#productSkn",{
params: {
... ...
... ... @@ -169,8 +169,6 @@ components.prototype={
var name = $this.attr("id"),
values = $this.val().split(/[|,]/g), //String.prototype.split.call($this.val(), '|'),
type = $this.attr("for");
//var name = $this.attr("id"),
//values = $this.val().split()
if (type) {
$(":" + type + "[name=" + name + "]").each(function() {
... ...
... ... @@ -6,6 +6,52 @@ var e = new common.edit2("#basicForm");
var type = $("#basicForm").attr("role"),
action = $("#basicForm").data("action");
var Bll = {
__render:function() {
$("#basicForm").html(common.util.__template2($("#limitcodeEdit-template").html(), editBean));
e.init();
if(type != "add") {
$('input[name="skn_sku"]').prop('disabled', true);
$(".noEdit").prop("disabled", true);
$('input[name="userTypeLimit"]').prop('disabled', true);
if(Bll.getLocalTime(editBean.limitDateFrom) <= Bll.getLocalTime(new Date())) {
$("#limitDateFrom").prop("disabled", true);
}
}
},
__checkSkn:function(callback) {
var flag = false;
common.util.__ajax({
async:false,
url: "/limitCode/checkSknValidity",
data: {skn:editBean.limitSkn}
},function(res) {
if(!res.data.isExist) {
flag = true;
common.util.__tip("SKN不存在");
} else if(res.data.isConflict) {
flag = true;
common.util.__tip("SKN与其他限购冲突");
} else if(res.data.isOnSales) {
flag = true;
common.util.__tip("SKN已上架,请先下架");
}
callback && callback(res);
}, true);
return flag;
},
getLocalTime:function(nS) {
var date = new Date(parseInt(nS) * 1000);
var mm = date.getMonth() + 1;
var dd = date.getDate();
var h = date.getHours();
var min = date.getMinutes();
var second = date.getSeconds();
return date.getFullYear() + "-" + (mm < 10 ? "0" + mm : mm) + "-" + (dd < 10 ? "0" + dd : dd) + " " + (h < 10 ? "0" + h : h) + ":"
+ (min < 10 ? "0" + min : min) + ":" + (second < 10 ? "0" + second : second);
},
};
if(type != "add") {
var id = location.href.substring(location.href.lastIndexOf("/") + 1);
common.util.__ajax({
... ... @@ -20,170 +66,87 @@ if(type != "add") {
"营销策划"
];
}
$("#basicForm").html(common.util.__template2($("#limitcodeEdit-template").html(), editBean));
e.init();
if (type == 'edit') {
//$('#name, #limitTimes, #userUseLimit, #department1, #department2, #limitDateFrom, #limitDateTo, #describe, #UID').prop('disabled', true);
$(".noEdit").prop("disabled", true);
$('input[name="userTypeLimit"]').prop('disabled', true);
$("#indetify").hide();
$("#limit-userUseLimit").hide();
}
editBean.selected = editBean.skus ? "SKU" : "SKN";
Bll.__render();
},true);
} else {
$("#basicForm").html(common.util.__template2($("#limitcodeEdit-template").html(), editBean));
e.init();
$("#indetify").hide();
$("#limit-userUseLimit").hide();
Bll.__render();
}
//var e = new edit("#basicForm");
//
$(document).on("change", ".observe", function () {
var val = $(this).val();
var fn = new Function("editBean", "val", "editBean." + $(this).data("field") + "= val;");
fn(editBean, val);
var $this = $(this);
var name = $this.data("field");
editBean = common.util.__buildobj(name, '.', editBean, function (obj, name) {
obj[name] = $this.val();
});
editBean.limitDateFrom = $("#limitDateFrom").val();
editBean.limitDateTo = $("#limitDateTo").val();
console.log(editBean);
});
$(document).on("change", "#limitSkn", function() {
var val = $(this).val();
if($("#sknsku").val() == "SKU" && val && val.length == 8) {
$(document).on("click", ".limitProduct", function() {
editBean.selected = $(this).val();
Bll.__render();
console.log(editBean);
});
}
$(document).on("click", ".delSku", function () {
var index = $(this).data("index");
editBean.skusInfos.splice(index, 1);
Bll.__render();
});
$(document).on("click", ".addSku", function () {
editBean.skusInfo.push({
"sku": "",
"skuTimes": ""
});
Bll.__render();
});
//
//
//e.on("render", function() {
// if ($("#reqDepartment").val()) {
// var departmentArr = String.prototype.split.call($("#reqDepartment").val(), '/'),
// $department1 = $("#department1"),
// $department2 = $("#department2");
//
// $department1.val(departmentArr[0]);
// if (departmentArr[1]) {
// $department2.val(departmentArr[1]).show();
// } else {
// $department2.hide();
// }
// }
//});
//
//e.on("bind", function() {
// if ($("#reqDepartment").val()) {
// var departmentArr = String.prototype.split.call($("#reqDepartment").val(), '/'),
// $department1 = $("#department1"),
// $department2 = $("#department2");
//
// $("select").change(function() {
// if ($(this).is($department1)) {
// departmentArr.length = 0;
// departmentArr[0] = $(this).val();
// if ($(this).val() === "零售部") {
// $department2.show();
// departmentArr[1] = $department2.val();
// } else {
// $department2.hide();
// }
// } else {
// departmentArr[1] = $(this).val();
// }
// $("#reqDepartment").val(departmentArr.join('/'));
// });
// }
//});
//
//e.on("validate", function() {
// var num = $.trim($("#limitTimes").val());
// if (+num > 100000 || +num < 1) {
// return "数量(范围:1-100000)";
// }
// return true;
//});
//e.on("validate", function() {
// var skn = $.trim($("#limitSkn").val());
// if (skn.length > 8) {
// return "skn长度不能超过8位";
// }
// return true;
//});
//
//e.on("validate", function() {
// var startTime = $('#limitDateFrom').val(),
// endTime = $('#limitDateTo').val();
//
// if (startTime > endTime) {
// return '结束时间不能小于开始时间';
// }
//});
//
//e.init();
//
//var submit = function(callback) {
//
// e.submit($("#basicForm").attr("action"), function(option) {
// $("#save_brand").addClass('disabled');
// option.success = function(res) {
// res = res.data;
// if (res.code == "200") {
// e.$tip('提交成功', function() {
// location.href = "/market/limitcode/index";
// }, 'growl-success');
// } else {
// e.$tip(res.message);
// $("#save_brand").removeClass('disabled');
// };
//
// return false;
// };
// option.error = function(res) {
// $("#save_brand").removeClass('disabled');
// e.$tip("提交失败");
// }
// console.log(option.data);
// callback && callback(option.data);
// });
//}
//
//
$("#save_brand").click(function() {
//submit(function(data) {
// // 限购码状态0:待审核 1:审核通过 2:驳回 3:过期 4:作废
// if (+data.status == 1) {
// //不改
// } else {
// data.status = 0;
// }
//});
if(e.validate()) {
editBean.limitDateFrom = $("#limitDateFrom").val();
editBean.limitDateTo = $("#limitDateTo").val();
$(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++) {
editBean.skusInfo.push({
"sku": res.data.skuList[i],
"skuTimes": ""
});
}
$(".addSku").prop("disabled", false);
}
Bll.__render();
});
});
$(document).on("blur", ".skus", function() {
//TODO
});
$(document).on("click","#save_brand", function() {
// 限购码状态0:待审核 1:审核通过 2:驳回 3:过期 4:作废
if(e.validate() && (!editBean.limitSkn || !Bll.__checkSkn())) {
editBean.reqDepartment = editBean.reqDepartment.join("/");
editBean.creatorId = $("#auth_id").val();
editBean.creatorName = $("#auth_name").val();
if (editBean.status != 1) {
editBean.status = 0;
}
console.log(editBean);
if(editBean.selected != "SKN") {
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;
}
}
common.util.__ajax({
url: action,
data: editBean
}, function (res) {
location.href = "/market/limitcode/index";
//editBean = res.data;
//editBean.reqDepartment = editBean.reqDepartment.split("/");
//if(!editBean.reqDepartment.length) {
// editBean.reqDepartment = [
// "零售部",
// "营销策划"
// ];
//}
//$("#basicForm").html(common.util.__template2($("#limitcodeEdit-template").html(), editBean));
//e.init();
},function() {
editBean.reqDepartment = editBean.reqDepartment.split("/");
});
}
return false;
... ...
... ... @@ -31,7 +31,9 @@ var g = new common.grid({
batchNo:common.util.__input("filter-id"),
name:common.util.__input("filter-name"),
reqDepartment:common.util.__input("filter-dep"),
status: t.active
status: t.active,
skn: common.util.__input("filter-skn"),
sku: common.util.__input("filter-sku")
};
},
columns:[
... ... @@ -52,6 +54,15 @@ var g = new common.grid({
{display:"限购码使用说明",name:"describe", render: function(item) {
return '<p style="max-width: 200px;word-wrap: break-word;">' + item.describe + '</p>';
}},
{display:"SKN/SKU", render: function(item) {
var arr = [];
var skn = item.skn?item.skn:"";
arr.push('<p style="max-width: 200px;word-wrap: break-word;">SKN:' + item.skn + '</p>');
if(item.skus) {
arr.push('<p style="max-width: 200px;word-wrap: break-word;">SKU:' + item.skus + '</p>');
}
return arr.join("");
}},
{display:"申请人",name:"creatorName", render: function(item) {
return item.creatorName + '<br>' + item.createTime;
}},
... ...
... ... @@ -3,6 +3,8 @@
*/
var limitcode_bean = {
auditTime:"",
batchNo:"",
name:"",
limitTimes:1,
reqDepartment:[
... ... @@ -18,7 +20,11 @@ var limitcode_bean = {
creatorName:"",
creatorId:"",
status:"",
id:""
id:"",
"createTime": "",
"skn": "",
selected:"SKN",
"skusInfo": []
};
module.exports = limitcode_bean;
\ No newline at end of file
... ...
exports.domain = require('../config/common.js').domain;
//exports.domain = require('../config/common.js').domain;
//exports.domain = 'http://172.16.6.240:8088/platform';
//exports.domain = 'http://172.16.6.162:8088/platform';
exports.domain = 'http://172.16.6.108:8088/platform';//谭玲
//营销管理路由配置
exports.res = [
... ... @@ -259,7 +260,8 @@ exports.res = [
pageTitle: '限购码列表',
filter: true,
createUrl: '/market/limitcode/add',
gridurl: '/market/limitcode/getLimitCode'
gridurl: '/market/limitcode/getLimitCode',
limitcode:true
}
}, {
//限购码管理 -> 限购码列表
... ... @@ -344,7 +346,21 @@ exports.res = [
}, {
name: "status",
type: "Number"
}, {
name: "skus",
type: "string"
}, {
name: "skuTimes",
type: "string"
}]
},{
//检查SKN的合法性并且获得其下的所有SKU
route: '/limitCode/checkSknValidity',
method: 'POST',
url: '/limitCode/checkSknValidity',
params:[
{name: "skn", type: "string"}
]
}, {
//限购码管理 -> 查看限购码页面渲染
route: '/market/limitcode/info/:id',
... ...
... ... @@ -65,7 +65,7 @@
<label class="col-sm-2"></label>
<div class="input-group col-sm-6">
<span class="input-group-addon">人数上限:</span>
<input type="text" form="activityForm" class="form-control observe" data-field="limitHum" value="{{limitHum}}" placeholder="人数上限">
<input type="text" form="activityForm" class="form-control observe numberbox" data-field="limitHum" value="{{limitHum}}" placeholder="人数上限">
</div>
</div>
... ...
... ... @@ -33,7 +33,7 @@
<div class="panel-col2">
<input id="filter-id" class="form-control panel-input" type="text" placeholder="请输入批次号">
</div>
<div class="panel-col2">
<div class="panel-col">
<input id="filter-name" class="form-control panel-input" type="text" placeholder="请输入名称">
</div>
<div class="panel-col">
... ... @@ -47,6 +47,14 @@
<option value="其他">其他</option>
</select>
</div>
{{# limitcode}}
<div class="panel-col">
<input id="filter-skn" class="form-control panel-input" type="text" placeholder="请输skn">
</div>
<div class="panel-col">
<input id="filter-sku" class="form-control panel-input" type="text" placeholder="请输sku">
</div>
{{/ limitcode}}
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
<a id="all-btn" href="" class="btn btn-info">全部</a>
</div>
... ...
... ... @@ -54,10 +54,10 @@
<label class="col-sm-2 control-label">使用期限<span class="red">*</span></label>
<div class="col-sm-6">
<div class="col-sm-6">
<input type="text" class="form-control noEdit" jsaction="time:end:limitDateTo" id="limitDateFrom" placeholder="开始时间" value="[[limitDateFrom]]" readonly required>
<input type="text" class="form-control" jsaction="time:end:limitDateTo" id="limitDateFrom" placeholder="开始时间" value="[[limitDateFrom]]" readonly required>
</div>
<div class="col-sm-6">
<input type="text" class="form-control noEdit" jsaction="time:start:limitDateFrom" id="limitDateTo" placeholder="结束时间" value="[[limitDateTo]]" readonly required>
<input type="text" class="form-control" jsaction="time:start:limitDateFrom" id="limitDateTo" placeholder="结束时间" value="[[limitDateTo]]" readonly required>
</div>
</div>
</div>
... ... @@ -75,7 +75,7 @@
<h4 class="panel-title">使用条件</h4>
</div>
<div class="form-group" id="indetify">
<div class="form-group" hidden>
<label class="col-sm-2 control-label">会员身份<i class="red">*</i></label>
<div class="col-sm-10">
<label class="checkbox-inline">
... ... @@ -107,7 +107,7 @@
<input type="hidden" value="[[userTypeLimit]]" id="userTypeLimit" for="checkbox" required placeholder="会员身份">
</div>
<div class="form-group" id="limit-userUseLimit">
<div class="form-group" hidden>
<label class="col-sm-2 control-label">限用次数<i class="red">*</i></label>
<div class="col-sm-8">
<input type="text" prompt="限用次数" placeholder="0 表示不限制" class="form-control observe noEdit" data-field="userUseLimit" required pattern="^[0-9]+$" value="[[userUseLimit]]">
... ... @@ -117,12 +117,31 @@
<div class="form-group">
<label class="col-sm-2 control-label">指定商品</label>
<div class="col-sm-4">
<input type="radio" value="SKN" name="sknsku" checked />SKN
<input type="radio" value="SKU" name="sknsku" />SKU
<input type="hidden" id="sknsku" for="radio" value="[[SKN]]"/>
<div class="col-sm-10">
<input type="radio" class="limitProduct" value="SKN" name="skn_sku" checked />SKN
<input type="radio" class="limitProduct" value="SKU" name="skn_sku" />SKU
<input type="hidden" id="skn_sku" for="radio" value="[[selected]]"/><br>
</div>
<label class="col-sm-3 control-label">SKN值:</label>
<div class="col-sm-4">
<input id="limitSkn" type="text" maxlength="8" placeholder="SKN" class="form-control observe" data-field="limitSkn" value="[[limitSkn]]">
</div><br>
<div id="skus" class="col-sm-10" [[selected=="SKU"?"":"hidden"]]>
<table class="table table-bordered responsive dataTable no-footer">
[[each skusInfo as item index]]
<tr>
<td><input type="text" class="form-control observe skus" data-field="skusInfo.[[index]].sku" value="[[item.sku]]" required></td>
<td><input type="text" class="form-control observe" data-field="skusInfo.[[index]].skuTimes" value="[[item.skuTimes]]" required></td>
<td><a href="javascript:;" class="btn btn-danger btn-xs delSku" data-index="[[index]]">删除</a></td>
</tr>
[[/each]]
<tr>
<td>sku</td>
<td>数量</td>
<td><a href="javascript:;" class="btn btn-info btn-xs addSku" disabled>添加</a></td>
</tr>
</table>
</div>
<div class="col-sm-2">
<input type="number" maxlength="8" id="limitSkn" placeholder="SKN" class="form-control" value="[[limitSkn]]">
</div>
</div>
... ...