123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627 |
- var mnu;
- var time;
- var isSave = false;
- var isSubmit = false;
- var isWindowCanClose = false;
- $.parser.onComplete = function () {
- var tableContainer = $("#dgScoreDetailList").find(".xDataTable").parent();
- var maxHeight = parseInt(tableContainer.css("maxHeight").replace("px", ""));
- tableContainer.css("maxHeight", maxHeight - $("#Comment").parent().outerHeight() - 20 + "px");
- };
- $(function () {
- mnu = $.SystemGeneral.getUrlParam("MNU");
- var Isdisplay = $.SystemGeneral.getUrlParam("Isdisplay");
- if (Isdisplay == "" || Isdisplay == null) {
- top.ScoreEditSetInterval = top.setInterval(setTimeout_Save, 1800000);
- }
- if (ApprovalStatus == 2 || ApprovalStatus == 4 || ApprovalStatus == 6) {
- isWindowCanClose = true;
- }
- $(document).keydown(function (e) {
- var keyEv = e || window.event;
- if (![37, 38, 39, 40].contains(keyEv.keyCode))
- return;
- var source = keyEv.srcElement || keyEv.target;
- if (!$(source).hasClass('validatebox-text'))
- return;
- if (!$(source).parent().attr('columnIndex'))
- return;
- if (!$(source).parent().parent().attr('xRowIndex'))
- return;
- var allRange = source.createTextRange();
- var columnIndex = parseInt($(source).parent().attr('columnIndex'));
- var rowIndex = parseInt($(source).parent().parent().attr('xRowIndex'));
- switch (keyEv.keyCode) {
- //Left Arrow
- case 37:
- if (document.selection.createRange().compareEndPoints('StartToStart', allRange) > 0) {
- return;
- }
- columnIndex--;
- break;
- //Up Arrow
- case 38:
- rowIndex--;
- break;
- //Right Arrow
- case 39:
- if (document.selection.createRange().compareEndPoints('EndToEnd', allRange) < 0) {
- return;
- }
- columnIndex++;
- break;
- //Dw Arrow
- case 40:
- rowIndex++;
- break;
- }
- var row = $("#dgScoreDetailList").find("[xRowIndex='" + rowIndex + "']");
- if (row.length > 0) {
- var column = row.find("[columnIndex='" + columnIndex + "']");
- if (column.length > 0) {
- var textbox = column.find('.validatebox-text');
- if (textbox.length > 0) {
- textbox.focus();
- }
- }
- }
- });
- });
- //获取选中的数据
- function validChoose() {
- var d = [];
- $.each($("#dgScoreDetailList").cmsXDataTable("getSelections"), function (index) {
- d.push(this);
- });
- return d;
- }
- function reload() {
- $("#dgScoreDetailList").cmsXDataTable("load", $.getDataGridParams("dgScoreDetailList"));
- }
- function getCustomScoreFormular(scoreTypes) {
- var result = new Array();
- var customScoreFormula = eval("(" + $("[name='CustomScoreFormula']").val() + ")");
- var scoreTypesCount = scoreTypes.length;
- //将各种组合先塞到result数组中
- $.each(scoreTypes, function (n, scoreType) {
- $.each($.grep(customScoreFormula, function (x) { return x.ScoreType == scoreType }), function (i, scoreFormula) {
- //找已有数组中有自己同伴的,复制出来把同伴换成自己,增加新数组
- var mateResultList = $.grep(result, function (x) { return $.grep(x.Detail, function (w) { return w.ScoreType == scoreFormula.ScoreType; }).length > 0 });
- $.each(mateResultList, function (m, mateResult) {
- var item = { total: 0, order: 1, Detail: $.grep(mateResult.Detail, function (x) { return x.ScoreType != scoreFormula.ScoreType; }) };
- item.Detail.push(scoreFormula);
- item.order = scoreTypesCount - item.Detail.length;
- $.each(item.Detail, function (v, x) { item.total += x.Percentage; });
- result.push(item);
- });
- //如果已有数组中没有同伴(一个新的ID出现,肯定是没有同伴的),则
- //遍历已有数组,把自己加进去
- //增加以自己为起点的数组
- if (mateResultList.length == 0) {
- $.each(result, function (i, x) {
- x.total += scoreFormula.Percentage;
- x.Detail.push(scoreFormula);
- x.order = scoreTypesCount - x.Detail.length;
- });
- var item = { total: scoreFormula.Percentage, order: scoreTypesCount - 1, Detail: [scoreFormula] };
- result.push(item);
- }
- });
- });
- //找出总和是100的组合并返回
- var correctResult = $.grep(result, function (x) { return x.total == 100 }).sort(function (a, b) { return a.order - b.order; });
- if (correctResult.length > 0) {
- return correctResult[0].Detail;
- } else {
- return new Array();
- }
- }
- function getResultType() {
- var ResultTypeDetail = new Array();
- var ResultType = eval("(" + $("[name='ResultType']").val() + ")");
- if (ResultType.length > 0) {
- ResultTypeDetail = $.map(ResultType, function (x) {
- return { Name: x.Name, MinScore: x.MinScore, MaxScore: x.MaxScore, MinScoreOperator: x.MinScoreOperator, MaxScoreOperator: x.MaxScoreOperator, Score: x.Score };
- });
- } else {
- ResultTypeDetail = null;
- }
- return ResultTypeDetail;
- }
- function getScoreFormulaDetail(scoreDetailList) {
- var scoreFormulaDetail = new Array();
- var scoreFormulaDropdownList = $("#ScoreFormulaID").combobox("getValue");
- var scoreFormula = eval("(" + scoreFormulaDropdownList + ")");
- //如果有自定义公式(广体那种),就拿自定义公式,否则就按选择的来
- var customScoreFormula = eval("(" + $("[name='CustomScoreFormula']").val() + ")");
- if (customScoreFormula.length > 0) {
- //获取有填写的分数类型
- var allScoreTypeList = $.map(customScoreFormula, function (x) { return x.ScoreType; }).unique();
- var notEmptyScoreTypes = new Array();
- $.each(scoreDetailList, function (i, scoreDetail) {
- $.each(allScoreTypeList, function (n, scoreType) {
- if (!(scoreDetail.ScoreDetail[scoreType].Score === "" || scoreDetail.ScoreDetail[scoreType].Score == null)) {
- if (!notEmptyScoreTypes.contains(scoreType)) {
- notEmptyScoreTypes.push(scoreType);
- }
- }
- });
- });
- //获取对应的总分公式
- scoreFormulaDetail = $.map(getCustomScoreFormular(notEmptyScoreTypes), function (x) {
- return { ScoreType: x.ScoreType, Percentage: x.Percentage, IsRequirePass: x.IsRequirePass, PassScore: x.PassScore };
- });
- } else {
- scoreFormulaDetail = $.map(scoreFormula.ScoreFormulaDetail, function (x) {
- return { ScoreType: x.ScoreType, Percentage: x.Percentage, IsRequirePass: x.IsRequirePass, PassScore: x.PassScore };
- });
- }
- return scoreFormulaDetail;
- }
- function getSpecialStateScore(examsStateID, originalScore) {
- var examStateSettingList = eval("(" + $("#ExamsStateSetting").val() + ")");
- var examStateSetting = $.grep(examStateSettingList, function (x) { return x.ExamsStateID == examsStateID }).shift();
- if (examStateSetting) {
- if (examStateSetting.Score) {
- return examStateSetting.Score;
- } else {
- return originalScore;
- }
- }
- return originalScore;
- }
- function Score_Calculate() {
- var creditFormulaDropdownList = $("#CreditFormulaID").combobox("getValue");
- var gradePointFormulaDropdownList = $("#GradePointFormulaID").combobox("getValue");
- var scoreDetailList = $("#dgScoreDetailList").cmsXDataTable("getRows");
- var creditFormula = eval("(" + creditFormulaDropdownList + ")");
- var gradePointFormula = eval("(" + gradePointFormulaDropdownList + ")");
- //根据目前填写情况获取总分公式
- var scoreFormulaDetail = getScoreFormulaDetail(scoreDetailList);
- var ResultType = new Array();
- var defeat = 0;
- ResultType = getResultType();
- // if (scoreFormulaDetail.length <= 0) {
- // return false;
- // }
- $.each(scoreDetailList, function (index, value) {
- //如果当前行不可编辑(重录时的非重录学生),跳过
- if (!value.RecordStatus) {
- return true;
- }
- //如果当前行不可编辑(成绩认定的学生),跳过
- if (!value.IsCanEdit) {
- return true;
- }
- if (value.RecordStatus <= unusableStatusID) {
- return true;
- }
- var examsStateID = null;
- if (value.ExamsStateID != null) {
- examsStateID = parseInt(value.ExamsStateID);
- }
- //如果考试状态不为正常考试,总分清零,跳过
- if (examsStateID == suspensionStateID || misconductStateIDList.contains(examsStateID)) {
- value.TotalScore = getSpecialStateScore(examsStateID, 0);
- value.Credit = 0;
- value.GradePoint = 0;
- return true;
- }
- //如果当前行是空行,则跳过
- if (examsStateID != exemptionStateID) {
- var isEmpty = true;
- for (var scoreType in value.ScoreDetail) {
- //判断空行时,单独管理的成绩不算填了值,因为不是用户填的
- if (scoreType == fixedScoreTypeID) {
- continue;
- }
- if (!(value.ScoreDetail[scoreType].Score === "" || value.ScoreDetail[scoreType].Score == null)) {
- isEmpty = false;
- }
- }
- if (isEmpty) {
- value.TotalScore = null;
- value.Credit = null;
- value.GradePoint = null;
- return true;
- }
- }
- //算总分
- var totalScore = 0;
- var needPassFailed = false;
- if (examsStateID == exemptionStateID) {
- value.TotalScore = getSpecialStateScore(examsStateID, 0);
- } else {
- if (scoreFormulaDetail.length > 0) {
- $.each(scoreFormulaDetail, function (i, x) {
- if (value.ScoreDetail[x.ScoreType]) {
- if (!(value.ScoreDetail[x.ScoreType].Score === "" || value.ScoreDetail[x.ScoreType].Score == null)) {
- totalScore += value.ScoreDetail[x.ScoreType].Score * x.Percentage / 100;
- if (x.IsRequirePass && x.PassScore != null) {
- if (value.ScoreDetail[x.ScoreType].Score < x.PassScore) {
- needPassFailed = true;
- }
- }
- } else if (x.IsRequirePass) {
- needPassFailed = true;
- }
- if (isSubmit && (value.ScoreDetail[x.ScoreType].Score === "" || value.ScoreDetail[x.ScoreType].Score == null)) {
- defeat++;
- return;
- }
- } else if (x.IsRequirePass) {
- needPassFailed = true;
- }
- });
- } else if (isSubmit) {
- defeat++;
- return;
- }
- if (needPassFailed) {
- totalScore = 0;
- value.TotalScore = 0;
- } else {
- //toFixed方法有问题,对小于1的数字计算不正确,所以运算前先加1确保没问题
- value.TotalScore = totalScore.toFixed(scoreDigitCount);
- }
- }
- //分制转化
- if (ResultType != null) {
- $.each(ResultType, function (i, x) {
- if (x.MinScore <= totalScore && totalScore <= x.MaxScore && x.MinScoreOperator == "<=" && x.MaxScoreOperator == "<=") {
- value.TotalScore = x.Score;
- }
- if (x.MinScore < totalScore && totalScore <= x.MaxScore && x.MinScoreOperator == "<" && x.MaxScoreOperator == "<=") {
- value.TotalScore = x.Score;
- }
- if (x.MinScore < totalScore && totalScore < x.MaxScore && x.MinScoreOperator == "<" && x.MaxScoreOperator == "<") {
- value.TotalScore = x.Score;
- }
- if (x.MinScore <= totalScore && totalScore < x.MaxScore && x.MinScoreOperator == "<=" && x.MaxScoreOperator == "<") {
- value.TotalScore = x.Score;
- }
- });
- }
- //算学分
- //免修是不需要计算,直接获得学分的
- if (examsStateID == exemptionStateID) {
- value.Credit = credit;
- } else {
- if (value.TotalScore >= creditFormula.Scores) {
- value.Credit = credit;
- }
- else {
- value.Credit = 0;
- }
- }
- //算绩点
- if (value.TotalScore >= gradePointFormula.GradePointlimit) {
- var gradePoint = 1;
- gradePoint += (value.TotalScore - gradePointFormula.GradePointlimit) * gradePointFormula.GradePointFloor;
- value.GradePoint = gradePoint.toFixed(1);
- }
- else {
- value.GradePoint = 0;
- }
- });
- if (defeat > 0 && isSubmit) {
- return false;
- }
- // if (defeat > 0 && !isSave && !isSubmit) {
- // $.messager.alert("系统提示", "录入信息不完整");
- // return;
- // }
- $("#dgScoreDetailList").cmsXDataTable("loadData", { rows: scoreDetailList, total: scoreDetailList.length });
- }
- //提交
- function Score_Submit() {
- var msg = "";
- var scoreDetailList = $("#dgScoreDetailList").cmsXDataTable("getRows");
- var scoreFormulaDetail = getScoreFormulaDetail(scoreDetailList);
- var requireScoreTypes = $.map(scoreFormulaDetail, function (x) { return x.ScoreType; });
- isSubmit = true;
- isSave = false;
- //Score_Calculate();
- var isOk = Score_Calculate();
- if (!isOk && isOk != null) {
- $.messager.alert("系统提示", "录入信息不完整。");
- return;
- } else {
- $.each(scoreDetailList, function (index, value) {
- if (value.ExamsStateID == null) {
- msg = "请选择考试状态!"
- return false;
- }
- });
- if (scoreDetailList.length == 0) {
- $.messager.alert("系统提示", "录入学生数不能为0");
- return
- }
- if (msg != "") {
- $.messager.alert("系统提示", msg);
- return;
- }
-
- $(document.forms[0]).attr("action", CMS_SystemConfig.VirtualDirectoryPath + '/Score/Submit');
- $(document.forms[0]).submit();
- isWindowCanClose = true;
- }
- }
- //保存
- function Score_Save() {
- isSubmit = false;
- isSave = true;
- commonSave();
- }
- function commonSave() {
- Score_Calculate(); //计算
- $(document.forms[0]).attr("action", CMS_SystemConfig.VirtualDirectoryPath + '/Score/ScoreSave');
- $(document.forms[0]).submit();
- isWindowCanClose = true;
- }
- //定时保存
- function setTimeout_Save() {
- isSubmit = false;
- isSave = false;
- commonSave();
- }
- //重置
- function Score_Resetting() {
- var scoreDetailList = $("#dgScoreDetailList").cmsXDataTable("getRows");
- $.each(scoreDetailList, function (index, value) {
- //如果当前行不可编辑(重录时的非重录学生),跳过
- if (!value.RecordStatus) {
- return true;
- }
- //如果当前行不可编辑(成绩认定的学生),跳过
- if (!value.IsCanEdit) {
- return true;
- }
- if (value.RecordStatus <= unusableStatusID) {
- return true;
- }
- $.each(value.ScoreDetail, function (i, score) {
- score.Score = null;
- });
- value.TotalScore = null;
- value.Credit = null;
- value.GradePoint = null;
- });
- $("#dgScoreDetailList").cmsXDataTable("loadData", { rows: scoreDetailList, total: scoreDetailList.length });
- }
- //成绩导入
- function Score_Import() {
- var finalExaminationID = $("#FinalExaminationID").val();
- var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + '/Score/Import?finalExaminationID=' + finalExaminationID + '&MNU=' + mnu;
- $.popupTopWindow('学生成绩导入', redirectTo, 400, 300, ScoreImportComplete);
- }
- function ScoreImportComplete(data) {
- if (data != null) {
- var scoreViewList = $("#dgScoreDetailList").cmsXDataTable("getRows");
- $.each(scoreViewList, function (i, x) {
- if (x.IsCanEdit == true) {
- var importedScore = $.grep(data, function (w) { return w.UserID == x.UserID }).pop();
- if (importedScore) {
- $.each(x.ScoreDetail, function (n, v) {
- if (v.IsCanEdit == true) {
- var score = importedScore.ScoreDetail[v.ScoreTypeID];
- v.Score = score;
- }
- });
- }
- }
- });
- $("#dgScoreDetailList").cmsXDataTable("loadData", { rows: scoreViewList, total: scoreViewList.length });
- Score_Calculate();
- }
- }
- function FormSuecess(data) {
- if (isSubmit) {
- EMISFunction.FormSuccess(data);
- } else if (isSave) {
- $.messager.alert("系统提示", data.Message);
- }
- }
- function FormSubmit(formID) {
- if (isSubmit || isSave) {
- EMISFunction.FormSubmit(formID);
- } else {
- $('a').attr('disabled', 'disabled');
- $.each($('a'), function () {
- if ($.data(this, "linkbutton")) {
- $(this).linkbutton('disable');
- }
- });
- $('#autoSave').show();
- }
- }
- function FormComplete() {
- if (isSubmit || isSave) {
- EMISFunction.FormComplete();
- } else {
- $.each($('a'), function () {
- if ($.data(this, "linkbutton")) {
- $(this).linkbutton('enable');
- }
- });
- $('a').removeAttr('disabled', 'disabled');
- $('#autoSave').hide();
- }
- }
- function formSuccessReloadNoClose(data) {
- if (data.IsSuccess == true) {
- if (data.Message == "提交成功。" || data.Message == "保存成功。") {
- $.messager.alert("系统提示", data.Message, null, function () {
- location.reload();
- });
- }
- }
- else {
- $.messager.alert("系统提示", data.Message);
- }
- }
- // if (data.IsSuccess == true) {
- // $.messager.alert("系统提示", data.Message);
- // location.reload();
- // //isWindowCanClose = true;
- // }
- // else {
- // $.messager.alert("系统提示", data.Message);
- // }
- function LoginIDColor(index, row, value) {
- if (row.IsDifferentDynamic == true) {
- return " <span style=\"color:red;\">" + value + "</span>";
- }
- else {
- return value
- }
- }
- function UserNameColor(index, row, value) {
- if (row.IsDifferentDynamic == true) {
- return " <span style=\"color:red;\">" + value + "</span>";
- }
- else {
- return value
- }
- }
- function ExamsCategoryNameColor(index, row, value) {
- if (row.IsDifferentDynamic == true) {
- return " <span style=\"color:red;\">" + value + "</span>";
- }
- else {
- return value
- }
- }
- function TotalScoreColor(index, row, value) {
- var ResultType = new Array();
- ResultType = getResultType();
- if (row.IsDifferentDynamic == true) {
- if (ResultType != null) {
- var valueName = "";
- $.each(ResultType, function (i, x) {
- if (value !== "" && value != null) {
- if (x.MinScore <= value && value <= x.MaxScore && x.MinScoreOperator == "<=" && x.MaxScoreOperator == "<=") {
- valueName = " <span style=\"color:red;\">" + x.Name + "</span>";
- }
- if (x.MinScore < value && value <= x.MaxScore && x.MinScoreOperator == "<" && x.MaxScoreOperator == "<=") {
- valueName = " <span style=\"color:red;\">" + x.Name + "</span>";
- }
- if (x.MinScore < value && value < x.MaxScore && x.MinScoreOperator == "<" && x.MaxScoreOperator == "<") {
- valueName = " <span style=\"color:red;\">" + x.Name + "</span>";
- }
- if (x.MinScore <= value && value < x.MaxScore && x.MinScoreOperator == "<=" && x.MaxScoreOperator == "<") {
- valueName = " <span style=\"color:red;\">" + x.Name + "</span>";
- }
- }
- });
- return valueName;
- }
- else {
- return " <span style=\"color:red;\">" + value + "</span>";
- }
- }
- else {
- if (ResultType != null) {
- var valueName = "";
- $.each(ResultType, function (i, x) {
- if (value !== "" && value != null) {
- if (x.MinScore <= value && value <= x.MaxScore && x.MinScoreOperator == "<=" && x.MaxScoreOperator == "<=") {
- valueName = x.Name;
- }
- if (x.MinScore < value && value <= x.MaxScore && x.MinScoreOperator == "<" && x.MaxScoreOperator == "<=") {
- valueName = x.Name;
- }
- if (x.MinScore < value && value < x.MaxScore && x.MinScoreOperator == "<" && x.MaxScoreOperator == "<") {
- valueName = x.Name;
- }
- if (x.MinScore <= value && value < x.MaxScore && x.MinScoreOperator == "<=" && x.MaxScoreOperator == "<") {
- valueName = x.Name;
- }
- }
- });
- return valueName;
- }
- else {
- return value;
- }
- }
- }
- function Score_Report() {
- var FinalExaminationID = $("#FinalExaminationID").val();
- var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/Score/Report?FinalExaminationID=" + FinalExaminationID + "&MNU=" + mnu;
- $.popupTopWindow('学生课程成绩报表', redirectTo, 800, 600, null, null);
- }
- function CreditColor(index, row, value) {
- if (row.IsDifferentDynamic == true) {
- return " <span style=\"color:red;\">" + value + "</span>";
- }
- else {
- return value
- }
- }
- function GradePointColor(index, row, value) {
- if (row.IsDifferentDynamic == true) {
- return " <span style=\"color:red;\">" + value + "</span>";
- }
- else {
- return value
- }
- }
- function Score_SetScoreBySOCScore() {
- var FinalExaminationID = $("#FinalExaminationID").val();
- var scoreDetailList = $("#dgScoreDetailList").cmsXDataTable("getRows");
- $.messager.confirm("系统提示", "同步SOC成绩后将覆盖当前已录的考试成绩,是否需要同步?", function (r) {
- if (r) {
- $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/Score/SetScoreBySOCScore', { finalExaminationID: FinalExaminationID }, function (res) {
- $.messager.alert("系统提示", res.Message);
- if (res.IsSuccess) {
- if (res.Data.length > 0) {
- for (var i = 0; i < res.Data.length; i++) {
- $.each(scoreDetailList, function (index, value) {
- if (res.Data[i].UserID == value.UserID) {
- $.each(value.ScoreDetail, function (ind, score) {
- if (ind == 3) {
- score.Score = res.Data[i].TotalScore;
- }
- });
- //value.Score = res.Data[i].TotalScore;
- }
- });
- }
- $("#dgScoreDetailList").cmsXDataTable("loadData", { rows: scoreDetailList, total: scoreDetailList.length });
- }
- }
- });
- }
- });
- }
|