問題:有一個頁面的input選值,點擊input之後彈出dialog,選值之後,無法正確傳回,怎麼解決呢?
1.入口html
<p class="input-group">
<input id="txt_proName" type="text" class="form-control" placeholder="点击选择产品" readonly="readonly" />
<span id="span_proName" class="input-group-addon"><span class="glyphicon glyphicon-check" aria-hidden="true"></span></span>
</p>
2.dialog
<p class="panel panel-default panel-box">
<p class="panel-body">
<table class="table table-bordered table-hover content-table">
<thead>
<tr>
<th class="text-center">分销组代码</th>
<th class="text-center">分销组名称</th>
<th class="text-center">所属供应商</th>
<th class="text-center">是否为公共分组</th>
<th class="text-center">当前状态</th>
<th class="text-center">操作时间</th>
<th class="text-center">操作方式</th>
</tr>
</thead>
<tbody>
#foreach($item in $groups)
<tr>
<td class="text-center">$!item.code</td>
<td class="text-center">$!item.name</td>
<td class="text-center">$!item.supplierName</td>
<td class="text-center">
#if($item.get_public() == 1) 是
#else 否
#end
</td>
<td class="text-center">
$statusMap.get($item.status)
</td>
<td class="text-center">$dateTool.format("yyyy-MM-dd HH:mm:ss",$!item.updateTime)</td>
<td class="text-center">
#if($shiro.hasPermission("groupUpd"))
<a href="/distributorGroup/update/${item.id}.do" data-control="edit">修改</a>
#end
#if($shiro.hasPermission("groupProduct"))
<a href="/distributorGroupRule/list.do?groupId=${item.id}" data-control="blank">分销产品</a>
#end
</td>
</tr>
#end
</tbody>
</table>
</p>
#paginate($pagination, $url, $param)
</p>
3.js檔案
/**
* 控制分销组分销规则添加和修改页面
* Created by yipeng.wang on 2015/9/10.
*/
var DistributorRule = {
init: function() {
$("#txt_proName").bind("click", DistributorRuleSelector.selectProduct);
$("#span_proName").bind("click", DistributorRuleSelector.selectProduct);
$("#btn_save").bind("click", DistributorRule.onSave);
$("#sale_price_type").bind("change", function(){
var txtCon = $("#sale_price_val");
var type = parseInt($(this).val(), 10);
switch(type) {
case 0:
txtCon.val("");
break;
case 1:
txtCon.val("{price}+");
break;
case 2:
txtCon.val("{price}-");
break;
case 3:
txtCon.val("{price}*");
break;
}
});
$("#bookPessengerRequired").bind("change", function(){
var val = $(this).val();
if(val == 0) {
$("#p_pessenger").hide();
} else {
$("#p_pessenger").show();
}
});
$("input[name='chargeType_type']").each(function(index, ele){
$(ele).bind("click", function(){
var type = $(this).val();
if(type == 0) {
$("#p_chargeType_type_1").hide();
$("#p_chargeType_type_2").hide();
} else if(type == 1) {
$("#p_chargeType_type_1").show();
$("#p_chargeType_type_2").hide();
} else {
$("#p_chargeType_type_1").hide();
$("#p_chargeType_type_2").show();
}
});
});
$("#btnAddFee").bind("click", function(){
DistributorRule.onAddFeeClicked(null, null);
});
$("#bookAdvanceTime_picker").datetimepicker({
pickDate: false
});
$("#bookStartTime_picker").datetimepicker({
pickDate: false
});
$("#bookEndTime_picker").datetimepicker({
pickDate: false
});
$("#refundType_2_time_picker").datetimepicker({
pickDate: false
});
$("#refund_datepicker").datetimepicker({
pickDate: true
});
},
onAddFeeClicked: function(hour, fee){
var p = $("<p>");
p.append($("<span>在游玩日期前</span>"));
var input1 = $("<input>");
input1.attr("type", "text");
input1.attr("name", "chargeType_type_2_hour");
if(hour != null && hour != undefined) {
input1.val(hour);
}
p.append(input1);
p.append($("<span>小时退订费率为</span>"));
var input2 = $("<input>");
input2.attr("type", "text");
input2.attr("name", "chargeType_type_2_fee");
if(fee != null && fee != undefined) {
input2.val(fee);
}
p.append(input2);
p.append($("<span> </span>"));
var btn = $("<a>");
btn.attr("href", "javascript:void(0)");
btn.html("删除");
btn.bind("click", function(){
p.remove();
});
p.append(btn);
$("#p_chargeType_type_2").append(p);
},
onSave: function() {
if(!DistributorRuleValidate.checkBookingDatas()) {
return;
}
if(!DistributorRuleValidate.checkPriceDatas()) {
return;
}
if(!DistributorRuleValidate.checkRefundDatas()) {
return;
}
var bookContactCredentialsType = DistributorRuleJCreator.createContactCredentials();
if(bookContactCredentialsType != null) {
$("#bookContactCredentialsType").val(JSON.stringify(bookContactCredentialsType));
}
var bookCredentialsType = DistributorRuleJCreator.createVisitorCredentials();
if(bookCredentialsType != null) {
$("#bookCredentialsType").val(JSON.stringify(bookCredentialsType));
}
var salePriceRule = DistributorRuleJCreator.createPrice();
if(salePriceRule != null) {
$("#salePriceRule").val(JSON.stringify(salePriceRule));
}
var refundRule = DistributorRuleJCreator.createRefund();
if(refundRule != null) {
$("#refundRule").val(JSON.stringify(refundRule));
}
$("#fdata").trigger("submit");
}
};
var DistributorRuleValidate = {
checkBookingDatas: function() {
if(!DistributorRuleSelector.productSelected) {
DistributorRuleTool.showMessage("请选择产品");
return false;
}
if($("input[name='ruleDto\.bookLimitTime'][value='0']")[0].checked) {
$("#bookAdvanceDay").val("");
$("#bookAdvanceTime").val("");
$("#bookMaxDay").val("");
} else {
var bookAdvanceDay = $("#bookAdvanceDay").val();
var bookMaxDay = $("#bookMaxDay").val();
if(!DistributorRuleTool.checkDayNumber(bookAdvanceDay)) {
DistributorRuleTool.showMessage("提前预定天数输入错误,输入值不能大于128。");
return false;
}
if(!DistributorRuleTool.checkDayNumber(bookMaxDay)) {
DistributorRuleTool.showMessage("最多预定天数输入错误,输入值不能大于128。");
return false;
}
}
var bookValidDay = $("#bookValidDay").val();
if(bookValidDay == "") {
DistributorRuleTool.showMessage("请填写产品有效期");
return false;
}
if(!DistributorRuleTool.checkDayNumber(bookValidDay)) {
DistributorRuleTool.showMessage("产品有效期,输入错误,输入值不能大于128。");
return false;
}
var bookStartTime = $("#bookStartTime").val();
var bookEndTime = $("#bookEndTime").val();
if((bookStartTime == "" && bookEndTime != "") || (bookStartTime != "" && bookEndTime == "")) {
DistributorRuleTool.showMessage("预定的时间必须成对出现");
return false;
} else if(bookStartTime != "" && bookEndTime != "") {
var datas1 = bookStartTime.split(":");
var datas2 = bookEndTime.split(":");
var idata1 = parseInt(datas1[0], 10) * 3600 + parseInt(datas1[1], 10) * 60 + parseInt(datas1[2], 10);
var idata2 = parseInt(datas2[0], 10) * 3600 + parseInt(datas2[1], 10) * 60 + parseInt(datas2[2], 10);
if(idata1 >= idata2) {
DistributorRuleTool.showMessage("预定开始时间不能大于或等于预定结束时间");
return false;
}
}
var bookOrderMinimum = $("#bookOrderMinimum").val();
var bookOrderMaximum = $("#bookOrderMaximum").val();
var bookCredentialsMaximum = $("#bookCredentialsMaximum").val();
var bookPhoneMaximum = $("#bookPhoneMaximum").val();
if(bookOrderMinimum != "" && !DistributorRuleTool.checkNumber(bookOrderMinimum)) {
DistributorRuleTool.showMessage("订单最少预定份数输入错误");
return false;
}
if(bookOrderMaximum != "" && !DistributorRuleTool.checkNumber(bookOrderMaximum)) {
DistributorRuleTool.showMessage("订单最多预定份数输入错误");
return false;
}
if(bookCredentialsMaximum != "" && !DistributorRuleTool.checkNumber(bookCredentialsMaximum)) {
DistributorRuleTool.showMessage("证件最多预定份数输入错误");
return false;
}
if(bookPhoneMaximum != "" && !DistributorRuleTool.checkNumber(bookPhoneMaximum)) {
DistributorRuleTool.showMessage("手机号最多预定份数输入错误");
return false;
}
return true;
},
checkPriceDatas: function(){
var workday = $("#sale_price_workday").val();
var weekend = $("#sale_price_weekend").val();
if(workday != "") {
if(!DistributorRuleTool.checkMoney(workday)) {
DistributorRuleTool.showMessage("请填写正确的产品平时价");
return false;
}
}
if(weekend != "") {
if(!DistributorRuleTool.checkMoney(weekend)) {
DistributorRuleTool.showMessage("请填写正确的产品周末价");
return false;
}
}
//var cval = /^\{price\}(\+|\-|\*)(([1-9]\d{0,6})|0)(\.\d{1,2})?$/;
//if(!cval.test(val)) {
// DistributorRuleTool.showMessage("产品价格公式填写有误");
// return false;
//}
return true;
},
checkRefundDatas: function(){
if($("input[name='refundType'][value='0']")[0].checked) {
return true;
}
if($("input[name='refundType'][value='2']")[0].checked) {
var day = $("#refundType_2_day").val();
if(day == "") {
DistributorRuleTool.showMessage("请填写提前退订的天数");
return false;
}
if(!DistributorRuleTool.checkDayNumber(day)) {
DistributorRuleTool.showMessage("提前退订的天数输入错误,输入值不能大于128。");
return false;
}
}
if($("input[name='refundType'][value='3']")[0].checked) {
var day = $("#refundType_3_day").val();
if(day == "") {
DistributorRuleTool.showMessage("请填写提前退订的天数");
return false;
}
if(!DistributorRuleTool.checkDayNumber(day)) {
DistributorRuleTool.showMessage("提前退订的天数输入错误,输入值不能大于128。");
return false;
}
}
if($("input[name='refundType'][value='4']")[0].checked) {
var day = $("#refundType_4_day").val();
if(day == "") {
DistributorRuleTool.showMessage("请填写允许退订的最终日期");
return false;
}
}
if($("input[name='chargeType_type'][value='0']").checked) {
return true;
}
if($("input[name='chargeType_type'][value='1']").checked) {
var val = $("#chargeType_type_1_fee").val();
if(val == "") {
DistributorRuleTool.showMessage("请填写退订手续费");
return false;
}
if(!DistributorRuleTool.checkMoney(val)) {
DistributorRuleTool.showMessage("退订手续费输入错误");
return false;
}
}
if($("input[name='chargeType_type'][value='2']").checked) {
var hours = $("input[name='chargeType_type_2_hour']");
var fees = $("input[name='chargeType_type_2_fee']");
if(hours.length == 0 || fees.length == 0) {
DistributorRuleTool.showMessage("请至少添加一条阶梯退款费率规则");
return false;
}
for(var index = 0; index < hours.length; index++) {
var hour = $(hours[index]).val();
if(hour == "") {
DistributorRuleTool.showMessage("请填写第" + (index + 1) + "条阶梯退款费率规则的小时参数");
return false;
}
if(!DistributorRuleTool.checkNumber(hour)) {
DistributorRuleTool.showMessage("第" + (index + 1) + "条阶梯退款费率规则的小时参数输入错误");
return false;
}
}
for(var index = 0; index < fees.length; index++) {
var fee = $(fees[index]).val();
if(fee == "") {
DistributorRuleTool.showMessage("请填写第" + (index + 1) + "条阶梯退款费率规则的费率参数");
return false;
}
if(!DistributorRuleTool.checkMoney(fee)) {
DistributorRuleTool.showMessage("第" + (index + 1) + "条阶梯退款费率规则的费率参数输入错误");
return false;
}
}
}
return true;
}
};
var DistributorRuleJCreator = {
createPrice: function(){
var workday_val = $("#sale_price_workday").val();
var weekend_val = $("#sale_price_weekend").val();
var root = {};
root.workday = workday_val;
root.weekend = weekend_val;
return root;
},
createContactCredentials: function(){
if(!$("#bookContactCredentialsRequired")[0].checked) {
return [];
}
var root = [];
var eles = $("input[name='bookContactCredentials_type']");
for(var index = 0; index < eles.length; index++) {
var ele = eles[index];
if(!ele.checked) {
continue;
}
var jele = $(ele);
var credential = {};
credential.key = jele.data("name");
credential.value = jele.val();
root.push(credential);
}
return root;
},
createVisitorCredentials: function(){
if(!$("#bookCredentialsRequired")[0].checked) {
return [];
}
var root = [];
var eles = $("input[name='book_credentials_type']");
for(var index = 0; index < eles.length; index++) {
var ele = eles[index];
if(!ele.checked) {
continue;
}
var jele = $(ele);
var credential = {};
credential.key = jele.data("name");
credential.value = jele.val();
root.push(credential);
}
return root;
},
createRefund: function(){
var root = {};
var refund = {};
if($("input[name='refundType'][value='0']")[0].checked) {
refund.type = 0;
refund.value = "";
} else if($("input[name='refundType'][value='1']")[0].checked) {
refund.type = 1;
refund.value = "";
} else if ($("input[name='refundType'][value='2']")[0].checked) {
refund.type = 2;
var day = $("#refundType_2_day").val();
var time = $("#refundType_2_time").val();
refund.value = day + "-" + time;
} else if($("input[name='refundType'][value='3']")[0].checked) {
refund.type = 3;
refund.value = $("#refundType_3_day").val();
} else {
refund.type = 4;
refund.value = $("#refundType_4_day").val();
}
root.refund = refund;
var charge = {};
var fees = [];
if($("input[name='chargeType_type'][value='0']")[0].checked) {
charge.type = 0;
charge.feetype = 0;
} else if($("input[name='chargeType_type'][value='1']")[0].checked) {
charge.type = 1;
var checked = $("input[name='chargeType_type_1_feetype'][value='0']")[0].checked;
charge.feetype = checked ? 0 : 1;
var fee = {};
fee.hour = "-1";
fee.value = $("#chargeType_type_1_fee").val();
fees.push(fee);
} else {
charge.type = 2;
var checked = $("input[name='chargeType_type_2_feetype'][value='0']")[0].checked;
charge.feetype = checked ? 0 : 1;
var hourEles = $("input[name='chargeType_type_2_hour']");
var feeEles = $("input[name='chargeType_type_2_fee']");
for(var index = 0; index < hourEles.length; index++) {
var fee = {};
fee.hour = $(hourEles[index]).val();
fee.value = $(feeEles[index]).val();
fees.push(fee);
}
}
charge.fee = fees;
root.charge = charge;
return root;
}
};
var DistributorRuleJAnalysis = {
analysisPrice: function(s) {
var json = null;
try {
json = $.parseJSON(s);
} catch(e) {
return;
}
$("#sale_price_workday").val(json.workday);
$("#sale_price_weekend").val(json.weekend);
},
analysisContactCredentials: function(s) {
var json = null;
try {
json = $.parseJSON(s);
} catch(e) {
return;
}
for(var index = 0; index < json.length; index++) {
var jitem = json[index];
var val = jitem.value;
$("input[name='bookContactCredentials_type'][value='" + val + "']").attr("checked", "checked");
}
},
analysisVisitorCredentials: function(s) {
var json = null;
try {
json = $.parseJSON(s);
} catch(e) {
return;
}
for(var index = 0; index < json.length; index++) {
var jitem = json[index];
var val = jitem.value;
$("input[name='book_credentials_type'][value='" + val + "']").attr("checked", "checked");
}
},
analysisRefundRule: function(s) {
var json = null;
try {
json = $.parseJSON(s);
} catch(e) {
return;
}
var refund = json.refund;
$("input[name='refundType'][value='" + refund.type + "']").attr("checked", "checked");
var data = refund.value;
var datas = data.split("-");
if(refund.type == 2) {
$("#refundType_2_day").val(datas[0]);
$("#refundType_2_time").val(datas[1]);
} else if(refund.type == 3) {
$("#refundType_3_day").val(datas[0]);
} else if(refund.type == 4) {
$("#refundType_4_day").val(datas[0]);
}
var charge = json.charge;
var fees = charge.fee;
$("input[name='chargeType_type'][value='" + charge.type + "']").attr("checked", "checked");
if(charge.type == 1) {
$("#p_chargeType_type_1").show();
$("input[name='chargeType_type_1_feetype'][value='" + charge.feetype + "']").attr("checked", "checked");
$("#chargeType_type_1_fee").val(fees[0].value);
} else if(charge.type == 2) {
$("#p_chargeType_type_2").show();
$("input[name='chargeType_type_2_feetype'][value='" + charge.feetype + "']").attr("checked", "checked");
for(var index = 0; index < fees.length; index++) {
var fee = fees[index];
DistributorRule.onAddFeeClicked(fee.hour, fee.value);
}
}
},
makeSafe: function(data) {
if(data == null || data == undefined) {
return "";
}
else {
return data;
}
}
};
var DistributorRuleSelector = {
productSelected: false,
selectProduct: function() {
var url = "/distributorGroupRule/selectProducts.do";
var supplierId = $('#supplierId').val();
if(supplierId != undefined && supplierId != "") {
url = url + "?supplierId=" + supplierId;
}
parent.ecModal({
title: "请点击选择产品",
windowSize: "lg",
button: false,
closem: true,
ajaxUrl: url,
ajaxType: "list",
shownFunction: function(){//弹出窗口后 对数据处理
parent.document.onkeydown = function(event){
var e = event || window.event || arguments.callee.caller.arguments[0];
if(e && e.keyCode==13){//enter 键
return false;
}
if(e && e.keyCode==32){//空格键
return false;
}
};
document.onkeydown = function(event){
var e = event || window.event || arguments.callee.caller.arguments[0];
if(e && e.keyCode==13){//enter 键
return false;
}
if(e && e.keyCode==32){//空格键
return false;
}
};
var mBody = parent.$(".modal-body", parent.$("#modalMsgTemplateHtml"));
$("table tr:gt(0) button[class='btnClick btn btn-primary']", mBody).click(function(){
parent.$("#modalMsgTemplateHtml >.modal").modal("hide");
var thisTr = $(this.parentElement.parentElement);
var productId = thisTr.data("productid");
var productName = $("td:eq(1)", this.parentElement.parentElement).text();
var goodName = $("td:eq(2)", this.parentElement.parentElement).text();
var supplierId = thisTr.data("supplierid");
var parentId = thisTr.data("id");
var parentProductId = thisTr.data("parentproductid");
var radios = parent.$("input[type=radio][name=type]", mBody);
if($(radios).prop("checked") && $(radios).val() == 0){
$(".PMS_PRODUCT_ID").removeClass("hidden");
}
else if($(radios).prop("checked") && $(radios).val() == 1){
$(".PMS_PRODUCT_ID").addClass("hidden");
$(".PMS_PRODUCT_ID").val("");
} else {
$(".PMS_PRODUCT_ID").addClass("hidden");
$(".PMS_PRODUCT_ID").val("");
}
DistributorRuleSelector.loadProductInfo(productId, productName, goodName, supplierId, parentProductId, parentId);
})
}
});
},
loadProductInfo: function(productId, productName, goodName, supplierId, parentProductId, parentId){
DistributorRuleSelector.productSelected = false;
$("#txt_proName").val("");
var groupId = $("#distributorGroupId").val();
var params = "groupId=" + groupId + "&productId=" + productId + "&parentProductId=" + parentProductId + "&parentId=" + parentId;
$.ajax({
url: "/distributorGroupRule/loadProductRule.do",
type: "post",
data: {"groupId":groupId, "productId":productId, "parentProductId":parentProductId, "parentId":parentId},
success: function(callbackData) {
var json = null;
try {
json = callbackData;
} catch(e) {
//DistributorRuleTool.showMessage("无法获取产品信息");
alert("无法获取产品信息");
$(".PMS_PRODUCT_ID").addClass("hidden");
$(".PMS_PRODUCT_ID").val("");
return;
}
if(json.isExists) {
//DistributorRuleTool.showMessage("当前分销组中已存在指定商品的分销规则,不能重复添加。");
alert("当前分销组已存在指定产品,请勿重复添加");
$(".PMS_PRODUCT_ID").addClass("hidden");
$(".PMS_PRODUCT_ID").val("");
return;
}
if(json.notAdd){
alert("当前分销组中不可分销该产品");
$(".PMS_PRODUCT_ID").addClass("hidden");
$(".PMS_PRODUCT_ID").val("");
return;
}
var booking = json.booking;
if(json.hasProductRule) {
var bookLimitTimes = $("input[name='ruleDto\.bookLimitTime']");
if(booking.bookLimitTime == 0) {
$(bookLimitTimes[0]).attr("checked", "checked");
} else {
$(bookLimitTimes[1]).attr("checked", "checked");
$("#bookAdvanceDay").val(booking.bookAdvanceDay);
$("#bookAdvanceTime").val(booking.bookAdvanceTime);
$("#bookMaxDay").val(booking.bookMaxDay);
}
$("#bookStartTime").val(booking.bookStartTime);
$("#bookEndTime").val(booking.bookEndTime);
var bookValidTypes = $("input[name='ruleDto\.bookValidType']");
if(booking.bookValidType == 0) {
$(bookValidTypes[0]).attr("checked", "checked");
} else {
$(bookValidTypes[1]).attr("checked", "checked");
}
$("#bookValidDay").val(booking.bookValidDay);
$("#p_bookValidArea").html(booking.bookValidArea);
$("#bookValidArea").val(booking.bookValidArea);
$("#bookOrderMinimum").val(booking.bookOrderMinimum);
$("#bookOrderMaximum").val(booking.bookOrderMaximum);
$("#bookCredentialsMaximum").val(booking.bookCredentialsMaximum);
$("#bookPhoneMaximum").val(booking.bookPhoneMaximum);
if(booking.bookContactCredentialsRequired == 1) {
$("#bookContactCredentialsRequired").attr("checked", "checked");
var bookContactCredentialsTypes = booking.bookContactCredentialsTypes;
for(var index = 0; index < bookContactCredentialsTypes.length; index++) {
var bookContactCredentialsType = bookContactCredentialsTypes[index];
var checkbox = $("input[name='bookContactCredentials_type'][value='" + bookContactCredentialsTypes.key + "']");
if(checkbox.length > 0) {
checkbox.attr("checked", "checked");
}
}
}
if(booking.bookPessengerRequired == 1 || booking.bookPessengerRequired == 2) {
if(booking.bookPessengerRequired == 1) {
$("#bookPessengerRequired option").eq(1).attr("selected", "selected");
} else {
$("#bookPessengerRequired option").eq(2).attr("selected", "selected");
}
if(booking.bookNameRequired == 1) {
$("#bookNameRequired").attr("checked", "checked");
}
if(booking.bookPhoneRequired == 1) {
$("#bookPhoneRequired").attr("checked", "checked");
}
if(booking.bookCredentialsRequired) {
$("#bookCredentialsRequired").attr("checked", "checked");
var bookCredentialsTypes = booking.bookCredentialsTypes;
for(var index = 0; index < bookCredentialsTypes.length; index++) {
var bookCredentialsType = bookCredentialsTypes[index];
var checkbox = $("input[name='book_credentials_type'][value='" + bookCredentialsType.key + "']");
if(checkbox.length > 0) {
checkbox.attr("checked", "checked");
}
}
}
}
}
$("#txt_proName").val(productName + "(" + goodName + ")");
$("#productId").val(productId);
$("#supplierId").val(supplierId);
//$("#parentProductId").val(parentProductId);
$("#parentProductId").val(parentId);
if(undefined != json.combinationFlag && json.combinationFlag == 1) {
$('#combinationFlag').val("1");
}
DistributorRuleSelector.productSelected = true;
DistributorRuleSelector.getPriceList(json.prices, json.combinationFlag);
}
});
},
getPriceList : function(data, flag){
var productPrices = data;
var results = [];
var weeks = new Array('周日','周一','周二','周三','周四','周五','周六');
var week = [];
$.each(productPrices, function(i, e){
results.push("<tr>");
results.push('<td class="text-center">');
results.push(e.saleStartTime + "到" + e.saleEndTime);
results.push('<input type="hidden" name="productPrices['+i+'].productPriceId" value="' + e.priceId + '"/>');
results.push("</td>");
var week_purchase_price = 0;
var week_sell_price = 0;
var work_purchase_price = 0;
var work_sell_price = 0;
if(undefined != flag && flag == 1) {
results.push('<td class="text-left">');
$.each(e.prices, function(i2, e2){
results.push("产品:" + e2.productName);
results.push("<input type='hidden' name='productPrices["+i+"].subPrices["+i2+"].productId' value='" + e2.productId + "'/>");
results.push("<br/>");
results.push('<p class="jsj">');
results.push('结算价:周末' + '<input onblur="js_week_sum(' + e.priceId +')" class="js_week_' + e.priceId +'" type="text" name="productPrices['+i+'].subPrices['+i2+'].weekendDistributorPrice.purchasePrice" style="margin-bottom:5px" value="' + e2.weekendDistributorPrice.purchasePrice + '"/>');
results.push(' 平日' + '<input onblur="js_work_sum(' + e.priceId +')" class="js_work_' + e.priceId +'" type="text" name="productPrices['+i+'].subPrices['+i2+'].workdayDistributorPrice.purchasePrice" style="margin-bottom:5px" value="' + e2.workdayDistributorPrice.purchasePrice + '"/>');
results.push("</p>");
results.push('<p class="xsj">');
results.push('销售价:周末' + '<input onblur="xs_week_sum(' + e.priceId +')" class="xs_week_' + e.priceId +'" type="text" name="productPrices['+i+'].subPrices['+i2+'].weekendDistributorPrice.salePrice" style="margin-bottom:5px" value="' + e2.weekendDistributorPrice.salePrice + '"/>');
results.push(' 平日' + '<input onblur="xs_work_sum(' + e.priceId +')" class="xs_work_' + e.priceId +'" type="text" name="productPrices['+i+'].subPrices['+i2+'].workdayDistributorPrice.salePrice" style="margin-bottom:5px" value="' + e2.workdayDistributorPrice.salePrice + '"/>');
results.push("</p>");
results.push('<hr/>');
week_purchase_price = parseFloat(week_purchase_price) + parseFloat(e2.weekendDistributorPrice.purchasePrice);
week_sell_price = parseFloat(week_sell_price) + parseFloat(e2.weekendDistributorPrice.salePrice);
work_purchase_price = parseFloat(work_purchase_price) + parseFloat(e2.workdayDistributorPrice.purchasePrice);
work_sell_price = parseFloat(work_sell_price) + parseFloat(e2.workdayDistributorPrice.salePrice);
});
results.push('<input class="js_week_sum_hidden_' + e.priceId +'" type="hidden" name="productPrices['+i+'].prices.weekendDistributorPrice.purchasePrice" value="' + week_purchase_price.toFixed(2) + '" />');
results.push('<input class="js_work_sum_hidden_' + e.priceId +'" type="hidden" name="productPrices['+i+'].prices.workdayDistributorPrice.purchasePrice" value="' + work_purchase_price.toFixed(2) + '" />');
results.push('<input class="xs_week_sum_hidden_' + e.priceId +'" type="hidden" name="productPrices['+i+'].prices.weekendDistributorPrice.salePrice" value="' + week_sell_price.toFixed(2) + '" />');
results.push('<input class="xs_work_sum_hidden_' + e.priceId +'" type="hidden" name="productPrices['+i+'].prices.workdayDistributorPrice.salePrice" value="' + work_sell_price.toFixed(2) + '" />');
results.push("</td>");
} else {
results.push('<td class="text-center">');
results.push('<p class="jsj">');
results.push('结算价:周末' + '<input onblur="js_week_sum(' + e.priceId +')" class="js_week_' + e.priceId +'" type="text" name="productPrices['+i+'].prices.weekendDistributorPrice.purchasePrice" style="margin-bottom:5px" value="' + e.weekendPrice.purchasePrice + '"/>');
results.push(' 平日' + '<input onblur="js_work_sum(' + e.priceId +')" class="js_work_' + e.priceId +'" type="text" name="productPrices['+i+'].prices.workdayDistributorPrice.purchasePrice" style="margin-bottom:5px" value="' + e.workdayPrice.purchasePrice + '"/>');
results.push("</p>");
results.push('<p class="xsj">');
results.push('销售价:周末' + '<input onblur="xs_week_sum(' + e.priceId +')" class="xs_week_' + e.priceId +'" type="text" name="productPrices['+i+'].prices.weekendDistributorPrice.salePrice" style="margin-bottom:5px" value="' + e.weekendPrice.sellPrice + '"/>');
results.push(' 平日' + '<input onblur="xs_work_sum(' + e.priceId +')" class="xs_work_' + e.priceId +'" type="text" name="productPrices['+i+'].prices.workdayDistributorPrice.salePrice" style="margin-bottom:5px" value="' + e.workdayPrice.sellPrice + '"/>');
results.push("</p>");
results.push("</td>");
week_purchase_price = parseFloat(week_purchase_price) + parseFloat(e.weekendPrice.purchasePrice);
week_sell_price = parseFloat(week_sell_price) + parseFloat(e.weekendPrice.sellPrice);
work_purchase_price = parseFloat(work_purchase_price) + parseFloat(e.workdayPrice.purchasePrice);
work_sell_price = parseFloat(work_sell_price) + parseFloat(e.workdayPrice.sellPrice);
}
results.push('<td class="text-center">');
results.push('<p class="jsj">');
results.push("结算总价:周末¥<span class='js_week_sum_" + e.priceId +"'>" + week_purchase_price.toFixed(2) +"</span>,平日¥<span class='js_work_sum_" + e.priceId +"'>" + work_purchase_price.toFixed(2) +"</span>");
results.push("</p>");
results.push('<p class="xsj">');
results.push("销售总价:周末¥<span class='xs_week_sum_" + e.priceId +"'>" + week_sell_price.toFixed(2) +"</span>,平日¥<span class='xs_work_sum_" + e.priceId +"'>" + work_purchase_price.toFixed(2) +"</span>");
results.push("</p>");
results.push("</td>");
results.push('<td class="text-center">');
for(var i = 0; i < e.weeksEffective.length; i++) {
week.push(weeks[e.weeksEffective[i]]);
}
results.push(week.join(","));
week = [];
results.push("</td>");
results.push("</tr>");
});
$('.priceRule').html(results.join(""));
}
};
var DistributorRuleTool = {
showMessage: function(msg, onOk, showCancel, title) {
if(onOk == null || onOk == undefined) {
onOk = function(){};
}
if(showCancel == null || showCancel == undefined) {
showCancel = false;
}
if(title == null || title == undefined) {
title = "提示";
}
parent.ecModal({
header: true,
title: title,
button: true,
buttonCancel: showCancel,
msg: msg,
confirmCallback: onOk,
shownFunction: function(){
parent.document.onkeydown = function(event){
var e = event || window.event || arguments.callee.caller.arguments[0];
if(e && e.keyCode==13){//enter 键
return false;
}
if(e && e.keyCode==32){//空格键
return false;
}
};
document.onkeydown = function(event){
var e = event || window.event || arguments.callee.caller.arguments[0];
if(e && e.keyCode==13){//enter 键
return false;
}
if(e && e.keyCode==32){//空格键
return false;
}
};
}
});
},
checkMoney: function(data) {
var regex = /^(([1-9]\d{0,6})|0)(\.\d{1,2})?$/;
return regex.test(data);
},
checkDayNumber: function(data) {
if(!DistributorRuleTool.checkNumber(data)) {
return false;
}
var idata = parseInt(data, 10);
return (idata < 128);
},
checkNumber: function(data) {
var regex = /^\d+$/;
return regex.test(data);
}
};
$(function(){
DistributorRule.init();
var pageMode = $("#pageMode").val();
if(pageMode == "edit") {
DistributorRuleSelector.productSelected = true;
}
var bookContactCredentialsType = $("#bookContactCredentialsType").val();
var bookCredentialsType = $("#bookCredentialsType").val();
var salePriceRule = $("#salePriceRule").val();
var refundRule = $("#refundRule").val();
if(bookContactCredentialsType != "") {
DistributorRuleJAnalysis.analysisContactCredentials(bookContactCredentialsType);
}
if(bookCredentialsType != "") {
DistributorRuleJAnalysis.analysisVisitorCredentials(bookCredentialsType);
}
if(salePriceRule != "") {
DistributorRuleJAnalysis.analysisPrice(salePriceRule);
}
if(refundRule != "") {
DistributorRuleJAnalysis.analysisRefundRule(refundRule);
}
$("#bookContactCredentialsType").val("");
$("#bookCredentialsType").val("");
$("#salePriceRule").val("");
$("#refundRule").val("");
});
function js_week_sum(priceId) {
var js_week_sum = 0;
$.each($('.js_week_'+ priceId), function(i,e){
js_week_sum = parseFloat(js_week_sum) + parseFloat($(e).val());
});
$('.js_week_sum_' + priceId).html(js_week_sum.toFixed(2));
$('.js_week_sum_hidden_' + priceId).val(js_week_sum.toFixed(2));
}
function js_work_sum(priceId) {
var js_work_sum = 0;
$.each($('.js_work_'+ priceId), function(i,e){
js_work_sum = parseFloat(js_work_sum) + parseFloat($(e).val());
});
$('.js_work_sum_' + priceId).html(js_work_sum.toFixed(2));
$('.js_work_sum_hidden_' + priceId).val(js_work_sum.toFixed(2));
}
function xs_week_sum(priceId) {
var xs_week_sum = 0;
$.each($('.xs_week_'+ priceId), function(i,e){
xs_week_sum = parseFloat(xs_week_sum) + parseFloat($(e).val());
});
$('.xs_week_sum_' + priceId).html(xs_week_sum.toFixed(2));
$('.xs_week_sum_hidden_' + priceId).val(xs_week_sum.toFixed(2));
}
function xs_work_sum(priceId) {
var xs_work_sum = 0;
$.each($('.xs_work_'+ priceId), function(i,e){
xs_work_sum = parseFloat(xs_work_sum) + parseFloat($(e).val());
});
$('.xs_work_sum_' + priceId).html(xs_work_sum.toFixed(2));
$('.xs_work_sum_hidden_' + priceId).val(xs_work_sum.toFixed(2));
}
同上、估計你也沒有認真看玩這些程式碼、或不屬於你的程式碼
因為一般提問都是把出錯地方的那段程式碼、或核心程式碼貼出來、
你這樣一大坨真心不會去慢慢看啊、最重要的是問題很不明確、
言歸正傳
建議你把傳的值存入Cookie中、要用就取出來、
這是最簡單的解決方法、
我猜沒人會一行一行的把你 800+ 行的程式碼看完的。
你正在維護 2015 年的舊系統嗎?