myd-wjtj.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. var session = null;
  2. var SubjectId = 0;
  3. var title = '';
  4. $(function(){
  5. SubjectId = QueryString('SubjectId');
  6. $('#setting3').prev('.mask').hide().end().fadeOut();
  7. queryWJTJData();
  8. });
  9. function showPie(id,data,title,is3d,height,width){//饼图
  10. $('#'+id).css('height',height);
  11. $('#'+id).css('width',width);
  12. $('#'+id).highcharts({
  13. chart: {
  14. type: 'pie',
  15. options3d: {
  16. enabled: is3d, alpha: 45, beta: 0
  17. }
  18. }, title: {
  19. text: title
  20. }, tooltip: {
  21. pointFormat: '{point.percentage:.1f}%</b>'
  22. }, plotOptions: {
  23. pie: {
  24. allowPointSelect: true, cursor: 'pointer', depth: 35,
  25. dataLabels: {
  26. enabled: true, format: '{point.name}'
  27. }
  28. }
  29. },credits: {
  30. enabled: false
  31. },exporting:{
  32. enabled:false
  33. },series: [{
  34. type: 'pie', name: title,
  35. data: data
  36. }]
  37. });
  38. }
  39. function showBar1(id,data,title,width,height){//条形图
  40. $('#'+id).css('width',width);
  41. $('#'+id).css('height',height);
  42. $('#'+id).highcharts({
  43. chart: {
  44. type: 'bar'
  45. },
  46. title: {
  47. text: ''
  48. },
  49. xAxis: {
  50. categories: title
  51. },
  52. exporting:{
  53. enabled:false
  54. },
  55. yAxis: {
  56. min: 0,
  57. title: {
  58. text: '',
  59. align: 'high'
  60. }
  61. },
  62. tooltip: {
  63. valueSuffix: '(%)'
  64. },
  65. legend: {
  66. backgroundColor: '#FFFFFF',
  67. reversed: true
  68. },
  69. plotOptions: {
  70. bar: {
  71. dataLabels: {
  72. enabled: false
  73. }
  74. }
  75. },
  76. credits: {
  77. enabled: false
  78. },
  79. series: data
  80. });
  81. }
  82. function QueryString(val) {
  83. var uri = window.location.search;
  84. var re = new RegExp("" +val+ "\=([^\&\?]*)", "ig");
  85. return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);
  86. }
  87. function queryWJTJData(){
  88. var param = {};
  89. param.SubjectId = SubjectId;
  90. var _d = _ajax('../survey/wtbj_AllStatisticaBySubjectid.action',param,false);
  91. initHtml(_d)
  92. }
  93. function downLoadFile(o,id){
  94. if(!id){
  95. id = '';
  96. }
  97. o.href = '../survey/wtbj_downLoadFile.action?SubjectId='+SubjectId+'&Questid='+id;
  98. }
  99. function detailMsg(){
  100. window.location.href = 'myd-jgtj-list.html?subjectid='+SubjectId+'&subjecttitle='+title+'&typeV=2&Status=2';
  101. }
  102. function initHtml(d){
  103. var _d = d.Result;
  104. $('#allCount').text(d.SubjectTotal);
  105. if(!isEmpty(_d) && d.SubjectTotal > 0){
  106. title = d.SubjectTitle;
  107. $('#title').text(d.SubjectTitle);
  108. for(var i = 0;i<_d.length;i++){
  109. if(parseInt(_d[i].Questtype) == 1){//选题
  110. $('#chartDiv').append(SCHtml(_d[i],i));
  111. var pieData = getPieData(_d[i]);
  112. showPie('chart'+_d[i].Questid,pieData,d.Question,false,300,'auto');
  113. }else if(parseInt(_d[i].Questtype) == 2){//多选题
  114. $('#chartDiv').append(MCHtml(_d[i],i));
  115. var barData = getBarData1(_d[i]);
  116. showBar1('chart'+_d[i].Questid,barData,getBarTitle1(_d[i]),800,300);
  117. }else if(parseInt(_d[i].Questtype) == 3){//填空题
  118. $('#chartDiv').append(TKHtml(_d[i],i));
  119. }else if(parseInt(_d[i].Questtype) == 4){//矩阵单选题
  120. var barData = getBarData2(_d[i]);
  121. var titles = getBarTitle2(_d[i]);
  122. $('#chartDiv').append(JZSHtml(getBarData3(_d[i]),_d[i].TotalSamp,titles,_d[i],i));
  123. showBar2('chart'+_d[i].Questid,barData,titles,800,300);
  124. }else if(parseInt(_d[i].Questtype) == 5){//矩阵多选选题
  125. var barData = getBarData2(_d[i]);
  126. var titles = getBarTitle2(_d[i]);
  127. $('#chartDiv').append(JZSHtml(getBarData3(_d[i]),_d[i].TotalSamp,titles,_d[i],i));
  128. showBar1('chart'+_d[i].Questid,barData,titles,800,300);
  129. }
  130. }
  131. }else{
  132. $('#divCount').empty().html('<span style="">暂无数据统计<span>');
  133. }
  134. }
  135. function getBarData2(d){
  136. var _d = new Array();
  137. var _data = d.series;
  138. for(var i = 0;i<_data.length;i++){
  139. var p = {};
  140. p.name = _data[i].Question;
  141. var _data1 = _data[i].data;
  142. if(!isEmpty(_data1)){
  143. var _arr = new Array();
  144. for(var j = 0;j<_data1.length;j++){
  145. var num = parseFloat(isNaN(_data1[j].Sum*100/d.TotalSamp)?0:_data1[j].Sum*100/d.TotalSamp).toFixed(2);
  146. _arr.push(parseFloat(num+''));
  147. }
  148. p.data = _arr;
  149. }
  150. _d.push(p);
  151. }
  152. return _d;
  153. }
  154. function getBarData3(d){
  155. var _d = new Array();
  156. var _data = d.series;
  157. for(var i = 0;i<_data.length;i++){
  158. var p = {};
  159. p.name = _data[i].Question;
  160. var _data1 = _data[i].data;
  161. if(!isEmpty(_data1)){
  162. var _arr = new Array();
  163. for(var j = 0;j<_data1.length;j++){
  164. _arr.push(_data1[j].Sum);
  165. }
  166. p.data = _arr;
  167. }
  168. _d.push(p);
  169. }
  170. return _d;
  171. }
  172. function getBarTitle2(d){
  173. var _d = new Array();
  174. var _data = d.categories;
  175. for(var i = 0;i<_data.length;i++){
  176. _d.push(_data[i].ItemCont);
  177. }
  178. return _d;
  179. }
  180. function showBar2(id,data,title,width,height){
  181. $('#'+id).css('width',width);
  182. $('#'+id).css('height',height);
  183. $('#'+id).highcharts({
  184. chart: {
  185. type: 'bar'
  186. },
  187. title: {
  188. text: ''
  189. },
  190. xAxis: {
  191. categories: title
  192. },credits:{
  193. enabled:0,text:"",href:""
  194. },
  195. yAxis: {
  196. min: 0,
  197. title: {
  198. text: ''
  199. }
  200. },
  201. exporting:{
  202. enabled:false
  203. },
  204. tooltip: {
  205. valueSuffix: '(%)'
  206. },
  207. legend: {
  208. backgroundColor: '#FFFFFF',
  209. reversed: true
  210. },
  211. plotOptions: {//重叠
  212. series: {
  213. stacking: 'normal'
  214. }
  215. },
  216. series: data
  217. });
  218. }
  219. function TKHtml(d,index){//填空题
  220. if(!isEmpty(d)){
  221. var html = '<div class="stat-sec"><div class="stat-sec-tit">';
  222. html += '<span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(填空)';
  223. html += '<a class="btn btn-gray btn-w65" onclick="downLoadFile(this,'+d.Questid+')">导出</a></div>';
  224. html += '<div class="stat-sec-con"><div class="t-center c-222 mt15">'+d.Question+'</div>';
  225. html += '<div class="mt30"></div><div class="mt30"><table class="tb tb-border" width="100%">';
  226. html += ' <tr><th>答案</th></tr>';
  227. var flag = false;
  228. for(var i = 0;i<d.SvQuestionItems.length;i++){
  229. if(i > 4){
  230. flag = true;
  231. html += '<tr style="display:none" name="showTr"><td>'+d.SvQuestionItems[i].Answer+'</td></tr>';
  232. }else html += '<tr><td>'+d.SvQuestionItems[i].Answer+'</td></tr>';
  233. }
  234. html += '<tr style="background-color:#f8f8f8;">';
  235. html += '<td class="relative" style="padding-left:20px;text-align:left">';
  236. html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span>';
  237. html += '<span class="absolute" style="right:20px; font-size:12px;">'+d.TotalSamp+'条';
  238. if(flag){
  239. html += '<a id="show'+d.Questid+'" href="javascript:;" onclick="optShowTr(this,'+d.Questid+')">展开全部</a>';
  240. html += '<a id="hide'+d.Questid+'" style="display:none" href="javascript:;" onclick="optHideTr(this,'+d.Questid+')">隐藏部份</a></span>';
  241. }else{
  242. html += '</span>';
  243. }
  244. html += '</td> </tr>';
  245. html += '</table> </div></div></div>';
  246. return html;
  247. }
  248. }
  249. function optShowTr(o,id){
  250. $('tr[name="showTr"]').each(function(i){
  251. $(this).show();
  252. })
  253. $(o).hide();
  254. $('#hide'+id).show();
  255. }
  256. function optHideTr(o,id){
  257. $('tr[name="showTr"]').each(function(i){
  258. $(this).hide();
  259. })
  260. $(o).hide();
  261. $('#show'+id).show();
  262. }
  263. function JZSHtml(dbarData,count,titles,d,index){//矩阵单选题
  264. if(!isEmpty(d)){
  265. var html = ' <div class="stat-sec"><div class="stat-sec-con">';
  266. html += '<div class="stat-sec-tit"><span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(多选题)';
  267. html += '<a class="btn btn-gray btn-w65" onclick="downLoadFile(this,'+d.Questid+')">导出</a></div>';
  268. html += '<div class="t-center c-222">'+d.Question+'</div>';
  269. html += '<div class="t-center f12 mt5">答题人数:<span class="c-org">'+d.TotalSamp+'</span></div>';
  270. html += '<div class="mt30" align="center">';
  271. html += '<div id="chart'+d.Questid+'" style=" width:400px; height:400px;"></div></div>';
  272. html += '<div class="mt30"><table class="tb tb-border" width="100%">';
  273. html += '<tr><th>选项</th>';
  274. var num = 1;
  275. for(var i = 0;i<titles.length;i++){
  276. html += '<th>'+titles[i]+'</th>';
  277. num++;
  278. }
  279. html += '</tr>';
  280. for(var i = 0;i<dbarData.length;i++){
  281. html += '<tr><th>'+dbarData[i].name+'</th>';
  282. for(var k = 0;k<dbarData[i].data.length;k++){
  283. html += '<th>'+dbarData[i].data[k]+'('+(isNaN(dbarData[i].data[k]*100/count)?0:dbarData[i].data[k]*100/count).toFixed(2)+'%)</th>';
  284. }
  285. }
  286. html += '</tr>';
  287. html += '<tr style="background-color:#f8f8f8;"><td colspan="'+num+'" style="padding-left:20px;text-align:left">';
  288. html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span></td></tr>';
  289. html += '</table> </div> </div> </div>';
  290. return html;
  291. }
  292. }
  293. function JZMHtml(dbarData,titles,d,index){//矩阵多选题
  294. if(!isEmpty(d)){
  295. var html = ' <div class="stat-sec"><div class="stat-sec-con">';
  296. html += '<div class="stat-sec-tit"><span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(多选题)';
  297. html += '<input type="button" class="btn btn-gray btn-w65" value="导出" /></div>';
  298. html += '<div class="t-center c-222">'+d.Question+'</div>';
  299. html += '<div class="t-center f12 mt5">答题人数:<span class="c-org">'+d.TotalSamp+'</span></div>';
  300. html += '<div class="mt30" align="center">';
  301. html += '<div id="chart'+d.Questid+'" style=" width:400px; height:400px;"></div></div>';
  302. html += '<div class="mt30"><table class="tb tb-border" width="100%">';
  303. html += '<tr><th>选项</th>';
  304. var num = 1;
  305. for(var i = 0;i<dbarData.length;i++){
  306. html += '<th>'+dbarData[i].name+'</th>';
  307. num++;
  308. }
  309. html += '</tr>';
  310. var n = 0;
  311. for(var i = 0;i<titles.length;i++){
  312. html += '<tr><th>'+titles[i]+'</th>';
  313. for(var j = 0;j<dbarData.length;j++){
  314. for(var k = 0;k<dbarData[j].data.length;k++){
  315. html += '<th>'+dbarData[j].data[k]+'%</th>';
  316. }
  317. j = dbarData.length;
  318. }
  319. n++;
  320. }
  321. html += '</tr>';
  322. html += '<tr style="background-color:#f8f8f8;"><td colspan="'+num+'" style="padding-left:20px;text-align:left">';
  323. html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span></td></tr>';
  324. html += '</table> </div> </div> </div>';
  325. return html;
  326. }
  327. }
  328. function MCHtml(d,index){//多选题
  329. if(!isEmpty(d)){
  330. var html = ' <div class="stat-sec"><div class="stat-sec-con">';
  331. html += '<div class="stat-sec-tit"><span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(多选题)';
  332. html += '<a class="btn btn-gray btn-w65" onclick="downLoadFile(this,'+d.Questid+')">导出</a></div>';
  333. html += '<div class="t-center c-222">'+d.Question+'</div>';
  334. html += '<div class="t-center f12 mt5">答题人数:<span class="c-org">'+d.TotalSamp+'</span></div>';
  335. html += '<div class="mt30" align="center">';
  336. html += '<div id="chart'+d.Questid+'" style=" width:400px; height:400px;"></div></div>';
  337. html += '<div class="mt30"><table class="tb tb-border" width="100%">';
  338. html += '<tr><th>选项</th><th>回复数(占比)</th></tr>';
  339. for(var i = 0;i<d.SvQuestionItems.length;i++){
  340. html += '<tr><td>'+d.SvQuestionItems[i].ItemCont
  341. +'</td><td><span class="c-org">'+d.SvQuestionItems[i].Sum
  342. +'</span>('+(isNaN(d.SvQuestionItems[i].Sum*100/d.TotalSamp)?0:d.SvQuestionItems[i].Sum*100/d.TotalSamp).toFixed(2)+'%)</td></tr>';
  343. }
  344. html += '<tr style="background-color:#f8f8f8;"><td colspan="2" style="padding-left:20px;text-align:left">';
  345. html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span></td></tr>';
  346. html += '</table> </div> </div> </div>';
  347. return html;
  348. }
  349. }
  350. function getBarData1(d){
  351. var _d = new Array();
  352. var p = {};
  353. p.name = d.Question;
  354. var t = new Array();
  355. for(var i = 0;i<d.SvQuestionItems.length;i++){
  356. var num = parseFloat(isNaN(d.SvQuestionItems[i].Sum*100/d.TotalSamp)?0:d.SvQuestionItems[i].Sum*100/d.TotalSamp).toFixed(2);
  357. t.push(parseFloat(num+''));
  358. }
  359. p.data = t;
  360. _d.push(p);
  361. return _d;
  362. }
  363. function getBarTitle1(d){
  364. var _d = new Array();
  365. for(var i = 0;i<d.SvQuestionItems.length;i++){
  366. _d.push(d.SvQuestionItems[i].ItemCont);
  367. }
  368. return _d;
  369. }
  370. function getPieData(d){
  371. var _d = new Array();
  372. for(var i = 0;i<d.SvQuestionItems.length;i++){
  373. var t = new Array();
  374. t.push(d.SvQuestionItems[i].ItemCont);
  375. t.push(parseInt(d.SvQuestionItems[i].Sum));
  376. _d.push(t);
  377. }
  378. return _d;
  379. }
  380. function SCHtml(d,index){//单选题
  381. if(!isEmpty(d)){
  382. var html = ' <div class="stat-sec"><div class="stat-sec-con">';
  383. html += '<div class="stat-sec-tit"><span class="q-num">Q'+(index+1)+'</span>'+d.Question+'(单选题)';
  384. html += '<a class="btn btn-gray btn-w65" onclick="downLoadFile(this,'+d.Questid+')">导出</a></div>';
  385. html += '<div class="t-center c-222">'+d.Question+'</div>';
  386. html += '<div class="t-center f12 mt5">答题人数:<span class="c-org">'+d.TotalSamp+'</span></div>';
  387. html += '<div class="mt30" align="center">';
  388. html += '<div id="chart'+d.Questid+'" style=" width:400px; height:400px;"></div></div>';
  389. html += '<div class="mt30"><table class="tb tb-border" width="100%">';
  390. html += '<tr><th>选项</th><th>回复数(占比)</th></tr>';
  391. for(var i = 0;i<d.SvQuestionItems.length;i++){
  392. html += '<tr><td>'+d.SvQuestionItems[i].ItemCont+'</td>';
  393. html += '<td><span class="c-org">'+d.SvQuestionItems[i].Sum+'</span>';
  394. html += '('+parseFloat(isNaN(d.SvQuestionItems[i].Sum*100/d.TotalSamp)?0:d.SvQuestionItems[i].Sum*100/d.TotalSamp).toFixed(2)+'%)';
  395. if(d.SvQuestionItems[i].OtherAnswer.length > 0){
  396. var str = '';
  397. for(var n = 0;n < d.SvQuestionItems[i].OtherAnswer.length;n++){
  398. if(str == ''){
  399. str += d.SvQuestionItems[i].OtherAnswer[n].OAnswer;
  400. }else str += '-'+d.SvQuestionItems[i].OtherAnswer[n].OAnswer;
  401. }
  402. html += '<a onclick="showOtherAnswer(\''+str+'\',\''+d.SvQuestionItems[i].ItemCont+'\')" class="absolute" style="right:16%;font-size:12px;" href="javascript:;">查看详情</a>';
  403. }
  404. html += '</td></tr>';
  405. }
  406. html += '<tr style="background-color:#f8f8f8;"><td colspan="2" style="padding-left:20px;text-align:left">';
  407. html += '<span class="c-222">答题人数:</span><span class="c-org">'+d.TotalSamp+'人</span></td></tr>';
  408. html += '</table> </div> </div> </div>';
  409. return html;
  410. }
  411. }
  412. function showOtherAnswer(str,t){
  413. $('#otherAnswerTitle').text('选择“'+t+'”所填写的内容');
  414. $('#setting3').prev('.mask').show().end().fadeIn();
  415. var arr = str.split('-');
  416. var html = '';
  417. for(var i = 0;i<arr.length;i++){
  418. html +='<tr ><td >'+(isEmpty(arr[i])?"无":arr[i])+'</td></tr>';
  419. }
  420. $('#otherAnswer tr').eq(0).nextAll().remove();
  421. $(html).insertAfter($("#otherAnswer tr").eq(0));
  422. setPopAlign('setting3');
  423. }
  424. function _ajax(url,param,flag){
  425. var obj = null;
  426. try{
  427. $.ajax({
  428. type: 'POST',
  429. url: url,
  430. data: param,
  431. async: flag,
  432. timeout : 8000,
  433. dataType: 'json',
  434. success: function(data){
  435. obj = data;
  436. }
  437. });
  438. }catch(err){
  439. ComWbj.artTips("提示","error","err",2,null);
  440. // ComWbj.alertIconNo('提示:',err,'error');
  441. }
  442. if(!flag) return obj;
  443. }
  444. function isEmpty(s){
  445. if(s == undefined){
  446. return true;
  447. }else{
  448. if(s == null || s == '' ||
  449. s == 'null' || s.length < 1
  450. || s == 'undefined'){
  451. return true;
  452. }
  453. }
  454. return false;
  455. }