device.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>设备</title>
  7. <link rel="stylesheet" type="text/css" href="../../../css/bootstrap.min.css" />
  8. <link rel="stylesheet" type="text/css" href="../../../css/style.min.css" />
  9. <link rel="stylesheet" type="text/css" href="../../../css/cross.css" />
  10. <link rel="stylesheet" href="../../../plugins/toastr/toastr.min.css" />
  11. <link rel="stylesheet" href="../../../plugins/element-ui/element-ui.css" />
  12. <link rel="stylesheet" type="text/css" href="../css/date.css" />
  13. <link rel="stylesheet" href="../css/common.css" />
  14. <style>
  15. #app {
  16. padding: 20px;
  17. position: relative;
  18. height: 100%;
  19. }
  20. .box {
  21. display: flex;
  22. flex-wrap: wrap;
  23. padding: 12px;
  24. }
  25. .item {
  26. display: flex;
  27. flex-direction: column;
  28. align-items: center;
  29. }
  30. .item .img-box {
  31. width: 200px;
  32. height: 200px;
  33. background-color: #fff;
  34. display: flex;
  35. align-items: center;
  36. justify-content: center;
  37. }
  38. .item img {
  39. width: 100px;
  40. }
  41. .device-info {
  42. display: flex;
  43. flex-direction: column;
  44. align-items: center;
  45. font-size: 18px;
  46. }
  47. .device-info img {
  48. width: 180px;
  49. margin: 10px 0;
  50. }
  51. .form-item {
  52. display: flex;
  53. align-items: center;
  54. margin-bottom: 10px;
  55. }
  56. .form-item .form-label {
  57. width: 70px;
  58. }
  59. .title {
  60. font-size: 18px;
  61. position: relative;
  62. margin-left: 6px;
  63. margin-bottom: 10px;
  64. }
  65. .title::before {
  66. content: '';
  67. width: 3px;
  68. height: 14px;
  69. position: absolute;
  70. left: -8px;
  71. top: 50%;
  72. transform: translateY(-50%);
  73. background-color: #17b3ec;
  74. }
  75. .ml6 {
  76. margin-left: 6px;
  77. }
  78. .add-device-btn {
  79. position: absolute;
  80. bottom: 28px;
  81. left: 50%;
  82. transform: translateX(-50%);
  83. width: 400px;
  84. }
  85. </style>
  86. </head>
  87. <body>
  88. <div id="app" v-cloak>
  89. <template v-if="step==1">
  90. <el-tabs v-model="active" type="card" @tab-click="tabChange">
  91. <el-tab-pane label="血压计" name="xueya" class="box">
  92. <div v-for="item in xueyaList" :id="item.id" class="item" @click="selectItem(item)">
  93. <div class="img-box">
  94. <img :src="item.photo" alt="" v-if="item.photo!=''" />
  95. <img src="../../../images/img.png" alt="" v-else />
  96. </div>
  97. <span>{{item.name}}</span>
  98. </div>
  99. </el-tab-pane>
  100. <el-tab-pane label="智能手表" name="watch" class="box">
  101. <div v-for="item in watchList" :id="item.id" class="item" @click="selectItem(item)">
  102. <div class="img-box">
  103. <img :src="item.photo" alt="" v-if="item.photo!=''" />
  104. <img src="../../../images/img.png" alt="" v-else />
  105. </div>
  106. <span>{{item.name}}</span>
  107. </div>
  108. </el-tab-pane>
  109. <el-tab-pane label="血糖仪" name="xuetang" class="box">
  110. <div v-for="item in xuetangList" :id="item.id" class="item" @click="selectItem(item)">
  111. <div class="img-box">
  112. <img :src="item.photo" alt="" v-if="item.photo!=''" />
  113. <img src="../../../images/img.png" alt="" v-else />
  114. </div>
  115. <span>{{item.name}}</span>
  116. </div>
  117. </el-tab-pane>
  118. </el-tabs>
  119. </template>
  120. <template v-else>
  121. <div class="device-info">
  122. <span>{{deviceObj.name}}</span>
  123. <img :src="deviceObj.photo" alt="" />
  124. </div>
  125. <div v-if="deviceObj.categoryCode == 2">
  126. <div class="form-item">
  127. <div class="form-label">SN码</div>
  128. <el-input v-model="query.device_sn" placeholder="请输入设备唯一码"></el-input>
  129. </div>
  130. <div class="form-item" v-if="deviceObj.deviceId == 6">
  131. <div class="form-label">SIM码</div>
  132. <el-input v-model="query.sim" placeholder="请输入SIM码"></el-input>
  133. </div>
  134. <div class="title">绑定快捷键</div>
  135. <el-radio v-model="query.userType" :label="key" class="ml6" v-for="(value, key) in deviceObj.multiUser">{{value}}</el-radio>
  136. <br />
  137. 绑定后,从该快捷键上传的数据将导入您的健康记录中!
  138. </div>
  139. <div v-else-if="deviceObj.categoryCode == 4">
  140. <div class="form-item">
  141. <div class="form-label">IMEI码</div>
  142. <el-input v-model="query.deviceSn" placeholder="请输入设备唯一码"></el-input>
  143. </div>
  144. 绑定后,智能手表监测的心率数据将自动同步导入您的健康记录中!
  145. </div>
  146. <div v-else>
  147. <div class="form-item">
  148. <div class="form-label">SN码</div>
  149. <el-input v-model="query.device_sn" placeholder="请输入设备唯一码"></el-input>
  150. </div>
  151. 绑定后,血氧仪测量的数据将自动同步导入您的健康记录中!
  152. </div>
  153. <el-button class="add-device-btn" type="primary" @click="bindDeviceFn">立即绑定</el-button>
  154. </template>
  155. </div>
  156. <script type="text/javascript" src="../../../js/vue.js"></script>
  157. <script type="text/javascript" src="../../../js/jquery-2.2.4.js"></script>
  158. <script type="text/javascript" src="../../../js/es6-promise.js" charset="utf-8"></script>
  159. <script type="text/javascript" src="../../../plugins/toastr/toastr.min.js"></script>
  160. <script type="text/javascript" src="../../../plugins/element-ui/element-ui.js"></script>
  161. <script type="text/javascript" src="../../../api/http-request.js"></script>
  162. <script type="text/javascript" src="../../../plugins/layer/layer.min.js"></script>
  163. <script type="text/javascript" src="../../../api/rehabilitation-api.js"></script>
  164. <script type="text/javascript" src="../../../api/recover_api.js"></script>
  165. <script type="text/javascript" src="../../../js/underscore-1.9.1.js"></script>
  166. <script type="text/javascript" src="../../../js/util.js" charset="utf-8"></script>
  167. <script>
  168. new Vue({
  169. el: '#app',
  170. data() {
  171. return {
  172. active: 'xueya',
  173. patient: '',
  174. step: 1,
  175. query: {},
  176. xueyaList: [],
  177. watchList: [],
  178. xuetangList: [],
  179. deviceObj: {},
  180. deviceId: null,
  181. dataId: null
  182. }
  183. },
  184. methods: {
  185. initData(){
  186. const vm = this
  187. httpRequest.get('common/device/DeviceInfo', { data: { id: this.deviceId } }).then(function(res){
  188. vm.deviceObj = res.data
  189. })
  190. },
  191. tabChange(val) {
  192. switch (val.name) {
  193. case 'xueya':
  194. this.getXueyaList()
  195. break
  196. case 'watch':
  197. this.getWatchList()
  198. break
  199. case 'xuetang':
  200. this.getXuetangList()
  201. break
  202. }
  203. },
  204. getXueyaList() {
  205. const vm = this
  206. httpRequest.get('common/device/DeviceList', { data: { category_code: 2 } }).then(function (res) {
  207. vm.xueyaList = res.data
  208. })
  209. },
  210. getWatchList() {
  211. const vm = this
  212. httpRequest.get('common/device/DeviceList', { data: { category_code: 4 } }).then(function (res) {
  213. vm.watchList = res.data
  214. })
  215. },
  216. getXuetangList() {
  217. const vm = this
  218. httpRequest.get('common/device/DeviceList', { data: { category_code: 1 } }).then(function (res) {
  219. vm.xuetangList = res.data
  220. })
  221. },
  222. selectItem(item) {
  223. const vm = this
  224. httpRequest.get('common/device/DeviceInfo', { data: { id: item.id } }).then(function (res) {
  225. vm.step++
  226. vm.deviceObj = res.data
  227. vm.deviceObj.multiUser = JSON.parse(res.data.multiUser)
  228. vm.query = {}
  229. })
  230. },
  231. bindDeviceFn() {
  232. return
  233. const vm = this
  234. var b = /^[0-9a-zA-Z]*$/g
  235. if (!b.test(this.device_sn)) {
  236. this.$message.warning('对不起,您输入的SN有误,请重新输入')
  237. }
  238. let params = {
  239. device_sn: this.query.device_sn,
  240. patient: this.patient,
  241. type: this.deviceObj.categoryCode
  242. }
  243. httpRequest.get('doctor/device/PatientDeviceIdcard', { data: params }).then(function (res) {
  244. if (res.data.length == 0) {
  245. checkSuccess(snCode)
  246. return
  247. }
  248. //遍历绑定信息
  249. var isbind = false //是否绑定
  250. var bindnum = 0
  251. var showTitle = ''
  252. var fatherData = null
  253. var montherData = null
  254. //循环取出爸爸妈妈健的数据
  255. for (var j in res.data) {
  256. var data = res.data[j] //取出设置
  257. var dataType = data['type'] //按键类型1.爸爸建2.妈妈键
  258. var others = data['others'] //others==1为被别人绑定
  259. if (dataType == 1) {
  260. fatherData = data
  261. if (others == 1) {
  262. bindnum += 1
  263. if (vm.userType == 1) vm.userType = 0 //被绑定
  264. }
  265. } else {
  266. montherData = data
  267. if (others == 1) {
  268. if (vm.userType == 2) vm.userType = 0 //被绑定
  269. $('.monther').attr('data-click', '0') //设置键2无法点击
  270. $('.montherbf').html('已经被' + data['name'] + '绑定') //设置绑定信息
  271. $('.div-monther-band').show() //显示绑定信息
  272. bindnum += 1
  273. if ($('.monther').hasClass('active')) {
  274. //用户已经选择了爸爸建,就重置
  275. $('.monther').removeClass('active')
  276. showTitle = '该快捷键已经被' + data['name'] + '绑定,若要绑定该快捷键,需' + data['name'] + '先解绑设备'
  277. }
  278. }
  279. }
  280. }
  281. if (bindnum == 2) {
  282. mui.confirm('该设备所有快捷键已被绑定,解绑快捷键后,方可再次绑定!', '', ['我知道了'], function (e) {
  283. return
  284. })
  285. $('#bang-btn').addClass('active')
  286. return false
  287. } else if (bindnum == 1 && showTitle != '') {
  288. //被绑定的按键选项
  289. mui.confirm(showTitle, '', ['我知道了'], function (e) {
  290. return
  291. })
  292. $('#bang-btn').addClass('active')
  293. return false
  294. }
  295. if (fatherData != null) {
  296. var others = fatherData['others'] //others==1为被别人绑定
  297. if (others != 1) {
  298. //被别人绑定了
  299. //被自己绑定
  300. if (dataId == null) {
  301. //新增的时候输入被自己绑定的SN码
  302. $('.father').attr('data-click', '-1') //设置爸爸妈妈键不能点击
  303. $('.monther').attr('data-click', '-1')
  304. if ($('.father').hasClass('active')) {
  305. //用户已经选择了爸爸建,就重置
  306. $('.father').removeClass('active')
  307. }
  308. mui.confirm('对不起,该居民已绑定过该设备,解绑后方可继续操作', '', ['我知道了'], function (e) {
  309. return
  310. })
  311. $('#bang-btn').addClass('active')
  312. return false //直接退出不保存
  313. } else {
  314. if (!checkSuccess) {
  315. //界面初始化的时候没有校验成功回调
  316. userType = 1
  317. //选中爸爸键
  318. $('.father').addClass('active')
  319. } else if (oldSn != snCode) {
  320. $('.father').attr('data-click', '-1') //设置爸爸妈妈键不能点击
  321. $('.monther').attr('data-click', '-1')
  322. if ($('.father').hasClass('active')) {
  323. //用户已经选择了爸爸建,就重置
  324. $('.father').removeClass('active')
  325. }
  326. mui.confirm('对不起,该居民已绑定过该设备,解绑后方可继续操作', '', ['我知道了'], function (e) {
  327. return
  328. })
  329. $('#bang-btn').addClass('active')
  330. return false //直接退出不保存
  331. }
  332. }
  333. }
  334. }
  335. if (montherData != null) {
  336. var others = montherData['others'] //others==1为被别人绑定
  337. if (others != 1) {
  338. //被自己绑定
  339. if (dataId == null) {
  340. //新增的时候输入被自己绑定的SN码
  341. $('.father').attr('data-click', '-1') //设置爸爸妈妈键不能点击
  342. $('.monther').attr('data-click', '-1')
  343. //$(".monther").addClass("active");//自己绑定了的键设置高亮
  344. if ($('.monther').hasClass('active')) {
  345. //用户已经选择了爸爸建,就重置
  346. $('.monther').removeClass('active')
  347. }
  348. mui.confirm('对不起,该居民已绑定过该设备,解绑后方可继续操作', '', ['我知道了'], function (e) {
  349. return
  350. })
  351. $('#bang-btn').addClass('active')
  352. return false //直接退出不保存
  353. } else {
  354. if (!suc) {
  355. userType = 2
  356. //选中妈妈键
  357. $('.monther').addClass('active')
  358. } else if (oldSn != snCode) {
  359. $('.father').attr('data-click', '-1') //设置爸爸妈妈键不能点击
  360. $('.monther').attr('data-click', '-1')
  361. //$(".monther").addClass("active");//自己绑定了的键设置高亮
  362. if ($('.monther').hasClass('active')) {
  363. //用户已经选择了爸爸建,就重置
  364. $('.monther').removeClass('active')
  365. }
  366. mui.confirm('对不起,该居民已绑定过该设备,解绑后方可继续操作', '', ['我知道了'], function (e) {
  367. return
  368. })
  369. $('#bang-btn').addClass('active')
  370. return false //直接退出不保存
  371. }
  372. }
  373. }
  374. }
  375. checkSuccess(snCode)
  376. })
  377. },
  378. checkSuccess(snCode) {
  379. if (userType == 0) {
  380. mui.toast('请选择要绑定的快捷键!')
  381. $('#bang-btn').addClass('active')
  382. return false
  383. }
  384. var name1 = '血压计-' + name
  385. var params = {}
  386. params.deviceId = deviceId //设备ID
  387. params.deviceName = name1 //设备名称
  388. params.deviceSn = snCode //设备SN码
  389. params.categoryCode = type //设备分类 血糖仪1 血压计 2
  390. params.userType = userType //是否多用户,1.爸爸建,2.妈妈键
  391. params.user = patient
  392. if (rowData.id) {
  393. params.id = rowData.id
  394. }
  395. if (deviceId == 6) {
  396. params.sim = $('#simcode').val()
  397. }
  398. //增加绑定信息
  399. var docInfo = JSON.parse(plus.storage.getItem('docInfo'))
  400. params.hospital = docInfo.hospital
  401. params.hospitalName = docInfo.hospitalName
  402. params.checkDoctorName = docInfo.name
  403. sendPost(
  404. 'doctor/device/SavePatientDevice',
  405. { 'data': JSON.stringify(params) },
  406. function (res) {
  407. mui.toast('设备绑定失败!')
  408. $('#bang-btn').addClass('active')
  409. },
  410. function (res) {
  411. if (res.status == '200') {
  412. mui.toast('设备绑定成功')
  413. openwdsb()
  414. } else {
  415. $('#bang-btn').addClass('active')
  416. mui.toast(res.msg)
  417. }
  418. }
  419. )
  420. }
  421. },
  422. mounted() {
  423. this.getXueyaList()
  424. this.patient = GetRequest().patient
  425. this.deviceId = GetRequest().deviceId
  426. this.dataId = GetRequest().id
  427. if(this.deviceId){
  428. this.step = 2
  429. }
  430. }
  431. })
  432. </script>
  433. </body>
  434. </html>