You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

626 lines
28 KiB

  1. /* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  2. * Copyright (c) 2013-2018 北京泉江科技有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2019-04-26 15:02
  5. * 描 述:学生宿舍管理
  6. */
  7. var refreshGirdData;
  8. var selectedParent = {};
  9. var bootstrap = function ($, learun) {
  10. "use strict";
  11. var page = {
  12. init: function () {
  13. page.initTree();
  14. page.initGird();
  15. page.search({ ParentID: '' });
  16. page.bind();
  17. },
  18. bind: function () {
  19. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  20. page.search(queryJson);
  21. }, 420, 400);
  22. //宿舍楼
  23. $('#ApartmentId').lrselect({
  24. allowSearch: true,
  25. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=DormitoryInfo',
  26. param: { strWhere: " BuildType='1' " },
  27. value: "id",
  28. text: "name",
  29. select: function (item) {
  30. if (!!item) {
  31. //单元
  32. $('#UnitId').lrselectRefresh({
  33. allowSearch: true,
  34. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=DormitoryInfo',
  35. param: { strWhere: " BuildType='2' and ApartmentId='" + item.id + "'" },
  36. value: "id",
  37. text: "name",
  38. select: function (item) {
  39. if (!!item) {
  40. //楼层
  41. $('#FloorId').lrselectRefresh({
  42. allowSearch: true,
  43. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=DormitoryInfo',
  44. param: { strWhere: " BuildType='3' and UnitId='" + item.id + "'" },
  45. value: "id",
  46. text: "name"
  47. });
  48. }
  49. }
  50. });
  51. }
  52. }
  53. });
  54. $('#UnitId').lrselect({ allowSearch: true });
  55. $('#FloorId').lrselect({ allowSearch: true });
  56. $('#Sex').lrDataItemSelect({ code: 'usersex' });
  57. //.lrRadioCheckbox({
  58. // type: 'radio',
  59. // code: 'usersex',
  60. //});
  61. $('#NoDistribution').lrRadioCheckbox({
  62. type: 'checkbox',
  63. code: 'NoDistribution'
  64. });
  65. $('#Distribution').lrRadioCheckbox({
  66. type: 'checkbox',
  67. code: 'NoDistribution'
  68. });
  69. $('#Class').lrselect({
  70. value: "classno",
  71. text: "classname"
  72. });
  73. $('#Dept').lrselect({
  74. value: "deptno",
  75. text: "deptname",
  76. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=CdDeptInfo',
  77. select: function (item) {
  78. if (item) {
  79. $('#Major').lrselectRefresh({
  80. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable',
  81. param: { code: "CdMajorInfo", strWhere: "DeptNo='" + item.deptno + "'" }
  82. });
  83. }
  84. else {
  85. $('#Major').lrselectRefresh({
  86. url: "",
  87. data: []
  88. });
  89. }
  90. $('#Class').lrselectRefresh({
  91. url: "",
  92. data: []
  93. });
  94. }
  95. });
  96. $('#Major').lrselect({
  97. value: "majorno",
  98. text: "majorname",
  99. select: function (item) {
  100. if (item) {
  101. $('#Class').lrselectRefresh({
  102. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable',
  103. param: { code: "bjsj", strWhere: "DeptNo='" + item.deptno + "' and majorno='" + item.majorno + "'" }
  104. });
  105. }
  106. }
  107. });
  108. $('#Major').on("click",
  109. function () {
  110. var data = $('#Dept').lrselectGet();
  111. if (!data) {
  112. learun.alert.error('请先选择系');
  113. }
  114. });
  115. $('#Class').on("click",
  116. function () {
  117. var data1 = $('#Dept').lrselectGet();
  118. var data2 = $('#Major').lrselectGet();
  119. if (!data1 || !data2) {
  120. learun.alert.error('请先选择系和专业');
  121. }
  122. });
  123. // 刷新
  124. $('#lr_refresh').on('click', function () {
  125. location.reload();
  126. });
  127. // 新增
  128. $('#lr_add').on('click', function () {
  129. var url = "";
  130. if (selectedParent.ID != null) {
  131. url = top.$.rootUrl + '/LogisticsManagement/Accommodation/Form?ParentID=' + selectedParent.ID + '&ParentName=' + selectedParent.Name;
  132. } else {
  133. return learun.alert.warning("请选择上级!");
  134. //url = top.$.rootUrl + '/LogisticsManagement/Accommodation/Form';
  135. }
  136. learun.layerForm({
  137. id: 'form',
  138. title: '新增',
  139. url: url,
  140. width: 900,
  141. height: 550,
  142. callBack: function (id) {
  143. return top[id].acceptClick(refreshGirdData);
  144. }
  145. });
  146. });
  147. // 编辑
  148. $('#lr_edit').on('click', function () {
  149. var keyValue = $('#gridtable').jfGridValue('ID');
  150. if (learun.checkrow(keyValue)) {
  151. if (keyValue.indexOf(',') != -1) {
  152. learun.alert.warning("只能选择一条记录进行编辑!");
  153. return false;
  154. }
  155. learun.layerForm({
  156. id: 'form',
  157. title: '编辑',
  158. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/Form?keyValue=' + keyValue,
  159. width: 900,
  160. height: 550,
  161. callBack: function (id) {
  162. return top[id].acceptClick(refreshGirdData);
  163. }
  164. });
  165. }
  166. });
  167. // 删除
  168. $('#lr_delete').on('click', function () {
  169. var keyValue = $('#gridtable').jfGridValue('ID');
  170. if (learun.checkrow(keyValue)) {
  171. learun.layerConfirm('是否确认删除该项!', function (res) {
  172. if (res) {
  173. learun.deleteForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/DeleteForm', { keyValue: keyValue }, function () {
  174. refreshGirdData();
  175. });
  176. }
  177. });
  178. }
  179. });
  180. //批量添加宿舍
  181. $("#lr_dormitoryAdd").on("click", function () {
  182. var keyvalue1 = $("#gridtable").jfGridValue("ID");
  183. if (selectedParent.ChildType == "2") {
  184. var keyValue = selectedParent.ID;
  185. learun.layerForm({
  186. id: 'form',
  187. title: '批量添加宿舍',
  188. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/DormitoryAdd?keyValue=' + keyValue,
  189. width: 600,
  190. height: 400,
  191. callBack: function (id) {
  192. return top[id].acceptClick(refreshGirdData);
  193. }
  194. });
  195. }
  196. else {
  197. learun.alert.warning("请选择楼");
  198. }
  199. });
  200. // 打印
  201. $('#lr_print').on('click', function () {
  202. $('#gridtable').jqprintTable();
  203. });
  204. //刷新左侧的树
  205. $("#tree_refresh").on("click", function () {
  206. page.initTree();
  207. });
  208. //分配系
  209. $("#lr_Dept").on("click", function () {
  210. var keyValue = $('#gridtable').jfGridValue('ID');
  211. var BuildType = $('#gridtable').jfGridValue('BuildType');
  212. var Dept = $('#gridtable').jfGridValue('Dept');
  213. var arr = BuildType.split(',');
  214. if (arr.some(x => x != '4')) {
  215. return learun.alert.warning("只能选择宿舍进行分配!");
  216. }
  217. if (keyValue.indexOf(',') > 0) {
  218. var arrDept = Dept.split(',');
  219. for (var i = 0; i < arrDept.length; i++) {
  220. if (arrDept[i].length >= 1) {
  221. learun.alert.warning("选中记录包含已分配的数据!");
  222. return false;
  223. }
  224. }
  225. }
  226. learun.layerForm({
  227. id: 'formDept',
  228. title: '分配系部',
  229. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/FormDept?keyValue=' + keyValue,
  230. width: 400,
  231. height: 300,
  232. callBack: function (id) {
  233. return top[id].acceptClick(refreshGirdData);
  234. }
  235. });
  236. });
  237. //分配专业和班级
  238. $("#lr_Class").on("click", function () {
  239. var keyValue = $('#gridtable').jfGridValue('ID');
  240. var BuildType = $('#gridtable').jfGridValue('BuildType');
  241. var Dept = $('#gridtable').jfGridValue('Dept');
  242. var arr = BuildType.split(',');
  243. if (arr.some(x => x != '4')) {
  244. return learun.alert.warning("只能选择宿舍进行分配!");
  245. }
  246. var arrDept = Dept.split(',');
  247. if (arrDept.some(function (value, index) {
  248. return value.length === 0;
  249. })) {
  250. return learun.alert.warning("选中记录包含未分配系的数据!");
  251. }
  252. if (keyValue.indexOf(',') > 0) {
  253. if (arrDept.some(function (value, index) {
  254. return value != arrDept[0];
  255. })) {
  256. return learun.alert.warning("选中记录包含多种专业的数据,不可批量分配班级!");
  257. }
  258. }
  259. learun.layerForm({
  260. id: 'formClass',
  261. title: '分配专业班级',
  262. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/FormClass?keyValue=' + keyValue + '&Dept=' + arrDept[0],
  263. width: 400,
  264. height: 300,
  265. callBack: function (id) {
  266. return top[id].acceptClick(refreshGirdData);
  267. }
  268. });
  269. });
  270. //分配宿舍
  271. $("#lr_Bed").on("click", function () {
  272. var keyValue = $('#gridtable').jfGridValue('ID');
  273. var Sex = $('#gridtable').jfGridValue('Sex');
  274. var BuildType = $('#gridtable').jfGridValue('BuildType');
  275. var Name = $('#gridtable').jfGridValue('Name');
  276. var Class = $('#gridtable').jfGridValue('Class');
  277. var arr = BuildType.split(',');
  278. if (arr.some(x => x != '4')) {
  279. return learun.alert.warning("只能选择宿舍进行分配!");
  280. }
  281. if (keyValue.indexOf(',') != -1) {
  282. return learun.alert.warning("只能选择一条记录进行分配!");
  283. }
  284. if (Class.length == 0) {
  285. return learun.alert.warning("请先分配班级!");
  286. }
  287. learun.layerForm({
  288. id: 'formRoom',
  289. title: '分配宿舍--' + Name,
  290. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/FormRoom?keyValue=' + keyValue + '&Class=' + Class + '&Sex=' + Sex,
  291. width: 600,
  292. height: 400,
  293. callBack: function (id) {
  294. return top[id].acceptClick(refreshGirdData);
  295. }
  296. });
  297. });
  298. },
  299. //初始化左侧树
  300. initTree: function () {
  301. // 初始化左侧树形数据
  302. $('#dataTree').lrtree({
  303. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetTree',
  304. nodeClick: function (item) {
  305. selectedParent.ID = item.value;
  306. selectedParent.Name = item.text;
  307. selectedParent.BuildType = item.title;
  308. if (item.parent) {
  309. if (!item.parent.parentId) {
  310. selectedParent.ChildType = "2";
  311. } else {
  312. selectedParent.ChildType = "0";
  313. }
  314. }
  315. else {
  316. selectedParent.ChildType = "1";
  317. }
  318. if (item.text.indexOf("室") > -1) {
  319. selectedParent.ChildType = "5";
  320. }
  321. var param = {};
  322. if (item.title == '1')
  323. param.ApartmentId = item.value;
  324. else if (item.title == '2')
  325. param.UnitId = item.value;
  326. else if (item.title == '3')
  327. param.FloorId = item.value;
  328. //page.initGird();
  329. //page.search({ ParentID: item.value });
  330. page.search(param);
  331. }
  332. });
  333. },
  334. // 初始化列表
  335. initGird: function () {
  336. //宿舍数据
  337. $('#gridtable').jfGrid({
  338. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetPageList',
  339. headData: [
  340. { label: "名称", name: "Name", width: 100, align: "left" },
  341. {
  342. label: "宿舍楼", name: "ApartmentName", width: 100, align: "left"
  343. },
  344. {
  345. label: "单元", name: "UnitName", width: 100, align: "left"
  346. },
  347. {
  348. label: "楼层", name: "FloorName", width: 100, align: "left"
  349. },
  350. //{
  351. // label: "学生", name: "StudentID", width: 100, align: "left",
  352. // formatterAsync: function (callback, value, row, op, $cell) {
  353. // learun.clientdata.getAsync('custmerData', {
  354. // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'StuInfoBasic',
  355. // key: value,
  356. // keyId: 'stuid',
  357. // callback: function (_data) {
  358. // callback(_data['stuname']);
  359. // }
  360. // });
  361. // }
  362. //},
  363. { label: "位置", name: "Address", width: 100, align: "left" },
  364. {
  365. label: "校区", name: "Campus", width: 100, align: "left",
  366. formatterAsync: function (callback, value, row, op, $cell) {
  367. learun.clientdata.getAsync('custmerData', {
  368. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'company',
  369. key: value,
  370. keyId: 'f_companyid',
  371. callback: function (_data) {
  372. callback(_data['f_fullname']);
  373. }
  374. });
  375. }
  376. },
  377. {
  378. label: "系", name: "Dept", width: 100, align: "left",
  379. formatterAsync: function (callback, value, row, op, $cell) {
  380. learun.clientdata.getAsync('custmerData', {
  381. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdDeptInfo',
  382. key: value,
  383. keyId: 'deptno',
  384. callback: function (_data) {
  385. callback(_data['deptname']);
  386. }
  387. });
  388. }
  389. },
  390. {
  391. label: "专业", name: "Major", width: 100, align: "left",
  392. formatterAsync: function (callback, value, row, op, $cell) {
  393. learun.clientdata.getAsync('custmerData', {
  394. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdMajorInfo',
  395. key: value,
  396. keyId: 'majorno',
  397. callback: function (_data) {
  398. callback(_data['majorname']);
  399. }
  400. });
  401. }
  402. },
  403. {
  404. label: "班级", name: "Class", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) {
  405. learun.clientdata.getAsync('custmerData', {
  406. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'bjsj',
  407. key: value,
  408. keyId: 'classno',
  409. callback: function (_data) {
  410. callback(_data['classname']);
  411. }
  412. });
  413. }
  414. },
  415. {
  416. label: "寝室类型", name: "RoomType", width: 100, align: "left",
  417. formatter: function (value, row) {
  418. if (value) {
  419. return value + '人寝';
  420. } else {
  421. return '';
  422. }
  423. }
  424. },
  425. { label: "入住人数", name: "CheckInStu", width: 100, align: "left" },
  426. {
  427. label: "性别", name: "Sex", width: 100, align: "left",
  428. formatter: function (value, row) {
  429. if (value == '0')
  430. return '女';
  431. else if (value == '1')
  432. return '男';
  433. else
  434. return '';
  435. }
  436. },
  437. { label: "负责人", name: "Functionary", width: 100, align: "left" },
  438. { label: "负责人电话", name: "Phone", width: 100, align: "left" },
  439. { label: "备注", name: "Remark", width: 100, align: "left" },
  440. ],
  441. mainId: 'ID',
  442. isPage: true,
  443. isMultiselect: true,
  444. sidx: 'CheckInStu asc,ApartmentId asc,UnitId asc ,FloorId asc ',
  445. //sord: 'ASC',
  446. isSubGrid: true, // 是否有子表
  447. subGridExpanded: function (subContentId, rowItem) {
  448. $('#' + subContentId).jfGrid({
  449. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetBedListByRoomId?RoomId=' + rowItem.ID,
  450. headData: [
  451. { label: "名称", name: "Name", width: 100, align: "left" },
  452. {
  453. label: "学生", name: "StudentID", width: 100, align: "left",
  454. formatterAsync: function (callback, value, row, op, $cell) {
  455. learun.clientdata.getAsync('custmerData', {
  456. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'StuInfoBasic',
  457. key: value,
  458. keyId: 'stuno',
  459. callback: function (_data) {
  460. callback(_data['stuname']);
  461. }
  462. });
  463. }
  464. },
  465. ],
  466. mainId: 'ID',
  467. isPage: false,
  468. //sidx: 'DNo',
  469. //sord: 'ASC',
  470. });
  471. //var param;
  472. //param = param || {};
  473. //param.ParentID = rowItem.Id;
  474. $('#' + subContentId).jfGridSet('reload');
  475. },
  476. subGridHeight: 250,
  477. });
  478. //$("#gridtable").empty();
  479. //$("#gridtable")[0].dfop = undefined;
  480. //if (selectedParent.BuildType == undefined || selectedParent.BuildType === "3") {
  481. //} else {
  482. // //lrAuthorizeJfGridLei
  483. // $('#gridtable').jfGrid({
  484. // url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetPageList',
  485. // headData: [
  486. // { label: "名称", name: "Name", width: 100, align: "left" },
  487. // {
  488. // label: "宿舍楼", name: "ApartmentName", width: 100, align: "left"
  489. // },
  490. // {
  491. // label: "单元", name: "UnitName", width: 100, align: "left"
  492. // },
  493. // {
  494. // label: "楼层", name: "FloorName", width: 100, align: "left"
  495. // },
  496. // //{
  497. // // label: "学生", name: "StudentID", width: 100, align: "left",
  498. // // formatterAsync: function (callback, value, row, op, $cell) {
  499. // // learun.clientdata.getAsync('custmerData', {
  500. // // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'StuInfoBasic',
  501. // // key: value,
  502. // // keyId: 'stuid',
  503. // // callback: function (_data) {
  504. // // callback(_data['stuname']);
  505. // // }
  506. // // });
  507. // // }
  508. // //},
  509. // { label: "位置", name: "Address", width: 100, align: "left" },
  510. // {
  511. // label: "校区", name: "Campus", width: 100, align: "left",
  512. // formatterAsync: function (callback, value, row, op, $cell) {
  513. // learun.clientdata.getAsync('custmerData', {
  514. // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'company',
  515. // key: value,
  516. // keyId: 'f_companyid',
  517. // callback: function (_data) {
  518. // callback(_data['f_fullname']);
  519. // }
  520. // });
  521. // }
  522. // },
  523. // //{
  524. // // label: "系", name: "Dept", width: 100, align: "left",
  525. // // formatterAsync: function (callback, value, row, op, $cell) {
  526. // // learun.clientdata.getAsync('custmerData', {
  527. // // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdDeptInfo',
  528. // // key: value,
  529. // // keyId: 'deptno',
  530. // // callback: function (_data) {
  531. // // callback(_data['deptname']);
  532. // // }
  533. // // });
  534. // // }
  535. // //},
  536. // //{
  537. // // label: "专业", name: "Major", width: 100, align: "left",
  538. // // formatterAsync: function (callback, value, row, op, $cell) {
  539. // // learun.clientdata.getAsync('custmerData', {
  540. // // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdMajorInfo',
  541. // // key: value,
  542. // // keyId: 'id',
  543. // // callback: function (_data) {
  544. // // callback(_data['majorname']);
  545. // // }
  546. // // });
  547. // // }
  548. // //},
  549. // //{ label: "班级", name: "Class", width: 100, align: "left" },
  550. // //{
  551. // // label: "性别", name: "Sex", width: 100, align: "left",
  552. // // formatterAsync: function (callback, value, row, op, $cell) {
  553. // // learun.clientdata.getAsync('dataItem', {
  554. // // key: value,
  555. // // code: 'usersex',
  556. // // callback: function (_data) {
  557. // // callback(_data.text);
  558. // // }
  559. // // });
  560. // // }
  561. // //},
  562. // { label: "负责人", name: "Functionary", width: 100, align: "left" },
  563. // { label: "负责人电话", name: "Phone", width: 100, align: "left" },
  564. // { label: "备注", name: "Remark", width: 100, align: "left" },
  565. // ],
  566. // mainId: 'ID',
  567. // isPage: true,
  568. // //isMultiselect: true
  569. // //sidx: 'ApartmentId asc,UnitId asc ,FloorId asc ',
  570. // //sord: 'ASC',
  571. // });
  572. //}
  573. },
  574. search: function (param) {
  575. param = param || {};
  576. param.SqlParameter = " AND t.BuildType ='4' ";
  577. $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  578. }
  579. };
  580. refreshGirdData = function () {
  581. //page.initTree();
  582. if (!!selectedParent.ID) {
  583. //var param = { ParentID: selectedParent.ID };
  584. //$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  585. page.initTree();
  586. page.search({ ParentID: selectedParent.ID });
  587. } else {
  588. page.initTree();
  589. page.search();
  590. }
  591. };
  592. page.init();
  593. }