| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784 | 
var httpData=GetRequest(),doctorInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'));var applyDate=httpData.applyDate?decodeURI(httpData.applyDate):""var refuseReason = null;function showSuccessMessage(msg) {layer.msg(msg, {	icon: 1})}function showErrorMessage(msg) {layer.msg(msg, {	icon: 5})}function showWarningMessage(msg) {layer.msg(msg, {	icon: 2})}function showInfoMessage(msg) {layer.msg(msg, {	icon: 6})}function getReason(ele) {if(ele.hasClass("active")) {	ele.removeClass("active")	refuseReason = null	return false;}ele.addClass("active").siblings().removeClass("active");refuseReason = ele.html();}top.changeTypeIndex=null;//修改居民标签的窗体top.handleVue=new Vue({el: "#app",data: {	renewFlag: httpData.renewFlag, // 2 改签	applyDate: applyDate,	justDoc: null,	justHDoc: null,	doctorType: doctorInfo.doctorType,	isShowList1: false,	isShowList2: false,	isShowList3: false,	isShowList4: false,	isShowList5:false,	patientInfo: {jtSign: {}},	warnMsg: "",	signdictList: null,	teamList: null,	hisTeamName: null, // 历史团队	memberList: null, // 团队成员列表	doctorList: null, // 全科医生列表	specialDoctorList:null,//专科医生列表	dictList: null,	fileList: null,	serverName: null,	labelName: null,	patLabel: [],	signInfo: {		signType: 1,		signCode: httpData.signCode,		majorDoctor: null,		majorDoctorName: null,		healthLabel: null,		customLabel: null,		disease: null,		patientIDcard: null, // 必填		adminTeamCode: null,		teamCode: null,		mesId: null, // 消息id(必填)		msgid: null, // 消息id(必填)		patient: httpData.patientCode,		doctor: null,		doctorName: null,		healthDoctor: null,		healthDoctorName: null,		type: 1,		state: 1,		expenses: null,		group: null,		//添加服务类型数据		sevId: null,		// 拒绝参数//		                adminTeamCode:0,//		                type: 2,		   refuseReason: null	},	zkdoctorShow:false,	choseTeamFirst:true,},mounted: function() {	this.getSigndict();	this.getDictByDictName();	if(!httpData.msgid || httpData.msgid == "undefined" || httpData.msgid == "null") {		this.findMsgId()	} else {		this.signInfo.mesId = httpData.msgid		this.signInfo.msgid = httpData.msgid	}	this.teamLimit();	this.findPatientSignServerBySignCode();	},methods: {	allLabels: function(selData) {		var vm =this,			param = {				teamCode: this.signInfo.adminTeamCode			},			loadding = layer.load(0, {shade: false});		signAPI.allLabels(param).then(function(res) {			layer.close(loadding)			if(res.status == 200) {				$.each(res.data, function(i, v) {					if(v.labelType == 2) {						$.each(selData.heath, function(j, u) {							if(u == v.labelCode) {								if(vm.labelName == "") {									vm.labelName += v.labelName								} else {									vm.labelName += ',' + v.labelName								}							}						});					}					if(v.labelType == 3) {						$.each(selData.disease, function(j, u) {							if(u == v.labelCode) {								if(vm.labelName == "") {									vm.labelName += v.labelName								} else {									vm.labelName += ',' + v.labelName								}							}						});					}					if(v.labelType == 4) {						$.each(selData.team, function(j, u) {							if(u == v.labelCode) {								if(vm.labelName == "") {									vm.labelName += v.labelName								} else {									vm.labelName += ',' + v.labelName								}							}						});					}				});			} else {				showErrorMessage(res.msg);			}		})	},	getTeamNameByTeamCode: function() {		var vm =this,			params = {				teamCode: vm.patientInfo.jtSign.adminTeamId			},			loadding = layer.load(0, {shade: false});		signAPI.getTeamNameByTeamCode(params).then(function(res) {			layer.close(loadding)			if(res.status == 200) {				vm.hisTeamName = res.data			} else {				showErrorMessage(res.msg);			}		})	},	patientLabel: function() {		var vm =this,			params = {				patient: httpData.patientCode,				labelType: ""			},			loadding = layer.load(0, {shade: false});		signAPI.patientLabel(params).then(function(res) {			layer.close(loadding)			if(res.status == 200) {				vm.patLabel = res.data			} else {				showErrorMessage(res.msg);			}		})	},	getSigndict: function() {		var vm =this,			loadding = layer.load(0, {shade: false});		signAPI.getSigndict().then(function(res) {			layer.close(loadding)			if(res.status == 200) {				vm.signdictList = res.data			} else {				showErrorMessage(res.msg);			}		})	},	findMsgId: function() {		var vm =this,			params = {				sender: httpData.patientCode,				signStatus: httpData.status == 0 ? 1 : (vm.renewFlag == 1 ? 8 : 9)			},			loadding = layer.load(0, {shade: false});		signAPI.findMsgId(params).then(function(res) {			layer.close(loadding)			if(res.status == 200) {				vm.signInfo.mesId = res.data.id				vm.signInfo.msgid = res.data.id			} else {				showErrorMessage(res.msg);			}		})	},	signing: function() {		var vm = this,			loadding = layer.load(0, {shade: false}),			params = {				patient: httpData.patientCode			}		signAPI.signing(params).then(function(res) {			layer.close(loadding)			if(res.status == 200) {				var patientInfo=JSON.parse(JSON.stringify(vm.patientInfo))				vm.patientInfo={}				vm.patientInfo = _.assign(patientInfo, res.data)				vm.signInfo.patientIDcard = res.data.idCard				if(res.data.jtSign){				if(vm.doctorType == 2) {					vm.signInfo.doctorName = res.data.jtSign.doctorName					vm.signInfo.doctor = res.data.jtSign.doctor				}				if(vm.doctorType == 3) {					vm.signInfo.healthDoctorName = res.data.jtSign.doctorHealthName					vm.signInfo.healthDoctor = res.data.jtSign.doctorHealth				}			}			} else {				showErrorMessage(res.msg);			}		})	},	selectServer:function(){        var localurl=window.location.href;        var useUrl=localurl.split("html/")[0]		var vm=this		if(!this.signInfo.adminTeamCode) {			showWarningMessage("请先选择签约团队");			return false;		}		if(top.changeTypeIndex && top.$('#layui-layer-shade'+top.changeTypeIndex).length){			top.xgLabel.initPage();			(top.$('#layui-layer-shade'+top.changeTypeIndex).show(),top.$('#layui-layer'+top.changeTypeIndex).show());		}else{			top.changeTypeIndex=top.layer.open({				type: 2,				area: ['500px', '405px'],				title: "修改居民标签",				shade: 0.5,				shadeClose: false,				closeBtn: 0,				shift: 2,				content: useUrl+'html/modify-the-label.html?patient=' + httpData.patientCode+'&teamCode='+vm.signInfo.adminTeamCode+"&signCode="+httpData.signCode			});		}	},	handleStr: function(str) {		if (!str || str === '') {			return ''		}		return str.substr(0, 19)   },	acceptanceRes:function(res){		var vm = this		this.serverName = "";		this.labelName = "";		if(res.server.length != 0) this.signInfo.sevId = res.server.join(",");		if(res.disease.length != 0) this.signInfo.disease = res.disease.join(",");		if(res.heath.length != 0) this.signInfo.healthLabel = res.heath.join(",");		if(res.team.length != 0) this.signInfo.customLabel = res.team.join(",");		$.each(res.server, function(i, v) {			$.each(vm.signdictList, function(j, u) {				if(v == u.code) {					if(vm.serverName == "") {						vm.serverName += u.name					} else {						vm.serverName += ',' + u.name					}				}			});		});		this.allLabels(res)		if(vm.serverName.split(',').indexOf('高血压')>-1 || vm.serverName.split(',').indexOf('糖尿病')>-1 ){			console.log('服务类型存在高血压,糖尿病')			this.zkdoctorShow=true		}else{			this.zkdoctorShow=false		}	},	signOuttime: function() {		var vm = this,			loadding = layer.load(0, {shade: false}),			params = {				patient: httpData.patientCode			}		signAPI.signOuttime(params).then(function(res) {			layer.close(loadding)			if(res.status == 200) {				vm.patientInfo = res.data				vm.signInfo.adminTeamCode = vm.patientInfo.jtSign.adminTeamId				vm.signInfo.teamCode = vm.patientInfo.jtSign.adminTeamId				vm.signInfo.healthDoctorName = vm.patientInfo.jtSign.doctorHealthName || ""				vm.signInfo.healthDoctor = vm.patientInfo.jtSign.doctorHealth || ""				vm.signInfo.doctor = vm.patientInfo.jtSign.doctor || ""				vm.signInfo.doctorName = vm.patientInfo.jtSign.doctorName || ""				if(vm.doctorType == 2) {					vm.signInfo.doctorName = doctorInfo.name					vm.signInfo.doctor = doctorInfo.uid				}				if(vm.doctorType == 3) {					vm.signInfo.healthDoctorName = doctorInfo.name					vm.signInfo.healthDoctor = doctorInfo.uid				}				vm.signInfo.expenses = vm.patientInfo.jtSign.expensesType				vm.judgeTeamToDoc(vm.signInfo.adminTeamCode)				// 查找之前签约的居民标签				vm.patientLabel()				if(vm.renewFlag == 2) { // 获取之前签约团队名字					vm.getTeamNameByTeamCode()				}			} else {				showErrorMessage(res.msg);			}		})	},	judgeTeamToDoc: function(teamCode) {		var judge = false		for(var i = 0, len = this.teamList.length; i < len; i++) {			if(this.teamList[i].id == teamCode) {				judge = true				this.teamMember()			}		}		if(!judge) {			this.signInfo.adminTeamCode = null			this.signInfo.teamCode = null			this.warnMsg = "您已不在原签约团队,请选择新的签约团队"			if(this.doctorType == 2) {				this.justHDoc = this.signInfo.healthDoctorName				this.signInfo.healthDoctorName = null				this.signInfo.healthDoctor = null			} else {				this.justDoc = this.signInfo.doctorName				this.signInfo.doctor = null				this.signInfo.doctorName = null			}		}	},	getDictByDictName: function() {		var vm =this,			loadding = layer.load(0, {shade: false}),			params = {				name: "SIGN_EXPENSES"			}		signAPI.getDictByDictName(params).then(function(res) {			layer.close(loadding)			if(res.status == 200) {				vm.dictList = res.list			} else {				showErrorMessage(res.msg);			}		})	},	teamLimit: function() {		var vm = this,			loadding = layer.load(0, {shade: false}),			params = {				doctorId: doctorInfo.uid			}		signAPI.teamLimit(params).then(function(res) {			layer.close(loadding)			if(res.status == 200) {				vm.teamList = res.data				if (httpData.status == 0) {					vm.signing()				} else {					vm.signOuttime();				}			} else {				showErrorMessage(res.msg);			}		})	},	findPatientSignServerBySignCode: function() {		var vm =this,			loadding = layer.load(0, {shade: false}),			params = {				signCode: httpData.signCode			};		signAPI.findPatientSignServerBySignCode(params).then(function(res) {			layer.close(loadding)			if(res.status == 200) {				vm.fileList = [];				var len = res.data.length;				if(res.data.length > 0) {					vm.serverName = "";					vm.signInfo.sevId = "";					for(var i = 0; i < len; i++) {						if(i == 0) {							vm.serverName += res.data[i].serverTypeName							vm.signInfo.sevId += res.data[i].servetType						} else {							vm.serverName += + ', ' + res.data[i].serverTypeName							vm.signInfo.sevId += +',' +  res.data[i].servetType						}					}				}				if(vm.serverName.split(',').indexOf('高血压')>-1 || vm.serverName.split(',').indexOf('糖尿病')>-1 ){					console.log('服务类型存在高血压,糖尿病')					vm.zkdoctorShow=true				}else{					vm.zkdoctorShow=false				}						$.each(res.data, function(i, v) {					if(v.serverType == 8 || v.serverType == 9 || v.serverType == 11) {						vm.fileList.push(v);					}				});			} else {				showErrorMessage(res.msg);			}		})	},	teamMember: function(val) {		var vm = this,			loadding = layer.load(0, {shade: false}),			params = {				teamId: vm.signInfo.adminTeamCode,				name:val||''			}		signAPI.teamMember(params).then(function(res) {			layer.close(loadding)			vm.memberList = [];			vm.doctorList = [];			vm.specialDoctorList=[];			if(res.status == 200) {				var judge = false				$.each(res.data, function(i, v) {					if(v.available) {						if(v.code == vm.signInfo.doctor && vm.doctorType == 3) {							judge = true						}						if(v.code == vm.signInfo.healthDoctor && vm.doctorType == 2) {							judge = true						}					}					if(v.available && (v.level == 3 || v.level == 2)) {vm.memberList.push(v);}					if(v.available && v.level == 2) {vm.doctorList.push(v);}					vm.specialDoctorList.push(v);				});					if(!judge && httpData.status == 1) {						if(vm.doctorType == 3) {							if(!vm.justDoc && !vm.signInfo.doctorName) {								vm.signInfo.doctorName = vm.signInfo.healthDoctorName								vm.signInfo.doctor = vm.signInfo.healthDoctor								return false							}							if(!vm.justDoc) {								vm.justDoc = vm.signInfo.doctorName							}							vm.warnMsg = "去年签约的全科医生" + vm.justDoc + "已不在您的团队,请重新选择一位全科医生"							vm.justDoc = null							vm.signInfo.doctor = null							vm.signInfo.doctorName = null						}						if(vm.doctorType == 2) {							if(!vm.justHDoc && !vm.signInfo.healthDoctorName) {								vm.signInfo.healthDoctorName = vm.signInfo.doctorName								vm.signInfo.healthDoctor = vm.signInfo.doctor								return false							}							if(!vm.justHDoc) {								vm.justHDoc = vm.signInfo.healthDoctorName							}							vm.warnMsg = "去年签约的健管师" + vm.justHDoc + "已不在您的团队,请重新选择一位健管师"							vm.justHDoc = null							vm.signInfo.healthDoctor = null							vm.signInfo.healthDoctorName = null						}						top.changeTypeIndex=null					}								} else {				showErrorMessage(res.msg);			}		})	   },	   teamMember2:function(val){		var vm = this,			loadding = layer.load(0, {shade: false}),			params = {				teamId: vm.signInfo.adminTeamCode,				name:val||''			}		signAPI.teamMember(params).then(function(res) {			layer.close(loadding)			vm.memberList = [];			vm.doctorList = [];			vm.specialDoctorList=[];			if(res.status == 200) {				var judge = false				$.each(res.data, function(i, v) {					if(v.available) {						if(v.code == vm.signInfo.doctor && vm.doctorType == 3) {							judge = true						}						if(v.code == vm.signInfo.healthDoctor && vm.doctorType == 2) {							judge = true						}					}					if(v.available && (v.level == 3 || v.level == 2)) {vm.memberList.push(v);}					if(v.available && v.level == 2) {vm.doctorList.push(v);}					vm.specialDoctorList.push(v);				});								} else {				showErrorMessage(res.msg);			}		})	   },	   handleSelect:function(item) {        console.log(item);      },      handleIconClick:function(ev) {        console.log(ev);	  },	  querySearch:function(queryString, cb) {		var doctorList = this.doctorList;		debugger        var results = queryString ? doctorList.filter(this.createFilter(queryString)) : doctorList;        // 调用 callback 返回建议列表的数据        cb(results);      },      createFilter:function(queryString) {        return function(restaurant){          return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);        };      },	selectStatus: function(num,val) {		var vm=this		if(num == 1) {			this.isShowList2 = false;			this.isShowList3 = false;			this.isShowList4 = false;			this.isShowList1 = !this.isShowList1;		} else if (num == 2 || num == 5) {			if(!this.signInfo.adminTeamCode) {				showWarningMessage("请先选择签约团队")				return false;			}		} else if (num == 3) {			this.isShowList1 = false;			this.isShowList2 = false;			this.isShowList4 = false;			this.isShowList3 = !this.isShowList3;		}else if(num==5){		} else {			if(!this.signInfo.adminTeamCode) {				showWarningMessage("请先选择签约团队")				return false;			}		}				// if(/^[\u4e00-\u9fa5]+$/i.test(val)){			// 	_.debounce(vm.teamMember2(val), 300)			// 	}							},	keyupStatus:function(num,val){		vm.selectStatus(num)	},	selectLi: function(num,data) {		if(num == 1) { // 选择签约团队			this.isShowList1 = false;			this.signInfo.adminTeamCode = data.id;			this.signInfo.teamCode = data.id;			if(this.doctorType == 2) {				this.signInfo.healthDoctor = null				this.signInfo.healthDoctorName = null			}			if(this.doctorType == 3) {				this.signInfo.doctor = null				this.signInfo.doctorName = null			}						// 发现切换团队时无法更新健管师列表,将这个判断取消后就可以更新.			// if(!this.memberList || !this.doctorList) {			this.teamMember()			// }		}		if(num == 2) { // 选择健管师			this.isShowList2 = false;			this.signInfo.healthDoctorName = data.name			this.signInfo.healthDoctor = data.code		}		if(num == 3) {			this.isShowList3 = false;			this.signInfo.expenses = data.code;		}		if(num == 4) { // 选择全科医生			this.isShowList4 = false;			this.signInfo.doctorName = data.name			this.signInfo.doctor = data.code		}		if(num==5){//选择专科医生			this.isShowList5=false			this.signInfo.specialistName = data.name			this.signInfo.specialist = data.code		}	},	// 把原来下拉选择框变成可搜索下拉选择框	changeSelect4:function(val){		var obj = {};		obj = this.doctorList.find(function(item){			return item.code === val;		});		this.signInfo.doctorName=obj.name	},	changeSelect2:function(val){		var obj = {};		obj = this.memberList.find(function(item){			return item.code === val;		});		this.signInfo.healthDoctorName=obj.name	},	changeSelect5:function(val){		var obj = {};		obj = this.specialDoctorList.find(function(item){			return item.code === val;		});		this.signInfo.specialistName=obj.name	},	showTeamName: function(teamCode) {		var teamName;		if(!this.teamList) {			return "请选择签约团队";		}		for(var i = 0, len = this.teamList.length; i < len; i++) {			if(teamCode == this.teamList[i].id) {				teamName = this.teamList[i].name;			}		}		return teamName	},	showExpensesName: function(code) {		var expensesName;		if(!this.dictList) {			return "请选择补贴类型";		}		for(var i = 0, len = this.dictList.length; i < len; i++) {			if(code == this.dictList[i].code) {				expensesName = this.dictList[i].value;			}		}		return expensesName	},	setPatImg: function(str) {		var imgStr = httpRequest.getImgUrl(str);		if (imgStr == "") {			return '../../../images/p-female.png';		} else {			return imgStr;		}	},	lookPhoto: function(data) {        var localurl=window.location.href;        var useUrl=localurl.split("html/")[0]		parent.photoLayerIndex = parent.layer.open({			type: 2,			area: ['70%', '600px'],			title: false,			shade: 0.5,			shadeClose: true,			shift: 2,			content: useUrl+'html/photo_show.html?serverType=' + data.serverType + '&patientCode=' + httpData.patientCode		})	},	refuse: function() {		var vm = this;		layer.open({			type: 1,			area: ['400px', '300px'],			shade: 0.5,			title: '拒绝签约原因',			shift: 2,			shadeClose: false, //点击遮罩关闭层			content: '<div class="p20 pb0"><div class="reason_list clearfix"><span class="fl mr10 mb20" onclick="getReason($(this))">居民信息填写不详</span><span class="fl mr10 mb20" onclick="getReason($(this))">签约人数已满</span><span class="fl mb20" onclick="getReason($(this))">家庭医生变更</span></div><textarea id="reason" maxLength="200" placeholder="可选择填写其他拒签原因(限200字以内)"></textarea></div>',			btn: ['提 交', '取 消'],			yes:function(index, layero) {				if(!refuseReason) {					if(!$("#reason").val()) {						showWarningMessage("请选择或输入拒绝理由!");						layer.close(index);						return false					}					vm.signInfo.refuseReason = $("#reason").val()				} else {					if($("#reason").val()) {						vm.signInfo.refuseReason = refuseReason + "。" + $("#reason").val()					} else {						vm.signInfo.refuseReason = refuseReason					}				}				vm.signInfo.adminTeamCode = 0;				vm.signInfo.teamCode = 0;				vm.signInfo.type = 2;				vm.signInfo.state = 0;				vm.sign();				layer.close(index);			},			success: function(layero){				layero.find('.layui-layer-btn').css('text-align', 'center')			}		});	},	sign: function() {// type:1签约 2拒签		if(this.signInfo.type == 1 && (!this.signInfo.expenses || (this.doctorType == 2 && !this.signInfo.healthDoctor) ||(this.zkdoctorShow==true &&this.doctorType == 2 && !this.signInfo.specialist) || (this.doctorType == 3 && !this.signInfo.doctor) || !this.signInfo.sevId || (!this.signInfo.disease && !this.signInfo.healthLabel && !this.signInfo.customLabel))) {			showWarningMessage("请将填写完整签约信息!");			return false;		}		var vm = this,			loadding = layer.load(0, {shade: false});		if (httpData.status == 0) {			var param = vm.signInfo			if(vm.doctorType == 2) {				param.doctor = null				param.doctorName = null			}			if(vm.doctorType == 3) {				param.doctorHealth = null				param.doctorHealthName = null				param.specialist=null				param.specialistName=null			}			signAPI.sign(vm.signInfo).then(function(res) {				layer.close(loadding)				if(res.status == 200) {					showSuccessMessage(res.msg || "操作成功")					setTimeout(function() {						parent.gobalVue.signCount();						layer.closeAll();						parent.layer.closeAll();					}, 1000)				} else {					showErrorMessage(res.msg);				}			})		} else {			signAPI.signRenew(vm.signInfo).then(function(res) {				layer.close(loadding)				if(res.status == 200) {					showSuccessMessage(res.msg || "操作成功")					setTimeout(function() {						parent.gobalVue.signCount();						layer.closeAll();						parent.layer.closeAll();					}, 1000)				} else {					showErrorMessage(res.msg);				}			})		}	}}})
 |