DetailBox.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <portal to="notification-detail">
  3. <div class="detailBoxMask"></div>
  4. <div class="detailBox-wrap viewPrew">
  5. <div class="content detailBoxMain" ref="detailBox">
  6. <div class="tmpDom"></div>
  7. <div class="main">
  8. <Detail :datas="privateData"
  9. ref="detail"
  10. :data="data"
  11. @check="changeCheck($event)"
  12. @checkReq="changeFins($event)"/>
  13. </div>
  14. <!-- <div class="foot" @click="complete">完成</div> -->
  15. </div>
  16. <div class="head">
  17. <span class="icon" @click="close">
  18. <img src="../images/small-close.png">
  19. </span>
  20. <span class="name">{{(privateData.description ||privateData.name)+'详情'}}</span>
  21. <span @click="handleClear" :class="{'check':checkF}">清空</span>
  22. <i>{{tips}}</i>
  23. </div>
  24. </div>
  25. <!-- <div :class="['foot',{'noCheck':!checkF}]" @click="complete">完成</div> -->
  26. <div :class="['foot',{'noCheck':!reqFinish}]" @click="complete">完成</div>
  27. <Toast :message="clearTxt"
  28. :show="showToast"
  29. @comfirn="comfirnDel"
  30. @cancel="cancelDel"/>
  31. </portal>
  32. </template>
  33. <script type="text/javascript">
  34. import Detail from './Detail.vue';
  35. import Toast from '../common/Toast.vue';
  36. import {fixedKeyboard,setScroll,moduleCP} from '@utils/tools.js';
  37. import BScroll from 'better-scroll';
  38. import $ from 'jquery';
  39. export default {
  40. name:'DetailBox', //点开详情的盒子
  41. data(){
  42. const {detailInfo,detailShow} = this.$store.state;
  43. return{
  44. msg:"胸痛详情",
  45. data:detailInfo,
  46. privateData:detailInfo.detail||{},
  47. compFlag:false,
  48. clearTxt:"是否清空当前已选内容?",
  49. showToast:false,
  50. tips:"(请完成病情预问诊可让医生提前了解病情)",
  51. checkF:false, //详情页有无已选项标识
  52. show:detailShow,
  53. reqFinish:false
  54. }
  55. },
  56. mounted(){
  57. this.$nextTick(()=>{
  58. // 校验是否有已填项,有--弹窗;无--return
  59. let hasCheck = this.$refs.detail.check();
  60. let checkReq = this.$refs.detail.checkReq();
  61. if(hasCheck){
  62. this.checkF = true;
  63. }
  64. if(checkReq){
  65. this.reqFinish = true;
  66. }
  67. setTimeout(() => {
  68. let scroll = setScroll(BScroll,true,'.viewPrew')
  69. this.scroll = scroll
  70. scroll.on('scroll', this.onScroll)
  71. }, 400);
  72. })
  73. },
  74. methods:{
  75. onScroll() {
  76. document.activeElement.scrollIntoViewIfNeeded(true);
  77. },
  78. close(){
  79. // 有必填项但没值则将choose移除 8-19
  80. const type = this.data.moduleType;
  81. if(type == moduleCP['symp']){//只处理主诉症状
  82. const list = this.privateData.questionMapping;
  83. if(list){
  84. for(let i in list){
  85. if(list[i].required==1 && !list[i].value){
  86. this.$store.commit('delChoose', {id: this.privateData.id })
  87. this.$store.commit('delText', { type: moduleCP['symp'], pId: this.privateData.id })
  88. }
  89. }
  90. }
  91. }
  92. this.$store.commit('setDetail',{detail:{}})
  93. },
  94. complete(){
  95. //有选中内容才可以点完成#1919
  96. // if(this.checkF){
  97. //必填项都填完了才可以点完成
  98. if(this.reqFinish){
  99. this.$refs.detail.saveData();
  100. this.$store.commit('setSearchShow', false);
  101. }
  102. },
  103. changeCheck(flag){//是否有选中项
  104. this.checkF = flag;
  105. },
  106. changeFins(flag){//必填项是否都填了
  107. this.reqFinish = flag;
  108. },
  109. handleClear(){//清空
  110. // 校验是否有已填项,有--弹窗;无--return
  111. if(this.checkF){
  112. this.showToast = true;
  113. }
  114. },
  115. cancelDel(){
  116. this.showToast = false;
  117. },
  118. comfirnDel(){
  119. this.$refs.detail.clearData();
  120. this.showToast = false;
  121. this.checkF = false;
  122. this.reqFinish = false;
  123. // 让detail组件更新
  124. const type = this.data.moduleType;
  125. if(type == moduleCP['symp']){ //症状情况单独处理
  126. const id = this.privateData.id;
  127. const read = this.$store.state.symptom.datas;
  128. const data = read[id];
  129. this.$store.commit('setDetail',{detail:data,ppId:null,moduleType:moduleCP['symp']})
  130. }
  131. }
  132. },
  133. components:{
  134. Detail,
  135. Toast
  136. },
  137. computed: {
  138. getStoreItem () {
  139. return this.$store.state.detailInfo
  140. }
  141. },
  142. watch: {
  143. getStoreItem:{
  144. handler(newVal){
  145. this.data = newVal;
  146. this.privateData = newVal.detail||{};
  147. },
  148. deep:true
  149. }
  150. },
  151. }
  152. </script>
  153. <style lang="less" scoped>
  154. @import '../less/base.less';
  155. .detailBoxMask {
  156. .mask;
  157. z-index: 110;
  158. }
  159. .tmpDom {
  160. height: 1rem;
  161. }
  162. .detailBox-wrap{
  163. width: 100%;
  164. // overflow-y: auto;
  165. position: fixed;
  166. // bottom: 0; //iPhone6plus键盘收起会跳转
  167. top:45px;
  168. bottom: 0;
  169. left: 0;
  170. z-index: 666;
  171. background: #fff;
  172. border-radius: .08rem .08rem 0 0;
  173. font-size: .3rem;
  174. animation: wave .4s linear;
  175. height: 100%;
  176. overflow: hidden;
  177. .head{
  178. height: 1rem; //增加了提示
  179. line-height: .88rem;
  180. display: flex; //有清空时
  181. justify-content: space-between;
  182. border-bottom: 1px solid #E6E7EF;
  183. padding: 0 .4rem 0 .32rem;
  184. font-size: .28rem;
  185. color: #7C828E;
  186. position: fixed;
  187. width: 100%;
  188. background-color: #fff;
  189. top: 45px;
  190. box-sizing: border-box;
  191. i{
  192. position: absolute;
  193. top:0.64rem;
  194. left:0;
  195. font-size: .22rem;
  196. width:100%;
  197. height: .33rem;
  198. line-height: .33rem;
  199. display: inline-block;
  200. text-align: center;
  201. }
  202. .icon{
  203. display: inline-block;
  204. height: 100%;
  205. padding: 0 .1rem;
  206. img{
  207. width:.34rem;
  208. vertical-align: middle;
  209. }
  210. }
  211. .name{
  212. font-size: .32rem;
  213. color: #1A1A1A;
  214. }
  215. }
  216. .main{
  217. height: 100%;
  218. width:100%;
  219. padding-bottom: 1rem;
  220. }
  221. }
  222. .foot{
  223. .footer;
  224. animation-delay:.6s;
  225. animation: foo .4s linear;
  226. /* width:100%;
  227. height: .88rem;
  228. line-height: .88rem;
  229. text-align: center;
  230. color:#fff;
  231. font-size: .32rem;
  232. background: linear-gradient(-270deg, #4F4FFF,#4F8BFF); */
  233. }
  234. .check{
  235. color: #1A1A1A;
  236. }
  237. .noCheck{
  238. background: #CACCFF !important;
  239. }
  240. @keyframes wave {
  241. 0% {top:100% ;}
  242. 25% {top: 75%;}
  243. 50% {top: 50%;}
  244. 75% {top: 25%;}
  245. 100% {top: 45px;}
  246. }
  247. @keyframes foo {
  248. 0% {bottom:-1rem;}
  249. 100% {bottom:0;}
  250. }
  251. </style>