123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- var page = 1,
- pagesize = 10;
- var $tabs = $('#tabs'),
- $panels = $('.c-panels'),//切换选项卡
- $list = $('#dest_list'),//选项卡内容
- $teamGroups = $('.lin-sel-group'),//团队数
- $notext = $('#no_result_wrap'),//没有样式
- $scroll = $('#iScroll');//内容展示
-
- var teamInfo,
- teamCode,//团队code
- state="",
- diseases="",
- startDate="",
- endDate="",
- docInfo;
- //现在时间
- 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 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 setCurTeamName(){
- teamCode = $('.lin-sel-group li.checked').attr('data-code');
- $('.demo-comtop h1').html(($('.lin-sel-group li.checked').attr('data-name'))+'续方管理 <label class="lin-down-arrow"></label>');
- }
- /**
- * 显示团队选择
- */
- var showGroupSel = function(e, isShow){
- isShow = isShow || $('.lin-mask:hidden').length != 0;
- $('.lin-mask').toggle(isShow);
- $('.lin-sel-group').toggle(isShow);
- }
- function queryHeaderData(){
- sendPost("doctor/prescriptionInfo/getPrescriptionFilter",{teamCode:teamCode}, function(){
- plus.nativeUI.closeWaiting();
- mui.toast("获取数据失败");
- }, function(res){
- if(res.status == 200){
- var html = template('tag_tmpl',{data:res.data})
- $('#showHeader').html(html)
- seledtedOne();//优选审核中
- var stateVal=0;
- $.map(res.data.states,function(o,index){
- stateVal += o.count;
- })
- $('#allStateVal').text(stateVal)
- queryListData();
- }
- },'get')
- }
- function queryListData(fun,text){
- var params ={
- teamCode:teamCode,
- 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(text == 'down'){
- // $list.empty();
- // fun&&fun.call(this,false)
- }else{
- 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 formatDate(data){
- var day = data.getDate();
- var month = data.getMonth() + 1;
- var year = data.getFullYear();
- return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
- }
-
- 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();
- endDate = formatDate(now);
- var myDate = new Date();
- if(num == 1){
- myDate.setDate(now.getDate()-6)
- startDate = formatDate(myDate);
- }else if(num == 2){
- myDate.setMonth(now.getMonth()-1)
- startDate = formatDate(myDate);
- }else if(num == 3){
- myDate.setMonth(now.getMonth()-6)
- startDate = formatDate(myDate);
- }else if(num == 4){
- myDate.setFullYear(now.getFullYear()-1)
- startDate = formatDate(myDate);
- }else{
- startDate = '';
- }
- }
- reloadLessData()
- })
-
- //点击跳转
- $list.on('tap','.j-detail',function(){
- mui.openWindow({
- id: "xufangxiangqing",
- url: "xufangxiangqing.html",
- extras: {
- teamCode:teamCode,
- infoStr:$(this).attr('data-json')
- }
- })
- })
-
- $('.demo-comtop h1').on('tap', showGroupSel);
-
- $teamGroups.on('click', 'li', function(){
- showGroupSel(undefined, false);
- if(!$(this).hasClass('checked')){
- $(this).addClass('checked').siblings().removeClass('checked');
- setCurTeamName();
- }
- reloadPageData()//重新加载数据
- })
-
- $('#search_btn').click(function(){
- mui.openWindow({
- id: "xufangsousuo",
- url: "xufangsousuo.html",
- waiting:{autoShow:false},
- extras: {
- teamCode:teamCode
- }
- })
- })
- }
- //局部刷新
- 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=$('.c-panel').eq(0).find('li.list-selected').attr('data-id');
- diseases='';startDate='';endDate='';
- }
- //优选审核中
- function seledtedOne(){
- $one = $('.c-panel').eq(0).find('li');
- $one.removeClass('list-selected');
- for(var i=0;i<$one.length;i++){
- if($one.eq(i).attr('data-id')=='0,2,3,4,10'){
- $one.eq(i).addClass('list-selected');
- $('.j-tag').eq(0).text($one.eq(i).find('a').text())
- state = $one.eq(i).attr('data-id')
- return
- }
- }
- }
- //恢复选项卡
- 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();
- //设置团队
- teamInfo = JSON.parse(plus.storage.getItem("teamInfo"));
- docInfo = JSON.parse(plus.storage.getItem("docInfo"))
- $('.lin-sel-group').html(template('teams_tmpl', teamInfo));
-
- var index =0;
- if(docInfo.adminTeamCode){
- for(var i=0;i<teamInfo.data.length;i++){
- if(teamInfo.data[i].id == docInfo.adminTeamCode){
- index = i;
- }
- }
- }
- $('.lin-sel-group li').eq(index).addClass('checked');
- setCurTeamName()
- //请求头部数据
- queryHeaderData();
- }).then(function() {
- mui.init({
- pullRefresh : {
- container:'.mui-scroll-wrapper',
- // down : {
- // height:50,
- // auto: false,
- // contentdown : "下拉可以刷新",
- // contentover : "释放立即刷新",
- // contentrefresh : "正在刷新...",
- // callback: function() {
- // var self = this;
- // page = 1;
- // queryListData(function(value){
- // setTimeout(function(){
- // self.endPulldownToRefresh(false);
- // mui('.mui-scroll-wrapper').pullRefresh().enablePullupToRefresh();
- // },500)
- // },'down')
- // }
- // },
- up : {
- height:50,
- contentrefresh : "正在加载...",
- contentnomore:'没有更多数据了',
- callback: function() {
- var self = this;
- page++;
- queryListData(function(value){
- setTimeout(function(){
- self.endPullupToRefresh(value);
- },500)
- },'up')
- }
- }
- }
- })
- bindEvents()
- })
- window.addEventListener("refreshXufang", function(){
- reloadPageData()
- })
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
|