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.
 
 
 
 
 
 

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