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.
 
 
 
 
 
 

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