device.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. .back-btn {
  86. position: absolute;
  87. bottom: 80px;
  88. left: 50%;
  89. transform: translateX(-47.5%);
  90. width: 400px;
  91. }
  92. </style>
  93. </head>
  94. <body>
  95. <div id="app" v-cloak>
  96. <template v-if="step==1">
  97. <el-tabs v-model="active" type="card" @tab-click="tabChange">
  98. <el-tab-pane label="血压计" name="xueya" class="box">
  99. <div v-for="item in xueyaList" :id="item.id" class="item" @click="selectItem(item)">
  100. <div class="img-box">
  101. <img :src="item.photo" alt="" v-if="item.photo!=''" />
  102. <img src="../../../images/img.png" alt="" v-else />
  103. </div>
  104. <span>{{item.name}}</span>
  105. </div>
  106. </el-tab-pane>
  107. <el-tab-pane label="智能手表" name="watch" class="box">
  108. <div v-for="item in watchList" :id="item.id" class="item" @click="selectItem(item)">
  109. <div class="img-box">
  110. <img :src="item.photo" alt="" v-if="item.photo!=''" />
  111. <img src="../../../images/img.png" alt="" v-else />
  112. </div>
  113. <span>{{item.name}}</span>
  114. </div>
  115. </el-tab-pane>
  116. <el-tab-pane label="血糖仪" name="xuetang" class="box">
  117. <div v-for="item in xuetangList" :id="item.id" class="item" @click="selectItem(item)">
  118. <div class="img-box">
  119. <img :src="item.photo" alt="" v-if="item.photo!=''" />
  120. <img src="../../../images/img.png" alt="" v-else />
  121. </div>
  122. <span>{{item.name}}</span>
  123. </div>
  124. </el-tab-pane>
  125. </el-tabs>
  126. </template>
  127. <template v-else>
  128. <div class="device-info">
  129. <span>{{deviceObj.name}}</span>
  130. <img :src="deviceObj.photo" alt="" />
  131. </div>
  132. <div v-if="deviceObj.categoryCode == 2">
  133. <div class="form-item">
  134. <div class="form-label">SN码</div>
  135. <el-input v-model="query.deviceSn" :disabled="dataId" placeholder="请输入设备唯一码"></el-input>
  136. </div>
  137. <div class="form-item" v-if="deviceObj.deviceId == 6">
  138. <div class="form-label">SIM码</div>
  139. <el-input v-model="query.sim" :disabled="dataId" placeholder="请输入SIM码"></el-input>
  140. </div>
  141. <div v-if="deviceObj.isMultiUser == 1">
  142. <div class="title">绑定快捷键</div>
  143. <div v-for="(value, key) in deviceObj.multiUser">
  144. <el-radio v-model="query.userType" :disabled="dataId" :label="key" class="ml6">{{value}}</el-radio>
  145. </div>
  146. </div>
  147. 绑定后,从该快捷键上传的数据将导入您的健康记录中!
  148. </div>
  149. <div v-else-if="deviceObj.categoryCode == 4">
  150. <div class="form-item">
  151. <div class="form-label">IMEI码</div>
  152. <el-input v-model="query.deviceSn" :disabled="dataId" placeholder="请输入设备唯一码"></el-input>
  153. </div>
  154. 绑定后,智能手表监测的心率数据将自动同步导入您的健康记录中!
  155. </div>
  156. <div v-else>
  157. <div class="form-item">
  158. <div class="form-label">SN码</div>
  159. <el-input v-model="query.deviceSn" :disabled="dataId" placeholder="请输入设备唯一码"></el-input>
  160. </div>
  161. 绑定后,血氧仪测量的数据将自动同步导入您的健康记录中!
  162. </div>
  163. <el-button class="back-btn" v-if="!dataId" @click="backFn">返回</el-button>
  164. <el-button class="add-device-btn" v-if="!dataId" type="primary" @click="bindDeviceFn">立即绑定</el-button>
  165. </template>
  166. </div>
  167. <script type="text/javascript" src="../../../js/vue.js"></script>
  168. <script type="text/javascript" src="../../../js/jquery-2.2.4.js"></script>
  169. <script type="text/javascript" src="../../../js/es6-promise.js" charset="utf-8"></script>
  170. <script type="text/javascript" src="../../../plugins/toastr/toastr.min.js"></script>
  171. <script type="text/javascript" src="../../../plugins/element-ui/element-ui.js"></script>
  172. <script type="text/javascript" src="../../../api/http-request.js"></script>
  173. <script type="text/javascript" src="../../../plugins/layer/layer.min.js"></script>
  174. <script type="text/javascript" src="../../../api/rehabilitation-api.js"></script>
  175. <script type="text/javascript" src="../../../api/recover_api.js"></script>
  176. <script type="text/javascript" src="../../../js/underscore-1.9.1.js"></script>
  177. <script type="text/javascript" src="../../../js/util.js" charset="utf-8"></script>
  178. <script>
  179. new Vue({
  180. el: '#app',
  181. data() {
  182. return {
  183. active: 'xueya',
  184. patient: '',
  185. step: 1,
  186. query: {},
  187. xueyaList: [],
  188. watchList: [],
  189. xuetangList: [],
  190. deviceObj: {},
  191. deviceId: null,
  192. dataId: null,
  193. docInfo: {}
  194. }
  195. },
  196. methods: {
  197. initData() {
  198. const vm = this
  199. httpRequest.get('common/device/DeviceInfo', { data: { id: this.deviceId } }).then(function (res) {
  200. vm.deviceObj = res.data
  201. if (vm.deviceObj.isMultiUser == 1) {
  202. vm.deviceObj.multiUser = JSON.parse(res.data.multiUser)
  203. }
  204. })
  205. httpRequest.get('doctor/device/PatientDeviceInfo', { data: { id: this.dataId } }).then(function (res) {
  206. vm.query = {
  207. deviceSn: res.data.deviceSn,
  208. sim: res.data.sim,
  209. userType: res.data.userType
  210. }
  211. })
  212. },
  213. tabChange(val) {
  214. switch (val.name) {
  215. case 'xueya':
  216. this.getXueyaList()
  217. break
  218. case 'watch':
  219. this.getWatchList()
  220. break
  221. case 'xuetang':
  222. this.getXuetangList()
  223. break
  224. }
  225. },
  226. getXueyaList() {
  227. const vm = this
  228. httpRequest.get('common/device/DeviceList', { data: { category_code: 2 } }).then(function (res) {
  229. vm.xueyaList = res.data
  230. })
  231. },
  232. getWatchList() {
  233. const vm = this
  234. httpRequest.get('common/device/DeviceList', { data: { category_code: 4 } }).then(function (res) {
  235. vm.watchList = res.data
  236. })
  237. },
  238. getXuetangList() {
  239. const vm = this
  240. httpRequest.get('common/device/DeviceList', { data: { category_code: 1 } }).then(function (res) {
  241. vm.xuetangList = res.data
  242. })
  243. },
  244. selectItem(item) {
  245. const vm = this
  246. httpRequest.get('common/device/DeviceInfo', { data: { id: item.id } }).then(function (res) {
  247. vm.step++
  248. vm.deviceObj = res.data
  249. if (vm.deviceObj.isMultiUser == 1) {
  250. vm.deviceObj.multiUser = JSON.parse(res.data.multiUser)
  251. }
  252. vm.query = {}
  253. })
  254. },
  255. bindDeviceFn() {
  256. const vm = this
  257. var b = /^[0-9a-zA-Z]*$/g
  258. if (!b.test(this.device_sn)) {
  259. this.$message.warning('对不起,您输入的SN有误,请重新输入')
  260. }
  261. let params = {
  262. device_sn: this.query.deviceSn,
  263. patient: this.patient,
  264. type: this.deviceObj.categoryCode
  265. }
  266. httpRequest.get('doctor/device/PatientDeviceIdcard', { data: params }).then(function (res) {
  267. if (res.status == 200) {
  268. var name = ''
  269. var others = null
  270. for (var j in res.data) {
  271. name = res.data[j].name
  272. others = res.data[j].others
  273. }
  274. //没被绑定
  275. if (name == '') {
  276. if (vm.checkSuccess != null) {
  277. vm.checkSuccess()
  278. }
  279. return false
  280. } else if (others != null && others == 1) {
  281. // $("#bang-btn").removeClass("active");
  282. //被绑定而且被别人绑定
  283. vm.$message.warning('该设备已被他人绑定,设备解绑后,方可再次绑定')
  284. return false
  285. } else if (others != null && others == 0) {
  286. // $("#bang-btn").removeClass("active");
  287. if (oldSn != vm.query.deviceSn) {
  288. //新增,编辑/被自己绑定
  289. vm.$message.warning('对不起,该居民已绑定过该设备,解绑后方可继续操作')
  290. return
  291. } else {
  292. if (vm.checkSuccess != null) {
  293. vm.checkSuccess()
  294. return false
  295. }
  296. }
  297. }
  298. }
  299. })
  300. },
  301. backFn() {
  302. this.step = 1
  303. },
  304. checkSuccess() {
  305. const vm = this
  306. const data = {
  307. deviceId: this.deviceObj.id,
  308. deviceName: this.deviceObj.name,
  309. deviceSn: this.query.deviceSn,
  310. categoryCode: this.deviceObj.categoryCode,
  311. userType: this.deviceObj.categoryCode == 1 ? '-1' : this.query.userType,
  312. user: this.patient,
  313. hospital: this.docInfo.hospital,
  314. hospitalName: this.docInfo.hospitalName,
  315. checkDoctorName: this.docInfo.doctorName
  316. }
  317. httpRequest.post('doctor/device/SavePatientDevice', { data: {data:JSON.stringify(data)} }).then(function (res) {
  318. if (res.status == '200') {
  319. vm.$message.success('绑定设备成功!')
  320. var index = parent.layer.getFrameIndex(window.name)
  321. parent.layer.close(index)
  322. }else{
  323. vm.$message.error(res.msg)
  324. }
  325. })
  326. }
  327. },
  328. mounted() {
  329. this.getXueyaList()
  330. this.patient = GetRequest().patient
  331. this.docInfo = JSON.parse(localStorage.getItem('docInfo'))
  332. this.deviceId = GetRequest().deviceId
  333. this.dataId = GetRequest().id
  334. if (this.dataId) {
  335. this.step = 2
  336. this.initData()
  337. }
  338. }
  339. })
  340. </script>
  341. </body>
  342. </html>