myd-wjlb.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. var session = null;
  2. var SubjectId = 0;
  3. var PageSize = 10;
  4. $(function(){
  5. $("#pagenumber").val(1);
  6. queryWJData(1);
  7. });
  8. function queryWJData(num){
  9. // ComWbj.openPG();
  10. var param = {};
  11. param.OrgId = "10011";
  12. param.PageSize = PageSize;
  13. param.PageStart = (num-1);
  14. var d = _ajax('../survey/wtbj_querySubjectlistByOrgId.action',param,false);
  15. Page(d.totalProperty,PageSize,'pager');
  16. initHtml(d.result);
  17. }
  18. function initHtml(d){
  19. var html = '';
  20. $.each(d,function(i,o) {
  21. html+= '<tr><td>'+getContent(o.subjecttitle,15,'...')+'</td>';
  22. html+= '<td>'+geWJType_CN(o.objtype)+'</td>';
  23. html+= '<td>'+getContent(o.createtime,16)+'</td>';
  24. html+= '<td>'+getContent(o.overtime,16)+'</td>';
  25. html+= '<td>'+o.countsample+'</td>';
  26. var type = getTypeByState(o);
  27. if(type == 3){
  28. html+= '<td><select name="" id="'+o.subjectid+'" disabled="disabled">'+getOptionByState(o)+'</select></td>';
  29. }else
  30. html+= '<td><select name="" id="'+o.subjectid+'" onchange="changeType(this,'+o.subjectid+',window)">'+getOptionByState(o)+'</select></td>';
  31. html+= '<td class="td-act">';
  32. if(type == 3){
  33. html+= '<a style="color:#666666">编辑</a>';
  34. html+= '<a style="color:#666666">设置</a>';
  35. }else{
  36. html+= '<a href="javascript:;" onclick="editSubject(window,'+o.subjectid+','+type+')">编辑</a>';
  37. html+= '<a href="javascript:;" style="color:#4095ce" onclick="editSubjectParam('+o.subjectid+',window)">设置</a>';
  38. }
  39. if(type == 1){
  40. html+= '<a style="color:#666666" target="_blank" >问卷链接</a>';
  41. }else html+= '<a href="javascript:;" style="color:#4095ce" onclick="linkUrl('+o.subjectid+')">问卷链接</a>';
  42. html+= '<a href="javascript:;" style="color:#4095ce" onclick="tj('+o.subjectid+')">统计</a>';
  43. html+= '<a href="javascript:;" style="color:#4095ce" onclick="showModel('+o.subjectid+')">预览</a>';
  44. // html+= '<a href="javascript:;" style="color:#4095ce" onclick="copy('+o.subjectid+')">复制</a>';
  45. html+= '<a href="javascript:;" style="color:#4095ce" onclick="deleteSubject('+o.subjectid+',0,\''+o.subjecttitle+'\')">删除</a>';
  46. html+= '</td></tr>';
  47. });
  48. $("#dataList tr").eq(0).nextAll().remove();
  49. $(html).insertAfter($("#dataList tr").eq(0));
  50. // ComWbj.closePG();
  51. }
  52. function linkUrl(id){
  53. window.location.href = 'myd-wjfb.html?SubjectId='+id;
  54. //o.href = 'http://satisfy.yihu.com/web/SurveyHome.aspx?platformType=17&sourceType=1&sourceId='+session.orgid;
  55. }
  56. function getContent(s,subsize,showText){
  57. if(isEmpty(s)){
  58. return '';
  59. }else{
  60. if(showText){
  61. if(s.length > subsize){
  62. return s.substring(0,subsize)+showText;
  63. }else return s;
  64. }else{
  65. if(s.length > subsize){
  66. return s.substring(0,subsize);
  67. }else return s;
  68. }
  69. }
  70. }
  71. function editSubject(o,id,type){
  72. if(type == 2){
  73. art.dialog({
  74. id: 'testID',
  75. width: '245px',
  76. height: '109px',
  77. content: '需要停止发布该份问卷才能进行编辑,您确定吗?',
  78. lock: true,
  79. button: [{
  80. name: '确定',
  81. callback: function () {
  82. updateSubject(id,1,false,true);
  83. o.location.href = '../survey/myd-wjbj.html?SubjectId='+id;
  84. }
  85. },{
  86. name: '取消',
  87. callback: function () {
  88. queryWJData(1);
  89. }
  90. }]
  91. });
  92. }else
  93. window.location.href = 'myd-wjbj.html?SubjectId='+id;
  94. }
  95. function tj(id){
  96. window.location.href = 'myd-wjtj.html?SubjectId='+id;
  97. }
  98. function showModel(id){
  99. window.location.href = 'myd-wjyl.html?SubjectId='+id;
  100. }
  101. function editSubjectParam(id,o){
  102. if(judgeQuestSumBySubjectid(id)){
  103. window.location.href = 'myd-wjsj.html?SubjectId='+id;
  104. }else{
  105. art.dialog({
  106. id: 'testID',
  107. width: '245px',
  108. height: '109px',
  109. content: '该问卷还未设置问题,是否先设置问题?',
  110. lock: true,
  111. button: [{
  112. name: '确定',
  113. callback: function () {
  114. o.location.href = '../survey/myd-wjbj.html?SubjectId='+id;
  115. }
  116. },{
  117. name: '取消',
  118. callback: function () {
  119. queryWJData(1);
  120. }
  121. }]
  122. });
  123. }
  124. }
  125. function changeType(t,id,o){
  126. if(t.value == 2){
  127. changeType2(id,t.value,o);
  128. }else if(t.value == 3){
  129. changeType3(id,t.value);
  130. }else if(t.value == 1){
  131. changeType1(id,t.value);
  132. }
  133. }
  134. function changeType1(id,type){
  135. art.dialog({
  136. id: 'testID',
  137. width: '245px',
  138. height: '109px',
  139. content: '您要停止收集该问卷吗?',
  140. lock: true,
  141. button: [{
  142. name: '确定',
  143. callback: function () {
  144. updateSubject(id,type);
  145. }
  146. },{
  147. name: '取消',
  148. callback: function () {
  149. queryWJData(1);
  150. }
  151. }]
  152. });
  153. }
  154. function changeType3(id,type){
  155. art.dialog({
  156. id: 'testID',
  157. width: '245px',
  158. height: '109px',
  159. content: '您确定要结束该问卷吗?结束后不能编辑和设置问卷',
  160. lock: true,
  161. button: [{
  162. name: '确定',
  163. callback: function () {
  164. updateSubject(id,type);
  165. }
  166. },{
  167. name: '取消',
  168. callback: function () {
  169. queryWJData(1);
  170. }
  171. }]
  172. });
  173. }
  174. function changeType2(id,type,o){
  175. if(judgeQuestSumBySubjectid(id)){
  176. updateSubject(id,type);
  177. }else{
  178. art.dialog({
  179. id: 'testID',
  180. width: '245px',
  181. height: '109px',
  182. content: '该问卷还未设置问题,是否先设置问题?',
  183. lock: true,
  184. button: [{
  185. name: '确定',
  186. callback: function () {
  187. o.location.href = '../survey/myd-wjbj.html?SubjectId='+id;
  188. }
  189. },{
  190. name: '取消',
  191. callback: function () {
  192. queryWJData(1);
  193. }
  194. }]
  195. });
  196. }
  197. }
  198. function deleteSubject(id,type,name){//
  199. art.dialog({
  200. id: 'testID',
  201. width: '245px',
  202. height: '109px',
  203. content: '您要删除问卷“'+name+'”吗?注意:删除后无法恢复',
  204. lock: true,
  205. button: [{
  206. name: '确定',
  207. callback: function () {
  208. var param = {};
  209. param.SubjectId = id;
  210. param.Status = type;
  211. param.OperatorId="10011";
  212. param.OperatorName="admin";
  213. var _d = _ajax('../survey/wtbj_updateSubjectbegin.action',param,false);
  214. if(_d.Code == 10000){
  215. // ComWbj.alertIcon('提示:','成功','succeed');
  216. ComWbj.artTips("提示","succeed","成功",2,null);
  217. queryWJData($("#pagenumber").val());
  218. }else{
  219. ComWbj.artTips("提示","warning","操作异常",2,null);
  220. // ComWbj.alertIconNo('提示:','操作异常','warning');
  221. }
  222. }
  223. },{
  224. name: '取消'
  225. }]
  226. });
  227. }
  228. function updateSubject(id,type,f,f1){//发布
  229. var param = {};
  230. param.SubjectId = id;
  231. param.Status = type;
  232. param.OperatorId="10011";
  233. param.OperatorName="admin";
  234. var _d = _ajax('../survey/wtbj_updateSubjectbegin.action',param,false);
  235. if(_d.Code == 10000){
  236. if(!f1)
  237. ComWbj.artTips("提示","succeed",_d.Message,2,null);
  238. //刷新当前页面
  239. queryWJData($("#pagenumber").val());
  240. // ComWbj.alertIcon('提示:',_d.Message,'succeed');
  241. }else{
  242. ComWbj.artTips("提示","warning","添加异常",2,null);
  243. // ComWbj.alertIconNo('提示:','添加异常','warning');
  244. }
  245. }
  246. function judgeQuestSumBySubjectid(id){
  247. var param = {};
  248. param.SubjectId = id;
  249. var _d = _ajax('../survey/wtbj_judgeQuestSumBySubjectid.action',param,false);
  250. if(_d.Code == 10000){
  251. if(_d.Count > 0){
  252. return true;
  253. }else return false;
  254. }else{
  255. ComWbj.artTips("提示","warning","添加异常",2,null);
  256. // ComWbj.alertIconNo('提示:','添加异常','warning');
  257. return false;
  258. }
  259. }
  260. function getOptionByState(o){
  261. var html = '';
  262. if(o.status == 3){
  263. return getOptionHtml(3);
  264. }else{
  265. if(isEmpty(o.overtype)){
  266. return getOptionHtml(o.status);
  267. }else if(o.overtype == 3){//不限
  268. return getOptionHtml(o.status);
  269. }else if(o.overtype == 2){//时间
  270. if(o.overtime){
  271. if(compareDate(o.overtime,getDateStr())){
  272. return getOptionHtml(o.status);
  273. }else{
  274. return getOptionHtml(3);
  275. }
  276. }
  277. return getOptionHtml(o.status);
  278. }else if(o.overtype == 1){//数量
  279. if(Number(o.countsample) >= Number(o.quantity)){
  280. //if(o.countsample >= o.quantity){
  281. return getOptionHtml(3);
  282. }else{
  283. return getOptionHtml(o.status);
  284. }
  285. }else{
  286. return getOptionHtml(1);
  287. }
  288. }
  289. return html;
  290. }
  291. function getTypeByState(o){
  292. if(o.status == 3){
  293. return 3;
  294. }else{
  295. if(isEmpty(o.overtype)){
  296. return (o.status);
  297. }else
  298. if(o.overtype == 3){//不限
  299. return (o.status);
  300. }else if(o.overtype == 2){//时间
  301. if(o.overtime){
  302. if(compareDate(o.overtime,getDateStr())){
  303. return (o.status);
  304. }else{
  305. return (3);
  306. }
  307. }
  308. return getOptionHtml(o.status);
  309. }else if(o.overtype == 1){//数量
  310. if(Number(o.countsample) >= Number(o.quantity)){
  311. //if((o.countsample) >= (o.quantity)){
  312. return (3);
  313. }else{
  314. return (o.status);
  315. }
  316. }else{
  317. return (1);
  318. }
  319. }
  320. }
  321. function compareDate(d1,d2){
  322. var start=new Date(d1.replace("-", "/").replace("-", "/"));
  323. var end=new Date(d2.replace("-", "/").replace("-", "/"));
  324. return (end<start);
  325. }
  326. function copy(id){
  327. var param = {};
  328. param.SubjectId = id;
  329. param.OrgId = "10011";//
  330. param.OrgName = "admin";//
  331. param.Examtype = 4;//网络
  332. var _d = _ajax('../survey/wtbj_examCopy.action',param,false);
  333. if(_d.Code == 10000){
  334. ComWbj.artTips("提示","warning",_d.Message,2,null);
  335. // ComWbj.alertIconNo('提示:',_d.Message,'warning');
  336. queryWJData(1);
  337. }else{
  338. ComWbj.artTips("提示","warning","添加异常",2,null);
  339. // ComWbj.alertIconNo('提示:','添加异常','warning');
  340. }
  341. }
  342. function getDateStr(){
  343. var dd = new Date();
  344. var y = dd.getFullYear();
  345. var m = dd.getMonth()+1;//获取当前月份的日期
  346. var d = dd.getDate();
  347. var h = dd.getHours();
  348. var ms = dd.getMinutes();
  349. if(m < 10) m = "0"+m;
  350. if(d<10) d = "0"+d;
  351. if(h<10) h = "0"+h;
  352. if(ms<10) ms = "0"+ms;
  353. return y+"-"+m+"-"+d+' '+h+':'+ms;
  354. }
  355. function getOptionHtml(type){
  356. var html = '';
  357. var s = 'selected="selected"';
  358. for(var i = 1;i<=3;i++){
  359. if(i == type){
  360. html += '<option value="'+i+'" '+s+'>'+geWJStatus_CN(i)+'</option>';
  361. }else
  362. html += '<option value="'+i+'">'+geWJStatus_CN(i)+'</option>';
  363. }
  364. return html;
  365. }
  366. function geWJStatus_CN(type){
  367. var name = '';
  368. switch(type){
  369. case 1:name = '未发布';break;
  370. case 2:name = '收集中';break;
  371. case 3:name = '已结束';break;
  372. default : name='未知';break;
  373. }
  374. return name;
  375. }
  376. function geWJType_CN(typeV){
  377. var name = '';
  378. if (typeV=="1") {
  379. name = '门诊患者';
  380. }else if (typeV=="2") {
  381. name = '住院患者';
  382. }else if (typeV=="3") {
  383. name = '手术患者';
  384. }else if (typeV=="4") {
  385. name = '体检患者';
  386. }else if (typeV=="5") {
  387. name = '其他';
  388. }else{
  389. name = '未知';
  390. }
  391. return name;
  392. }
  393. //分页
  394. function Page(totalcounts,pagecount,pager) {
  395. $("#"+pager).pager( {
  396. totalcounts : totalcounts,
  397. pagesize : pagecount,
  398. pagenumber : $("#pagenumber").val(),
  399. pagecount : parseInt(totalcounts/pagecount)+(totalcounts%pagecount >0?1:0),
  400. buttonClickCallback : function(al) {
  401. $("#pagenumber").val(al);
  402. queryWJData(al);
  403. }
  404. });
  405. }
  406. function _ajax(url,param,flag){
  407. var obj = null;
  408. try{
  409. $.ajax({
  410. type: 'POST',
  411. url: url,
  412. data: param,
  413. async: flag,
  414. timeout : 8000,
  415. dataType: 'json',
  416. success: function(data){
  417. obj = data;
  418. }
  419. });
  420. }catch(err){
  421. ComWbj.artTips("提示","error",err,2,null);
  422. // ComWbj.alertIconNo('提示:',err,'error');
  423. }
  424. if(!flag) return obj;
  425. }
  426. function isEmpty(s){
  427. if(s == undefined){
  428. return true;
  429. }else{
  430. if(s == null || s == '' ||
  431. s == 'null' || s.length < 1){
  432. return true;
  433. }
  434. }
  435. return false;
  436. }