window.submitUrl = "/Pages/business/OrderList.aspx"; //设置当前页的提交路径 /* 处理受理订单 */ var DoAccept = function (orderId) { CallServer({ Target: "AcceptOrder", id: orderId }, function (data, textStatus) { if ('1' == data) { alertMsg('操作成功!'); RefreshDIVOpener(); //关闭页面 } else { alertMsg('-1' == data ? '受理过程中发生异常,请重新受理!' : '受理失败!'); //dialog.close(); } }); } /* 批量处理受理订单 */ var DoAcceptAll = function (orderIds) { CallServer({ Target: "AcceptOrderAll", ids: orderIds }, function (data, textStatus) { if ('1' == data) { alertMsg('操作成功!'); RefreshDIVOpener(); //关闭页面 } else { alertMsg('-1' == data ? '受理过程中发生异常,请重新受理!' : '受理失败!'); //dialog.close(); } }); } var qtypes = { '1': 'ToAccountDelay', '2': 'DeliveryDelay', '3': 'OrderRepeal','4':'RetireOrderBySeller' }; /* 确认受理 */ function ToAccept(sumPrice, orderShowId, orderId, orderTypeId) { var commission = parseFloat(document.getElementById('txtCommission').value); if (isNaN(commission)) return; // var html = ''; // html += '
'; // html += orderTypeId > 0 ? ('确认受理订单:' + orderShowId + '?') : ('受理订单:' + orderShowId + '需要支付¥' + Float2(commission * sumPrice) + '服务费,是否确认受理?
'); // html += '
'; // html += '
  
'; // dialog.open({ InnerHtml: html, Title: '确认受理', Width: 200, Height: 100, Modal: false }); var msg = orderTypeId > 0 ? ('确认受理订单:' + orderShowId + '?') : ('受理订单:' + orderShowId + '需要支付¥' + Float2(commission * sumPrice) + '服务费,是否确认受理'); top.Dialog.confirm(msg, function () { DoAccept(orderId); }); } /* 确认受理 */ function ToSuodan(orderId, orderShowId) { var msg ='确认锁单订单:' + orderShowId + '?'; top.Dialog.confirm(msg, function () { CallServer({ Target: "SuodanOrder", id: orderId }, function (data, textStatus) { if ('1' == data) { alertMsg('操作成功!'); RefreshDIVOpener(); //关闭页面 } else { alertMsg('-1' == data ? '锁单过程中发生异常,请重新受理!' : '锁单失败!'); //dialog.close(); } }); }); } ///批量受理 function ToAllAccept() { var commission = parseFloat(document.getElementById('txtCommission').value); if (isNaN(commission)) return; var ids = ''; var cks = $("input[name='ckId']:checked"); if (cks.length == 0) { alertMsg('没有选中任何项!'); return; } else { } var isCan = true; var needPrice = false; var price = 0; var orderShowIds = ''; cks.each( function () { var ckVal = $(this).val(); var ckValJson = eval('(' + ckVal + ')'); if (ckValJson.orderState != 1) { isCan = false; return false; } ids = ids + ',' + $(this).attr("value_keyid"); orderShowIds = orderShowIds + ',' + ckValJson.ordershowId; if (ckValJson.orderType < 1) { needPrice = true; price += parseFloat(ckValJson.sumPrice) * commission; } } ); if (!isCan) { alertMsg('请选择未受理的订单!'); } else { if (ids != '') { ids = ids.substring(1); } if (orderShowIds != '') { orderShowIds = orderShowIds.substring(1); } // var html = ''; // html += '

'; // html += !needPrice ? ('确认批量受理所选' + orderShowIds + '订单?') : ('受理所选线上订单需要支付¥' + Float2(price) + '服务费,是否确认批量受理' + orderShowIds + '订单?
'); // html += '

'; // html += '
  
'; // dialog.open({ InnerHtml: html, Title: '批量确认受理', Width: 400, Height: 100, Modal: false }); var msg = !needPrice ? ('确认批量受理所选' + orderShowIds + '订单?') : ('受理所选线上订单需要支付¥' + Float2(price) + '服务费,是否确认批量受理' + orderShowIds + '订单?'); top.Dialog.confirm(msg, function () { DoAcceptAll(ids); }); } } /* 清除选中多选框的选中状态 */ function clearSelected(ckbs) { if (!ckbs || !ckbs.length || ckbs.length <= 0 || !ckbs[0]) return false; else { } var i = -1; while (++i < ckbs.length) { ckbs[i].checked = false; } } /* 批量置为完成 params: @target:要设置的目标 @ids:要设置的订单编号(逗号分隔) */ function BatchToTarget(target, ids) { CallServer({ Target: target, ids: ids }, function (data, textStatus) { if ('1' == data) { alertMsg('操作成功!'); global.delaytodo(ReLoad); //刷新页面 } else { alertMsg('-1' == data ? '操作过程中发生异常,请重新操作!' : '操作失败!'); } }); } /* 检查是否不可生产数据 params: @jsonObj:当前json对象 returns: true:是不可完成的数据,false:不是不可完成数据 */ function IsObjCanntProduction(jsonObj) { return 0 > jsonObj['orderType'] && 1 < jsonObj['orderState']; } //线上订单必须是已受理订单才可生产(2为已受理) /* 检查是否不可完成数据 params: @jsonObj:当前json对象 returns: true:是不可完成的数据,false:不是不可完成数据 */ function IsObjCanntOver(jsonObj) { return 0 > jsonObj['orderType'] && 0 < jsonObj['orderState']; } /* 检查是否不可删除数据 params: @jsonObj:当前json对象 returns: true:是不可删除数据,false:不是不可删除数据 */ function IsObjCanntDelete(jsonObj) { return 1 != jsonObj['orderType'] || 1 != jsonObj['orderState']; } //是线下订单并且没有受理才可以删除 /* 批量删除数据 params: @ids:要删除的订单编号(逗号分隔) */ function BatchDelete(ids) { CallServer({ Target: "BatchDelete", ids: ids }, function (data, textStatus) { if ('1' == data) { ReLoad(); //刷新页面 } else { alertMsg('-1' == data ? '操作过程中发生异常,请重新操作!' : '操作失败!'); } }); } /* 询问删除 params: @id:订单编号 */ function DeleteForAsk(id, showid, typeid) { if (typeid > 0) { alertMsg('您不具备订单“' + showid + '”的所有权不能撤销订单!'); return; } var askMsg = ('撤单后订单将完全作废,请问是否确认对订单“' + showid + '”进行撤单?'); window.dialog.confirm(askMsg, function () { BatchDelete(id); }); } /* 确认批量删除 */ function ToBatch(operateFn, validateFn) { var canntDeleteobjs = new Array(); var jsonObj = undefined; var ids = ''; var cks = $("input[name='ckId']:checked"); if (cks.length == 0) { alertMsg('只有未受理的线下订单可删除,未选中!'); return; } else { } cks.each(function (d) { try { jsonObj = eval('[' + this.value + ']')[0]; } catch (ex) { global.DealDataException(ex); return; } if (validateFn && validateFn(jsonObj)) { canntDeleteobjs[canntDeleteobjs.length] = this; } else { ids += ',' + jsonObj.id; } }); //有不可删除的数据 if (canntDeleteobjs.length > 0) { window.dialog.confirm('只有未受理的线下订单可删除,请问是否排除不能删除的订单并继续操作?', function () { setTimeout(function () { clearSelected(canntDeleteobjs); //清除选中的不可删除数据 ToBatch(operateFn, validateFn); //重新执行自己 }, 0); }); } else if (operateFn) { window.dialog.confirm('是否确认当前操作?', function () { { operateFn(ids.substring(1)); } }); } else { alertMsg('调用错误!必须传入要进行的操作!'); } } /* 批量完工 */ function ToCompled(operateFn, validateFn) { var ids = ''; var cks = $("input[name='ckId']:checked"); if (cks.length == 0) { alertMsg('没有选中任何项!'); return; } else { } var isCan = true; cks.each(function (ii, vv) { var ckVal = $(this).val(); var ckValJson = eval('(' + ckVal + ')'); // if (parseInt(ckValJson.orderType) < 1 && ckValJson.orderState == 1) { // isCan = false; // return false; // } if (ckValJson.orderState == 1 || ckValJson.orderState<=0) { isCan = false; return false; } ids = ids + ',' + $(vv).attr("value_keyid"); }); if (isCan) { dialog.open({ URL: "/Pages/business/CompledWork.aspx?ids=" + ids, Title: '完工', Height: 600, Width: 680 }); } else { alertMsg("所选订单未受理,或已冻结,或者已终止,或已完成,不能操作完工!"); } } function SendToServer(sparam) { CallServer(sparam, function (data, textStatus) { var msg = {}; msg["1"] = "操作成功!"; msg["0"] = "操作失败!"; msg["-1"] = "操作过程中发生异常,请重新操作!"; msg["-2"] = "订单上次同类申请未处理时不能提交新申请!"; // dialog.close(); RefreshDIVOpener(); alertMsg(msg[data] ? msg[data] : '提交错误,请刷新页面重新操作!'); }, function (XMLHttpRequest, textStatus, errorThrown) { dialog.close(); alertMsg('数据提交失败!'); }); } /* 展示延期申请界面 */ function ShowDoDelay(sparam) { //正数正则表达式 var reg1 = /^\d+(?=\.{0,1}\d+$|$)/; //未受理 if (sparam.orderState == '1') { sparam.dtypeId = 4; sparam.title = "撤单管理"; } parent.parent.parent.parent.parent.parent['ToSubmit'] = function (domobj) { if (!domobj) return; else; var txtTargetValue = domobj.getElementById('txtTargetValue'); var txtDialoguecontent = domobj.getElementById('txtDialoguecontent'); if (!txtTargetValue || !txtDialoguecontent || undefined == txtDialoguecontent.value) return; else; var day = parseFloat(txtTargetValue.value); if (!reg1.test(day)) { alertMsg('申请目标值无效!'); txtTargetValue.focus(); return; } else; if (day > sparam.defaultarget && (sparam.dtypeId == 3 || sparam.dtypeId == 4) && !domobj.isBiged) { domobj.isBiged = true; alertMsg('退款金额大于已支付金额,请在确认无误后重新点击申请按钮!'); txtTargetValue.focus(); return; } var dcontent = txtDialoguecontent.value; SendToServer({ Target: qtypes[sparam.dtypeId], receiver: sparam['receiver'], orderid: sparam['orderid'], tovalue: day, dialoguecontent: dcontent }); }; // dialog.open({ // URL: ('/Pages/business/SubmitOrderDialogue.aspx?dtype=' + sparam.dtypeId + '&orderId=' + sparam.orderShowId + '&defaultarget=' + sparam.defaultarget), Title: sparam.title, Height: 170, Width: 400 // }); //alertMsg('/Pages/business/SubmitOrderDialogue.aspx?dtype=' + sparam.dtypeId + '&orderId=' + sparam.orderShowId + '&defaultarget=' + sparam.defaultarget + '&orderState=' + sparam.orderState + '&orderType=' + sparam.orderType); top.Dialog.open( { URL: ('/Pages/business/SubmitOrderDialogue.aspx?dtype=' + sparam.dtypeId + '&orderId=' + sparam.orderShowId + '&defaultarget=' + sparam.defaultarget + '&orderState=' + sparam.orderState + '&orderType=' + sparam.orderType), Title: sparam.title, Height: 170, Width: 400 } ); } /* 答复订单请求 */ function ToReply(id, orderid, typename, publisher, isAllow) { var askMsg = ("是否" + (isAllow ? "允许" : "拒绝") + "[" + publisher + "]
对订单[" + orderid + "]的" + typename + "请求"); window.dialog.confirm(askMsg, function () { CallServer({ Target: 'ReplyRequest', did: id, isAllow: isAllow }, function (data, textStatus) { var msg = {}; msg["2"] = "操作成功!由于订单已完成或终止,系统未执行申请操作!"; msg["1"] = "操作成功!"; msg["0"] = "操作失败!"; msg["-1"] = "操作过程中发生异常,请重新操作!"; msg["-2"] = ""; alertMsg(msg[data] ? msg[data] : '提交错误,请刷新页面重新操作!'); if ('1' == data) { ReLoad(); } }, function (XMLHttpRequest, textStatus, errorThrown) { alertMsg('数据提交失败!'); }); }); } /* 打印送货单 */ function ToPrintAwbOrder() { var tobjs = new Array(); var errordata = new Array(); var jsonObj = undefined; var ids = ''; var cks = $("input[name='ckId']:checked"); if (cks.length == 0) { alertMsg('没有选中任何项!'); return; } else { } var buyerid = false; var orderId = ""; var DeliveryOrderId = ""; cks.each(function (d) { try { jsonObj = eval('[' + this.value + ']')[0]; } catch (ex) { global.DealDataException(ex); return; } buyerid = !buyerid ? jsonObj['buyerId'] : buyerid; tobjs[tobjs.length] = jsonObj; if (buyerid != jsonObj['buyerId']) { errordata[errordata.length] = jsonObj; } else { ids += jsonObj.id + ','; orderId = jsonObj.id } DeliveryOrderId = jsonObj.DeliveryOrderId; }); if (errordata.length > 0) { alertMsg('必须是相同客户!'); return; } if (ids != "") { ids = ids.substring(0, ids.length - 1); } window.GetSelectedOrders = function () { return tobjs }; CallServer({ Target: "CanPrintAwb", orderIds: ids }, function (dataStr, textStatus) { if (dataStr == "-1") { alertMsg('程序错误,请联系管理员'); return; } var data = eval("(" + dataStr + ")"); if (data.IsCan == "false") { alertMsg(data.Msg); return; } else { if (DeliveryOrderId == null || DeliveryOrderId == "" || DeliveryOrderId == "00000000-0000-0000-0000-000000000000") { var url = "/Pages/business/DeliverPlanShifou.aspx?ids=" + ids + '&buyerid=' + tobjs[0]['buyerId'] + '&orderId=' + orderId; top.Dialog.open({ URL: url, Title: "送货日期", Height: 300, Width: 680 }); //var r = confirm("是否安排送货?"); //if (r == true) { // OpenWindowByUrl('/Pages/business/PrintAwbOrder.aspx?ids=' + ids + '&buyerid=' + tobjs[0]['buyerId'] + '&orderId=' + orderId + '&shifouDelivery=1' ); //} //else { // OpenWindowByUrl('/Pages/business/PrintAwbOrder.aspx?ids=' + ids + '&buyerid=' + tobjs[0]['buyerId'] + '&orderId=' + orderId + '&shifouDelivery=2' ); //} } else { OpenWindowByUrl('/Pages/business/PrintAwbOrder.aspx?ids=' + ids + '&buyerid=' + tobjs[0]['buyerId'] + '&orderId=' + orderId + '&shifouDelivery=2' ); } } }); } function DelayLoadPrintType(printid, pvctype, orderkeyid) { if (window.delaier) { clearTimeout(window.delaier); } window.delaier = setTimeout(function () { LoadPrintType(printid, pvctype, orderkeyid); }, '0' == orderkeyid ? 1000 : 0); //延迟两秒执行 } /* 印刷类型选中值改变方法 */ function printTypeChange(sel) { showWait(); var OldOrderId = document.getElementById('txtKeyid').value; if (sel.value == -1 || sel.value == "-1") { //其他类型 $("#hidOrderId").val(OldOrderId); $("#divInquiry").load("/Pages/front/OtherType.aspx", { "PrintTypeId": "-1" }); setTimeout(function () { if (OldOrderId != "" || OldOrderId == "0") { BindControl(OldOrderId); } }, 1000); window.hideWaitDiv = window.parent.parent.parent.parent.parent.parent.hideWaitDiv; if (window.hideWaitDiv) window.hideWaitDiv(); } else { DelayLoadPrintType(sel.value, '1', OldOrderId, 'order'); } document.getElementById('hidPrintTypeId').value = sel.value; if ($("#txtKeyid").val() == "0") { //document.getElementById('txtDocumentName').value = sel.value ? sel.options[sel.selectedIndex].text : ''; } if (sel.value == 6) { document.getElementById('trbook').style.display = ''; var sselCustormer = document.getElementById('selCustormer').value; if (sselCustormer != null && sselCustormer != '') { //CallServer({ Target: "getPrintAsk", id: sselCustormer }, function (data, textStatus) { // alert(sselCustormer); // var jobj = false; // console.info(data); // try { // jobj = $.parseJSON(data); // } catch (ex) { // global.DealDataException(ex); return; // } // $("#selprintask").empty(); // $("#selprintask").prepend(""); //为Select插入一个Option(第一个位置) // for (var i = 0; i < jobj.length; i++) { // $("#selprintask").append(""); // } //}); $.ajax({ url: "/Pages/business/OrderEdit.aspx", type: "POST", dataType: "html", data: { Target: "getPrintAsk", id: sselCustormer }, global: false, cache: false, async: false, success: function (data) { var jobj = false; // console.info(data); try { //jobj = eval('[' + data + ']'); jobj = $.parseJSON(data); } catch (ex) { global.DealDataException(ex); return; } $("#selprintask").empty(); $("#selprintask").prepend(""); //为Select插入一个Option(第一个位置) for (var i = 0; i < jobj.length; i++) { $("#selprintask").append(""); } }, error: function (arg1) { console.log(arg1) } }); } else { $("#selprintask").empty(); $("#selprintask").prepend(""); //为Select插入一个Option(第一个位置) } } else { document.getElementById('trbook').style.display = 'none'; $("#selprintask").empty(); $("#selprintask").prepend(""); //为Select插入一个Option(第一个位置) } if (sel.value == 37) { document.getElementById('tbFacing').style.display = 'none'; document.getElementById('selVerifyWay12').style.display = 'none'; document.getElementById('selVerifyWay21').style.display = 'none'; document.getElementById('selVerifyWay1234').style.display = 'none'; document.getElementById('selVerifyWay4321').style.display = 'none'; if (OldOrderId == "" || OldOrderId == "0") { document.getElementById('txtDeliveryTime').value = ""; } if (document.getElementById('txtDocumentNameHide').value != "") { document.getElementById('txtDocumentName').value = document.getElementById('txtDocumentNameHide').value; } } else { document.getElementById('tbFacing').style.display = ''; document.getElementById('selVerifyWay12').style.display = ''; document.getElementById('selVerifyWay21').style.display = ''; document.getElementById('selVerifyWay123').style.display = ''; document.getElementById('selVerifyWay321').style.display = ''; document.getElementById('selVerifyWay1234').style.display = ''; document.getElementById('selVerifyWay4321').style.display = ''; } if (sel.value == 37 || sel.value == 38) { $("#Duiyinghetongbianhao").hide(); } else { $("#Duiyinghetongbianhao").show(); } } /* 交易客户选中值发生改变 */ function custormerChange(sel) { if (window.isDataLoading) { return; } if (!sel.value) { $("#selprintask").empty(); $("#selprintask").prepend(""); //为Select插入一个Option(第一个位置) return; } document.getElementById('txtCompanyName').value = sel.options[sel.selectedIndex].text; window.submitUrl = '/Pages/business/OrderEdit.aspx'; setTimeout(function () {//获取联系方式 CallServer({ Target: "GetCommunication", id: sel.value }, function (data, textStatus) { var jobj = false; try { jobj = eval('[' + data + ']')[0]; } catch (ex) { global.DealDataException(ex); return; } if (jobj) { document.getElementById('selCustormerLevel').value = jobj.DegreeImportanId; document.getElementById('selCustormerManagers').value = jobj.AccountManagerId; document.getElementById('selBusinessManagers').value = jobj.BusinessManagerId; document.getElementById('txtContact').value = jobj.BusinessManagers; document.getElementById('txtPhone').value = jobj.CompanyPhone; document.getElementById('txtPrintPackDeliveryRequir').value = jobj.Note; var aaaaaaaaaselPrintTypes = document.getElementById('selPrintTypes').value; if (aaaaaaaaaselPrintTypes == "37") { document.getElementById('txtDocumentName').value = jobj.CompanyName + "作业本"; document.getElementById('txtDocumentNameHide').value = jobj.CompanyName + "作业本"; } else { document.getElementById('txtDocumentNameHide').value = jobj.CompanyName + "作业本"; } setTimeout(function () { ReceiptT('customer', jobj.Keyid, 6, 120); }, 0); //获取收货方式 } else; }); }, 0); var ssselPrintTypes = document.getElementById('selPrintTypes').value; if (ssselPrintTypes == "6" && sel.value != null && sel.value != '') { setTimeout(function () {//获取联系方式 CallServer({ Target: "getPrintAsk", id: sel.value }, function (data, textStatus) { var jobj = false; //console.info(data); try { // jobj = eval('[' + data + ']'); jobj = $.parseJSON(data); } catch (ex) { global.DealDataException(ex); return; } $("#selprintask").empty(); $("#selprintask").prepend(""); //为Select插入一个Option(第一个位置) for (var i = 0; i < jobj.length; i++) { $("#selprintask").append(""); } }); }, 0); } else { $("#selprintask").empty(); $("#selprintask").prepend(""); //为Select插入一个Option(第一个位置) } } function AutoSumPrice() { // var txtPrintCount = document.getElementById("printCount"); // if (!txtPrintCount || undefined == txtPrintCount.value) { return; } else; // document.getElementById("txtSumPrice").value = parseInt(document.getElementById("txtUnitPrice").value) * // parseInt(txtPrintCount.value); // if (this.id == 'printCount') return; else; // txtPrintCount.onblur = AutoSumPrice; } /* 验证界面 */ function ValidateForm() { if (Check()) { document.getElementById('txtBillMode').value = GetInvoice(); var txtEndTime = document.getElementById('txtDeliveryTime'); if (!txtEndTime) return; else; var endTime = new Date(txtEndTime.value.replace(/-/g, "/")).toString("yyyy-MM-dd"); // if (Date.parse(endTime) - Date_ForDay() < 0) { // alertMsg('交货时间不能小于当前时间'); // txtEndTime.focus(); // return false; // } return verfy_form(document.forms[0]); } } function Save() { if (document.getElementById('txtSumPrice').value == "" || parseFloat(document.getElementById('txtSumPrice').value) <= 0) { if (!confirm("订单总价为0,是否继续保存?")) return false; } return ValidateForm(); }