xiaoxichuli.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. var msgId, patiCode;
  2. var groupCode = [],
  3. groupName = [],
  4. healthManagementCode=[],
  5. healthManagementName=[],
  6. diseaseCode=[],
  7. diseaseName=[];
  8. var type, self, signStatus;
  9. var hzCode=""//患者CODE
  10. var signType=1
  11. var signedData = null;
  12. //添加服务类型的数据
  13. var currService;
  14. var refuseReason = "";//拒绝签约原因
  15. // 居民标签
  16. var $juminLabels = $('#jumin_labels input[data-val=jumin_labels]');
  17. var docInfo;
  18. mui.init();
  19. mui.plusReady(function() {
  20. plus.nativeUI.showWaiting();
  21. self = plus.webview.currentWebview();
  22. msgId = self.msgId;
  23. patiCode = self.patiCode;
  24. type = self.type;
  25. signStatus = self.signStatus;
  26. var status = self.status;
  27. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  28. initPage();
  29. bindEvents();
  30. });
  31. function initPage(){
  32. console.log("signStatus = "+signStatus);
  33. if(signStatus == 1 || signStatus == 8 || signStatus == 9) { //签约
  34. $(".demo-comtop").find("h1").text("签约处理");
  35. $('#btn_refuse').text("拒绝签约");
  36. $('#btn_agree').text("同意签约");
  37. var promise1 = getReqPromises([{url:"/doctor/family_contract/patient_signing",data:{patient: patiCode}},
  38. // {url:"/doctor/patient/disease_sanshi",data:{patient: patiCode}},
  39. // {url:"/doctor/family_contract/getSanshiSign",data:{patientCode:patiCode}},
  40. {url:"/doctor/admin-teams/team/"+ docInfo.code +"/teamsLimit",data:{},reqType: 'GET'},//获取签约团队
  41. {url:"/common/getDictByDictName?name=SIGN_EXPENSES",data:{},reqType: 'GET'},//设置政府补贴
  42. {url:"/doctor/sign/getSigndict", data:{}, reqType: "GET"}]);//获取服务团队的信息
  43. console.log(promise1);
  44. return promise1.then(function(datas){
  45. console.log(datas);
  46. var data0 = datas[0],
  47. data1 = datas[1],
  48. data2 = datas[2],
  49. data3 = datas[3];
  50. // data4 = datas[4];
  51. // data5 = datas[5];
  52. // setApplyData(data0,data1);
  53. // initData(1,data2);
  54. // getQytd(data3);
  55. // setExpenses(data4);
  56. // fillServiceDropdown(data5);
  57. setApplyData(data0);
  58. getQytd(data1);
  59. setExpenses(data2);
  60. fillServiceDropdown(data3);
  61. //改签获得历史签约团队
  62. if(signStatus == 9){
  63. getHisSignInfo();
  64. }
  65. $("#div_qianyue").removeClass("c-hide");
  66. $("#div_jieyue").addClass("c-hide");
  67. $('.c-main').removeClass('c-hide');
  68. plus.nativeUI.closeWaiting();
  69. }).catch(function(e) {
  70. console && console.error(e);
  71. });
  72. } else if(signStatus == 4) { //解约
  73. $(".demo-comtop").find("h1").text("解约处理");
  74. $('#btn_refuse').text("拒绝解约");
  75. $('#btn_agree').text("同意解约");
  76. if(self.reason) {
  77. $("#div_jieyue").find("textarea").val(self.reason);
  78. } else {
  79. $("#div_jieyue").find("textarea").attr("placeholder", "该居民无说明解约理由")
  80. }
  81. // 解约申请时间
  82. var applyUnsignDate = "";
  83. var promise2 = getReqPromises([{url:"/doctor/patient_group/patient",data:{code: patiCode}},//居民信息
  84. {url:"/doctor/family_contract/getSanshiSign",data:{patientCode:patiCode}},
  85. {url:"/doctor/admin-teams/team/"+ docInfo.code +"/teamsLimit",data:{},reqType: 'GET'},
  86. {url:"/common/getDictByDictName?name=SIGN_EXPENSES",data:{},reqType: 'GET'},
  87. {url:"/doctor/sign/getSigndict", data:{}, reqType: "GET"}]);//获取服务团队的信息
  88. return promise2.then(function(datas){
  89. var data0 = datas[0],
  90. data1 = datas[1],
  91. data2 = datas[2],
  92. data3 = datas[3];
  93. data4 = datas[4];
  94. if(data0.status == 200) {
  95. hzCode=data0.data.code;
  96. initData(2,data1);
  97. applyUnsignDate = data0.data.jtSign.applyUnsignDate;
  98. $("#pati_info").html(template("pati_info_tmpl", data0.data));
  99. var applySurrDate = applyUnsignDate.slice(0,16);
  100. $("#app_date").text("申请解约时间:"+applySurrDate);
  101. $('.c-main').removeClass('c-hide');
  102. }
  103. getQytd(data2);
  104. setExpenses(data3);
  105. fillServiceDropdown(data4);
  106. $("#div_jieyue").removeClass("c-hide");
  107. $("#div_qianyue").addClass("c-hide");
  108. plus.nativeUI.closeWaiting();
  109. })
  110. }
  111. }
  112. //获得历史签约信息
  113. function getHisSignInfo(){
  114. var url = "/doctor/sign/getPatientSignLogInfo",
  115. params = {patient:patiCode};
  116. sendPost(url, params, null, function(res){
  117. if(res.status == 200){
  118. var data = res.data,
  119. arr = [];
  120. if(data.oldHospitalName){
  121. arr.push(data.oldHospitalName);
  122. }
  123. if(data.oldTeamName){
  124. arr.push(data.oldTeamName);
  125. }
  126. if(data.OldLeaderName){
  127. arr.push(data.OldLeaderName);
  128. }
  129. if(data.OldDoctorName){
  130. arr.push(data.OldDoctorName);
  131. }
  132. if(data.OldHealthDoctorName){
  133. arr.push(data.OldHealthDoctorName);
  134. }
  135. var text = arr.join(",");
  136. $("#teamInfo").text(text);
  137. $("#hisInfo").show();
  138. }
  139. });
  140. }
  141. function setApplyData (data1,data2) {
  142. if(data1){
  143. if(data1.status == 200) {
  144. var data=data1.data,
  145. appDate = "";
  146. if(signStatus == 1 || signStatus == 8 || signStatus == 9) {
  147. console.log(data);
  148. appDate = data.applyDate ? data.applyDate.slice(0,16): "";
  149. $("#pati_info").html(template("pati_info_tmpl", data1.data));
  150. $("#app_date").text("申请签约时间:"+appDate);
  151. signedData = data1.data;
  152. }
  153. }else{
  154. mui.toast(res.msg);
  155. }
  156. }
  157. }
  158. //获取政府补贴数据
  159. function setExpenses(res){
  160. var expensesCode=[];
  161. var expensesName=[];
  162. if(res.status == 200) {
  163. var expensesList = res.list;
  164. for(var i = 0; i < expensesList.length; i++) {
  165. expensesCode.push(expensesList[i].code);
  166. expensesName.push(expensesList[i].value);
  167. }
  168. activExpensesM(expensesCode,expensesName);
  169. };
  170. }
  171. //设置政府补贴下拉框
  172. function activExpensesM(expensesCodes,expensesNames) {
  173. var $expensesInput = $('#li_expenses input[data-val=expenses]');
  174. $expensesInput.mobiscroll({
  175. theme: 'ios',
  176. lang: 'zh',
  177. customWheels: true,
  178. wheels: [
  179. [{
  180. keys: [expensesCodes[1],expensesCodes[0],expensesCodes[3],expensesCodes[2]],
  181. values: [expensesNames[1],expensesNames[0],expensesNames[3],expensesNames[2]]
  182. }]
  183. ],
  184. onSelect: function(valueText, inst) {
  185. var dd = eval("[" + valueText + "]");
  186. var name=dd[0].values
  187. $(this).val(name);
  188. currExpenses = dd[0].keys;
  189. $('#li_expenses input[data-val=expenses]').attr("data-code",currExpenses);
  190. }
  191. });
  192. // 获取政府补贴下拉框mibiscroll实例
  193. var expensesMobiscroll = $expensesInput.mobiscroll('getInst');
  194. var valueText = "{keys:'"+expensesCodes[0]+"',values:'"+expensesNames[0]+"'}";
  195. expensesMobiscroll.setVal([valueText]);
  196. $expensesInput.val(expensesNames[0]);
  197. $expensesInput.attr("data-code",expensesCodes[0]);
  198. }
  199. //普通 老年 高血 糖尿 孕妇 儿童 贫困 计生 重性 残疾 结核
  200. function filterSer(name){
  201. var $li = $('.dw-bf').find('div.dw-li');
  202. $li.addClass('dw-v');
  203. var nameArr = name.split(',');
  204. $.map(nameArr,function(item,index){
  205. if(item.trim() == '普通人群'){
  206. var arr = [2,3,6,7,8,9,10]
  207. $.map(arr,function(it,index){
  208. $li.eq(it).removeClass('dw-v')
  209. })
  210. }
  211. if(item.trim() == '老年人'){
  212. var arr = [4,5]
  213. $.map(arr,function(it,index){
  214. $li.eq(it).removeClass('dw-v')
  215. })
  216. }
  217. if(item.trim() == '高血压' ||item.trim() == '糖尿病'||item.trim() == '贫困人口'||item.trim() == '计生特殊人群'||item.trim() == '重性精神疾病'||item.trim() == '残疾人'||item.trim() == '结核病' ){
  218. var arr = [0]
  219. $.map(arr,function(it,index){
  220. $li.eq(it).removeClass('dw-v')
  221. })
  222. }
  223. if(item.trim() == '0-6岁儿童'){
  224. var arr = [1,4]
  225. $.map(arr,function(it,index){
  226. $li.eq(it).removeClass('dw-v')
  227. })
  228. }
  229. if(item.trim() == '孕产妇'){
  230. var arr = [1,5]
  231. $.map(arr,function(it,index){
  232. $li.eq(it).removeClass('dw-v')
  233. })
  234. }
  235. })
  236. }
  237. //设置服务类型下拉
  238. function fillServiceDropdown(data){
  239. var $serviceSel = $('#selFuwu'),
  240. data = data.data,
  241. html="";
  242. for(i=0; i<data.length; i++){
  243. html += '<option value="'+data[i].code+'">'+data[i].name+'</option>'
  244. }
  245. $serviceSel.html(html);
  246. $serviceSel.mobiscroll().select({
  247. theme: 'ios',
  248. lang: 'zh',
  249. display: 'bottom',
  250. rows:6,
  251. placeholder:'请选择服务类型',
  252. onSelect: function ( valueText, inst) {
  253. // var vArr = valueText.split(',');
  254. //判断服务类型是否变更
  255. $juminLabels.val("").attr("data-code",JSON.stringify({health: "",disease: "", custom: "" }));
  256. currService = inst._tempValue?inst._tempValue.join(','):'';
  257. },
  258. onChange: function (event, inst) {
  259. filterSer(event)
  260. },
  261. onShow: function (event, inst) {
  262. filterSer(inst)
  263. }
  264. })
  265. }
  266. function validForm(){
  267. if(!$('#agreement_checkbox').hasClass('checked')) {
  268. mui.toast("您还未接受签约协议");
  269. return false;
  270. }
  271. if(!$.trim($doctorQytdInput.attr("data-code"))){
  272. mui.toast("请选择签约团队!");
  273. return false;
  274. }
  275. if($("#healthManagement input").val()==""){
  276. mui.toast("请选择健康管理师!");
  277. $("#btn_agree").attr("disabled",false);
  278. return false;
  279. }
  280. if(!currService){
  281. mui.toast("请选择服务类型!");
  282. return false;
  283. }
  284. var labelObj = $juminLabels.attr("data-code");
  285. labelObj = JSON.parse(labelObj);
  286. if(!labelObj.health) {
  287. mui.toast("请选择居民标签!");
  288. return false;
  289. }
  290. return true;
  291. }
  292. //分组选择
  293. var currGroupCode;//分组 不要了!
  294. var currdiseaseCode;// 病种类型CODE
  295. var currfamilyDoctorCode;//家庭医生CODE
  296. var currfamilyDoctorName;//家庭医生名字
  297. var currHealthManagement;
  298. var currHealthManagementname;
  299. function bindEvents(){
  300. //选择医生
  301. $("#doctor_zk input").on("click",function(){
  302. mui.openWindow('../../huanzhe/html/hospital_qianyue.html', 'hospital_qianyue', {
  303. });
  304. });
  305. $('#healthManagement input').on('tap', function(){
  306. mui.confirm('请先选择签约团队', "提示", ["确定"], function(){});
  307. })
  308. //选择分组
  309. $("body").on("click","#li_group",function(){
  310. mui.openWindow({
  311. url:"xiaoxichuli_fzgl.html",
  312. id:"xiaoxichuli_fzgl.html"
  313. })
  314. });
  315. //同意、拒绝
  316. var signUrl = "doctor/family_contract/sign"; //签约
  317. var surrUrl = "doctor/family_contract/surrender"; //解约
  318. $("#btn_agree").click(function() { //同意
  319. if($("#btn_agree").attr("disabled")){
  320. return false;
  321. }
  322. $("#btn_agree").attr("disabled",true);
  323. currHealthManagementName=$("#healthManagement input").val()//医生姓名
  324. var patientIDcard=$("#idcard").html()//身份证
  325. //console.log(currHealthManagementName)
  326. if(signStatus == 1 || signStatus == 8 || signStatus == 9) {
  327. var val = $("input").val().trim();
  328. var isValid = validForm();
  329. if(!isValid){
  330. $("#btn_agree").attr("disabled",false);
  331. return;
  332. }
  333. var juminLabels = JSON.parse($juminLabels.attr("data-code"));
  334. sendPost(signUrl, {
  335. signType:signType,
  336. majorDoctor:$("#doctor_zk input").attr("data-code"),
  337. majorDoctorName:$("#doctor_zk input").val(),
  338. healthLabel: juminLabels.health,
  339. customLabel: juminLabels.custom,
  340. disease: juminLabels.disease,
  341. patientIDcard:patientIDcard,
  342. adminTeamCode: $doctorQytdInput.attr("data-code"),
  343. msgid: msgId,
  344. patient: patiCode,
  345. healthDoctor:$("#healthManagement input").attr("data-code"),
  346. healthDoctorName:$("#healthManagement input").val(),
  347. type: 1,
  348. expenses:$("#li_expenses input").attr("data-code"),
  349. group:$("#li_group input").attr("data-code"),
  350. //添加服务类型数据
  351. sevId: currService
  352. }, function(){
  353. $("#btn_agree").attr("disabled",false);
  354. mui.toast("系统异常!");
  355. }, function(res) {
  356. $("#btn_agree").attr("disabled",false);
  357. if(res.status == 200) {
  358. mui.toast("签约成功!");
  359. mui.fire(self.opener(), "updata");
  360. var xxWv = plus.webview.getWebviewById("xiaoxi.html");
  361. if(xxWv) {
  362. mui.fire(xxWv, "updateQy");
  363. }
  364. var hzWv = plus.webview.getWebviewById("huanzhe.html");
  365. if(hzWv) {
  366. mui.fire(hzWv, "update");
  367. }
  368. var mainWv = plus.webview.getWebviewById("main");
  369. if(mainWv) {
  370. mui.fire(mainWv, "xSxS");
  371. }
  372. mui.later(function() {
  373. mui.back();
  374. }, 500)
  375. }else if(res.status==-2||res.status==-3||res.status==-4){
  376. mui.confirm(res.msg, "提示", ["我知道了"], function(){
  377. mui.fire(self.opener(),"updata");
  378. var xxWv = plus.webview.getWebviewById("xiaoxi.html");
  379. if(xxWv) {
  380. mui.fire(xxWv, "updateQy");
  381. }
  382. var hzWv = plus.webview.getWebviewById("huanzhe.html");
  383. if(hzWv) {
  384. mui.fire(hzWv, "update");
  385. }
  386. var mainWv = plus.webview.getWebviewById("main");
  387. if(mainWv) {
  388. mui.fire(mainWv, "xSxS");
  389. }
  390. mui.back();
  391. });
  392. } else {
  393. mui.toast(res.msg);
  394. }
  395. });
  396. } else if(signStatus == 4) {
  397. console.log(msgId+" "+patiCode)
  398. sendPost(surrUrl, {
  399. msgid: msgId,
  400. patient: patiCode,
  401. healthLabel:"",
  402. adminTeamCode:0,
  403. type: 1
  404. }, null, function(res) {
  405. $("#btn_agree").attr("disabled",false);
  406. // alert(JSON.stringify(res))
  407. if(res.status == 200) {
  408. mui.toast("解约成功!");
  409. mui.fire(self.opener(), "updata");
  410. var xxWv = plus.webview.getWebviewById("xiaoxi.html");
  411. if(xxWv) {
  412. mui.fire(xxWv, "updateQy");
  413. }
  414. var hzWv = plus.webview.getWebviewById("huanzhe.html");
  415. if(hzWv) {
  416. mui.fire(hzWv, "update");
  417. }
  418. var mainWv = plus.webview.getWebviewById("main");
  419. if(mainWv) {
  420. mui.fire(mainWv, "mainupdate");
  421. }
  422. mui.later(function() {
  423. mui.back();
  424. }, 500)
  425. } else {
  426. mui.toast(res.msg);
  427. }
  428. });
  429. }
  430. });
  431. $("#btn_refuse").click(function() { //拒绝
  432. refuseReason = $('#refuseReason').val();
  433. if($("#btn_refuse").attr("disabled")){
  434. return false;
  435. }
  436. $("#btn_agree").attr("disabled",true);
  437. var patientIDcard=$("#idcard").html()
  438. if(signStatus == 1) {
  439. sendPost(signUrl, {
  440. patientIDcard:patientIDcard,
  441. // group: "",
  442. msgid: msgId,
  443. patient: patiCode,
  444. adminTeamCode:0,
  445. type: 2,
  446. refuseReason: refuseReason
  447. }, function(res){
  448. alert("请求出错");
  449. //alert(JSON.stringify(res))
  450. }, function(res) {
  451. if(res.status == 200) {
  452. mui.toast("已拒绝签约!");
  453. mui.fire(self.opener(), "updata");
  454. var xxWv = plus.webview.getWebviewById("xiaoxi.html");
  455. if(xxWv) {
  456. mui.fire(xxWv, "updateQy");
  457. }
  458. var mainWv = plus.webview.getWebviewById("main");
  459. if(mainWv) {
  460. mui.fire(mainWv, "mainupdate");
  461. }
  462. mui.later(function() {
  463. mui.back();
  464. }, 500)
  465. } else {
  466. mui.toast(res.msg);
  467. }
  468. });
  469. } else if(signStatus == 4) {
  470. sendPost(surrUrl, {
  471. msgid: msgId,
  472. patient: patiCode,
  473. type: 2
  474. }, null, function(res) {
  475. if(res.status == 200) {
  476. mui.toast("已拒绝解约!");
  477. mui.fire(self.opener(), "updata");
  478. var xxWv = plus.webview.getWebviewById("xiaoxi.html");
  479. if(xxWv) {
  480. mui.fire(xxWv, "updateQy");
  481. }
  482. var mainWv = plus.webview.getWebviewById("main");
  483. if(mainWv) {
  484. mui.fire(mainWv, "mainupdate");
  485. }
  486. mui.later(function() {
  487. mui.back();
  488. }, 500)
  489. } else {
  490. mui.toast(res.msg);
  491. }
  492. });
  493. }
  494. });
  495. // 点击家庭医生签约协议(勾选框)
  496. $(document.body).on('click', '#agreement_checkbox', function() {
  497. $(this).toggleClass("checked");
  498. })
  499. // 选择居民标签
  500. .on("click","#jumin_labels",function(){
  501. var teamCode = $('#qytdNum').attr("data-code");
  502. if($.trim(teamCode)) {
  503. //判断当前服务类型是否已经选择
  504. if(!currService){
  505. mui.confirm('请先选择服务类型', "提示", ["确定"], function(){});
  506. return false;
  507. }
  508. mui.openWindow({
  509. url:"../../huanzhe/html/disease-label-choose.html",
  510. id:"disease-label-choose",
  511. extras: {
  512. teamCode: teamCode,
  513. showData: $juminLabels.attr("data-code") || null,
  514. patientCode: patiCode,
  515. serviceCode: currService
  516. }
  517. })
  518. } else {
  519. mui.confirm('请先选择签约团队', "提示", ["确定"], function(){
  520. });
  521. }
  522. });
  523. window.addEventListener('getDoctor', function(event) {
  524. console.log(event.detail.name)
  525. $("#doctor_zk input").val(event.detail.name);
  526. $("#doctor_zk input").attr("data-code",event.detail.code);
  527. // console.log(event.detail.code);
  528. // console.log(event.detail.name);
  529. });
  530. window.addEventListener("group", group);
  531. /*居民标签*/
  532. window.addEventListener("setJuMinLabels", function setJuMinLabels(e) {
  533. var health = e.detail.health,
  534. disease = e.detail.disease,
  535. custom = e.detail.custom,
  536. labelName = e.detail.labelName;
  537. $juminLabels.val(labelName).attr("data-code",JSON.stringify({health: health,disease: disease, custom: custom }));
  538. });
  539. $("textarea").on("input", function(){
  540. var text = $(this).val().trim(),
  541. len = text.length;
  542. $("#count").text(len);
  543. });
  544. //选择拒绝签约说明文本,直接将内容添加到textarea中
  545. $("#explain").on('click', '.text-tag', function(){
  546. var $this = $(this),
  547. text = $this.text(),
  548. tatext = $("textarea").val();
  549. if($this.hasClass("active")){
  550. $this.removeClass("active");
  551. var a = tatext.split(text);
  552. tatext = a.join("");
  553. $("textarea").val(tatext);
  554. $("#count").text(tatext.length);
  555. }else{
  556. $this.addClass("active");
  557. tatext += text;
  558. $("textarea").val(tatext);
  559. $("#count").text(tatext.length);
  560. }
  561. });
  562. }
  563. function activHealthM(codes, names) {
  564. healthManagementCode = codes;
  565. healthManagementName = names;
  566. $('#healthManagement input[data-val=healthManagement]').mobiscroll({
  567. theme: 'ios',
  568. lang: 'zh',
  569. customWheels: true,
  570. wheels: [
  571. [{
  572. keys: healthManagementCode,
  573. values: healthManagementName
  574. }]
  575. ],
  576. onSelect: function(valueText, inst) {
  577. var dd = eval("[" + valueText + "]");
  578. var name=dd[0].values
  579. $(this).val(name);
  580. currHealthManagement = dd[0].keys;
  581. $('#healthManagement input[data-val=healthManagement]').attr("data-code",currHealthManagement);
  582. }
  583. });
  584. };
  585. function initData(type,res){
  586. var data=res.data;
  587. console.log(JSON.stringify(data))
  588. /*if(data.hasSanshi=="true"){
  589. signType=type
  590. $(".no").show()
  591. //$("#healthManagement input").val(data.glsName).attr({"data-code":data.glsCode});//健康医生
  592. }*/
  593. }//判断是不是三师已经签约 回填
  594. /*分组事件*/
  595. function group(e) {
  596. var groupcode=e.detail.code
  597. var groupName=e.detail.name
  598. //console.log(groupName)
  599. $('#li_group input[data-val=li_group]').val(groupName).attr("data-code",groupcode)
  600. }
  601. //获取签约团队
  602. function getQytd(res){
  603. if(res.status == 200) {
  604. if(res.data.length == 0){
  605. alert("查无签约团队");
  606. return;
  607. }
  608. var teams = res.data,
  609. teamCodes=[],
  610. teamNames=[];
  611. // 萃取数组对象中code、name,返回一个数组
  612. teamCodes = _.pluck(teams, 'id');
  613. // teamNames = _.pluck(teams, 'name');
  614. for(var i = 0; i < teams.length; i++){
  615. var signTeam;
  616. var signCount = teams[i].signCount;
  617. var signLimitNumber = teams[i].signLimitNumber;
  618. if(signCount >= signLimitNumber){
  619. signTeam = teams[i].name + "<span class='filled'>(已达上限)</span>";
  620. }else{
  621. signTeam = teams[i].name + "(已签约"+signCount+"人)";
  622. }
  623. teamNames.push(signTeam);
  624. }
  625. qytdSelect(teamCodes, teamNames);
  626. }
  627. }
  628. //var $doctorQytdInput = $('#qytd input');
  629. var $doctorQytdInput = $('#qytdNum');
  630. // 设置团队下拉框
  631. function qytdSelect(teamCodes, teamNames) {
  632. $doctorQytdInput.mobiscroll({
  633. theme: 'ios',
  634. lang: 'zh',
  635. customWheels: true,
  636. wheels: [
  637. [{
  638. keys: teamCodes,
  639. values: teamNames
  640. }]
  641. ],
  642. onSelect: function(valueText, inst) {
  643. var valueTextZy = valueText.replace("<span class='filled'>", "<span class=\\\'filled\\\'>");
  644. var dd = eval("[" + valueTextZy + "]"),
  645. name=dd[0].values,
  646. currExpenses = dd[0].keys;
  647. $(this).html(name);
  648. $(this).removeClass("c-9e9e9e");
  649. var isFilled = $(this).find("span").hasClass("filled");
  650. if(isFilled){
  651. $('#btn_agree').addClass("disabled").attr("disabled", true);
  652. }else{
  653. $('#btn_agree').removeClass("disabled").attr("disabled", false);
  654. }
  655. if($(this).text().length>20){
  656. $doctorQytdInput.css({textAlign:'left'});
  657. }else{
  658. $doctorQytdInput.css({textAlign:'right'});
  659. }
  660. $doctorQytdInput.attr("data-code",currExpenses);
  661. $('#healthManagement input[data-val=healthManagement]').val("").attr("data-code","")
  662. getTeamMember(currExpenses);
  663. }
  664. });
  665. if(teamCodes.length == 1){
  666. setQytdSelect(teamCodes[0], teamNames[0]);
  667. getTeamMember(teamCodes[0]);
  668. }
  669. }
  670. function setQytdSelect(code, name) {
  671. // 获取全科医生下拉框mibiscroll实例
  672. var mobiscroll = $doctorQytdInput.mobiscroll('getInst');
  673. var valueText = "{keys:'"+code+"',values:'"+name+"'}";
  674. mobiscroll.setVal([valueText]);
  675. $doctorQytdInput.html(name);
  676. if($doctorQytdInput.html(name).toString().length>=12){
  677. $doctorQytdInput.css({textAlign:'left'});
  678. }else{
  679. $doctorQytdInput.css({textAlign:'right'});
  680. }
  681. $doctorQytdInput.attr("data-code", code);
  682. }
  683. //获取团队成员
  684. function getTeamMember(teamCode){
  685. plus.nativeUI.showWaiting();
  686. sendGet("/doctor/admin-teams/"+ teamCode + "/members", {}, null, function(res){
  687. if(res.status == 200){
  688. var jgs= [],
  689. jgCodes =[], jgNames = [];
  690. $.each(res.data, function(i, v) {
  691. if(v.level == 3 || v.level == 2)
  692. jgs.push(v);
  693. });
  694. // 萃取数组对象中code、name,返回一个数组
  695. jgCodes = _.pluck(jgs, 'code');
  696. jgNames = _.pluck(jgs, 'name');
  697. activHealthM(jgCodes, jgNames);
  698. } else
  699. mui.toast("获取团队成员失败!");
  700. plus.nativeUI.closeWaiting();
  701. })
  702. }