Authored by LiQZ

新增编辑功能完成

... ... @@ -16,15 +16,23 @@ module.exports = function (app) {
});
// app.get("/product/bundle/:id", "product.productBundle.Edit", productBundle_findProductBundleByID, function(apiReq, req, res) {
// this.$extend = {
// moduleName: "营销管理",
// pageName: "编辑套餐",
// action: "/product/bundle/save",
// data: apiReq.data
// }
//
// });
app.get("/product/bundle/:id", "product.productBundle.Edit", "productBundle_findProductBundleByID", function(apiReq) {
// 日期处理
apiReq.data.beginTimeStr = toDate(apiReq.data.startTime);
apiReq.data.endTimeStr = toDate(apiReq.data.endTime);
if (apiReq.data.productSkn) {
apiReq.data.skns = apiReq.data.productSkn.split("/");
}
this.$extend = {
moduleName: "营销管理",
pageName: "编辑套餐",
action: "/product/bundle/save",
data: apiReq.data
}
});
app.post("/product/bundle/list", "productBundle_productBundleList");
... ... @@ -34,3 +42,13 @@ module.exports = function (app) {
}
function toDate(seconds) {
if (!seconds || seconds <= 0) { return ''; }
var date = new Date(seconds * 1000);
return fixTwo(date.getFullYear()) + '-' + fixTwo((date.getMonth() + 1)) + '-' + fixTwo(date.getDate()) + ' ' + fixTwo(date.getHours()) + ':' + fixTwo(date.getMinutes()) + ':' + fixTwo(date.getSeconds());
}
function fixTwo(number) {
return number < 10? "0" + number: number;
}
... ...
... ... @@ -36,11 +36,11 @@
<div class="form-group">
<label class="col-sm-2 control-label">有效时间:</label>
<div class="col-sm-2">
<input id="beginTimeStr" data-time="" value="<%if data%><% data.beginTimeStr %><%/if%>" type="text" class="form-control" jsaction="time" placeholder="开始时间" readonly required>
<input id="beginTimeStr" data-time="" value="<%if data%><% data.beginTimeStr %><%/if%>" type="text" class="form-control" jsaction="time:end:endTimeStr" placeholder="开始时间" readonly required>
</div>
<div class="col-sm-1" style="width: 28px;">~</div>
<div class="col-sm-2">
<input id="endTimeStr" data-time="" value="<%if data%><% data.endTimeStr %><%/if%>" type="text" class="form-control" jsaction="time" placeholder="结束时间" readonly required>
<input id="endTimeStr" data-time="" value="<%if data%><% data.endTimeStr %><%/if%>" type="text" class="form-control" jsaction="time:begin:beginTimeStr" placeholder="结束时间" readonly required>
</div>
</div>
<div class="form-group">
... ... @@ -56,13 +56,13 @@
</thead>
<tbody>
<tr>
<td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.productSkn1 %><%/if%>"> </td>
<td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.skns[0]%><%/if%>"> </td>
<td>
<button type="button" class="btn btn-default btn-sm btn-down"><span class="glyphicon glyphicon-chevron-down"></span></button>
</td>
</tr>
<tr>
<td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.productSkn2 %><%/if%>"> </td>
<td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.skns[1]%><%/if%>"> </td>
<td>
<div class="btn-group">
<button type="button" class="btn btn-default btn-sm btn-up"><span class="glyphicon glyphicon-chevron-up"></span></button>
... ... @@ -71,7 +71,7 @@
</td>
</tr>
<tr>
<td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.productSkn3 %><%/if%>"> </td>
<td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.skns[2]%><%/if%>"> </td>
<td>
<div class="btn-group">
<button type="button" class="btn btn-default btn-sm btn-up"><span class="glyphicon glyphicon-chevron-up"></span></button>
... ... @@ -80,7 +80,7 @@
</td>
</tr>
<tr>
<td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.productSkn4 %><%/if%>"> </td>
<td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.skns[3]%><%/if%>"> </td>
<td><button type="button" class="btn btn-default btn-sm btn-up"><span class="glyphicon glyphicon-chevron-up"></span></button>
</td>
</tr>
... ...
... ... @@ -4,24 +4,25 @@ var e = new common.edit('#editor-group');
e.on("validate", function () {
if (new Date($("#beginTimeStr").val()).getTime() >= new Date($("#endTimeStr").val()).getTime()) {
return "开始时间必须小于结束时间";
}
var discount = $("#discount").val();
if (!/^1|0\.[0-9][0-9]$/.test(discount) || discount > 1.0) {
if (!/^1|0\.[0-9]{0,2}$/.test(discount) || discount > 1.0 || discount <= 0.0) {
return "折扣格式不正确";
}
var skns = '';
$("input[name='productSkn']").each(function (index) {
var skn = $(this).val();
if (skn && skn.length > 1) {
var iptSkns = $("input[name='productSkn']");
for (var i = 0, l = iptSkns.length; i < l; i++) {
var $thiz = $(iptSkns[i]);
var skn = $.trim($thiz.val());
if (/^[1-9][0-9]{4,10}$/.test(skn)) {
skns = skns + skn + "/";
} else if(skn.length != 0) {
return "第 " + (i + 1) + " 个 SKN 格式错误";
}
});
}
var lio = skns.lastIndexOf("/");
... ... @@ -45,8 +46,6 @@ $('#add-btn').click(function(option) {
data.startTime = toSeconds(data.beginTimeStr);
data.endTime = toSeconds(data.endTimeStr);
data.popupPic = $("#popupPic").parent().find("img").attr("src");
option.beforeSend = function() {
$('#add-btn').addClass('disabled');
};
... ... @@ -54,7 +53,7 @@ $('#add-btn').click(function(option) {
option.success = function(res) {
if (res.code == "200") {
e.$tip('提交成功', function() {
location.href = "/activity/yohocoin/index";
location.href = "/product/bundle/index";
}, 'growl-success');
} else {
$('#add-btn').removeClass('disabled');
... ... @@ -91,7 +90,3 @@ function toSeconds(strDate) {
var seconds = new Date(strDate).getTime() / 1000;
return seconds;
}
$("#set_default_img").click(function() {
$("#popupPic").parent().find("img").attr("src", default_img);
});
... ...
... ... @@ -39,6 +39,10 @@ var tableGird = new common.grid({
return items.discount;
}},
{ display: "状态", render: function(items) {
if (items.status != 1) {
return "已终止";
}
return '';
}},
{ display: "操作信息", render: function(items) {
... ... @@ -46,7 +50,7 @@ var tableGird = new common.grid({
}},
{ display: "操作", render: function(items) {
var HtmArr = [];
HtmArr.push('<a href="/activity/yohocoin/update/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
HtmArr.push('<a href="/product/bundle/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
HtmArr.push('<a href="javascript:void(0);" data-id="' + items.id + '" class="btn btn-danger btn-xs delete">删除</a>');
return HtmArr.join('');
}
... ...