Symptom.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <div class="symp-wrap symper btscroll">
  3. <div class="content">
  4. <div
  5. class="choose"
  6. v-if="chooseSymp.length>0"
  7. >
  8. <p class="quest">已选症状</p>
  9. <p
  10. class="choo-symp"
  11. v-for="(v,i) in chooseSymp"
  12. >
  13. <span @click="showChecked(v)">{{v.description || v.name}}</span>
  14. <span @click="deletSymp(v,i)"><img
  15. src="../images/del.png"
  16. alt=""
  17. ></span>
  18. </p>
  19. </div>
  20. <div class="label">
  21. <p class="quest" id="test">{{quesText}}<img
  22. @click="search(true)"
  23. class="searchImg"
  24. src="../images/search.png"
  25. alt=""
  26. ></p>
  27. <!-- <span
  28. class="symp"
  29. v-for="(it,ind) in symp"
  30. :key="it.conceptId"
  31. @click="showDetil(it)"
  32. >{{it.description || it.name}}</span> -->
  33. <!-- 暂时隐藏长按显示功能 -->
  34. <span
  35. class="symp"
  36. v-for="(it,ind) in symp"
  37. v-if="ind<9||showAll"
  38. :key="it.conceptId"
  39. @touchstart.stop.prevent="touchstart(it)"
  40. @touchend.stop.prevent="touchend(it)"
  41. >{{it.description || it.name}}</span>
  42. <p class="show-all" v-if="chooseSymp.length===0" @click="showAllLabel">{{showAll?"收起":"展开全部"}}</p>
  43. <p class="tip" v-show="chooseSymp.length==0">长按症状按钮可显示症状解释说明</p>
  44. </div>
  45. <div
  46. class="result"
  47. v-if="checkText.length>0"
  48. >
  49. <p class="title">{{nameStr}}</p>
  50. <p v-for="(value,index) in checkText">{{value.textP}}</p>
  51. </div>
  52. </div>
  53. <div v-if="modluesLen>1"
  54. :class="['footer',{'nofoot':chooseSymp.length==0}]"
  55. @click="toNext"
  56. >下一步</div>
  57. <div v-if="modluesLen==1"
  58. :class="['footer',{'nofoot':chooseSymp.length==0}]"
  59. @click="toNext"
  60. >预览并提交病历</div>
  61. <Toast
  62. :message="delText"
  63. :show="showToast"
  64. @comfirn="comfirnDel"
  65. @cancel="cancelDel"
  66. />
  67. <Search
  68. v-if="this.$store.state.searchShow"
  69. @search="search"
  70. @setText="common"
  71. @showDetil="showDetil"
  72. :age="age"
  73. :chooseSymp="chooseSymp"
  74. :sexType="sexType"
  75. ></Search>
  76. <Tiptoast :show="showExp" :data="message" @close="closeTip"/>
  77. </div>
  78. </template>
  79. <script type="text/javascript">
  80. import api from '@utils/api.js';
  81. import DetailBox from './DetailBox.vue';
  82. import Toast from '../common/Toast.vue';
  83. import Tiptoast from '../common/Tiptoast.vue';
  84. import Search from './Search.vue';
  85. import {moduleCP,setScroll,trimDots} from '@utils/tools'
  86. import BScroll from 'better-scroll';
  87. import $ from 'jquery';
  88. export default {
  89. name: 'Symptom',
  90. props:['modluesLen','nameStr'],
  91. data() {
  92. let { datas, pathInfo,searchShow } = this.$store.state;
  93. const { choose, text } = this.$store.state.symptom;
  94. return {
  95. age: pathInfo.patientAge,
  96. sexType: pathInfo.patientSex == '男' ? 1 : (pathInfo.patientSex == '女' ? 2 : 3),
  97. deptName: pathInfo.selfDeptName,
  98. hosCode: pathInfo.hospitalCode,
  99. chooseSymp: choose, //已选症状
  100. symp: [], //症状
  101. labelDetail: {}, //明细
  102. checkText: text, //症状情况文字
  103. questId: null, //id
  104. delText: "是否删除该信息?<br/>(已填内容将清除)",
  105. delIndex: null,
  106. showToast: false,
  107. searchShow: searchShow,//显示搜索界面
  108. tmpItem:{},//检索的症状
  109. isSearch:false,
  110. scroll:null,
  111. quesText:"请问您这次哪里最不舒服?",
  112. startTime:'',
  113. timer:null,
  114. showExp:false,
  115. showAll:false, //默认显示9个症状,showAll=true展开全部
  116. message:{
  117. title:'',
  118. text:''
  119. }
  120. }
  121. },
  122. created() {
  123. if (this.chooseSymp.length > 0) {
  124. this.quesText = "请问您还有其他不适吗?";
  125. // 推送
  126. const sympText = this.getSympText();
  127. this.getPush(sympText);
  128. } else {
  129. this.getSympList(); //常见
  130. }
  131. },
  132. mounted(){
  133. this.$nextTick(()=>{
  134. let scroll = setScroll(BScroll,true,'.symper')
  135. this.scroll = scroll
  136. scroll.on('scroll', this.onScroll)
  137. })
  138. },
  139. methods: {
  140. touchstart(it){
  141. this.startTime = +new Date();
  142. const that = this;
  143. this.start = this.$store.state.scroll;
  144. this.timer = setTimeout(function(){
  145. // 长按事件
  146. that.showExp = true;
  147. if(it.explains){
  148. that.message.title = it.description || it.name;
  149. that.message.text = it.explains;
  150. }else{
  151. that.message.title = "";
  152. that.message.text = "暂无资料";
  153. }
  154. },600)
  155. },
  156. closeTip(){
  157. this.showExp = false,
  158. this.message.title = '';
  159. this.message.text = '';
  160. },
  161. onScroll(data) {
  162. this.$store.commit('setScroll', data);
  163. document.activeElement.scrollIntoViewIfNeeded(true);
  164. },
  165. search(flg) {
  166. this.$store.commit('setSearchShow', flg);
  167. },
  168. getSympList() {
  169. const param = {
  170. "age": this.age,
  171. "deptName": this.deptName,
  172. "sexType": this.sexType
  173. }
  174. api.getSymptom(param).then((res) => {
  175. const result = res.data;
  176. if (result.code == 0) {
  177. this.symp = result.data;
  178. }
  179. })
  180. },
  181. toNext() {
  182. // 把1切换成完成图标,且2高亮--判断有几个模块显示,1个--提交预览;1个以上--下一步
  183. if (this.chooseSymp.length == 0) { return }
  184. // 把症状情况的数据存起-已选
  185. this.$store.commit('setChoose', { choose: this.chooseSymp, type: moduleCP['symp'] });
  186. if(this.modluesLen==1){
  187. this.$emit('next','preview')
  188. }else{
  189. this.$emit('next');
  190. }
  191. },
  192. common(item,flg){
  193. this.questId = item.questionId || item.id || item.conceptId;
  194. const id = item.questionId || item.id; //常见症状questionId,推送id,两者均有可能没有
  195. //将选中的name存到store中的text
  196. this.$store.commit('setText', { type: moduleCP['symp'], text: item.name,textP: item.description||item.name, pId: this.questId });
  197. //不是第一个症状,都不弹出详情
  198. if (this.chooseSymp.length === 0&&id) {
  199. const param = {
  200. "age": this.age,
  201. "id": id,
  202. "sexType": this.sexType
  203. }
  204. api.getById(param).then((res) => {
  205. const result = res.data;
  206. if (result.code == 0) {
  207. const mapping = result.data.questionMapping;
  208. this.labelDetail = result.data;
  209. this.$store.commit('setOrigin', { type: moduleCP['symp'], data: result.data });
  210. if (mapping && mapping.length > 0) {
  211. this.$store.commit('setDetail',{detail:result.data,ppId:null,moduleType:moduleCP['symp']})
  212. if(flg){
  213. return
  214. }
  215. this.chooseSymp.push(item);
  216. } else {
  217. this.chooseSymp.push(item);
  218. this.$store.commit('setSearchShow', false);
  219. }
  220. }
  221. })
  222. } else {//没有questionId或id
  223. this.chooseSymp.push(item);
  224. this.checkText = this.$store.state.symptom.text;
  225. }
  226. },
  227. showDetil(item,flg) {//搜索点开的详情
  228. this.tmpItem=item
  229. this.isSearch=flg||false
  230. this.common(item,flg);
  231. },
  232. touchend(item,flg) {//症状点开详情
  233. clearTimeout(this.timer);
  234. this.end = this.$store.state.scroll;
  235. if(JSON.stringify(this.start)!== JSON.stringify(this.end)){
  236. return;
  237. }
  238. let endTime = +new Date();
  239. if(endTime - this.startTime < 500){//点击事件
  240. this.common(item,flg);
  241. }
  242. this.startTime = "";
  243. },
  244. showAllLabel(){
  245. this.showAll = !this.showAll;
  246. },
  247. getSympText() {//推送使用医生端信息
  248. const text = this.$store.state.symptom.text;
  249. let msg = "";
  250. for (let i in text) {
  251. if(text[i] && text[i].text){
  252. msg += text[i].text;
  253. }
  254. }
  255. return trimDots(msg);
  256. },
  257. getPush(symptoms) {//推理
  258. const param = {
  259. "age": this.age,
  260. "hosCode": this.hosCode,
  261. "sex": this.sexType,
  262. "symptom": symptoms //症状+选择的明细,string
  263. }
  264. api.getPush(param).then((res) => {
  265. const result = res.data;
  266. if (result.code == 0) {
  267. this.symp = result.data.symptom;
  268. }
  269. })
  270. },
  271. deletSymp(item, index) {
  272. this.delIndex = index;
  273. this.questId = item.questionId || item.id || item.conceptId;
  274. if (this.chooseSymp.length == 1) {
  275. this.delText = "是否删除该信息?<br/>删除后将重新填写预问诊流程 <br/>(已填内容将清除)"
  276. }
  277. this.showToast = true;
  278. $(".btscroll").css({'position':'fixed'})
  279. $(".foot").css({'position':'fixed'})
  280. },
  281. comfirnDel() {
  282. $(".btscroll").css({'position':'absolute'})
  283. this.chooseSymp.splice(this.delIndex, 1);
  284. this.checkText.splice(this.delIndex, 1);
  285. this.$store.commit('delText', { type: moduleCP['symp'], pId: this.questId })
  286. // 删除setDatas数据,防止回读
  287. this.$store.commit('setDatas', { type: moduleCP['symp'], pId: this.questId ,data:''})
  288. // 删除完-常见;其他-推送
  289. if (this.chooseSymp.length > 0) {
  290. } else {
  291. // 全部删除完 重新走问诊流程
  292. // this.$router.push("/")
  293. // this.$router.replace({path:'/'})
  294. // 停留在当前页 8-19
  295. this.quesText = "请问您这次哪里最不舒服?";
  296. this.getSympList();
  297. }
  298. this.cancelDel();
  299. },
  300. cancelDel() {
  301. $(".btscroll").css({'position':'absolute'})
  302. this.showToast = false;
  303. this.delIndex = null;
  304. this.questId = null;
  305. this.delText = "是否删除该信息?<br/>(已填内容将清除)";
  306. },
  307. showChecked(item) {
  308. const origin = this.$store.state.symptom.origin;
  309. const read = this.$store.state.symptom.datas;
  310. const data = read[(item.questionId||item.id)] || origin[(item.questionId||item.id)];
  311. if (data&&data.questionMapping && data.questionMapping.length > 0) {
  312. this.$store.commit('setDetail',{detail:data,ppId:null,moduleType:moduleCP['symp']})
  313. }
  314. },
  315. },
  316. components: {
  317. DetailBox,
  318. Toast,
  319. Search,
  320. Tiptoast
  321. },
  322. watch:{
  323. checkText:{//更新推送
  324. handler(newVal,oldVal){
  325. const sympText = this.getSympText();
  326. if(sympText){
  327. this.getPush(sympText);
  328. this.quesText = "请问您还有其他不适吗?";
  329. }else{
  330. this.getSympList();
  331. this.quesText = "请问您这次哪里最不舒服?";
  332. }
  333. },
  334. deep:true
  335. }
  336. }
  337. }
  338. </script>
  339. <style lang="less" scoped>
  340. @import "../less/base.less";
  341. .symp-wrap {
  342. font-size: 0.3rem;
  343. // .btscroll;
  344. .quest {
  345. color: #colors[quest];
  346. margin-bottom: 0.36rem;
  347. font-weight: 700;
  348. .searchImg {
  349. width: 0.44rem;
  350. height: 0.44rem;
  351. float: right;
  352. }
  353. }
  354. }
  355. .choose{
  356. padding-bottom: .2rem;
  357. .choo-symp{
  358. display: inline-block;
  359. min-width:1.9rem;
  360. height: .74rem;
  361. background: linear-gradient(-270deg, #3638EE, #4E72FF);
  362. box-shadow: 0 .08rem .16rem 0 rgba(79,129,255,0.40);
  363. border-radius: .08rem;
  364. white-space: nowrap;
  365. margin: 0 .25rem .3rem 0;
  366. span{
  367. display: inline-block;
  368. vertical-align: top;
  369. }
  370. span:first-child{
  371. min-width:1.42rem;
  372. height: .74rem;
  373. line-height: .74rem;
  374. text-align: center;
  375. color: #fff;
  376. }
  377. img{
  378. width:.48rem;
  379. height: .74rem;
  380. }
  381. }
  382. .choo-symp:last-child{
  383. margin-right: 0;
  384. }
  385. .label{
  386. .label;
  387. }
  388. .result{
  389. padding-right: .3rem;
  390. .title{
  391. color: #4F50FF;
  392. padding-left: .1rem;
  393. border-left: .08rem solid #4F50FF;
  394. margin-bottom: .19rem;
  395. font-weight: 700;
  396. }
  397. p{
  398. color: #666;
  399. line-height: .44rem;
  400. }
  401. }
  402. .footer{
  403. .footer;
  404. }
  405. }
  406. .label{
  407. .label;
  408. .show-all{
  409. text-align: right;
  410. color: #4f7aff;
  411. font-size: 0.25rem;
  412. height:35px;
  413. line-height: 35px;
  414. float: right;
  415. /* width: 80px;
  416. border:1px #4f7aff solid;
  417. border-radius: 5px;
  418. margin: auto;*/
  419. }
  420. }
  421. .result{
  422. .result;
  423. }
  424. .footer{
  425. .footer;
  426. }
  427. .nofoot{
  428. background:#CACCFF;
  429. }
  430. </style>