123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- var rowData={};
- var sn="";//记录sn码
- var dataId = null;
- var type = null;
- var name = null;
- var type = null;
- var photoUrl = null;
- var deviceId = null;
- var oldSn="";//旧sn
- $(function() {
- Request = GetRequest();
- dataId = Request["id"];
- deviceId = Request["deviceId"];
- getDeviceInfo(deviceId);
- bindEvents();
- initData(dataId);
- });
- function initData(dataId){
- var params = {};
- params.id=dataId;
- sendPost("patient/device/PatientDeviceInfo",params,"JSON","GET",
- function(res){
- if(res.msg){
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'设备信息初始化失败!'}).show();
- }
- },
- function(res){
- if(res.status==200){
- rowData = res.data;
- oldSn = rowData.deviceSn;
- $("#sncode").val(rowData.device.deviceSn);
- // var html = template('listTempl',res.data.time);
- // $('#duringList').html(html);
-
- console.log(rowData);
- var fasting = (rowData.time['fasting'].replace(/ /g, '')).split('-'),
- afterBreakFast = (rowData.time['afterBreakFast'].replace(/ /g, '')).split('-'),
- beforeLunch = (rowData.time['beforeLunch'].replace(/ /g, '')).split('-'),
- afterLunch = (rowData.time['afterLunch'].replace(/ /g, '')).split('-'),
- beforeDinner = (rowData.time['beforeDinner'].replace(/ /g, '')).split('-'),
- afterDinner = (rowData.time['afterDinner'].replace(/ /g, '')).split('-'),
- beforeSleep = (rowData.time['beforeSleep'].replace(/ /g, '')).split('-');
-
- $('#mobIn1').val(fasting[0].substring(0,5) + '-' + fasting[1].substring(0,5));
- $('#mobIn2').val(afterBreakFast[0].substring(0,5) + '-' + afterBreakFast[1].substring(0,5));
- $('#mobIn3').val(beforeLunch[0].substring(0,5) + '-' + beforeLunch[1].substring(0,5));
- $('#mobIn4').val(afterLunch[0].substring(0,5) + '-' + afterLunch[1].substring(0,5));
- $('#mobIn5').val(beforeDinner[0].substring(0,5) + '-' + beforeDinner[1].substring(0,5));
- $('#mobIn6').val(afterDinner[0].substring(0,5) + '-' + afterDinner[1].substring(0,5));
- $('#mobIn7').val(beforeSleep[0].substring(0,5) + '-' + beforeSleep[1].substring(0,5));
- // $('#mobIn1').val(rowData.time['fasting'].replace(/ /g,''));
- // $('#mobIn2').val(rowData.time['afterBreakFast'].replace(/ /g,''));
- // $('#mobIn3').val(rowData.time['beforeLunch'].replace(/ /g,''));
- // $('#mobIn4').val(rowData.time['afterLunch'].replace(/ /g,''));
- // $('#mobIn5').val(rowData.time['beforeDinner'].replace(/ /g,''));
- // $('#mobIn6').val(rowData.time['afterDinner'].replace(/ /g,''));
- // $('#mobIn7').val(rowData.time['beforeSleep'].replace(/ /g,''));
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'设备信息初始化失败!'}).show();
- }
- }
- )
- }
- //判断值是否改变过
- function isValueChange(){
- var changeTagStr = $("#sncode").val();
- if(oldSn!=changeTagStr){
-
- }
- }
- //绑定事件
- function bindEvents(){
- //添加isrcoll
- // var scroller1 = new IScrollPullUpDown('wrapper',{
- // probeType:2,
- // bounceTime: 250,
- // bounceEasing: 'quadratic',
- // mouseWheel:false,
- // scrollbars:true,
- // click:true,
- // fadeScrollbars:true,
- // interactiveScrollbars:false
- // },null,null);
-
- $("#del-btn").bind("click",function(){
- dialog({
- content: '解绑设备信息,将会导致医生无法实时<br/>关注到您的体征变化。是否继续解绑?',
- okValue:'确定',
- ok: function (){
- deleteSn(dataId);
- },
- cancelValue: '取消',
- cancel: function () {
- return;
- }
- }).showModal();
- })
-
- $("#edit-btn").bind("click",function(){
- openedit();
- })
- }
- function checkSnBind(snCode,checkSuccess){
- var b = /^[0-9a-zA-Z]*$/g;
- if(!b.test(snCode)){
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'对不起,您输入的SN有误,请重新输入!'}).show();
- return false;
- }
- var params = {};
- params.type=type;
- params.device_sn = snCode;
- sendPost("patient/device/PatientDeviceIdcard",params,"JSON","GET",
- function(res){
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'设备SN校验失败!'}).show();
- },function(res){
- if(res.status==200){
- var name = "" ;
- var others = null;
- for(var j in res.data){
- name = res.data[j].name;
- others = res.data[j].others
- }
- //没被绑定
- if(name==""){
- $("#bang-btn").addClass("active");
- if(checkSuccess!=null){
- checkSuccess(snCode);
- }
- }else if(others!=null&&others==1){
- // $("#bang-btn").removeClass("active");
- //被绑定而且被别人绑定
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'该设备已被他人绑定,设备解绑后,方可再次绑定!'}).show();
- }
- else if(others!=null&&others==0){
- // $("#bang-btn").removeClass("active");
- if(deviceId==null||!deviceId||deviceId==""){
- //新增,编辑/被自己绑定
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'对不起,您已绑定过该设备,解绑后方可继续绑定!'}).show();
- }else{
- if(checkSuccess!=null){
- checkSuccess(snCode);
- }
- }
- }
- }
- }
- );
-
-
- }
- function getDeviceInfo(deviceId){
- sendPost("/common/device/DeviceInfo?id="+deviceId,{},"JSON","GET",
- function(res){
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'设备信息获取失败!'}).show();
- },
- function(res){
- if(res.status==200){
- var rowData1 = res.data;
- type = rowData1.categoryCode;
- name = rowData1.name;
- photoUrl = getImgUrl(rowData1.photo);
- $(".deviceName").html(name);
- $(".div-xuetangyi-img img").attr("src",photoUrl);
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'设备信息获取失败!'}).show();
- }
- }
- )
- }
- function checkSuccess(snCode){
- var name1="血糖仪-"+name;
- var params ={};
- params.deviceId=deviceId;//设备ID
- params.deviceName=name1;//设备名称
- params.deviceSn=snCode;//设备SN码
- params.categoryCode=type;//设备分类 血糖仪1 血压计 2
- params.userType="-1";//是否多用户
- if(rowData.id){
- params.id = rowData.id;
- }
- sendPost("/patient/device/SavePatientDevice",{"json":JSON.stringify(params)},"JSON","post",
- function(res){
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'设备绑定失败!'}).show();
- },
- function(res){
- if(res.status==200){
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'设备绑定成功!'}).show();
- setTimeout(function(){
- window.location.href='my-equipments.html';
- },1000);
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:res.msg}).show();
- return false;
- }
-
- }
- )
- }
- function openedit(){
- location.href="edit-xuetangyi.html?deviceId="+deviceId+"&id="+dataId+"&categoryCode=" + type;
- }
- function deleteSn(code){
- sendPost("patient/device/DeletePatientDevice?id="+code,{},"JSON","get",function(res){
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'删除设备失败'}).show();
- }
- },function(res){
- if(res.status==200){
- location.href="my-equipments.html";
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'删除设备失败'}).show();
- }
- })
- }
|