|
|
'use strict';
|
|
|
var $ = require('jquery'), common = require('../../../common/common');
|
|
|
|
|
|
var dropDown = new common.dropDown({
|
|
|
el: '#shop',
|
|
|
ajax: 'shopsRest'
|
|
|
});
|
|
|
|
|
|
var e = new common.edit('#editor-group');
|
|
|
|
|
|
e.on("validate", function () {
|
...
|
...
|
@@ -24,21 +30,81 @@ e.on("validate", function () { |
|
|
}
|
|
|
}
|
|
|
|
|
|
var lio = skns.lastIndexOf(",");
|
|
|
/*var lio = skns.lastIndexOf(",");
|
|
|
|
|
|
if (lio == -1) {
|
|
|
return "请填写商品 SKN";
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
$("#productSkn").val(skns.substring(0, lio));
|
|
|
// $("#productSkn").val(skns.substring(0, lio));
|
|
|
|
|
|
});
|
|
|
|
|
|
e.init();
|
|
|
|
|
|
if($("#id").val()){
|
|
|
var sknArray = $("#productSkn").val().split(",");
|
|
|
var shopName = $("#shopName").val();
|
|
|
$.each(sknArray,function(index,item){
|
|
|
$($("#budle-table").find("input[name='productSkn']")[index]).val(item);
|
|
|
})
|
|
|
$("#budle-table").find("input[name='bundleDiscount']").val($("#edit-discount").val());
|
|
|
|
|
|
$("#shopLable").text(shopName);
|
|
|
}
|
|
|
|
|
|
|
|
|
// submit
|
|
|
$('#add-btn').click(function(option) {
|
|
|
e.submit($('#add-form').attr('action'), function(option) {
|
|
|
|
|
|
var bundleName = $("#bundleName").val();
|
|
|
var startTime = toSeconds($("#beginTimeStr").val());
|
|
|
var endTime = toSeconds($("#endTimeStr").val());
|
|
|
var shopId = $("#shopId").val();
|
|
|
var id = $("#id").val();
|
|
|
|
|
|
|
|
|
var bundleArray = [];
|
|
|
$("#budle-table").find("tr").each(function(){
|
|
|
var bundle = {};
|
|
|
var sknList = [];
|
|
|
$(this).find("input[name='productSkn']").each(function(){
|
|
|
sknList.push($(this).val());
|
|
|
});
|
|
|
bundle.productSkn = sknList.join(",");
|
|
|
bundle.discount = $(this).find("input[name='bundleDiscount']").val();
|
|
|
bundle.bundleName=bundleName;
|
|
|
bundle.startTime=startTime;
|
|
|
bundle.endTime=endTime;
|
|
|
bundle.shopId=shopId;
|
|
|
bundle.id=id;
|
|
|
bundleArray.push(bundle);
|
|
|
})
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
dataType: 'json',
|
|
|
url: '/product/bundle/save',
|
|
|
data: {"boListStr":JSON.stringify(bundleArray)},
|
|
|
success: function (rs) {
|
|
|
var data = rs;
|
|
|
// $('.historyDetail').html($(common.util.__template2($("#template2").html(), data.data)));
|
|
|
|
|
|
if(data.code == 200){
|
|
|
common.util.__tip(data.message, 'success');
|
|
|
history.go(-1)
|
|
|
}else{
|
|
|
common.util.__tip(data.message, 'warning');
|
|
|
}
|
|
|
},
|
|
|
error: function (rs) {
|
|
|
// $('.historyDetail').html($(common.util.__template2($("#template2").html(), {})));
|
|
|
common.util.__tip(rs.message, 'danger');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/*e.submit($('#add-form').attr('action'), function(option) {
|
|
|
|
|
|
var data = option.data;
|
|
|
|
...
|
...
|
@@ -48,6 +114,9 @@ $('#add-btn').click(function(option) { |
|
|
|
|
|
option.beforeSend = function() {
|
|
|
$('#add-btn').addClass('disabled');
|
|
|
console.log(data);
|
|
|
data.zw="123";
|
|
|
// analyzeBundleTable();
|
|
|
};
|
|
|
|
|
|
option.success = function(res) {
|
...
|
...
|
@@ -65,9 +134,10 @@ $('#add-btn').click(function(option) { |
|
|
option.error = function(res) {
|
|
|
e.$tip("提交失败");
|
|
|
};
|
|
|
});
|
|
|
});*/
|
|
|
});
|
|
|
|
|
|
|
|
|
$(".btn-up").click(function() {
|
|
|
var tr = $(this).parents("tr");
|
|
|
var ipt = tr.find("input[name='productSkn']");
|
...
|
...
|
@@ -90,3 +160,66 @@ function toSeconds(strDate) { |
|
|
var seconds = new Date(strDate).getTime() / 1000;
|
|
|
return seconds;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(".add-bundle-btn").click(function() {
|
|
|
|
|
|
var bundleHtml = "";
|
|
|
bundleHtml += "<tr>";
|
|
|
bundleHtml += "<td>";
|
|
|
bundleHtml += "<input type=\"text\" name=\"productSkn\" value=\"\" style=\"width:23%\"><input name=\"productSkn\" type=\"text\" value=\"\" style=\"margin-left:5px;width:23%\">";
|
|
|
bundleHtml += "<input type=\"text\" name=\"productSkn\" value=\"\" style=\"margin-left:5px;width:23%\"><input name=\"productSkn\" type=\"text\" value=\"\" style=\"margin-left:5px;width:23%\"></td>";
|
|
|
bundleHtml += "<td align=\"center\"><input type=\"text\" name=\"bundleDiscount\" placeholder=\"折扣\" class=\"form-control\" required maxlength=\"10\" value=\"0.9\" style=\"width:40%\">";
|
|
|
bundleHtml += "</td><td align=\"center\"><input class=\"btn btn-danger delete-bundle-btn\" type=\"button\" value=\"删除\" style=\"margin:5px\"></input>";
|
|
|
bundleHtml += "</td></tr> ";
|
|
|
$("#budle-table").append(bundleHtml);
|
|
|
$(".delete-bundle-btn").click(function() {
|
|
|
$(this).parent().parent().remove();
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("#shop").change(function(){
|
|
|
// console.log(dropDown.getValue().text);
|
|
|
$("#shopId").val(dropDown.getValue().id);
|
|
|
$("#shopLable").text(dropDown.getValue().text);
|
|
|
})
|
|
|
|
|
|
$("#discount").blur(function(){
|
|
|
|
|
|
var discount = $("#discount").val();
|
|
|
if (!/^1|0\.[0-9]{0,2}$/.test(discount) || discount > 1.0 || discount <= 0.0) {
|
|
|
common.util.__tip("折扣格式不正确", 'warning');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$("input[name='bundleDiscount']").each(function(){
|
|
|
$(this).val($("#discount").val());
|
|
|
})
|
|
|
})
|
|
|
|
|
|
|
|
|
// function analyzeBundleTable(){
|
|
|
|
|
|
// $("#budle-table").find("tr").each(function(){
|
|
|
|
|
|
// })
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//新版本控制
|
|
|
//$("#basicInfo").html(common.util.__template2($("#template2").html(),RESPONSEDATA));
|
|
|
|
|
|
// bundleTemplate
|
|
|
|
|
|
|
|
|
/*[
|
|
|
{"bundleDiscount":12,"bundleConfig":[{"skn":1234,"discount":0.9},{"skn":1234,"discount":"0.8"}]}
|
|
|
]*/
|
|
|
|
|
|
/*var bundleTemplateData = [];
|
|
|
*/ |
|
|
\ No newline at end of file |
...
|
...
|
|