EvaluationNormEdit.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. var url = CMS_SystemConfig.VirtualDirectoryPath + "/EvaluationNorm/DetailEdit";
  2. var mnu = "";
  3. //加载
  4. $(function () {
  5. mnu = $.SystemGeneral.getUrlParam("MNU");
  6. })
  7. //刷新
  8. function reload() {
  9. $("#dgEvaluationNormDetailList").cmsXDataTable("load", $.getDataGridParams("dgEvaluationNormDetailList"));
  10. }
  11. //获取选中的数据
  12. function validChoose() {
  13. var d = [];
  14. $.each($("#dgEvaluationNormDetailList").cmsXDataTable("getSelections"), function (index) {
  15. d.push(this.EvaluationNormDetailID);
  16. });
  17. return d;
  18. }
  19. //获取选中的数据All
  20. function validChooseAll() {
  21. var d = [];
  22. $.each($("#dgEvaluationNormDetailList").cmsXDataTable("getSelections"), function (index) {
  23. d.push(this);
  24. });
  25. return d;
  26. }
  27. function queryNormType(data) {
  28. var normTypeID = $("#NormTypeID").combogridX("getValue");
  29. if (normTypeID == checkBoxNormTypeID) {
  30. $("#divDetail").show();
  31. } else {
  32. $("#divDetail").hide();
  33. }
  34. }
  35. //查看
  36. function edit(rowindex, rowdata) {
  37. var redirectTo = url + "?evaluationNormDetailID=" + rowdata.EvaluationNormDetailID + "&RowIndex=" + rowindex + "&MNU=" + mnu + "&type=detail";
  38. $.popupTopWindow('评分标准明细信息', redirectTo, 650, 350, EvaluationNormDetail_Confirm, rowdata);
  39. }
  40. //新增
  41. function EvaluationNormDetail_Add() {
  42. var d = validChooseAll();
  43. if (d.length > 0) {
  44. $.popupTopWindow('评分标准明细复制新增', CMS_SystemConfig.VirtualDirectoryPath + '/EvaluationNorm/CopyAddDetail?evaluationNormDetailID=' + d[0].EvaluationNormDetailID + '&MNU=' + mnu, 650, 350, EvaluationNormDetail_Confirm, d[0]);
  45. }
  46. else {
  47. var redirectTo = url + "?MNU=" + mnu;
  48. $.popupTopWindow('评分标准明细新增', redirectTo, 650, 350, EvaluationNormDetail_Confirm, null);
  49. }
  50. }
  51. //确定
  52. function EvaluationNormDetail_Confirm(resultData) {
  53. if (resultData) {
  54. var orderNo = resultData.OrderNo;
  55. var name = resultData.Name;
  56. var weight = resultData.Weight;
  57. var remark = resultData.Remark;
  58. var rowIndex = resultData.RowIndex;
  59. var detailViewList = $("#dgEvaluationNormDetailList").cmsXDataTable("getRows");
  60. if ($.grep(detailViewList, function (row, index) { return name == row.Name; }).length == 0) {
  61. if (rowIndex == null) {
  62. detailViewList.push({
  63. EvaluationNormDetailID: Guid.NewGuid().ToString(),
  64. OrderNo: orderNo,
  65. Name: name,
  66. Weight: weight,
  67. Remark: remark
  68. });
  69. } else {
  70. detailViewList[rowIndex].OrderNo = orderNo;
  71. detailViewList[rowIndex].Name = name;
  72. detailViewList[rowIndex].Weight = weight;
  73. detailViewList[rowIndex].Remark = remark;
  74. }
  75. } else {
  76. $.messager.alert("系统提示", "添加失败,评分标准明细名称已存在。");
  77. return;
  78. }
  79. $("#dgEvaluationNormDetailList").cmsXDataTable("loadData", { rows: detailViewList, total: detailViewList.length });
  80. }
  81. }
  82. //删除
  83. function EvaluationNormDetail_Delete() {
  84. var d = validChooseAll();
  85. if (d.length == 0) {
  86. $.messager.alert("系统提示", "请选择您要删除的信息。");
  87. return;
  88. }
  89. $.messager.confirm("系统提示", "您确定要删除选择的信息?", function (r) {
  90. if (r) {
  91. var detailViewList = $("#dgEvaluationNormDetailList").cmsXDataTable("getRows");
  92. var i, j;
  93. var len = detailViewList.length;
  94. for (i = len - 1; i >= 0; i--) {
  95. for (j = 0; j < d.length; j++) {
  96. if (detailViewList[i].EvaluationNormDetailID == d[j].EvaluationNormDetailID) {
  97. detailViewList.splice(i, 1);
  98. break;
  99. }
  100. }
  101. }
  102. $("#dgEvaluationNormDetailList").cmsXDataTable("loadData", { rows: detailViewList, total: detailViewList.length });
  103. }
  104. });
  105. }
  106. //保存
  107. function EvaluationNorm_Save() {
  108. var normTypeID = $("#NormTypeID").combogridX("getValue");
  109. if (normTypeID == "" || normTypeID == "-1" || normTypeID == null) {
  110. $.messager.alert("系统提示", "请选择评分类型。");
  111. return;
  112. }
  113. if (normTypeID == checkBoxNormTypeID) {
  114. var rows = $("#dgEvaluationNormDetailList").cmsXDataTable("getRows");
  115. if (rows.length <= 0) {
  116. $.messager.alert("系统提示", "评分标准明细不能为空,请添加。");
  117. return;
  118. }
  119. }
  120. $(document.forms[0]).submit();
  121. }
  122. //设置列颜色为红色
  123. function SetRedColumn(index, row, value) {
  124. return " <span style=\"color: red;\">" + value + "</span>";
  125. }