123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- var page = 1,
- pagesize = 10;
- var $tabs = $('#tabs'),
- $unassignedLink = $('#unassignedLink'), // 待分配配送员链接
- $unassignedNum = $('#unassigned_num'), // 待分配配送员数
- $panels = $('.c-panels'),//切换选项卡
- $list = $('#dest_list'),//选项卡内容
- $teamGroups = $('.lin-sel-group'),//团队数
- $notext = $('#no_result_wrap'),//没有样式
- $scroll = $('#iScroll');//内容展示
-
- var teamInfo,
- docInfo,
- teamCode,//团队code
- state="",
- dispensaryType="",
- startDate="",
- endDate="";
- 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/getPrescriptionExpressageAsdoctorFilter",{}, null, function(res){
- if(res.status == 200){
- var html = template('tag_tmpl',{data:res.data})
- $('#showHeader').html(html)
- }
- },'get')
- }
- function queryListData(fun,text){
- var params ={
- teamCode:teamCode,
- state:state,
- dispensaryType:dispensaryType,
- startDate:startDate,
- endDate:endDate,
- page:page,
- size:pagesize
- }
- sendPost("/doctor/prescriptionInfo/getDoctorPrescriptionExpressage",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'){
- // $('#dest_list').empty();
- // fun&&fun.call(this);
- }else{
- if(res.data.length < pagesize){
- fun&&fun.call(this,true)
- }else{
- fun&&fun.call(this,false)
- }
- }
- $('#dest_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('dispensaryTypeName',function(type){
- if(type == 1){
- return '自取'
- } else if(type == 2){
- return '快递配送'
- } else if(type == 3){
- return '健管师配送'
- }
- return ''
- })
- //该上月份最后一天
- 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 showUnssignedLink() {
- showUnssignedNum();
- var teamCode = $('.lin-sel-group li.checked').attr('data-code');
- if(docInfo.adminTeamCode == teamCode && docInfo.isLeader == "1") {
- $unassignedLink.show();
- $scroll.css('top','135px')
- } else {
- $unassignedLink.hide();
- $scroll.css('top','80px')
- }
- }
- // 显示待分配配送员数
- function showUnssignedNum() {
- var teamCode = $('.lin-sel-group li.checked').attr('data-code');
- sendPost("/doctor/prescriptionInfo/getCountExpressage",{
- teamCode: teamCode
- }, function(){
- mui.toast("获取数据失败!");
- }, function(res){
- if(res.status == 200){
- $unassignedNum.text(res.data.count)
- }else{
- mui.toast("获取数据失败!");
- }
- },'get')
- }
- 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){ dispensaryType = $(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()
- })
-
- //点击跳转
- $('#dest_list').on('tap','li',function(){
- var data = JSON.parse($(this).attr('data-json')),
- prescriptionCode = data.code;
- mui.openWindow({
- id: "dingdangenzong",
- url: "dingdangenzong.html",
- extras: {
- teamCode: teamCode,
- prescriptionCode: prescriptionCode
- }
- })
- })
-
- $unassignedLink.on('tap', function() {
- mui.openWindow({
- id: "daifenpei",
- url: "daifenpei.html",
- extras: {
- teamCode: teamCode
- }
- })
- });
-
- $('.demo-comtop h1').on('tap', showGroupSel);
-
- $('.lin-mask').on('tap', showGroupSel);
-
- $teamGroups.on('click', 'li', function(){
- showGroupSel(undefined, false);
- if(!$(this).hasClass('checked')){
- $(this).addClass('checked').siblings().removeClass('checked');
- setCurTeamName();
- showUnssignedLink();
- }
- reloadPageData()//重新加载数据
- })
-
- $('#search_btn').click(function(){
- mui.openWindow({
- id: "searchxufangdingdan",
- url: "searchxufangdingdan.html",
- extras: {
- teamCode:teamCode
- }
- })
- })
- }
- //局部刷新
- function reloadLessData(){
- plus.nativeUI.showWaiting();
- page = 1;
- $('#dest_list').empty();
- mui('.mui-scroll-wrapper').pullRefresh().refresh(true);//重置
- queryListData();
- }
- //整体刷新
- function reloadPageData(){
- plus.nativeUI.showWaiting();
- page = 1;
- recoverTag()
- $('#dest_list').empty();
- queryListData();
- }
- function paramReset(){
- state='';dispensaryType='';startDate='';endDate='';
- }
- //恢复选项卡
- 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())
- })
- 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;
- for(var i=0;i<teamInfo.data.length;i++){
- // 默认显示其担任团队长的团队列表
- if(teamInfo.data[i].leaderCode == docInfo.adminTeamCode){
- index = i;
- }
- }
- $('.lin-sel-group li').eq(index).addClass('checked');
- setCurTeamName();
- showUnssignedLink();
- //请求头部数据
- 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')
- }
- }
- }
- })
- queryListData();
- bindEvents()
- })
- window.addEventListener("refreshPage", function(e) {
- plus.webview.getWebviewById("xufangdingdan").reload(true);
- });
|