/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) * Copyright (c) 2013-2018 北京泉江科技有限公司 * 创建人:超级管理员 * 日 期:2019-04-26 15:02 * 描 述:学生宿舍管理 */ var refreshGirdData; var selectedParent = {}; var bootstrap = function ($, learun) { "use strict"; var page = { init: function () { page.initTree(); //page.initGird(); page.bind(); }, bind: function () { $('#multiple_condition_query').lrMultipleQuery(function (queryJson) { page.search(queryJson); }, 220, 400); $('#Sex').lrRadioCheckbox({ type: 'radio', code: 'usersex', }); // 刷新 $('#lr_refresh').on('click', function () { location.reload(); }); // 新增 $('#lr_add').on('click', function () { var url = ""; if (selectedParent.ID != null) { url = top.$.rootUrl + '/LogisticsManagement/Accommodation/Form?ParentID=' + selectedParent.ID + '&ParentName=' + selectedParent.Name; } else { url = top.$.rootUrl + '/LogisticsManagement/Accommodation/Form'; } learun.layerForm({ id: 'form', title: '新增', url: url, width: 600, height: 400, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); }); // 编辑 $('#lr_edit').on('click', function () { var keyValue = $('#gridtable').jfGridValue('ID'); if (learun.checkrow(keyValue)) { if (keyValue.indexOf(',') != -1) { learun.alert.warning("只能选择一条记录进行编辑!"); return false; } learun.layerForm({ id: 'form', title: '编辑', url: top.$.rootUrl + '/LogisticsManagement/Accommodation/Form?keyValue=' + keyValue, width: 600, height: 400, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); } }); // 删除 $('#lr_delete').on('click', function () { var keyValue = $('#gridtable').jfGridValue('ID'); if (learun.checkrow(keyValue)) { learun.layerConfirm('是否确认删除该项!', function (res) { if (res) { learun.deleteForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/DeleteForm', { keyValue: keyValue }, function () { refreshGirdData(); }); } }); } }); //批量添加宿舍 $("#lr_dormitoryAdd").on("click", function () { var keyvalue1 = $("#gridtable").jfGridValue("ID"); if (selectedParent.ChildType == "2") { var keyValue = selectedParent.ID; learun.layerForm({ id: 'form', title: '批量添加宿舍', url: top.$.rootUrl + '/LogisticsManagement/Accommodation/DormitoryAdd?keyValue=' + keyValue, width: 600, height: 400, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); } else { learun.alert.warning("请选择楼"); } }); // 打印 $('#lr_print').on('click', function () { $('#gridtable').jqprintTable(); }); //刷新左侧的树 $("#tree_refresh").on("click", function () { page.initTree(); }); //自动分配宿舍 $("#lr_allocation").on("click", function () { learun.layerForm({ id: 'form', title: '自动分配宿舍', url: top.$.rootUrl + '/LogisticsManagement/Accommodation/Allocation', width: 400, height: 250, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); }); }, //初始化左侧树 initTree: function () { // 初始化左侧树形数据 $('#dataTree').lrtree({ url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetTree', nodeClick: function (item) { selectedParent.ID = item.value; selectedParent.Name = item.text; if (item.parent) { if (!item.parent.parentId) { selectedParent.ChildType = "2"; } else { selectedParent.ChildType = "0"; } } else { selectedParent.ChildType = "1"; } if (item.text.indexOf("室") > -1) { selectedParent.ChildType = "5"; } page.initGird(); page.search({ ParentID: item.value }); } }); }, // 初始化列表 initGird: function () { //$("#gridtable").removeClass("jfgrid-layout"); //$("#gridtable").removeAttr("style"); //$("#gridtable").empty(); //$("#gridtable")[0].dfop = undefined; if (selectedParent.ChildType == "5") { $('#gridtable').lrAuthorizeJfGridLei({ url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetPageList', headData: [ { label: "名称", name: "Name", width: 100, align: "left" }, { label: "学生名字", name: "StuName", width: 100, align: "left" }, { label: "班级", name: "Class", width: 100, align: "left" }, { label: "性别", name: "Sex", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('dataItem', { key: value, code: 'usersex', callback: function (_data) { callback(_data.text); } }); } }, { label: "负责人", name: "Functionary", width: 100, align: "left" }, { label: "负责人电话", name: "Phone", width: 100, align: "left" }, { label: "价格", name: "Price", width: 100, align: "left" }, { label: "星级", name: "Starred", width: 100, align: "left" }, { label: "是否独卫", name: "HasToilet", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('dataItem', { key: value, code: 'HasToilet', callback: function (_data) { callback(_data.text); } }); } }, { label: "舍长", name: "Leader", width: 100, align: "left" }, { label: "备注", name: "Remark", width: 100, align: "left" }, ], mainId: 'ID', isPage: true, isMultiselect:true }); } else { $('#gridtable').lrAuthorizeJfGridLei({ url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetPageList', headData: [ { label: "名称", name: "Name", width: 100, align: "left" }, { label: "学生", name: "StudentID", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'StuInfoBasic', key: value, keyId: 'stuid', callback: function (_data) { callback(_data['stuname']); } }); } }, { label: "位置", name: "Address", width: 100, align: "left" }, { label: "校区", name: "Campus", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'company', key: value, keyId: 'f_companyid', callback: function (_data) { callback(_data['f_fullname']); } }); } }, { label: "系", name: "Dept", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdDeptInfo', key: value, keyId: 'deptno', callback: function (_data) { callback(_data['deptname']); } }); } }, { label: "专业", name: "Major", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdMajorInfo', key: value, keyId: 'id', callback: function (_data) { callback(_data['majorname']); } }); } }, { label: "班级", name: "Class", width: 100, align: "left" }, { label: "性别", name: "Sex", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('dataItem', { key: value, code: 'usersex', callback: function (_data) { callback(_data.text); } }); } }, { label: "负责人", name: "Functionary", width: 100, align: "left" }, { label: "负责人电话", name: "Phone", width: 100, align: "left" }, { label: "备注", name: "Remark", width: 100, align: "left" }, ], mainId: 'ID', isPage: true, isMultiselect:true }); } //page.search(); }, search: function (param) { param = param || {}; $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } }; refreshGirdData = function () { //page.initTree(); if (!!selectedParent.ID) { page.search({ ParentID: selectedParent.ID }); } else { page.search(); } }; page.init(); }