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.
 
 
 
 
 
 

129 lines
4.8 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 acceptClick;
  8. var Class = request('Class');
  9. var keyValue = request('keyValue');
  10. var Sex = request('Sex');
  11. var arr = [];
  12. var bootstrap = function ($, learun) {
  13. "use strict";
  14. var page = {
  15. init: function () {
  16. $('.lr-form-wrap').lrscroll();
  17. page.bind();
  18. page.initData();
  19. },
  20. bind: function () {
  21. },
  22. initData: function () {
  23. if (!!keyValue) {
  24. $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetBedListByRoomId?RoomId=' + keyValue, function (data) {
  25. $('#content').html('');
  26. var strWhere = " ClassNo='" + Class + "'";
  27. if (Sex == '0') {
  28. strWhere += " and GenderNo=0";
  29. }
  30. else if (Sex == '1') {
  31. strWhere += " and GenderNo=1";
  32. }
  33. for (var i = 0; i < data.length; i++) {
  34. var html = '';
  35. html += '<div class="col-xs-12 lr-form-item div12">';
  36. html += '<div class="col-xs-6 lr-form-item">';
  37. html += '<div class="lr-form-item-title">床位</div>';
  38. html += '<input id="Name" readonly="readonly" type="text" class="form-control" value="' +
  39. data[i].Name +
  40. '" />';
  41. html += '</div>';
  42. html += '<div class="col-xs-6 lr-form-item" style="padding-right: 20px;">';
  43. html += '<div class="lr-form-item-title">学生</div>';
  44. html += '<div class="Student" id="' + data[i].ID + '"></div>';
  45. html += '</div>';
  46. html += '</div>';
  47. $('#content').append(html);
  48. $('#' + data[i].ID).lrselect({
  49. value: "stuno",
  50. text: "stuname",
  51. url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable',
  52. param: { code: "StuInfoBasic", strWhere: strWhere },
  53. // 是否允许搜索
  54. allowSearch: true,
  55. select: function (item) {
  56. // console.log(item);
  57. var stuid = '';
  58. if (item) {
  59. stuid = item.stuno;
  60. }
  61. var id = $(this).attr('id');
  62. //console.log('id', id);
  63. //console.log('item',item);
  64. arr.forEach(item => {
  65. if (item.ID == id) {
  66. //如果存在删除
  67. removeByValue(arr, 'ID', id);
  68. }
  69. });
  70. arr.push({ ID: id, StudentID: stuid });
  71. }
  72. });
  73. $('#' + data[i].ID).lrselectSet(data[i].StudentID);
  74. //arr.push({ ID: data[i].ID, StudentID: data[i].StudentID });
  75. }
  76. });
  77. }
  78. },
  79. };
  80. // 保存数据
  81. acceptClick = function (callBack) {
  82. //if (!$('body').lrValidform()) {
  83. // return false;
  84. //}
  85. //var postData = {
  86. // strEntity: JSON.stringify($('body').lrGetFormData())
  87. //};
  88. //console.log('arr', arr);
  89. for (var i = 0; i < arr.length - 1; i++) {
  90. for (var j = i + 1; j < arr.length; j++) {
  91. if (!!arr[i].StudentID && arr[i].StudentID === arr[j].StudentID) {
  92. return learun.alert.warning('学生不可重复!');
  93. }
  94. }
  95. }
  96. var postData = {
  97. list: arr
  98. };
  99. $.lrSaveForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/SaveRoom?RoomId=' + keyValue, postData, function (res) {
  100. // 保存成功后才回调
  101. if (!!callBack) {
  102. callBack();
  103. }
  104. });
  105. };
  106. page.init();
  107. //删除数组元素
  108. function removeByValue(arr, attr, value) {
  109. var index = 0;
  110. for (var i in arr) {
  111. if (arr[i][attr] == value) {
  112. index = i;
  113. break;
  114. }
  115. }
  116. arr.splice(index, 1);
  117. }
  118. }