PushSymptom.vue 7.4 KB

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