123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- var listPage = function(){
- var d = dialog({contentType:'load', skin:'bk-popup'});
- //设置变量标记选项的值
- var deseaseType = 0,
- startDate = '',
- endDate = '';
-
- var page = 0,
- pagesize = 10,
- recipeNo = 0; // 记录
-
- function pageInit(){
- getPrescriptionList(true);
- initScroller();
- bindEvents();
- }
-
- function getPrescriptionList(isInit){
- d.show();
- if(isInit){
- page = 0;
- //mui(".mui-scroll-wrapper").pullRefresh().scrollTo(0, 0, 1);
- }
- var url = 'patient/prescriptionInfo/getRecipeMasterList',
- params = {
- type: 1, //type: 1-查询处方,2-我的续方, 3-续方记录
- isRenewal: 1, //1: 可续方,2: 无过滤
- diagnosisCode: deseaseType, //0: 全部,1:高血压,2: 糖尿病
- startDate: startDate?startDate+' 00:00:00':startDate,
- endDate: endDate?endDate+' 23:59:59':endDate,
- page: page,
- size: pagesize
- // recipeNo:recipeNo
- };
- sendPost(url, params, 'json', 'get', queryFailed, function(res){
- if(res.status == 200){
- d.close();
- if(res.data.list.length >0){
- $("#next").removeClass("disabled")
- $(".mui-scroll-wrapper").show();
- $(".div-no-info").hide();
- var list = _.map(res.data.list, function(o){
- o.jsonStr = JSON.stringify(o);
- var canXF = getXFStatus(o.prescriptionDt, o.createTime);
- o.canXF = canXF;
- recipeNo = o.code;
- return o;
- });
- var html = template("prescription_tmp", {list: list});
-
- if(!isInit){
- $("#prescriptionList").append(html);
- }else{
- $("#prescriptionList").empty().append(html);
- }
-
- if(res.data.list.length < pagesize){
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }else{
- page ++;
- }
- }else{
- if(isInit){ //初始请求,无数据
- $(".mui-scroll-wrapper").hide();
- $(".div-no-info").show();
- $("#next").hide();
- }else{
- $("#next").addClass("disabled");
- }
- }
- }else{
- queryFailed(res);
- }
- });
- }
-
- function getXFStatus(arr, date){
- var isXFDesease = true,
- statusName = '',
- canXF = false;
- if(arr){
- for(i=0; i<arr.length; i++){
- var item = arr[i];
- //HP0093 - 高血压 , HP0047 - 糖尿病
- if((item.healthProblem != 'HP0093') && (item.healthProblem != 'HP0047')){
- isXFDesease = false;
- break;
- }
- }
- if(isXFDesease){
- //判断时间是否是在6个月内的
- // var d = new Date(date),
- // now = new Date();
- // now.setMonth(now.getMonth() - 2);
- //
- // if(d > now){ //6个月内的时间
- statusName = '续方';
- canXF = true;
- // }
- }
- }
- return canXF;
- }
-
- /**
- * 根据选择的时间类型获取开始和结束时间
- */
- function getDate(type){
- var now = new Date(),
- d = new Date();
- switch (type){
- case 'all':
- startDate = '';
- endDate = "";
- break;
- case 'week':
- d.setDate(d.getDate() - 6);
- break;
- case 'month':
- d.setMonth(d.getMonth() - 1);
- d.setDate(d.getDate() + 1);
- break;
- case 'half-year':
- d.setMonth(d.getMonth() - 2);
- d.setDate(d.getDate() + 1);
- break;
- }
-
- if(type != 'all'){
- endDate = now.Format('yyyy-MM-dd');
- startDate = d.Format('yyyy-MM-dd');
- }
- }
-
- function bindEvents(){
- $(".c-lab-mor").on("click","li",function(){
- var index = $(this).index();
- $(".c-lab-mor li i").removeClass("active");
- $(this).find("i").addClass("active");
- if(index==0){//所有诊断
- $(".div-diagnosis").show();
- $(".div-dates").hide();
- }else{
- $(".div-diagnosis").hide();
- $(".div-dates").show();
- }
- $(".modal-overlay").show();
- });
-
- //所有诊断-tab点击事件
- $(".div-diagnosis").on("click","li",function(){
- $(".div-diagnosis li").removeClass("active");
- $(this).addClass("active");
- $(".c-lab-mor li i").removeClass("active");
- $(".modal-overlay").hide();
- $(".div-diagnosis").hide();
- $(".c-lab-mor li").eq(0).find("span").html($(this).find("label").html());
-
- //TODO 搜索数据处理
- deseaseType = $(this).attr("data-val");
- page = 1;
- getPrescriptionList(true);
- });
- //全部时间-tab点击事件
- $(".div-dates").on("click","li",function(){
- $(".div-dates li").removeClass("active");
- $(this).addClass("active");
- $(".c-lab-mor li i").removeClass("active");
- $(".modal-overlay").hide();
- $(".div-dates").hide();
- $(".c-lab-mor li").eq(1).find("span").html($(this).find("label").html());
-
- //TODO 搜索数据处理
- var value = $(this).attr("data-val");
- getDate(value);
- page = 1;
- getPrescriptionList(true);
- });
- //点击遮罩事件
- $(".modal-overlay").on("click",function(){
- $(".div-diagnosis").hide();
- $(".div-dates").hide();
- $(".c-lab-mor li i").removeClass("active");
- $(".modal-overlay").hide();
- });
- //申请续方按钮事件
- $(".ul-consultation").on("tap",".div-sqxf-btn",function(e){
- e.stopPropagation();
- var $this = $(this);
- if($this.hasClass('appy-btn')){
- var code = $this.closest("li").attr("data-code");
- window.localStorage.setItem("prescriptionCode", code);
- viewApi.back();
- }else{
- return false;
- }
- })
- //域跳转处方详情页
- .on("tap","li",function(){
- var code = $(this).attr("data-code");
- window.location.href = "../../prescription/html/prescription_detail.html?code="+code;
- });
-
- //显示下一条数据
- $("#next").on('tap', function(){
- if($(this).hasClass("disabled")){
- return false;
- }
- getPrescriptionList(false);
- })
- }
-
- function initScroller(){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
- mui(".mui-scroll-wrapper").pullRefresh({
- down: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- getPrescriptionList(true);
- self.endPulldownToRefresh();
- }, 1000);
- }
- },
- up: {
- callback: function() {
- var self = this;
- setTimeout(function(){
- getPrescriptionList();
- self.endPullupToRefresh();
- }, 1000);
- }
- }
- });
- }
-
- function queryFailed(res){
- d.close();
- if(res && res.msg) {
- dialog({
- contentType: 'tipsbox',
- skin: 'bk-popup',
- content: res.msg
- }).show();
- } else {
- dialog({
- contentType: 'tipsbox',
- skin: 'bk-popup',
- content: '加载失败'
- }).show();
- }
- }
-
- return {
- initPage: pageInit
- };
- }
|