123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- var baseInfo = null,// 基本信息(包括userAgent)
- baseEnv = null, // 基础环境信息(包括当前webview)
- self,
- $searchbarInput = $('.icon-sousuo-btn'),// 搜索输入框
- $sendCount = $("#sendCount");//发送数量
- var lastTeamId,
- typeId = 1, //记录排列的值
- sendCount = 0, //记录发送的数量
- groupId = 0,//记录分组的值
- groupName = '',//记录分组的名字
- groupData = '',//记录分组的所有数据
- type,//转移或分配
- docCode,//医生code
- level,//2全科 3健管
- allCount,//所有人数
- allGroupData=[],//所有组的数据信息
- allGroupCode=[];//所有组的数据code
- // 获取登录相关信息
- var getBaseInfo = function() {
- var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
- self = plus.webview.currentWebview();
- docCode = self.docCode;
- level = self.level;
- type = self.type;
- 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;
- });
- },
- // 初始化选择团队
- initTeams = function (){
- // lastTeamId = self.teamCode;
- //从消息列表过来的处理是没有团队code,能够分配健管师的只能是团队长 20171110 rl update
- if(self.teamCode){
- lastTeamId = self.teamCode;
- }else{
- var teams = baseInfo.teamInfo.data,
- len = teams.length;
- for(i=0; i<len; i++){
- if(baseInfo.userAgent.uid == teams[i].leaderCode){
- lastTeamId = teams[i].id;
- }
- }
- }
- $('#sortName').text($('#sortList').find('li').eq(typeId-1).find('a').text());//排列初始值
- $('.notice-tip').text('服务类型分组仅支持'+type+'2017年签约居民,如需为2016年签约居民进行操作,请使用健康情况、疾病类型、团队标签或所属居委会分组,或搜索居民单独'+type)
-
- },
- // 初始化画面患者分组列表
- initPatientGroupsList = function() {
- if(!lastTeamId){ return; }
- plus.nativeUI.showWaiting();
- var url = type == "分配" ? 'doctor/family_contract/findNoHealthSignFamilyHealthNum' : '/doctor/family_contract/getPatientLables' ;
- getReqPromise(url,{labelType: typeId, teamCode: lastTeamId,oldDoctorCode:docCode,level:level})
- .then(function(res) {
- if(res.status == 200) {
- groupData = res.data.patients;//储存分组的数据
- if(groupData){
- _.map(groupData,function(item){
- $.each(item.codes, function(i, v) {
- allGroupData.push(v);
- allGroupCode.push(v.code);
- })
- })
- allGroupCode = _.uniq(allGroupCode);
- allCount = allGroupCode.length;
- }
- if(typeId = 3){
- var other = _.find(groupData, function(v) {
- return v.label == "其他疾病"
- });
-
- var arr = _.filter(groupData, function(v) {
- return v.label != "其他疾病"
- }) || [];
- other && arr.push(other);
- groupData = arr;
- }
-
- var html = template("groups_tmpl", {list: groupData});
- $('#groupList').empty().append(html);
- countHeight(groupData);
- changeGroupNum($('#groupList').find('li').eq(0));
-
- mui('.mui-scroll-wrapper').scroll({
- bounce: false //是否启用回弹
- }).scrollTo(0,0,100);
-
- plus.nativeUI.closeWaiting();
- }
- if(res.status == -1){
- plus.nativeUI.closeWaiting();
- mui.toast('数据获取失败');
- }
- }).catch(function(e){ console && console.error(e) });;
- },
- countHeight = function(data){
- var num = data.length;
- if(num>5){
- $('#sheet3_area').css('height','276px');
- }else{
- $('#sheet3_area').css('height',46*(num+1));
- }
- },
- changeGroupNum = function(obj){
- var groupNum;
- groupId = obj.data('id');//储存组的位置
- $('#groupName').text(obj.find('a').text());
- //groupId=0为全部分组
- if(groupId>0){
- groupNum = groupData[groupId-1].number;
- groupName = groupData[groupId-1].label;
- }else{
- groupNum = allCount;
- groupName = '';
- }
- var html = template("num_tmpl",{data:groupNum});
- $('#numList').empty().append(html);
- changePeopleNum($('#numList').find('li').eq(0));//取人数初始值
- },
- changePeopleNum = function(obj){
- $('#peopleNum').text(obj.find('a').text());
- sendCount = obj.data('num');
- $sendCount.text(sendCount);//发送人数
- if(sendCount>0){
- $('#sendBtn').addClass('active');//变色
- }else{
- $('#sendBtn').removeClass('active');
- }
- },
- // 绑定页面事件
- bindEvents = function () {
- $('#sortList').on('click','.j-choose-name',function(){
- var $this = $(this);
- $('#sortName').text($this.find('a').text());
- typeId = $this.data('type');
- mui('#sheet2').popover('toggle');
- initPatientGroupsList();
- $sendCount.text(0);
- sendCount=0;
- groupId = 0;
- allGroupData=[];//所有组的数据信息
- allGroupCode=[];
- })
- $('#groupList').on('click','.j-choose-name',function(){
- var $this = $(this);
- changeGroupNum($this);
- mui('#sheet3').popover('toggle');
- })
-
- $('#numList').on('click','.j-choose-name',function(){
- var $this = $(this);
- changePeopleNum($this);
- mui('#sheet4').popover('toggle');
- })
-
- $searchbarInput.on('click',function() {
- mui.openWindow({
- id: "zhuanyijumin_search",
- url: "zhuanyijumin_search.html",
- extras: {
- type:type,
- docCode:docCode,
- level:level,
- lastTeamId:lastTeamId,
- }
- });
- })
-
- $("#sendBtn").on('click',function(){
- if(sendCount<=0){
- mui.toast('请至少选一个居民!');
- return;
- }
- plus.nativeUI.showWaiting();
-
- //取居民code
- var pCode=[],
- patientArr=[];
- if(groupId>0){//不是全部分组
- for(var i=0;i<sendCount;i++){
- pCode.push(groupData[groupId-1].codes[i].code)
- }
- }else{//全部分组
- for(var i=0;i<sendCount;i++){
- pCode.push(allGroupCode[i])
- }
- }
- pCode = pCode.join(',');
-
- if(type == '转移'){
- sendPost("/doctor/consult/getConsultByPatientAndDoctor", {patientCode: pCode, doctor: docCode}, null, function(res){
- var tem = {};
- if(res.length==0){
- to_next(pCode);
- } else if(res.length == sendCount){
- plus.nativeUI.closeWaiting();
- mui.confirm("对不起,您选择的居民均有尚未结束的健康咨询,无法继续转移。", "提示", ["我知道了"], function(e){})
- return;
- } else if(res.length <= 3 ){
- tem = getCanTrans(allGroupCode, res);
- plus.nativeUI.closeWaiting();
- mui.confirm("居民"+ tem.names + "尚有未结束的健康咨询,本次只可转移其余居民,是否继续?", "提示", ["继续转移", "不了,谢谢"], function(e){
- if(e.index == 0){
- to_next(tem.canPati);
- cancleSel(res);
- }
- })
- } else if(res.length < sendCount){
- tem = getCanTransByCode(allGroupCode, res);
- plus.nativeUI.closeWaiting();
- mui.confirm("选中居民中有"+ res.length + "人,尚有未结束的健康咨询,本次只可转移其余居民,是否继续?", "提示", ["继续转移", "不了,谢谢"], function(e){
- if(e.index == 0){
- to_next(tem.canPati);
- cancleSel(res);
- }
- })
- }
-
- })
- }else{
- to_next(pCode)
- return;
- }
- })
-
- function getCanTrans(allGroupCode, notCodes){
- var canPati = [];
- var names = [];
- $.each(allGroupCode, function(i, v) {
- var has = false;
- $.each(notCodes, function(n, m) {
- if(v == m){
- has = true;
- var obj = _.find(allGroupData, function(o){ return o.code== m; });
- names.push(obj.name);
- }
- });
- if(!has){
- canPati.push(v);
- }
- });
- return {canPati: canPati.join(","), names: names.join(",")}
- }
-
- function getCanTransByCode(allGroupCode, notCodes){
- var canPati = [];
- $.each(allGroupCode, function(i, v) {
- var has = false;
- $.each(notCodes, function(n, m) {
- if(v == m){
- has = true;
- }
- });
- if(!has){
- canPati.push(v);
- }
- });
- return {canPati: canPati.join(",")}
- }
-
- function cancleSel(notCodes){
- sendCount = sendCount*1 - (notCodes.length)*1
- }
-
- function to_next(pCode){
- mui.openWindow({
- id: "choose_doctor.html",
- url: "../../tuandui/html/choose_doctor.html",
- extras: {
- teamCode: lastTeamId,
- sendCount:sendCount,
- patients:pCode,
- level: level,
- docCode:docCode,
- type:type
- }
- })
- }
-
- };
- // 处理流程开始
- 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();
- initPatientGroupsList();
- })
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- })
|