123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- 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+= '<tr><td>'+getContent(o.subjecttitle,15,'...')+'</td>';
- html+= '<td>'+geWJType_CN(o.objtype)+'</td>';
- html+= '<td>'+getContent(o.createtime,16)+'</td>';
- html+= '<td>'+getContent(o.overtime,16)+'</td>';
- html+= '<td>'+o.countsample+'</td>';
- var type = getTypeByState(o);
- if(type == 3){
- html+= '<td><select name="" id="'+o.subjectid+'" disabled="disabled">'+getOptionByState(o)+'</select></td>';
- }else
- html+= '<td><select name="" id="'+o.subjectid+'" onchange="changeType(this,'+o.subjectid+',window)">'+getOptionByState(o)+'</select></td>';
- html+= '<td class="td-act">';
- if(type == 3){
- html+= '<a style="color:#666666">编辑</a>';
- html+= '<a style="color:#666666">设置</a>';
- }else{
- html+= '<a href="javascript:;" onclick="editSubject(window,'+o.subjectid+','+type+')">编辑</a>';
- html+= '<a href="javascript:;" style="color:#4095ce" onclick="editSubjectParam('+o.subjectid+',window)">设置</a>';
- }
- if(type == 1){
- html+= '<a style="color:#666666" target="_blank" >问卷链接</a>';
- }else html+= '<a href="javascript:;" style="color:#4095ce" onclick="linkUrl('+o.subjectid+')">问卷链接</a>';
- html+= '<a href="javascript:;" style="color:#4095ce" onclick="tj('+o.subjectid+')">统计</a>';
- html+= '<a href="javascript:;" style="color:#4095ce" onclick="showModel('+o.subjectid+')">预览</a>';
- // html+= '<a href="javascript:;" style="color:#4095ce" onclick="copy('+o.subjectid+')">复制</a>';
- html+= '<a href="javascript:;" style="color:#4095ce" onclick="deleteSubject('+o.subjectid+',0,\''+o.subjecttitle+'\')">删除</a>';
- html+= '</td></tr>';
- });
- $("#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<start);
- }
-
- function copy(id){
-
- var param = {};
- param.SubjectId = id;
- param.OrgId = "10011";//
- param.OrgName = "admin";//
- param.Examtype = 4;//网络
- var _d = _ajax('../survey/wtbj_examCopy.action',param,false);
- if(_d.Code == 10000){
- ComWbj.artTips("提示","warning",_d.Message,2,null);
- // ComWbj.alertIconNo('提示:',_d.Message,'warning');
- queryWJData(1);
- }else{
- ComWbj.artTips("提示","warning","添加异常",2,null);
- // ComWbj.alertIconNo('提示:','添加异常','warning');
- }
- }
-
- function getDateStr(){
- var dd = new Date();
- var y = dd.getFullYear();
- var m = dd.getMonth()+1;//获取当前月份的日期
- var d = dd.getDate();
- var h = dd.getHours();
- var ms = dd.getMinutes();
- if(m < 10) m = "0"+m;
- if(d<10) d = "0"+d;
- if(h<10) h = "0"+h;
- if(ms<10) ms = "0"+ms;
- return y+"-"+m+"-"+d+' '+h+':'+ms;
- }
-
-
- function getOptionHtml(type){
- var html = '';
- var s = 'selected="selected"';
- for(var i = 1;i<=3;i++){
- if(i == type){
- html += '<option value="'+i+'" '+s+'>'+geWJStatus_CN(i)+'</option>';
- }else
- html += '<option value="'+i+'">'+geWJStatus_CN(i)+'</option>';
- }
- 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;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|