Authored by ZhongW

Merge branch 'dev_zw' into dev_5.5

# Conflicts:
#	code/static/sass/module/decorator-modular.css
... ... @@ -21,12 +21,7 @@ module.exports={
title: "保存编辑",
url: '/productBundleSaveOrUpdate',
params: [
{ name: 'id', type: 'Number'},
{ name: 'productSkn', type: 'String'},
{ name: 'bundleName', type: 'String'},
{ name: 'discount', type: 'Number'},
{ name: 'startTime', type: 'Number'},
{ name: 'endTime', type: 'Number'}
{ name: 'boListStr', type: 'String'}
]
},
productBundleStop: {
... ...
... ... @@ -52,58 +52,75 @@
<input id="endTimeStr" data-time="" value="<%if data%><% data.endTimeStr %><%/if%>" type="text" class="form-control" jsaction="date:begin:beginTimeStr" placeholder="结束时间" readonly required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">套餐商品:</label>
<div class="col-sm-4">
<input type="hidden" id="productSkn" value="">
<table class="table table-bordered">
<thead>
<tr>
<th>SKN</th>
<th>排序</th>
</tr>
</thead>
<tbody>
<tr>
<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.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>
<button type="button" class="btn btn-default btn-sm btn-down"><span class="glyphicon glyphicon-chevron-down"></span></button>
</div>
</td>
</tr>
<tr>
<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>
<button type="button" class="btn btn-default btn-sm btn-down"><span class="glyphicon glyphicon-chevron-down"></span></button>
</div>
</td>
</tr>
<tr>
<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>
</tbody>
</table>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">优惠力度:</label>
<div class="col-sm-3">
<input type="text" id="discount" placeholder="折扣" class="form-control" required maxlength="10" value="<% if data%><% data.discount %><%/if%>">
<span class="help-inline red">支持0.01-1之间的数字</span>
<div class="form-group">
<label class="col-sm-2 control-label">选择店铺:</label>
<select id="shop" name="shopId" style="width:15%" tabindex="-1" title="" value="<%if data%><% data.shopId %><%/if%>" class="form-control">
<option value="-1">请选择店铺</option>
</select>
<input type="hidden" id="productSkn" value="<%if data%><%data.productSkn%><%/if%>">
<input type="hidden" id="edit-discount" value="<%if data%><%data.discount%><%/if%>">
</div>
<div class="form-group">
<div class="col-sm-2">
</div>
</div>
<div class="col-sm-8">
<table style="width:100%;border-collapse:separate; border-spacing:10px;" id="bundleItem">
<tr>
<td style="width:10%">店铺:</td>
<td>
<span class="help-inline red" id="shopLable"><%if data%><%data.shopName%><%/if%></span>
<input type="hidden" id="shopId" value="<%if data%><%data.shopId%><%/if%>">
</td>
</tr>
<tr>
<td style="width:10%">折扣配置:</td>
<td><input type="text" id="discount" placeholder="折扣" class="form-control" required maxlength="10" value="" style="width:40%">
<span class="help-inline red">支持0.01-1之间的数字</span>
</td>
</tr>
<tr>
<td>套餐商品配置:</td>
<td>
<%if data%> <%else%><input class="btn btn-success add-bundle-btn" type="button" value="添加一组"></input> <%/if%>
</td>
</tr>
<tr>
<td colSpan="2">
<table style="width:100%;padding:10px" border="1">
<thead>
<tr >
<td align="center" style="width:60%">SKN </td>
<td align="center" style="width:20%">折扣</td>
<td align="center" style="width:20%">操作</td>
</tr>
</thead>
<tbody id="budle-table">
<tr>
<td>
<input type="text" name="productSkn" value="" style="width:23%">
<input type="text" name="productSkn" value="" style="margin-left:5px;width:23%">
<input type="text" name="productSkn" value="" style="margin-left:5px;width:23%">
<input type="text" name="productSkn" value="" style="margin-left:5px;width:23%">
</td>
<td align="center">
<input type="text" name="bundleDiscount" placeholder="折扣" class="form-control" required maxlength="10" value="0.95" style="width:40%">
</td>
<td align="center">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
... ... @@ -122,3 +139,4 @@
... ...
... ... @@ -55,3 +55,7 @@
</div>
<div id="tooltip" style="width:400px;height:130px;display:none;background-color:#f6f7f7;color:#333333;line-height:18px;border:1px solid #e1e3e2;padding:5px;">
</div>
... ...
'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
... ...
... ... @@ -32,7 +32,13 @@ var tableGird = new common.grid({
{ display: "组合套餐号", name: "id" },
{ display: "套餐名称", name: "bundleName" },
{ display: "SKN", render: function(items) {
return items.productSkn.replace(/,/g, '/');
var imgHtml = "<table><tr>" ;
$.each(items.productInfoList,function(index,item){
imgHtml += "<td><img data-productName='" + item.productName + "' data-salePrice='" + item.salePrice + "' data-sknStatus='" + item.sknStatus + "' data-storageNum='" + item.storageNum + "' class=\"viewSknImg\" src=\""+item.productPicImg+"\"/></td>";
})
imgHtml += "</tr></table>"
return imgHtml;
}},
{ display: "品牌", render: function(items) {
return items.brand;
... ... @@ -104,6 +110,52 @@ function fixTwo(number) {
return number < 10? "0" + number: number;
}
//获取鼠标坐标
function mousePosition(ev){
ev = ev || window.event;
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
/**
* 悬浮事件
*/
$(document).on('mouseover', '.viewSknImg', function (e) {
var productName = $(this).attr("data-productName");
var salePrice = $(this).attr("data-salePrice");
var sknStatus = $(this).attr("data-sknStatus");
var storageNum = $(this).attr("data-storageNum");
var mousePos = mousePosition(e);
var xOffset = 1;
var yOffset = 1;
$("#tooltip").css("display","block").css("position","absolute").css("top",(mousePos.y - yOffset) + "px").css("left",(mousePos.x + xOffset) + "px");
var html = "";
html += "<span><strong>商品名:</strong>"+productName+"</span><br>";
html += "<span><strong>销售价:</strong>"+salePrice+"</span><br>";
html += "<span><strong>上下架状态:</strong>"+sknStatus+"</span><br>";
html += "<span><strong>库存:</strong>"+storageNum+"</span><br>";
html += "<span><strong>套餐价:</strong></span><br>";
$("#tooltip").append(html);
});
/**
* 悬浮事件
*/
$(document).on('mouseout', '.viewSknImg', function (e) {
$("#tooltip").css("display","none");
$("#tooltip").html("");
});
/**
* 删除--点击事件
*/
... ...