123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- var myScroll, teamCode, hospital, checkedNum = 0, checked = {},
- pageSize = 20, searchPage;
- mui.plusReady(function(){
- hospital = JSON.parse(plus.storage.getItem('userAgent')).hospital;
- teamCode = plus.webview.currentWebview().teamCode;
- myScroll = $('#scroller').lscroll({pullUpAction: pullUpAction, top: 60});
- getDocs(1);
-
- /**
- * 预加载查询页面
- */
- searchPage = mui.preload({
- url: "tjcy-search.html",
- });
- })
-
- template.helper('setInfo', function(v){
- return JSON.stringify(v);
- })
-
- /**
- * 获取同机构下医生列表
- */
- function getDocs(page){
- sendGet("/doctor/admin-teams/"+ teamCode +"/members/excluded",
- {org_code: hospital, size: pageSize, page: page}, null,
- function(res){
- if(res.status==200){
- if(!res.data || res.data.length==0){
- if(page == 1)
- $('#wushuju').show();
- else{
- myScroll.refresh(true);
- }
- }
- else{
- $('.doc-list').append(template('docs_tmpl', res));
- myScroll.refresh(false);
- }
- } else
- mui.toast(res.msg);
- })
- }
-
- /**
- * 滚动翻页 (自定义实现此方法)
- */
- function pullUpAction (g) {
- getDocs(g.options.page);
- }
-
- /**
- * 选择事件
- */
- $('.doc-list').on('tap', '.doc-item', function(){
- var code = $(this).toggleClass('checked').attr('data-code');
- var info = JSON.parse($(this).attr('data-info'));
-
- if($(this).hasClass('checked')){
- add(code, info);
- } else{
- remove(code);
- }
- $('.link').html('确定('+ checkedNum+'人)').toggleClass('c-ccc', checkedNum<=0);
- })
-
- function add(code, info){
- checked[code] = info;
- checkedNum++;
- }
-
- function remove(code){
- delete checked[code];
- checkedNum--;
- }
-
- $('.lin-search').on('tap', function(){
- mui.fire(searchPage, "initSearch",
- {checked: checked, checkedNum: checkedNum, teamCode: teamCode, hospital: hospital,
- openerId: plus.webview.currentWebview().opener().id});
- searchPage.show();
- })
-
- /**
- * 提交保存
- */
- function submit(){
- if(checkedNum<=0)
- return;
- var val = "";
- for(var k in checked){
- val += "," + k;
- }
- val = val.substring(1);
- plus.nativeUI.showWaiting();
- sendPost("/doctor/admin-teams/"+ teamCode +"/members",
- {doctor_code: val}, null,
- function(res){
- if(res.status == 200){
- $.each($('.doc-list .doc-item[class*="checked"]'), function(i, v) {
- $(v).parent().remove();
- });
- myScroll.refresh();
- checkedNum = 0;
- $(".link").addClass("c-ccc");
- updateParent();
- checked = {};
- plus.nativeUI.closeWaiting();
- mui.toast("添加成功");
- mui.back();
- } else {
- plus.nativeUI.closeWaiting();
- mui.toast(res.msg);
- }
- });
- }
-
- function updateParent(){
- var p = {data: checked}
- var wv = plus.webview.getWebviewById("tuanduishezhi.html");
- if(wv)
- mui.fire(wv, 'updateTeamMember', p);
-
- wv = plus.webview.getWebviewById("../../tuandui/html/tuandui.html");
- if(wv)
- mui.fire(wv, 'updateTeamMember', p);
- }
|