码迷,mamicode.com
首页 > 其他好文 > 详细

父子窗口

时间:2018-02-02 17:11:08      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:dex   head   show   shu   char   views   ges   content   replace   

<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>开单管理</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
$(document).ready(function() {
//$("#name").focus();
$("#btnSubmit").click(function(){
changeJieyuhou();
$("#inputForm").submit();
});

$("#inputForm").validate({
submitHandler: function(form){
loading(‘正在提交,请稍等...‘);
form.submit();
},
errorContainer: "#messageBox",
errorPlacement: function(error, element) {
$("#messageBox").text("输入有误,请先更正。");
if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
error.appendTo(element.parent().parent());
} else {
error.insertAfter(element);
}
}
});
});
function getGoods() {
var factory = $("#factory :selected").val();
var store = $("#suibianName").val();
if(factory=="" || factory == null || store=="" || store == null){
layer.alert("厂商和门店为必选项");
return;
}
layer.open({
id: ‘selectGood-form‘,//定义子页面的ID标记
type: 2,
title: ‘货品列表‘,
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ["70%", "90%"],
/*content: "${ctx}/kd/kdSale/getGoods"*/
content: "${ctx}/kd/kdSale/getGoods?factory="+factory+"&store="+store+""
,btn: [‘全选‘, ‘不选‘, ‘确认‘]
,yes: function(index, layero){
var frameId=document.getElementById(‘selectGood-form‘).getElementsByTagName("iframe")[0].id;
$(‘#‘+frameId)[0].contentWindow.choice(1);
}
,btn2: function(index, layero){
var frameId=document.getElementById(‘selectGood-form‘).getElementsByTagName("iframe")[0].id;
$(‘#‘+frameId)[0].contentWindow.choice(2);
return false;
}
,btn3: function(index, layero){
var frameId=document.getElementById(‘selectGood-form‘).getElementsByTagName("iframe")[0].id;
$(‘#‘+frameId)[0].contentWindow.addGoods();
}

});
}
function out(obj) {
$("#span" + obj).show();
$("#but" + obj).hide();
}

function over(obj) {
$("#span" + obj).hide();
$("#but" + obj).show();
}
function removerow(obj) {
$(obj).parent().parent().remove();
changeTotalAndPayable();
}

//动态改变小计金额
function changeNum(obj) {
var id=obj.id.substring(3);
//获取销售数量和库存数量
var saleCount=parseInt($("#num"+id).val());
var stockCount=parseInt($("#stock"+id).val());
//alert(saleCount+"===="+stockCount);
if(saleCount>stockCount){
layer.alert("库存不足,请重新输入");
$("#num"+id).val(1);
$("#amount"+id).val(parseFloat($("#price"+id).val()));
}else{
var value= parseFloat($("#price"+id).val())*parseFloat($("#num"+id).val())
$("#amount"+id).val(value);
}
changeTotalAndPayable();
}

//动态改变总数和应付金额
function changeTotalAndPayable() {
var nums = 0;
var sum = 0;
//求货品总数和总额
$("input[name=‘num‘]").each(function (index) {
var id = $(this).attr("id").substring(3) ;
var num = parseFloat($(this).val());
nums += num;
sum += num*parseFloat($("#price"+id).val());
});
$("#total").val(nums);//总数
$("#payable").val(sum);//应付金额
}


function distKnameField(obj) {
var id = obj.selectedIndex;
var value = obj.options[id].value;
var text = obj.options[id].text;
$.post("${ctx}/wl/wlCustomer/getCustom", {id: value},
function (res) {
var data= $.parseJSON(res);
if(value!="") {//表示已选择了一个客户
$("#kname").val(text);
var amount=parseFloat(data.advanceAmount)+parseFloat(data.forCash)+parseFloat(data.wechatAmount)+parseFloat(data.alipayAmount);
//结余=额度+现金+微信+支付宝
$("#jieyu").val(amount);
$("#edu").val(data.advanceAmount);
$("#weixin").val(data.wechatAmount);
$("#xianjin").val(data.forCash);
$("#zhifubao").val(data.alipayAmount);
}
else{
$("#kname").val(0);
$("#jieyu").val(0);
$("#weixin").val(0);
$("#xianjin").val(0);
$("#zhifubao").val(0);
}
}
);
}
function changeJieyuhou() {
//计算“结余后”的值
var edu=$("#edu").val();
var xianjin=$("#xianjin").val();
var hexiao = $("#hexiao").val();
//核销金额>额度
if(parseFloat(hexiao)>parseFloat(edu)){
layer.alert("核销金额已超出使用额度!");
$("#jieyuhou").val("");
return;
}
var shuaka = $("#shuaka").val();
//刷卡金额>现金
if(parseFloat(shuaka)>parseFloat(xianjin)){
layer.alert("刷卡金额已超出现有金额!");
$("#jieyuhou").val("");
return;
}
var jieyu = $("#jieyu").val();
var huikuan = $("#huikuan").val();
//实付金额=核销+刷卡+汇款
var shifu=parseFloat(hexiao)+parseFloat(shuaka)+parseFloat(huikuan);
//结余后金额=结余-核销-刷卡+汇款
var jieyuhou=parseFloat(jieyu)-parseFloat(hexiao)-parseFloat(shuaka)+parseFloat(huikuan);
$("#jieyuhou").val(jieyuhou);
$("#shifu").val(shifu);
}
</script>
</head>
<body>
<ul class="breadcrumb">
<li>首页<span class="divider"> > </span></li>
<li>销售开单<span class="divider"> > </span></li>
<li class="active">开单</li>
<li style="float: right"><a class="btn btn-primary btn-small" href="#"
onclick="javascript:location.replace(location.href.replace(‘#‘,‘‘));"><i
class="icon-refresh"></i>刷新</a></li>
</ul>
<br/>
<ul class="breadcrumb">
<input id="success" hidden="hidden">
</ul>
<form:form id="inputForm" modelAttribute="kdSale" action="${ctx}/kd/kdSale/save" method="post" class="form-horizontal">
<form:hidden path="id"/>
<sys:message content="${message}"/>
<table>
<tr>
<td>
<div class="control-group">
<label class="control-label">门店:</label>
<div class="controls">
<%-- text5表示门店--%>
<sys:treeselect id="suibian" name="suibianStr" value="" labelName="text5" cssStyle="width:118px"
labelValue=""
title="门店" url="/sys/office/treeData?type=2"
notAllowSelectParent="true"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">厂商:</label>
<div class="controls">
<select id="factory" path="factory" class="input-medium" style="width:176px">
<option value="">请选择</option>
<c:forEach var="bean" items="${fns:getFirmList()}">
<option value="${bean.name}"
>${bean.name}</option>
</c:forEach>
</select>
</div>
</div>
</td>
<td colspan="2">
<div class="control-group">
<label class="control-label">是否挂单:</label>
<form:select path="guadan" class="input-medium" style="width:176px">
<form:options items="${fns:getDictList(‘data_flag‘)}" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:select>

</div>
</td>
</tr>
<tr>
<td>
<div class="control-group">
<label class="control-label">客户:</label>
<input type="hidden" id="kname" name="kname">
<input type="hidden" id="edu" name="edu">
<select path="kid" name="kid" class="input-medium" style="width: 176px" onchange="distKnameField(this)">
<option value="">--请选择--</option>
<c:forEach var="bean" items="${fns:getCustomList()}">
<option value="${bean.id}"
>${bean.name}</option>
</c:forEach>
</select>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">结余:</label>
<div class="controls">
<form:input path="jieyu" htmlEscape="false" readonly="true" cssClass="number input-medium required"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">微信:</label>
<div class="controls">
<form:input path="weixin" htmlEscape="false" readonly="true" cssClass="number input-medium required"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">现金:</label>
<div class="controls">
<form:input path="xianjin" htmlEscape="false" readonly="true" cssClass="number input-medium required"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">支付宝:</label>
<div class="controls">
<form:input path="zhifubao" htmlEscape="false" readonly="true" cssClass="number input-medium required"/>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="control-group">
<label class="control-label">日期:</label>
<div class="controls">
<input name="saleDate" type="text" readonly="readonly" maxlength="20" class="input-medium required Wdate "
value="<fmt:formatDate value="${kdSale.saleDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
onclick="WdatePicker({dateFmt:‘yyyy-MM-dd HH:mm:ss‘,isShowClear:false});"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">店员:</label>
<div class="controls">
<form:input path="storeler" htmlEscape="false" maxlength="64" class="input-medium required"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">应付:</label>
<div class="controls">
<form:input path="payable" htmlEscape="false" readonly="true" cssClass="number input-medium required"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">实付:</label>
<div class="controls">
<form:input path="shifu" htmlEscape="false" readonly="true" cssClass="number input-medium required"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">总数:</label>
<div class="controls">
<form:input path="total" htmlEscape="false" readonly="true" cssClass="number input-medium required"/>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="control-group">
<label class="control-label">备注:</label>
<div class="controls">
<form:input path="remarks" htmlEscape="false" class="input-medium"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">核销:</label>
<div class="controls">
<form:input path="hexiao" htmlEscape="false" maxlength="64" cssClass="number input-medium required"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">刷卡:</label>
<div class="controls">
<form:input path="shuaka" htmlEscape="false" maxlength="64" cssClass="number input-medium required"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">汇款:</label>
<div class="controls">
<form:input path="huikuan" htmlEscape="false" maxlength="64" cssClass="number input-medium required"/>
</div>
</div>
</td>
<td>
<div class="control-group">
<label class="control-label">结余:</label>
<div class="controls">
<form:input path="jieyuhou" htmlEscape="false" maxlength="64" readonly="true" cssClass="number input-medium required"/>
<input id="" class="btn btn-info" type="button" onclick="changeJieyuhou()" value="核销"/>
</div>
</div>
</td>
</tr>
<tr>
<td colspan="5">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;说明:实付金额=核销+刷卡+汇款, 第二个结余 = 结余-核销-刷卡+汇款
</td>
</tr>

<tr>
<td colspan="5">
<div style="height: 10px;"></div>
货品<a class="btn btn-success" href="#" onclick="getGoods()"><i class="layui-icon" data-icon=""></i>新增货品</a>
<div style="height: 10px;"></div>
</td>
</tr>
<tr>
<td colspan="5">
<table class="table table-striped table-bordered table-condensed" id="table">
<tr>
<td>序号</td><td>图片</td><td>货品</td>
<td>颜色</td><td>尺码</td>
<td>数量</td><td>单价</td>
<td>小计</td><td>备注</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="form-actions">
<shiro:hasPermission name="kd:kdSale:edit"><input id="btnSubmit" class="btn btn-primary" type="button" value="保存"/>&nbsp;</shiro:hasPermission>
<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
</div>
</form:form>
</body>
</html>


子页面
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
<title>货品管理</title>
<meta name="decorator" content="default"/>
<%--
<link rel="stylesheet" href="${ctxStatic}/amaze-ui/assets/css/amazeui.min.css" media="all" />
<link rel="stylesheet" href="${ctxStatic}/layui/css/layui.css" media="all" />
--%>
<script type="text/javascript">
$(document).ready(function () {

});
function page(n, s) {
$("#pageNo").val(n);
$("#pageSize").val(s);
$("#searchForm").submit();
return false;
}

function choice(o) {
$("input[name=‘ids‘]").each(function () {
if (o == 1) {
$(this).attr("checked","checked");
} else {
$(this).removeAttr("checked");
//$(this).prop("checked", false)
}
});
}
var str = []; //定义一数组
function addGoods() {
var tmp = parent.$("#table tr").length;
var table = parent.$("#table");
var j = 1,sum=0;
// var tmp =$("#tbody").find("tr").length;
parent.$("#table tr").each(function () {
str.push(parent.$("#goodsId" + j + "").val());
j++;
});
var i = 0, arrChk = $("input[name=‘ids‘]:checked"), goodsId = "", goodsName = "", img = "", color = "", size = "",stock="", price, buf = [];
$(arrChk).each(function () {
goodsId += this.value;
var ss = this.value;
if (str.length > 0) {
for (var j = 0; j < str.length; j++) {
if (ss == str[j]) {
// alert("");
return;
}
}
}
goodsId += ",";
i++;
img = $(this).parents("#tab tr").find(‘td:eq(1)‘).text().trim();
goodsName = $(this).parents("#tab tr").find(‘td:eq(3)‘).text().trim();
color = $(this).parents("#tab tr").find(‘td:eq(5)‘).text().trim();
size = $(this).parents("#tab tr").find(‘td:eq(6)‘).text().trim();
stock = $(this).parents("#tab tr").find(‘td:eq(7)‘).text().trim();
price = $(this).parents("#tab tr").find(‘td:eq(9)‘).text().trim();

buf.push(‘<tr>‘);
buf.push(‘<input type="hidden" name="goodsId" id ="goodsId‘ + tmp + ‘" value="‘, this.value, ‘">‘);
buf.push(‘<input type="hidden" name="stock" id ="stock‘ + tmp + ‘" value="‘,stock, ‘">‘);
buf.push(‘<td align="center" onmouseout="out(‘ + (tmp) + ‘)" onmouseover="over(‘ + (tmp) + ‘)" bgcolor="#FFFFFF"><span id="span‘ + (tmp) + ‘">‘);
buf.push(tmp, ‘</span>‘);
buf.push(‘<button type="button" style="display: none" id="but‘ + (tmp) + ‘" class="btn btn-xs btn-danger" title="删除" onclick="removerow(this)">‘);
// buf.push(‘<td align="center" valign="middle" bgcolor="#FFFFFF">‘,i,‘</td>‘);
buf.push(‘<i class="ace-icon fa fa-trash-o bigger-120"></i>删除</button></span></td>‘);
buf.push(‘<td><input type="hidden" name="pic" id ="pic‘ + tmp + ‘" value="‘,img, ‘"> <image src="‘, img, ‘" alt="logo" style="width:30px;height:40px"/></td>‘);
buf.push(‘<td><input type="hidden" name="styleName" id ="styleName‘ + tmp + ‘" value="‘,goodsName,‘">‘ , goodsName, ‘</td>‘);
buf.push(‘<td><input type="hidden" name="color" id ="color‘ + tmp + ‘" value="‘,color, ‘">‘, color, ‘</td>‘);
buf.push(‘<td><input type="hidden" name="size" id ="size‘ + tmp + ‘" value="‘,size, ‘">‘ , size, ‘</td>‘);
buf.push(‘<td><input type="text" name="num" class="input-small" id ="num‘ + tmp + ‘" value="1" onblur="changeNum(this)"></td>‘);
buf.push(‘<td><input type="hidden" name="price" id ="price‘ + tmp + ‘" value="‘,price, ‘">‘ , price, ‘</td>‘);
buf.push(‘<td><input type="text" name="amount" class="input-small" readonly id ="amount‘ + tmp + ‘" value="‘,price,‘" ></td>‘);
buf.push(‘<td><textarea name="text10" class="input-small" ></textarea></td>‘);
buf.push(‘</tr>‘);
tmp++;
sum = parseInt(sum)+parseInt( price);
});
parent.$("#table").append(buf.join(‘‘));
parent.$("#total").val(i);
parent.$("#payable").val(sum);
}
</script>
</head>
<body>

<form:form id="searchForm" modelAttribute="hpcxCloth" action="${ctx}/kd/kdSale/getGoods" method="post" class="breadcrumb form-search">
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
</form:form>
<table id="tab" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>选择</th>
<th style="display:none"></th>
</div>
<th>图片</th>
<th>名称</th>
<th>类别</th>
<th>颜色</th>
<th>尺码</th>
<th>库存</th>
<th>进价</th>
<th>零售价</th>
<th>打包价</th>
<th>计量单位</th>
</tr>
</thead>
<tbody>
<c:forEach items="${page.list}" var="hpCloth" varStatus="idx">
<tr>
<td>
<input type="checkbox" name="ids" am-filter="choose" value="${hpCloth.id}">${idx.count}
</td>
<td style="display: none">${hpCloth.pic}
</td>
<td>
<image src="${hpCloth.pic}" alt="logo" style="width:30px;height:40px"/>
</td>
<td>
${hpCloth.styleName}
</td>
<td>
${hpCloth.typeName}
</td>
<td>
${hpCloth.color}
</td>
<td>
${hpCloth.size}
</td>
<td>
${hpCloth.stock}
</td>
<td>
${hpCloth.comeinPrice}
</td>
<td>
${hpCloth.zeroPrice}
</td>
<td>
${hpCloth.packPrice}
</td>

<td>
${hpCloth.oneUnit}
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="pagination">
${page}
</div>
</body>
</html>

父子窗口

标签:dex   head   show   shu   char   views   ges   content   replace   

原文地址:https://www.cnblogs.com/gtbky/p/8405655.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!