denizen-info.js 11 KB

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