UNPKG

h5-cli

Version:

hello

205 lines (176 loc) 10.3 kB
"use strict"; define(function (require, exports, module) { var PageModule = require("component/PageModule"); var page = PageModule.render({ init: function init() { this.saveKey = "zhuyuan-cache"; this.registerData = this.cache.getCacheModule(this.saveKey); var patient = this.patient = this.registerData.get("patient"); this.patientIdNo = this.registerData.get("patientIdNo").value || "****"; this.corpId = this.query.corpId; this.unionId = this.query.unionId; this.patientId = patient.value; this.regEvent(); // if (!(patient && patient.value)) { // $("#no-patient").css("display", "block"); // $("#J_Page").css("display", "none"); // return; // // } if (patient && patient.value) { this.renderPatient(patient.name, this.patientIdNo); // this.loadData(patient.value, patient.name); } this.getPatient(this.patientId); }, //\u52a0\u8f7d\u9ed8\u8ba4\u5c31\u8bca\u4eba getPatient: function getPatient(patientId) { var self = this; PageModule.render({ init: function init() { this.get("/user-web/restapi/patient/getList", { unionId: this.query.unionId || this.unionId, corpId: this.query.corpId || this.corpId }); }, onSuccess: function onSuccess(result) { if (result.data) { var patientList = result.data; var isSelect = false; var needDefault = this.cache.get("needDefault"); for (var i = 0; i < patientList.length; i++) { if (patientId == patientList[i].id && needDefault == "false") { isSelect = true; lib.windvane.fire({ ret: "SUCCESS", origin: "self", data: "{\"patientId\":\"" + patientList[i].id + "\",\"patientName\":\"" + patientList[i].patientName + "\",\"patientIdNo\":\"" + (patientList[i].idType == 1 ? patientList[i].idNo : patientList[i].guarderIdNo) + "\",\"origin\":\"self\"}" }); break; } } if (!isSelect) { for (var i = 0; i < patientList.length; i++) { if (patientList[i].default) { isSelect = true; lib.windvane.fire({ ret: "SUCCESS", origin: "self", data: "{\"patientId\":\"" + patientList[i].id + "\",\"patientName\":\"" + patientList[i].patientName + "\",\"patientIdNo\":\"" + (patientList[i].idType == 1 ? patientList[i].idNo : patientList[i].guarderIdNo) + "\",\"origin\":\"self\"}" }); } } } if (!isSelect) { $("#no-patient").css("display", "block"); $("#J_Page").css("display", "none"); $("#J_Patient").css("display", "none"); $(".line-span").css("display", "none"); } } }, onError: function onError() {} }).init(); }, loadData: function loadData(patientId, patientName) { this.patientName = patientName; this.patientId = patientId; //alert( patientName ) this.renderPatient(patientName, this.patientIdNo); this.getCache("/user-web/restapi/inhos/patientinfo", { patientId: patientId, unionId: this.unionId, corpId: this.corpId }); $('#J_Page').addClass("wait"); }, //\u8df3\u8f6c\u5230\u9009\u62e9\u5c31\u8bca\u4eba\u9875\u9762 choosePatient: function choosePatient() { var chooseUrl = window.location.origin + window.location.pathname.slice(0, window.location.pathname.indexOf("/pages/") + 7) + "patient-list.html?selectView=1&saveKey=" + this.saveKey; //console.log( chooseUrl ) if (this.util.isInYuantuApp()) { chooseUrl += "&backview=1"; //\u767b\u5f55\u5b8c\u6210\u8df3\u8f6c\u5230\u4e0a\u4e00\u4e2a\u9875\u9762\u5e76\u5237\u65b0 this.util.brige("openView", { url: chooseUrl, animation: "left-in" }); } else { //\u76f4\u63a5\u8df3\u8f6c chrome \u5386\u53f2\u8bb0\u5f55\u4e0d\u4f1a\u8bb0\u5f55\u5f53\u524dURL Google Chrome 46.0.2490.71 (64-bit) setTimeout(function () { window.location.href = chooseUrl; }, 500); } }, //\u7ed1\u5b9a\u9875\u9762\u4e8b\u4ef6 regEvent: function regEvent() { var self = this; //\u5220\u9664\u4e0a\u4e00\u6b21\u7684\u9009\u62e9\u8bb0\u5f55 //\u4e0b\u4e00\u4e2a\u754c\u9762\u9009\u62e9\u7684\u5c31\u8bca\u4eba\uff0c\u4f1a\u901a\u8fc7windvane\u4f20\u9012\u8fc7\u6765 lib.windvane.on(function (result) { if (result.ret == "SUCCESS") { self.cache.set("needDefault", true); var data = result.data ? JSON.parse(result.data) : null; if (data.patientId && (data.origin == "self" || data.origin == "daily-list" || data.origin == "patient-list")) { self.patientIdNo = data.patientIdNo || "****"; self.loadData(data.patientId, data.patientName); } } }); }, onError: function onError(result) { var tmpl = '<div style="height: 200px;">' + '<div class="ui-notice">' + '<i></i>' + '<p>\u6ca1\u6709\u4f4f\u9662\u8bb0\u5f55</p>' + '</div>' + '</div>'; $("#J_List").html(tmpl); $('#J_Page').removeClass("wait"); this.errorHandle(result); }, onSuccess: function onSuccess(result) { this.render(result.data); $('#J_Page').removeClass("wait"); this.registerData.refresh(); this.registerData.set("hospitalize", result.data); }, renderPatient: function renderPatient(name, idNo) { $("#no-patient").css("display", "none"); $("#J_Patient").css("display", "block"); $("#J_Page").css("display", "block"); $(".line-span").css("display", "block"); var href = "../patient-list.html?corpId=" + this.corpId + "&selectView=1&saveKey=zhuyuan-cache&target=_blank"; var tmpl = '<div class="inpatient-icon" style="background-image:url(//s.yuantutech.com/i4/47f8f9bb6c859be98888b0b13c20364a-92-92.png);"></div>' + '<div class="inpatient-info" id="J_Inpatient">' + '<div class="inpatient-name">' + '<em id="inpatient-name">${name}</em>' + '<a class="inpatient-choice" href=' + href + '>\u5207\u6362\u5c31\u8bca\u4eba</a>' + '</div>' + '<div class="inpatient-idNo" id="inpatient-idNo">${idNo}</div>' + '</div>'; this.renderTo(tmpl, { name: name, idNo: idNo }, "#J_Patient"); }, render: function render(data) { this.renderPatient(this.patientName || data.name, data.idNo || this.patientIdNo); var len = 0; if (data.items == undefined) { len = 0; } else { len = data.items.length; } var self = this; var patientName = this.patientName; var patitentId = this.patientId; var tmpl = '{@each list as item}' + '<a class="hospitalize-item ui-border-tb" href="daily-list.html?patientHosId=${item.patientHosId}&target=_blank&corpId=${item.corpId}&patientId=' + patitentId + '&patientName=' + patientName + '&unionId=' + this.unionId + '">' + '<div class="hospitalize-body ">' + '<div class="hospital-name">${item.corpName}</div>' + '<div class="hospital-dept">${item.deptName}<span>\u8d39\u7528\u5408\u8ba1: <em>\u00a5${item.cost|moneyFormat}</em></span></div>' + '</div>' + '<div class="ui-border-t" style="height: 1px"></div>' + '<div class="hospitalize-title">\u5165\u9662\u65e5\u671f:${item.createDate}</div>' + '<div>\u4f4f\u9662\u53f7: ${item.patientHosId} <em class="hospitalize-status">${item.status}</em> </div>' + // '<div class="hospitalize-title">' + // '\u5165\u9662\u65e5\u671f:${item.createDate}' + // '<div class="hospitalize-status">${item.status}</div>' + // '</div>' + // '<div class="ui-border-t" style="height: 1px" ></div>' + // '<div class="hospitalize-body ">' + // '<div class="hospital-name">${item.corpName} ${item.deptName}</div>' + // '<div class="hospital-bed ui-arrowlink">' + // '\u4f4f\u9662\u53f7: <em class="bed-no">${item.patientHosId}</em>' + // '\u75c5\u533a: <em>${item.area}</em>' + // '\u5e8a\u4f4d: <em>${item.bedNo}</em>' + // '</div>' + // '<div class="hospital-cost">' + // '\u8d39\u7528\u5408\u8ba1: <em class="cost-sum">${item.cost|moneyFormat}\u5143</em>' + // '</div>' + // '</div>' + '</a>' + '{@/each}' + '{@if len == 0}<div style="height: 200px;"><div class="ui-notice"> <i></i> <p>\u6ca1\u6709\u4f4f\u9662\u8bb0\u5f55</p> </div></div>{@/if}'; this.juicer.register("moneyFormat", this.util.moneyFormat); this.renderTo(tmpl, { list: data.items, len: len }, "#J_List"); } }); page.init(); module.exports = page; });