|
- /* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn)
- * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
- * 创建人:超级管理员
- * 日 期:2022-02-18 14:27
- * 描 述:教材订单管理
- */
- var acceptClick;
- var keyValue = request('keyValue');
- // 设置权限
- var setAuthorize;
- // 设置表单数据
- var setFormData;
- // 验证数据是否填写完整
- var validForm;
- // 保存数据
- var save;
- var selectedRow;
- var refreshGirdData;
- var tempdatra = new Array();
- var order = 0;
-
- var bootstrap = function ($, learun) {
- "use strict";
- // 设置权限
- setAuthorize = function (data) {
- };
- var page = {
- init: function () {
- $('.lr-form-wrap').lrscroll();
- $("#detailadd").on('click', function () {
- selectedRow = null;
- learun.layerForm({
- id: 'formTextBookIndentDetail',
- title: '新增明细',
- url: top.$.rootUrl + '/EducationalAdministration/TextBookIndent/FormDetail',
- width: 600,
- height: 350,
- callBack: function (id) {
- return top[id].acceptClick(refreshGirdData);
- }
- });
- });
- $("#detailedit").on('click', function () {
- var keyValue = $('#TextBookIndentDetail').jfGridValue('ID');
- selectedRow = $('#TextBookIndentDetail').jfGridGet('rowdata');
- if (learun.checkrow(keyValue)) {
- learun.layerForm({
- id: 'formTextBookIndentDetail',
- title: '编辑明细',
- url: top.$.rootUrl + '/EducationalAdministration/TextBookIndent/FormDetail?keyValue=' + keyValue,
- width: 600,
- height: 350,
- callBack: function (id) {
- return top[id].acceptClick(refreshGirdData);
- }
- });
- }
- });
- $("#detaildel").on('click', function () {
- var keyValue = $('#TextBookIndentDetail').jfGridValue('ID');
- if (learun.checkrow(keyValue)) {
- learun.layerConfirm('是否确认删除该项!', function (res, index) {
- if (res) {
- order = 0;
- $.each(tempdatra, function (key, val) {
- if (tempdatra[key].ID === keyValue) {
- // order -= tempdatra[key].TeachSum + tempdatra[key].StuSum;
- tempdatra.splice(key, 1);
- } else {
- order += (parseInt(tempdatra[key].TeachSum) + parseInt(tempdatra[key].StuSum));
- }
- });
- $("#OrderNum").val(order);
- $('#TextBookIndentDetail').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
- top.layer.close(index);
- }
- });
- }
- });
- page.bind();
- page.initData();
- },
- bind: function () {
- $('#DeptNo').lrDataSourceSelect({ code: 'CdDeptInfo', value: 'deptno', text: 'deptname' });
- $('#MajorNo').lrDataSourceSelect({ code: 'CdMajorInfo', value: 'majorname', text: 'majorname' });
- $('#LessonNo').lrDataSourceSelect({ code: 'LessonInfo', value: 'lessonno', text: 'lessonname' });
- $('#AcademicYearNo').lrselect({
- placeholder: "请选择学年",
- allowSearch: true,
- url: top.$.rootUrl + '/EducationalAdministration/TextBookIndent/GetAcademicYear',
- value: 'value',
- text: 'text'
- });
- //学期
- $('#Semester').lrselect({
- placeholder: "请选择学期",
- allowSearch: true,
- url: top.$.rootUrl + '/EducationalAdministration/EADateArrange/GetSemester',
- value: 'value',
- text: 'text'
- });
- $('#TextBookIndentDetail').jfGrid({
- headData: [
- {
- label: "班级", name: "ClassNo", width: 100, align: "left",
- formatterAsync: function (callback, value, row, op, $cell) {
- learun.clientdata.getAsync('custmerData', {
- url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'bjsj',
- key: value,
- keyId: 'classno',
- callback: function (_data) {
- callback(_data['classname']);
- }
- });
- }
- },
- { label: '教师人数', name: 'TeachSum', width: 80, align: 'left' },
- { label: '学生人数', name: 'StuSum', width: 80, align: 'left' },
- { label: '备注', name: 'Remark', width: 100, align: 'left' },
- ],
- height: 400,
- mainId: 'ID,IndentID',
- reloadSelected: false,
- });
- $('#TextBookName').lrGirdSelect({
- url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=TextBookInfo',
- param: { strWhere: " IsDel = '0' and IsValid ='true' " },
- height: 800,
- width: 1100,
- selectWord: 'textbookname',
- value: 'textbookname',
- text: 'textbookname',
- headData:
- [
- { label: "教材号", name: "publishno", width: 150, align: "left" },
- { label: "教材名称", name: "textbookname", width: 150, align: "left" },
- { label: "作者", name: "firstauthor", width: 150, align: "left" },
- { label: "其他作者", name: "otherauthor", width: 100, align: "left" },
- { label: "出版社", name: "publisher", width: 100, align: "left" },
- {
- label: "教材类型", name: "textbooktype", width: 100, align: "left",
- formatterAsync: function (callback, value, row, op, $cell) {
- learun.clientdata.getAsync('dataItem', {
- key: value,
- code: 'TextBookType',
- callback: function (_data) {
- callback(_data.text);
- }
- });
- }
- },
- {
- label: "教材性质", name: "textbooknature", width: 100, align: "left",
- formatterAsync: function (callback, value, row, op, $cell) {
- learun.clientdata.getAsync('dataItem', {
- key: value,
- code: 'TextBookNature',
- callback: function (_data) {
- callback(_data.text);
- }
- });
- }
- },
- { label: "价格", name: "price", width: 50, align: "left" },
- { label: "版次", name: "edition", width: 100, align: "left" },
- { label: "印次", name: "impression", width: 100, align: "left" },
- ],
- select: function (item) {
- ////赋值
- $("#Price").val(item.price);
- $("#PublishNo").val(item.publishno);
- $("#FirstAuthor").val(item.firstauthor);
- $("#TextBookName").val(item.textbookname);
- $("#OtherAuthor").val(item.otherauthor);
- $("#Publisher").val(item.publisher);
- $("#Edition").val(item.edition);
- }
- });
- $('#Status').val(0);
- $('#CreateTime').val(learun.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss'));
- $('#CreateUserID')[0].lrvalue = learun.clientdata.get(['userinfo']).userId;
- $('#CreateUserID').val(learun.clientdata.get(['userinfo']).realName);
- },
- initData: function () {
- if (!!keyValue) {
- $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookIndent/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]);
- //if (data[id].AAPrice) {
- // pricecount = data[id].AAPrice;
- //}
- }
- }
- });
- }
- }
- };
- 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);
- }
- //订购数量
- order = 0;
- for (var i = 0; i < tempdatra.length; i++) {
- order += (parseInt(tempdatra[i].TeachSum) + parseInt(tempdatra[i].StuSum));
- }
- $("#OrderNum").val(order);
-
- $('#TextBookIndentDetail').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
- };
- function sortNumber(a, b) {
- return a.StuSum - b.StuSum;
- }
- // 设置表单数据
- setFormData = function (processId, param, callback) {
- if (!!processId) {
- $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookIndent/GetFormDataByProcessId?processId=' + processId, function (data) {
- for (var id in data) {
- if (!!data[id] && data[id].length > 0) {
- $('#' + id).jfGridSet('refreshdata', data[id]);
- }
- else {
- if (id == 'TextBookIndent' && data[id]) {
- keyValue = data[id].ID;
- }
- $('[data-table="' + id + '"]').lrSetFormData(data[id]);
- }
- }
- });
- }
- }
- // 验证数据是否填写完整
- validForm = function () {
- if (!$('.lr-form-wrap').lrValidform()) {
- return false;
- }
- var datas = $('#TextBookIndentDetail').jfGridGet('rowdatas');
- if (datas == null || datas.length == 0) {
- learun.alert.warning("申请未包含明细!请先新增明细!");
- return false;
- }
- return true;
- };
- // 保存数据
- save = function (processId, callBack, i) {
- var postData = {};
- var formData = $('[data-table="TextBookIndent"]').lrGetFormData();
- if (!!processId) {
- formData.processId = processId;
- }
- postData.strEntity = JSON.stringify(formData);
- postData.strTextBookIndentDetailList = JSON.stringify($('#TextBookIndentDetail').jfGridGet('rowdatas'));
- $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TextBookIndent/SaveForm?keyValue=' + keyValue, postData, function (res) {
- // 保存成功后才回调
- if (!!callBack) {
- callBack(res, formData, i);
- }
- });
- };
- page.init();
- }
|