123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- var isModify = false, isJGmodify = false,isQkmodify=false,
- expenses, expenseName,
- patiCode,
- signStatus,
- isSigned;
- var $doctorJGInput;
- var $doctorQkInput;
- mui.init({
- beforeback: function() {
- if(isModify || isJGmodify||isQkmodify){
- mui.confirm("您有未保存的变动,是否保存?", "提示", ["保存", "不了"], function(e) {
- if(e.index == 0) {
- submit();
- } else {
- plus.webview.currentWebview().close();
- }
- })
- return false;
- }
- }
- });
- /**
- * 获取患者信息
- */
- function getPatientInfo(){
- var docCode = JSON.parse(plus.storage.getItem("docInfo")).code;
- sendPost("doctor/patient_group/patient", {
- code: patiCode,
- jyStatus: signStatus=='yjy'? '1' : ''
- }, null, function(res) {
- if(res.status == 200) {
- sendGet("/doctor/admin-teams/team/members/"+patiCode, {}, null, function(res1){
- if(res1.status==200 && res1.data.teamId){
- // res1.data.isLeader = true; //测试用
-
- res.data.signStatus = signStatus;
- res.data.qkys = res1.data.doctorName;
- res.data.qkysCode = res1.data.doctor;
- res.data.jgs = res1.data.healthDoctorName;
- res.data.jgsCode = res1.data.healthDoctorCode;
- res.data.teamName = res1.data.teamName;
- res.data.ModifyJgs = res1.data.isLeader;
- if(res.data.ssSign){
- res.data.Modifqk = false;
- }else{
- res.data.Modifqk = true;
- }
- oldQy = res1.data;
- $("#pati_info").html(template("info_tmpl", res.data));
- $doctorJGInput = $('#healthManagement input');
- $doctorQkInput = $('#dortor_qke input');
- setExpenses(); //初始化政府补贴下拉框
- if(res1.data.isLeader && $doctorJGInput.length > 0)
- getTeamMember(oldQy.teamId); // 初始化健管师下拉框
- if(res.data.ssSign){
- $(".no").show();
- }
-
- } else
- mui.toast("获取居民签约团队失败!");
- })
- } else {
- mui.toast(res.msg);
- }
- });
- }
- /**
- * 获取政府补贴数据
- */
- function setExpenses() {
- var $expenses = $('#li_expenses');
- if($expenses.length > 0) {
- expenses = $expenses.attr('data-code');
- if(signStatus!='yjy'){
- $('.header-link').show();
- }
- var expensesCode = [];
- var expensesName = [];
- sendGet("/common/getDictByDictName?name=SIGN_EXPENSES", null, null, function(res) {
- if(res.status == 200) {
- var expensesList = res.list;
- for(var i = 0; i < expensesList.length; i++) {
- if(expenses == expensesList[i].code){
- expenseName = expensesList[i].value;
- $expenses.val(expensesList[i].value);
- }
- expensesCode.push(expensesList[i].code);
- expensesName.push(expensesList[i].value);
- }
- checkQy(expensesCode, expensesName);
- };
- });
- }
- }
- function checkQy(expensesCode, expensesName){
- sendPost("/doctor/family_contract/medical_insurance_num", {patient: patiCode}, null, function(res) {
- isSigned = res.data.status;
- if(signStatus != 'yjy')
- activExpensesM(expensesCode, expensesName);
- });
- }
- function setExpensesSelect(code, name) {
- var $li_expenses = $('#li_expenses');
- var mobiscroll = $li_expenses.mobiscroll('getInst');
- var valueText = "{keys:'"+code+"',values:'"+name+"'}";
- mobiscroll.setVal([valueText]);
- $li_expenses.val(name);
- $li_expenses.attr("data-code", code);
- }
- /**
- * 设置政府补贴下拉框
- */
- function activExpensesM(expensesCode, expensesName) {
- if(isSigned == 0){
- $('#li_expenses').mobiscroll({
- theme: 'ios',
- lang: 'zh',
- customWheels: true,
- wheels: [
- [{
- keys: expensesCode,
- values: expensesName
- }]
- ],
- onSelect: function(valueText, inst) {
- var dd = eval("[" + valueText + "]");
- $(this).val(dd[0].values).attr("data-code", dd[0].keys);
- isModify = expenses != dd[0].keys;
- toggleModify();
- },
- onShow: function() {
- if($(this).attr('data-init') == "1") {
- $(this).attr('data-init', "0");
- $('#li_expenses').mobiscroll("selectWheel", [$(this).attr('data-code')]);
- }
- }
- });
- } else {
- $('#li_expenses').on('tap', function(){
- mui.toast("已成功签约,无法变更");
- })
- }
- };
- /**
- * 提交
- */
- function submit(t) {
- if(!isModify && !isJGmodify&&!isQkmodify)
- return;
-
- plus.nativeUI.showWaiting();
- var p = {patient: patiCode}
- if(isModify){
- p.expensesType = $('#li_expenses').attr('data-code');
- }
-
- if(isJGmodify){
- p.healthDoctor = $doctorJGInput.attr("data-code");
- }if(isQkmodify){
- p.doctor = $doctorQkInput.attr("data-code");
- }
-
- sendPost("/doctor/family_contract/sign_info_update", p, null,
- function(res) {
- if(res.status == 200) {
- expenses = $('#li_expenses').attr('data-code');
- oldQy.healthDoctorCode = $doctorJGInput.attr('data-code');
- oldQy.healthDoctorName = $doctorJGInput.val();
- oldQy.doctor = $doctorQkInput.attr('data-code');
- oldQy.doctorName = $doctorQkInput.val();
- isModify = false;
- isJGmodify = false;
- isQkmodify = false;
- toggleModify();
-
- mui.toast("保存成功!");
- plus.nativeUI.closeWaiting();
- if(!t)
- plus.webview.currentWebview().close();
- } else {
- if(isModify){
- setExpensesSelect(expenses, expenseName);
- isModify = false;
- }
-
- if(isJGmodify){
- setJGSelect(oldQy.healthDoctorCode, oldQy.healthDoctorName);
- isJGmodify = false;
- }
- if(isQkmodify){
- setQkSelect(oldQy.doctor,oldQy.doctorName);
- isQkmodify = false;
- }
- toggleModify();
- plus.nativeUI.closeWaiting();
- mui.toast(res.msg);
- }
- })
- }
- //获取团队成员
- function getTeamMember(teamCode){
- plus.nativeUI.showWaiting();
-
- sendGet("/doctor/admin-teams/"+ teamCode + "/members", {}, null, function(res){
- if(res.status == 200){
- var jgs= [],qk=[],
- jgCodes =[], jgNames = [],qkCodes=[],qkNames=[];
-
- $.each(res.data, function(i, v) {
- if(v.level == 3 || v.level==2){
- jgs.push(v);
- }
- if(v.level==2){
- qk.push(v);
- }
- });
- qkCodes = _.pluck(qk, 'code')
- qkNames = _.pluck(qk, 'name');
- // 萃取数组对象中code、name,返回一个数组
- jgCodes = _.pluck(jgs, 'code');
- jgNames = _.pluck(jgs, 'name');
-
-
- activHealthM(jgCodes, jgNames);
- activDoctorM(qkCodes, qkNames)
- } else
- mui.toast("获取团队成员失败!");
- plus.nativeUI.closeWaiting();
- })
- }
- function activDoctorM(codes, names) {
-
- $doctorQkInput.mobiscroll({
- theme: 'ios',
- lang: 'zh',
- customWheels: true,
- wheels: [
- [{
- keys: codes,
- values: names
- }]
- ],
- onSelect: function(valueText, inst) {
- var dd = eval("[" + valueText + "]");
- var curDocCode = dd[0].keys;
- $(this).val(dd[0].values);
- $doctorQkInput.attr("data-code", curDocCode);
- isQkmodify = oldQy.doctor != curDocCode;
- toggleQkModify();
- }
- });
-
- setQkSelect(oldQy.doctor, oldQy.doctorName);
- };
- function activHealthM(codes, names) {
-
- $doctorJGInput.mobiscroll({
- theme: 'ios',
- lang: 'zh',
- customWheels: true,
- wheels: [
- [{
- keys: codes,
- values: names
- }]
- ],
- onSelect: function(valueText, inst) {
- var dd = eval("[" + valueText + "]");
- var curDocCode = dd[0].keys;
- $(this).val(dd[0].values);
- $doctorJGInput.attr("data-code", curDocCode);
- isJGmodify = oldQy.healthDoctorCode != curDocCode;
- toggleModify();
- }
- });
-
- setJGSelect(oldQy.healthDoctorCode, oldQy.healthDoctorName);
- };
- function setJGSelect(code, name) {
- var mobiscroll = $doctorJGInput.mobiscroll('getInst');
- var valueText = "{keys:'"+code+"',values:'"+name+"'}";
- mobiscroll.setVal([valueText]);
- $doctorJGInput.val(name);
- $doctorJGInput.attr("data-code", code);
- }
- function setQkSelect(code, name) {
- var mobiscroll = $doctorJGInput.mobiscroll('getInst');
- var valueText = "{keys:'"+code+"',values:'"+name+"'}";
- mobiscroll.setVal([valueText]);
- $doctorQkInput.val(name);
- $doctorQkInput.attr("data-code", code);
- }
- function toggleModify(){
- console.log(isModify+ ","+ isJGmodify)
- $('.link').toggleClass('c-ccc', !(isModify || isJGmodify) );
- }
- function toggleQkModify(){
- console.log(isModify+ ","+ isQkmodify)
- $('.link').toggleClass('c-ccc', !(isModify || isQkmodify) );
- }
|