DetailBox.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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 style="position:absolute" :class="['foot',{'noCheck':!checkF || !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 && hasCheck){
  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(data) {
  76. this.$store.commit('setScroll', data)
  77. document.activeElement.scrollIntoViewIfNeeded(true);
  78. },
  79. close(){
  80. // 有必填项但没值则将choose移除 8-19
  81. // 没点过完成,点关闭时校验是否有必填项--有直接移除
  82. const type = this.data.moduleType;
  83. const select = this.privateData.select;
  84. $(".foot").css({'display':'block'})
  85. if(type == moduleCP['symp'] && !select){//只处理主诉症状
  86. const list = this.privateData.questionMapping;
  87. if(list){
  88. for(let i in list){
  89. // if(list[i].required==1 && !list[i].value){
  90. if(list[i].required==1){
  91. this.$store.commit('delChoose', {id: this.privateData.id })
  92. this.$store.commit('delText', { type: moduleCP['symp'], pId: this.privateData.id })
  93. }
  94. }
  95. }
  96. }
  97. this.$store.commit('setDetail',{detail:{}})
  98. },
  99. complete(){
  100. //有选中内容才可以点完成#1919
  101. // if(this.checkF){
  102. //必填项都填完了才可以点完成
  103. if(this.reqFinish && this.checkF){
  104. this.$refs.detail.saveData();
  105. this.$store.commit('setSearchShow', false);
  106. }
  107. },
  108. changeCheck(flag){//是否有选中项
  109. this.checkF = flag;
  110. },
  111. changeFins(flag){//必填项是否都填了
  112. this.reqFinish = flag;
  113. },
  114. handleClear(){//清空
  115. // 校验是否有已填项,有--弹窗;无--return
  116. if(this.checkF){
  117. this.showToast = true;
  118. $(".btscroll").css({'position':'fixed'})
  119. $(".foot").css({'position':'fixed'})
  120. }
  121. },
  122. cancelDel(){
  123. $(".btscroll").css({'position':'absolute'})
  124. this.showToast = false;
  125. },
  126. comfirnDel(){
  127. $(".btscroll").css({'position':'absolute'})
  128. this.$refs.detail.clearData();
  129. this.showToast = false;
  130. this.checkF = false;
  131. this.reqFinish = false;
  132. // 让detail组件更新
  133. const type = this.data.moduleType;
  134. if(type == moduleCP['symp']){ //症状情况单独处理
  135. const id = this.privateData.id;
  136. const read = this.$store.state.symptom.datas;
  137. const data = read[id];
  138. this.$store.commit('setDetail',{detail:data,ppId:null,moduleType:moduleCP['symp']})
  139. }
  140. }
  141. },
  142. components:{
  143. Detail,
  144. Toast
  145. },
  146. computed: {
  147. getStoreItem () {
  148. return this.$store.state.detailInfo
  149. }
  150. },
  151. watch: {
  152. getStoreItem:{
  153. handler(newVal){
  154. this.data = newVal;
  155. this.privateData = newVal.detail||{};
  156. },
  157. deep:true
  158. }
  159. },
  160. }
  161. </script>
  162. <style lang="less" scoped>
  163. @import '../less/base.less';
  164. .detailBoxMask {
  165. .mask;
  166. z-index: 110;
  167. }
  168. .tmpDom {
  169. height: 1rem;
  170. }
  171. .detailBox-wrap{
  172. width: 100%;
  173. // overflow-y: auto;
  174. position: absolute;
  175. // bottom: 0; //iPhone6plus键盘收起会跳转
  176. top:45px;
  177. bottom: 0;
  178. left: 0;
  179. z-index: 666;
  180. background: #fff;
  181. border-radius: .08rem .08rem 0 0;
  182. font-size: .3rem;
  183. animation: wave .4s linear;
  184. height: 100%;
  185. overflow: hidden;
  186. .head{
  187. height: 1rem; //增加了提示
  188. line-height: .88rem;
  189. display: flex; //有清空时
  190. justify-content: space-between;
  191. border-bottom: 1px solid #E6E7EF;
  192. padding: 0 .4rem 0 .32rem;
  193. font-size: .28rem;
  194. color: #7C828E;
  195. position: fixed;
  196. width: 100%;
  197. background-color: #fff;
  198. top: 45px;
  199. box-sizing: border-box;
  200. i{
  201. position: absolute;
  202. top:0.64rem;
  203. left:0;
  204. font-size: .22rem;
  205. width:100%;
  206. height: .33rem;
  207. line-height: .33rem;
  208. display: inline-block;
  209. text-align: center;
  210. }
  211. .icon{
  212. display: inline-block;
  213. height: 100%;
  214. padding: 0 .1rem;
  215. img{
  216. width:.34rem;
  217. vertical-align: middle;
  218. }
  219. }
  220. .name{
  221. font-size: .32rem;
  222. color: #1A1A1A;
  223. }
  224. }
  225. .main{
  226. height: 100%;
  227. width:100%;
  228. padding-bottom: 1rem;
  229. }
  230. }
  231. .foot{
  232. .footer;
  233. animation-delay:.6s;
  234. animation: foo .4s linear;
  235. /* width:100%;
  236. height: .88rem;
  237. line-height: .88rem;
  238. text-align: center;
  239. color:#fff;
  240. font-size: .32rem;
  241. background: linear-gradient(-270deg, #4F4FFF,#4F8BFF); */
  242. }
  243. .check{
  244. color: #1A1A1A;
  245. }
  246. .noCheck{
  247. background: #CACCFF !important;
  248. }
  249. @keyframes wave {
  250. 0% {top:100% ;}
  251. 25% {top: 75%;}
  252. 50% {top: 50%;}
  253. 75% {top: 25%;}
  254. 100% {top: 45px;}
  255. }
  256. @keyframes foo {
  257. 0% {bottom:-1rem;}
  258. 100% {bottom:0;}
  259. }
  260. </style>