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.

Index.js 26 KiB

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