123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>设备</title>
- <link rel="stylesheet" type="text/css" href="../../../css/bootstrap.min.css" />
- <link rel="stylesheet" type="text/css" href="../../../css/style.min.css" />
- <link rel="stylesheet" type="text/css" href="../../../css/cross.css" />
- <link rel="stylesheet" href="../../../plugins/toastr/toastr.min.css" />
- <link rel="stylesheet" href="../../../plugins/element-ui/element-ui.css" />
- <link rel="stylesheet" type="text/css" href="../css/date.css" />
- <link rel="stylesheet" href="../css/common.css" />
- <style>
- #app {
- padding: 20px;
- position: relative;
- height: 100%;
- }
- .box {
- display: flex;
- flex-wrap: wrap;
- padding: 12px;
- }
- .item {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .item .img-box {
- width: 200px;
- height: 200px;
- background-color: #fff;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .item img {
- width: 100px;
- }
- .device-info {
- display: flex;
- flex-direction: column;
- align-items: center;
- font-size: 18px;
- }
- .device-info img {
- width: 180px;
- margin: 10px 0;
- }
- .form-item {
- display: flex;
- align-items: center;
- margin-bottom: 10px;
- }
- .form-item .form-label {
- width: 70px;
- }
- .title {
- font-size: 18px;
- position: relative;
- margin-left: 6px;
- margin-bottom: 10px;
- }
- .title::before {
- content: '';
- width: 3px;
- height: 14px;
- position: absolute;
- left: -8px;
- top: 50%;
- transform: translateY(-50%);
- background-color: #17b3ec;
- }
- .ml6 {
- margin-left: 6px;
- }
- .add-device-btn {
- position: absolute;
- bottom: 28px;
- left: 50%;
- transform: translateX(-50%);
- width: 400px;
- }
- </style>
- </head>
- <body>
- <div id="app" v-cloak>
- <template v-if="step==1">
- <el-tabs v-model="active" type="card" @tab-click="tabChange">
- <el-tab-pane label="血压计" name="xueya" class="box">
- <div v-for="item in xueyaList" :id="item.id" class="item" @click="selectItem(item)">
- <div class="img-box">
- <img :src="item.photo" alt="" v-if="item.photo!=''" />
- <img src="../../../images/img.png" alt="" v-else />
- </div>
- <span>{{item.name}}</span>
- </div>
- </el-tab-pane>
- <el-tab-pane label="智能手表" name="watch" class="box">
- <div v-for="item in watchList" :id="item.id" class="item" @click="selectItem(item)">
- <div class="img-box">
- <img :src="item.photo" alt="" v-if="item.photo!=''" />
- <img src="../../../images/img.png" alt="" v-else />
- </div>
- <span>{{item.name}}</span>
- </div>
- </el-tab-pane>
- <el-tab-pane label="血糖仪" name="xuetang" class="box">
- <div v-for="item in xuetangList" :id="item.id" class="item" @click="selectItem(item)">
- <div class="img-box">
- <img :src="item.photo" alt="" v-if="item.photo!=''" />
- <img src="../../../images/img.png" alt="" v-else />
- </div>
- <span>{{item.name}}</span>
- </div>
- </el-tab-pane>
- </el-tabs>
- </template>
- <template v-else>
- <div class="device-info">
- <span>{{deviceObj.name}}</span>
- <img :src="deviceObj.photo" alt="" />
- </div>
- <div v-if="deviceObj.categoryCode == 2">
- <div class="form-item">
- <div class="form-label">SN码</div>
- <el-input v-model="query.device_sn" placeholder="请输入设备唯一码"></el-input>
- </div>
- <div class="form-item" v-if="deviceObj.deviceId == 6">
- <div class="form-label">SIM码</div>
- <el-input v-model="query.sim" placeholder="请输入SIM码"></el-input>
- </div>
- <div class="title">绑定快捷键</div>
- <el-radio v-model="query.userType" :label="key" class="ml6" v-for="(value, key) in deviceObj.multiUser">{{value}}</el-radio>
- <br />
- 绑定后,从该快捷键上传的数据将导入您的健康记录中!
- </div>
- <div v-else-if="deviceObj.categoryCode == 4">
- <div class="form-item">
- <div class="form-label">IMEI码</div>
- <el-input v-model="query.deviceSn" placeholder="请输入设备唯一码"></el-input>
- </div>
- 绑定后,智能手表监测的心率数据将自动同步导入您的健康记录中!
- </div>
- <div v-else>
- <div class="form-item">
- <div class="form-label">SN码</div>
- <el-input v-model="query.device_sn" placeholder="请输入设备唯一码"></el-input>
- </div>
- 绑定后,血氧仪测量的数据将自动同步导入您的健康记录中!
- </div>
- <el-button class="add-device-btn" type="primary" @click="bindDeviceFn">立即绑定</el-button>
- </template>
- </div>
- <script type="text/javascript" src="../../../js/vue.js"></script>
- <script type="text/javascript" src="../../../js/jquery-2.2.4.js"></script>
- <script type="text/javascript" src="../../../js/es6-promise.js" charset="utf-8"></script>
- <script type="text/javascript" src="../../../plugins/toastr/toastr.min.js"></script>
- <script type="text/javascript" src="../../../plugins/element-ui/element-ui.js"></script>
- <script type="text/javascript" src="../../../api/http-request.js"></script>
- <script type="text/javascript" src="../../../plugins/layer/layer.min.js"></script>
- <script type="text/javascript" src="../../../api/rehabilitation-api.js"></script>
- <script type="text/javascript" src="../../../api/recover_api.js"></script>
- <script type="text/javascript" src="../../../js/underscore-1.9.1.js"></script>
- <script type="text/javascript" src="../../../js/util.js" charset="utf-8"></script>
- <script>
- new Vue({
- el: '#app',
- data() {
- return {
- active: 'xueya',
- patient: '',
- step: 1,
- query: {},
- xueyaList: [],
- watchList: [],
- xuetangList: [],
- deviceObj: {},
- deviceId: null,
- dataId: null
- }
- },
- methods: {
- initData(){
- const vm = this
- httpRequest.get('common/device/DeviceInfo', { data: { id: this.deviceId } }).then(function(res){
- vm.deviceObj = res.data
- })
- },
- tabChange(val) {
- switch (val.name) {
- case 'xueya':
- this.getXueyaList()
- break
- case 'watch':
- this.getWatchList()
- break
- case 'xuetang':
- this.getXuetangList()
- break
- }
- },
- getXueyaList() {
- const vm = this
-
- httpRequest.get('common/device/DeviceList', { data: { category_code: 2 } }).then(function (res) {
- vm.xueyaList = res.data
- })
- },
- getWatchList() {
- const vm = this
- httpRequest.get('common/device/DeviceList', { data: { category_code: 4 } }).then(function (res) {
- vm.watchList = res.data
- })
- },
- getXuetangList() {
- const vm = this
- httpRequest.get('common/device/DeviceList', { data: { category_code: 1 } }).then(function (res) {
- vm.xuetangList = res.data
- })
- },
- selectItem(item) {
- const vm = this
- httpRequest.get('common/device/DeviceInfo', { data: { id: item.id } }).then(function (res) {
- vm.step++
- vm.deviceObj = res.data
- vm.deviceObj.multiUser = JSON.parse(res.data.multiUser)
- vm.query = {}
- })
- },
- bindDeviceFn() {
- return
- const vm = this
- var b = /^[0-9a-zA-Z]*$/g
- if (!b.test(this.device_sn)) {
- this.$message.warning('对不起,您输入的SN有误,请重新输入')
- }
- let params = {
- device_sn: this.query.device_sn,
- patient: this.patient,
- type: this.deviceObj.categoryCode
- }
- httpRequest.get('doctor/device/PatientDeviceIdcard', { data: params }).then(function (res) {
- if (res.data.length == 0) {
- checkSuccess(snCode)
- return
- }
- //遍历绑定信息
- var isbind = false //是否绑定
- var bindnum = 0
- var showTitle = ''
- var fatherData = null
- var montherData = null
- //循环取出爸爸妈妈健的数据
- for (var j in res.data) {
- var data = res.data[j] //取出设置
- var dataType = data['type'] //按键类型1.爸爸建2.妈妈键
- var others = data['others'] //others==1为被别人绑定
- if (dataType == 1) {
- fatherData = data
- if (others == 1) {
- bindnum += 1
- if (vm.userType == 1) vm.userType = 0 //被绑定
- }
- } else {
- montherData = data
- if (others == 1) {
- if (vm.userType == 2) vm.userType = 0 //被绑定
- $('.monther').attr('data-click', '0') //设置键2无法点击
- $('.montherbf').html('已经被' + data['name'] + '绑定') //设置绑定信息
- $('.div-monther-band').show() //显示绑定信息
- bindnum += 1
- if ($('.monther').hasClass('active')) {
- //用户已经选择了爸爸建,就重置
- $('.monther').removeClass('active')
- showTitle = '该快捷键已经被' + data['name'] + '绑定,若要绑定该快捷键,需' + data['name'] + '先解绑设备'
- }
- }
- }
- }
- if (bindnum == 2) {
- mui.confirm('该设备所有快捷键已被绑定,解绑快捷键后,方可再次绑定!', '', ['我知道了'], function (e) {
- return
- })
- $('#bang-btn').addClass('active')
- return false
- } else if (bindnum == 1 && showTitle != '') {
- //被绑定的按键选项
- mui.confirm(showTitle, '', ['我知道了'], function (e) {
- return
- })
- $('#bang-btn').addClass('active')
- return false
- }
- if (fatherData != null) {
- var others = fatherData['others'] //others==1为被别人绑定
- if (others != 1) {
- //被别人绑定了
- //被自己绑定
- if (dataId == null) {
- //新增的时候输入被自己绑定的SN码
- $('.father').attr('data-click', '-1') //设置爸爸妈妈键不能点击
- $('.monther').attr('data-click', '-1')
- if ($('.father').hasClass('active')) {
- //用户已经选择了爸爸建,就重置
- $('.father').removeClass('active')
- }
- mui.confirm('对不起,该居民已绑定过该设备,解绑后方可继续操作', '', ['我知道了'], function (e) {
- return
- })
- $('#bang-btn').addClass('active')
- return false //直接退出不保存
- } else {
- if (!checkSuccess) {
- //界面初始化的时候没有校验成功回调
- userType = 1
- //选中爸爸键
- $('.father').addClass('active')
- } else if (oldSn != snCode) {
- $('.father').attr('data-click', '-1') //设置爸爸妈妈键不能点击
- $('.monther').attr('data-click', '-1')
- if ($('.father').hasClass('active')) {
- //用户已经选择了爸爸建,就重置
- $('.father').removeClass('active')
- }
- mui.confirm('对不起,该居民已绑定过该设备,解绑后方可继续操作', '', ['我知道了'], function (e) {
- return
- })
- $('#bang-btn').addClass('active')
- return false //直接退出不保存
- }
- }
- }
- }
- if (montherData != null) {
- var others = montherData['others'] //others==1为被别人绑定
- if (others != 1) {
- //被自己绑定
- if (dataId == null) {
- //新增的时候输入被自己绑定的SN码
- $('.father').attr('data-click', '-1') //设置爸爸妈妈键不能点击
- $('.monther').attr('data-click', '-1')
- //$(".monther").addClass("active");//自己绑定了的键设置高亮
- if ($('.monther').hasClass('active')) {
- //用户已经选择了爸爸建,就重置
- $('.monther').removeClass('active')
- }
- mui.confirm('对不起,该居民已绑定过该设备,解绑后方可继续操作', '', ['我知道了'], function (e) {
- return
- })
- $('#bang-btn').addClass('active')
- return false //直接退出不保存
- } else {
- if (!suc) {
- userType = 2
- //选中妈妈键
- $('.monther').addClass('active')
- } else if (oldSn != snCode) {
- $('.father').attr('data-click', '-1') //设置爸爸妈妈键不能点击
- $('.monther').attr('data-click', '-1')
- //$(".monther").addClass("active");//自己绑定了的键设置高亮
- if ($('.monther').hasClass('active')) {
- //用户已经选择了爸爸建,就重置
- $('.monther').removeClass('active')
- }
- mui.confirm('对不起,该居民已绑定过该设备,解绑后方可继续操作', '', ['我知道了'], function (e) {
- return
- })
- $('#bang-btn').addClass('active')
- return false //直接退出不保存
- }
- }
- }
- }
- checkSuccess(snCode)
- })
- },
- checkSuccess(snCode) {
- if (userType == 0) {
- mui.toast('请选择要绑定的快捷键!')
- $('#bang-btn').addClass('active')
- return false
- }
- var name1 = '血压计-' + name
- var params = {}
- params.deviceId = deviceId //设备ID
- params.deviceName = name1 //设备名称
- params.deviceSn = snCode //设备SN码
- params.categoryCode = type //设备分类 血糖仪1 血压计 2
- params.userType = userType //是否多用户,1.爸爸建,2.妈妈键
- params.user = patient
- if (rowData.id) {
- params.id = rowData.id
- }
- if (deviceId == 6) {
- params.sim = $('#simcode').val()
- }
- //增加绑定信息
- var docInfo = JSON.parse(plus.storage.getItem('docInfo'))
- params.hospital = docInfo.hospital
- params.hospitalName = docInfo.hospitalName
- params.checkDoctorName = docInfo.name
- sendPost(
- 'doctor/device/SavePatientDevice',
- { 'data': JSON.stringify(params) },
- function (res) {
- mui.toast('设备绑定失败!')
- $('#bang-btn').addClass('active')
- },
- function (res) {
- if (res.status == '200') {
- mui.toast('设备绑定成功')
- openwdsb()
- } else {
- $('#bang-btn').addClass('active')
- mui.toast(res.msg)
- }
- }
- )
- }
- },
- mounted() {
- this.getXueyaList()
- this.patient = GetRequest().patient
- this.deviceId = GetRequest().deviceId
- this.dataId = GetRequest().id
- if(this.deviceId){
- this.step = 2
- }
- }
- })
- </script>
- </body>
- </html>
|