You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.0 KiB

2 years ago
4 months ago
2 years ago
4 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. const {getapi, postapi, putapi, deletapi} = require('../api/api');
  2. // 这种方式一般不推荐使用,因为同步(阻塞)方式 响应页面响应
  3. //获取登记人员 所登记的组合项目
  4. const getPrAsb = async (id) =>{
  5. let result = {
  6. code: -1,
  7. message:'',
  8. data:[]
  9. }
  10. if(!id) return result
  11. try {
  12. let res = await getapi(`/api/app/registerasbitem/getlistinpatientregisterid?PatientRegisterId=${id}`)
  13. if(res.code != -1){
  14. // console.log(`getPrAsb:PatientRegisterId=${id}:data:`,res.data)
  15. result.code = 1
  16. result.message = "success"
  17. res.data.forEach(e => {
  18. e.standTotal = e.amount * e.standardPrice
  19. e.total = e.amount * e.chargePrice
  20. result.data.push(e)
  21. });
  22. }
  23. } catch (error) {
  24. result.message = error
  25. }
  26. return result
  27. };
  28. async function savePeoplePhoto(peopleId, photoBase64) {
  29. let lres = { code: -1, msg: '' }
  30. if (!peopleId) return { code: -1, msg: '人员ID不能为空' }
  31. if (!photoBase64 || photoBase64.indexOf('data:image') < 0) return { code: -1, msg: '图像数据不是合法的base64编码数据' }
  32. let uploadPhoto = {
  33. patientRegisterId: peopleId,
  34. photo: photoBase64.split(",")[1],
  35. };
  36. try {
  37. lres = await postapi(`/api/app/patient-register/up-load-img`, uploadPhoto)
  38. let body = {
  39. patientRegisterId: peopleId,
  40. photo: lres.data,
  41. }
  42. await postapi(`/api/app/patient-register/update-photo`, body)
  43. } catch (error) {
  44. lres = { code: -1, msg: error }
  45. }
  46. return lres
  47. };
  48. // 照片是相对路径时,加刷新标识
  49. function photoParse(photo) {
  50. let sysConfig = JSON.parse(window.sessionStorage.getItem('sysConfig'))
  51. //console.log(sysConfig,photo)
  52. let lphoto = '' //data:image、UpLoad/、/pic/Photo.jpg
  53. if (!photo) return '/pic/Photo.jpg'
  54. if (photo.toLowerCase().indexOf("http") > - 1) {
  55. lphoto = photo
  56. } else {
  57. lphoto = sysConfig.apiurl + '/' + photo + '?' + new Date().getTime()
  58. }
  59. //console.log(lphoto)
  60. return lphoto
  61. };
  62. module.exports = {
  63. getPrAsb,savePeoplePhoto,photoParse
  64. }