|
- /* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn)
- * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
- * 创建人:超级管理员
- * 日 期:2021-10-14 10:09
- * 描 述:教学计划
- */
- var acceptClick;
- var keyValue = request('keyValue');
- // 设置表单数据
- var setFormData;
- // 验证数据是否填写完整
- var validForm;
- // 保存数据
- var save;
- var refreshGirdData;
- var selectedRow;
- var tempdatra = new Array();
- var bootstrap = function ($, learun) {
- "use strict";
- var page = {
- init: function () {
- $('.lr-form-wrap').lrscroll();
- $("#detailedit").on('click', function () {
- var keyValue = $('#TeachingPlanItem').jfGridValue('Id');
- selectedRow = $('#TeachingPlanItem').jfGridGet('rowdata');
- if (learun.checkrow(keyValue)) {
- learun.layerForm({
- id: 'form_TeachingPlanItem',
- title: '编辑明细',
- url: top.$.rootUrl + '/EducationalAdministration/TeachingPlanItem/Form?keyValue=' + keyValue,
- width: 650,
- height: 430,
- callBack: function (id) {
- return top[id].acceptClick(refreshGirdData);
- }
- });
- }
- });
- page.bind();
- page.initData();
- },
- bind: function () {
- //年级
- $('#Grade').lrselect({
- url: top.$.rootUrl + '/EducationalAdministration/ClassInfo/GenerateNearByYear',
- value: 'value',
- text: 'text',
- maxHeight: 200
- });
-
- $('#Dept').lrDataSourceSelect({ code: 'CdDeptInfo', value: 'deptno', text: 'deptname' });
- $('#Major').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorno', text: 'majorname' });
- $('#Enabled').lrRadioCheckbox({
- type: 'radio',
- code: 'YesOrNoBit',
- });
- $('#TeachingPlanItem').jfGrid({
- headData: [
- {
- label: '课程名称', name: 'LessonNo', width: 100, align: 'left',
- formatterAsync: function (callback, value, row, op, $cell) {
- learun.clientdata.getAsync('custmerData', {
- url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'LessonInfo',
- key: value,
- keyId: 'lessonno',
- callback: function (_data) {
- callback(_data['lessonname']);
- }
- });
- }
- },
- {
- label: '课程学时', name: 'LessonTime', width: 100, align: 'left'
- },
- {
- label: '执行学期', name: 'Semester', width: 100, align: 'left'
- },
- {
- label: '周节次', name: 'WeeklyFestival', width: 100, align: 'left'
- },
- {
- label: '开课起始周', name: 'WeeklyStart', width: 150, align: 'left'
- },
- {
- label: '开课结束周', name: 'WeeklyEnd', width: 150, align: 'left'
- },
- ],
- height: 270,
- mainId: 'Id'
- });
- },
- initData: function () {
- if (!!keyValue) {
- $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlan/GetFormData?keyValue=' + keyValue, function (data) {
- for (var id in data) {
- if (!!data[id].length && data[id].length > 0) {
- $('#' + id).jfGridSet('refreshdata', data[id]);
- tempdatra = data[id];
- }
- else {
- $('[data-table="' + id + '"]').lrSetFormData(data[id]);
- }
- }
- });
- }
- }
- };
- refreshGirdData = function (temprow) {
-
- var ifnewrow = true;
- $.each(tempdatra, function (key, val) {
- if (tempdatra[key].Id === temprow.Id) {
- tempdatra[key] = temprow;
- ifnewrow = false;
- }
- });
- if (ifnewrow) {
- tempdatra.push(temprow);
- }
- $('#TeachingPlanItem').jfGridSet('refreshdata', tempdatra);
-
- };
-
- // 验证数据是否填写完整
- validForm = function () {
- if (!$('.lr-form-wrap').lrValidform()) {
- return false;
- }
- //var datas = $('#TeachingPlanItem').jfGridGet('rowdatas');
- //if (datas == null || datas.length == 0) {
- // learun.alert.warning("申请未包含明细!请先新增明细!");
- // return false;
- //}
- return true;
- };
- //// 保存数据
- //acceptClick = function (callBack) {
- // if (!$('body').lrValidform()) {
- // return false;
- // }
- // var postData = {
- // strEntity: JSON.stringify($('body').lrGetFormData())
- // };
- // $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlan/SaveForm?keyValue=' + keyValue, postData, function (res) {
- // // 保存成功后才回调
- // if (!!callBack) {
- // callBack();
- // }
- // });
- //};
- // 保存数据
- save = function (callBack, i) {
- var postData = {};
- var formData = $('[data-table="TeachingPlan"]').lrGetFormData();
-
- postData.strEntity = JSON.stringify(formData);
- postData.TeachingPlanItemList = JSON.stringify($('#TeachingPlanItem').jfGridGet('rowdatas'));
- $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TeachingPlan/SaveForm?keyValue=' + keyValue, postData, function (res) {
- // 保存成功后才回调
- if (!!callBack) {
- callBack(res, formData, i);
- }
- });
- };
- page.init();
- }
|