123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- var d = dialog({contentType:'load', skin:'bk-popup', content:''});
- var userAgent = localStorage.getItem(agentName);
- var patient, doctor, healthDoctor, doctorName, healthDoctorName;
- var doctors = [];
- var request = GetRequest();
- var changeDoctor = request.changeDoctor; //标记是否是从医生发起的模板消息
- var request = GetRequest();
- var signStatus = request.signStatus;
- var isSignLimit = false; //判断签约人数是否达到上限
- if(userAgent){
- userAgent = JSON.parse(userAgent);
- patient = userAgent.represented?userAgent.represented:userAgent.uid;
- }
- $(function() {
- // var referrer = document.referrer;
- getSignMessage();
-
- $('#agree_btn').on('click',function() {
- //判断当前时间是否在2017年度
- // var date = new Date();
- // if(date.getFullYear() != 2017){
- // dialog({
- // content: "对不起,2017年度续签工作已结束,无法发起续签工作",
- // okValue: "我知道了",
- // ok: function(){}
- // }).showModal();
- // return false;
- // }else{
- // if(referrer.indexOf("xuqian/html/information.html") == -1){
- checkRenewEnable();
- // }else{
- // showDialogInfo(signStatus);
- // }
-
- // }
- });
-
- $("#changeDoctor").on("click", function(){
- window.localStorage.setItem("is_renew", "1");
- window.location.href = "../../qygl/html/select-doctor.html?renew=1";
- });
- });
- function checkRenewEnable(){
- //判断是否可以续签
- var url = "/patient/family_contract/checkCanRenew",
- params = {patient: userAgent.represented?userAgent.represented:userAgent.uid};
- d.show();
- sendPost(url, params, "json", "post", reqFailed , function(res){
- if(res.status == 200){
- d.close();
- var code = res.data.code,
- msg = res.data.mes,
- enable = true;
-
- switch (parseInt(code)){
- case -5:
- msg = "医生已同意您的续签,您无需再次签约";
- enable = false;
- break;
- case -4:
- msg = "您当前无可续签的家庭医生,可在签约管理页面签约医生";
- enable = false;
- break;
- case -3:
- //已经提交续签申请了
- msg = "您已提交过申请,无需重复提交";
- enable = false;
- break;
- case -2:
- msg = "您已完成2017~2018年度签约,不能再次签约";
- enable = false;
- break;
- case -1:
- msg = "当前时间段不允许续签,可前往签约管理页面签约医生";
- enable = false;
- break;
- case 0:
- msg = "患者数据有误";
- enable = false;
- break;
- }
- if(!enable){
- if(code == "-4" || code == "-1"){
- dialog({
- content: msg,
- okValue: "我知道了",
- ok: function(){
- location.href = "../../qygl/html/signing_management.html";
- }
- }).showModal();
- }else{
- dialog({
- content: msg,
- okValue: "我知道了",
- ok: function(){
- }
- }).showModal();
- }
- }else{
- showDialogInfo(code);
- }
- }else{
- reqFailed(res);
- }
- });
- }
- //弹框信息
- function showDialogInfo(status){
- if(status == 1){
- if(parseInt(changeDoctor)){
- if(isSignLimit){
- dialog({
- content: doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生",
- okValue: "选择其他医生",
- ok: function(){
- window.localStorage.setItem("is_renew", "1");
- window.location.href = "../../qygl/html/select-doctor.html?renew=1";
- },
- cancelValue: "我再看看",
- cancel: function(){}
- }).showModal();
- }else{
- dialog({
- content: "是否向"+doctors.join("、")+"提交续签申请?提交后无法变更",
- okValue: "立即提交",
- ok: function(){
- var renew = window.localStorage.getItem("is_renew");
- if(renew){
- window.localStorage.setItem("is_renew", "0");
- }
- renewSign();
- },
- cancelValue: "我再看看",
- cancel: function(){}
- }).showModal();
- }
- }else{
- var content = "";
- if(isSignLimit){
- content = doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生";
- $("#renewSign").hide();
- }else{
- content = "是否向"+doctors.join("、")+"提交续签申请?提交后无法变更";
- }
- $("#remind-msg").text(content);
- mui('#sheet1').popover('toggle');
- }
- }
- if(status == 2){ //签约过期的患者
- getOverdueSignMessage();
- }
- }
- /*获取签约信息*/
- function getSignMessage(){
- d.show();
- var url = "/patient/family_contract/getSignMessage",
- params = {patientCode: patient};
-
- sendPost(url, params, "json", "post", reqFailed, function(res){
- if(res.status == 200){
- d.close();
- var len = res.list.length;
- for(i=0; i< len; i++){
- var item = res.list[i];
- if(item.level == 2){
- doctor = item.code;
- doctorName = item.name;
- }
- if(item.level == 3){
- healthDoctor = item.code;
- healthDoctorName = item.name;
- }
- }
- if(doctorName){
- doctors.push(doctorName);
- }
- if(healthDoctorName){
- doctors.push(healthDoctorName);
- }
- if(doctor){
- getDoctorInfo();
- }
- }else{
- reqFailed(res);
- }
- });
- }
- //获取已过期的签约信息
- function getOverdueSignMessage(){
- var url = "/patient/family_contract/getSignMessageOverdue",
- params = {patientCode: patient};
- d.show();
- sendPost(url, params, "json", "get", reqFailed, function(res){
- if(res.status == 200){
- d.close();
- var len = res.list.length;
- for(i=0; i< len; i++){
- var item = res.list[i];
- if(item.level == 2){
- doctor = item.code;
- doctorName = item.name;
- }
- if(item.level == 3){
- healthDoctor = item.code;
- healthDoctorName = item.name;
- }
- }
- if(doctorName){
- doctors.push(doctorName);
- }
- if(healthDoctorName){
- doctors.push(healthDoctorName);
- }
- getDoctorInfo(function(){
- if(parseInt(changeDoctor)){
- if(isSignLimit){
- dialog({
- content: doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生",
- okValue: "选择其他医生",
- ok: function(){
- window.localStorage.setItem("is_renew", "1");
- window.location.href = "../../qygl/html/select-doctor.html?renew=1";
- },
- cancelValue: "我再看看",
- cancel: function(){}
- }).showModal();
- }else{
- dialog({
- content: "是否向"+doctors.join("、")+"提交续签申请?提交后无法变更",
- okValue: "立即提交",
- ok: function(){
- var renew = window.localStorage.getItem("is_renew");
- if(renew){
- window.localStorage.setItem("is_renew", "0");
- }
- renewSign();
- },
- cancelValue: "我再看看",
- cancel: function(){}
- }).showModal();
- }
- }else{
- var content = "";
- if(isSignLimit){
- content = doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生";
- $("#renewSign").hide();
- }else{
- content = "是否向"+doctors.join("、")+"提交续签申请?提交后无法变更";
- }
- $("#remind-msg").text(content);
- mui('#sheet1').popover('toggle');
- }
- });
-
- }else{
- reqFailed(res);
- }
- });
- }
- //获取医生是否签约达到上限
- function getDoctorInfo(cb){
- var url = 'family_contract/homepage/homepage',
- data = {doctor: doctor};
- sendPost(url, data, 'json', 'post', reqFailed, function(res){
- if(res.status == 200){
- //判断签约人数是否达到上限
- if(res.data.signTotal >= res.data.limitTotal){
- isSignLimit = true;
- }
- if(cb && (typeof cb == "function")){
- cb();
- }
- }else{
- reqFailed(res);
- }
- });
- }
- //续签
- function renewSign(){
- var url = "/patient/family_contract/signRenew",
- params = {
- doctor: doctor || "",
- healthDoctor: healthDoctor || "",
- patient: patient
- };
- d.show();
- sendPost(url, params, "json", "post", reqFailed, function(res){
- if(res.status == 200){
- d.close();
- window.location.href = "../../qygl/html/signing_management.html";
- }else{
- reqFailed(res);
- }
- })
- }
- function reqFailed(res){
- d.close();
- if(res.msg){
- dialog({
- contentType:'tipsbox',
- bottom:true,
- skin:'bk-popup',
- content: res.msg
- }).show();
- }else{
- dialog({
- contentType:'tipsbox',
- bottom:true,
- skin:'bk-popup',
- content: "请求失败,请重试"
- }).show();
- }
- }
- function notSignFlow(){
- dialog({
- content: "您当前未签约家庭医生,是否前往签约家庭医生?",
- okValue: "签约家庭医生",
- ok: function(){
- location.href = "../../qygl/html/select-doctor.html";
- },
- cancelValue: "不了,谢谢",
- cancel: function(){}
- }).showModal();
- }
- function preSignedFlow(){
- dialog({
- content: "您已完成2017~2018年度预签约,不能再次签约",
- okValue: "我知道了",
- ok:{}
- }).showModal();
- }
|