Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

639 рядки
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: 800,
  292. height: 600,
  293. callBack: function (id) {
  294. return top[id].acceptClick(refreshGirdData);
  295. }
  296. });
  297. });
  298. //清空
  299. $("#lr_Clear").on("click", function () {
  300. learun.layerForm({
  301. id: 'form',
  302. title: '按年级清空',
  303. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/ClearForm',
  304. width: 400,
  305. height: 300,
  306. callBack: function (id) {
  307. return top[id].acceptClick();
  308. }
  309. });
  310. });
  311. },
  312. //初始化左侧树
  313. initTree: function () {
  314. // 初始化左侧树形数据
  315. $('#dataTree').lrtree({
  316. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetTree',
  317. nodeClick: function (item) {
  318. selectedParent.ID = item.value;
  319. selectedParent.Name = item.text;
  320. selectedParent.BuildType = item.title;
  321. if (item.parent) {
  322. if (!item.parent.parentId) {
  323. selectedParent.ChildType = "2";
  324. } else {
  325. selectedParent.ChildType = "0";
  326. }
  327. }
  328. else {
  329. selectedParent.ChildType = "1";
  330. }
  331. if (item.text.indexOf("室") > -1) {
  332. selectedParent.ChildType = "5";
  333. }
  334. var param = {};
  335. if (item.title == '1')
  336. param.ApartmentId = item.value;
  337. else if (item.title == '2')
  338. param.UnitId = item.value;
  339. else if (item.title == '3')
  340. param.FloorId = item.value;
  341. //page.initGird();
  342. //page.search({ ParentID: item.value });
  343. page.search(param);
  344. }
  345. });
  346. },
  347. // 初始化列表
  348. initGird: function () {
  349. //宿舍数据
  350. $('#gridtable').jfGrid({
  351. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetPageList',
  352. headData: [
  353. { label: "名称", name: "Name", width: 100, align: "left" },
  354. {
  355. label: "宿舍楼", name: "ApartmentName", width: 100, align: "left"
  356. },
  357. {
  358. label: "单元", name: "UnitName", width: 100, align: "left"
  359. },
  360. {
  361. label: "楼层", name: "FloorName", width: 100, align: "left"
  362. },
  363. //{
  364. // label: "学生", name: "StudentID", width: 100, align: "left",
  365. // formatterAsync: function (callback, value, row, op, $cell) {
  366. // learun.clientdata.getAsync('custmerData', {
  367. // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'StuInfoBasic',
  368. // key: value,
  369. // keyId: 'stuid',
  370. // callback: function (_data) {
  371. // callback(_data['stuname']);
  372. // }
  373. // });
  374. // }
  375. //},
  376. { label: "位置", name: "Address", width: 100, align: "left" },
  377. {
  378. label: "校区", name: "Campus", width: 100, align: "left",
  379. formatterAsync: function (callback, value, row, op, $cell) {
  380. learun.clientdata.getAsync('custmerData', {
  381. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'company',
  382. key: value,
  383. keyId: 'f_companyid',
  384. callback: function (_data) {
  385. callback(_data['f_fullname']);
  386. }
  387. });
  388. }
  389. },
  390. {
  391. label: "系", name: "Dept", width: 100, align: "left",
  392. formatterAsync: function (callback, value, row, op, $cell) {
  393. learun.clientdata.getAsync('custmerData', {
  394. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdDeptInfo',
  395. key: value,
  396. keyId: 'deptno',
  397. callback: function (_data) {
  398. callback(_data['deptname']);
  399. }
  400. });
  401. }
  402. },
  403. {
  404. label: "专业", name: "Major", width: 100, align: "left",
  405. formatterAsync: function (callback, value, row, op, $cell) {
  406. learun.clientdata.getAsync('custmerData', {
  407. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdMajorInfo',
  408. key: value,
  409. keyId: 'majorno',
  410. callback: function (_data) {
  411. callback(_data['majorname']);
  412. }
  413. });
  414. }
  415. },
  416. {
  417. label: "班级", name: "Class", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) {
  418. learun.clientdata.getAsync('custmerData', {
  419. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'bjsj',
  420. key: value,
  421. keyId: 'classno',
  422. callback: function (_data) {
  423. callback(_data['classname']);
  424. }
  425. });
  426. }
  427. },
  428. {
  429. label: "寝室类型", name: "RoomType", width: 100, align: "left",
  430. formatter: function (value, row) {
  431. if (value) {
  432. return value + '人寝';
  433. } else {
  434. return '';
  435. }
  436. }
  437. },
  438. { label: "入住人数", name: "CheckInStu", width: 100, align: "left" },
  439. {
  440. label: "性别", name: "Sex", width: 100, align: "left",
  441. formatter: function (value, row) {
  442. if (value == '0')
  443. return '女';
  444. else if (value == '1')
  445. return '男';
  446. else
  447. return '';
  448. }
  449. },
  450. { label: "负责人", name: "Functionary", width: 100, align: "left" },
  451. { label: "负责人电话", name: "Phone", width: 100, align: "left" },
  452. { label: "备注", name: "Remark", width: 100, align: "left" },
  453. ],
  454. mainId: 'ID',
  455. isPage: true,
  456. isMultiselect: true,
  457. sidx: 'CheckInStu asc,ApartmentId asc,UnitId asc ,FloorId asc ',
  458. //sord: 'ASC',
  459. isSubGrid: true, // 是否有子表
  460. subGridExpanded: function (subContentId, rowItem) {
  461. $('#' + subContentId).jfGrid({
  462. url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetBedListByRoomId?RoomId=' + rowItem.ID,
  463. headData: [
  464. { label: "名称", name: "Name", width: 100, align: "left" },
  465. { label: "学号", name: "StudentID", width: 150, align: "left" },
  466. {
  467. label: "学生姓名", name: "StudentName", width: 150, align: "left",
  468. formatterAsync: function (callback, value, row, op, $cell) {
  469. learun.clientdata.getAsync('custmerData', {
  470. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'StuInfoBasicAll',
  471. key: row.StudentID,
  472. keyId: 'stuno',
  473. callback: function (_data) {
  474. callback(_data['stuname']);
  475. }
  476. });
  477. }
  478. },
  479. ],
  480. mainId: 'ID',
  481. isPage: false,
  482. //sidx: 'DNo',
  483. //sord: 'ASC',
  484. });
  485. //var param;
  486. //param = param || {};
  487. //param.ParentID = rowItem.Id;
  488. $('#' + subContentId).jfGridSet('reload');
  489. },
  490. subGridHeight: 250,
  491. });
  492. //$("#gridtable").empty();
  493. //$("#gridtable")[0].dfop = undefined;
  494. //if (selectedParent.BuildType == undefined || selectedParent.BuildType === "3") {
  495. //} else {
  496. // //lrAuthorizeJfGridLei
  497. // $('#gridtable').jfGrid({
  498. // url: top.$.rootUrl + '/LogisticsManagement/Accommodation/GetPageList',
  499. // headData: [
  500. // { label: "名称", name: "Name", width: 100, align: "left" },
  501. // {
  502. // label: "宿舍楼", name: "ApartmentName", width: 100, align: "left"
  503. // },
  504. // {
  505. // label: "单元", name: "UnitName", width: 100, align: "left"
  506. // },
  507. // {
  508. // label: "楼层", name: "FloorName", width: 100, align: "left"
  509. // },
  510. // //{
  511. // // label: "学生", name: "StudentID", width: 100, align: "left",
  512. // // formatterAsync: function (callback, value, row, op, $cell) {
  513. // // learun.clientdata.getAsync('custmerData', {
  514. // // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'StuInfoBasic',
  515. // // key: value,
  516. // // keyId: 'stuid',
  517. // // callback: function (_data) {
  518. // // callback(_data['stuname']);
  519. // // }
  520. // // });
  521. // // }
  522. // //},
  523. // { label: "位置", name: "Address", width: 100, align: "left" },
  524. // {
  525. // label: "校区", name: "Campus", width: 100, align: "left",
  526. // formatterAsync: function (callback, value, row, op, $cell) {
  527. // learun.clientdata.getAsync('custmerData', {
  528. // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'company',
  529. // key: value,
  530. // keyId: 'f_companyid',
  531. // callback: function (_data) {
  532. // callback(_data['f_fullname']);
  533. // }
  534. // });
  535. // }
  536. // },
  537. // //{
  538. // // label: "系", name: "Dept", width: 100, align: "left",
  539. // // formatterAsync: function (callback, value, row, op, $cell) {
  540. // // learun.clientdata.getAsync('custmerData', {
  541. // // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdDeptInfo',
  542. // // key: value,
  543. // // keyId: 'deptno',
  544. // // callback: function (_data) {
  545. // // callback(_data['deptname']);
  546. // // }
  547. // // });
  548. // // }
  549. // //},
  550. // //{
  551. // // label: "专业", name: "Major", width: 100, align: "left",
  552. // // formatterAsync: function (callback, value, row, op, $cell) {
  553. // // learun.clientdata.getAsync('custmerData', {
  554. // // url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdMajorInfo',
  555. // // key: value,
  556. // // keyId: 'id',
  557. // // callback: function (_data) {
  558. // // callback(_data['majorname']);
  559. // // }
  560. // // });
  561. // // }
  562. // //},
  563. // //{ label: "班级", name: "Class", width: 100, align: "left" },
  564. // //{
  565. // // label: "性别", name: "Sex", width: 100, align: "left",
  566. // // formatterAsync: function (callback, value, row, op, $cell) {
  567. // // learun.clientdata.getAsync('dataItem', {
  568. // // key: value,
  569. // // code: 'usersex',
  570. // // callback: function (_data) {
  571. // // callback(_data.text);
  572. // // }
  573. // // });
  574. // // }
  575. // //},
  576. // { label: "负责人", name: "Functionary", width: 100, align: "left" },
  577. // { label: "负责人电话", name: "Phone", width: 100, align: "left" },
  578. // { label: "备注", name: "Remark", width: 100, align: "left" },
  579. // ],
  580. // mainId: 'ID',
  581. // isPage: true,
  582. // //isMultiselect: true
  583. // //sidx: 'ApartmentId asc,UnitId asc ,FloorId asc ',
  584. // //sord: 'ASC',
  585. // });
  586. //}
  587. },
  588. search: function (param) {
  589. param = param || {};
  590. param.SqlParameter = " AND t.BuildType ='4' ";
  591. $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  592. }
  593. };
  594. refreshGirdData = function () {
  595. //page.initTree();
  596. if (!!selectedParent.ID) {
  597. //var param = { ParentID: selectedParent.ID };
  598. //$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  599. page.initTree();
  600. page.search({ ParentID: selectedParent.ID });
  601. } else {
  602. page.initTree();
  603. page.search();
  604. }
  605. };
  606. page.init();
  607. }