huanzeziliao.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. var isModify = false,
  2. isJGmodify = false,
  3. isQkmodify = false,
  4. isPhonenumber = false,
  5. expenses, expenseName,
  6. patiCode,
  7. patiPhoto,
  8. signStatus,
  9. isSigned,
  10. isRenewable,
  11. qyRelation;
  12. var $doctorJGInput;
  13. var $doctorQkInput;
  14. var docInfo;
  15. var oldMobile;
  16. mui.init({
  17. beforeback: function() {
  18. if(isModify || isJGmodify || isQkmodify || isPhonenumber) {
  19. mui.confirm("您有未保存的变动,是否保存?", "提示", ["保存", "不了"], function(e) {
  20. if(e.index == 0) {
  21. submit();
  22. } else {
  23. plus.webview.currentWebview().close();
  24. }
  25. })
  26. return false;
  27. }
  28. }
  29. });
  30. var self;
  31. mui.plusReady(function() {
  32. self = plus.webview.currentWebview();
  33. patiCode = self.patiCode;
  34. patiPhoto = self.patiPhoto;
  35. isRenewable = self.renewable;
  36. qyRelation = self.qyRelation;
  37. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  38. getPatientInfo();
  39. bindEvents();
  40. });
  41. /**
  42. * 获取患者信息
  43. */
  44. function getPatientInfo() {
  45. var curDoc = docInfo.code;
  46. sendPost("doctor/patient_label_info/patient", {
  47. patient: patiCode
  48. }, null, function(res) {
  49. if(res.status == 200) {
  50. var data = res.data;
  51. if(self.teamCode) {
  52. data.isShowJt = data.jtAdminTeam == self.teamCode ? true : false;
  53. } else if(data.jtDoctor == curDoc || data.jtDoctorHealth == curDoc) {
  54. data.isShowJt = true;
  55. }
  56. if(self.teamCode) {
  57. data.isShowSs = data.ssAdminTeam == self.teamCode ? true : false;
  58. } else if(data.ssDoctor == curDoc || data.ssDoctorHealth == curDoc) {
  59. data.isShowSs = true;
  60. }
  61. //判断是否显示提醒按钮
  62. if(isRenewable && isRenewable == 1) {
  63. $("#remindXQ").parent().show();
  64. if(data.isRemindRenew == "1") {
  65. $("#remindXQ").text("已提醒续签");
  66. $("#remindXQ").addClass("ytx");
  67. } else {
  68. //判断用户是否有微信号和手机号
  69. if(!data.openid && !data.mobile) {
  70. $("#remindXQ").addClass("remind-not");
  71. }
  72. $("#remindXQ").text("提醒续签");
  73. $("#remindXQ").removeClass("ytx");
  74. }
  75. } else {
  76. $("#remindXQ").parent().hide();
  77. }
  78. data.photo = patiPhoto;
  79. data.idcard = plusXing(data.idcard,9,2);
  80. data.ssc = plusXing(data.ssc,3,2);
  81. $("#pati_info").html(template("info_tmpl", data));
  82. // //取家庭签约团队
  83. // sendGet("/doctor/admin-teams/team/members/" + patiCode, {}, null, function(res1) {
  84. // if(res1.status == 200 && res1.data.teamId) {
  85. // // res1.data.isLeader = true; //测试用
  86. // data.teamName = res1.data.teamName;
  87. // data.Modifqk = data.ssDoctor || !res1.data.isLeader ? false : true;
  88. // data.ModifyJgs = res1.data.isLeader;
  89. // oldQy = res1.data;
  90. //
  91. // $("#pati_info").html(template("info_tmpl", data));
  92. // $doctorJGInput = $('#healthManagement input');
  93. // $doctorQkInput = $('#dortor_qke input');
  94. // setExpenses(); //初始化政府补贴下拉框
  95. // if(res1.data.isLeader && $doctorJGInput.length > 0)
  96. // getTeamMember(oldQy.teamId); // 初始化健管师下拉框
  97. // if(data.ssDoctor) {
  98. // $(".no").show();
  99. // }
  100. //
  101. // } else
  102. // mui.toast("获取居民签约团队失败!");
  103. // })
  104. } else {
  105. mui.toast(res.msg);
  106. }
  107. });
  108. }
  109. //参数的含义:str:字符串,frontLen:前面保留位数,endLen:后面保留位数。
  110. function plusXing (str,frontLen,endLen) {
  111. var len = str.length-frontLen-endLen;
  112. var xing = '';
  113. for (var i=0;i<len;i++) {
  114. xing+='*';
  115. }
  116. return str.substring(0,frontLen)+xing+str.substring(str.length-endLen);
  117. }
  118. function changeInfo() {
  119. }
  120. /**
  121. * 获取政府补贴数据
  122. */
  123. function setExpenses() {
  124. var $expenses = $('#li_expenses');
  125. if($expenses.length > 0) {
  126. expenses = $expenses.attr('data-code');
  127. if(signStatus != 'yjy') {
  128. $('.header-link').show();
  129. }
  130. var expensesCode = [];
  131. var expensesName = [];
  132. sendGet("/common/getDictByDictName?name=SIGN_EXPENSES", null, null, function(res) {
  133. if(res.status == 200) {
  134. var expensesList = res.list;
  135. for(var i = 0; i < expensesList.length; i++) {
  136. if(expenses == expensesList[i].code) {
  137. expenseName = expensesList[i].value;
  138. $expenses.val(expensesList[i].value);
  139. }
  140. expensesCode.push(expensesList[i].code);
  141. expensesName.push(expensesList[i].value);
  142. }
  143. checkQy(expensesCode, expensesName);
  144. };
  145. });
  146. }
  147. }
  148. function checkQy(expensesCode, expensesName) {
  149. sendPost("/doctor/family_contract/medical_insurance_num", {
  150. patient: patiCode
  151. }, null, function(res) {
  152. isSigned = res.data.status;
  153. if(signStatus != 'yjy')
  154. activExpensesM(expensesCode, expensesName);
  155. });
  156. }
  157. function setExpensesSelect(code, name) {
  158. var $li_expenses = $('#li_expenses');
  159. var mobiscroll = $li_expenses.mobiscroll('getInst');
  160. var valueText = "{keys:'" + code + "',values:'" + name + "'}";
  161. mobiscroll.setVal([valueText]);
  162. $li_expenses.val(name);
  163. $li_expenses.attr("data-code", code);
  164. }
  165. /**
  166. * 设置政府补贴下拉框
  167. */
  168. function activExpensesM(expensesCode, expensesName) {
  169. if(isSigned == 0) {
  170. $('#li_expenses').mobiscroll({
  171. theme: 'ios',
  172. lang: 'zh',
  173. customWheels: true,
  174. wheels: [
  175. [{
  176. keys: expensesCode,
  177. values: expensesName
  178. }]
  179. ],
  180. onSelect: function(valueText, inst) {
  181. var dd = eval("[" + valueText + "]");
  182. $(this).val(dd[0].values).attr("data-code", dd[0].keys);
  183. isModify = expenses != dd[0].keys;
  184. toggleModify();
  185. },
  186. onShow: function() {
  187. if($(this).attr('data-init') == "1") {
  188. $(this).attr('data-init', "0");
  189. $('#li_expenses').mobiscroll("selectWheel", [$(this).attr('data-code')]);
  190. }
  191. }
  192. });
  193. } else {
  194. $('#li_expenses').on('tap', function() {
  195. mui.toast("已成功签约,无法变更");
  196. })
  197. }
  198. };
  199. /**
  200. * 手机号码修改
  201. */
  202. function Mobilephone() {
  203. var Inputbox = $("#Inputbox").val();
  204. oldMobile = $('#Inputbox').attr('data-id')
  205. if(!isPhonenumber) {
  206. if(oldMobile==null||oldMobile=='') {
  207. sendPost("/doctor/patient/updateMobile",
  208. {patient: patiCode,newMobile: Inputbox},null,function(res) {
  209. if(res.status == 200) {
  210. mui.toast(res.msg)
  211. } else {
  212. mui.toast(res.msg);
  213. }
  214. }, 'post');
  215. }else {
  216. sendPost("/doctor/patient/updateMobile",
  217. {patient: patiCode,newMobile: Inputbox,oldMobile: oldMobile},null,function(res) {
  218. if(res.status == 200) {
  219. mui.toast(res.msg)
  220. } else {
  221. mui.toast(res.msg);
  222. }
  223. }, 'post');
  224. }
  225. }
  226. }
  227. /**
  228. * 提交
  229. */
  230. function submit(t) {
  231. if(!isModify && !isJGmodify && !isQkmodify && !isPhonenumber)
  232. return;
  233. plus.nativeUI.showWaiting();
  234. var p = {
  235. patient: patiCode
  236. }
  237. if(isModify) {
  238. p.expensesType = $('#li_expenses').attr('data-code');
  239. }
  240. if(isJGmodify) {
  241. p.healthDoctor = $doctorJGInput.attr("data-code");
  242. }
  243. if(isQkmodify) {
  244. p.doctor = $doctorQkInput.attr("data-code");
  245. }
  246. if(isPhonenumber) {
  247. p.newMobile = $("#Inputbox").val();
  248. }
  249. sendPost("/doctor/family_contract/sign_info_update", p, null,
  250. function(res) {
  251. if(res.status == 200) {
  252. expenses = $('#li_expenses').attr('data-code');
  253. oldQy.healthDoctorCode = $doctorJGInput.attr('data-code');
  254. oldQy.healthDoctorName = $doctorJGInput.val();
  255. oldQy.doctor = $doctorQkInput.attr('data-code');
  256. oldQy.doctorName = $doctorQkInput.val();
  257. isModify = false;
  258. isJGmodify = false;
  259. isQkmodify = false;
  260. toggleModify();
  261. mui.toast("保存成功!");
  262. plus.nativeUI.closeWaiting();
  263. if(!t)
  264. plus.webview.currentWebview().close();
  265. } else {
  266. if(isModify) {
  267. setExpensesSelect(expenses, expenseName);
  268. isModify = false;
  269. }
  270. if(isJGmodify) {
  271. setJGSelect(oldQy.healthDoctorCode, oldQy.healthDoctorName);
  272. isJGmodify = false;
  273. }
  274. if(isQkmodify) {
  275. setQkSelect(oldQy.doctor, oldQy.doctorName);
  276. isQkmodify = false;
  277. }
  278. if(isPhonenumber) {
  279. $("#Inputbox").val()
  280. isPhonenumber = false;
  281. }
  282. toggleModify();
  283. plus.nativeUI.closeWaiting();
  284. mui.toast(res.msg);
  285. }
  286. })
  287. }
  288. //获取团队成员
  289. function getTeamMember(teamCode) {
  290. plus.nativeUI.showWaiting();
  291. sendGet("/doctor/admin-teams/" + teamCode + "/members", {}, null, function(res) {
  292. if(res.status == 200) {
  293. var jgs = [],
  294. qk = [],
  295. jgCodes = [],
  296. jgNames = [],
  297. qkCodes = [],
  298. qkNames = [];
  299. $.each(res.data, function(i, v) {
  300. if(v.level == 3 || v.level == 2) {
  301. jgs.push(v);
  302. }
  303. if(v.level == 2) {
  304. qk.push(v);
  305. }
  306. });
  307. qkCodes = _.pluck(qk, 'code')
  308. qkNames = _.pluck(qk, 'name');
  309. // 萃取数组对象中code、name,返回一个数组
  310. jgCodes = _.pluck(jgs, 'code');
  311. jgNames = _.pluck(jgs, 'name');
  312. activHealthM(jgCodes, jgNames);
  313. activDoctorM(qkCodes, qkNames)
  314. } else
  315. mui.toast("获取团队成员失败!");
  316. plus.nativeUI.closeWaiting();
  317. })
  318. }
  319. function activDoctorM(codes, names) {
  320. $doctorQkInput.mobiscroll({
  321. theme: 'ios',
  322. lang: 'zh',
  323. customWheels: true,
  324. wheels: [
  325. [{
  326. keys: codes,
  327. values: names
  328. }]
  329. ],
  330. onSelect: function(valueText, inst) {
  331. var dd = eval("[" + valueText + "]");
  332. var curDocCode = dd[0].keys;
  333. $(this).val(dd[0].values);
  334. $doctorQkInput.attr("data-code", curDocCode);
  335. isQkmodify = oldQy.doctor != curDocCode;
  336. toggleQkModify();
  337. }
  338. });
  339. setQkSelect(oldQy.doctor, oldQy.doctorName);
  340. };
  341. function activHealthM(codes, names) {
  342. $doctorJGInput.mobiscroll({
  343. theme: 'ios',
  344. lang: 'zh',
  345. customWheels: true,
  346. wheels: [
  347. [{
  348. keys: codes,
  349. values: names
  350. }]
  351. ],
  352. onSelect: function(valueText, inst) {
  353. var dd = eval("[" + valueText + "]");
  354. var curDocCode = dd[0].keys;
  355. $(this).val(dd[0].values);
  356. $doctorJGInput.attr("data-code", curDocCode);
  357. isJGmodify = oldQy.healthDoctorCode != curDocCode;
  358. toggleModify();
  359. }
  360. });
  361. setJGSelect(oldQy.healthDoctorCode, oldQy.healthDoctorName);
  362. };
  363. function setJGSelect(code, name) {
  364. var mobiscroll = $doctorJGInput.mobiscroll('getInst');
  365. var valueText = "{keys:'" + code + "',values:'" + name + "'}";
  366. mobiscroll.setVal([valueText]);
  367. $doctorJGInput.val(name);
  368. $doctorJGInput.attr("data-code", code);
  369. }
  370. function setQkSelect(code, name) {
  371. var mobiscroll = $doctorJGInput.mobiscroll('getInst');
  372. var valueText = "{keys:'" + code + "',values:'" + name + "'}";
  373. mobiscroll.setVal([valueText]);
  374. $doctorQkInput.val(name);
  375. $doctorQkInput.attr("data-code", code);
  376. }
  377. function toggleModify() {
  378. console.log(isModify + "," + isJGmodify)
  379. $('.link').toggleClass('c-ccc', !(isModify || isJGmodify));
  380. }
  381. function toggleQkModify() {
  382. console.log(isModify + "," + isQkmodify)
  383. $('.link').toggleClass('c-ccc', !(isModify || isQkmodify));
  384. }
  385. function togglePhonenumberModify() {
  386. $('.link').toggleClass('c-ccc', !isPhonenumber);
  387. Mobilephone()
  388. }
  389. /*提醒续签*/
  390. function sendRenewRemind() {
  391. var url = "/doctor/sign/remindPatientRenew",
  392. params = {
  393. patient: patiCode
  394. };
  395. plus.nativeUI.showWaiting();
  396. sendPost(url, params, null, function(res) {
  397. if(res.status == 200) {
  398. if(res.data == 1 || res.data == 2) {
  399. $("#remindXQ").text("已提醒续签");
  400. $("#remindXQ").addClass("ytx");
  401. }
  402. mui.toast(res.msg);
  403. } else {
  404. mui.toast(res.msg)
  405. }
  406. plus.nativeUI.closeWaiting();
  407. }, "post", "", true);
  408. }
  409. function bindEvents() {
  410. $("#remindXQ").on("click", function() {
  411. var $this = $(this);
  412. if($this.hasClass("ytx")) {
  413. mui.toast("您今日已提醒过居民续签啦~");
  414. } else {
  415. if($this.hasClass("remind-not")) {
  416. mui.toast("对不起,该居民未绑定手机及微信,无法提醒。");
  417. $("#remindXQ").text("已提醒续签");
  418. $("#remindXQ").addClass("ytx");
  419. } else {
  420. sendRenewRemind();
  421. }
  422. }
  423. });
  424. $("#pati_info").on('change', '#Inputbox', function() {
  425. if($(this).val()) {
  426. togglePhonenumberModify()
  427. } else {
  428. }
  429. })
  430. }
  431. template.helper("setPhoto", function(p) {
  432. return getImgUrl(p);
  433. });