otherTreatment.js 7.21 KB
Newer Older
1
define(['zepto', 'medtap', 'mui', 'mui.picker'], function($, medtap, mui) { 
2
  var otherTreatment = {
zujiaozhang committed
3 4 5 6 7 8 9 10
     // 获取问卷id
    followUpId: medtap.getRequest('followUpId')||'',
    // 获取本题序号
		questionNo: medtap.getRequest('questionNo')||'',
		//  获取本题id
    questionId: medtap.getRequest('questionId')||'',	
    //  获取parentId
    parentId: medtap.getRequest('parentId')||'',
11 12
    // 修改人员id
    adminId: medtap.getRequest('adminId')||'',  
13 14
    // 
    treatmentTypePicker: '',
zujiaozhang committed
15
    // 选择有或者无
16
    flag: '',
zujiaozhang committed
17 18 19 20
    // 治疗类型
    treatmentTypeVal: '',
    // 具体疗法和药物
    specificTherapy: '',
21
    init:function(){
zujiaozhang committed
22 23 24 25 26 27 28 29 30 31
      	// 用户点击了无
			$('.noHas').click(function(){
				otherTreatment.flag=false
				console.log(otherTreatment.flag)
			})
			// 用户点击了有
			$('.has').click(function(){
				otherTreatment.flag=true
				console.log(otherTreatment.flag)
			})
32 33
       // 点击下一题
       $('.next').on('click',function(){
zujiaozhang committed
34 35 36 37 38 39 40 41
        if(otherTreatment.flag){
          otherTreatment.treatmentTypeVal = $.trim($('.input_item_treatmentType').val())
          otherTreatment.specificTherapy = $.trim($('#content_body__specificTherapy').val())
					if(otherTreatment.treatmentTypeVal==''){
						medtap.winPop('请选择治疗类型')
						return
          }
          var dataHas = {
zujiaozhang committed
42
            "adminId":otherTreatment.adminId,
zujiaozhang committed
43 44 45 46 47 48 49 50 51 52 53 54 55
            "parentId":otherTreatment.parentId,
            "questionId":otherTreatment.questionId,
						"answer":{
              "treatmentTypeVal": otherTreatment.treatmentTypeVal,
              "specificTherapy": otherTreatment.specificTherapy,
              "status":1
            },
						"questionNo":Number(otherTreatment.questionNo),
						"followUpId": otherTreatment.followUpId
          }
          otherTreatment.getNextQuestion(dataHas)
        }else{
          var dataNo = {
zujiaozhang committed
56
            "adminId":otherTreatment.adminId,
zujiaozhang committed
57 58 59 60 61 62 63 64 65 66 67 68
            "parentId":otherTreatment.parentId,
            "questionId":otherTreatment.questionId,
						"answer":{
              "treatmentTypeVal": '',
              "specificTherapy": '',
              "status":0
            },
						"questionNo":Number(otherTreatment.questionNo),
						"followUpId": otherTreatment.followUpId
          }
          otherTreatment.getNextQuestion(dataNo)
        }
69 70 71
			})
			 // 点击上一题
			 $('.pre').on('click',function(){
zujiaozhang committed
72
        otherTreatment.getPreQuestion()
73 74 75
      })
      // tab切换
      $(".tabbox li").click(function ()
76 77 78 79 80 81 82
    {
      //获取点击的元素给其添加样式,讲其兄弟元素的样式移除
      $(this).addClass("active").siblings().removeClass("active");
      //获取选中元素的下标
      var index = $(this).index();
      $(this).parent().siblings().children().eq(index).addClass("active")
      .siblings().removeClass("active");
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
    })
    otherTreatment.inintTreatmentType();
    otherTreatment.selectItems();
    },
    // 初始化drugTypesPicker
    inintTreatmentType:function(){
      otherTreatment.treatmentTypePicker = new mui.PopPicker();
      otherTreatment.treatmentTypePicker.setData([
        {value:'1',text:'药物'},
        {value:'2',text:'手术'},
        {value:'3',text:'放疗'},
        {value:'4',text:'PD-1/PD-L1'},
        {value:'5',text:'中药治疗'},
      ]);
    },
     // 点击picker后的事件注册
     selectItems:function(){
      // 点击药物类型的判断
      $('.content_body_treatmentType').click(function(){
        otherTreatment.treatmentTypePicker.show(function (Items) {
103 104
        // console.log(Items[0].text);
        // console.log(Items[0].value);
105 106 107 108 109
        $('.input_item_treatmentType').val(Items[0].text)
      })
    })
  
    },
zujiaozhang committed
110 111
    // 获取答案
    getQuestionAnswer: function(){
112
      var crm = otherTreatment.adminId==''? '':'/crm'
zujiaozhang committed
113
      medtap.submitAjax({
114
        url: 'https://gateway.medtap.cn/operation/followUp'+crm+'/getAnswer',
zujiaozhang committed
115 116 117 118 119 120
        type: 'post',
        async: false,
        contentType: 'application/json',
        data: {
          "followUpId": otherTreatment.followUpId,
          "questionId": otherTreatment.questionId,
zujiaozhang committed
121
          "adminId":otherTreatment.adminId,
zujiaozhang committed
122 123 124 125
        },
        success: function(res) {
          console.log(res) 
          if(!res.success) return winPop('获取数据失败')
126 127 128 129 130 131 132
          if(!res.content.followAnswer.answer) {
            otherTreatment.flag=true
            return
          }
         var status = res.content.followAnswer.answer.status=undefined?  '1':res.content.followAnswer.answer.status
          if(status=='1'){
            otherTreatment.flag=true
zujiaozhang committed
133 134
          $('.input_item_treatmentType').val(res.content.followAnswer.answer.treatmentTypeVal || '')
          $('#content_body__specificTherapy').val(res.content.followAnswer.answer.specificTherapy || '')
135
          }else if(status=='0'){
zujiaozhang committed
136 137 138
            otherTreatment.flag=false
            $('.noHas').addClass('active').siblings('.has').removeClass('active')
            $('.content_select_no').addClass('active').siblings('.content_select').removeClass('active')
139 140 141 142
          }else{
            otherTreatment.flag=true
            $('.input_item_treatmentType').val(res.content.followAnswer.answer.treatmentTypeVal || '')
            $('#content_body__specificTherapy').val(res.content.followAnswer.answer.specificTherapy || '')
zujiaozhang committed
143 144 145 146 147 148
          }
        }
      })
    },
      // 上一题
		getPreQuestion:function(){
149
      var crm = otherTreatment.adminId==''? '':'/crm'
zujiaozhang committed
150
			medtap.submitAjax({
151
				url: 'https://gateway.medtap.cn/operation/followUp'+crm+'/previousQuestion',
zujiaozhang committed
152 153 154 155 156 157
				type: 'post',
				async: false,
				contentType: 'application/json',
				data: {
					"questionId":otherTreatment.questionId,
					"questionNo":otherTreatment.questionNo,
zujiaozhang committed
158 159
          "followUpId":otherTreatment.followUpId,
          "adminId":otherTreatment.adminId,
zujiaozhang committed
160 161 162 163 164 165 166
				},
				success: function(res) {
          console.log(res)
          if(!res.success) return winPop('获取数据失败')
          var parentId = res.content.previousQuestion.parentId||''
					var questionId = res.content.previousQuestion.questionId||''
					var questionNo = res.content.previousQuestion.questionNo||''
167
						medtap.pushWindow('targetedTherapy.html?followUpId='+otherTreatment.followUpId+'&questionId='+questionId+'&questionNo='+questionNo+'&parentId='+parentId+'&adminId='+otherTreatment.adminId);
zujiaozhang committed
168 169 170 171 172
				}
			})
		},
    // 下一题
		getNextQuestion:function(data){
173
      var crm = otherTreatment.adminId==''? '':'/crm'
zujiaozhang committed
174
			medtap.submitAjax({
175
				url: 'https://gateway.medtap.cn/operation/followUp'+crm+'/nextQuestion',
zujiaozhang committed
176 177 178 179 180 181 182 183 184 185 186
				type: 'post',
				async: false,
				contentType: 'application/json',
				data: data,
				success: function(res) {
          console.log(res)
          if(!res.success) return winPop('获取数据失败')
            // 获取下一题的id和序号通过url传递
          var parentId = res.content.nextQuestion.parentId||''
					var questionId = res.content.nextQuestion.questionId||''
					var questionNo = res.content.nextQuestion.questionNo||''
187
					medtap.pushWindow('examination.html?followUpId='+otherTreatment.followUpId+'&questionId='+questionId+'&questionNo='+questionNo+'&parentId='+parentId+'&adminId='+otherTreatment.adminId);
zujiaozhang committed
188 189 190
				}
			})
		}
191 192
}
otherTreatment.init()
zujiaozhang committed
193
otherTreatment.getQuestionAnswer()
194
})