/* * 版 本 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.search({ ParentID: '' }); page.bind(); }, bind: function () { $('#multiple_condition_query').lrMultipleQuery(function (queryJson) { page.search(queryJson); }, 420, 400); //宿舍楼 $('#ApartmentId').lrselect({ allowSearch: true, url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=DormitoryInfo', param: { strWhere: " BuildType='1' " }, value: "id", text: "name", select: function (item) { if (!!item) { //单元 $('#UnitId').lrselectRefresh({ allowSearch: true, url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=DormitoryInfo', param: { strWhere: " BuildType='2' and ApartmentId='" + item.id + "'" }, value: "id", text: "name", select: function (item) { if (!!item) { //楼层 $('#FloorId').lrselectRefresh({ allowSearch: true, url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=DormitoryInfo', param: { strWhere: " BuildType='3' and UnitId='" + item.id + "'" }, value: "id", text: "name" }); } } }); } } }); $('#UnitId').lrselect({ allowSearch: true }); $('#FloorId').lrselect({ allowSearch: true }); $('#Sex').lrDataItemSelect({ code: 'usersex' }); //.lrRadioCheckbox({ // type: 'radio', // code: 'usersex', //}); $('#Class').lrselect({ value: "classno", text: "classname" }); $('#Dept').lrselect({ value: "deptno", text: "deptname", url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=CdDeptInfo', select: function (item) { if (item) { $('#Major').lrselectRefresh({ url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable', param: { code: "CdMajorInfo", strWhere: "DeptNo='" + item.deptno + "'" } }); } else { $('#Major').lrselectRefresh({ url: "", data: [] }); } $('#Class').lrselectRefresh({ url: "", data: [] }); } }); $('#Major').lrselect({ value: "majorno", text: "majorname", select: function (item) { if (item) { $('#Class').lrselectRefresh({ url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable', param: { code: "bjsj", strWhere: "DeptNo='" + item.deptno + "' and majorno='" + item.majorno + "'" } }); } } }); $('#Major').on("click", function () { var data = $('#Dept').lrselectGet(); if (!data) { learun.alert.error('请先选择系'); } }); $('#Class').on("click", function () { var data1 = $('#Dept').lrselectGet(); var data2 = $('#Major').lrselectGet(); if (!data1 || !data2) { learun.alert.error('请先选择系和专业'); } }); // 刷新 $('#lr_refresh').on('click', function () { location.reload(); }); // 新增 $('#lr_add').on('click', function () { if (selectedParent.BuildType != '3') { return learun.alert.warning("请选择楼层!"); } var url = ""; if (selectedParent.ID != null) { url = top.$.rootUrl + '/LogisticsManagement/Accommodation/Form?ParentID=' + selectedParent.ID + '&ParentName=' + selectedParent.Name; } else { return learun.alert.warning("请选择上级!"); //url = top.$.rootUrl + '/LogisticsManagement/Accommodation/Form'; } learun.layerForm({ id: 'form', title: '新增', url: url, width: 900, height: 550, 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: 900, height: 550, 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"); //console.log(selectedParent.ChildType); if (selectedParent.BuildType == "1") { 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); } }); }); // 同步宿舍信息 $('#lr_syncdata').on('click', function () { if (learun.checkrow(keyValue)) { learun.layerConfirm('是否确认同步!', function (res) { if (res) { learun.postForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/SyncData', { keyValue: keyValue }, function () { refreshGirdData(); }); } }); } }); //床位管理 $("#lr_bedManage").on("click", function () { var keyValue = $('#gridtable').jfGridValue('ID'); if (learun.checkrow(keyValue)) { if (keyValue.indexOf(',') != -1) { learun.alert.warning("只能选择一条记录!"); return false; } learun.layerForm({ id: 'indexBed', title: '床位管理', url: top.$.rootUrl + '/LogisticsManagement/Accommodation/IndexBed?ParentID=' + keyValue, width: 700, height: 500, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); } }); //分类管理 $("#lr_Classify").on("click", function () { learun.layerForm({ id: 'indexClassify', title: '分类管理', url: top.$.rootUrl + '/LogisticsManagement/Accommodation/IndexClassify', width: 1200, height: 780, //btn:null, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); }); //导入 $("#lr_importBed").on("click", function () { learun.layerForm({ id: 'indexImport', title: "导入宿舍信息", url: top.$.rootUrl + '/LogisticsManagement/Accommodation/IndexImport', width: 600, height: 400, maxmin: true, btn: null, end: function () { refreshGirdData(); } }); }); }, //初始化左侧树 initTree: function () { // 初始化左侧树形数据 $('#dataTree').lrtree({ url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetTree', nodeClick: function (item) { selectedParent.ID = item.value; selectedParent.Name = item.text; selectedParent.BuildType = item.title; 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"; } var param = {}; if (item.title == '1') param.ApartmentId = item.value; else if (item.title == '2') param.UnitId = item.value; else if (item.title == '3') param.FloorId = item.value; //page.initGird(); //page.search({ ParentID: item.value }); page.search(param); } }); }, // 初始化列表 initGird: function () { //宿舍数据 $('#gridtable').jfGrid({ url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetPageList', headData: [ { label: "名称", name: "Name", width: 100, align: "left" }, { label: "宿舍楼", name: "ApartmentName", width: 100, align: "left" }, { label: "单元", name: "UnitName", width: 100, align: "left" }, { label: "楼层", name: "FloorName", 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: 'majorno', callback: function (_data) { callback(_data['majorname']); } }); } }, { label: "班级", name: "Class", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'bjsj', key: value, keyId: 'classno', callback: function (_data) { callback(_data['classname']); } }); } }, { label: "寝室类型", name: "RoomType", width: 100, align: "left", formatter: function (value, row) { if (value) { return value + '人寝'; } else { return ''; } } }, { label: "入住人数", name: "CheckInStu", width: 100, align: "left" }, { label: "性别", name: "Sex", width: 100, align: "left", formatter: function (value, row) { if (value == '0') return '女'; else if (value == '1') return '男'; else return ''; } }, { 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, sidx: 'ApartmentId asc,UnitId asc ,FloorId asc ', //sord: 'ASC', isSubGrid: true, // 是否有子表 //床位信息 subGridExpanded: function (subContentId, rowItem) { $('#' + subContentId).jfGrid({ url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetBedListByRoomId?RoomId=' + rowItem.ID, 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: 'stuno', callback: function (_data) { callback(_data['stuname']); } }); } }, ], mainId: 'ID', isPage: false, sidx: ' CAST(REPLACE(Name,\'床\',\'\') as int)' //sord: 'ASC', }); //var param; //param = param || {}; //param.ParentID = rowItem.Id; $('#' + subContentId).jfGridSet('reload'); }, subGridHeight: 250, }); //$("#gridtable").empty(); //$("#gridtable")[0].dfop = undefined; //if (selectedParent.BuildType == undefined || selectedParent.BuildType === "3") { //} else { // //lrAuthorizeJfGridLei // $('#gridtable').jfGrid({ // url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetPageList', // headData: [ // { label: "名称", name: "Name", width: 100, align: "left" }, // { // label: "宿舍楼", name: "ApartmentName", width: 100, align: "left" // }, // { // label: "单元", name: "UnitName", width: 100, align: "left" // }, // { // label: "楼层", name: "FloorName", 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 // //sidx: 'ApartmentId asc,UnitId asc ,FloorId asc ', // //sord: 'ASC', // }); //} }, search: function (param) { param = param || {}; param.SqlParameter = " AND t.BuildType ='4' "; $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } }; refreshGirdData = function () { //page.initTree(); if (!!selectedParent.ID) { //var param = { ParentID: selectedParent.ID }; //$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); page.initTree(); page.search({ ParentID: selectedParent.ID }); } else { page.initTree(); page.search(); } }; page.init(); }