根据子节点的ID 回填所有相关的数据,当还没单击子节点的时候是没数据的,如图
单击子节点的时候,相关的数据就回填了,如图
下面是在控制器写的源代码
//查出结账的客房对应的信息
public ActionResult SelectDetail(int sysOrderFormid)
{
try
{
var sysDetail = (from tbR in myModel.R_OrderFormDetail
join tbRoom in myModel.S_GuestRoom on tbR.GuestRoomID equals tbRoom.GuestRoomID
join tbB in myModel.B_OrderForm on tbR.OrderFormID equals tbB.OrderFormID
join tbS in myModel.S_GuestInformation on tbB.GuestInformationID equals tbS.GuestInformationID
join tbG in myModel.S_GuestCategory on tbB.GuestCategoryID equals tbG.GuestCategoryID
join tbCategory in myModel.S_RoomCategory on tbRoom.RoomCategoryID equals tbCategory.RoomCategoryID
where tbR.ZhaungTai == true && tbR.GuestRoomID == sysOrderFormid //条件查询
select new OrderForm
{
OrderFormDetailID = tbR.OrderFormDetailID,
GuestRoomID = tbRoom.GuestRoomID,
OrderFormID = tbB.OrderFormID,
GuestInformationID = tbS.GuestInformationID,
RoomCategoryID = tbCategory.RoomCategoryID,
GuestCategoryID = tbG.GuestCategoryID,
Accounts = tbB.Accounts,
RoomNumber = tbRoom.RoomNumber,
Name = tbS.Name,
Abbreviation = tbCategory.Abbreviation,
PracticalHousingPrice = tbB.PracticalHousingPrice.ToString(),
ArriveShopTime = tbB.ArriveShopDate.ToString(),
OunShopTime = tbB.OutShopDate.ToString(),
CategoryName = tbG.CategoryName,
RemarkInformation = tbB.RemarkInformation,
FirstCollectCashPledge = tbB.FirstCollectCashPledge.ToString(),
}).Single();
return Json(sysDetail, JsonRequestBehavior.AllowGet);
}
catch (Exception e)
{
Console.WriteLine(e);
return Json("", JsonRequestBehavior.AllowGet);
}
}
下面是视图的代码
//获取子节点的ID
function zTreeOnClick(event, treeId, treeNode) {
var treeObj = $.fn.zTree.getZTreeObj("tree"); //装树形数据的ID
var nodes = treeObj.getSelectedNodes();
console.log(treeNode);
var DistrictID = treeNode.id;//节点的ID
//回填结账客房的信息
$.post("/KfFroom/FangTaitu/SelectDetail", { sysOrderFormid: DistrictID }, functio (data) {
$("#ZH").val(data.Accounts);//账号
$("#XM").val(data.Name); //名称
$("#FH").val(data.RoomNumber);//房号
$("#FL").val(data.Abbreviation);//房类
$("#FJ").val(data.PracticalHousingPrice);//实际价格
$("#DD").val(data.ArriveShopTime);//抵店时间
$("#LD").val(data.OutShoptime);//离店时间
$("#BZ").val(data.RemarkInformation);//备注
$("#LX").val(data.CategoryName);//客人类别
$("#YJ").val(data.FirstCollectCashPledge);//押金
$("#IDss").val(data.OrderFormID);//订单ID
$("#KFIDs").val(data.GuestRoomID);//客房ID
$("#TS").val(olldata);//天数
var LL = $("#YJ").val();//押金
var ff = $("#LJxf").val();//累计消费
document.getElementById("YE").value = parseFloat(LL) - parseFloat(ff);//计算余额
$("#KB").val(ff - LL);//计算客宾支付
$("#ZL").val((LL - ff) + (ff - LL));//找零
}, 'json');