index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="patient-search-content">
  3. <view class="notice-wrap">
  4. <view class="notice">
  5. <text>{{title}}</text>
  6. </view>
  7. </view>
  8. <view class="search-pre" v-if="searchStatus">
  9. <textarea class="desc" v-model="desc" placeholder="请详细描述您的病情(5-200字内)" maxlength="200" />
  10. <text class="head">添加医学影像</text>
  11. <p class="tip">支持各类图片,文件不大于10M</p>
  12. <view class="upload" @click="uploadBt">
  13. <div class="icon"></div>
  14. <text class="uploadTitle">点击上传</text>
  15. </view>
  16. <view class="preview" v-if="diseaseImgDesc.length>0">
  17. <view class="item" v-for="(item,index) in diseaseImgDesc" :key="index" @click="preview(baseUrl+item.path)">
  18. <image :src="baseUrl+item.path" mode="widthFix" class="preview-pic"></image>
  19. </view>
  20. </view>
  21. <button type="primary" class="submit-BT" @click="submit(1)">提交</button>
  22. </view>
  23. <view class="search-over" v-else>
  24. <checkbox-group @change="changeTags">
  25. <view class="item" v-for="(item,index) in illness" :key="index">
  26. <view class="head">
  27. <label>
  28. <checkbox :value="index.toString()" color="#3384FF" style="transform:scale(0.7)" />
  29. <text>{{item.illnessname}}</text>
  30. </label>
  31. </view>
  32. <view class="item-cont" v-html="formateTxt(item.symptom)"></view>
  33. </view>
  34. </checkbox-group>
  35. <view class="submit-BT-wrap">
  36. <button type="primary" class="submit-BT" @click="submit(2)">下一步</button>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {upload} from '@/api/index';
  43. import {searchByText,searchSubmit} from '@/api/patient';
  44. import {parseTime,notEmpty,deepClone} from '@/libs/index';
  45. import config from '@/config'
  46. const baseUrl =config.uploadServer;
  47. export default{
  48. data(){
  49. return{
  50. title:'请详情描述患者的病情(具体症状、患病时长、用药情况等)',
  51. desc:"",
  52. searchStatus:true,
  53. diseaseTags:[],
  54. illness:[],
  55. diseaseImgDesc:[],
  56. baseUrl
  57. }
  58. },
  59. methods:{
  60. submit(type){
  61. if(type===1){
  62. /*使用文本检索*/
  63. if(!notEmpty(this.desc)){
  64. uni.showToast({
  65. icon:'error',
  66. title:"请填写检索信息"
  67. })
  68. return;
  69. }
  70. searchByText({
  71. diseaseDesc:this.desc,
  72. seekTime:parseTime(new Date())
  73. }).then((res)=>{
  74. this.searchStatus=false;
  75. this.title="请选择已下病症(可多选)";
  76. this.illness=res.data.site;
  77. })
  78. }else{
  79. /*提交*/
  80. searchSubmit({
  81. diseaseDesc:this.desc,
  82. seekTime:parseTime(new Date()),
  83. site:JSON.stringify(this.diseaseTags),
  84. diseaseImgDesc:JSON.stringify(this.diseaseImgDesc)
  85. }).then((res)=>{
  86. if(res.code===0){
  87. /**检索成功返回ai推荐数据 */
  88. uni.setStorageSync('aidiagnoseInfo',res.data)
  89. uni.navigateTo({
  90. url: '/views/patientItems/diagnose/index'
  91. });
  92. }
  93. })
  94. }
  95. },
  96. changeTags({detail}){
  97. let enums=JSON.parse(JSON.stringify(this.illness));
  98. let diseaseTags=[];
  99. for(let i=0;i<detail.value.length;i++){
  100. let index=detail.value[i];
  101. diseaseTags.push(enums[index])
  102. }
  103. this.diseaseTags=diseaseTags;
  104. },
  105. uploadBt(){
  106. uni.chooseImage({
  107. success: (chooseImageRes) => {
  108. const tempFilePaths = chooseImageRes.tempFilePaths;
  109. this.uploadSubmit(tempFilePaths[0])
  110. }
  111. });
  112. },
  113. uploadSubmit(filePath){
  114. let diseaseImgDesc=deepClone(this.diseaseImgDesc);
  115. upload({filePath}).then((res)=>{
  116. let cont=JSON.parse(res)
  117. uni.showToast({
  118. title:"上传成功",
  119. icon:'success'
  120. })
  121. diseaseImgDesc.push({
  122. path:cont.data.path
  123. })
  124. this.diseaseImgDesc=diseaseImgDesc;
  125. }).catch((msg)=>{
  126. uni.showToast({
  127. title:msg||"上传失败",
  128. icon:'none'
  129. })
  130. })
  131. },
  132. formateTxt(txt){
  133. return txt.replace(/\n/g,'<br>');
  134. },
  135. preview(path){
  136. uni.previewImage({
  137. urls:path,
  138. fail(res) {
  139. console.log(res)
  140. }
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .patient-search-content{
  148. .notice-wrap{
  149. padding:24upx 20upx ;
  150. .notice{
  151. background-color:#FFF2EA;
  152. padding: 20upx 26upx 20upx 16upx;
  153. color: #FA6400;
  154. }
  155. }
  156. .desc{
  157. font-size: 32upx;
  158. width: 702upx;
  159. height: 50vh;
  160. display: block;
  161. margin: 0 auto;
  162. text-indent: 58upx;
  163. }
  164. .head{
  165. padding-left: 59upx;
  166. font-size: 30upx;
  167. color: #333;
  168. }
  169. .tip{
  170. padding: 8upx 0 16upx 59upx;
  171. font-size: 24upx;
  172. color: #3584FF;
  173. }
  174. .upload{
  175. width: 150upx;
  176. height: 120upx;
  177. background-color: #F1F1F1;
  178. margin-left: 59upx;
  179. padding-top: 30upx;
  180. .icon{
  181. width: 50upx;
  182. height: 50upx;
  183. margin: 0 auto;
  184. position: relative;
  185. &::after{
  186. width: 4upx;
  187. height: 50upx;
  188. display: block;
  189. content: "";
  190. position: absolute;
  191. left: 50%;
  192. top: 50%;
  193. transform: translate(-50%,-50%);
  194. background-color: #ccc;
  195. }
  196. &::before{
  197. width: 50upx;
  198. height: 4upx;
  199. display: block;
  200. content: "";
  201. position: absolute;
  202. left: 50%;
  203. top: 50%;
  204. transform: translate(-50%,-50%);
  205. background-color: #ccc;
  206. }
  207. }
  208. .uploadTitle{
  209. text-align: center;
  210. display: block;
  211. font-size: 24upx;
  212. color: #666;
  213. padding-top: 12upx;
  214. }
  215. }
  216. .submit-BT{
  217. display: block;
  218. width: 702upx;
  219. height: 98upx;
  220. line-height: 98upx;
  221. text-align: center;
  222. color: #fff;
  223. font-size: 32upx;
  224. letter-spacing: 4upx;
  225. margin-top: 40upx;
  226. background-color: #3384FF;
  227. }
  228. .search-pre{
  229. .preview{
  230. display: flex;
  231. justify-content: flex-start;
  232. flex-wrap: wrap;
  233. .item{
  234. width: 40upx;
  235. height: 40upx;
  236. margin-left: 8upx;
  237. margin-top: 8upx;
  238. .preview-pic{
  239. display: block;
  240. width: 40upx;
  241. height: 40upx;
  242. }
  243. }
  244. }
  245. }
  246. .search-over{
  247. padding-left: 34upx;
  248. .item{
  249. .head{
  250. font-size: 28upx;
  251. color: #333;
  252. padding: 24upx 0;
  253. display: flex;
  254. justify-content: flex-start;
  255. align-items: center;
  256. }
  257. .item-cont{
  258. font-size: 24upx;
  259. color:#666666;
  260. line-height: 36upx;
  261. padding-top: 23upx;
  262. }
  263. }
  264. .submit-BT-wrap{
  265. position: fixed;
  266. bottom: 0;
  267. width: 100%;
  268. padding: 20upx 0;
  269. background-color: #fff;
  270. left: 0;
  271. border-top: #eaeaea;
  272. }
  273. padding-bottom: 200upx;
  274. }
  275. }
  276. </style>