toastr.options = { "closeButton": true, "positionClass": "toast-top-center" } Date.prototype.format = function(formatStr) { var str = formatStr; var Week = ['日','一','二','三','四','五','六']; str=str.replace(/yyyy|YYYY/,this.getFullYear()); str=str.replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100)); str=str.replace(/MM/,this.getMonth()>8?(this.getMonth()+1).toString():'0' + (this.getMonth()+1)); str=str.replace(/M/g,this.getMonth()+1); str=str.replace(/w|W/g,Week[this.getDay()]); str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate()); str=str.replace(/d|D/g,this.getDate()); str=str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0' + this.getHours()); str=str.replace(/h|H/g,this.getHours()); str=str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0' + this.getMinutes()); str=str.replace(/m/g,this.getMinutes()); str=str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0' + this.getSeconds()); str=str.replace(/s|S/g,this.getSeconds()); return str; } //获取链接上的参数 function getRequest() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1]); } } return theRequest; } //根据选择的tab获得开始和结束时间 function getStartEndDate(index){ var now = new Date(), sDate = new Date(); var endDate = now.format('yyyy-MM-dd'), startDate = ''; switch (index){ case '0': startDate = ''; endDate = ''; break; case '1': //近一周 sDate.setDate(now.getDate() - 7); startDate = sDate.format('yyyy-MM-dd'); break; case '2': //近一个月 sDate.setMonth(now.getMonth() -1); startDate = sDate.format('yyyy-MM-dd'); break; case '3': //近半年 sDate.setMonth(now.getMonth() - 6); startDate = sDate.format('yyyy-MM-dd'); break; case '4': //近一年 sDate.setFullYear(now.getFullYear() - 1); startDate = sDate.format('yyyy-MM-dd'); break; } return {endDate: endDate, startDate: startDate}; } //获得状态值 //续方各状态返回值 //(-3 支付过期 -2 患者自己取消 )续方取消, //-1 审核不通过 , //(0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中, //20药师审核中, //21.药师审核失败, //30 开方中/药师审核成功, //31.开方失败, //(40开方完成/待支付 ,41 支付失败 )待支付, // 50 支付成功/待配药, //(60配药成功/待配送)等待领药, //(61配送失败62分配健管师 65配送中,69配送到服务站)配送中, //(100配送到患者手中/已完成)已完成 //根据状态获得相关信息 function getStatusName(status){ var name = ""; status = status + ''; switch (status){ case '-3': name = '支付过期'; break; case '-2': name = '续方取消(居民主动取消)'; break; case '-1': name = '审核未通过'; break; case '0': case '2': case '3': case '4': case '10': name = '审核中'; break; case '20': name = '药师审核中'; break; case '21': name = '药师审核失败'; break; case '30': name = '开方中'; break; case '31': name = '开方失败'; break; case '40': name = '待支付'; break; case '41': name = '支付失败'; break; case '50': name = '配药中'; break; case '60': name = '等待领药'; break; case '61': case '62': case '65': name = '配送中'; break; case '69': name = '药品到达服务站'; break; case '100': name = '已完成'; break; default: break; } return name; } function getExpressName(type){ switch(type){ case 1: return '自取'; break; case 2: return '快递配送'; break; case 3: return '健管师配送'; break; } } function getDrugs(prescriptionInfo) { return _.map(prescriptionInfo,function(v) { return v.drugName + ' ' + (v.num || '') + (v.drugNumUnitName || '')+' ' }) } function getDaysRemaining(item) { // 最小用药天数minDrugDay -(当前时间-建立时间presCreateTime)天数 var minDrugDay = item.minDrugDay, presCreateTime = item.presCreateTime, curTime = new Date().getTime(); if(minDrugDay && presCreateTime) { var preTime = new Date(presCreateTime.replace(/-/g,'/')).getTime() var remain = Math.round(minDrugDay - parseInt(Math.abs(curTime - preTime)/(24 * 3600 * 1000))) if(remain < 0) { return '已用完' } return remain } else { return '-' } } function getReviewResultName(status) { if(status == -2) { return "删除" } else if(status == -1) { return "审核失败" } else if(status == 0) { return "待审核" } else if(status == 1) { return "审核成功" } else { return "" } } function showErrorMsg(msg) { if(top.toastr) { top.toastr.error(msg) } } function showSuccessMsg(msg) { if(top.toastr) { top.toastr.success(msg) } } function showWarningMsg(msg) { if(top.toastr) { top.toastr.warning(msg) } } function calcWorldWithTextarea() { var preVule = '' $('textarea[calcWorld]').on('input focus',function() { var num = $(this).attr('calcWorld'); var len = $(this).val().length; var value = $(this).val(); var $tip = $(this).parent().find('.wordCount'); if(num >= len) { $tip.text(len+' / '+ num) preVule = value } else { $(this).val(preVule) } }) } function isTeamLeader() { var docInfo = JSON.parse(window.localStorage.getItem('docInfo')) return docInfo.isLeader == '1'? true: false; } //设置title function setTitle(title){ var a = top.document.getElementById("pageTitle"); $(a).text(title); }