1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- function reload() {
- $("#dgScoreFormulaDetailList").cmsXDataTable("load", $.getDataGridParams("dgScoreFormulaDetailList"));
- }
- //获取选中的数据
- function validChoose() {
- var d = [];
- $.each($("#dgScoreFormulaDetailList").cmsXDataTable("getSelections"), function (index) {
- d.push(this);
- });
- return d;
- }
- //添加
- function ScoreFormula_SettingsAdd() {
- var scoreFormulaDetailList = $("#dgScoreFormulaDetailList").cmsXDataTable("getRows");
- var scoreFormulaDetailID = Guid.NewGuid().ToString();
- scoreFormulaDetailList.push({
- ScoreFormulaDetailID: scoreFormulaDetailID,
- ScoreType: 1,
- Percentage: 0,
- IsRequirePass: false
- });
- $("#dgScoreFormulaDetailList").cmsXDataTable("loadData", { rows: scoreFormulaDetailList, total: scoreFormulaDetailList.length });
- }
- //删除
- function ScoreFormula_SettingsDelete() {
- var d = validChoose();
- var scoreFormulaDetailList = $("#dgScoreFormulaDetailList").cmsXDataTable("getRows");
- var i, j;
- var len = scoreFormulaDetailList.length;
- for (i = len - 1; i >= 0; i--) {
- for (j = 0; j < d.length; j++) {
- if (scoreFormulaDetailList[i].ScoreFormulaDetailID == d[j].ScoreFormulaDetailID) {
- scoreFormulaDetailList.splice(i, 1);
- break;
- }
- }
- }
- $("#dgScoreFormulaDetailList").cmsXDataTable("loadData", { rows: scoreFormulaDetailList, total: scoreFormulaDetailList.length });
- }
- //保存
- function ScoreFormula_Save() {
- var percentage = 0;
- var d = [];
- var scoreFormulaDetailList = $("#dgScoreFormulaDetailList").cmsXDataTable("getRows");
- for (var i = 0; i < scoreFormulaDetailList.length; i++) {
- percentage += parseInt(scoreFormulaDetailList[i].Percentage);
- d.push(scoreFormulaDetailList[i].ScoreType);
- }
- var scoreType = d.join(',');
- for (var i = 0; i < scoreType.split(',').length; i++) {
- var sf = 0;
- for (var j = 0; j < scoreFormulaDetailList.length; j++) {
- if (scoreType.split(',')[i] == scoreFormulaDetailList[j].ScoreType) {
- sf++;
- }
- }
- if (sf > 1) {
- $.messager.alert("系统提示", "不能保存重复分数类型,请检查!");
- return;
- }
- }
- if (scoreFormulaDetailList.length == 0) {
- $.messager.alert("系统提示", "请添加公式设置明细!");
- return;
- }
- if (percentage != 100) {
- $.messager.alert("系统提示", "请设置总百分比达到100%!");
- return;
- }
- $(document.forms[0]).submit();
- }
|