123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- 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(item.status == 0 || item.status == 2 || item.status == 3 || item.status == 4 || item.status == 10 || item.status == 31) {
- 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 '<span style="color: #ff3b30;">已用完</span>';
- } else {
- return remain;
- }
- } else {
- return '<span style="color: #ff3b30;">-</span>';
- }
- } else {
- return '<span style="color: #ff3b30;">-</span>';
- }
- }
- 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);
- }
|