123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485 |
- var session = null;
-
- var SubjectId = 0;
- var title = '';
-
- $(function(){
- SubjectId = QueryString('SubjectId');
- $('#setting3').prev('.mask').hide().end().fadeOut();
- queryWJTJData();
- });
-
- function showPie(id,data,title,is3d,height,width){//饼图
- $('#'+id).css('height',height);
- $('#'+id).css('width',width);
- $('#'+id).highcharts({
- chart: {
- type: 'pie',
- options3d: {
- enabled: is3d, alpha: 45, beta: 0
- }
- }, title: {
- text: title
- }, tooltip: {
- pointFormat: '{point.percentage:.1f}%</b>'
- }, plotOptions: {
- pie: {
- allowPointSelect: true, cursor: 'pointer', depth: 35,
- dataLabels: {
- enabled: true, format: '{point.name}'
- }
- }
- },credits: {
- enabled: false
- },exporting:{
- enabled:false
- },series: [{
- type: 'pie', name: title,
- data: data
- }]
- });
- }
-
- function showBar1(id,data,title,width,height){//条形图
- $('#'+id).css('width',width);
- $('#'+id).css('height',height);
- $('#'+id).highcharts({
- chart: {
- type: 'bar'
- },
- title: {
- text: ''
- },
- xAxis: {
- categories: title
- },
- exporting:{
- enabled:false
- },
- yAxis: {
- min: 0,
- title: {
- text: '',
- align: 'high'
- }
- },
- tooltip: {
- valueSuffix: '(%)'
- },
- legend: {
- backgroundColor: '#FFFFFF',
- reversed: true
- },
- plotOptions: {
- bar: {
- dataLabels: {
- enabled: false
- }
- }
- },
- credits: {
- enabled: false
- },
- series: data
- });
- }
-
- function QueryString(val) {
- var uri = window.location.search;
- var re = new RegExp("" +val+ "\=([^\&\?]*)", "ig");
- return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);
- }
-
- function queryWJTJData(){
- var param = {};
- param.SubjectId = SubjectId;
- var _d = _ajax('../survey/wtbj_AllStatisticaBySubjectid.action',param,false);
- initHtml(_d)
- }
-
- function downLoadFile(o,id){
- if(!id){
- id = '';
- }
- o.href = '../survey/wtbj_downLoadFile.action?SubjectId='+SubjectId+'&Questid='+id;
- }
-
- function detailMsg(){
- window.location.href = 'myd-jgtj-list.html?subjectid='+SubjectId+'&subjecttitle='+title+'&typeV=2&Status=2';
- }
-
- function initHtml(d){
- var _d = d.Result;
- $('#allCount').text(d.SubjectTotal);
- if(!isEmpty(_d) && d.SubjectTotal > 0){
- title = d.SubjectTitle;
- $('#title').text(d.SubjectTitle);
- for(var i = 0;i<_d.length;i++){
- if(parseInt(_d[i].Questtype) == 1){//选题
- $('#chartDiv').append(SCHtml(_d[i],i));
- var pieData = getPieData(_d[i]);
- showPie('chart'+_d[i].Questid,pieData,d.Question,false,300,'auto');
- }else if(parseInt(_d[i].Questtype) == 2){//多选题
- $('#chartDiv').append(MCHtml(_d[i],i));
- var barData = getBarData1(_d[i]);
- showBar1('chart'+_d[i].Questid,barData,getBarTitle1(_d[i]),800,300);
- }else if(parseInt(_d[i].Questtype) == 3){//填空题
- $('#chartDiv').append(TKHtml(_d[i],i));
- }else if(parseInt(_d[i].Questtype) == 4){//矩阵单选题
- var barData = getBarData2(_d[i]);
- var titles = getBarTitle2(_d[i]);
- $('#chartDiv').append(JZSHtml(getBarData3(_d[i]),_d[i].TotalSamp,titles,_d[i],i));
- showBar2('chart'+_d[i].Questid,barData,titles,800,300);
- }else if(parseInt(_d[i].Questtype) == 5){//矩阵多选选题
- var barData = getBarData2(_d[i]);
- var titles = getBarTitle2(_d[i]);
- $('#chartDiv').append(JZSHtml(getBarData3(_d[i]),_d[i].TotalSamp,titles,_d[i],i));
- showBar1('chart'+_d[i].Questid,barData,titles,800,300);
- }
- }
- }else{
- $('#divCount').empty().html('<span style="">暂无数据统计<span>');
- }
- }
-
- function getBarData2(d){
- var _d = new Array();
- var _data = d.series;
- for(var i = 0;i<_data.length;i++){
- var p = {};
- p.name = _data[i].Question;
- var _data1 = _data[i].data;
- if(!isEmpty(_data1)){
- var _arr = new Array();
- for(var j = 0;j<_data1.length;j++){
- var num = parseFloat(isNaN(_data1[j].Sum*100/d.TotalSamp)?0:_data1[j].Sum*100/d.TotalSamp).toFixed(2);
- _arr.push(parseFloat(num+''));
- }
- p.data = _arr;
- }
- _d.push(p);
- }
- return _d;
- }
-
- function getBarData3(d){
- var _d = new Array();
- var _data = d.series;
- for(var i = 0;i<_data.length;i++){
- var p = {};
- p.name = _data[i].Question;
- var _data1 = _data[i].data;
- if(!isEmpty(_data1)){
- var _arr = new Array();
- for(var j = 0;j<_data1.length;j++){
- _arr.push(_data1[j].Sum);
- }
- p.data = _arr;
- }
- _d.push(p);
- }
- return _d;
- }
-
- function getBarTitle2(d){
- var _d = new Array();
- var _data = d.categories;
- for(var i = 0;i<_data.length;i++){
- _d.push(_data[i].ItemCont);
- }
- return _d;
- }
-
- function showBar2(id,data,title,width,height){
- $('#'+id).css('width',width);
- $('#'+id).css('height',height);
- $('#'+id).highcharts({
- chart: {
- type: 'bar'
- },
- title: {
- text: ''
- },
- xAxis: {
- categories: title
- },credits:{
- enabled:0,text:"",href:""
- },
- yAxis: {
- min: 0,
- title: {
- text: ''
- }
- },
- exporting:{
- enabled:false
- },
- tooltip: {
- valueSuffix: '(%)'
- },
- legend: {
- backgroundColor: '#FFFFFF',
- reversed: true
- },
- plotOptions: {//重叠
- series: {
- stacking: 'normal'
- }
- },
- series: data
- });
- }
-
- function TKHtml(d,index){//填空题
- if(!isEmpty(d)){
- var html = '<div class="stat-sec"><div class="stat-sec-tit">';
- html += '<span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(填空)';
- html += '<a class="btn btn-gray btn-w65" onclick="downLoadFile(this,'+d.Questid+')">导出</a></div>';
- html += '<div class="stat-sec-con"><div class="t-center c-222 mt15">'+d.Question+'</div>';
- html += '<div class="mt30"></div><div class="mt30"><table class="tb tb-border" width="100%">';
- html += ' <tr><th>答案</th></tr>';
- var flag = false;
- for(var i = 0;i<d.SvQuestionItems.length;i++){
- if(i > 4){
- flag = true;
- html += '<tr style="display:none" name="showTr"><td>'+d.SvQuestionItems[i].Answer+'</td></tr>';
- }else html += '<tr><td>'+d.SvQuestionItems[i].Answer+'</td></tr>';
- }
- html += '<tr style="background-color:#f8f8f8;">';
- html += '<td class="relative" style="padding-left:20px;text-align:left">';
- html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span>';
- html += '<span class="absolute" style="right:20px; font-size:12px;">'+d.TotalSamp+'条';
- if(flag){
- html += '<a id="show'+d.Questid+'" href="javascript:;" onclick="optShowTr(this,'+d.Questid+')">展开全部</a>';
- html += '<a id="hide'+d.Questid+'" style="display:none" href="javascript:;" onclick="optHideTr(this,'+d.Questid+')">隐藏部份</a></span>';
- }else{
- html += '</span>';
- }
- html += '</td> </tr>';
- html += '</table> </div></div></div>';
- return html;
- }
- }
-
- function optShowTr(o,id){
- $('tr[name="showTr"]').each(function(i){
- $(this).show();
- })
- $(o).hide();
- $('#hide'+id).show();
- }
-
- function optHideTr(o,id){
- $('tr[name="showTr"]').each(function(i){
- $(this).hide();
- })
- $(o).hide();
- $('#show'+id).show();
- }
-
- function JZSHtml(dbarData,count,titles,d,index){//矩阵单选题
- if(!isEmpty(d)){
- var html = ' <div class="stat-sec"><div class="stat-sec-con">';
- html += '<div class="stat-sec-tit"><span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(多选题)';
- html += '<a class="btn btn-gray btn-w65" onclick="downLoadFile(this,'+d.Questid+')">导出</a></div>';
- html += '<div class="t-center c-222">'+d.Question+'</div>';
- html += '<div class="t-center f12 mt5">答题人数:<span class="c-org">'+d.TotalSamp+'</span></div>';
- html += '<div class="mt30" align="center">';
- html += '<div id="chart'+d.Questid+'" style=" width:400px; height:400px;"></div></div>';
- html += '<div class="mt30"><table class="tb tb-border" width="100%">';
- html += '<tr><th>选项</th>';
- var num = 1;
- for(var i = 0;i<titles.length;i++){
- html += '<th>'+titles[i]+'</th>';
- num++;
- }
- html += '</tr>';
- for(var i = 0;i<dbarData.length;i++){
- html += '<tr><th>'+dbarData[i].name+'</th>';
- for(var k = 0;k<dbarData[i].data.length;k++){
- html += '<th>'+dbarData[i].data[k]+'('+(isNaN(dbarData[i].data[k]*100/count)?0:dbarData[i].data[k]*100/count).toFixed(2)+'%)</th>';
- }
- }
- html += '</tr>';
- html += '<tr style="background-color:#f8f8f8;"><td colspan="'+num+'" style="padding-left:20px;text-align:left">';
- html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span></td></tr>';
- html += '</table> </div> </div> </div>';
- return html;
- }
- }
-
- function JZMHtml(dbarData,titles,d,index){//矩阵多选题
- if(!isEmpty(d)){
- var html = ' <div class="stat-sec"><div class="stat-sec-con">';
- html += '<div class="stat-sec-tit"><span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(多选题)';
- html += '<input type="button" class="btn btn-gray btn-w65" value="导出" /></div>';
- html += '<div class="t-center c-222">'+d.Question+'</div>';
- html += '<div class="t-center f12 mt5">答题人数:<span class="c-org">'+d.TotalSamp+'</span></div>';
- html += '<div class="mt30" align="center">';
- html += '<div id="chart'+d.Questid+'" style=" width:400px; height:400px;"></div></div>';
- html += '<div class="mt30"><table class="tb tb-border" width="100%">';
- html += '<tr><th>选项</th>';
- var num = 1;
- for(var i = 0;i<dbarData.length;i++){
- html += '<th>'+dbarData[i].name+'</th>';
- num++;
- }
- html += '</tr>';
- var n = 0;
- for(var i = 0;i<titles.length;i++){
- html += '<tr><th>'+titles[i]+'</th>';
- for(var j = 0;j<dbarData.length;j++){
- for(var k = 0;k<dbarData[j].data.length;k++){
- html += '<th>'+dbarData[j].data[k]+'%</th>';
- }
- j = dbarData.length;
- }
- n++;
- }
- html += '</tr>';
- html += '<tr style="background-color:#f8f8f8;"><td colspan="'+num+'" style="padding-left:20px;text-align:left">';
- html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span></td></tr>';
- html += '</table> </div> </div> </div>';
- return html;
- }
- }
-
- function MCHtml(d,index){//多选题
- if(!isEmpty(d)){
- var html = ' <div class="stat-sec"><div class="stat-sec-con">';
- html += '<div class="stat-sec-tit"><span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(多选题)';
- html += '<a class="btn btn-gray btn-w65" onclick="downLoadFile(this,'+d.Questid+')">导出</a></div>';
- html += '<div class="t-center c-222">'+d.Question+'</div>';
- html += '<div class="t-center f12 mt5">答题人数:<span class="c-org">'+d.TotalSamp+'</span></div>';
- html += '<div class="mt30" align="center">';
- html += '<div id="chart'+d.Questid+'" style=" width:400px; height:400px;"></div></div>';
- html += '<div class="mt30"><table class="tb tb-border" width="100%">';
- html += '<tr><th>选项</th><th>回复数(占比)</th></tr>';
- for(var i = 0;i<d.SvQuestionItems.length;i++){
- html += '<tr><td>'+d.SvQuestionItems[i].ItemCont
- +'</td><td><span class="c-org">'+d.SvQuestionItems[i].Sum
- +'</span>('+(isNaN(d.SvQuestionItems[i].Sum*100/d.TotalSamp)?0:d.SvQuestionItems[i].Sum*100/d.TotalSamp).toFixed(2)+'%)</td></tr>';
- }
- html += '<tr style="background-color:#f8f8f8;"><td colspan="2" style="padding-left:20px;text-align:left">';
- html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span></td></tr>';
- html += '</table> </div> </div> </div>';
- return html;
- }
- }
-
- function getBarData1(d){
- var _d = new Array();
- var p = {};
- p.name = d.Question;
- var t = new Array();
- for(var i = 0;i<d.SvQuestionItems.length;i++){
- var num = parseFloat(isNaN(d.SvQuestionItems[i].Sum*100/d.TotalSamp)?0:d.SvQuestionItems[i].Sum*100/d.TotalSamp).toFixed(2);
- t.push(parseFloat(num+''));
- }
- p.data = t;
- _d.push(p);
- return _d;
- }
-
- function getBarTitle1(d){
- var _d = new Array();
- for(var i = 0;i<d.SvQuestionItems.length;i++){
- _d.push(d.SvQuestionItems[i].ItemCont);
- }
- return _d;
- }
-
- function getPieData(d){
- var _d = new Array();
- for(var i = 0;i<d.SvQuestionItems.length;i++){
- var t = new Array();
- t.push(d.SvQuestionItems[i].ItemCont);
- t.push(parseInt(d.SvQuestionItems[i].Sum));
- _d.push(t);
- }
- return _d;
- }
-
- function SCHtml(d,index){//单选题
- if(!isEmpty(d)){
- var html = ' <div class="stat-sec"><div class="stat-sec-con">';
- html += '<div class="stat-sec-tit"><span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(单选题)';
- html += '<a class="btn btn-gray btn-w65" onclick="downLoadFile(this,'+d.Questid+')">导出</a></div>';
- html += '<div class="t-center c-222">'+d.Question+'</div>';
- html += '<div class="t-center f12 mt5">答题人数:<span class="c-org">'+d.TotalSamp+'</span></div>';
- html += '<div class="mt30" align="center">';
- html += '<div id="chart'+d.Questid+'" style=" width:400px; height:400px;"></div></div>';
- html += '<div class="mt30"><table class="tb tb-border" width="100%">';
- html += '<tr><th>选项</th><th>回复数(占比)</th></tr>';
- for(var i = 0;i<d.SvQuestionItems.length;i++){
- html += '<tr><td>'+d.SvQuestionItems[i].ItemCont+'</td>';
- html += '<td><span class="c-org">'+d.SvQuestionItems[i].Sum+'</span>';
- html += '('+parseFloat(isNaN(d.SvQuestionItems[i].Sum*100/d.TotalSamp)?0:d.SvQuestionItems[i].Sum*100/d.TotalSamp).toFixed(2)+'%)';
- if(d.SvQuestionItems[i].OtherAnswer.length > 0){
- var str = '';
- for(var n = 0;n < d.SvQuestionItems[i].OtherAnswer.length;n++){
- if(str == ''){
- str += d.SvQuestionItems[i].OtherAnswer[n].OAnswer;
- }else str += '-'+d.SvQuestionItems[i].OtherAnswer[n].OAnswer;
- }
- html += '<a onclick="showOtherAnswer(\''+str+'\',\''+d.SvQuestionItems[i].ItemCont+'\')" class="absolute" style="right:16%;font-size:12px;" href="javascript:;">查看详情</a>';
- }
- html += '</td></tr>';
- }
- html += '<tr style="background-color:#f8f8f8;"><td colspan="2" style="padding-left:20px;text-align:left">';
- html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span></td></tr>';
- html += '</table> </div> </div> </div>';
- return html;
- }
- }
-
- function showOtherAnswer(str,t){
-
- $('#otherAnswerTitle').text('选择“'+t+'”所填写的内容');
- $('#setting3').prev('.mask').show().end().fadeIn();
- var arr = str.split('-');
- var html = '';
- for(var i = 0;i<arr.length;i++){
- html +='<tr ><td >'+(isEmpty(arr[i])?"无":arr[i])+'</td></tr>';
- }
- $('#otherAnswer tr').eq(0).nextAll().remove();
- $(html).insertAfter($("#otherAnswer tr").eq(0));
- setPopAlign('setting3');
- }
-
- function _ajax(url,param,flag){
- var obj = null;
- try{
- $.ajax({
- type: 'POST',
- url: url,
- data: param,
- async: flag,
- timeout : 8000,
- dataType: 'json',
- success: function(data){
- obj = data;
- }
- });
- }catch(err){
- ComWbj.artTips("提示","error","err",2,null);
- // ComWbj.alertIconNo('提示:',err,'error');
- }
- if(!flag) return obj;
- }
-
-
- function isEmpty(s){
-
- if(s == undefined){
- return true;
- }else{
- if(s == null || s == '' ||
- s == 'null' || s.length < 1
- || s == 'undefined'){
- return true;
- }
- }
- return false;
- }
|