StudentEvaluationEnterEdit.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. //加载
  2. $(function () {
  3. var evaluationStudentID = $("#EvaluationStudentID").val();
  4. var evaluationTableID = $("#EvaluationTableID").val();
  5. if (evaluationTableID != "" && evaluationTableID != null) {
  6. loadColumsRank(evaluationTableID, evaluationStudentID);
  7. LoadCalculateMethod();
  8. }
  9. });
  10. function loadColumsRank(evaluationTableID, evaluationStudentID) {
  11. var dataColums = Invoke("/StudentEvaluationEnter/FormTitle", null, "jsonp", function (re) { });
  12. var dataList = Invoke("/StudentEvaluationEnter/Content?evaluationTableID=" + evaluationTableID + "&evaluationStudentID=" + evaluationStudentID, null, "jsonp", function (re) { });
  13. if (dataColums != undefined && dataColums != null) {
  14. if (dataList !== undefined && dataList != null) {
  15. var jsonData = { rows: eval("[" + dataList.rows + "]"), total: dataList.total };
  16. $("#dgStudentEvaluationEnterList").datagrid({
  17. columns: [[
  18. { field: 'OrderNo', title: '次序', width: 120, align: 'center' },
  19. { field: 'EvaluationTargetID', title: '评价指标ID', width: 20, align: 'center' },
  20. { field: 'EvaluationTargetWeight', title: '评价指标权重', width: 20, align: 'center' },
  21. { field: 'EvaluationProjectID', title: '评价项目ID', width: 20, align: 'center' },
  22. { field: 'EvaluationProjectName', title: '评价项目', width: 350, align: 'center', formatter: formatCellTooltip },
  23. { field: 'Weight', title: '权重', width: 50, align: 'center' },
  24. { field: 'EvaluationNormName', title: '评分标准', width: 385, align: 'center' }]],
  25. data: jsonData,
  26. singleSelect: true,
  27. rownumbers: false,
  28. showFooter: true,
  29. striped: 'True',
  30. nowrap: true,
  31. fitColumns: false,
  32. rowStyler: function (index, row) {
  33. if (isNaN(row.OrderNo)) {
  34. return 'color:blue;';
  35. }
  36. },
  37. onClickRow: function (rowIndex, field, value) {
  38. //onClickSum(rowIndex, field, value);
  39. }
  40. });
  41. $('#dgStudentEvaluationEnterList').datagrid('hideColumn', 'EvaluationTargetID');
  42. $('#dgStudentEvaluationEnterList').datagrid('hideColumn', 'EvaluationTargetWeight');
  43. $('#dgStudentEvaluationEnterList').datagrid('hideColumn', 'EvaluationProjectID');
  44. }
  45. }
  46. }
  47. function LoadCalculateMethod() {
  48. //计算规则
  49. //1.选中的评分标准权重/100*评价项目权重=评价项目分数
  50. //2.Sum(评价项目分数)/Sum(评价项目权重)*评价指标权重=评价指标分数
  51. //3.Sum(评价指标分数)/Sum(评价指标权重)*评价表格权重=评价表格分数
  52. var rows = $("#dgStudentEvaluationEnterList").datagrid("getRows");//获取全部数据
  53. var radioButtonObject = $("input:radio[name^='radioButtonName_']:checked")
  54. //求取评价指标分数
  55. var jsonStr = "";
  56. var evaluationScore = 0;//评价项目分数
  57. var zbScore = 0;//评价指标分数
  58. var bgScore = 0;//评价表格分数
  59. var arrList = new Array();
  60. var newarrList = new Array();
  61. var xmqzarrList = new Array();
  62. var pjzbfsArry = new Array();
  63. var pjxmID = null;
  64. var pjzbfs = 0;
  65. for (var k = 0; k < radioButtonObject.length; k++) {
  66. var str = radioButtonObject[k].name;
  67. var strindex = str.lastIndexOf("_") + 1;
  68. var sNewStr = str.substring(strindex);
  69. arrList.push(sNewStr);//将评价指标权重加入数组记录起来
  70. }
  71. var pjzbSum = "";
  72. arrList.sort();
  73. newarrList = $.unique(arrList);//去除重复元素、新指标权重
  74. var targetIDs = newarrList.join(','); //获取指标这个数组的和
  75. if (targetIDs != "") {
  76. $.ajax({
  77. type: "POST",
  78. url: "/StudentEvaluationEnter/GetTargetWeightSum",
  79. data: { evaluationTargetIDs: targetIDs },
  80. dataType: "json",
  81. async: false,
  82. success: function (result) {
  83. //将返回数据添加到页面表格中
  84. $("#ProjectWeightSum").val(result);
  85. }
  86. });
  87. }
  88. pjzbSum = $("#ProjectWeightSum").val();
  89. var zb = 0;
  90. var bg = 0;
  91. var evaluationTableWeight = $("#EvaluationTableWeight").val();
  92. if (evaluationTableWeight == null || evaluationTableWeight == "") {
  93. evaluationTableWeight = 100.0;
  94. }
  95. var tableWeight = evaluationTableWeight;//评价表格
  96. var CodeSum = new Array();
  97. var ProjectSum = 0;
  98. for (var i = 0; i < radioButtonObject.length; i++) {
  99. var qzxmf = radioButtonObject.parent().parent().prev().prev().prev().prev().find("div").eq(i).html();//评价权重
  100. var qz = radioButtonObject.parent().parent().prev().find("div").eq(i).html();//项目权重数据
  101. pjxmID = radioButtonObject.parent().parent().prev().prev().prev().find("div").eq(i).html();//评价项目ID
  102. var targetID = $(radioButtonObject[i]).closest("tr").find("td[field='EvaluationTargetID'] div").text();
  103. if (targetID != "") {
  104. $.ajax({
  105. type: "POST",
  106. url: "/StudentEvaluationEnter/GetProjectWeightSum",
  107. data: { evaluationTargetID: targetID },
  108. dataType: "json",
  109. async: false,
  110. success: function (result) {
  111. ProjectSum = result;
  112. //将返回数据添加到页面表格中
  113. }
  114. });
  115. }
  116. var pfbz = radioButtonObject[i].value;
  117. var xm = radioButtonObject[i].value / 100 * qz;
  118. zb = xm / parseInt(ProjectSum) * qzxmf/*指标权重*/;
  119. bg = zb / parseInt(pjzbSum) * parseInt(tableWeight);
  120. CodeSum.push(bg.toFixed(5));
  121. evaluationScore += pfbz / 100 * qz;
  122. pjzbfs = ((pfbz / 100) * qz) / 100 * (qzxmf);
  123. pjzbfsArry.push(pjzbfs.toFixed(2));
  124. xmqzarrList.push(qz);//记录项目权重
  125. jsonStr += "{ \"EvaluationProjectID\":\"" + pjxmID + "\",\"Score\":\"" + pfbz + "\"}" + ","; //拼接json、返回后台操作
  126. }
  127. jsonStr = jsonStr.substring(0, jsonStr.length - 1);
  128. var jsonData = "[ " + jsonStr + " ]";
  129. var SumValue = eval(CodeSum.join('+')) //获取项目权重这个数组的和
  130. // var sum = eval(pjzbfsArry.join('+')) //获取项目权重这个数组的和
  131. $("#JsonDataStr").val(jsonData);
  132. $("#EvaluationProjectID").val(pjxmID);
  133. $("#EvaluationScore").val(evaluationScore);
  134. $("#EvaluationTotalScore").html(((SumValue * 100) / 100).toFixed(1));
  135. if ($("#EvaluationTotalScore").html() == "NaN" || $("#EvaluationTotalScore").html() == "") {
  136. $("#EvaluationTotalScore").html(0);
  137. }
  138. }
  139. function getonclick(obj) {
  140. var CodeSum = new Array();
  141. var jsonStr = "";
  142. var evaluationTableWeight = $("#EvaluationTableWeight").val();
  143. if (evaluationTableWeight == null || evaluationTableWeight == "") {
  144. evaluationTableWeight = 100;
  145. }
  146. var tableWeight = evaluationTableWeight;//评价表格
  147. var rows = $("#dgStudentEvaluationEnterList").datagrid("getRows");//获取全部数据
  148. var orderNo = $(obj).closest("tr").find("td[field='OrderNo'] div").text();//序号ID
  149. var targetID = $(obj).closest("tr").find("td[field='EvaluationTargetID'] div").text();
  150. var targetWeight = $(obj).closest("tr").find("td[field='EvaluationTargetWeight'] div").text();//评价指标分数
  151. var normNameProjectID = $(obj).closest("tr").find("td[field='EvaluationProjectID'] div").text();
  152. var weight = $(obj).closest("tr").find("td[field='Weight'] div").text();//项目分数
  153. var allZb = $.grep(rows, function (x) { return (x.EvaluationProjectID == ""); });
  154. var brothers = $.grep(rows, function (x) { return (x.EvaluationTargetID == targetID); })
  155. var xmqzdate = $.grep(rows, function (x) { return (x.EvaluationTargetID == targetID && x.EvaluationProjectID != ""); });//Sum(评价项目权重)
  156. var xmqzSum = 0;
  157. var targetWeightSum = 0;
  158. var totalSum = 0;
  159. var radioButtonObject = $("input:radio[name^='radioButtonName_']:checked") //获取所有选中值~~
  160. for (var j = 0; j < xmqzdate.length; j++) {
  161. var xmqzfs = xmqzdate[j].Weight;
  162. xmqzSum += parseInt(xmqzfs);
  163. }
  164. for (var k = 0; k < allZb.length; k++) {
  165. var pgfs = allZb[k].Weight;
  166. targetWeightSum += parseInt(pgfs);
  167. }
  168. var zb = 0;
  169. var bg = 0;
  170. //debugger;
  171. for (var h = 0; h < radioButtonObject.length; h++) {
  172. var qzxmf = radioButtonObject.parent().parent().prev().prev().prev().prev().find("div").eq(h).html();//评价权重
  173. var qz = radioButtonObject.parent().parent().prev().find("div").eq(h).html();//项目权重数据
  174. var pjxmID = radioButtonObject.parent().parent().prev().prev().prev().find("div").eq(h).html();//评价项目ID
  175. var xm = radioButtonObject[h].value / 100 * qz;
  176. zb = xm / xmqzSum * qzxmf/*指标权重*/;
  177. bg = zb / targetWeightSum * parseInt(tableWeight);
  178. CodeSum.push(bg.toFixed(5));
  179. jsonStr += "{ \"EvaluationProjectID\":\"" + pjxmID + "\",\"Score\":\"" + radioButtonObject[h].value + "\"}" + ","; //拼接json、返回后台操作
  180. }
  181. var jsonData = "[ " + jsonStr + " ]";
  182. for (var z = 0; z < CodeSum.length; z++) {
  183. totalSum = totalSum + parseFloat(CodeSum[z]);
  184. }
  185. $("#JsonDataStr").val(jsonData);
  186. $("#EvaluationTotalScore").html(((totalSum * 100) / 100).toFixed(1));
  187. }
  188. function EvaluationCount() {
  189. var rows = $("#dgStudentEvaluationEnterList").datagrid("getRows");
  190. var evaluationTotal = "";
  191. for (var i = 0; i < rows.length; i++) {
  192. if (rows[i]['EvaluationProjectName'] != "") {
  193. evaluationTotal += rows[i]['EvaluationProjectName'] + "&";
  194. }
  195. }
  196. if (evaluationTotal.length > 0) {
  197. evaluationTotal = evaluationTotal.substr(0, evaluationTotal.length - 1);
  198. }
  199. return evaluationTotal.split('&').length;
  200. }
  201. //格式化单元格提示信息
  202. function formatCellTooltip(val, rec) {
  203. return "<span title='" + val + "'>" + val + "</span>";
  204. }
  205. //设置列颜色为红色
  206. function SetRedColumn(index, row, value) {
  207. return " <span style=\"color: red;\">" + value + "</span>";
  208. }
  209. //保存
  210. function StudentEvaluationEnter_Save() {
  211. var radioButtonCount = $("input:radio[name^='radioButtonName_']:checked");
  212. if (radioButtonCount.length != EvaluationCount()) {
  213. $.messager.alert("系统提示", "评价内容没有评选完,请选择。");
  214. return;
  215. }
  216. var advice = $("#Advice").val();
  217. if (advice == null || advice == "") {
  218. $.messager.alert("系统提示", "请填写简要评语或建议。");
  219. return;
  220. }
  221. var evaluationTotalScore = $("#EvaluationTotalScore").text();
  222. $("#TotalScore").val(evaluationTotalScore);
  223. $(document.forms[0]).submit();
  224. }