123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- //加载
- $(function () {
- var evaluationStudentID = $("#EvaluationStudentID").val();
- var evaluationTableID = $("#EvaluationTableID").val();
- if (evaluationTableID != "" && evaluationTableID != null) {
- loadColumsRank(evaluationTableID, evaluationStudentID);
- LoadCalculateMethod();
- }
- });
- function loadColumsRank(evaluationTableID, evaluationStudentID) {
- var dataColums = Invoke("/StudentEvaluationEnter/FormTitle", null, "jsonp", function (re) { });
- var dataList = Invoke("/StudentEvaluationEnter/Content?evaluationTableID=" + evaluationTableID + "&evaluationStudentID=" + evaluationStudentID, null, "jsonp", function (re) { });
- if (dataColums != undefined && dataColums != null) {
- if (dataList !== undefined && dataList != null) {
- var jsonData = { rows: eval("[" + dataList.rows + "]"), total: dataList.total };
- $("#dgStudentEvaluationEnterList").datagrid({
- columns: [[
- { field: 'OrderNo', title: '次序', width: 120, align: 'center' },
- { field: 'EvaluationTargetID', title: '评价指标ID', width: 20, align: 'center' },
- { field: 'EvaluationTargetWeight', title: '评价指标权重', width: 20, align: 'center' },
- { field: 'EvaluationProjectID', title: '评价项目ID', width: 20, align: 'center' },
- { field: 'EvaluationProjectName', title: '评价项目', width: 350, align: 'center', formatter: formatCellTooltip },
- { field: 'Weight', title: '权重', width: 50, align: 'center' },
- { field: 'EvaluationNormName', title: '评分标准', width: 385, align: 'center' }]],
- data: jsonData,
- singleSelect: true,
- rownumbers: false,
- showFooter: true,
- striped: 'True',
- nowrap: true,
- fitColumns: false,
- rowStyler: function (index, row) {
- if (isNaN(row.OrderNo)) {
- return 'color:blue;';
- }
- },
- onClickRow: function (rowIndex, field, value) {
- //onClickSum(rowIndex, field, value);
- }
- });
- $('#dgStudentEvaluationEnterList').datagrid('hideColumn', 'EvaluationTargetID');
- $('#dgStudentEvaluationEnterList').datagrid('hideColumn', 'EvaluationTargetWeight');
- $('#dgStudentEvaluationEnterList').datagrid('hideColumn', 'EvaluationProjectID');
- }
- }
- }
- function LoadCalculateMethod() {
- //计算规则
- //1.选中的评分标准权重/100*评价项目权重=评价项目分数
- //2.Sum(评价项目分数)/Sum(评价项目权重)*评价指标权重=评价指标分数
- //3.Sum(评价指标分数)/Sum(评价指标权重)*评价表格权重=评价表格分数
- var rows = $("#dgStudentEvaluationEnterList").datagrid("getRows");//获取全部数据
- var radioButtonObject = $("input:radio[name^='radioButtonName_']:checked")
- //求取评价指标分数
- var jsonStr = "";
- var evaluationScore = 0;//评价项目分数
- var zbScore = 0;//评价指标分数
- var bgScore = 0;//评价表格分数
- var arrList = new Array();
- var newarrList = new Array();
- var xmqzarrList = new Array();
- var pjzbfsArry = new Array();
- var pjxmID = null;
- var pjzbfs = 0;
- for (var k = 0; k < radioButtonObject.length; k++) {
- var str = radioButtonObject[k].name;
- var strindex = str.lastIndexOf("_") + 1;
- var sNewStr = str.substring(strindex);
- arrList.push(sNewStr);//将评价指标权重加入数组记录起来
- }
- var pjzbSum = "";
- arrList.sort();
- newarrList = $.unique(arrList);//去除重复元素、新指标权重
- var targetIDs = newarrList.join(','); //获取指标这个数组的和
- if (targetIDs != "") {
- $.ajax({
- type: "POST",
- url: "/StudentEvaluationEnter/GetTargetWeightSum",
- data: { evaluationTargetIDs: targetIDs },
- dataType: "json",
- async: false,
- success: function (result) {
- //将返回数据添加到页面表格中
- $("#ProjectWeightSum").val(result);
- }
- });
- }
- pjzbSum = $("#ProjectWeightSum").val();
- var zb = 0;
- var bg = 0;
- var evaluationTableWeight = $("#EvaluationTableWeight").val();
- if (evaluationTableWeight == null || evaluationTableWeight == "") {
- evaluationTableWeight = 100.0;
- }
- var tableWeight = evaluationTableWeight;//评价表格
- var CodeSum = new Array();
- var ProjectSum = 0;
- for (var i = 0; i < radioButtonObject.length; i++) {
- var qzxmf = radioButtonObject.parent().parent().prev().prev().prev().prev().find("div").eq(i).html();//评价权重
- var qz = radioButtonObject.parent().parent().prev().find("div").eq(i).html();//项目权重数据
- pjxmID = radioButtonObject.parent().parent().prev().prev().prev().find("div").eq(i).html();//评价项目ID
- var targetID = $(radioButtonObject[i]).closest("tr").find("td[field='EvaluationTargetID'] div").text();
- if (targetID != "") {
- $.ajax({
- type: "POST",
- url: "/StudentEvaluationEnter/GetProjectWeightSum",
- data: { evaluationTargetID: targetID },
- dataType: "json",
- async: false,
- success: function (result) {
- ProjectSum = result;
- //将返回数据添加到页面表格中
- }
- });
- }
- var pfbz = radioButtonObject[i].value;
- var xm = radioButtonObject[i].value / 100 * qz;
- zb = xm / parseInt(ProjectSum) * qzxmf/*指标权重*/;
- bg = zb / parseInt(pjzbSum) * parseInt(tableWeight);
- CodeSum.push(bg.toFixed(5));
- evaluationScore += pfbz / 100 * qz;
- pjzbfs = ((pfbz / 100) * qz) / 100 * (qzxmf);
- pjzbfsArry.push(pjzbfs.toFixed(2));
- xmqzarrList.push(qz);//记录项目权重
- jsonStr += "{ \"EvaluationProjectID\":\"" + pjxmID + "\",\"Score\":\"" + pfbz + "\"}" + ","; //拼接json、返回后台操作
- }
- jsonStr = jsonStr.substring(0, jsonStr.length - 1);
- var jsonData = "[ " + jsonStr + " ]";
- var SumValue = eval(CodeSum.join('+')) //获取项目权重这个数组的和
- // var sum = eval(pjzbfsArry.join('+')) //获取项目权重这个数组的和
- $("#JsonDataStr").val(jsonData);
- $("#EvaluationProjectID").val(pjxmID);
- $("#EvaluationScore").val(evaluationScore);
- $("#EvaluationTotalScore").html(((SumValue * 100) / 100).toFixed(1));
- if ($("#EvaluationTotalScore").html() == "NaN" || $("#EvaluationTotalScore").html() == "") {
- $("#EvaluationTotalScore").html(0);
- }
- }
- function getonclick(obj) {
- var CodeSum = new Array();
- var jsonStr = "";
- var evaluationTableWeight = $("#EvaluationTableWeight").val();
- if (evaluationTableWeight == null || evaluationTableWeight == "") {
- evaluationTableWeight = 100;
- }
- var tableWeight = evaluationTableWeight;//评价表格
- var rows = $("#dgStudentEvaluationEnterList").datagrid("getRows");//获取全部数据
- var orderNo = $(obj).closest("tr").find("td[field='OrderNo'] div").text();//序号ID
- var targetID = $(obj).closest("tr").find("td[field='EvaluationTargetID'] div").text();
- var targetWeight = $(obj).closest("tr").find("td[field='EvaluationTargetWeight'] div").text();//评价指标分数
- var normNameProjectID = $(obj).closest("tr").find("td[field='EvaluationProjectID'] div").text();
- var weight = $(obj).closest("tr").find("td[field='Weight'] div").text();//项目分数
- var allZb = $.grep(rows, function (x) { return (x.EvaluationProjectID == ""); });
- var brothers = $.grep(rows, function (x) { return (x.EvaluationTargetID == targetID); })
- var xmqzdate = $.grep(rows, function (x) { return (x.EvaluationTargetID == targetID && x.EvaluationProjectID != ""); });//Sum(评价项目权重)
- var xmqzSum = 0;
- var targetWeightSum = 0;
- var totalSum = 0;
- var radioButtonObject = $("input:radio[name^='radioButtonName_']:checked") //获取所有选中值~~
- for (var j = 0; j < xmqzdate.length; j++) {
- var xmqzfs = xmqzdate[j].Weight;
- xmqzSum += parseInt(xmqzfs);
- }
- for (var k = 0; k < allZb.length; k++) {
- var pgfs = allZb[k].Weight;
- targetWeightSum += parseInt(pgfs);
- }
- var zb = 0;
- var bg = 0;
- //debugger;
- for (var h = 0; h < radioButtonObject.length; h++) {
- var qzxmf = radioButtonObject.parent().parent().prev().prev().prev().prev().find("div").eq(h).html();//评价权重
- var qz = radioButtonObject.parent().parent().prev().find("div").eq(h).html();//项目权重数据
- var pjxmID = radioButtonObject.parent().parent().prev().prev().prev().find("div").eq(h).html();//评价项目ID
- var xm = radioButtonObject[h].value / 100 * qz;
- zb = xm / xmqzSum * qzxmf/*指标权重*/;
- bg = zb / targetWeightSum * parseInt(tableWeight);
- CodeSum.push(bg.toFixed(5));
- jsonStr += "{ \"EvaluationProjectID\":\"" + pjxmID + "\",\"Score\":\"" + radioButtonObject[h].value + "\"}" + ","; //拼接json、返回后台操作
- }
- var jsonData = "[ " + jsonStr + " ]";
- for (var z = 0; z < CodeSum.length; z++) {
- totalSum = totalSum + parseFloat(CodeSum[z]);
- }
- $("#JsonDataStr").val(jsonData);
- $("#EvaluationTotalScore").html(((totalSum * 100) / 100).toFixed(1));
- }
- function EvaluationCount() {
- var rows = $("#dgStudentEvaluationEnterList").datagrid("getRows");
- var evaluationTotal = "";
- for (var i = 0; i < rows.length; i++) {
- if (rows[i]['EvaluationProjectName'] != "") {
- evaluationTotal += rows[i]['EvaluationProjectName'] + "&";
- }
- }
- if (evaluationTotal.length > 0) {
- evaluationTotal = evaluationTotal.substr(0, evaluationTotal.length - 1);
- }
- return evaluationTotal.split('&').length;
- }
- //格式化单元格提示信息
- function formatCellTooltip(val, rec) {
- return "<span title='" + val + "'>" + val + "</span>";
- }
- //设置列颜色为红色
- function SetRedColumn(index, row, value) {
- return " <span style=\"color: red;\">" + value + "</span>";
- }
- //保存
- function StudentEvaluationEnter_Save() {
- var radioButtonCount = $("input:radio[name^='radioButtonName_']:checked");
- if (radioButtonCount.length != EvaluationCount()) {
- $.messager.alert("系统提示", "评价内容没有评选完,请选择。");
- return;
- }
- var advice = $("#Advice").val();
- if (advice == null || advice == "") {
- $.messager.alert("系统提示", "请填写简要评语或建议。");
- return;
- }
- var evaluationTotalScore = $("#EvaluationTotalScore").text();
- $("#TotalScore").val(evaluationTotalScore);
- $(document.forms[0]).submit();
- }
|