PushSymptom.vue 8.9 KB

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