huanzeziliao.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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. //取家庭签约团队
  80. sendGet("/doctor/admin-teams/team/members/" + patiCode, {}, null, function(res1) {
  81. if(res1.status == 200 && res1.data.teamId) {
  82. // res1.data.isLeader = true; //测试用
  83. data.teamName = res1.data.teamName;
  84. data.Modifqk = data.ssDoctor || !res1.data.isLeader ? false : true;
  85. data.ModifyJgs = res1.data.isLeader;
  86. oldQy = res1.data;
  87. $("#pati_info").html(template("info_tmpl", data));
  88. $doctorJGInput = $('#healthManagement input');
  89. $doctorQkInput = $('#dortor_qke input');
  90. setExpenses(); //初始化政府补贴下拉框
  91. if(res1.data.isLeader && $doctorJGInput.length > 0)
  92. getTeamMember(oldQy.teamId); // 初始化健管师下拉框
  93. if(data.ssDoctor) {
  94. $(".no").show();
  95. }
  96. } else
  97. mui.toast("获取居民签约团队失败!");
  98. })
  99. } else {
  100. mui.toast(res.msg);
  101. }
  102. });
  103. }
  104. function changeInfo() {
  105. }
  106. /**
  107. * 获取政府补贴数据
  108. */
  109. function setExpenses() {
  110. var $expenses = $('#li_expenses');
  111. if($expenses.length > 0) {
  112. expenses = $expenses.attr('data-code');
  113. if(signStatus != 'yjy') {
  114. $('.header-link').show();
  115. }
  116. var expensesCode = [];
  117. var expensesName = [];
  118. sendGet("/common/getDictByDictName?name=SIGN_EXPENSES", null, null, function(res) {
  119. if(res.status == 200) {
  120. var expensesList = res.list;
  121. for(var i = 0; i < expensesList.length; i++) {
  122. if(expenses == expensesList[i].code) {
  123. expenseName = expensesList[i].value;
  124. $expenses.val(expensesList[i].value);
  125. }
  126. expensesCode.push(expensesList[i].code);
  127. expensesName.push(expensesList[i].value);
  128. }
  129. checkQy(expensesCode, expensesName);
  130. };
  131. });
  132. }
  133. }
  134. function checkQy(expensesCode, expensesName) {
  135. sendPost("/doctor/family_contract/medical_insurance_num", {
  136. patient: patiCode
  137. }, null, function(res) {
  138. isSigned = res.data.status;
  139. if(signStatus != 'yjy')
  140. activExpensesM(expensesCode, expensesName);
  141. });
  142. }
  143. function setExpensesSelect(code, name) {
  144. var $li_expenses = $('#li_expenses');
  145. var mobiscroll = $li_expenses.mobiscroll('getInst');
  146. var valueText = "{keys:'" + code + "',values:'" + name + "'}";
  147. mobiscroll.setVal([valueText]);
  148. $li_expenses.val(name);
  149. $li_expenses.attr("data-code", code);
  150. }
  151. /**
  152. * 设置政府补贴下拉框
  153. */
  154. function activExpensesM(expensesCode, expensesName) {
  155. if(isSigned == 0) {
  156. $('#li_expenses').mobiscroll({
  157. theme: 'ios',
  158. lang: 'zh',
  159. customWheels: true,
  160. wheels: [
  161. [{
  162. keys: expensesCode,
  163. values: expensesName
  164. }]
  165. ],
  166. onSelect: function(valueText, inst) {
  167. var dd = eval("[" + valueText + "]");
  168. $(this).val(dd[0].values).attr("data-code", dd[0].keys);
  169. isModify = expenses != dd[0].keys;
  170. toggleModify();
  171. },
  172. onShow: function() {
  173. if($(this).attr('data-init') == "1") {
  174. $(this).attr('data-init', "0");
  175. $('#li_expenses').mobiscroll("selectWheel", [$(this).attr('data-code')]);
  176. }
  177. }
  178. });
  179. } else {
  180. $('#li_expenses').on('tap', function() {
  181. mui.toast("已成功签约,无法变更");
  182. })
  183. }
  184. };
  185. /**
  186. * 手机号码修改
  187. */
  188. function Mobilephone() {
  189. var Inputbox = $("#Inputbox").val();
  190. oldMobile = $('#Inputbox').attr('data-id')
  191. if(!isPhonenumber) {
  192. if(oldMobile==null||oldMobile=='') {
  193. sendPost("/doctor/patient/updateMobile",
  194. {patient: patiCode,newMobile: Inputbox},null,function(res) {
  195. if(res.status == 200) {
  196. mui.toast(res.msg)
  197. } else {
  198. mui.toast(res.msg);
  199. }
  200. }, 'post');
  201. }else {
  202. sendPost("/doctor/patient/updateMobile",
  203. {patient: patiCode,newMobile: Inputbox,oldMobile: oldMobile},null,function(res) {
  204. if(res.status == 200) {
  205. mui.toast(res.msg)
  206. } else {
  207. mui.toast(res.msg);
  208. }
  209. }, 'post');
  210. }
  211. }
  212. }
  213. /**
  214. * 提交
  215. */
  216. function submit(t) {
  217. if(!isModify && !isJGmodify && !isQkmodify && !isPhonenumber)
  218. return;
  219. plus.nativeUI.showWaiting();
  220. var p = {
  221. patient: patiCode
  222. }
  223. if(isModify) {
  224. p.expensesType = $('#li_expenses').attr('data-code');
  225. }
  226. if(isJGmodify) {
  227. p.healthDoctor = $doctorJGInput.attr("data-code");
  228. }
  229. if(isQkmodify) {
  230. p.doctor = $doctorQkInput.attr("data-code");
  231. }
  232. if(isPhonenumber) {
  233. p.newMobile = $("#Inputbox").val();
  234. }
  235. sendPost("/doctor/family_contract/sign_info_update", p, null,
  236. function(res) {
  237. if(res.status == 200) {
  238. expenses = $('#li_expenses').attr('data-code');
  239. oldQy.healthDoctorCode = $doctorJGInput.attr('data-code');
  240. oldQy.healthDoctorName = $doctorJGInput.val();
  241. oldQy.doctor = $doctorQkInput.attr('data-code');
  242. oldQy.doctorName = $doctorQkInput.val();
  243. isModify = false;
  244. isJGmodify = false;
  245. isQkmodify = false;
  246. toggleModify();
  247. mui.toast("保存成功!");
  248. plus.nativeUI.closeWaiting();
  249. if(!t)
  250. plus.webview.currentWebview().close();
  251. } else {
  252. if(isModify) {
  253. setExpensesSelect(expenses, expenseName);
  254. isModify = false;
  255. }
  256. if(isJGmodify) {
  257. setJGSelect(oldQy.healthDoctorCode, oldQy.healthDoctorName);
  258. isJGmodify = false;
  259. }
  260. if(isQkmodify) {
  261. setQkSelect(oldQy.doctor, oldQy.doctorName);
  262. isQkmodify = false;
  263. }
  264. if(isPhonenumber) {
  265. $("#Inputbox").val()
  266. isPhonenumber = false;
  267. }
  268. toggleModify();
  269. plus.nativeUI.closeWaiting();
  270. mui.toast(res.msg);
  271. }
  272. })
  273. }
  274. //获取团队成员
  275. function getTeamMember(teamCode) {
  276. plus.nativeUI.showWaiting();
  277. sendGet("/doctor/admin-teams/" + teamCode + "/members", {}, null, function(res) {
  278. if(res.status == 200) {
  279. var jgs = [],
  280. qk = [],
  281. jgCodes = [],
  282. jgNames = [],
  283. qkCodes = [],
  284. qkNames = [];
  285. $.each(res.data, function(i, v) {
  286. if(v.level == 3 || v.level == 2) {
  287. jgs.push(v);
  288. }
  289. if(v.level == 2) {
  290. qk.push(v);
  291. }
  292. });
  293. qkCodes = _.pluck(qk, 'code')
  294. qkNames = _.pluck(qk, 'name');
  295. // 萃取数组对象中code、name,返回一个数组
  296. jgCodes = _.pluck(jgs, 'code');
  297. jgNames = _.pluck(jgs, 'name');
  298. activHealthM(jgCodes, jgNames);
  299. activDoctorM(qkCodes, qkNames)
  300. } else
  301. mui.toast("获取团队成员失败!");
  302. plus.nativeUI.closeWaiting();
  303. })
  304. }
  305. function activDoctorM(codes, names) {
  306. $doctorQkInput.mobiscroll({
  307. theme: 'ios',
  308. lang: 'zh',
  309. customWheels: true,
  310. wheels: [
  311. [{
  312. keys: codes,
  313. values: names
  314. }]
  315. ],
  316. onSelect: function(valueText, inst) {
  317. var dd = eval("[" + valueText + "]");
  318. var curDocCode = dd[0].keys;
  319. $(this).val(dd[0].values);
  320. $doctorQkInput.attr("data-code", curDocCode);
  321. isQkmodify = oldQy.doctor != curDocCode;
  322. toggleQkModify();
  323. }
  324. });
  325. setQkSelect(oldQy.doctor, oldQy.doctorName);
  326. };
  327. function activHealthM(codes, names) {
  328. $doctorJGInput.mobiscroll({
  329. theme: 'ios',
  330. lang: 'zh',
  331. customWheels: true,
  332. wheels: [
  333. [{
  334. keys: codes,
  335. values: names
  336. }]
  337. ],
  338. onSelect: function(valueText, inst) {
  339. var dd = eval("[" + valueText + "]");
  340. var curDocCode = dd[0].keys;
  341. $(this).val(dd[0].values);
  342. $doctorJGInput.attr("data-code", curDocCode);
  343. isJGmodify = oldQy.healthDoctorCode != curDocCode;
  344. toggleModify();
  345. }
  346. });
  347. setJGSelect(oldQy.healthDoctorCode, oldQy.healthDoctorName);
  348. };
  349. function setJGSelect(code, name) {
  350. var mobiscroll = $doctorJGInput.mobiscroll('getInst');
  351. var valueText = "{keys:'" + code + "',values:'" + name + "'}";
  352. mobiscroll.setVal([valueText]);
  353. $doctorJGInput.val(name);
  354. $doctorJGInput.attr("data-code", code);
  355. }
  356. function setQkSelect(code, name) {
  357. var mobiscroll = $doctorJGInput.mobiscroll('getInst');
  358. var valueText = "{keys:'" + code + "',values:'" + name + "'}";
  359. mobiscroll.setVal([valueText]);
  360. $doctorQkInput.val(name);
  361. $doctorQkInput.attr("data-code", code);
  362. }
  363. function toggleModify() {
  364. console.log(isModify + "," + isJGmodify)
  365. $('.link').toggleClass('c-ccc', !(isModify || isJGmodify));
  366. }
  367. function toggleQkModify() {
  368. console.log(isModify + "," + isQkmodify)
  369. $('.link').toggleClass('c-ccc', !(isModify || isQkmodify));
  370. }
  371. function togglePhonenumberModify() {
  372. $('.link').toggleClass('c-ccc', !isPhonenumber);
  373. Mobilephone()
  374. }
  375. /*提醒续签*/
  376. function sendRenewRemind() {
  377. var url = "/doctor/sign/remindPatientRenew",
  378. params = {
  379. patient: patiCode
  380. };
  381. plus.nativeUI.showWaiting();
  382. sendPost(url, params, null, function(res) {
  383. if(res.status == 200) {
  384. if(res.data == 1 || res.data == 2) {
  385. $("#remindXQ").text("已提醒续签");
  386. $("#remindXQ").addClass("ytx");
  387. }
  388. mui.toast(res.msg);
  389. } else {
  390. mui.toast(res.msg)
  391. }
  392. plus.nativeUI.closeWaiting();
  393. }, "post", "", true);
  394. }
  395. function bindEvents() {
  396. $("#remindXQ").on("click", function() {
  397. var $this = $(this);
  398. if($this.hasClass("ytx")) {
  399. mui.toast("您今日已提醒过居民续签啦~");
  400. } else {
  401. if($this.hasClass("remind-not")) {
  402. mui.toast("对不起,该居民未绑定手机及微信,无法提醒。");
  403. $("#remindXQ").text("已提醒续签");
  404. $("#remindXQ").addClass("ytx");
  405. } else {
  406. sendRenewRemind();
  407. }
  408. }
  409. });
  410. $("#pati_info").on('change', '#Inputbox', function() {
  411. if($(this).val()) {
  412. togglePhonenumberModify()
  413. } else {
  414. }
  415. })
  416. }
  417. template.helper("setPhoto", function(p) {
  418. return getImgUrl(p);
  419. });