123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- var page = 1,
- pagesize = 10;
- var $tabs = $('#tabs'),
- $panels = $('.c-panels'),//切换选项卡
- $list = $('#dest_list'),//选项卡内容
- $notext = $('#no_result_wrap'),//没有样式
- $scroll = $('#iScroll');//内容展示
-
- var teamCode,//团队code
- state="",
- diseases="",
- startDate="",
- endDate="",
- docInfo,
- self;
- function queryHeaderData(){
- sendPost("doctor/prescriptionInfo/getPrescriptionFilter",{teamCode:teamCode,patient:self.patiCode}, null, function(res){
- if(res.status == 200){
- var html = template('tag_tmpl',{data:res.data})
- $('#showHeader').html(html)
- var stateVal=0;
- $.map(res.data.states,function(o,index){
- stateVal += o.count;
- })
- $('#allStateVal').text(stateVal);
- seledtedOne();//取消优选审核中
- }
- },'get')
- }
- function queryListData(fun,text){
- var params ={
- teamCode:teamCode,
- patient:self.patiCode,
- state:state,
- diseases:diseases,
- startDate:startDate,
- endDate:endDate,
- page:page,
- size:pagesize
- }
- sendPost("/doctor/prescriptionInfo/getDoctorPrescription",params, function(){
- plus.nativeUI.closeWaiting();
- fun&&fun.call(this,false)
- mui.toast("获取数据失败!");
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- var html = template('li_tmpl',{list:_.map(res.data,function(o){
- o.jsonStr = JSON.stringify(o);
- return o;})
- })
- if(page == 1 && res.data.length==0){
- $notext.show();
- $scroll.hide();
- }else{
- $notext.hide();
- $scroll.show();
- if(res.data.length < pagesize){
- fun&&fun.call(this,true)
- }else{
- fun&&fun.call(this,false)
- }
- $list.append(html);
- }
- }else{
- fun&&fun.call(this,false)
- mui.toast("获取数据失败!");
- }
- },'get')
- }
- template.helper('setSex',function(item){
- if(item == 1){
- return '男'
- }else{
- return '女'
- }
- })
- template.helper('setPrescription',function(array){
- var arr=[];
- $.map(array,function(item,index){
- arr.push(item.name)
- })
- return arr.join(',')
- })
- template.helper('setRestTime',function(minDate,sDate){
- var now = getNowDate();
- var createDate = sDate.split(' ');
- var diff = getDays(createDate[0],now);
- if(diff<minDate){
- return '<span style="color:#17b3ec">'+(minDate-diff)+'</span>'
- }else{
- return '<span style="color:#ff4c4c">已用完</span>'
- }
- })
- //相隔几天
- function getDays(sDate,eDate){
- var oDate1;
- var oDate2;
- var iDays;
- oDate1= sDate.split("-");
- oDate2= eDate.split("-");
- var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2]);
- var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2]);
- iDays = parseInt(Math.abs(strDateE - strDateS ) / 1000 / 60 / 60 /24)
- return iDays ;
- }
- //现在时间
- function getNowDate() {
- var date = new Date();
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- var hour = date.getHours();
- var minute = date.getMinutes();
- var second = date.getSeconds();
- return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
- }
- //该上月份最后一天
- function lastDate(date){
- var arr = date.split('-');
- var year = arr[0];
- var month = arr[1]*1-1;
- if(month<1){
- month = 12;
- year = year - 1;
- }
- var day = new Date(year,month,0).getDate();
- return day;
- }
- //近一周
- function beforeWeek(date,num){
- var arr = date.split('-');
- var reduce = arr[2]*1-num;
- if(reduce>0){
- var sDate = arr[0]*1+'-'+arr[1]*1+'-'+reduce;
- return sDate;
- }else if(arr[1]*1 > 1){
- var sDate = arr[0]*1+'-'+(arr[1]*1-1)+'-'+(lastDate(date)+reduce);
- return sDate;
- }else{
- var sDate = (arr[0]*1-1)+'-12-'+(lastDate(date)+reduce);
- return sDate;
- }
- }
- //近几个月前
- function beforeMonth(date,num){
- var arr = date.split('-');
- var reduce = arr[1]*1-num;
- if(reduce>0){
- var sDate = arr[0]+'-'+reduce+'-'+arr[2];
- return sDate;
- }else{
- var sDate = (arr[0]*1-1)+'-'+(12+reduce*1)+'-'+arr[2];
- return sDate;
- }
- }
-
- function bindEvents() {
- $tabs.on('click','.sanp-flex',function() {
- var index = $(this).index(),
- $panel = $panels.find('.c-panel').eq(index);
- $panel.siblings().hide();
- if($panel.css('display')=='none') {
- $panel.show();
- } else {
- $panel.hide();
- }
- })
-
- $panels.on('click','li',function() {
- var $panel = $(this).closest('.c-panel');
- $(this).siblings().removeClass('list-selected');
- $(this).addClass('list-selected');
- $panel.hide();
- $('.j-tag').eq($panel.index()).text($(this).find('a').text())
-
- if($panel.index() ==0){ state = $(this).attr('data-id') }
- if($panel.index() ==1){ diseases = $(this).attr('data-id') }
- if($panel.index() ==2){
- var num = $(this).attr('data-id'),
- now = new Date();
- var day = now.getDate();
- var month = now.getMonth() + 1;
- var year = now.getFullYear();
- var date = year+'-'+month+'-'+day
- endDate = date;
- if(num == 1){
- startDate = beforeWeek(date,6);
- }else if(num == 2){
- startDate = beforeMonth(date,1);
- }else if(num == 3){
- startDate = beforeMonth(date,6);
- }else if(num == 4){
- startDate = beforeMonth(date,12);
- }else{
- startDate = '';
- }
- }
- reloadLessData()
- })
-
- //点击跳转
- $list.on('tap','.j-detail',function(){
- mui.openWindow({
- id: "juminxufangxiangqing",
- url: "juminxufangxiangqing.html",
- extras: {
- teamCode:teamCode,
- infoStr:$(this).attr('data-json')
- }
- })
- })
- }
- //局部刷新
- function reloadLessData(){
- plus.nativeUI.showWaiting();
- page = 1;
- $list.empty();
- mui('.mui-scroll-wrapper').pullRefresh().refresh(true);//重置
- queryListData();
- }
- //整体刷新
- function reloadPageData(){
- plus.nativeUI.showWaiting();
- page = 1;
- recoverTag()
- $list.empty();
- queryHeaderData();
- }
- function paramReset(){
- state="";diseases='';startDate='';endDate='';
- }
- //取消优选审核中
- function seledtedOne(){
- $one = $('.c-panel').eq(0).find('li');
- $one.removeClass('list-selected');
- $one.eq(0).addClass('list-selected');
- $('.j-tag').eq(0).text($one.eq(0).find('a').text())
- }
- //恢复选项卡
- function recoverTag(){
- $('.c-panel').find('li').removeClass('list-selected');
- $.map($('.c-panel'),function(o,i){
- var $li = $('.c-panel').eq(i).find('li').eq(0);
- $li.addClass('list-selected');
- $('.j-tag').eq(i).text($li.find('a').text())
- })
- seledtedOne()
- paramReset()
- }
- new Promise(function(resolve, reject) {
- mui.plusReady(function() {
- resolve(true);
- })
- }).then(function() {
- plus.nativeUI.showWaiting();
- //设置团队
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- self = plus.webview.currentWebview();
- teamCode = self.teamCode?self.teamCode:'';//可以为空
- //展示头部标题
- $('#header_title').html(self.patiName+'续方记录');
-
- //请求头部标签数据
- queryHeaderData();
- }).then(function() {
- mui.init({
- pullRefresh : {
- container:'.mui-scroll-wrapper',
- up : {
- height:50,
- contentrefresh : "正在加载...",
- contentnomore:'没有更多数据了',
- callback: function() {
- var self = this;
- page++;
- queryListData(function(value){
- setTimeout(function(){
- self.endPullupToRefresh(value);
- },500)
- },'up')
- }
- }
- }
- })
- queryListData();
- bindEvents()
- })
- window.addEventListener("refreshXufang", function(){
- reloadPageData()
- });
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
|