UNPKG

h5-cli

Version:

hello

413 lines (361 loc) 14.5 kB
"use strict"; define(function (require, exports, module) { var PageModule = require("component/PageModule"); var registerToken = require("mods/register-token/index"); var condition = require("mods/condition/index"); var PageTopTip = require("mods/page-top-tip/index"); var sourceModule = PageModule.render({ init: function init() { this.sid = this.util.getSID(); //\u662f\u5426\u9700\u8981\u53f7\u6e90 this.needSource = true; this.sourceEmpty = false; //\u6392\u73ed\u53f7 this.scheduleId = this.query.scheduleId; //1 \u4e0a\u5348\uff0c 2 \u4e0b\u5348 this.medAmPm = this.query.medAmPm; this.doctName = this.query.doctName; this.doctCode = this.query.doctCode; this.hosRegType = this.query.hosRegType; this.medDate = this.query.medDate; this.regAmount = this.query.regAmount; this.deptCode = this.query.deptCode; this.deptName = this.query.deptName; this.corpName = this.query.corpName; this.regType = this.query.regType; this.regMode = this.query.regMode; this.registerData = this.cache.getCacheModule(); //\u6e32\u67d3\u524d\u9762\u9875\u9762\u6240\u6709\u9009\u62e9\u7684\u4fe1\u606f this.render(); //\u83b7\u53d6\u53f7\u539f\u6570\u636e //\u6709\u6392\u73edid\u624d\u67e5\u53f7\u6e90 12\u670818 \u548c\u6653\u98de\u7684\u5546\u91cf\u7ed3\u679c if (this.scheduleId) { this.util.waitAlert("\u6b63\u5728\u83b7\u53d6\u53f7\u6e90..."); /* corpId:261 type:4 deptCode:0028 parentDeptCode:0028 regMode:1 medAmPm:2 medDate:2016-11-18 doctCode:001568 scheduleId:1199347 */ this.get("/user-web/restapi/common/reservation/numbersource", { corpId: this.corpId, // type:this.type, regType: this.regType, // type:this.regType, deptCode: this.deptCode, parentDeptCode: this.deptCode, doctCode: this.doctCode, regMode: this.regMode, medAmPm: this.medAmPm, medDate: this.medDate, // id:this.query.id, scheduleId: this.scheduleId }); } else { this.onSuccess({}); } if (this.type == "56") { //\u5982\u679c\u662f\u89c6\u5c4f\u9884\u7ea6\u7684\u65f6\u5019\u5c31init\u75c5\u60c5\u6a21\u5757 condition.init(true); } //\u5982\u679c\u662f\u6302\u53f7\uff0c\u663e\u793a\u6302\u53f7\u4e0d\u80fd\u9000\u53f7\u6587\u6848 if (this.regMode == 2) { PageTopTip.init('#J_TopTip', 'regdetails'); } //\u6ce8\u518c\u4e8b\u4ef6 this.regEvent(); }, //\u662f\u5426\u9700\u8981\u9009\u62e9\u53f7\u6e90 isNeedSource: function isNeedSource() { return this.needSource; }, //\u53f7\u6e90\u662f\u5426\u4e3a\u7a7a isSourceEmpty: function isSourceEmpty() { return this.sourceEmpty; }, // \u5982\u679c\u7528\u6237\u5207\u6362\u8d26\u6237\u91cd\u65b0\u767b\u5f55 onActivation: function onActivation() { if (this.sid != this.util.getSID()) { this.sid = this.util.getSID(); //\u5220\u9664\u4e4b\u524d\u9009\u62e9\u7684\u5c31\u8bca\u4eba //this.registerData.remove("patient"); //\u91cd\u65b0\u8f7d\u5165\u9875\u9762 location.reload(); } }, //\u7ed1\u5b9a\u9875\u9762\u4e8b\u4ef6 regEvent: function regEvent() { var registerData = this.cache.getCacheModule(); //\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") { var data = result.data ? JSON.parse(result.data) : null; if (data.patientId) { registerData.set("patient", data.patientId, data.patientName); $('#J_PatientName').val(data.patientName); } } }); // return ; var patient = registerData.get("patient"); //\u67e5\u770b\u4e0a\u6b21\u5c31\u8bca\u4eba \u662f\u5426 \u672a\u5f53\u524d\u7528\u6237\u7684 this.renderPatient(patient.value); }, //\u52a0\u8f7d\u9ed8\u8ba4\u5c31\u8bca\u4eba renderPatient: function renderPatient(patientId) { PageModule.render({ init: function init() { this.get("/user-web/restapi/patient/getList", { corpId: this.query.corpId || this.corpId }); }, onSuccess: function onSuccess(result) { if (result.data) { var patientList = result.data; var isSelect = false; for (var i = 0; i < patientList.length; i++) { if (patientId == patientList[i].id) { isSelect = true; lib.windvane.fire({ ret: "SUCCESS", data: '{"patientId":"' + patientList[i].id + '","patientName":"' + patientList[i].patientName + '"}' }); break; } } if (!isSelect && patientList[0]) { lib.windvane.fire({ ret: "SUCCESS", data: '{"patientId":"' + patientList[0].id + '","patientName":"' + patientList[0].patientName + '"}' }); } } }, onError: function onError() {} }).init(); }, render: function render() { // var var registerData = this.registerData; //\u4e0a\u4e00\u4e2a\u9875\u9762\u65b0\u63a5\u53e3\u53ef\u4ee5\u7a7f\u533b\u9662\u540d\u5b57\u8fc7\u6765 $('#J_dropName').val(this.corpName); $('#J_deptName').val(this.deptName); // console.log( this.doctCode ) if (this.doctName) { $('#J_doctorName').val(this.doctName); } else { //\u5982\u679c\u662f\u9884\u7ea6\u5230\u79d1\u5ba4\u7684\uff0c\u5c31\u4e0d\u663e\u793a\u533b\u751f $('#J_DoctorItem').addClass("hide"); } $('#J_Date').val(this.medDate + " " + { "1": "\u4e0a\u5348", "2": "\u4e0b\u5348" }[this.medAmPm]); var type = this.registerData.get("type").value; // $('#J_Submit').text("\u786e\u8ba4"+ (type<=3 ? "\u6302\u53f7" : "\u9884\u7ea6")); // if(type<=3){ $('#J_ShowRegAmount').removeClass("hide"); $('#J_RegAmount').val("\uffe5" + this.util.rmb(this.regAmount / 100)); // } //<span class="y">\uffe5</span> }, onError: function onError() { // this.util.alert("\u6ca1\u6709\u627e\u5230\u53ef\u7528\u53f7\u6e90"); $('#J_regNoList').html('<option value="">\u6ca1\u6709\u53f7\u6e90</option>'); }, onSuccess: function onSuccess(result) { // result.data = { // needSource: //\u662f\u5426\u9700\u8981\u9009\u62e9\u53f7\u6e90 // sourceList: // } var data = result.data; if (data && data.needSource) { this.needSource = true; var list = data.sourceList ? data.sourceList : []; var html = ""; if (list.length) { // var tmpl = '<option value="'+ list[i].appoNo+","+list[i].medBegTime +","+list[i].medEndTime +'">'+ list[i].appoNo +'\u53f7 '+list[i].medBegTime + "~"+ list[i].medEndTime+'</option>'; html = '{@each sourceList as item}' + '<option value="${string(item.appoNo)},${string(item.medBegTime)},${string(item.medEndTime)}">${hao(item.appoNo)} ${string(item.medBegTime)}~${string(item.medEndTime)}</option>' + '{@/each}'; } else { this.sourceEmpty = true; html = '<option value=",,,">\u6ca1\u6709\u53f7\u6e90</option>'; } this.juicer.register("hao", function (value) { if (value == null || value === undefined) { return ""; } return value + "\u53f7"; }); // $('#J_regNoList').html( html ); this.renderTo(html, data, '#J_regNoList'); } else { //\u4e0d\u9700\u8981\u53f7\u6e90 this.needSource = false; $('#J_SourceSelect').addClass("hide"); } } }); //\u6839\u636epatientId,cropId\u5224\u65ad\u662f\u5426\u8981\u7ed1\u5361 var isNeddBindCard = PageModule.render({ init: function init() { this.registerData = this.cache.getCacheModule(); // console.log(this.registerData.get("patient").value,this.query.cropId) this.util.waitAlert("\u533b\u9662\u7ed1\u5361\u4fe1\u606f"); this.get("/user-web/restapi/card/isNeddBindCard", { patientId: this.registerData.get("patient").value, corpId: this.query.corpId }); }, onSuccess: function onSuccess(result) { console.log(result); this.data = result.data; }, getData: function getData() { return this.data; } }); //\u70b9\u51fb\u786e\u8ba4\u6309\u94ae\u7684\u4ea4\u4e92 var register = PageModule.render({ init: function init() { this.isSubmit = 0; this.regEvent(); }, regEvent: function regEvent() { var self = this; $('#J_Submit').click(function () { // if(self.checkLogin()){ self.submit(); // } }); }, submit: function submit() { var corpId = this.corpId; //\u533b\u751f\u9875\u9762\u53ef\u80fd\u6539\u53d8\u7c7b\u578b // var type = this.query.type || this.registerData.get("type").value; this.registerData = this.cache.getCacheModule(); var scheduleId = this.query.scheduleId; var regType = this.query.regType; var regMode = this.query.regMode; var deptCode = this.query.deptCode; // this.registerData.get("deptCode").value; var doctCode = this.query.doctCode; //this.registerData.get("doctor").value; var medDate = this.query.medDate; //this.registerData.get("medDate").value; var medAmPm = this.query.medAmPm; //this.registerData.get("medAmPm").value; // var id = this.registerData.get("id").value; var noList = $('#J_regNoList').val(); var appoNo = noList.split(',')[0]; var medBegTime = noList.split(',')[1]; var medEndTime = noList.split(',')[2]; var patientId = this.registerData.get("patient").value; var parentDeptCode = this.registerData.get("parentDeptCode").value; // var hosRegType = this.registerData.get("hosRegType").value; // console.log(corpId, type, deptCode, doctCode,date, medAmPm, regNo, patientId) if (!corpId) { this.util.alert("\u6ca1\u6709\u9009\u62e9\u533b\u9662"); return; } if (!deptCode) { this.util.alert("\u6ca1\u6709\u9009\u62e9\u79d1\u5ba4"); return; } if (!medDate) { this.util.alert("\u6ca1\u6709\u9009\u62e9\u5c31\u8bca\u65f6\u95f4"); return; } if (!medAmPm) { this.util.alert("\u6ca1\u6709\u9009\u62e9\u5c31\u8bca\u65f6\u95f4"); return; } if (sourceModule.isNeedSource()) { if (sourceModule.isSourceEmpty()) { this.util.alert("\u53f7\u6e90\u88ab\u62a2\u5149\u4e86\uff01"); return; } //\u9700\u8981\u9009\u62e9\u53f7\u6e90 \u9a8c\u8bc1 // if(!appoNo){ // this.util.alert("\u8bf7\u9009\u62e9\u5c31\u8bca\u53f7"); // return ; // } } if (!patientId) { this.util.alert("\u8bf7\u9009\u62e9\u5c31\u8bca\u4eba"); return; } //\u91cd\u590d\u63d0\u4ea4 if (this.isSubmit == 1) { return; } //\u89c6\u5c4f\u9884\u7ea6\u7684\u75c5\u60c5\u63cf\u8ff0\u548c\u56fe\u7247 var conditionContent = condition.getContent(); var conditionPhotos = condition.getPhotos(); this.isSubmit = 1; this.util.waitAlert("\u8bf7\u7b49\u5f85...", 100); // this.regMode = 1 \u9884\u7ea6 2\u6302\u53f7 var url = "/user-web/restapi/reservation/appointCreateOrder"; if (regMode == 2) { url = "/user-web/restapi/reservation/regCreateOrder"; } this.get(url, { scheduleId: scheduleId, corpId: corpId, regType: regType, regMode: regMode, deptCode: deptCode, doctCode: doctCode, parentDeptCode: parentDeptCode, medDate: medDate, appoNo: appoNo, medAmPm: medAmPm, patientId: patientId, medBegTime: medBegTime, medEndTime: medEndTime, diseaseDesc: conditionContent ? conditionContent.slice(0, 300) : conditionContent, diseaseImageUrl: conditionPhotos }); }, getRegModeType: function getRegModeType(regMode) { return { "1": "\u9884\u7ea6", "2": "\u6302\u53f7" }[regMode] || ""; }, onSuccess: function onSuccess(result) { var self = this; //\u767b\u8bb0\u8bbe\u5907\u53f7 registerToken.init(); var data = isNeddBindCard.getData(); if (result.data && data.needBindCard) { var msg = data.msg || ""; var msgs = msg.split("</br>"); self.registerData = self.cache.getCacheModule(); var content = msgs[0] + "</br>" + "<span style='font-size: 12px;color: rgba(31, 29, 29, 0.95);'>" + msgs[1] + "</span>"; self.util.dialog(content, function (okay) { if (okay) { location.href = "bind-card.html?cardType=" + data.cardType + "&unionId=" + data.unionId + "&patientId=" + self.registerData.get("patient").value + "&target=_blank"; // bind-card.html?cardType=${cardType}&description=${description}&unionId=' + this.unionId + '&patientId=' + this.patientId + '&target=_blank" } else { // self.util.brige("popToRootViewController"); // window.location.href = "register-details-2.html?corpId="+result.data.corpId+"&id="+result.data.id; } }, { cancel: true, cancelText: "\u6682\u4e0d\u7ed1\u5361", ok: true, okText: "\u7ed1\u5b9a\u5c31\u8bca\u5361" }); } else if (result.data) { window.location.href = "register-details-2.html?corpId=" + result.data.corpId + "&id=" + result.data.id; } //\u6d41\u7a0b\u4fee\u6539 return; }, onError: function onError(result) { this.isSubmit = 0; this.util.waitHide(); this.errorHandle(result); } }); //\u53f7\u6e90\u4fe1\u606f sourceModule.init(); //\u4fdd\u5b58\u6309\u94ae register.init(); //\u5224\u65ad\u662f\u5426\u7ed1\u5361 isNeddBindCard.init(); module.exports = sourceModule; });