questionaires.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. // 基本信息(包括userAgent)
  2. var baseInfo = null,
  3. // 基础环境信息(包括当前webview、encry相关)
  4. baseEnv = null,
  5. docInfo = null,
  6. fv_id = null,
  7. pro_id = null,
  8. title = "",
  9. followupClass = null,
  10. patientCode = null,
  11. otherPeople = '',
  12. activeField = ""; //记录输入框修改时的id
  13. var project_data;
  14. var $form = $("#question_form"),
  15. BP_D_OPS = BP_U_OPS = WEIGHT_OPS = HEART_RATE_OPS = BS_FPG_OPS = null; //历史记录下拉选择模板
  16. // 获取登录相关信息
  17. var getBaseInfo = function() {
  18. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  19. fv_id = baseEnv.webview.followup_id;
  20. pro_id = baseEnv.webview.project_id;
  21. title = baseEnv.webview.title;
  22. followupClass = baseEnv.webview.followupClass;
  23. patientCode = baseEnv.webview.patientCode;
  24. otherPeople = baseEnv.webview.otherPeople;
  25. // 登录的相关信息
  26. var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
  27. return {
  28. userAgent: userAgent
  29. }
  30. },
  31. // 获取基础环境信息
  32. getBaseEnvPromise = function () {
  33. var env = {
  34. webview: plus.webview.currentWebview()
  35. };
  36. // 因为有异步请求,需要等待数据返回之后进行处理,所以返回Promise
  37. return Promise.resolve().then(function(res) {
  38. return env;
  39. });
  40. },
  41. initPage = function(){
  42. plus.nativeUI.showWaiting();
  43. $("#title").text(title);
  44. if(otherPeople){
  45. $('#btn_group').hide();
  46. $('#question_form').css('pointer-events','none')
  47. }else{
  48. $('#btn_group').show();
  49. $('#question_form').css('pointer-events','')
  50. }
  51. //统一模板
  52. project_data = gTemplate[pro_id];
  53. sendPost("/doctor/followup/getFollowupProjectData", {id: fv_id,followupProject: pro_id}, null,
  54. function(res){
  55. for(key in project_data){
  56. project_data[key].value = res.data?res.data[key]:'';
  57. if(project_data[key].type==4 || project_data[key].type==3) {
  58. if(project_data[key].value){
  59. project_data[key].valueLength = project_data[key].value.length;
  60. }
  61. }
  62. }
  63. if(pro_id == 5){
  64. if(followupClass == 1){//高血压
  65. project_data = _.pick(project_data, 'HYP_FOLLOWUP_TYPE_CODE', 'HYP_COMPLICATION_DETAIL');
  66. }else if(followupClass == 2){//糖尿病
  67. project_data = _.pick(project_data, 'DIA_FOLLOWUP_TYPE_CODE', 'DIA_COMPLICATION_DETAIL');
  68. }
  69. }
  70. //处理拒绝转诊字段不统一问题
  71. if(pro_id == 9){
  72. project_data.DISAGREE_TRANSFER.value = res.data?res.data['REFUSE_REFERRAL_WHY']:''
  73. }
  74. var html = template("item", {data:project_data,followupClass:followupClass});
  75. var link = "";
  76. if(pro_id == 8){//健康教育
  77. link = '<div class="li-link c-f16 pt10 plr10"><a href="javascript:;" data-href="edu_history.html" data-type="edu" onclick="openNewPage(this)">从健康指导、健康教育记录获取</a></div>';
  78. }
  79. $form.append(link+html);
  80. if(pro_id == 8){//健康教育
  81. $('#jkjy').attr('data-id',res.data?res.data['HEALTH_EDUCATE']:'')
  82. }
  83. initMobiscroll();
  84. checkBtnEnable();
  85. if(pro_id == 7){//控制目标
  86. $("input[name=CONTROL_CONSTITUTOR]").val(docInfo.name);
  87. }
  88. plus.nativeUI.closeWaiting();
  89. },'GET');
  90. },
  91. initMobiscroll = function(){
  92. //随访日期选择
  93. $('[data-val=date]').mobiscroll({
  94. preset: 'date',
  95. theme: 'ios',
  96. display:'bottom',
  97. lang: 'zh',
  98. dateFormat: 'yy-mm-dd',
  99. showLabel: false
  100. });
  101. //选择下拉选择
  102. if(pro_id == 8){
  103. var html = '<option disabled selected></option>';
  104. var datas = project_data['HEALTH_EDUCATE'].list
  105. for(var key in datas){
  106. if(key == $('#jkjy').attr('data-id')){
  107. html += '<option selected value="'+key+'">'+datas[key]+'</option>';
  108. }else{
  109. html += '<option value="'+key+'">'+datas[key]+'</option>';
  110. }
  111. }
  112. $('#jkjy').html(html);
  113. $('#jkjy').mobiscroll().select({
  114. theme: 'ios',
  115. lang: 'zh',
  116. display: 'bottom',
  117. placeholder:'请选择',
  118. rows:4,
  119. onSelect: function ( valueText, inst) {
  120. $('#jkjy').attr('data-id',inst._tempValue)
  121. $('#jkjy').attr('data-name',valueText)
  122. }
  123. })
  124. }
  125. //绑定数字键盘
  126. $.each(document.querySelectorAll('input[type=number]'), function(index, el){
  127. var name = el.name;
  128. if(name == "BP_U" || name == "BP_D" || name=="CONTROL_BP_U"|| name=="CONTROL_BP_D"){
  129. $(el).mobiscroll().numpad({
  130. theme: 'ios',
  131. display: 'bottom',
  132. lang: 'zh',
  133. placeholder: '0',
  134. fill: 'rtl',
  135. allowLeadingZero: true,
  136. template: 'ddd',
  137. scale:0,
  138. buttons: ['set','cancel'],
  139. onShow: function(html, inst){
  140. activeField = this.name;
  141. var linkHtml = "<div class='mob-link' data-type='2'><a>您可从居民血压记录中获取</a></div>";
  142. html.find(".dwwr").before(linkHtml);
  143. var dialog = html.find("[role=dialog]"),
  144. top = dialog.css("top");
  145. dialog.css('top', (parseFloat(top)-30)+"px");
  146. },
  147. onSelect: function(valueText, inst){
  148. var value = parseFloat($('.mbsc-np-dsp').text());
  149. $(this).val(value);
  150. }
  151. });
  152. }else if(name=="HEART_RATE" || name=="DAILY_SMOKING" || name=="CONTROL_EXERCISE_DURATION_MINS" || name=="SOMKING_EXP" || name=="EXERCISE_DURATION_MINS" || name=="EXERCISE_DURATION_MINS_EXP"){
  153. $(el).mobiscroll().numpad({
  154. theme: 'ios',
  155. display: 'bottom',
  156. lang: 'zh',
  157. placeholder: '0',
  158. fill: 'rtl',
  159. allowLeadingZero: true,
  160. template: 'ddd',
  161. scale:0,
  162. buttons: ['set','cancel'],
  163. onSelect: function(valueText, inst){
  164. var value = parseFloat($('.mbsc-np-dsp').text());
  165. $(this).val(value);
  166. }
  167. })
  168. }else if(name == "RENAL_FUNCTION_CREATININE" || name=="DRINK_EXP" || name=="DAILY_DRINKING" || name=="DAILY_STAPLE" || name == "WEIGHT_EXP"){
  169. $(el).mobiscroll().numpad({
  170. theme: 'ios',
  171. display: 'bottom',
  172. lang: 'zh',
  173. placeholder: '0',
  174. fill: 'rtl',
  175. allowLeadingZero: true,
  176. template: 'ddd.d',
  177. scale:0,
  178. buttons: ['set','cancel'],
  179. onSelect: function(valueText, inst){
  180. var value = parseFloat($('.mbsc-np-dsp').text());
  181. $(this).val(value);
  182. }
  183. })
  184. }else if(name == "BS_FPG" || name == "NO_BS_FPG" || name == "RANDOM_BLOOD_SUGAR" || name == "CONTROL_BS_FPG" || name == "CONTROL_NO_BS_FPG"){
  185. $(el).mobiscroll().numpad({
  186. theme: 'ios',
  187. display: 'bottom',
  188. lang: 'zh',
  189. placeholder: '0',
  190. fill: 'rtl',
  191. template: 'dd.d',
  192. allowLeadingZero: true,
  193. buttons: ['set','cancel'],
  194. onSelect: function(valueText, inst){
  195. var value = parseFloat($('.mbsc-np-dsp').text());
  196. $(this).val(value);
  197. },
  198. onShow: function(html, inst){
  199. activeField = this.name;
  200. var linkHtml = "<div class='mob-link' data-type='1'><a>您可从居民血糖记录中获取</a></div>";
  201. html.find(".dwwr").before(linkHtml);
  202. var dialog = html.find("[role=dialog]"),
  203. top = dialog.css("top");
  204. dialog.css('top', (parseFloat(top)-30)+"px");
  205. },
  206. validate: function(value){
  207. var v = value.length > 0 ? value.join("") : 0;
  208. return {invalid: parseFloat(v)<=0};
  209. }
  210. });
  211. }else if(name == "WEIGHT" || name == "HEIGHT" || name == "CONTROL_WEIGHT"){
  212. $(el).mobiscroll().numpad({
  213. theme: 'ios',
  214. display: 'bottom',
  215. lang: 'zh',
  216. placeholder: '0',
  217. fill: 'rtl',
  218. template: 'ddd.d',
  219. allowLeadingZero: true,
  220. buttons: ['set','cancel'],
  221. onSelect: function(valueText, inst){
  222. var value = parseFloat($('.mbsc-np-dsp').text());
  223. $(this).val(value);
  224. },
  225. onShow: function(html, inst){
  226. activeField = this.name;
  227. var linkHtml = "<div class='mob-link' data-type='3'><a>您可从居民身高体重记录中获取</a></div>";
  228. html.find(".dwwr").before(linkHtml);
  229. var dialog = html.find("[role=dialog]"),
  230. top = dialog.css("top");
  231. dialog.css('top', (parseFloat(top)-30)+"px");
  232. },
  233. validate: function(value){
  234. var v = value.length > 0 ? value.join("") : 0;
  235. return {invalid: parseFloat(v)<=0};
  236. }
  237. })
  238. }else{
  239. $(el).mobiscroll().numpad({
  240. theme: 'ios',
  241. display: 'bottom',
  242. lang: 'zh',
  243. // placeholder: '0',
  244. // fill: 'rtl',
  245. // allowLeadingZero: true,
  246. // scale:0,
  247. // buttons: ['set','cancel'],
  248. // onBeforeShow: function(inst){
  249. // inst.settings.leftButton = {text:".", value:"."};
  250. // inst.settings.maxLength = 4;
  251. // inst.settings.maxScale = 4;
  252. // },
  253. onSelect: function(valueText, inst){
  254. var value = parseFloat($('.mbsc-np-dsp').text())
  255. $(this).val(value)
  256. },
  257. // validate: function(value){
  258. // var v = value.length > 0 ? value.join("") : 0;
  259. // return {invalid: parseFloat(v)<=0};
  260. // }
  261. })
  262. }
  263. })
  264. },
  265. checkBtnEnable = function(){
  266. var radios = $('input[type=radio]:checked').val();
  267. var checkboxs = $('input[type=checkbox]:checked').val();
  268. var textareas = $.trim($('textarea').val());
  269. var numbers = 0;
  270. var texts = 0;
  271. if ($('input[type=text]').length > 0 ) texts = $('input[type=text]').val().length;
  272. if(undefined == radios && undefined == checkboxs && '' == textareas) {
  273. $('#active_save').hide();
  274. $('#disable_save').show();
  275. } else {
  276. $('#active_save').show();
  277. $('#disable_save').hide();
  278. }
  279. $("input[type=number]").each(function(){
  280. var value = $(this).val();
  281. if(value.length>0){
  282. $('#active_save').show();
  283. $('#disable_save').hide();
  284. }
  285. });
  286. $("input[type=text]").each(function(){
  287. var value = $(this).val();
  288. if(value.length>0){
  289. $('#active_save').show();
  290. $('#disable_save').hide();
  291. }
  292. });
  293. },
  294. //获得收缩压和舒张压和心率等历史记录
  295. getXueyaHistoryData = function(){
  296. var url = "doctor/health_index/getHealthIndexHistory",
  297. params = {patient:patientCode, type: 2, page:0, pagesize: 3};
  298. sendGet(url, params, null, function(res){
  299. if(res.status == 200){
  300. var BP_D_list = [],
  301. BP_U_list = [],
  302. HEART_RATE_list = [];
  303. for(i=0; i<res.data.length; i++){
  304. var item = res.data[i];
  305. if(item.sys){
  306. BP_D_list.push({
  307. time: item.time.substr(0, item.time.length-3),
  308. value: item.sys,
  309. text: item.sys+"mmHg",
  310. jsonStr: JSON.stringify(item)
  311. });
  312. }
  313. if(item.dia){
  314. BP_U_list.push({
  315. time: item.time.substr(0, item.time.length-3),
  316. value: item.dia,
  317. text: item.dia+"mmHg",
  318. jsonStr: JSON.stringify(item)
  319. });
  320. }
  321. if(item.pul){
  322. HEART_RATE_list.push({
  323. time: item.time.substr(0, item.time.length-3),
  324. value: item.pul,
  325. text: item.pul+'次/分',
  326. jsonStr: JSON.stringify(item)
  327. });
  328. }
  329. }
  330. if(BP_D_list.length > 0){
  331. BP_D_OPS = template('option_tmp', {list: BP_D_list, id: "BP_D", type:2, title: "血压"});
  332. }
  333. if(BP_U_list.length > 0){
  334. BP_U_OPS = template('option_tmp', {list: BP_U_list, id: "BP_U", type:2, title: "血压"});
  335. }
  336. if(HEART_RATE_list.length > 0){
  337. HEART_RATE_OPS = template('option_tmp', {list: HEART_RATE_list, id: "HEART_RATE", type:2, title: "心率"});
  338. }
  339. }else{
  340. mui.toast(res.msg);
  341. }
  342. });
  343. },
  344. //获得体重的历史记录
  345. getWeightHistoryData = function(){
  346. var url = "doctor/health_index/getHealthIndexHistory",
  347. params = {patient:patientCode, type: 3, page:0, pagesize: 3};
  348. sendGet(url, params, null, function(res){
  349. if(res.status == 200){
  350. var weight = [];
  351. for(i=0; i<res.data.length; i++){
  352. var item = res.data[i];
  353. weight.push({
  354. time: item.time,
  355. value: item.weight,
  356. text: item.weight+"Kg"
  357. });
  358. }
  359. if(weight.length > 0){
  360. WEIGHT_OPS = template('option_tmp', {list: weight, id: "WEIGHT", type:3, title:"体重"});
  361. }
  362. }else{
  363. mui.toast(res.msg);
  364. }
  365. });
  366. },
  367. //获得血糖的历史记录
  368. getXuetangHistoryData = function(){
  369. var url = "doctor/health_index/getHealthIndexHistory",
  370. params = {patient:patientCode, type: 1, page:0, pagesize: 3};
  371. sendGet(url, params, null, function(res){
  372. if(res.status == 200){
  373. var list = [];
  374. for(i=0; i< res.data.length; i++){
  375. var item = res.data[i];
  376. list.push({
  377. time: item.time.substr(0, item.time.length-3),
  378. value: item.gi,
  379. text: item.text
  380. });
  381. }
  382. if(list.length > 0){
  383. BS_FPG_OPS = template('option_tmp', {list: list, id: "BS_FPG", type:1, title:"血糖"});
  384. }
  385. }else{
  386. mui.toast(res.msg);
  387. }
  388. });
  389. },
  390. openNewPage = function(ele){
  391. var url = ele.getAttribute("data-href"),
  392. type = ele.getAttribute("data-type");
  393. openWebview(url, {type: type, patientCode: patientCode});
  394. },
  395. bindEvents = function(){
  396. $form.on("change","input",function(){
  397. if(this.value){
  398. $("#disable_save").hide();
  399. $("#active_save").show();
  400. }else{
  401. var list = $("input"),
  402. len = list.length,
  403. empty = true;
  404. for(i=0; i< len; i++){
  405. var value = list[i].value;
  406. if(value){
  407. empty = false;
  408. }
  409. }
  410. if(empty){
  411. $("#disable_save").show();
  412. $("#active_save").hide();
  413. }
  414. }
  415. //计算BMI值 体质指数(BMI)=体重(kg)÷身高^2(m)
  416. var name = $(this).attr("name");
  417. switch(name){
  418. case "WEIGHT":
  419. case "WEIGHT_EXP":
  420. case "HEIGHT":
  421. var w = parseFloat($("input[name=WEIGHT]").val()),
  422. ex_w = parseFloat($("input[name=WEIGHT_EXP]").val()),
  423. h = parseFloat($("input[name=HEIGHT]").val());
  424. var BMI = w/(h/100 * h/100),
  425. EX_BMI = ex_w/(h/100 * h/100);
  426. if(!isNaN(BMI)){
  427. $("input[name=BMI]").val(BMI.toFixed(2));
  428. }
  429. if(!isNaN(EX_BMI)){
  430. $("input[name=BMI_EXP]").val(EX_BMI.toFixed(2));
  431. }
  432. break;
  433. }
  434. })
  435. //添加获取历史记录的按钮事件
  436. $("body").on("tap", ".mob-link", function(){
  437. var type = $(this).attr("data-type");
  438. openWebview("history_record.html",{
  439. accessData:{
  440. type: type,
  441. id: activeField,
  442. patientCode: patientCode
  443. }
  444. });
  445. $("input[name="+activeField+"]").mobiscroll("hide");
  446. })
  447. //判断checkbox和radio控件
  448. $form.on("click","input[type=checkbox]",function(){
  449. if(this.checked){
  450. $("#disable_save").hide();
  451. $("#active_save").show();
  452. this.value = 1;
  453. }else{
  454. this.value = 0;
  455. }
  456. });
  457. $form.on("click","input[type=radio]",function(){
  458. $("#disable_save").hide();
  459. $("#active_save").show();
  460. });
  461. $form.on("click",".c-check",function(){
  462. var hideType = $(this).attr('has-hide')
  463. var name = $(this).find('input').attr('name')
  464. var $list = $(this).closest('.c-list')
  465. var $textarea;
  466. if(hideType == "4") {
  467. $textarea = $list.find('textarea[name="'+name+'"]')
  468. if($(this).find('input')[0].checked) {
  469. $textarea.closest('li').show()
  470. } else {
  471. $textarea.closest('li').hide()
  472. }
  473. }
  474. });
  475. $("#active_save").on("click", function(){
  476. if(pro_id == 2) {
  477. var xy_d = $('input[name="BP_D"]').val()
  478. var xy_u = $('input[name="BP_U"]').val()
  479. if(!(xy_d && xy_u)) {
  480. mui.toast("收缩压和舒张压必填");
  481. return ;
  482. }
  483. }
  484. if(pro_id == 5) {
  485. var xtExam = $('input[name="DIA_FOLLOWUP_TYPE_CODE"]:checked').val()
  486. var xyExam = $('input[name="HYP_FOLLOWUP_TYPE_CODE"]:checked').val()
  487. if($('input[name="DIA_FOLLOWUP_TYPE_CODE"]').length>0){
  488. if(!xtExam){
  489. mui.toast("请完善必填项");
  490. return ;
  491. }
  492. }
  493. if($('input[name="HYP_FOLLOWUP_TYPE_CODE"]').length>0){
  494. if(!xyExam){
  495. mui.toast("请完善必填项");
  496. return ;
  497. }
  498. }
  499. }
  500. if(pro_id == 3) { // 实验室检查,空腹血糖、餐后血糖、随机血糖、三项需必填一项
  501. var bsValue = $('input[name="BS_FPG"]').val()
  502. || $('input[name="NO_BS_FPG"]').val()
  503. || $('input[name="RANDOM_BLOOD_SUGAR"]').val()
  504. if(!bsValue) {
  505. mui.toast("血糖必填一项");
  506. return ;
  507. }
  508. }
  509. // if(pro_id == 4) { // 运动频率、摄盐情况变更为必填
  510. // var exercise = $('input[name="EXERCISE_FREQ_CODE"]:checked').val()
  511. // var salt = $('input[name="SALT_TAKEN_LEVEL_CODE"]:checked').val()
  512. // if(!exercise) {
  513. // mui.toast("请选择运动频率");
  514. // return ;
  515. // }
  516. // if(!salt) {
  517. // mui.toast("请选择摄盐情况");
  518. // return ;
  519. // }
  520. // }
  521. if(pro_id == 8) { // 健康教育
  522. var Value = $('#jkjy').attr('data-id');
  523. if(!Value) {
  524. mui.toast("健康教育必填");
  525. return ;
  526. }
  527. }
  528. if(pro_id == 9) { // 转诊原因及机构科室变更为必填
  529. var disagree = $('input[name="DISAGREE_TRANSFER"]').val()
  530. if(!disagree || disagree=="0"){
  531. disagree = 0
  532. }else{
  533. disagree = 1
  534. }
  535. var tranferReson = $('textarea[name="TRANSFER_RESON"]').val().trim()
  536. var tranferOrgDept = $('textarea[name="TRANSFER_ORG_DEPT"]').val().trim()
  537. if(!tranferReson) {
  538. mui.toast("请输入转诊原因");
  539. return ;
  540. }
  541. if(!tranferOrgDept) {
  542. mui.toast("请输入转诊机构科室");
  543. return ;
  544. }
  545. if(disagree == 0){
  546. $('textarea[name="DISAGREE_TRANSFER"]').val('')
  547. }else{
  548. if(!$('textarea[name="DISAGREE_TRANSFER"]').val().trim()){
  549. mui.toast("请输入拒绝原因");
  550. return ;
  551. }
  552. }
  553. }
  554. plus.nativeUI.showWaiting();
  555. var url = "doctor/followup/saveFollowupProjectData",
  556. params = {id: fv_id, followupProject:pro_id},
  557. data = {};
  558. $form.serializeArray().map(function(x){data[x.name]=x.value;});
  559. if(pro_id == 7){
  560. data.CONTROL_CONSTITUTOR_DOCTORCODE = docInfo.code;
  561. }
  562. if(pro_id == 8){
  563. data.HEALTH_EDUCATE = $('#jkjy').attr('data-id');
  564. }
  565. //处理拒绝转诊字段不统一问题
  566. if(pro_id == 9){
  567. data.REFUSE_REFERRAL = disagree;
  568. data.REFUSE_REFERRAL_WHY = $('textarea[name="DISAGREE_TRANSFER"]').val().trim();
  569. delete data.DISAGREE_TRANSFER
  570. }
  571. params.followupProjectData = JSON.stringify(data);
  572. sendPost(url, params, null, function(res){
  573. plus.nativeUI.closeWaiting();
  574. mui.toast(res.msg);
  575. if(res.status == 200){
  576. var preWebview = plus.webview.getWebviewById('fvDetail'),
  577. preWebview2 = plus.webview.getWebviewById('xf_fvDetail'),
  578. curWebview = plus.webview.currentWebview();
  579. setTimeout(function(){
  580. if(preWebview){
  581. mui.fire(preWebview,"refresh")
  582. }
  583. if(preWebview2){
  584. mui.fire(preWebview2,"refresh")
  585. }
  586. },500)
  587. setTimeout(function(){
  588. curWebview.close();
  589. },1000)
  590. }
  591. }, 'POST');
  592. });
  593. $("body").on('keyup', "textarea", function(){
  594. var value = this.value,
  595. $count = $(this).siblings("p").find(".other-count");
  596. if($.trim(value) == ""){
  597. this.value = "";
  598. $count.text(0);
  599. }else{
  600. $count.text(value.length);
  601. }
  602. });
  603. };
  604. // 页面业务处理流程开始
  605. new Promise(function(resolve, reject) {
  606. // TODO 临时放开
  607. //resolve(true);
  608. mui.plusReady(function() {
  609. // plus已经准备好,可以往下执行
  610. resolve(true);
  611. });
  612. }).then(function() {
  613. // 获取基础环境信息
  614. return getBaseEnvPromise().then(function(env) {
  615. baseEnv = env;
  616. }).then(function() {
  617. // 获取登录医生信息
  618. baseInfo = getBaseInfo();
  619. //初始化页面内容
  620. initPage();
  621. // 绑定页面事件
  622. bindEvents();
  623. })
  624. }).catch(function(e) {
  625. plus.nativeUI.closeWaiting();
  626. console && console.error(e);
  627. });
  628. window.addEventListener("fillValue", function(e){
  629. var id = e.detail.id,
  630. value2 = e.detail.value2;
  631. value = e.detail.value;
  632. $("input[name="+id+"]").val(value);
  633. if(activeField == "WEIGHT" || activeField == "HEIGHT"){
  634. $("input[name=WEIGHT]").val(value)
  635. $("input[name=HEIGHT]").val(value2)
  636. var w = $("input[name=WEIGHT]").val(),
  637. h = $("input[name=HEIGHT]").val();
  638. var BMI = w/(h/100 * h/100);
  639. if(!isNaN(BMI)){
  640. $("input[name=BMI]").val(BMI.toFixed(2));
  641. }
  642. }
  643. //填充血压
  644. if(activeField == "BP_D" || activeField == "BP_U"){
  645. var $bpu = $("input[name=BP_U]"),
  646. $bpd = $("input[name=BP_D]");
  647. $bpd.val(value)
  648. $bpu.val(value2)
  649. }
  650. if(activeField == "CONTROL_BP_U" || activeField == "CONTROL_BP_D"){
  651. var $bpu = $("input[name=CONTROL_BP_D]"),
  652. $bpd = $("input[name=CONTROL_BP_U]");
  653. $bpd.val(value2)
  654. $bpu.val(value)
  655. }
  656. $("#disable_save").hide();
  657. $("#active_save").show();
  658. })
  659. window.addEventListener("fillEdu", function(e){
  660. //填充教育信息
  661. var info = JSON.parse(e.detail.info);
  662. var dateStr = info.czrq ? info.czrq.substr(0,10) : info.createTime.substr(0, 10);
  663. var type = e.detail.type;
  664. $("input[data-val=date]").val(dateStr);
  665. $("input[name=ARCHIVE_OPERATOR_NAME]").val(info.doctorName);
  666. var content = "";
  667. if(type == "zhidao"){
  668. plus.nativeUI.showWaiting();
  669. var url = "doctor/health/guidance/id",
  670. params = {id: info.id};
  671. sendPost(url, params, null, function(res){
  672. if(res.status == 200){
  673. content = res.data.content;
  674. var content1 = content.replace(/\&nbsp;/g, "");
  675. content1 = content1.replace(/<[^>]+?>/g, "");
  676. content1 = content1.substr(0, 2000);
  677. $("textarea[name=EDUCATE_CONTENT]").val(content1);
  678. $(".other-count").text(content1.length);
  679. }
  680. plus.nativeUI.closeWaiting();
  681. }, 'POST', '', true);
  682. }
  683. if(type == "edu"){
  684. var url = "/third/jkEdu/Article/getArticalById",
  685. params = {articleId: info.code, userType: 1};
  686. sendPost(url, params, null, function(res){
  687. if(res.status == 200){
  688. content = res.data.articleContent;
  689. //出去文本中的html标签的内容
  690. var content1 = content.replace(/\&nbsp;/g, "");
  691. content1 = content1.replace(/<[^>]+?>/g, "");
  692. content1 = content1.substr(0, 2000);
  693. $("textarea[name=EDUCATE_CONTENT]").val(content1);
  694. $(".other-count").text(content1.length);
  695. }
  696. }, 'GET', '', true);
  697. }
  698. $("#disable_save").hide();
  699. $("#active_save").show();
  700. });
  701. window.addEventListener("filldyy", function(e){
  702. var info = JSON.parse(e.detail.info),
  703. text = info.orgName+" "+info.deptName;
  704. $("[name=TRANSFER_ORG_DEPT]").val(text);
  705. $("[name=TRANSFER_ORG_DEPT]").siblings("p").find(".other-count").text(text.length);
  706. });