DetailBox.vue 7.6 KB

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