ComplianceServer/oldcode/WEB/Views/WeiXin/JZOrder/AddByRes.cshtml

1116 lines
44 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@model WX.CRM.Model.MAP.WX_SZZYORDER_Extend
@using WX.CRM.WebHelper;
@{
ViewBag.Title = "订单录入";
Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
}
<style>
.BorderErro {
border-color: red !important;
}
.settime {
width: 40%;
}
</style>
<script src="~/Scripts/jquery.form.js"></script>
<div class="mvctool bgb">
@Html.ToolButtonPlain("btnSave", "icon-save", "保存", false, "")
</div>
<form id="CreateForm" action="/WeiXin/JZOrder/AddByRes" method="post" enctype="multipart/form-data">
@Html.ValidationSummary(true)
<table class="fromEditTable ">
<tbody>
<tr>
<td style="width:120px;">客户ID</td>
<td style="width:310px"><input type="text" name="resid" id="resid" value="@ViewBag.CustomerId" /></td>
<td width="120px"></td>
</tr>
<tr>
<td>用户名</td>
<td>@Html.DropDownList("SoftUserName", ViewBag.UserNameItems as IEnumerable<SelectListItem>)</td>
<td></td>
</tr>
@if (ViewBag.DeptList != null)
{
<tr>
<td class="tdRight">部门归属</td>
<td>
<select id="deptcode" name="deptcode">
<option value="">请选择...</option>
@foreach (var item in ViewBag.DeptList as List<SelectListItem>)
{
<option value="@item.Value">@item.Text</option>
}
</select>
</td>
<td></td>
</tr>
}
<tr>
<td>姓名</td>
<td>@Html.TextBoxFor(m => m.Name)</td>
<td>@Html.ValidationMessageFor(m => m.Name)</td>
</tr>
<tr style="display:none">
<td>产品系列:</td>
<td>
<select id="productId" name="productId" style="width:150px;height:22px">
<option value="0">智赢系列</option>
@*@foreach (var item in ViewBag.productList as List<SelectListItem>)
{
<option value="@item.Value">@item.Text</option>
}*@
</select>
</td>
<td></td>
</tr>
<tr>
<td>产品大类:</td>
<td>
<select id="midProductId" name="midProductId" style="width:220px;height:22px" onChange="changeMidProduct(this.value)">
<option value="0">--请选中产品大类--</option>
@foreach (var item in ViewBag.midproductList as List<SelectListItem>)
{
<option value="@item.Value">@item.Text</option>
}
</select>
</td>
<td></td>
</tr>
<tr>
<td>产品小类:</td>
<td>
<select id="subProductId" name="subProductId" style="width:220px;height:22px" onChange="changeSubProduct(this.value)">
<option value="0">--请选中产品小类--</option>
</select>
</td>
<td></td>
</tr>
<tr>
<td>订单类型</td>
<td>
<select id="ORDERTYPE" name="ORDERTYPE" style="height:22px;" onChange="ordertypeselect(this.value)">
<option value="1">普通订单</option>
<option value="2">续费订单</option>
<option value="3">升级订单</option>
</select>
</td>
<td></td>
</tr>
<tr>
<td>开通天数</td>
<td>
@*@if (ViewBag.DeptCode == "DNZZ")
{
<input type="text" id="OpenDays" name="OpenDays" value="" />
}
else
{
<span id="opendaystext" style="color:green;"></span><input type="hidden" id="curOpenDays" /> @Html.HiddenFor(m => m.OpenDays)
}*@
<span id="opendaystext" style="color:green;"></span><input type="text" id="opendays2" style="display:none;" /><input type="hidden" id="curOpenDays" /> @Html.HiddenFor(m => m.OpenDays)
</td>
<td></td>
</tr>
<tr style="display:none">
<td>售后电话服务归属</td>
<td>
<select id="TEAMSERVE" name="TEAMSERVE" style="height:22px;">
<option value="0">总公司负责电话售后服务</option>
<option value="1" selected>分公司负责电话售后服务</option>
</select>
</td>
<td></td>
</tr>
<tr>
<td>下单金额</td>
<td>
<span id="needpaytext" style="color:red;"></span>
<input type="hidden" name="needPay" id="NEEdPAY" />
<input type="hidden" id="curNeedPay" />
</td>
<td>
@{
if (ViewBag.roleCodes.IndexOf("[GLY]") > -1 || ViewBag.roleCodes.IndexOf("[ZJZL]") > -1)
{
<input type="checkbox" id="chkTest" />@:测试单
}
}
<input type="hidden" name="isTest" id="isTest" value="0" />
<input type="hidden" id="payTest" />
</td>
</tr>
<tr style="display:none">
<td>支付类型</td>
<td>
@Html.DropDownList("PAYTYPE", new List<SelectListItem>() {
new SelectListItem(){Text="银行转账",Value="3",Selected=false},
new SelectListItem(){Text="支付宝",Value="1",Selected=false},
new SelectListItem(){Text="微信支付",Value="5",Selected=true}})
</td>
<td></td>
</tr>
<tr style="display:none;">
<td style="width:120px;">产品数</td>
<td style="width:310px"><input type="text" id="bookNum" name="bookNum" value="1" /></td>
<td width="120px"></td>
</tr>
<tr id="promotionTR" style="display:none;">
<td><span style="color:red; font-weight:bold;">促销信息</span></td>
<td><select id="promotion" style="display:none;"></select></td>
<td></td>
</tr>
<tr id="promotionTR2" style="display:none;">
<td><span style="color:red; font-weight:bold;">促销信息</span></td>
<td><span id="promotion2" style="display:none;"></span></td>
<td></td>
</tr>
<tr id="discountTR" style="background-color:pink; display:none;">
<td>折扣</td>
<td>
<select id="DDLDiscount" style="display:none;"></select><input type="hidden" name="discount" id="discount" />
</td>
<td></td>
</tr>
<tr id="customprisceTR" style="background-color:pink; display:none;">
<td>折后价</td>
<td>
<select id="DDLCustomPrisce" style="display:none;"></select><input type="hidden" name="customprisce" id="customprisce" />
</td>
<td></td>
</tr>
<tr id="upgradeOrderShow1" style="background-color:pink; display:none;">
<td>订单升级原CRM订单号列表</td>
<td><textarea name="UPGRADEORDERIDS" id="UPGRADEORDERIDS" rows="2" style="width:250px" onChange="getOrderLeftValue(this.value)"></textarea></td>
<td>以逗号分隔</td>
</tr>
<tr id="upgradeOrderShow2" style="background-color:pink; display:none;">
<td>原订单剩余金额</td>
@*<td><input type="text" name="totalupgradevalue" id="TOTALUPGRADEVALUE" /></td>*@
@*<td><input type="text" name="TOTALUPGRADEVALUE" id="TOTALUPGRADEVALUE" readonly /></td>*@
<td><input type="text" name="TOTALUPGRADEVALUE" id="TOTALUPGRADEVALUE" @{ if (ViewBag.DeptCode != "SHZZ" && ViewBag.DeptCode != "DNG8") { @Html.Raw("readonly") } } /></td>
<td><input type="checkbox" id="chkOriginalPrice" />原价</td>
</tr>
<tr id="trgiftdays" style="display:none; background-color:lightgoldenrodyellow">
<td>赠送<span id="giftdayslab"></span></td>
<td>
@if (ViewBag.DeptCode == "SHZZ")
{
<input type="text" name="giftdays" value="" />
}
else
{
<select id="giftdays" name="giftdays"></select>
}
@*<select id="giftdays" name="giftdays"></select>*@
</td>
<td></td>
</tr>
<tr id="trgiftdays2" style="display:none; background-color:lightgoldenrodyellow">
<td>赠送<span id="giftdays2lab"></span></td>
<td>
@if (ViewBag.DeptCode == "SHZZ")
{
<input type="text" name="giftdays2" value="" />
}
else
{
<select id="giftdays2" name="giftdays2"></select>
}
</td>
<td></td>
</tr>
<tr>
<td>留&nbsp;&nbsp;痕</td>
<td>
<select id="SOURCE" name="source" style="height:22px;" onChange="sourceselect(this.value)">
<option value="">请选择</option>
<option value="1">微信/企微</option>
<option value="2">手机号</option>
<option value="3">线下资源</option>
<option value="4">自找资源</option>
</select>
</td>
<td></td>
</tr>
<tr id="customerSource" style="display:none;">
@{ bool fujian = ViewBag.ShowFuJian; }
<td>
客户微信用户名:<br />
<span style="display:none;">
客户企微姓名:<br />
</span>
客户企微:
@if (fujian == true)
{<br /><span>附件:</span>}
</td>
<td>
<input disabled value="" id="wxUserName" />
<input type="button" onclick="ChooseCustomerWx()" value="选择微信用户" />
@Html.HiddenFor(m => m.wx_SzzyOrder.CUSTOMERUSERNAME)
<div style="display:none;">
<br />
<input disabled value="" id="qwUserName" />
<input type="button" onclick="ChooseCustomerQw()" value="选择企业微信" />
@Html.HiddenFor(m => m.wx_SzzyOrder.WEWORK_REMOTEID)
</div>
<br />
<input disabled value="" id="wwUserName" />
<input type="button" onclick="ChooseCustomerWw()" value="选择付费企业微信" />
@Html.HiddenFor(m => m.wx_SzzyOrder.EXTERNAL_USERID)
<input type="hidden" name="userid" id="userid" />
<input type="hidden" name="corpid" id="corpid" />
@if (fujian == true)
{
<br />
<input id="FileMobile" name="FileMobile" type="file" accept=".doc,.docx" />
}
</td>
<td></td>
</tr>
<tr>
<td style="">客户希望回访的时间</td>
<td style="width:310px">
<input id="startTime" name="ai_hgrecord_stime" class="Wdate settime" type="text" onclick="WdatePicker({ qsEnabled:false,isShowToday:false,dateFmt: 'HH:mm' })" placeholder="开始时间" autocomplete="off" onchange="changeTime()" />
&nbsp;
-&nbsp;<input id="endTime" name="ai_hgrecord_etime" class="Wdate settime" type="text" onclick="WdatePicker({ qsEnabled:false,isShowToday:false,dateFmt: 'HH:mm' })" placeholder="结束时间" autocomplete="off" />
</td>
<td width="120px">
非必填
<img style="margin-left: 10px;cursor: pointer;" src="/image/icon/tip.png" title="非必填,若填写,则回访会优先按照这&#10个时间进行回访">
</td>
</tr>
<tr>
<td style="">预计开通时间</td>
<td style="width:310px">
<input id="ESTIMATEOTIME" name="ESTIMATEOTIME" class="Wdate" type="text" value="@Html.Raw(DateTime.Now.ToString("yyyy-MM-dd"))" onclick="WdatePicker()" realvalue="">
</td>
<td width="120px"></td>
</tr>
<tr>
<td style="width:120px;">备注</td>
<td style="width:310px">@Html.TextAreaFor(m => m.wx_SzzyOrder.REMARK, new { style = "width:300px;height:30px" })</td>
<td width="120px"></td>
</tr>
</tbody>
</table>
<div id="modalwindow" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
</form>
<script type="text/javascript">
var oldProductPrice = 0;
var _disCount = "";
var _customPrisce = "";
var deptCode = '@ViewBag.DeptCode';
$(function () {
$("#startTime").on("change", function () {
var endValue = $("#endTime").val();
var value = $("#startTime").val();
if (value != "" && endValue == "") {
var dateStr = value.split(":");
if (dateStr.length > 1) {
parseInt((parseInt(dateStr[1]) + 30) / 60)
var endStr = parseInt(dateStr[0]) * 60 + parseInt(dateStr[1]) + 30;
var hourstr = parseInt(endStr / 60);
var minStr = endStr % 60;
if (hourstr < 9) {
hourstr = "0" + hourstr;
}
if (minStr < 9) {
minStr = "0" + minStr;
}
endValue = hourstr + ":" + minStr;
$("#endTime").val(endValue);
}
}
});
$("#customerSource").hide();
$("#upgradeOrderShow1").hide();
$("#upgradeOrderShow2").hide();
$("#trgiftdays").hide();
$("#trgiftdays2").hide();
$("#promotionTR").hide();
$("#discountTR").hide();
$("#customprisceTR").hide();
$('#CreateForm').ajaxForm({
dataType: 'json',
beforeSend: ForEverajaxLoading,
complete: ForEverajaxLoadEnd,
success: function (data) {
if (data.type == 1) {
//window.parent.frameReturnByMes(data.message);
window.parent.frameReturnByMes('订单创建成功');
window.parent.frameReturnByReload(true);
//window.parent.frameReturnByClose();
window.location = "/WeiXin/CommissionRule/Edit?orderid=" + data.value;
}
else {
$.messager.alert("警告", data.message, "error");
}
},
error: function () {
$.messager.alert("警告", "操作失败", "error");
}
});
$("#btnSave").click(function () {
@if (ViewBag.DeptList != null)
{
@Html.Raw("var deptcode = $('#deptcode');");
@Html.Raw("if (!$.trim(deptcode.val())){");
@Html.Raw(" return ErroBox(deptcode, '请选择部门归属!','change');");
@Html.Raw("}");
}
var needpay = $("#NEEdPAY");
if (needpay.val() < 0) {
$.messager.alert("警告", "下单金额不能小于0", "error");
return;
}
if ($("#CreateForm").valid()) {
$('#CreateForm').submit();
}
return false;
});
$("#btnQuery").click(function () {
$('#tablist').tablegrid("Search");
});
$("#bookNum").change(function () {
var num = $("#bookNum").val();
if (num == 0) {
num = 1
$("#bookNum").val(1);
}
var days = $("#curOpenDays").val();
var price = $("#curNeedPay").val();
$("#opendaystext").html(num * days);
$("#OpenDays").val(num * days);
$("#NEEdPAY").val(num * price);
$("#needpaytext").html(num * price);
$("#payTest").val(num * price);
});
$("#TOTALUPGRADEVALUE").change(function () {
if ($("#UPGRADEORDERIDS").val() == "") {
$.messager.alert("警告", "请先输入升级单号", "error");
return;
}
//alert(this.value);
var changePrice = parseFloat(this.value);
var productPrice = parseFloat($("#curNeedPay").val());
if (isNaN(changePrice)) {
$(this).val(0);
$.messager.alert("警告", "金额只能是数字", "error");
return;
}
if (changePrice > productPrice) {
$.messager.alert("警告", "金额不能大于产品金额", "error");
return;
}
//alert(oldProductPrice);
//alert(productPrice);
var orderType = $("#ORDERTYPE").val();
if (orderType == 4)
{
setChangeOrderPrice();
}
else {
setOrderLeftValue(this.value);
}
//setOrderLeftValue(this.value);
});
});
function changeTime() {
var endValue = $("#endTime").val();
var value = $("#startTime").val();
if (value != "" && endValue == "") {
var dateStr = value.split(":");
if (dateStr.length > 1) {
parseInt((parseInt(dateStr[1]) + 30) / 60)
var endStr = parseInt(dateStr[0]) * 60 + parseInt(dateStr[1]) + 30;
var hourstr = parseInt(endStr / 60);
var minStr = endStr % 60;
if (hourstr < 9) {
hourstr = "0" + hourstr;
}
if (minStr < 9) {
minStr = "0" + minStr;
}
endValue = hourstr + ":" + minStr;
$("#endTime").val(endValue);
}
}
}
function ErroBox(_control, title, shijian) {
if (shijian) {//兼容ie360等垃圾浏览器
$(_control).addClass("BorderErro").focus().one(shijian, function () {
$(_control).removeClass("BorderErro");
});
} else {
$(_control).addClass("BorderErro").focus().one("keyup", function () {
$(_control).removeClass("BorderErro");
});
}
$.messager.alert("警告", title, "error");
isCanSubMit = false;
return false;
}
function reset() {
$("#UPGRADEORDERIDS").val("");
setOrderLeftValue(0);
$("#trgiftdays").hide();
$("#trgiftdays2").hide();
$("#promotionTR").hide();
$("#promotion").empty().hide();
$("#discountTR").hide();
$("#customprisceTR").hide();
$("#DDLDiscount").empty().hide();
$("#DDLCustomPrisce").empty().hide();
$("#discount").val('');
$("#customprisce").val('');
////北一至尊版不需要升级单,(已经改成需要升级订单,但是只能至尊版间相互升级)
if (deptCode == "SHZZ") {
$("#ORDERTYPE").empty().append(new Option("普通订单", "1")).append(new Option("续费订单", "2")).append(new Option("升级订单", "3")).append(new Option("换课订单(不补款)", "4")).append(new Option("换课订单(补款)", "5"));
}
else {
$("#ORDERTYPE").empty().append(new Option("普通订单", "1")).append(new Option("续费订单", "2")).append(new Option("升级订单", "3"));
//$("#ORDERTYPE").empty().append(new Option("普通订单", "1")).append(new Option("续费订单", "2")).append(new Option("升级订单", "3")).append(new Option("换课订单(不补款)", "4")).append(new Option("换课订单(补款)", "5"));
}
_disCount = "";
_customPrisce = "";
//$("#ORDERTYPE").val(1).change();
}
function changeselect(productId) {
//var nb1defaultIndex = 0;
reset();
if (productId == 0) {
$("#subProductId").unbind();
$("#subProductId").html("<option value='0'>--请选中产品小类--</option>");
return;
}
$.r_post("/JzOrder/GetSubProductList?productId=" + productId, function (data) {
$("#subProductId").unbind();
$("#subProductId").html("<option value='0'>--请选中产品小类--</option>");
$(data).each(function (n, m) {
/*if (nb1defaultIndex == 0) {
$("#slt_subProductId").append("<option value='" + m.Value + "' selected='selected'>" + m.Text + "</option>");
}
else {*/
$("#subProductId").append("<option value='" + m.Value + "'>" + m.Text + "</option>");
//}
});
//nb1defaultIndex++;
}, "json");
}
function changeMidProduct(midproductId) {
if (midproductId == 0) {
return;
}
reset();
$.r_post("/JzOrder/GetSubProductList?productId=0&midproductId=" + midproductId, function (data) {
//$("#subProductId").unbind();
$("#subProductId").html("<option value='0'>--请选中产品小类--</option>");
$(data).each(function (n, m) {
$("#subProductId").append("<option value='" + m.Value + "'>" + m.Text + "</option>");
});
}, "json");
}
function ordertypeselect(type) {
var subProductId = $("#subProductId").val();
if (subProductId == 0) {
$.messager.alert("警告", "请先选择产品!", "error");
$("#ORDERTYPE").val(1);
return;
}
else {
$("#promotion").empty();
$("#promotion2").empty();
$("#promotionTR").hide();
$("#promotionTR2").hide();
$("#discountTR").hide();
$("#UPGRADEORDERIDS").val("");
$("#customprisceTR").hide();
$("#discount").val('');
$("#customprisce").val('');
setOrderLeftValue(0);
$('#upgradeOrderShow1').hide();
$('#upgradeOrderShow2').hide();
$('#opendaystext').show();
$('#opendays2').hide();
//console.log("_disCount:" + _disCount);
//折扣
if (_disCount != '' && _disCount != undefined && _disCount != null) {
$("#DDLDiscount").empty().append(new Option("可选择折扣", ""));
var disArr = _disCount.split(',');
for (var i = 0; i < disArr.length; i++) {
var title = disArr[i] / 10 + "折";
$("#DDLDiscount").append(new Option(title, disArr[i]));
}
}
//折后价
if (_customPrisce != '' && _customPrisce != undefined && _customPrisce != null) {
$("#DDLCustomPrisce").empty().append(new Option("可选择折后价", ""));
var disArr = _customPrisce.split(',');
for (var i = 0; i < disArr.length; i++) {
var title = disArr[i];
$("#DDLCustomPrisce").append(new Option(title, disArr[i]));
}
}
if (type == 3 || type == 4) {
//新媒体三,升级,补课订单两种促销方式都支持
//if (deptCode == "SHZZ" || deptCode == "QBJX") {
/*if (_disCount != '' && _disCount != undefined && _disCount != null) {
var checkhtml = '<input id="zk" type="checkbox" onchange="zhikou(this)" /><label for="zk">折扣</label><span style="padding:0 10px"></span><input id="dk" type="checkbox" onchange="dikou(this)" /><label for="dk">抵扣</label>';
$("#promotion2").append(checkhtml).show();
} else
*/
if (_customPrisce != '' && _customPrisce != undefined && _customPrisce != null) {
var checkhtml = '<input id="zk" type="checkbox" onchange="zhihoujia(this)" /><label for="zk">折后价</label><span style="padding:0 10px"></span><input id="dk" type="checkbox" onchange="dikou(this)" /><label for="dk">抵扣</label>';
$("#promotion2").append(checkhtml).show();
}
else {
$("#promotion2").append('<input id="dk" type="checkbox" onchange="dikou(this)" /><label for="dk">抵扣</label>').show();
}
$("#promotionTR2").show();
//}
//else {
// if (_disCount != '' && _disCount != undefined && _disCount != null) {
// $("#promotion").append(new Option('请选择', '')).append(new Option('折扣', 1)).append(new Option("抵扣", 2)).show();
// }
// else if (_customPrisce != '' && _customPrisce != undefined && _customPrisce != null) {
// $("#promotion").append(new Option('请选择', '')).append(new Option('折后价', 3)).append(new Option("抵扣", 2)).show();
// }
// else {
// $("#promotion").append(new Option("抵扣", 2)).show();
// }
// $("#promotionTR").show();
//}
if (deptCode == "SHZZ") {
$("#opendays2").show();
$("#opendaystext").hide();
}
}
else if (type == 5)
{
if (_disCount != '' && _disCount != undefined && _disCount != null) {
var checkhtml = '<input id="zk" type="checkbox" onchange="zhikou(this)" /><label for="zk">折扣</label><span style="padding:0 10px"></span><input id="dk" type="checkbox" onchange="dikou(this)" /><label for="dk">抵扣</label>';
$("#promotion2").append(checkhtml).show();
}
else if (_customPrisce != '' && _customPrisce != undefined && _customPrisce != null) {
var checkhtml = '<input id="zk" type="checkbox" onchange="zhihoujia(this)" /><label for="zk">折后价</label><span style="padding:0 10px"></span><input id="dk" type="checkbox" onchange="dikou(this)" /><label for="dk">抵扣</label>';
$("#promotion2").append(checkhtml).show();
}
else {
$("#promotion2").append('<input id="dk" type="checkbox" onchange="dikou(this)" /><label for="dk">抵扣</label>').show();
}
$("#promotionTR2").show();
if (deptCode == "SHZZ") {
$("#opendays2").show();
$("#opendaystext").hide();
}
}
else if (type == 2 || deptCode == "SHZZ" || deptCode == "DNZZ" || (deptCode == "QBJX" && (subProductId == 1008194 || subProductId == 1008196))) {
if (_disCount != '' && _disCount != undefined && _disCount != null) {
$("#promotion").append(new Option("折扣", 1)).show();
$("#promotionTR").show();
}
if (_customPrisce != '' && _customPrisce != undefined && _customPrisce != null) {
$("#promotion").append(new Option("折后价", 3)).show();
$("#promotionTR").show();
}
}
var len = $("#promotion option").length;
if (len == 1) {
$("#promotion").change();
}
}
}
function sourceselect(val) {
if (val == 1) {
$('#customerSource').show();
//$("#trQwSource").hide();
} /*else if (val == 6) {
$('#customerSource').hide();
$("#trQwSource").show();
}*/
else {
$('#customerSource').hide();
//$("#trQwSource").hide();
}
$('#wx_SzzyOrder_CUSTOMERUSERNAME').val('');
$('#wx_SzzyOrder_WEWORK_REMOTEID').val('');
$('#wx_SzzyOrder_EXTERNAL_USERID').val('');
$('#wxUserName').val('');
$('#qwUserName').val('');
$('#wwUserName').val('');
}
function changeSubProduct(subProductId) {
reset();
$.r_post("/JZOrder/GetSubProductPriceById?subProductId=" + subProductId, function (data) {
//console.log(data.discount);
if (data.result) {
//data.customprisce;
$("#NEEdPAY").val(data.price);
$("#needpaytext").html(data.price);
$("#OpenDays").val(data.days);
$("#opendaystext").html(data.days);
$("#opendays2").val(data.days);
$("#bookNum").val(1);
$("#curOpenDays").val(data.days);
$("#curNeedPay").val(data.price);
$("#payTest").val(data.price);
loadGift('trgiftdays', 'giftdays', data.gifts);
loadGift('trgiftdays2', 'giftdays2', data.gifts2);
if (data.discount != '') {
_disCount = data.discount;
}
if (data.customprisce != '') {
_customPrisce = data.customprisce;
}
$("#ORDERTYPE").change()
}
}, "json");
}
function loadGift(trid, id, gifts) {
$("#" + id).empty();
if (gifts != null && !$.isEmptyObject(gifts)) {
$.each(gifts, function (m, n) {
if (m == 0) {
$("#" + id + "lab").text(n.GIFTNAME);
}
$("#" + id).append("<option value='" + n.GIFTDAYS + "'>" + n.GIFTDAYSNAME + "</option>");
});
$("#" + trid).show();
}
}
function selectCustomerWx(userName) {
$('#wxUserName').val(userName);
$('#wx_SzzyOrder_CUSTOMERUSERNAME').val(userName);
}
function ChooseCustomerWx() {
$("#modalwindow").html(GetIframeHtml("/WeiXin/SzzyOrder/RContactIndex"));
$("#modalwindow").window({ title: '选择客户微信', width: 650, height: 500, iconCls: 'icon-add' }).window('open');
}
function SelectCustomerQw(userName, userId) {
$('#qwUserName').val(userName);
$('#wx_SzzyOrder_WEWORK_REMOTEID').val(userName);
if (userId != '') {
SelectCustomerWw(userId);
}
}
function ChooseCustomerQw() {
$("#modalwindow").html(GetIframeHtml("/WeiXin/SzzyOrder/WeWorkRcontact"));
$("#modalwindow").window({ title: '选择企业微信', width: 650, height: 500, iconCls: 'icon-add' }).window('open');
}
function SelectCustomerWw(userName) {
$('#wwUserName').val(userName);
$('#wx_SzzyOrder_EXTERNAL_USERID').val(userName);
}
function ChooseCustomerWw() {
var wwmessageurl = "@Html.Raw(ViewBag.WwMessage_Url)";
var companycode = "@Html.Raw(ViewBag.companycode)";
if (wwmessageurl.indexOf("$") > -1) {
wwmessageurl = wwmessageurl.split("$")[0];
}
if (wwmessageurl.indexOf("|") > -1) {//分内外网
var ssw = window.location.href;
if (ssw.indexOf("192.168.") > -1 || ssw.indexOf("localhost") > -1) {//内网无疑
wwmessageurl = wwmessageurl.split('|')[0];
} else {
wwmessageurl = wwmessageurl.split('|')[1];
}
}
$("#modalwindow").html(GetIframeHtml(wwmessageurl + "/Admin/OutHHuser/Choose?companycode=" + companycode));
$("#modalwindow").window({ title: '选择付费企业微信', width: 650, height: 500, iconCls: 'icon-add' }).window('open');
//$("#modalwindow").html(GetIframeHtml("/WeiXin/SzzyOrder/WwExtuser"));
//$("#modalwindow").window({ title: '选择付费企业微信', width: 650, height: 500, iconCls: 'icon-add' }).window('open');
}
function getOrderLeftValue(val) {
var orderType = $("#ORDERTYPE").val();
if (orderType == 4 && val != "" && val.indexOf(',') > -1) {
$.messager.alert("警告", "换课订单只能输入一个", "error");
return;
}
$.r_post("/JZOrder/GetOrderLeftValue?oldOrderIds=" + val + "&subProductId=" + $('#subProductId').val(), function (data) {
if (data.result) {
var arr = data.data.oldProductPriceList.split(',');
oldProductPrice = arr[0];
setOrderLeftValue(data.data.leftValues);
}
else {
//$(this).prop("checked", false);
setOrderLeftValue(0);
$("#UPGRADEORDERIDS").val('');
$.messager.alert("警告", data.message, "error");
}
}, "json");
}
function setOrderLeftValue(val) {
var orderType = $("#ORDERTYPE").val();
if (orderType == 4) {
setChangeOrderPrice();
var leftValue = parseFloat(val);
$('#TOTALUPGRADEVALUE').val(leftValue);
}
//else if (orderType == 5 || (deptCode == "QBJX" && orderType == 3))
else if (orderType == 5 || orderType == 3)
{
var curNeedPay = $('#curNeedPay').val();
if (curNeedPay == "")
curNeedPay = 0;
if ($("#zk").is(":checked") && !$("#DDLDiscount").val() != '' && $("#DDLDiscount").val() != null && $("#DDLDiscount").val() != undefined) {
//$("#DDLDiscount").change();
var v = (100 - $("#DDLDiscount").val()) / 100;
var cnp = parseFloat(curNeedPay);
//取整
var pay = parseInt(cnp - (cnp * v));
curNeedPay = pay;
}
if ($("#zk").is(":checked") && $("#DDLCustomPrisce").val() != '' && $("#DDLCustomPrisce").val() != null && $("#DDLCustomPrisce").val() != undefined) {
//更新到 折后价
curNeedPay = $("#DDLCustomPrisce").val();
}
var leftValue = parseFloat(val);
var needPay = parseFloat(curNeedPay);
$("#NEEdPAY").val(needPay - leftValue);
$("#needpaytext").html(needPay - leftValue);
$('#TOTALUPGRADEVALUE').val(leftValue);
$("#payTest").val(needPay - leftValue);
}
else {
var curNeedPay = $('#curNeedPay').val();
if (curNeedPay == "")
curNeedPay = 0;
var leftValue = parseFloat(val);
var needPay = parseFloat(curNeedPay);
$("#NEEdPAY").val(needPay - leftValue);
$("#needpaytext").html(needPay - leftValue);
$('#TOTALUPGRADEVALUE').val(leftValue);
$("#payTest").val(needPay - leftValue);
}
}
function setChangeOrderPrice() {
$("#NEEdPAY").val(0);
$("#needpaytext").html(0);
$("#payTest").val(0);
}
$("#chkTest").change(function () {
var needpay = $("#NEEdPAY").val();
if (needpay == "") {
$.messager.alert("警告", "请先选择产品!", "error");
$(this).prop("checked", false);
return;
}
if ($(this).prop("checked")) {
$("#NEEdPAY").val(0.01);
$("#needpaytext").html(0.01);
$("#isTest").val(1);
}
else {
$("#NEEdPAY").val($("#payTest").val());
$("#needpaytext").html($("#payTest").val());
$("#isTest").val(0);
}
});
$("#chkOriginalPrice").change(function () {
var orders = $("#UPGRADEORDERIDS").val();
if (orders == "") {
setOrderLeftValue(0);
$.messager.alert("警告", "请先输入升级单号!", "error");
$(this).prop("checked", false);
return;
}
var isOriginalPrice = 0;
if ($(this).prop("checked"))
isOriginalPrice = 1;
$.r_post("/JZOrder/GetOrderLeftValue?oldOrderIds=" + orders + "&subProductId=" + $('#subProductId').val() + "&isOriginalPrice=" + isOriginalPrice, function (data) {
//if (data.type) {
// setOrderLeftValue(data.message);
//} else {
// $(this).prop("checked", false);
// //alert(data.message);
// $.messager.alert("警告", data.message, "error");
//}
if (data.result) {
var arr = data.data.oldProductPriceList.split(',');
oldProductPrice = arr[0];
setOrderLeftValue(data.data.leftValues);
}
else {
$(this).prop("checked", false);
$.messager.alert("警告", data.message, "error");
}
}, "json");
});
$("#DDLDiscount").change(function () {
//alert(this.value);
var curNeedPay = $('#curNeedPay').val();
if (curNeedPay == "")
curNeedPay = 0;
if (this.value != '') {
var v = (100 - this.value) / 100;
var cnp = parseFloat(curNeedPay);
//取整
var pay = parseInt(cnp - (cnp * v));
$("#NEEdPAY").val(pay);
$("#needpaytext").html(pay);
$("#discount").val(this.value);
}
else {
$("#NEEdPAY").val(curNeedPay);
$("#needpaytext").html(curNeedPay);
$("#discount").val('');
}
});
//折后价选择
$("#DDLCustomPrisce").change(function () {
var curNeedPay = $('#curNeedPay').val();
if (curNeedPay == "")
curNeedPay = 0;
if (this.value != '') {
var v = this.value;
$("#NEEdPAY").val(v);
$("#needpaytext").html(v);
$("#customprisce").val(this.value);
}
else {
$("#NEEdPAY").val(curNeedPay);
$("#needpaytext").html(curNeedPay);
$("#customprisce").val('');
}
var isdk = $("#dk").is(':checked');
if (isdk) {
$("#UPGRADEORDERIDS").val("");
setOrderLeftValue(0);
}
});
$("#promotion").change(function () {
if (this.value == 1) {
$("#discountTR").show();
$("#customprisceTR").hide();
$("#upgradeOrderShow1").hide();
$("#upgradeOrderShow2").hide();
var productid = $("#subProductId").val();
if (deptCode == "QBJX" && (productid == 1008194 || productid == 1008196)) {
$("#DDLDiscount").attr("disabled", "disabled").get(0).selectedIndex = 1;
$("#DDLDiscount").change();
//console.log($("#DDLDiscount").get(0));
}
else {
$("#DDLDiscount").removeAttr("disabled");
}
$("#DDLDiscount").show();
}
else if (this.value == 2) {
$("#discountTR").hide();
$("#customprisceTR").hide();
//$("#upgradeOrderShow1").show();
//$("#upgradeOrderShow2").show();
$("#DDLDiscount").hide();
$("#discount").val('');
var type = $("#ORDERTYPE").val();
setOrderLeftValue(0);
if (type == 3 || type == 4 || type == 5) {
$('#upgradeOrderShow1').show();
$('#upgradeOrderShow2').show();
} else {
$("#UPGRADEORDERIDS").val("");
$('#upgradeOrderShow1').hide();
$('#upgradeOrderShow2').hide();
}
}
else if (this.value == 3) {
$("#customprisceTR").show();
$("#discountTR").hide();
$("#upgradeOrderShow1").hide();
$("#upgradeOrderShow2").hide();
var productid = $("#subProductId").val();
if (productid == 1008194 || productid == 1008196) {
$("#DDLCustomPrisce").attr("disabled", "disabled").get(0).selectedIndex = 1;
$("#DDLCustomPrisce").change();
}
else {
$("#DDLCustomPrisce").removeAttr("disabled");
}
$("#DDLCustomPrisce").show();
}
else {
$("#discountTR").hide();
$("#customprisceTR").hide();
$("#DDLDiscount").hide();
$("#discount").val('');
$("#UPGRADEORDERIDS").val("");
setOrderLeftValue(0);
$('#upgradeOrderShow1').hide();
$('#upgradeOrderShow2').hide();
}
});
$("#opendays2").change(function () {
if (this.value == '') {
$(this).val($("#curOpenDays").val());
$.messager.alert("警告", "天数不能为空!", "error");
return;
}
if (isNaN(this.value) || this.value == '') {
$(this).val($("#curOpenDays").val());
$.messager.alert("警告", "天数只能是数字!", "error");
return;
}
$("#OpenDays").val(this.value);
});
function zhikou(obj) {
var ischeck = $(obj).is(':checked');
if (ischeck) {
$("#discountTR").show();
var productid = $("#subProductId").val();
if (productid == 1008194 || productid == 1008196) {
$("#DDLDiscount").attr("disabled", "disabled").get(0).selectedIndex = 1;
$("#DDLDiscount").change();
}
else {
$("#DDLDiscount").removeAttr("disabled");
}
$("#DDLDiscount").show();
}
else {
$("#DDLDiscount").val('').change().hide();
$("#discountTR").hide();
setOrderLeftValue(0);
}
}
//
function zhihoujia(obj) {
var ischeck = $(obj).is(':checked');
if (ischeck) {
$("#customprisceTR").show();
var productid = $("#subProductId").val();
if (productid == 1008194 || productid == 1008196) {
$("#DDLCustomPrisce").attr("disabled", "disabled").get(0).selectedIndex = 1;
$("#DDLCustomPrisce").change();
}
else {
$("#DDLCustomPrisce").removeAttr("disabled");
}
$("#DDLCustomPrisce").show();
}
else {
$("#DDLCustomPrisce").val('').change().hide();
$("#customprisceTR").hide();
setOrderLeftValue(0);
}
}
function dikou(obj) {
var ischeck = $(obj).is(':checked');
if (ischeck) {
$('#upgradeOrderShow1').show();
$('#upgradeOrderShow2').show();
} else {
$("#UPGRADEORDERIDS").val("");
setOrderLeftValue(0);
$('#upgradeOrderShow1').hide();
$('#upgradeOrderShow2').hide();
}
}
function GetIframeHtml(src) {
return "<iframe width='100%' height='98%' scrolling='yes' frameborder='0'' src='" + src + "'></iframe>";
}
function frameReturnByClose() {
$("#modalwindow").window('close');
}
</script>
<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
console.log("收到消息了,该死的");
console.log(event.data);
var mydata = event.data;
if (mydata.type == "choose") {
$('#wwUserName').val(mydata.extuserid);
$('#userid').val(mydata.userid);
$('#corpid').val(mydata.corpid);
$('#wx_SzzyOrder_EXTERNAL_USERID').val(mydata.extuserid);
}
frameReturnByClose();
}
</script>