123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677 |
- var patient,
- msgId,
- signCode,
- applyDate,
- renewFlag = 1; //1-普通续签,2-转签
- var docInfo;
- var refuseReason = '';//拒绝签约原因
- //下拉框选中的数据
- var currHealthManagement,
- currService,
- currTeam;
- var $juminLabels = $('#jumin_labels input[data-val=jumin_labels]');
- mui.init();
- mui.plusReady(function(){
- var self = plus.webview.currentWebview();
- patient = self.patient;
- msgId = self.msgId;
- signCode = self.signCode;
- applyDate = self.applyDate;
- renewFlag = self.renewFlag || renewFlag;
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- getPatientInfo();
- bindEvents();
- templateHelper();
- });
- function getPatientInfo(){
- // var url = "/doctor/family_contract/patient_signing_renew", //"/doctor/patient_label_info/patient",
- // params = {
- // patient: patient
- // };
- var date = new Date();
- // if(date.getMonth() > 5){ //7月份开始,算是签约过期流程,请求不一样
- getInfo2();
- // }else{
- // getInfo1();
- // }
- }
- //获得未过期的续签信息
- function getInfo1(){
- plus.nativeUI.showWaiting();
- var promise = getReqPromises([{url:"/doctor/family_contract/patient_signing",data:{patient: patient}},//居民信息
- {url:"/doctor/admin-teams/team/"+ docInfo.code +"/teamsLimit",data:{},reqType: 'GET'},
- {url:"/doctor/sign/getSigndict", data:{}, reqType: "GET"},//获取服务类型信息
- {url:"/common/getDictByDictName?name=SIGN_EXPENSES",data:{},reqType: 'GET'}])//设置政府补贴;
- return promise.then(function(datas){
- var data0 = datas[0],
- data1 = datas[1];
- data3 = datas[3];
- var teamName = "";
- if(data0.status == 200) {
- if(renewFlag == "2"){
- var url = "/doctor/sign/getTeamNameByTeamCode",
- params = {teamCode: data0.data.jtAdminTeam};
- sendGet(url, params, null, function(res){
- data0.data.teamName = res.data;
- data0.data.renewFlag = renewFlag;
- data0.data.applyDate = applyDate;
- var html = template("info_tmp", data0.data);
- $("#pati_info").empty().append(html);
- getQytd(data1);
- setExpenses(data3);
- });
- }else{
- var isFilled = false;
- for(i=0; i<data1.data.length; i++){
- var item = data1.data[i];
- if(item.id == data0.data.jtSign.adminTeamId){
- if(item.signCount >= item.signLimitNumber){
- teamName = item.name+"<span class='filled'>(已达上限)</span>";
- isFilled = true;
- $('#btn_agree').addClass("disabled").attr("disabled", true);
- }else{
- teamName = item.name+"(已签约"+item.signCount+"人)";
- }
- break;
- }
- }
- data0.data.teamName = teamName;
- data0.data.renewFlag = renewFlag;
- data0.data.applyDate = applyDate;
- var html = template("info_tmp", data0.data);
- $("#pati_info").empty().append(html);
-
- if(isFilled && (data1.data.length > 1)){
- getQytd(data1);
- $("#qytdNum").after('<span class="mui-icon c-icon-right"></span>');
- $("#jgLi").append('<span class="mui-icon c-icon-right"></span>');
- $("#btLi").append('<span class="mui-icon c-icon-right"></span>');
- }
- setExpenses(data3);
- }
- }else{
- mui.toast(data0.msg)
- }
- var data2 = datas[2];
- fillServiceDropdown(data2);
- plus.nativeUI.closeWaiting();
- });
- }
- //处理已过期签约关系的续签信息
- function getInfo2(){
- plus.nativeUI.showWaiting();
- var promise2 = getReqPromises([{url:"/doctor/family_contract/patient_signing_outtime",data:{patient: patient}},//居民信息
- {url:"/doctor/admin-teams/team/"+ docInfo.code +"/teamsLimit",data:{},reqType: 'GET'},
- {url:"/doctor/sign/getSigndict", data:{}, reqType: "GET"},//获取服务类型信息
- {url:"/common/getDictByDictName?name=SIGN_EXPENSES",data:{},reqType: 'GET'}]);//设置政府补贴
- return promise2.then(function(datas){
- plus.nativeUI.closeWaiting();
- var data0 = datas[0],
- data1 = datas[1],
- data3 = datas[3];
- var teamName = "";
- if(data0.status == 200) {
- var expense = data0.data.jtSign.expensesType,
- list = data3.list,
- obj = _.findWhere(list, {code: expense}),
- expenseName = obj.value;
- var info = {
- teamName : teamName,
- photo: data0.data.photo,
- name: data0.data.name,
- sex: data0.data.sex,
- age: data0.data.age,
- renewTime: data0.data.applyDate,
- applyDate: applyDate,
- idcard: data0.data.idCard,
- medicareNumber: data0.data.medicareNumber,
- ssc: data0.data.ssc,
- mobile: data0.data.mobile,
- provinceName: data0.data.provinceName,
- cityName: data0.data.cityName,
- address: data0.data.address,
- jtDoctorName: data0.data.jtSign.doctorName,
- jtDoctorHealthName: data0.data.jtSign.doctorHealthName,
- jtAdminTeam: data0.data.jtSign.adminTeamId,
- jtHospitalName: data0.data.jtSign.hospitalName,
- renewFlag: renewFlag,
- countryName:data0.data.countryName,
- //添加政府补贴内容
- expensesType: expense,
- expenseName: expenseName
- };
- if(renewFlag == "2"){
- var url = "/doctor/sign/getTeamNameByTeamCode",
- params = {teamCode: data0.data.jtSign.adminTeamId};
- sendGet(url, params, null, function(res){
- info.teamName = res.data;
-
- var html = template("info_tmp", info);
- $("#pati_info").empty().append(html);
- getQytd(data1);
- setExpenses(data3);
- });
- }else{
- var isFilled = false;
- for(i=0; i<data1.data.length; i++){
- var item = data1.data[i];
- if(item.id == data0.data.jtSign.adminTeamId){
- if(item.signCount >= item.signLimitNumber){
- teamName = item.name+"<span class='filled'>(已达上限)</span>";
- isFilled = true;
- $('#btn_agree').addClass("disabled").attr("disabled", true);
- }else{
- teamName = item.name+"(已签约"+item.signCount+"人)";
- }
- break;
- }
- }
- // 修复bug#3551 【医生端】续签未变更续签团队,原本签约团队没有显示出来
- info.teamName = teamName;
- var html = template("info_tmp", info);
- $("#pati_info").empty().append(html);
- if(isFilled && (data1.data.length > 1)){
- getQytd(data1);
- $("#qytdNum").after('<span class="mui-icon c-icon-right"></span>');
- $("#jgLi").append('<span class="mui-icon c-icon-right"></span>');
- $("#btLi").append('<span class="mui-icon c-icon-right"></span>');
- }
- setExpenses(data3);
- }
- }else{
- mui.toast(data0.msg)
- }
- var data2 = datas[2];
- fillServiceDropdown(data2);
- plus.nativeUI.closeWaiting();
- });
- }
- //获取签约团队
- function getQytd(res){
- if(res.status == 200) {
- if(res.data.length == 0){
- alert("查无签约团队");
- return;
- }
- var teams = res.data,
- teamCodes=[],
- teamNames=[];
- // 萃取数组对象中code、name,返回一个数组
- teamCodes = _.pluck(teams, 'id');
- // teamNames = _.pluck(teams, 'name');
- for(var i = 0; i < teams.length; i++){
- var signTeam;
- var signCount = teams[i].signCount;
- var signLimitNumber = teams[i].signLimitNumber;
- if(signCount >= signLimitNumber){
- signTeam = teams[i].name + "<span class='filled'>(已达上限)</span>";
- }else{
- signTeam = teams[i].name + "(已签约"+signCount+"人)";
- }
- teamNames.push(signTeam);
- }
- qytdSelect(teamCodes, teamNames);
- }
- }
- // 设置团队下拉框
- function qytdSelect(teamCodes, teamNames) {
- // var $doctorQytdInput = $('input[data-val=qytd]');
- var $doctorQytdInput = $('#qytdNum');
- $doctorQytdInput.mobiscroll({
- theme: 'ios',
- lang: 'zh',
- customWheels: true,
- wheels: [
- [{
- keys: teamCodes,
- values: teamNames
- }]
- ],
- onSelect: function(valueText, inst) {
- var valueTextZy = valueText.replace("<span class='filled'>", "<span class=\\\'filled\\\'>");
- var dd = eval("[" + valueTextZy + "]"),
- name=dd[0].values;
- currTeam = dd[0].keys;
- // $(this).val(name);
- $(this).html(name);
-
- $(this).html(name);
- $(this).removeClass("c-9e9e9e");
- var isFilled = $(this).find("span").hasClass("filled");
- if(isFilled){
- $('#btn_agree').addClass("disabled").attr("disabled", true);
- }else{
- $('#btn_agree').removeClass("disabled").attr("disabled", false);
- }
-
- if($(this).text().length>20){
- $doctorQytdInput.css({textAlign:'left'});
- }else{
- $doctorQytdInput.css({textAlign:'right'});
- }
-
- $doctorQytdInput.attr("data-code",currTeam);
- $('input[data-val=healthManagement]').val("").attr("data-code","")
- getTeamMember(currTeam);
- }
- })
- }
- //普通 老年 高血 糖尿 孕妇 儿童 贫困 计生 重性 残疾 结核
- function filterSer(name){
- var $li = $('.dw-bf').find('div.dw-li');
- $li.addClass('dw-v');
- var nameArr = name.split(',');
- $.map(nameArr,function(item,index){
- if(item.trim() == '普通人群'){
- var arr = [2,3,6,7,8,9,10]
- $.map(arr,function(it,index){
- $li.eq(it).removeClass('dw-v')
- })
- }
- if(item.trim() == '老年人'){
- var arr = [4,5]
- $.map(arr,function(it,index){
- $li.eq(it).removeClass('dw-v')
- })
- }
- if(item.trim() == '高血压' ||item.trim() == '糖尿病'||item.trim() == '贫困人口'||item.trim() == '计生特殊人群'||item.trim() == '重性精神疾病'||item.trim() == '残疾人'||item.trim() == '结核病' ){
- var arr = [0]
- $.map(arr,function(it,index){
- $li.eq(it).removeClass('dw-v')
- })
- }
- if(item.trim() == '0-6岁儿童'){
- var arr = [1,4]
- $.map(arr,function(it,index){
- $li.eq(it).removeClass('dw-v')
- })
- }
- if(item.trim() == '孕产妇'){
- var arr = [1,5]
- $.map(arr,function(it,index){
- $li.eq(it).removeClass('dw-v')
- })
- }
- })
- }
- //设置服务类型下拉
- function fillServiceDropdown(data){
- var $serviceSel = $('#selFuwu'),
- data = data.data,
- html="";
- for(i=0; i<data.length; i++){
- html += '<option value="'+data[i].code+'">'+data[i].name+'</option>'
- }
- $serviceSel.html(html);
- $serviceSel.mobiscroll().select({
- theme: 'ios',
- lang: 'zh',
- display: 'bottom',
- rows:6,
- placeholder:'请选择服务类型',
- onSelect: function ( valueText, inst) {
- // var vArr = valueText.split(',');
- //判断服务类型是否变更
- $juminLabels.val("").attr("data-code",JSON.stringify({health: "",disease: "", custom: "" }));
- currService = inst._tempValue?inst._tempValue.join(','):'';
- },
- onChange: function (event, inst) {
- filterSer(event)
- },
- onShow: function (event, inst) {
- filterSer(inst)
- }
- })
- }
- //获取团队成员
- function getTeamMember(teamCode){
- plus.nativeUI.showWaiting();
- sendGet("/doctor/admin-teams/"+ teamCode + "/members", {}, null, function(res){
- if(res.status == 200){
- var jgs= [],
- jgCodes =[], jgNames = [];
-
- $.each(res.data, function(i, v) {
- if(v.level == 3 || v.level == 2)
- jgs.push(v);
- });
-
- // 萃取数组对象中code、name,返回一个数组
- jgCodes = _.pluck(jgs, 'code');
- jgNames = _.pluck(jgs, 'name');
- activHealthM(jgCodes, jgNames);
- } else
- mui.toast("获取团队成员失败!");
- plus.nativeUI.closeWaiting();
- })
- }
- //填充健管师下拉框
- function activHealthM(codes, names) {
- $('input[data-val=healthManagement]').mobiscroll({
- theme: 'ios',
- lang: 'zh',
- customWheels: true,
- wheels: [
- [{
- keys: codes,
- values: names
- }]
- ],
- onSelect: function(valueText, inst) {
- var dd = eval("[" + valueText + "]");
- var name=dd[0].values
- $(this).val(name);
- currHealthManagement = dd[0].keys;
- $(this).attr("data-code",currHealthManagement);
- }
- });
- };
- //获取政府补贴数据
- function setExpenses(res){
- var expensesCode=[];
- var expensesName=[];
-
- if(res.status == 200) {
- var expensesList = res.list;
- for(var i = 0; i < expensesList.length; i++) {
- expensesCode.push(expensesList[i].code);
- expensesName.push(expensesList[i].value);
- }
- activExpensesM(expensesCode,expensesName);
- };
- }
- //设置政府补贴下拉框
- function activExpensesM(expensesCodes,expensesNames) {
- var $expensesInput = $('input[data-val=expenses]');
- $expensesInput.mobiscroll({
- theme: 'ios',
- lang: 'zh',
- customWheels: true,
- wheels: [
- [{
- keys: [expensesCodes[1],expensesCodes[0],expensesCodes[3],expensesCodes[2]],
- values: [expensesNames[1],expensesNames[0],expensesNames[3],expensesNames[2]]
- }]
- ],
- onSelect: function(valueText, inst) {
- var dd = eval("[" + valueText + "]");
- var name=dd[0].values
- $(this).val(name);
- currExpenses = dd[0].keys;
- $('input[data-val=expenses]').attr("data-code",currExpenses);
- }
- });
- // 获取政府补贴下拉框mibiscroll实例
- var expensesMobiscroll = $expensesInput.mobiscroll('getInst');
- var valueText = "{keys:'"+$expensesInput.attr("data-code")+"',values:'"+$expensesInput.val()+"'}";
- expensesMobiscroll.setVal([valueText]);
- }
- function validForm(){
- if(!$('#agreement_checkbox').hasClass('checked')) {
- mui.toast("您还未接受签约协议");
- return false;
- }
-
- // if(renewFlag == "2"){ //改签
- if(!$.trim($("#qytdNum").attr("data-code"))){
- mui.toast("请选择签约团队!");
- return false;
- }
- if($("input[data-val=healthManagement]").val()==""){
- mui.toast("请选择健康管理师!");
- $("#btn_agree").attr("disabled",false);
- return false;
- }
- // }
-
- if(!currService){
- mui.toast("请选择服务类型!");
- return false;
- }
- var labelObj = $juminLabels.attr("data-code");
- labelObj = JSON.parse(labelObj);
- if(!labelObj.health) {
- mui.toast("请选择居民标签!");
- return false;
- }
- return true;
- }
- function bindEvents(){
- $("textarea").on("input", function(){
- var text = $(this).val().trim(),
- len = text.length;
- $("#count").text(len);
- });
- //选择拒绝签约说明文本,直接将内容添加到textarea中
- $("#explain").on('tap', '.text-tag', function(){
- var $this = $(this),
- text = $this.text(),
- tatext = $("textarea").val();
- if($this.hasClass("active")){
- $this.removeClass("active");
- var a = tatext.split(text);
- tatext = a.join("");
- $("textarea").val(tatext);
- $("#count").text(tatext.length);
- }else{
- $this.addClass("active");
- tatext += text;
- $("textarea").val(tatext);
- $("#count").text(tatext.length);
- }
- });
- // 点击家庭医生签约协议(勾选框)
- $("body").on('click', '#agreement_checkbox', function() {
- $(this).toggleClass("checked");
- });
-
- $("body").on("click","#jumin_labels",function(){
- var teamCode = $('#qytdNum').attr("data-code");
- if($.trim(teamCode)) {
- //判断当前服务类型是否已经选择
- if(!currService){
- mui.confirm('请先选择服务类型', "提示", ["确定"], function(){});
- return false;
- }
- mui.openWindow({
- url:"../../huanzhe/html/disease-label-choose.html",
- id:"disease-label-choose",
- extras: {
- teamCode: teamCode,
- showData: $juminLabels.attr("data-code") || null,
- patientCode: patient,
- serviceCode: currService
- }
- })
- } else {
- mui.confirm('请先选择签约团队', "提示", ["确定"], function(){
-
- });
- }
-
- });
-
- $("#btn_agree").click(function() { //同意
- if($("#btn_agree").attr("disabled")){
- return false;
- }
- var isValid = validForm();
-
- if(isValid){
- $("#btn_agree").attr("disabled",true);
- agreeRenew(1);
- }
- });
-
- $("#btn_refuse").click(function() { //拒绝
- if($("#btn_refuse").attr("disabled")){
- return false;
- }
- $("#btn_refuse").attr("disabled",true);
-
- agreeRenew(0);
- });
-
- /*居民标签*/
- window.addEventListener("setJuMinLabels", function setJuMinLabels(e) {
- var health = e.detail.health,
- disease = e.detail.disease,
- custom = e.detail.custom,
- labelName = e.detail.labelName;
-
- $juminLabels.val(labelName).attr("data-code",JSON.stringify({health: health,disease: disease, custom: custom }));
- });
-
-
- }
- function templateHelper(){
- template.helper("getSex", function(str){
- if(str == 1){
- return "男";
- }else if(str == 2){
- return "女";
- }else{
- return "其他";
- }
- });
-
- template.helper("formatShowTime", function(str){
- if(str){
- return str.substr(0,16);
- }else{
- return "";
- }
- });
- }
- function agreeRenew(state){
- var juminLabels = JSON.parse($juminLabels.attr("data-code"));
- refuseReason = $('#refuseReason').val();
- var url = "/doctor/sign/agreeRenew",
- params = {
- state: state,
- patient: patient,
- mesId: msgId || "",
- signCode: signCode,
- health: juminLabels.health || "",
- disease: juminLabels.disease || "",
- custom: juminLabels.custom || "",
- sevId: currService,
- expenses:$("input[data-val=expenses]").attr("data-code"),
- healthDoctor : currHealthManagement || "",
- teamCode : currTeam || "",
- refuseReason: refuseReason
- };
- //改签情况
- // if(renewFlag == "2"){
- // params.healthDoctor = currHealthManagement || "";
- // params.teamCode = currTeam || "";
- // }
- plus.nativeUI.showWaiting();
- sendPost(url, params, null, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- if(res.data == -1){
- //已存在下个年度的签约
- var now = new Date();
- var signYear = now.getFullYear()+"-"+(now.getFullYear()+1);
- dialog({
- content: "您已完成"+signYear+"年度签约,不能再次签约",
- okValue: "我知道了",
- ok: function(){
- backToPre(state);
- }
- }).showModal();
- return false;
- }else if(res.data == 1){
- mui.toast(res.msg);
- backToPre(state);
- }else{
- var data = res.data;
- var msg = "";
- switch (data){
- case 2:
- msg = "已同意过申请,不能再次处理";
- break;
- case 3:
- msg = "患者已取消申请";
- break;
- case 4:
- msg = "已拒绝申请,不能再次处理";
- break;
- case 5:
- case 6:
- case 7:
- msg = "该签约申请已无效,不能操作";
- break;
- default:
- msg = "该申请已处理,无需再次处理";
- break;
- }
- dialog({
- content: msg,
- okValue: "我知道了",
- ok: function(){
- backToPre(state);
- }
- }).showModal();
- }
- }else{
- mui.toast(res.msg);
- }
-
- }, "POST", "", true);
- }
- function backToPre(state){
- var self = plus.webview.currentWebview(),
- parent = self.opener();
-
- if(parent && parent.id == "sign_manage"){
- // var tab = 4; //代缴费tab index
- // if(state == 1){
- // tab = 4;
- // }else{
- // tab = 3; //待处理tab
- // }
- //续签管理页面关闭,所以现在跳转去签约管理的tab中
- var tab = 1; //代缴费tab index
- if(state == 1){
- tab = 1;
- }else{
- tab = 0; //待处理tab
- }
- mui.fire(parent, "reloadTab", {tab: tab}); //刷新续签管理的代缴费tab内容
- parent.show();
- mui.later(function(){
- self.close();
- }, 300);
- }else{
- if(parent){
- mui.fire(parent, "updata");
- self.close();
- }
- }
- }
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
|