如果一个JS文件写的JS太多是不是找不到方法而头痛 以下是我总结的写下
/****************来自:http://52mvc.com/showtopic-658.aspx***********************************/
/********************销售订单***********************/
/***************************************************/
$(function () {
searchSales();
$("[id=txtGoods]").delSalesGood(); //双击删除销售订单名细
$("[id=txtSTraderid]").live("dblclick", function () { $(this).val(""); })//双击清空客户
$(".detailbox input:text").inputbind(); //销售订单名细input输入联动操作
$("[id=txtGoods]").autoGood(); //货品名自动提示
$("[id=txtSTraderid]").autoTrader(); //客户名自动提示
$("[id=txtSLinkman]").autoLinkman(); //联系人名自动提示
$(".list tr").dblOpenSales(); //双击查看编辑销售订单
$("#winSales .tabs li:eq(0)").live("click", function () { $("#AddGood,.chancetasnotonenone").show() })
$("#winSales .tabs li:eq(1)").live("click", function () { $("#AddGood,.chancetasnotonenone").hide() })
$("#winSales .tabs li:eq(2)").live("click", function () { $("#AddGood,.chancetasnotonenone").hide() })
});
/***************************函数说明 ***************************
searchSales 绑定订单列表
openSalesSaveWindow 打开保存窗口
fSales_Details_SaveSubmit 保存销售订单
SalesAudit 审核销售订单
OpenGoodWindow 打开新增货品窗口
first last next prev 第一单 最后一单 下一单 上一单
reloadSalesWin 刷新销售订单保存窗口
SaveSuccessedGoodToSales 保存货品
printSales(Billid) 打印销售订单
openSalesWord(Billid)WORD打开销售订单
openSalesPDF(Billid)PDF打开销售订单
OpenSalesMailTo(Billid)打开邮件窗口
OpenSalesFaxTo(Billid)打开传真窗口
SalesFaxSubmit提交传真
SalesEmailSubmit提交邮件
buildSale**ill(orderId)生成销售开单 根据订单ID
buildPurchasebill(orderId)生成采购订单 根据订单ID
***************************************************************/
//页面首次加载扩展方法集合
$.fn.extend({
delSalesGood: function () {
this.live("dblclick", function () {
$(this).closest("tr").remove();
GetGoodsTol();
})
},
inputbind: function () {
this.live("keyup", function () {
var tr = $(this).closest("tr");
var ds_quantity = parseFloat(tr.find("#ds_Quantity").val());
var ds_price = parseFloat(tr.find("#ds_Price").val());
var ds_taxrate = parseFloat(tr.find("#ds_Taxrate").val());
var apriceandtax = ds_price + ds_price * ds_taxrate / 100;
var tolpriceandtax = apriceandtax * ds_quantity;
if (tolpriceandtax > 0) {
var apriceandtaxobj = tr.find("#apriceandtax").text(apriceandtax);
var tolpriceandtaxobj = tr.find("#tolpriceandtax").text(tolpriceandtax);
}
GetGoodsTol();
});
},
autoGood: function () {
this.autoProductNamesByFun({ load: function () {
var id = $("body").data(_txtGoodsClick);
var boxselector = $("#" + id);
var trId = boxselector.closest("tr").attr("id");
var goods = $(boxselector).find("[id=txtGoods]").val();
if (goods != null) {
$.ajax({
data: { goods: goods },
dataType: "html",
type: "get",
cache: false,
url: "/Sales/Sales_Details_Save",
success: function (msg) {
var wds = $("#" + trId);
wds.html(msg);
}, error: error
});
}
}
});
},
autoTrader: function () {
this.autoComplete({
url: "/Sales/GetTraderNames",
showdivclick: function () {
$(".customer>a").live("click", function () {
$("[id=txtSTraderid],[id=txtTraderid]").val($(this).text())
});
$("body").click(function () {
$(".showDiv").removeAttr("style");
$(".showDiv").css("display", "none")
})
},
p2: "customer"
});
},
autoLinkman: function () {
this.autoComplete({
url: "/Sales/GetLinkmanNames",
showdivclick: function () {
$(".linkman>a").live("click", function () {
$("[id=txtSLinkman],[id=txtLinkman]").val($(this).text())
$(".showDiv").removeAttr("style");
});
$("body").click(function () {
$(".showDiv").removeAttr("style");
})
}, p2: "linkman"
});
},
dblOpenSales: function () {
this.live("dblclick", function () {
var connname = $("#hdConn").val();
var billId = $(this).find("#o_Billid").val();
if (billId > 0) {
openSalesSaveWindow(billId);
}
})
}
});
function openSalesSaveWindow(id) {
var isadd = id == 0 || id == null || id == "";
var title = (isadd ? "增加销售订单" : "编辑销售订单");
title += "-" + $("#hdConn").val();
$.ajax({
dataType: "html",
data: { id: id },
type: "get",
url: "/Sales/Sales_Save",
beforeSend: function () { $.loading(); },
success: function (msg) {
$("#winSales").html(msg);
$("#tabSales").tabs();
$("#winSales").window(getW(title));
$("[lk=lk]").linkbutton();
$.removeLoading();
}, error: error
})
}
function searchSales() {
$.loading();
$("#fSalesSearch").ajaxSubmit({
url: "/Sales/Sales_List",
type: "GET",
error: error,
dataType: "html",
success: function (msg) {
$(".list").html(msg);
$.removeLoading();
$('#salesBox').datagrid();
}, error: error
});
}
function Sales_SaveSubmit() {
var goodtol = $("#goodtol").text();
if (goodtol > 0) {
if ($("#txtTraderid").isNotNull("客户不能为空。")) {
$("#fSaleSave").ajaxSubmit({
url: "/Sales/Sales_SaveSubmit",
type: "post",
cache: false,
dataType: "text",
success: function (msg) {
if (msg != null && msg != "") {
alert(msg.toString());
} else {
$.messager.alert(_wxtx, "操作成功!");
searchSales();
$("#winSales").window("close")
}
},error:error
});
}
} else {
$.messager.alert(_wxtx, "明细不能为空。");
}
}
function SalesAudit(state, id) {
$.ajax({
url: "/Sales/SalesAudit",
data: { state: state, id: id },
dataType: "text",
success: function (msg) {
openSalesSaveWindow(id);
}
})
}
function OpenGoodWindow(id, pageId) {
$.ajax({
data: { id: id, pageId: pageId },
dataType: "html",
type: "get",
cache: false,
url: "/crm/Product_Save",
success: function (msg) {
$("#winGoods").html(msg);
$("#winGoods").window({
title: "增加商品",
modal: true,
shadow: false,
closed: false
});
$("#tabsGoods").tabs();
$("#btngoodssubmit").linkbutton();
}
});
}
function first() {
$.ajax({
data: { isFirst: true },
type: "get",
cache: false,
url: "/Sales/GetFirstOrLastBillId",
success: function (msg) {
openSalesSaveWindow(msg);
}
})
}
function last() {
$.ajax({
data: { isFirst: false },
type: "get",
cache: false,
url: "/Sales/GetFirstOrLastBillId",
success: function (msg) {
openSalesSaveWindow(msg);
}
})
}
function prev(billId) {
$.ajax({
data: { billId: billId, isNext: false },
type: "get",
cache: false,
url: "/Sales/GetPrevOrNextBillId",
success: function (msg) {
openSalesSaveWindow(msg);
}
})
}
function next(billId) {
var connname = $("#hdConn").val();
if (billId == 0) {
openSalesSaveWindow(0);
} else {
$.ajax({
data: { billId: billId, isNext: true },
type: "get",
cache: false,
url: "/Sales/GetPrevOrNextBillId",
success: function (msg) {
openSalesSaveWindow(msg);
}
})
}
}
function reloadSalesWin(billid) {
prev(billid + 1);
}
function SaveSuccessedGoodToSales(goodName) {
if (goodName != null) {
$.ajax({
data: { goods: goodName },
dataType: "html",
type: "get",
cache: false,
url: "/Sales/Sales_Details_Save",
success: function (msg) {
$("[id*=goodrow]").each(function () {
var th = $(this);
var thv = th.val();
if (th.find("[id=ds_price]").size() == 0) {
th.html(msg);
return false;
}
})
}, error: error
});
}
$("#winGoods").window("close");
}
function printSales(billid) {
var printid = $("#prints").val();
$.ajax({
data: { id: billid, printid: printid },
dataType: "html",
type: "get",
cache: false,
beforeSend: function () {
$.loading();
},
url: "/Sales/SalesPrint",
success: function (msg) {
$.removeLoading();
_print(msg.toString());
}, error: error
});
}
function openSalesWord(billid) {
var printid = $("#prints").val();
window.open("/Sales/OpenSalesWord?billId=" + billid + "&printId=" + printid, "销售订单")
}
function openSalesPDF(billid) {
var printid = $("#prints").val();
window.open("/Sales/OpenSalesPDF?billId=" + billid + "&printId=" + printid, "销售订单")
}
function OpenSalesMailTo(Billid) {
$.ajax({
url: "/Sales/Sales_Mail_Save",
data: { billId: Billid },
dataType: "text",
type: "get",
cache: false,
beforeSend: function () {
$.loading();
},
success: function (msg) {
$.removeLoading();
$("#winMailTo").html(msg);
$("#winMailTo").window(getW("发送邮件"));
$("#btnSendMail").linkbutton();
}, error: error
})
$("#winMailTo").window(getW("发送邮件", 500, 500));
}
function OpenSalesFaxTo(Billid) {
$.ajax({
url: "/Sales/Sales_Fax_Save",
data: { billId: Billid },
dataType: "text",
type: "get",
cache: false,
beforeSend: function () {
$.loading();
},
success: function (msg) {
$.removeLoading();
$("#winMailTo").html(msg);
$("#winMailTo").window(getW("发送传真"));
$("#btnSendMail").linkbutton();
}, error: error
})
$("#winMailTo").window(getW("发送邮件", 500, 500));
}
function SalesEmailSubmit() {
$.loading();
var printsval = $("#prints").val();
var o_Billid = $("#o_Billid").val();
$("#maillBillid").val(o_Billid)
$("#mamilprintid").val(printsval);
$("#fSalesMail").ajaxSubmit({
url: "/Sales/SalesEmailSubmit",
dataType: "html",
type: "post",
success: function (msg) {
$("#ajaxRev").html(msg);
$.removeLoading();
}, error: error
});
}
function buildSale**ill(orderId) {
window.open("/SalesBilling/index?title=销售开单&orderId=" + orderId);
}
function buildPurchasebill(orderId) {
window.open("/Purchase/Purchase?title=采购订单&orderId=" + orderId);
}