MainPage.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <template>
  2. <div class="page">
  3. <Head :activeTab='activeTab' :allMoudles='allMoudles' :progress='progress'/>
  4. <!-- <div class="progress-bar">
  5. <div class="title">
  6. <span :class="{'active':activeTab==i.type}" :style="{width:(100/allMoudles.length)+'%'}" v-for="i in allMoudles">{{i.name}}</span>
  7. </div>
  8. <div class="progress">
  9. <p :style="{width:progress}"></p>
  10. </div>
  11. </div> -->
  12. <div class="wrapper">
  13. <div class="scrollPart" :style="{'paddingBottom':pdbm}">
  14. <!--<div class="right clearfix">
  15. <img src="../assets/patient.png" alt="" class="fr">
  16. <div class="content fr">
  17. <p>医生您好!我想咨询新型冠状病毒。(个人信息:{{userInfo.patientName}}{{userInfo.patientSex?','+userInfo.patientSex:''}}{{userInfo.patientAge?','+userInfo.patientAge+'岁':''}})</p>
  18. </div>
  19. </div>-->
  20. <div class="left clearfix">
  21. <img src="../images/doctor.png" alt="" class="fl">
  22. <div class="content fl">
  23. <p>欢迎来到{{userInfo.hospitalName}}!候诊期间请先填写自己的实际症状,信息会马上传送到您的预约医生,便于您实现快速就诊。</p>
  24. </div>
  25. </div>
  26. <!--<div class="left clearfix" @click="selectToggle(2,disData.symptom.result,true)">
  27. <img src="../assets/doctor.png" alt="" class="fl">
  28. <div class="content fl">
  29. <p>您哪里不舒服?</p>
  30. </div>
  31. </div>-->
  32. <UsualSymptom v-if="showUsual" @selectUsual="selectUsual"></UsualSymptom>
  33. <div class="right clearfix" v-if="selectedSymptom.name">
  34. <img src="../images/patient.png" alt="" class="fr">
  35. <div class="content fr">
  36. <p>{{selectedSymptom.description||selectedSymptom.name}}</p>
  37. </div>
  38. <span v-if="!canceledSym&&num<1" class="edit" @click="cancelSymptom">修改</span>
  39. </div>
  40. <div v-for="(item,idx) in symptomQasList" :key="'0'+idx+item.id" v-if="activeTab">
  41. <Dialog :idx="idx" v-if="item.show" :item="item" @cancel="cancelSelected" :num="activeNum" :cancelNum="canceledQa" :extNum ="[]" :cancelTab="cancelTab" :isLast="idx===symptomQasList.length-1"/>
  42. </div>
  43. <div v-for="(item,idx) in diagnoseQasList" :key="'1'+idx+item.id" v-if="activeTab==moduleKeys[1]||activeTab==moduleKeys[2]||activeTab==moduleKeys[3]">
  44. <Dialog :idx="idx" v-if="item.show" :item="item" @cancel="cancelSelected" :num="activeNum" :extNum ="[symptomQasList.length]" :cancelNum="canceledQa" :cancelTab="cancelTab" :isLast="idx===diagnoseQasList.length-1"/>
  45. </div>
  46. <div v-for="(item,idx) in othersQasList" :key="'2'+idx+item.id" v-if="activeTab==moduleKeys[2]||activeTab==moduleKeys[3]">
  47. <Dialog :idx="idx" v-if="item.show" :item="item" @cancel="cancelSelected" :num="activeNum" :extNum ="[symptomQasList.length,diagnoseQasList.length]" :cancelNum="canceledQa" :cancelTab="cancelTab" :isLast="idx===othersQasList.length-1"/>
  48. </div>
  49. <div v-for="(item,idx) in addContentQasList" :key="'3'+idx+item.id" v-if="activeTab==moduleKeys[3]">
  50. <Dialog :idx="idx" v-if="item.show" :item="item" @cancel="cancelSelected" :num="activeNum" :extNum ="[symptomQasList.length,diagnoseQasList.length,othersQasList.length]" :cancelNum="canceledQa" :cancelTab="cancelTab"/>
  51. </div>
  52. </div>
  53. </div>
  54. <MultSelect @updataResult="updataResultSingle" :num="num" :symptomResult="symptomResult" v-if="type==3"></MultSelect>
  55. <Select @updataResult="updataResultSingle" :num="num" @getExtQa="addExtQa" :symptomResult="symptomResult" v-if="type == 2"></Select>
  56. <Radio @updataResultSingle="updataResultSingle" @getExtQa="addExtQa" :num="num" :symptomResult="symptomResult" v-if="type == 1"></Radio>
  57. <!--普通单列拨盘-->
  58. <Picker v-if="type==10" @confirm="updataResultSingle" :columns="getColumns()" :num="num" :defaultIndex = "defaultIndex"></Picker>
  59. <!--时间拨盘,拨盘内容写死-->
  60. <Picker v-if="type == 9" :symptomResult="symptomResult" :columns="getTimeColumns()" :defaultVal="pickDVal" @confirm="updataResultSingle" :num="num" :defaultIndex = "defaultIndex"></Picker>
  61. <PushSymptom v-if="type == 99" @updataResult="updataResultSingle" :num="num" @warning="showWarn"></PushSymptom>
  62. <!-- 上传图片 -->
  63. <UploadImg v-if="type==4"
  64. :num="num"
  65. :item="symptomResult"
  66. :moduleType="symptomResult.type"
  67. @updataResult="updataResultSingle"
  68. :imgList="imgs"/>
  69. <!-- 输入框 -->
  70. <!--<Input v-if="type==7"
  71. :num="num"
  72. :item="symptomResult"
  73. :key="symptomResult.id"
  74. @updata="updataResultSingle"/>-->
  75. <!-- 文本域 -->
  76. <ComTextArea v-if="type==6 || type == 5"
  77. :num="num"
  78. :item="symptomResult"
  79. width="92%"
  80. @updata="updataResultSingle"/>
  81. <div class="submit" v-if="showPreview">
  82. <a href="javascript:void(0)" @click="previewRes">提交并预览</a>
  83. </div>
  84. <!--<div v-if="wrong" class="tip">{{waring}}</div>-->
  85. <TipWarning v-if="wrong" :text="waring" @close="closeTip"/>
  86. </div>
  87. </template>
  88. <script>
  89. import BScroll from 'better-scroll';
  90. import Radio from '../common/Radio';
  91. import Select from '../common/Select';
  92. import Dialog from '../common/Dialog';
  93. import Picker from '../common/Picker';
  94. import Label from '../common/Label.vue';
  95. import ComTextArea from '../common/ComTextArea.vue';
  96. /*import Input from '../common/Input.vue';*/
  97. import PickTime from '../common/PickTime.vue';
  98. import UploadImg from '../common/UploadImg.vue';
  99. import PushSymptom from '../common/PushSymptom.vue';
  100. import ConfirmBox from '../common/ConfirmBox'
  101. import UsualSymptom from '../common/UsualSymptom';
  102. import MultSelect from '../common/MultSelect.vue';
  103. import TipWarning from '../common/TipWarning.vue';
  104. import Head from '../common/Head.vue';
  105. import api from "../utils/api.js";
  106. import {mapState} from 'vuex';
  107. import {moduleCP,moduleConfig,getValuesArr,getNSum} from '@utils/tools'
  108. export default {
  109. name:'MainPage',
  110. data(){
  111. return {
  112. num:-1,//题目计数
  113. pickDVal:'1天', //时间控件默认值
  114. allMoudles:[],
  115. showUsual:false, //常用症状显示
  116. activeTab:1, //当前模块
  117. activeNum:0, //当前问题的index,整体顺序
  118. scroll:null,
  119. canceledSym:false, //是否已修改过主症状
  120. canceledQa:-1,
  121. cancelTab:-1,
  122. deledUpload:[], //被删除的上传控件数据(记录用于修改时恢复)
  123. type :-1, //当前显示的控件类型
  124. showPreview:false,//显示预览按钮
  125. selectedSymptom:{},
  126. symptomResult:'',//症状选择
  127. connectResult:[],//关联问题的id
  128. contentResult:{},//选中的结果val医生端显示,valp患者端显示
  129. symptomQasList:[],//症状详情所有的问题
  130. diagnoseQasList:[], //诊疗详情所有问题
  131. othersQasList:[],//其他情况所有问题
  132. addContentQasList:[],
  133. moduleMap:{
  134. 1:'symptom',
  135. 51:'diagnose',
  136. 3:'others',
  137. 52:'addContent'
  138. },
  139. defaultIndex: 0, //温度默认值
  140. order:0,
  141. userInfo: {}, //用户信息
  142. pdbm:'8.5rem',
  143. waring:'', //错误提示语
  144. wrong:false, //是否显示错误toast
  145. showConfirm: false,
  146. time:1000,
  147. }
  148. },
  149. created() {
  150. //const userInfo= JSON.parse(localStorage.getItem("userInfo"))
  151. const userInfo = this.$store.state.pathInfo;
  152. this.userInfo = userInfo;
  153. let tmpModule = moduleConfig(this.config,this.tmpAllMoudles);
  154. this.allMoudles = tmpModule.data;
  155. this.updata()
  156. },
  157. mounted(){
  158. this.$nextTick(()=>{
  159. let bs = new BScroll('.wrapper', {
  160. probeType: 3,
  161. click:true
  162. });
  163. this.scroll = bs
  164. })
  165. // this.tmpSymptom = JSON.parse(JSON.stringify(data))
  166. //this.symptomResult = data.symptom.result;
  167. },
  168. computed:{
  169. ...mapState({
  170. imgs: state => state.diagnose.imgSrc,
  171. tmpAllMoudles: state => state.allMoudles,
  172. config: state => state.sysConfig,
  173. }),
  174. moduleKeys(){
  175. return this.allMoudles.map((it)=>{
  176. return it.type;
  177. });
  178. },
  179. progress(){
  180. if(this.num===-1){
  181. return '0.1px';
  182. }
  183. const moduleName = this.moduleMap[this.activeTab]+'QasList';
  184. const precent = (this.num+1)/this[moduleName].length;
  185. return precent*100+"%";
  186. }
  187. },
  188. watch:{
  189. num:function(){
  190. let n=0;
  191. let numArr=this.moduleKeys.map((i,index)=>{
  192. if(this.activeTab!=-1&&i==this.activeTab){
  193. n=index;
  194. }
  195. return this[this.moduleMap[i]+'QasList'].length;
  196. });
  197. numArr.length=n;
  198. this.activeNum = getNSum(numArr)+this.num;
  199. }
  200. },
  201. methods:{
  202. getColumns(){
  203. return getValuesArr(this.symptomResult.questionDetailList);
  204. },
  205. previewRes(){
  206. this.$router.push({
  207. path:'/preview'
  208. })
  209. },
  210. updata(){
  211. this.symptomQasList = [];
  212. //this.pdbm = '8.5rem';
  213. this.showUsual=true;
  214. this.num = 0;
  215. },
  216. selectToggle(type,result,flg,idx,order){
  217. return
  218. if(flg){
  219. this.num = 1
  220. }
  221. this.symptomResult = result
  222. this.type = type
  223. this.order = order
  224. this.scrollDown()
  225. },
  226. getTimeColumns(){
  227. let num = [];
  228. for(let i = 1; i <=60; i++) {
  229. num.push(i)
  230. }
  231. let unit = ['分钟', '小时', '天', '周', '月','年'];
  232. return [
  233. {
  234. values:num,
  235. className:'column1',
  236. defaultIndex: 0
  237. },
  238. {
  239. values:unit,
  240. className:'column2',
  241. defaultIndex: 2
  242. },
  243. ]
  244. },
  245. cancelSelected(){ //修改题目
  246. let moduleName='',tmpArr=[],tmpPreItem={},tmpNowItem={};
  247. moduleName = this.moduleMap[this.activeTab]+'QasList';
  248. tmpArr = this[moduleName];
  249. tmpNowItem = tmpArr[this.num];
  250. this.type = -1;
  251. tmpNowItem?tmpNowItem.show = false:''; //最后一题时没有下一题
  252. const keyIdx = this.moduleKeys.findIndex((i)=>i==this.activeTab);
  253. if(this.activeTab!==this.moduleKeys[0]&&this.num===0){ //取消上一阶段的最后一题时
  254. this.activeTab=this.moduleKeys[keyIdx-1];
  255. this.cancelTab=keyIdx-1;
  256. moduleName = this.moduleMap[this.activeTab]+'QasList';
  257. const n = this[moduleName].length-1;
  258. tmpPreItem = this[moduleName][n];
  259. this.num=n;
  260. }else{
  261. this.cancelTab=keyIdx;
  262. tmpPreItem = tmpArr[this.num-1];
  263. this.num=this.num-1;
  264. }
  265. tmpPreItem.content='';
  266. this.symptomResult = tmpPreItem;
  267. const timer = setTimeout(()=>{
  268. this.type = tmpPreItem.controlType;
  269. clearTimeout(timer);
  270. });
  271. this.canceledQa=this.num; //记录被修改过的题目,只可修改一次
  272. },
  273. formatQaArr(obj){
  274. let arr = [],nobj=JSON.parse(JSON.stringify(obj));
  275. for(let i in nobj){
  276. arr.push(nobj[i]);
  277. }
  278. return arr;
  279. },
  280. addExtQa(obj,i){
  281. const mName=this.moduleMap[this.activeTab];
  282. let moduleName = mName+'QasList';
  283. const dataArr = this.formatQaArr(obj);
  284. this[moduleName].splice(i+1,0,...dataArr);
  285. this.$store.commit("setModuleDatas",{data:this[moduleName],mName});
  286. },
  287. updataResultSingle(result,contentResult,num){
  288. this.num = num;
  289. this.type = -1;
  290. const mkeys =this.moduleKeys;
  291. let moduleName = this.moduleMap[this.activeTab]+'QasList';
  292. let tmpArr = JSON.parse(JSON.stringify(this[moduleName]));
  293. tmpArr[num-1].content = contentResult.valp;
  294. //选没有可上传报告,则上传控件不显示
  295. const noUpload = this.symptomResult.id===999999&&contentResult.valp.indexOf("没有")!==-1;
  296. if(noUpload&&this.deledUpload.length===0){ //是否可上传没有被修改过
  297. this.deledUpload=tmpArr.splice(num,1);
  298. this.$store.commit("cancelImgs");
  299. }else if(this.symptomResult.id===999999&&!noUpload&&this.deledUpload.length>0){
  300. tmpArr.splice(num,0,...this.deledUpload);
  301. this.$store.commit("cancelImgs");
  302. }
  303. this[moduleName] = tmpArr;
  304. //上传的图片及是否有可上传***答案不显示在预览所以不记录到state.diagnose.text中
  305. if(this.symptomResult.id!==999999&&this.symptomResult.controlType!=4){
  306. this.$store.commit('setText', { type: this.activeTab,
  307. text: contentResult.val,
  308. textP: contentResult.valp,
  309. idx:contentResult.idx,
  310. flag:contentResult.flag,
  311. isEdit:this.num-1==this.canceledQa
  312. });
  313. }
  314. //console.log(this.$store.state); //最后一题答完
  315. if(+num===this[moduleName].length||(noUpload&&+num===this[moduleName].length+1)){
  316. if(this.activeTab===mkeys[mkeys.length-1]){ //最后一个模块时显示预览按钮
  317. this.showPreview=true;
  318. return;
  319. }
  320. const state = this.$store.state;
  321. const tabIndx = this.moduleKeys.findIndex((i)=>i==this.activeTab);
  322. this.activeTab=this.moduleKeys[+tabIndx+1]; //进入下一个阶段问题
  323. this.num = 0;
  324. moduleName = this.moduleMap[this.activeTab]+'QasList';
  325. const mDataName = this.moduleMap[this.activeTab];
  326. this[moduleName] = JSON.parse(JSON.stringify(state[mDataName].datas));
  327. let tmpArrDetail1 = JSON.parse(JSON.stringify(this[moduleName][0]));
  328. this[moduleName][0] = tmpArrDetail1;
  329. const tmpNowItem = this[moduleName][this.num];
  330. let timer = setTimeout(() => {
  331. this.type = tmpNowItem.controlType;
  332. tmpNowItem.show = true;
  333. //console.log(tmpNowItem)
  334. this.symptomResult = tmpNowItem;
  335. });
  336. this.$nextTick(()=>{
  337. this.scroll.refresh()
  338. this.scroll.scrollTo(0, this.scroll.maxScrollY,500)
  339. })
  340. return;
  341. }
  342. let tmpArrDetailResult = JSON.parse(JSON.stringify(this[moduleName][num]));
  343. let tmpArrDetail = JSON.parse(JSON.stringify(tmpArr[num]));
  344. let timer = setTimeout(() => {
  345. this.type = tmpArrDetail.controlType;
  346. tmpArrDetail.show = true;
  347. tmpArr[num] = tmpArrDetail;
  348. this.symptomResult = tmpArrDetailResult;
  349. clearTimeout(timer)
  350. }, this.time);
  351. this.$nextTick(()=>{
  352. this.scroll.refresh()
  353. this.scroll.scrollTo(0, this.scroll.maxScrollY,500)
  354. })
  355. },
  356. showWarn(text){
  357. this.waring=text;
  358. this.wrong=true;
  359. },
  360. closeTip(){
  361. this.wrong=false;
  362. /*const _this=this;
  363. const timer=setTimeout(()=>{
  364. _this.wrong=false;
  365. clearTimeout(timer)
  366. },4500);*/
  367. },
  368. cancelSymptom(){ //修改(即删除)已选主症
  369. this.symptomQasList = [];
  370. this.selectedSymptom=[];
  371. this.showUsual=true;
  372. this.type=-1;
  373. this.$store.commit('setChoose', { choose: [], type: moduleCP['symp'] });
  374. this.canceledSym = true;
  375. },
  376. selectUsual(sym){
  377. this.getSymptomQas(sym.questionId); //获取症状下的关联问题
  378. sym.idx=1; //标记主诉
  379. this.$store.commit('setChoose', { choose: [sym], type: moduleCP['symp'] });
  380. this.selectedSymptom = sym; //设置搜索选中症状
  381. this.showUsual=false; //关闭症状选择进入下一个问题
  382. this.pdbm = '11rem'
  383. setTimeout(() => {
  384. this.scrollDown()
  385. }, 0);
  386. },
  387. getSymptomQas(id){
  388. const param = {
  389. age:this.userInfo.patientAge,
  390. id:id,
  391. sexType:this.userInfo.sexType
  392. };
  393. api.getById(param).then((res) => {
  394. const result = res.data;
  395. if(result.code==='0'){
  396. const data = result.data;
  397. if(!data){
  398. return ;
  399. }
  400. let qaLis = data.questionMapping;
  401. if(qaLis.length===0){
  402. this.wrong = true;
  403. this.waring ='该症状数据未维护';
  404. return ;
  405. }
  406. //qaLis.length=2; //开发测试代码,要删除
  407. qaLis[0].show=true; //第一题自动显示
  408. this.type = qaLis[0].controlType;
  409. this.symptomResult = qaLis[0];
  410. this.$store.commit('setSymptomDatas',qaLis);
  411. this.symptomQasList = this.$store.state.symptom.origin;
  412. }else{
  413. }
  414. });
  415. },
  416. scrollDown(){
  417. this.scroll.scrollTo(0, this.scroll.maxScrollY)
  418. },
  419. },
  420. components:{
  421. Radio,
  422. Select,
  423. Dialog,
  424. Picker,
  425. Label,
  426. ComTextArea,
  427. /*Input,*/
  428. PickTime,
  429. UploadImg,
  430. PushSymptom,
  431. ConfirmBox,
  432. UsualSymptom,
  433. MultSelect,
  434. TipWarning,
  435. Head
  436. }
  437. }
  438. </script>
  439. <style lang="less" scoped>
  440. @import "../less/base.less";
  441. .wrapper {
  442. height: 100%;
  443. width: 100%;
  444. position: fixed;
  445. box-sizing: border-box;
  446. overflow: hidden;
  447. top: 0.86rem;
  448. }
  449. .scrollPart {
  450. // padding-bottom: 5rem;
  451. // padding-top: 1.44rem;
  452. // box-sizing: border-box;
  453. }
  454. .progress-bar {
  455. height: .8rem;
  456. line-height: 0.44rem;
  457. background: #fff;
  458. color: #aaa;
  459. /*margin-bottom:.4rem;*/
  460. .title{
  461. height: 100%;
  462. }
  463. span{
  464. display: inline-block;
  465. font-size: .26rem;
  466. color: #aaa;
  467. text-align: center;
  468. &:not(:last-child):after{
  469. content: ">";
  470. float: right;
  471. color: #aaa;
  472. }
  473. }
  474. .active{
  475. font-size: #font[dialog];
  476. color: #colors[theme];
  477. font-weight: 500;
  478. }
  479. .progress{
  480. height:0.06rem;
  481. background:#F5F5F5;
  482. p{
  483. width:.1px;
  484. height: 100%;
  485. background: #colors[theme];
  486. }
  487. }
  488. }
  489. .right {
  490. padding-top: .2rem;
  491. margin-bottom: .12rem;
  492. padding-right: .24rem;
  493. .content {
  494. max-width: 5rem;
  495. background-color: #colors[theme];
  496. border-radius: .24rem 0 .24rem .24rem;
  497. margin-top: .3rem;
  498. font-size: #font[dialog];
  499. padding: .24rem;
  500. display: inline-block;
  501. p {
  502. color: #fff;
  503. }
  504. }
  505. img {
  506. width: 0.8rem;
  507. height: 0.8rem;
  508. margin-left: .24rem;
  509. }
  510. }
  511. .left {
  512. margin-bottom: .2rem;
  513. padding-top: .12rem;
  514. padding-left: .24rem;
  515. .content {
  516. max-width: 5rem;
  517. background-color: #colors[bgques];
  518. border-radius: 0 .24rem .24rem .24rem;
  519. margin-top: .3rem;
  520. font-size: #font[dialog];
  521. padding: .24rem;
  522. display: inline-block;
  523. }
  524. img {
  525. width: 0.8rem;
  526. height: 0.8rem;
  527. margin-right: .24rem;
  528. }
  529. }
  530. .edit{
  531. color: #colors[theme];
  532. font-style: normal;
  533. font-size: #font[dialog];
  534. float: right;
  535. display: inline-block;
  536. margin-top: .56rem;
  537. margin-right: .24rem;
  538. }
  539. .submit{
  540. position: fixed;
  541. bottom: 0;
  542. width: 100%;
  543. a{
  544. display: inline-block;
  545. width: 100%;
  546. height: 0.88rem;
  547. font-size: #font[dialog];
  548. background-color: #colors[btn];
  549. line-height: 0.88rem;
  550. margin-top: 0.8rem;
  551. text-align: center;
  552. color: #fff;
  553. }
  554. }
  555. </style>