PushSymptom.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <portal to="notification-outlet">
  3. <div class="select">
  4. <div class="selected-tags">
  5. <p class="title">已选伴随症状:</p>
  6. <ul class="clearfix">
  7. <li v-if="selecteds.length>0" v-for="it in selecteds">
  8. <span>{{it.description||it.name}}</span>
  9. <img @click="delSelected(it)" src="../images/closeimg.png" alt=""/>
  10. </li>
  11. </ul>
  12. </div>
  13. <ul class="tags clearfix">
  14. <li
  15. v-for="(item,idx) in symptoms"
  16. :class="[{'liSelect':item.select,'big':item.explains}]"
  17. :key="item.id"
  18. @click="selectResult(item,idx)"
  19. >
  20. {{item.description||item.name}}
  21. <img src="../images/icon_que.png" alt="解释说明" @click.stop="showExplain(item)" v-if="item.explains"/>
  22. </li>
  23. </ul>
  24. <div :class="selecteds.length>0?'realSure sure':'sure'" @click="makeSuer">
  25. 确定 <span v-if="numPlus">({{numPlus}})</span>
  26. </div>
  27. </div>
  28. </portal>
  29. </template>
  30. <script>
  31. import api from '../utils/api.js';
  32. import {mapState} from 'vuex';
  33. import {delResymptoms} from '@utils/tools';
  34. export default {
  35. props: ["num"],
  36. data() {
  37. return {
  38. selecteds: [], //已选伴随症状
  39. selectedsName:'', //已选伴随症状名称
  40. symptoms:[], //症状
  41. sure:false,
  42. numPlus:0, //已选答案个数
  43. };
  44. },
  45. computed:{
  46. ...mapState({
  47. activeModule: state => state.activeModule,
  48. chooseSymp: state => state.symptom.choose,//已选症状
  49. checkText: state => state.symptom.text,//症状情况文字
  50. config: state => state.sysConfig,
  51. pathInfo: state => state.pathInfo,
  52. extSyms: state => state.extPushSymptom
  53. }),
  54. },
  55. mounted() {
  56. //this.numPlus = this.num
  57. //this.result = this.symptomResult.questionDetailList;
  58. this.getPush(this.chooseSymp[0].name);
  59. },
  60. methods: {
  61. getSympText() {//推送使用医生端信息
  62. const text = this.$store.state.symptom.text;
  63. let msg = "";
  64. for (let i in text) {
  65. if(text[i] && text[i].text){
  66. msg += text[i].text;
  67. }
  68. }
  69. return trimDots(msg);
  70. },
  71. getPush(symptoms) {//推理
  72. const param = {
  73. "age": this.pathInfo.patientAge,
  74. "hosCode": this.pathInfo.hospitalCode,
  75. "sex": this.pathInfo.sexType,
  76. "symptom": symptoms //症状+选择的明细,string
  77. };
  78. api.getPush(param).then((res) => {
  79. const result = res.data;
  80. if (result.code == 0&&result.data) {
  81. const syms = result.data.symptom;
  82. const none={
  83. conceptId: 0,
  84. name: "没有了",
  85. tagName: "没有了",
  86. libType: 1,
  87. id: 0,
  88. type: 1,
  89. description: "",
  90. exclusion:1,
  91. hasExplain: 0,
  92. explains: null,
  93. };
  94. //没有了与其他互斥
  95. const hasNone = symptoms.indexOf("没有了")!==-1;
  96. const selecteds = this.selecteds;
  97. const exts=JSON.parse(JSON.stringify(this.extSyms));
  98. const newSyms = delResymptoms(exts,syms);
  99. const newExt =selecteds.length>0?newSyms.reduce((total,it,idx)=>{
  100. if(selecteds.findIndex((i)=>i.name===it.name)!==-1){
  101. total.splice(idx,1);
  102. }
  103. return total;
  104. },[...newSyms]):newSyms;
  105. if(hasNone){
  106. this.symptoms = [...newExt];
  107. }else{
  108. this.symptoms = [none,...newExt];
  109. }
  110. this.symptoms.length=this.symptoms.length>10?10:this.symptoms.length;
  111. //this.getSymptomLisCom(result)
  112. }else{
  113. //this.getSymptomLisCom()
  114. }
  115. }).catch((err)=>{
  116. })
  117. },
  118. getSymptomLisCom(result){
  119. let symp = (result&&result.data.symptom)||[];
  120. let symped = JSON.parse(JSON.stringify(this.chooseSymp));//已选症状
  121. let sympStic = JSON.parse(localStorage.getItem('staticSymp'))||[];//首次有无症状
  122. let sympAll = sympStic.concat(symp);
  123. var obj = {};
  124. sympAll = sympAll.reduce(function(item, next) {
  125. obj[next.name] ? '' : obj[next.name] = true && item.push(next);
  126. return item;
  127. }, []);
  128. for(let i = 0;i < symped.length;i++){//去掉已选的已选症状
  129. for(let j = 0;j < sympAll.length;j++){//去掉
  130. if(sympAll[j].name == symped[i].name){
  131. sympAll.splice(j,1)
  132. }
  133. }
  134. }
  135. this.symp = sympAll.slice(0,12);
  136. this.$refs.showHide.style.height = 'auto'
  137. },
  138. makeSuer() {
  139. if(!this.selecteds.length>0){return}
  140. let number = this.num;
  141. const sName=this.selectedsName.replace(/、+/g,"、").replace(/^、|、$/g,'');
  142. const sNamep=this.selectedsName.replace(/、+/g,"、").replace(/^、|、$/g,'');
  143. this.$emit("updataResult", '',{val:sName,valp:sNamep,idx:2},++number);
  144. this.$store.commit("setChoose",{choose:[...this.chooseSymp,...this.selecteds]});
  145. },
  146. selectResult(item) {
  147. if(this.selecteds.length>2&&item.name!=="没有了"){
  148. this.$emit('warning','最多选择3个症状');
  149. return;
  150. }
  151. const hasNone = this.selecteds.findIndex((it)=>{
  152. return it.name==='没有了';
  153. })!==-1;
  154. if(hasNone){
  155. this.selecteds.splice(0,1);
  156. this.selectedsName = this.selectedsName.replace("没有了",'');
  157. this.selectedsNamep = this.selectedsNamep.replace("没有了",'');
  158. }else if(item.name==='没有了'){
  159. this.selecteds=[];
  160. this.selectedsName = '';
  161. this.selectedsNamep ='';
  162. }
  163. const name = item.name;
  164. const namep=item.description||item.name;
  165. this.selectedsName = this.selectedsName?this.selectedsName+"、"+name:name;
  166. this.selectedsNamep = this.selectedsNamep?this.selectedsNamep+"、"+namep:namep;
  167. this.selecteds.push(item);
  168. this.numPlus = this.selectedsName==="没有了"?0:this.selecteds.length;
  169. this.getPush(this.chooseSymp[0].name+this.selectedsName);
  170. },
  171. delSelected(item){ //删除已选伴随症状
  172. const selecteds = JSON.parse(JSON.stringify(this.selecteds));
  173. const inx = selecteds.findIndex((it)=>{
  174. return it.tagName === item.tagName;
  175. });
  176. if(inx!==-1){
  177. this.selectedsName = this.selectedsName.replace(item.name,"");
  178. this.selectedsNamep = this.selectedsNamep.replace(item.description||item.name,"");
  179. selecteds.splice(inx,1);
  180. }
  181. this.selecteds = selecteds;
  182. this.numPlus = this.selectedsName==="没有了"?0:this.selecteds.length;
  183. this.getPush(this.chooseSymp[0].name+this.selectedsName);
  184. }
  185. }
  186. };
  187. </script>
  188. <style lang="less" scoped>
  189. @import "../less/base.less";
  190. .select{
  191. background-color: #fff;
  192. padding: 0.28rem 0 0 0;
  193. position: fixed;
  194. width: 100%;
  195. bottom: 0;
  196. box-sizing: border-box;
  197. box-shadow: 0 0 30px -10px rgba(104, 124, 189, 0.25);
  198. }
  199. .selected-tags{
  200. margin-bottom: .8rem;
  201. .title{
  202. color: #aaa;
  203. font-size: .26rem;
  204. margin-bottom: .4rem;
  205. text-indent: .28rem;
  206. }
  207. li{
  208. position: relative;
  209. display:inline-block;
  210. span{
  211. display: inline-block;
  212. padding: 0.14rem 0.2rem;
  213. background-color: #colors[btn];
  214. border:1px #colors[btn] solid;
  215. border-radius: 0.36rem;
  216. font-size: 0.26rem;
  217. margin: 0.15rem;
  218. float: left;
  219. color: #fff;
  220. }
  221. img{
  222. width: .3rem;
  223. height: .3rem;
  224. position: absolute;
  225. right: .05rem;
  226. top: .1rem;
  227. }
  228. }
  229. }
  230. .tags {
  231. li {
  232. padding: 0.14rem 0.2rem;
  233. border:1px #DFE0E4 solid;
  234. border-radius: 0.36rem;
  235. font-size: 0.26rem;
  236. margin: 0.15rem;
  237. float: left;
  238. color: #666;
  239. position: relative;
  240. &.big{
  241. margin: 0.15rem .65rem .15rem .15rem
  242. }
  243. img{
  244. width: .35rem;
  245. position: absolute;
  246. right: -0.55rem;
  247. }
  248. }
  249. .liSelect {
  250. color: #fff;
  251. background-color: #colors[btn];
  252. border-color: #colors[btn];
  253. }
  254. }
  255. </style>