Symptom.vue 11 KB

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