|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- /* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
- * Copyright (c) 2013-2018 北京泉江科技有限公司
- * 创建人:超级管理员
- * 日 期:2019-04-26 15:02
- * 描 述:学生宿舍管理
- */
- var acceptClick;
- var Class = request('Class');
- var keyValue = request('keyValue');
- var Sex = request('Sex');
- var arr = [];
- var bootstrap = function ($, learun) {
- "use strict";
- var page = {
- init: function () {
- $('.lr-form-wrap').lrscroll();
- page.bind();
- page.initData();
- },
- bind: function () {
-
- },
- initData: function () {
- if (!!keyValue) {
- $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetBedListByRoomId?RoomId=' + keyValue, function (data) {
- $('#content').html('');
- var strWhere = " ClassNo='" + Class + "'";
- if (Sex == '0') {
- strWhere += " and GenderNo=0";
- }
- else if (Sex == '1') {
- strWhere += " and GenderNo=1";
- }
- for (var i = 0; i < data.length; i++) {
- var html = '';
- html += '<div class="col-xs-12 lr-form-item div12">';
- html += '<div class="col-xs-6 lr-form-item">';
- html += '<div class="lr-form-item-title">床位</div>';
- html += '<input id="Name" readonly="readonly" type="text" class="form-control" value="' +
- data[i].Name +
- '" />';
- html += '</div>';
- html += '<div class="col-xs-6 lr-form-item" style="padding-right: 20px;">';
- html += '<div class="lr-form-item-title">学生</div>';
- html += '<div class="Student" id="' + data[i].ID + '"></div>';
- html += '</div>';
- html += '</div>';
- $('#content').append(html);
-
- $('#' + data[i].ID).lrselect({
- value: "stuno",
- text: "stuname",
- url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable',
- param: { code: "StuInfoBasic", strWhere: strWhere },
- // 是否允许搜索
- allowSearch: true,
- select: function (item) {
- // console.log(item);
- var stuid = '';
- if (item) {
- stuid = item.stuno;
-
- }
- var id = $(this).attr('id');
- //console.log('id', id);
- //console.log('item',item);
- arr.forEach(item => {
- if (item.ID == id) {
- //如果存在删除
- removeByValue(arr, 'ID', id);
-
- }
- });
- arr.push({ ID: id, StudentID: stuid });
- }
- });
- $('#' + data[i].ID).lrselectSet(data[i].StudentID);
-
- //arr.push({ ID: data[i].ID, StudentID: data[i].StudentID });
- }
-
-
-
- });
- }
- },
- };
- // 保存数据
- acceptClick = function (callBack) {
- //if (!$('body').lrValidform()) {
- // return false;
- //}
- //var postData = {
- // strEntity: JSON.stringify($('body').lrGetFormData())
- //};
- //console.log('arr', arr);
- for (var i = 0; i < arr.length - 1; i++) {
- for (var j = i + 1; j < arr.length; j++) {
- if (!!arr[i].StudentID && arr[i].StudentID === arr[j].StudentID) {
- return learun.alert.warning('学生不可重复!');
- }
- }
- }
- var postData = {
- list: arr
- };
-
- $.lrSaveForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/SaveRoom?RoomId=' + keyValue, postData, function (res) {
- // 保存成功后才回调
- if (!!callBack) {
- callBack();
- }
- });
- };
- page.init();
- //删除数组元素
- function removeByValue(arr, attr, value) {
- var index = 0;
- for (var i in arr) {
- if (arr[i][attr] == value) {
- index = i;
- break;
- }
- }
- arr.splice(index, 1);
- }
-
- }
|