123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- var baseInfo = null, // 基本信息(包括userAgent)
- baseEnv = null;
- var $queryTab = $("#query_tab");
- var $views = $('.c-view');
- var $undoView = $('#undo_view');
- var $undoViewList = $undoView.find('#dest_list');
- var $sendCount = $("#sendCount"); //发送人的数量
- var $dest_list = $('#dest_list');
- var ServiceName = ''; //服务站的名字
- var $no_result_wrap = $('#no_result_wrap');
- var $doing_view = $('#doing_view')//获取待分配列表的id
- var self,
- docCode,
- level,
- type,
- teamCode,
- groupId,
- groupData = '',
- allOrder,
- sendCount = 0, //记录发送的数量
- ArRR = [],
- allpData=[],
- allpCode=[],
- cd,
- Arr = []; //创建一个空数组来接 服务站返回的数组
- // 获取登陆者信息
- var getBaseInfo = function() {
- var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
- self = plus.webview.currentWebview();
- docCode = self.docCode;
- level = self.level;
- type = self.type;
- teamCode = self.teamCode;
- console.log(teamCode);
- return {
- userAgent: userAgent,
- teamInfo: JSON.parse(plus.storage.getItem("teamInfo"))
- }
- },
- // 获取基础环境信息
- getBaseEnvPromise = function() {
- var env = {
- webview: plus && plus.webview.currentWebview()
- };
- return Promise.resolve().then(function(res) {
- return env;
- });
- },
- // 初始化待分配分组列表
- //获取服务站列表url:GET /doctor/prescriptionInfo/getHospitalListTitle
- initPatientGroupsList = function() {
- plus.nativeUI.closeWaiting();
- teamCode = self.teamCode;
- console.log(teamCode);
- var Url = 'doctor/prescriptionInfo/getHospitalListTitle';
- sendGet(Url, { teamCode: teamCode }, null, function(res) {
- if(res.status == 200) {
- console.log(res);
- groupData = res.data; //储存的服务站
- var html = template("groups_tmpl", { list: groupData });
- $('#groupList').empty().append(html);
- countHeight(groupData);
- changeServiceNum($('#groupList').find('li').eq(0));
- _.map(groupData, function(item) {
- Arr.push(item.hospitalCode);
- return Arr;
- })
- }
- })
- },
- //弹窗自适应高度
- countHeight = function(data) {
- var num = data.length;
- if(num > 5) {
- $('#sheet3_area').css('height', '276px');
- } else {
- $('#sheet3_area').css('height', 46 * (num + 1));
- }
- },
- changeServiceNum = function(obj) {
- // var ServiceNum;
- groupId = obj.data('id'); //储存的服务站位置
- $('#ServiceName').text(obj.find('a').text());
- if(groupId > 0) {
- // 先清空数组 再push
- allpCode = [];
- var _Url = 'doctor/prescriptionInfo/getDoctorPrescriptionExpressage';
- var str = Arr[groupId - 1];
- sendGet(_Url, { teamCode: teamCode, hospital: str, dispensaryType: 3, allocationType: 1 }, null, function(res) {
- if(res.status == 200) {
- console.log(res);
- ArRR = res.data;
- console.log(ArRR);
- _.map(ArRR,function(item){
- return allpCode.push(item.code);
- })
- cd = res.data.length;
- $('#OrderNum').text(cd);
- var html = template("num_tmpl", { data: cd });
- $('#numList').empty().append(html);
- changeOrderNum($('#numList').find('li').eq(0));
- //获取 订单的 code 为下一个页面确定传参;
- }
- })
- } else {
- var uRl = 'doctor/prescriptionInfo/getDoctorPrescriptionExpressage';
- sendGet(uRl, { teamCode: teamCode, dispensaryType: 3, allocationType: 1}, null, function(res) {
- if(res.status == 200) {
- console.log(res);
- ArRR = res.data;
- console.log(ArRR);
- _.map(ArRR,function(item){
- return allpCode.push(item.code)
- })
- cd = res.data.length;
- $('#OrderNum').text(cd);
- var html = template("num_tmpl", {data: cd});
- $('#numList').empty().append(html);
- changeOrderNum($('#numList').find('li').eq(0)); //取订单初始值
- }
- })
- }
- },
- changeOrderNum = function(obj) {
- sendCount = obj.data('num');
- $sendCount.text(sendCount); //发送订单数
- if(sendCount > 0) {
- $('#sendBtn').addClass('active'); //变色
- } else {
- $('#sendBtn').removeClass('active');
- }
- },
- // 待分配 列表的 循环遍历
- chackVal = function() {
- var uRl = 'doctor/prescriptionInfo/getDoctorPrescriptionExpressage';
- sendGet(uRl, { teamCode: teamCode, dispensaryType: 3, allocationType: 1 }, null, function(res) {
- if(res.status == 200) {
- console.log(res);
- var data = res.data
- if(data.length == 0) {
- $no_result_wrap.removeClass('c-hide');
- }
- if(data.length && data.length > 0) {
- var html = template('wait_list_temp', { list: data });
- $dest_list.empty().append(html);
- }
- }
- })
- },
- // 绑定页面事件
- bindEvents = function() {
- //tab切换事件
- // ul 里面li 的点击事件 (待分配列表的点击)
- $doing_view.on('click', 'li', function() {
- var $this = $(this),
- codep = $this.attr("data-pcode");
- console.log(codep);
- console.log(teamCode);
- mui.openWindow({
- id: "dingdangenzong",
- url: "dingdangenzong.html",
- extras: {
- prescriptionCode:codep,
- teamCode : teamCode
- }
- })
-
- });
- $queryTab.on('click', '.tab-item', function() {
- var type = $(this).attr('data-type'),
- $activeView = $('#' + type);
- $queryTab.find('.tab-item').removeClass('curr');
- $views.hide();
- $(this).addClass('curr');
- $activeView.show();
- chackVal();
- });
- $('#groupList').on('click', '.j-choose-name', function() {
- var $this = $(this);
- changeServiceNum($this);
- mui('#sheet3').popover('toggle');
- })
- $('#numList').on('click', '.j-choose-name', function() {
- var $this = $(this);
- changeOrderNum($this);
- mui('#sheet4').popover('toggle');
- })
- //为点击点击下一步 的订单 增加点击事件
- $("#sendBtn").on('click', function() {
- console.log(cd);
- if (cd!=0) {
- to_next();
- }
- })
- // 点击下一步 打开新页面 传递参数
- function to_next() {
- console.log(allpCode);
- mui.openWindow({
- id: "Distribution.html",
- url: "Distribution.html",
- extras: {
- team_id: teamCode,
- codes:allpCode
- }
- })
- }
- }
- //返回刷新
- function backParent(){
- var old_back = mui.back;
- mui.back = function() {
- if(self.opener()){
- mui.fire(self.opener(), "refreshPage");
- }
- old_back();
- }
- }
- new Promise(function(resolve, reject) {
- mui.plusReady(function() {
- resolve(true);
- });
- }).then(function() {
- // 获取基础环境信息
- return getBaseEnvPromise().then(function(env) {
- baseEnv = env;
- }).then(function() {
- // 获取登录基本信息
- baseInfo = getBaseInfo();
- // 绑定页面事件
- bindEvents();
- // initTeams();
- // 刷新事件
- backParent();
- initPatientGroupsList();
-
- })
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- })
-
- window.addEventListener('refresh', function(e){//执行刷新
- plus.webview.getWebviewById("daifenpei").reload(true);
- })
|