123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- //创建全局变量
- var obj ,p_aggregate, arr =[],singlepatiCode,docName;
- //创建节点变量并且赋值
- var $n_list = $('.n-list'),
- $makeSure = $('#makeSure');
- //mui 初始化
- mui.init();
- //文档就绪函数执行函数
- mui.plusReady(function(){
-
- //获取基本信息
- obj = pageInfo();
-
- //获取页面信息
- var self = plus.webview.currentWebview();
-
- //获取病人集合
- p_aggregate = self.residentArr;
-
- //获取单个病人
- singlepatiCode = self.patiCode;
- healthCode = self.healthAssistant;
-
- //初始化页面
- initpage();
- //事件执行函数
- bindEvent();
- })
- function pageInfo (){
-
- userInfo = JSON.parse(plus.storage.getItem('userAgent'));
-
- accountInfo = JSON.parse(plus.storage.getItem('docInfo'));
- return {
- dlxx :userInfo,
- docxx:accountInfo
- }
- }
- function initpage(){
-
- //获取所有健管师
- var url = '/doctor/specialist/findHealthAssistantPatientCount';
- var params = {
- doctor :obj.docxx.code
- }
- sendGet(url,params,null,function(res){
-
- if (res.status == 200) {
- for (var i in res.data){
- res.data[i].photo = getImgUrl(res.data[i].photo);
-
-
- }
- $n_list.html(template('health_care_manager',{list :res.data}))
-
- //遍历健管师的code 看看是否已经授权
- var nodeArr = $('.n-list').find('li');
-
- nodeArr.each(function(){
- var jgCode = $(this).attr('data-code');
- if(jgCode == healthCode){
- $(this).find('input[name=care_manager]').attr('checked','checked');
- docName = $(this).attr('data-name')
- }
- })
- } else{
- mui.toast(res.msg)
- }
- },'GET','',true)
- }
- function bindEvent(){
- $('#makeSure').on('tap', function(){
-
- //点击确定的时候判断是否选择了健管师
- var careManagerSum = $(".n-list input[name=care_manager]:checked");
- if(!(careManagerSum.length!=0)){
- dialog({
- contentType: 'tipsbox',
- skin: 'bk-popup',
- content: '请选择健管师!',
- closeTime: 2000
- }).showModal();
- return false
- }
-
-
-
- var manageUrl = '/doctor/specialist/saveHealthAssistant';
- var params = {
- json:JSON.stringify(arr)
- };
- plus.nativeUI.showWaiting();
- sendPost(manageUrl, params, null, function(res){
- if (res.status == 200) {
- plus.nativeUI.closeWaiting();
- var wv = plus.webview.getWebviewById('huanzhe-specal.html');
- if (wv) {
- mui.fire(wv,'refresh');
- }
-
- mui.toast("分配健管师成功");
-
- var lastWeb = plus.webview.getWebviewById("dingyibiaoqian");
- if(lastWeb) {
- lastWeb.close()
- }
- mui.back()
- } else{
- mui.toast(res.msg);
- }
- })
- })
- //点击选择健管师
- $('.n-list').on('tap', '.n-list-link input' , function(){
- var $that = $(this);
- var codeMiddle = $that.parent().parent().attr('data-code');
- var nameMiddle = $that.parent().parent().attr('data-name');
-
- if(p_aggregate){
- for(var i = 0;i<p_aggregate.length;i++){
- var changeObj = {};
- var code = p_aggregate[i].patient ;
- changeObj.doctor = obj.docxx.code;
- changeObj.patient = code ;
- changeObj.healthAssistant = codeMiddle ;
- changeObj.healthAssistantName = nameMiddle ;
- arr.push(changeObj);
- }
- return arr
- }else{
-
- //判断之前是否已经授权
- if(healthCode && codeMiddle!= healthCode){
- mui.confirm('您移除了'+docName+'居民管理权限,授予了'+nameMiddle+'居民管理权限,是否继续?','提示',["继续","不了"],function(e){
- if(e.index == 0){
- var changeObj = {};
- changeObj.doctor = obj.docxx.code;
- changeObj.patient = singlepatiCode;
- changeObj.healthAssistant = codeMiddle;
- changeObj.healthAssistantName = nameMiddle;
- arr.push(changeObj);
- return arr
- }else{
- $(".n-list input[name=care_manager]").removeAttr('checked');
- }
- })
- }else{
- var changeObj = {};
- changeObj.doctor = obj.docxx.code;
- changeObj.patient = singlepatiCode;
- changeObj.healthAssistant = codeMiddle;
- changeObj.healthAssistantName = nameMiddle;
- arr.push(changeObj);
- return arr
- }
- }
-
- })
-
- }
|