var session = null; var SubjectId = 0; var PageSize = 10; $(function(){ $("#pagenumber").val(1); queryWJData(1); }); function queryWJData(num){ // ComWbj.openPG(); var param = {}; param.OrgId = "10011"; param.PageSize = PageSize; param.PageStart = (num-1); var d = _ajax('../survey/wtbj_querySubjectlistByOrgId.action',param,false); Page(d.totalProperty,PageSize,'pager'); initHtml(d.result); } function initHtml(d){ var html = ''; $.each(d,function(i,o) { html+= ''+getContent(o.subjecttitle,15,'...')+''; html+= ''+geWJType_CN(o.objtype)+''; html+= ''+getContent(o.createtime,16)+''; html+= ''+getContent(o.overtime,16)+''; html+= ''+o.countsample+''; var type = getTypeByState(o); if(type == 3){ html+= ''; }else html+= ''; html+= ''; if(type == 3){ html+= '编辑'; html+= '设置'; }else{ html+= '编辑'; html+= '设置'; } if(type == 1){ html+= '问卷链接'; }else html+= '问卷链接'; html+= '统计'; html+= '预览'; // html+= '复制'; html+= '删除'; html+= ''; }); $("#dataList tr").eq(0).nextAll().remove(); $(html).insertAfter($("#dataList tr").eq(0)); // ComWbj.closePG(); } function linkUrl(id){ window.location.href = 'myd-wjfb.html?SubjectId='+id; //o.href = 'http://satisfy.yihu.com/web/SurveyHome.aspx?platformType=17&sourceType=1&sourceId='+session.orgid; } function getContent(s,subsize,showText){ if(isEmpty(s)){ return ''; }else{ if(showText){ if(s.length > subsize){ return s.substring(0,subsize)+showText; }else return s; }else{ if(s.length > subsize){ return s.substring(0,subsize); }else return s; } } } function editSubject(o,id,type){ if(type == 2){ art.dialog({ id: 'testID', width: '245px', height: '109px', content: '需要停止发布该份问卷才能进行编辑,您确定吗?', lock: true, button: [{ name: '确定', callback: function () { updateSubject(id,1,false,true); o.location.href = '../survey/myd-wjbj.html?SubjectId='+id; } },{ name: '取消', callback: function () { queryWJData(1); } }] }); }else window.location.href = 'myd-wjbj.html?SubjectId='+id; } function tj(id){ window.location.href = 'myd-wjtj.html?SubjectId='+id; } function showModel(id){ window.location.href = 'myd-wjyl.html?SubjectId='+id; } function editSubjectParam(id,o){ if(judgeQuestSumBySubjectid(id)){ window.location.href = 'myd-wjsj.html?SubjectId='+id; }else{ art.dialog({ id: 'testID', width: '245px', height: '109px', content: '该问卷还未设置问题,是否先设置问题?', lock: true, button: [{ name: '确定', callback: function () { o.location.href = '../survey/myd-wjbj.html?SubjectId='+id; } },{ name: '取消', callback: function () { queryWJData(1); } }] }); } } function changeType(t,id,o){ if(t.value == 2){ changeType2(id,t.value,o); }else if(t.value == 3){ changeType3(id,t.value); }else if(t.value == 1){ changeType1(id,t.value); } } function changeType1(id,type){ art.dialog({ id: 'testID', width: '245px', height: '109px', content: '您要停止收集该问卷吗?', lock: true, button: [{ name: '确定', callback: function () { updateSubject(id,type); } },{ name: '取消', callback: function () { queryWJData(1); } }] }); } function changeType3(id,type){ art.dialog({ id: 'testID', width: '245px', height: '109px', content: '您确定要结束该问卷吗?结束后不能编辑和设置问卷', lock: true, button: [{ name: '确定', callback: function () { updateSubject(id,type); } },{ name: '取消', callback: function () { queryWJData(1); } }] }); } function changeType2(id,type,o){ if(judgeQuestSumBySubjectid(id)){ updateSubject(id,type); }else{ art.dialog({ id: 'testID', width: '245px', height: '109px', content: '该问卷还未设置问题,是否先设置问题?', lock: true, button: [{ name: '确定', callback: function () { o.location.href = '../survey/myd-wjbj.html?SubjectId='+id; } },{ name: '取消', callback: function () { queryWJData(1); } }] }); } } function deleteSubject(id,type,name){// art.dialog({ id: 'testID', width: '245px', height: '109px', content: '您要删除问卷“'+name+'”吗?注意:删除后无法恢复', lock: true, button: [{ name: '确定', callback: function () { var param = {}; param.SubjectId = id; param.Status = type; param.OperatorId="10011"; param.OperatorName="admin"; var _d = _ajax('../survey/wtbj_updateSubjectbegin.action',param,false); if(_d.Code == 10000){ // ComWbj.alertIcon('提示:','成功','succeed'); ComWbj.artTips("提示","succeed","成功",2,null); queryWJData($("#pagenumber").val()); }else{ ComWbj.artTips("提示","warning","操作异常",2,null); // ComWbj.alertIconNo('提示:','操作异常','warning'); } } },{ name: '取消' }] }); } function updateSubject(id,type,f,f1){//发布 var param = {}; param.SubjectId = id; param.Status = type; param.OperatorId="10011"; param.OperatorName="admin"; var _d = _ajax('../survey/wtbj_updateSubjectbegin.action',param,false); if(_d.Code == 10000){ if(!f1) ComWbj.artTips("提示","succeed",_d.Message,2,null); //刷新当前页面 queryWJData($("#pagenumber").val()); // ComWbj.alertIcon('提示:',_d.Message,'succeed'); }else{ ComWbj.artTips("提示","warning","添加异常",2,null); // ComWbj.alertIconNo('提示:','添加异常','warning'); } } function judgeQuestSumBySubjectid(id){ var param = {}; param.SubjectId = id; var _d = _ajax('../survey/wtbj_judgeQuestSumBySubjectid.action',param,false); if(_d.Code == 10000){ if(_d.Count > 0){ return true; }else return false; }else{ ComWbj.artTips("提示","warning","添加异常",2,null); // ComWbj.alertIconNo('提示:','添加异常','warning'); return false; } } function getOptionByState(o){ var html = ''; if(o.status == 3){ return getOptionHtml(3); }else{ if(isEmpty(o.overtype)){ return getOptionHtml(o.status); }else if(o.overtype == 3){//不限 return getOptionHtml(o.status); }else if(o.overtype == 2){//时间 if(o.overtime){ if(compareDate(o.overtime,getDateStr())){ return getOptionHtml(o.status); }else{ return getOptionHtml(3); } } return getOptionHtml(o.status); }else if(o.overtype == 1){//数量 if(Number(o.countsample) >= Number(o.quantity)){ //if(o.countsample >= o.quantity){ return getOptionHtml(3); }else{ return getOptionHtml(o.status); } }else{ return getOptionHtml(1); } } return html; } function getTypeByState(o){ if(o.status == 3){ return 3; }else{ if(isEmpty(o.overtype)){ return (o.status); }else if(o.overtype == 3){//不限 return (o.status); }else if(o.overtype == 2){//时间 if(o.overtime){ if(compareDate(o.overtime,getDateStr())){ return (o.status); }else{ return (3); } } return getOptionHtml(o.status); }else if(o.overtype == 1){//数量 if(Number(o.countsample) >= Number(o.quantity)){ //if((o.countsample) >= (o.quantity)){ return (3); }else{ return (o.status); } }else{ return (1); } } } function compareDate(d1,d2){ var start=new Date(d1.replace("-", "/").replace("-", "/")); var end=new Date(d2.replace("-", "/").replace("-", "/")); return (end'+geWJStatus_CN(i)+''; }else html += ''; } return html; } function geWJStatus_CN(type){ var name = ''; switch(type){ case 1:name = '未发布';break; case 2:name = '收集中';break; case 3:name = '已结束';break; default : name='未知';break; } return name; } function geWJType_CN(typeV){ var name = ''; if (typeV=="1") { name = '门诊患者'; }else if (typeV=="2") { name = '住院患者'; }else if (typeV=="3") { name = '手术患者'; }else if (typeV=="4") { name = '体检患者'; }else if (typeV=="5") { name = '其他'; }else{ name = '未知'; } return name; } //分页 function Page(totalcounts,pagecount,pager) { $("#"+pager).pager( { totalcounts : totalcounts, pagesize : pagecount, pagenumber : $("#pagenumber").val(), pagecount : parseInt(totalcounts/pagecount)+(totalcounts%pagecount >0?1:0), buttonClickCallback : function(al) { $("#pagenumber").val(al); queryWJData(al); } }); } 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){ return true; } } return false; }