ScoreFormulaEdit.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. function reload() {
  2. $("#dgScoreFormulaDetailList").cmsXDataTable("load", $.getDataGridParams("dgScoreFormulaDetailList"));
  3. }
  4. //获取选中的数据
  5. function validChoose() {
  6. var d = [];
  7. $.each($("#dgScoreFormulaDetailList").cmsXDataTable("getSelections"), function (index) {
  8. d.push(this);
  9. });
  10. return d;
  11. }
  12. //添加
  13. function ScoreFormula_SettingsAdd() {
  14. var scoreFormulaDetailList = $("#dgScoreFormulaDetailList").cmsXDataTable("getRows");
  15. var scoreFormulaDetailID = Guid.NewGuid().ToString();
  16. scoreFormulaDetailList.push({
  17. ScoreFormulaDetailID: scoreFormulaDetailID,
  18. ScoreType: 1,
  19. Percentage: 0,
  20. IsRequirePass: false
  21. });
  22. $("#dgScoreFormulaDetailList").cmsXDataTable("loadData", { rows: scoreFormulaDetailList, total: scoreFormulaDetailList.length });
  23. }
  24. //删除
  25. function ScoreFormula_SettingsDelete() {
  26. var d = validChoose();
  27. var scoreFormulaDetailList = $("#dgScoreFormulaDetailList").cmsXDataTable("getRows");
  28. var i, j;
  29. var len = scoreFormulaDetailList.length;
  30. for (i = len - 1; i >= 0; i--) {
  31. for (j = 0; j < d.length; j++) {
  32. if (scoreFormulaDetailList[i].ScoreFormulaDetailID == d[j].ScoreFormulaDetailID) {
  33. scoreFormulaDetailList.splice(i, 1);
  34. break;
  35. }
  36. }
  37. }
  38. $("#dgScoreFormulaDetailList").cmsXDataTable("loadData", { rows: scoreFormulaDetailList, total: scoreFormulaDetailList.length });
  39. }
  40. //保存
  41. function ScoreFormula_Save() {
  42. var percentage = 0;
  43. var d = [];
  44. var scoreFormulaDetailList = $("#dgScoreFormulaDetailList").cmsXDataTable("getRows");
  45. for (var i = 0; i < scoreFormulaDetailList.length; i++) {
  46. percentage += parseInt(scoreFormulaDetailList[i].Percentage);
  47. d.push(scoreFormulaDetailList[i].ScoreType);
  48. }
  49. var scoreType = d.join(',');
  50. for (var i = 0; i < scoreType.split(',').length; i++) {
  51. var sf = 0;
  52. for (var j = 0; j < scoreFormulaDetailList.length; j++) {
  53. if (scoreType.split(',')[i] == scoreFormulaDetailList[j].ScoreType) {
  54. sf++;
  55. }
  56. }
  57. if (sf > 1) {
  58. $.messager.alert("系统提示", "不能保存重复分数类型,请检查!");
  59. return;
  60. }
  61. }
  62. if (scoreFormulaDetailList.length == 0) {
  63. $.messager.alert("系统提示", "请添加公式设置明细!");
  64. return;
  65. }
  66. if (percentage != 100) {
  67. $.messager.alert("系统提示", "请设置总百分比达到100%!");
  68. return;
  69. }
  70. $(document.forms[0]).submit();
  71. }