123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- var $drugsInfo = $('#drugsInfo'),
- $logs = $('#logs'),
- $receiveInfo = $('#receiveInfo'),
- $orderRecord = $('#orderRecord'),
- $xufangRecord = $('#xufangRecord'),
- $drugTakingQrCode = $('#drugTakingQrCode');
- var docInfo = {};
- // 医生角色: 3 健管师;2 全科医生
- var level;
- // 是否是团队长
- var isLeader;
- var hospital;
- var picker;
- //取药类型:1 自取 2快递配送 3健管师配送
- var dispensaryDispensaryType;
- var dispensaryDispensaryTypeName;
- //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中 , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送 41配送失败 42配送中 43配送到服务站 100配送到患者手中/已完成)
- //(-3 支付过期 -2 患者自己取消 )续方取消, -1 审核不通过 ,(0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
- // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,(40开方完成/待支付 ,41 支付失败 )待支付,
- // 50 支付成功/待配药,(60配药成功/待配送)等待领药,(61配送失败62分配健管师 65配送中,69配送到服务站)配送中,(100配送到患者手中/已完成)已完成
- var prescriptionStatus;
- var prescriptionExpressage;
- var prescriptionCode = '';
- var teamCode = '';
- // 订单所属团队团队长code
- var leadCode = '';
- var isShowQuYaoCode;
- // 续方订单(健管师)选择类型:需跟踪订单、已接收订单、团队(team),当前只有team值
- var selectType="";
- mui.plusReady(function() {
- var cur = plus.webview.currentWebview(),
- opener = cur.opener();
- var oldBack = mui.back;
- if(opener.id == "shurushuzima") {
- mui.back = backToWebviewById("home2.html")
- } else {
- mui.back = function() {
- mui.fire(opener, 'refresh');
- mui.fire(opener, 'refreshPage');
- oldBack();
- }
- }
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- level = docInfo.level;
- hospital = docInfo.hospital || plus.storage.getItem("hospital");
- isLeader = docInfo.isLeader;
- var self = plus.webview.currentWebview();
- prescriptionCode = self.prescriptionCode;
- teamCode = self.teamCode;
- isShowQuYaoCode = self.isShowQuYaoCode;
- selectType = self.selectType;
- pageInit();
- })
- template.helper('setStatusName',function(o){
- if(o == '续方申请通过'){ return '<span style="color:#18d5c5">续方申请通过</span>' }
- if(o == ' 订单已支付'){ return '<span style="color:#06bf04">订单已支付</span>' }
- if(o == '配药完成'){ return '<span style="color:#ffa54d">配药完成</span>' }
- if(o == '配送中 '){ return '<span style="color:#ff6a56">配送中</span>' }
- if(o == '药品到达服务站'){ return '<span style="color:#db6bbd">药品到达服务站</span>' }
- if(o == '续方完成'){ return '<span style="color:#17b3ec">续方完成</span>' }
- })
- function getPrescriptionFollowPromise() {
- return getReqPromise("doctor/prescriptionInfo/prescriptionFollow", {
- prescriptionCode: prescriptionCode // 处方code
- }, 'GET')
- }
- function getTeamsPromise() {
- return getReqPromise("doctor/admin-teams/teams/" + hospital+'/noTranslateAdminTeamLeaderName', {}, 'GET')
- }
- function getJGMembersPromise(teamId) {
- return getReqPromise("doctor/admin-teams/" + teamId + "/jgsmembers", {}, 'GET')
- }
- function getOrderFollowPromise() {
- return getReqPromise("doctor/prescriptionlog/orderFollow", {
- prescriptionCode: prescriptionCode // 处方code
- }, 'GET')
- }
- function expressageJGSPromise() {
- var $senderSelect = $('#senderSelect');
- var name = $senderSelect.text(),
- code = $senderSelect.attr('data-code'),
- mobile = $senderSelect.attr('data-mobile')
-
- return getReqPromise("doctor/prescription/expressage/expressageJGS", {
- code: code,
- name : name,
- mobile: mobile,
- prescriptionCode: prescriptionCode
- }, 'POST')
- }
- function showJGInfo() {
- showReceiveDrugsInfoForJG(
- $.extend({},prescriptionExpressage,{
- dispensaryDispensaryTypeName: dispensaryDispensaryTypeName
- }));
-
- $('.jg-info').show();
-
- if(isShowQuYaoCode) { // 需跟踪订单
- $drugTakingQrCode.closest('ul').show();
- } else {
- $drugTakingQrCode.closest('ul').hide();
- }
-
- if(prescriptionStatus > 61 && prescriptionStatus < 69 && selectType != 'team') { // (61配送失败62分配健管师 65配送中,69配送到服务站)配送中
- $('#confirmBtn').show()
- }
-
- if(prescriptionStatus == 69 && prescriptionExpressage.patientHospitalCode == prescriptionExpressage.acceptHospital && selectType != 'team') {
- $('#quyaoBtn').show();
- }
- }
- function showQKInfo() {
- showReceiveDrugsInfoForQK(
- $.extend({},prescriptionExpressage,{
- dispensaryDispensaryTypeName: dispensaryDispensaryTypeName
- }));
- if( level==2 && (isLeader && leadCode == docInfo.code) // 医生为当前团队团队长
- && dispensaryDispensaryType == 3 // 健管师配送
- && (prescriptionStatus == "50" || prescriptionStatus == "60") // 等待领药(待分配)
- && !prescriptionExpressage.expressageName // 还未分配配送员
- ) {
- getTeamsPromise().then(function(res) {
- initPicker(res)
- })
- } else {
- $('#senderLi').hide();
- $('#ok_btn').hide();
- }
-
- $('.qk-info').show()
- }
- // 显示订单记录
- function showOrderRecord(data) {
- var html = template('record_tmpl',data);
- $orderRecord.html(html)
- }
- // 显示药品信息
- function showDrugsInfo(drugs) {
- var html = template('drug_tmpl',{list: drugs});
- $drugsInfo.html(html)
- }
- // 显示订单跟踪
- function showLogsInfo(logs) {
- if(logs && logs.length) {
- var html = template('log_tmpl',{list: logs});
- $logs.html(html)
- } else {
- $logs.text("暂无信息")
- }
- }
- // 显示收药信息(全科医生)
- function showReceiveDrugsInfoForQK(data) {
- var html = ""
-
- if(dispensaryDispensaryType == 3) { // 健管师配送
- if(prescriptionStatus >= 50 && prescriptionStatus <= 60 && !data.expressageName) { //50 支付成功/待配药,(60配药成功/待配送)等待领药
- html = template('unassigned_tmpl',data)
- } else {
- html = template('qk_delivery_tmpl',data)
- }
- } else {
- if(dispensaryDispensaryType == 1) {
- html = template('personal_tmpl',data)
- } else if(dispensaryDispensaryType == 2){
- html = template('delivery_tmpl',data)
- }
- }
- $receiveInfo.html(html)
- }
- // 显示收药信息(健管师)
- function showReceiveDrugsInfoForJG(data) {
- var html = ""
-
- if(dispensaryDispensaryType == 3) { // 健管师配送
- html = template('jgs_delivery_tmpl',data)
- } else {
- if(dispensaryDispensaryType == 1) {
- html = template('personal_tmpl',data)
- } else if(dispensaryDispensaryType == 2){
- html = template('delivery_tmpl',data)
- }
- }
- $receiveInfo.html(html)
- }
- function initPicker(res) {
- var data = res.data;
- picker = new mui.PopPicker({
- layer: 2,
- layerNames: ["所属团队","健管师"]
- });
-
- var teams = _.map(data, function(v) {
- return {
- value: v.id + '',
- text: v.name
- }
- });
- teams = [{value:'',text:' ',mobile: ''}].concat(teams)
- picker.setData(teams)
- //picker.pickers[0].setSelectedIndex(1);
- //picker.pickers[1].setSelectedIndex(1);
- $(picker.pickers[0].holder).on('change', function(event) {
- var eventData = event.originalEvent.detail || {},
- item = eventData.item;
- if(!item.value) {
- return ;
- }
- getJGMembersPromise(item.value).then(function(res) {
- picker.pickers[1].setItems(_.map(res.data, function(v) {
- return {
- value: v.code + '',
- text: v.name,
- mobile: v.mobile
- }
- }))
- }).catch(function(e) {
- console && console.error(e)
- })
- })
- }
- function bindEvents() {
- $xufangRecord.on('click',function(){
- openWebview("xufangxiangqing.html",{
- teamCode: teamCode,
- prescriptionCode: prescriptionCode
- })
- })
- $drugTakingQrCode.on('click',function(){
- openWebview("quyaoma.html",{
- teamCode: teamCode,
- prescriptionCode: prescriptionCode
- })
- })
- $(document.body).on("click",'#ok_btn',function() {
- var $senderSelect = $('#senderSelect');
- var name = $senderSelect.text()
- if(name) {
- expressageJGSPromise().then(function(res) {
- if(res.status == 200) {
- mui.toast("分配成功!");
- pageRefresh();
- } else {
- mui.toast(res.msg);
- }
- }).catch(function(e) {
- console && console.error(e)
- })
- } else {
- mui.toast("请选择配送人员");
- }
- }).on('click', '#senderSelect', function() {
- picker.show(function(selected) {
- var $senderSelect = $('#senderSelect');
- $senderSelect.text(selected[1].text);
- $senderSelect.attr('data-code',selected[1].value);
- $senderSelect.attr('data-mobile',selected[1].mobile);
- })
- }).on('click','li[data-milno]',function() {
- var milno = $(this).attr('data-milno');
- openWebview("express-info.html",{
- prescriptionCode: prescriptionCode
- })
- }).on('click', '#confirmBtn', function() {
- openWebview("peisongma.html",{
- prescriptionCode: prescriptionCode
- })
- }).on('click', '#quyaoBtn', function() {
- openWebview("querensongda.html",{
- prescriptionCode: prescriptionCode
- })
- })
- }
- function pageInit() {
- pageRefresh();
- bindEvents();
- }
- function pageRefresh() {
- getPrescriptionFollowPromise().then(function(res) {
- var data;
- if(res.status == 200) {
- data = res.data;
- prescriptionStatus = data.prescriptionStatus;
- dispensaryDispensaryType = data.dispensaryDispensaryType;
- dispensaryDispensaryTypeName = data.dispensaryDispensaryTypeName;
- prescriptionExpressage = data.prescriptionExpressage;
- leadCode = data.leadCode;
- showOrderRecord({
- payNum: (data.prescriptionExpressage && data.prescriptionExpressage.code) || "",
- prescriptionHospital: data.prescriptionHospital||"",
- prescriptionStatusName: data.prescriptionStatusName||""
- })
- showDrugsInfo(data.prescriptionInfos)
- if(level == 3) {
- showJGInfo()
- } else if(level == 2) {
- showQKInfo()
- }
- } else {
- mui.toast(res.msg);
- }
-
- }).catch(function(e) {
- console && console.error(e)
- })
-
- getOrderFollowPromise().then(function(res) {
- if(res.status == 200) {
- showLogsInfo(res.data)
- }
- }).catch(function(e) {
- console && console.error(e)
- })
- }
- /*刷新事件*/
- window.addEventListener("updateOrderStatus", function refresh(e) {
- pageRefresh();
- });
|