medical-records.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>添加住院病历</title>
  6. <link rel="stylesheet" type="text/css" href="../../../css/cross.css" />
  7. <link rel="stylesheet" type="text/css" href="../../../css/cross.ui.css" />
  8. <link rel="stylesheet" type="text/css" href="../../../css/style.min.css" />
  9. <link href="../../../plugins/toastr/toastr.min.css" rel="stylesheet">
  10. <link rel="stylesheet" href="../../../plugins/element-ui/element-ui.css" />
  11. <link rel="stylesheet" type="text/css" href="../css/common.css" />
  12. <style>
  13. .el-select-dropdown{
  14. width: 381px !important;
  15. left: 89px!important;
  16. }
  17. .upload-box{margin-top:0;padding: 10px 0 10px 10px;overflow: hidden;border: 1px solid #d7dce6;}
  18. .upload-box li{width: 60px;height: 60px;position: relative;display: block;float: left;margin-right: 10px;}
  19. .upload-box li img{width: 100%;display: block;}
  20. .upload-img-box{width: 100%;height: 100%;overflow: hidden;}
  21. .delete-img{position: absolute;right: -5px;top: -5px;color: #fff;background-color: #ccc;border-radius: 100%;text-align: center;line-height: 15px;width: 15px;height: 15px;}
  22. .upload-img{position: absolute;left: 0;right: 0;top: 0;bottom: 0;opacity: 0;z-index: 3;font-size: 0;width: 100%;height: 100%;}
  23. .add-img{font-size: 40px;line-height: 60px;font-weight: 500;width: 60px;height: 60px;display: block;text-align: center;border: 1px dashed #d7dce6;color: #bec8d2;}
  24. </style>
  25. </head>
  26. <body class="m0">
  27. <div id="app" class="p10 c-333" v-cloak>
  28. <el-tabs v-model="uploadType" @tab-click="handleClick" :stretch="true">
  29. <el-tab-pane label="手动上传" name="0"></el-tab-pane>
  30. <el-tab-pane label="拍照上传" name="1"></el-tab-pane>
  31. </el-tabs>
  32. <div v-show="uploadType=='0'">
  33. <div class="pt10 flex ui-row mt10">
  34. <label class="c-999 required" style="font-weight: normal;">入院时间:</label>
  35. <div class="flex1">
  36. <el-date-picker v-model="admissionTime" type="date" placeholder="请选择">
  37. </el-date-picker>
  38. </div>
  39. </div>
  40. <div class="pt10 flex ui-row mt10">
  41. <label class="c-999 required" style="font-weight: normal;">入院诊断:</label>
  42. <div class="flex1">
  43. <div class="flex">
  44. <el-autocomplete
  45. class="w-220"
  46. v-model="admittingDiagnosisValue"
  47. :fetch-suggestions="fetchAdmittingDiagnosis"
  48. placeholder="请输入内容"
  49. @select="handleSelect"
  50. ></el-autocomplete>
  51. <button type="button" class="btn btn-12B7F5 btn-size-s ml15" style="border-radius: 0;" @click="saveDiagnosisWrap('admitting')">+ 添加</button>
  52. </div>
  53. <div>
  54. <el-tag
  55. v-for="(v, i) in admittingTags"
  56. :key="i"
  57. closable
  58. class="mr5 mt5"
  59. @close="closeTag('admitting', i)">
  60. {{v}}
  61. </el-tag>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="pt10 flex ui-row mt10">
  66. <label class="c-999 required" style="font-weight: normal;">出院时间:</label>
  67. <div class="flex1">
  68. <!-- :picker-options="pickerOptions1" -->
  69. <el-date-picker v-model="dischargeTime" type="date" placeholder="请选择">
  70. </el-date-picker>
  71. </div>
  72. </div>
  73. <div class="pt10 flex ui-row mt10">
  74. <label class="c-999 required" style="font-weight: normal;">出院诊断:</label>
  75. <div class="flex1">
  76. <div class="flex">
  77. <el-autocomplete
  78. class="w-220"
  79. v-model="dischargeDiagnosisValue"
  80. :fetch-suggestions="fetchDischargeDiagnosis"
  81. placeholder="请输入内容"
  82. @select="handleSelect"
  83. ></el-autocomplete>
  84. <button type="button" class="btn btn-12B7F5 btn-size-s ml15" style="border-radius: 0;" @click="saveDiagnosisWrap('')">+ 添加</button>
  85. </div>
  86. <div>
  87. <el-tag
  88. v-for="(v, i) in dischargeTags"
  89. :key="i"
  90. closable
  91. class="mr5 mt5"
  92. @close="closeTag('discharge', i)">
  93. {{v}}
  94. </el-tag>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="pt10 flex ui-row mt10">
  99. <label class="c-999 required" style="font-weight: normal;">医嘱小结:</label>
  100. <div class="flex1">
  101. <textarea v-model="advice" class="p10 c-333" style="height: 160px; width: 100%; border:1px solid #e1e1e1; resize:none;box-sizing: border-box"></textarea>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="pt10 flex ui-row mt10" v-show="uploadType=='1'">
  106. <label class="c-999 required" style="font-weight: normal;">病历图片:</label>
  107. <div class="flex1">
  108. <ul class="upload-box">
  109. <li class="flex-box" v-for="(img,index) in upImgs">
  110. <div class="upload-img-box">
  111. <img :src="img.baseUrl" @click="previewImg(img.baseUrl)"/>
  112. </div>
  113. <a class="delete-img" @click="deleteImg(index)">&times;</a>
  114. </li>
  115. <li class="flex-box" v-if="upImgs.length<6">
  116. <span class="add-img">+</span>
  117. <input type="file" @change="upLoadImgToBase64" class="upload-img" />
  118. </li>
  119. </ul>
  120. <div>({{upImgs.length}}/6)</div>
  121. </div>
  122. </div>
  123. <div class="c-t-center mt20">
  124. <button type="button" class="btn btn-white btn-size-m mr15" @click="cancelMedicalRecords">取消</button>
  125. <button type="button" class="btn btn-12B7F5 btn-size-m" @click="addMedicalRecords">保存</button>
  126. </div>
  127. </div>
  128. <!--查看图片-->
  129. <div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
  130. <div id="innerdiv" style="position:absolute;">
  131. <img id="bigimg" style="border:5px solid #fff;" src="" />
  132. </div>
  133. </div>
  134. <script src="../../../js/vue.js" type="text/javascript" charset="utf-8"></script>
  135. <script src="../../../js/jquery-2.2.4.js"></script>
  136. <script src="../../../plugins/layer/layer.min.js"></script>
  137. <script src="../../../plugins/toastr/toastr.min.js"></script>
  138. <script type="text/javascript" src="../../../plugins/element-ui/element-ui.js"></script>
  139. <script src="../../../js/bootstrap.min.js"></script>
  140. <script src="../../../js/es6-promise.js" type="text/javascript" charset="utf-8"></script>
  141. <script src="../../../js/underscore.js" type="text/javascript" charset="utf-8"></script>
  142. <script src="../../../js/util.js" type="text/javascript" charset="utf-8"></script>
  143. <script src="../../../api/http-request.js" type="text/javascript"></script>
  144. <script src="../../../api/recover_api.js" type="text/javascript"></script>
  145. <script type="text/javascript" src="../../../api/rehabilitation-api.js"></script>
  146. <script type="text/javascript">
  147. var doctorType = (JSON.parse(window.localStorage.getItem('wlyyAgent'))||{}).doctorType,
  148. docInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'))
  149. var httpData=GetRequest()
  150. console.log('httpData:', httpData)
  151. function showSuccessMessage(msg) {
  152. layer.msg(msg, {
  153. icon: 1
  154. })
  155. }
  156. function showErrorMessage(msg) {
  157. layer.msg(msg, {
  158. icon: 5
  159. })
  160. }
  161. function showWarningMessage(msg) {
  162. layer.msg(msg, {
  163. icon: 2
  164. })
  165. }
  166. function showInfoMessage(msg) {
  167. layer.msg(msg, {
  168. icon: 6
  169. })
  170. }
  171. top.medicalRecordsVue = new Vue({
  172. el: "#app",
  173. data: {
  174. pickerOptions1: {
  175. disabledDate: function(time) {
  176. return time.getTime() < Date.now() - 8.64e7;
  177. }
  178. },
  179. admissionTime: '',
  180. dischargeTime: '',
  181. admittingDiagnosisValue: '',
  182. admittingDiagnosisObj: {},
  183. admittingTagsObj: {},
  184. admittingTags: [],//入院诊断标签
  185. dischargeDiagnosisValue: '',
  186. dischargeDiagnosisObj: {},
  187. dischargeTagsObj: {},
  188. dischargeTags: [],//出院诊断标签
  189. advice: '',
  190. doctorCode: docInfo.uid,
  191. patient: httpData.patient,
  192. patientName: decodeURI(httpData.patientName),
  193. medicalRecordsId: '',
  194. upImgs: [],
  195. upImgArr: [],
  196. imgData: {
  197. accept: 'image/gif, image/jpeg, image/png, image/jpg',
  198. },
  199. uploadType:'0',
  200. },
  201. mounted: function() {
  202. if(httpData['medicalRecordsId']){
  203. this.medicalRecordsId = httpData['medicalRecordsId']
  204. var curMedicalRecords = JSON.parse(window.localStorage.getItem('curMedicalRecords'))
  205. this.initMedicalRecords(curMedicalRecords)
  206. }
  207. },
  208. methods: {
  209. handleClick(tab, event) {
  210. this.uploadType = tab.index
  211. },
  212. initMedicalRecords: function(model){
  213. var vm = this
  214. if(model.admissionTime){
  215. vm.uploadType = "0"
  216. vm.admissionTime = model.admissionTime
  217. vm.dischargeTime = model.dischargeTime
  218. vm.admittingTags = model.admittingDiagnosisName.split(',')
  219. var admittingCodeArr = model.admittingDiagnosis.split(',')
  220. $.each(vm.admittingTags, function(index, o){
  221. vm.admittingTagsObj[o] = admittingCodeArr[index]
  222. })
  223. vm.dischargeTags = model.dischargeDiagnosisName.split(',')
  224. var dischargeCodeArr = model.dischargeDiagnosis.split(',')
  225. $.each(vm.dischargeTags, function(index, o){
  226. vm.dischargeTagsObj[o] = dischargeCodeArr[index]
  227. })
  228. vm.advice = model.advice
  229. }else{
  230. vm.uploadType = "1"
  231. var imgList = model.images.split(',')||[]
  232. $.each(imgList, function(index, item){
  233. var obj = {
  234. baseUrl: httpRequest.getImgUrl(item)
  235. }
  236. vm.upImgs.push(obj)
  237. })
  238. }
  239. },
  240. handleSelect: function(res){
  241. },
  242. deleteImg: function(idx) {
  243. console.log(idx)
  244. this.upImgs.splice(idx, 1)
  245. },
  246. upLoadImgToBase64: function() {
  247. var vm = this;
  248. var img1 = event.target.files[0];
  249. var reader = new FileReader();
  250. var type = img1.type; //文件的类型,判断是否是图片
  251. var size = img1.size; //文件的大小,判断图片的大小
  252. if(this.imgData.accept.indexOf(type) == -1) {
  253. alert('请选择我们支持的图片格式!');
  254. return false;
  255. }
  256. if(size > 3145728) {
  257. alert('请选择3M以内的图片!');
  258. return false;
  259. }
  260. reader.readAsDataURL(img1);
  261. reader.onload = function(e) {
  262. vm.upImgs.push({
  263. baseUrl: e.target.result
  264. });
  265. vm.upImgArr.push(img1);
  266. vm.uploadImg(vm.upImgArr);
  267. }
  268. },
  269. //上传图片
  270. uploadImg: function(data) {
  271. var vm = this;
  272. var len = data.length;
  273. if(len==0){
  274. return
  275. }
  276. var file = data[len - 1];
  277. var formData = new FormData();
  278. formData.append('file', file);
  279. rehaAPI.upload(formData).then(function(res) {
  280. if(res.status == 200) {
  281. vm.upImgs[len - 1].img = res.data;
  282. data.pop();
  283. vm.$forceUpdate()
  284. vm.uploadImg(data);
  285. } else {
  286. layer.msg(res.msg, {
  287. icon: 5
  288. });
  289. }
  290. })
  291. },
  292. //添加诊断
  293. saveDiagnosisWrap: function(type){
  294. if(type=='admitting'){
  295. if(this.admittingDiagnosisValue.trim().length>0){
  296. if(this.admittingTagsObj[this.admittingDiagnosisValue]){
  297. showInfoMessage('该诊断已被添加')
  298. return false
  299. }
  300. this.admittingTagsObj[this.admittingDiagnosisValue] = this.admittingDiagnosisObj[this.admittingDiagnosisValue]
  301. this.admittingTags.push(this.admittingDiagnosisValue)
  302. this.admittingDiagnosisValue = ''
  303. }else{
  304. showErrorMessage('请先选择诊断内容')
  305. }
  306. } else {
  307. if(this.dischargeDiagnosisValue.trim().length>0){
  308. if(this.dischargeTagsObj[this.dischargeDiagnosisValue]){
  309. showInfoMessage('该诊断已被添加')
  310. return false
  311. }
  312. this.dischargeTagsObj[this.dischargeDiagnosisValue] = this.dischargeDiagnosisObj[this.dischargeDiagnosisValue]
  313. this.dischargeTags.push(this.dischargeDiagnosisValue)
  314. this.dischargeDiagnosisValue = ''
  315. }else{
  316. showErrorMessage('请先选择诊断内容')
  317. }
  318. }
  319. },
  320. //删除诊断标签
  321. closeTag: function(type, i){
  322. if(type=='admitting'){
  323. var key = this.admittingTags[i]
  324. delete this.admittingTagsObj[key]
  325. this.admittingTags.splice(i, 1)
  326. } else {
  327. var key = this.dischargeTags[i]
  328. delete this.dischargeTagsObj[key]
  329. this.dischargeTags.splice(i, 1)
  330. }
  331. },
  332. fetchAdmittingDiagnosis: function(queryString, cb){
  333. var vm = this
  334. vm.getIcd10Info('admitting',queryString, cb)
  335. },
  336. fetchDischargeDiagnosis: function(queryString, cb){
  337. var vm = this
  338. vm.getIcd10Info('discharge',queryString, cb)
  339. },
  340. getIcd10Info: function(type, queryString, cb){
  341. var vm = this,nameKey = queryString,
  342. params = {
  343. nameKey:nameKey,
  344. page: 1,
  345. pageSize: 10000
  346. }
  347. rehaAPI.getIcd10Info(params).then(function(res){
  348. if(res.status == 200) {
  349. var arr = []
  350. if(type=='admitting'){
  351. var admittingDiseaseData = $.each(res.data, function(i, o){
  352. vm.admittingDiagnosisObj[o.name]=o.code
  353. o.value = o.name
  354. return o
  355. })
  356. arr = admittingDiseaseData
  357. } else if(type=='discharge') {
  358. var dischargeDiseaseData = $.each(res.data, function(i, o){
  359. vm.dischargeDiagnosisObj[o.name]=o.code
  360. o.value = o.name
  361. return o
  362. })
  363. arr = dischargeDiseaseData
  364. }
  365. cb(arr);
  366. } else {
  367. showErrorMessage(res.msg);
  368. }
  369. })
  370. },
  371. cancelMedicalRecords: function(){
  372. top.recoverVue.closeMedicalRecords()
  373. },
  374. previewImg: function(url){
  375. imgShow("#outerdiv", "#innerdiv", "#bigimg", url);
  376. },
  377. addMedicalRecords: function(){
  378. var vm = this
  379. var jsonData = {}
  380. if(vm.uploadType == '0'){
  381. if(!this.admissionTime){
  382. showErrorMessage('请选择入院时间!')
  383. return false
  384. }
  385. if(!this.dischargeTime){
  386. showErrorMessage('请选择出院时间!')
  387. return false
  388. }
  389. if(this.admissionTime>this.dischargeTime){
  390. showWarningMessage("入院时间应小于出院时间!")
  391. return false;
  392. }
  393. if(this.admittingTags.length<=0){
  394. showErrorMessage('请添加入院诊断!')
  395. return false
  396. }
  397. if(this.dischargeTags.length<=0){
  398. showErrorMessage('请添加出院诊断!')
  399. return false
  400. }
  401. if(!this.advice||this.advice.trim().length<=0){
  402. showErrorMessage('请输入医嘱小结!')
  403. return false
  404. }
  405. var admittingDiagnosisArr=[], admittingDiagnosisNameArr=[],
  406. dischargeDiagnosisArr = [], dischargeDiagnosisNameArr = []
  407. $.each(vm.admittingTags, function(index, value){
  408. var code = vm.admittingTagsObj[value]
  409. admittingDiagnosisArr.push(code)
  410. admittingDiagnosisNameArr.push(value)
  411. })
  412. $.each(vm.dischargeTags, function(index, value){
  413. var code = vm.dischargeTagsObj[value]
  414. dischargeDiagnosisArr.push(code)
  415. dischargeDiagnosisNameArr.push(value)
  416. })
  417. jsonData = {
  418. admissionTime: new Date(this.admissionTime).format('yyyy-MM-dd HH:mm:ss'),
  419. dischargeTime: new Date(this.dischargeTime).format('yyyy-MM-dd HH:mm:ss'),
  420. admittingDiagnosis: admittingDiagnosisArr.join(','), // 入院诊断
  421. admittingDiagnosisName: admittingDiagnosisNameArr.join(','), //入院诊断名称
  422. dischargeDiagnosis: dischargeDiagnosisArr.join(','), // 出院诊断
  423. dischargeDiagnosisName: dischargeDiagnosisNameArr.join(','), // 出院诊断名称,多个用逗号
  424. advice: this.advice,
  425. images: ""
  426. }
  427. }
  428. if(vm.uploadType == '1'){
  429. if(vm.upImgs.length==0){
  430. showErrorMessage('请上传图片!')
  431. return false
  432. }
  433. var imgList=[];
  434. $.each(vm.upImgs, function(index, item){
  435. imgList.push(item.img)
  436. })
  437. jsonData = {
  438. admissionTime: "",
  439. dischargeTime: "",
  440. admittingDiagnosis: "", // 入院诊断
  441. admittingDiagnosisName: "", //入院诊断名称
  442. dischargeDiagnosis: "", // 出院诊断
  443. dischargeDiagnosisName: "", // 出院诊断名称,多个用逗号
  444. advice: "出院继续观察",
  445. images: imgList.join(',')
  446. }
  447. }
  448. var params = {
  449. doctorCode: vm.doctorCode,
  450. patient: vm.patient,
  451. patientName: vm.patientName,
  452. jsonData: JSON.stringify(jsonData)
  453. }
  454. if(vm.medicalRecordsId){
  455. params['id'] = vm.medicalRecordsId
  456. }
  457. // console.log('paramsparamsparamsparamsparams', jsonData)
  458. // return
  459. var loading = layer.load(0, {shade: false})
  460. rehaAPI.createMedicalRecords(params).then(function(res){
  461. layer.close(loading)
  462. if(res.status==200){
  463. console.log('res.data', res.data)
  464. if(vm.medicalRecordsId){
  465. top.recoverVue.completeMedicalRecords('edit', res.data)
  466. } else {
  467. top.recoverVue.completeMedicalRecords('isNew', res.data)
  468. }
  469. }else{
  470. top.recoverVue.closeMedicalRecords()
  471. showErrorMessage(res.msg);
  472. }
  473. })
  474. }
  475. }
  476. })
  477. function imgShow(outerdiv, innerdiv, bigimg, src){
  478. // var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  479. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  480. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  481. $("<img/>").attr("src", src).load(function(){
  482. var windowW = $(window).width();//获取当前窗口宽度
  483. var windowH = $(window).height();//获取当前窗口高度
  484. var realWidth = this.width;//获取图片真实宽度
  485. var realHeight = this.height;//获取图片真实高度
  486. var imgWidth, imgHeight;
  487. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  488. if(realHeight>windowH*scale) {//判断图片高度
  489. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  490. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  491. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  492. imgWidth = windowW*scale;//再对宽度进行缩放
  493. }
  494. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  495. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  496. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  497. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  498. imgWidth = realWidth;
  499. imgHeight = realHeight;
  500. }
  501. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  502. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  503. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  504. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  505. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  506. });
  507. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  508. $(this).fadeOut("fast");
  509. });
  510. }
  511. </script>
  512. </body>
  513. </html>