Picker.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <portal to="notification-outlet">
  3. <div class="pickerBox" @touchmove.prevent>
  4. <div class="picker">
  5. <van-picker :columns="columnsp"
  6. :visible-item-count = "5"
  7. :swipe-duration = "time"
  8. :item-height ="36"
  9. @change="changeTemp" />
  10. <!-- <div class="selected">
  11. </div> -->
  12. </div>
  13. <div class="realSure sure" @click="onConfirm">
  14. 确定
  15. </div>
  16. </div>
  17. </portal>
  18. </template>
  19. <script>
  20. export default {
  21. name:"Picker",
  22. props: {
  23. symptomResult:{default:function() {
  24. return {}
  25. }},
  26. defaultIndex:{default:0},
  27. num:{default:0},
  28. defaultVal:{default:""},
  29. columns:{
  30. default:function() {
  31. return ['37.0°C', '37.1°C', '37.2°C','37.3°C', '37.4°C', '37.5°C', '37.6°C', '37.7°C', '37.8°C', '37.9°C', '38.0°C',
  32. '38.1°C', '38.2°C', '38.3°C', '38.4°C', '38.5°C', '38.6C', '38.7°C', '38.8°C', '38.9°C',
  33. '39.0°C', '39.1°C', '39.2°C', '39.3°C', '39.4°C', '39.5°C', '39.6°C', '39.7°C', '39.8°C',
  34. '39.9°C', '40.0°C', '40.1°C', '40.2°C', '40.3°C', '40.4°C', '40.5°C', '40.6°C', '40.7°C',
  35. '40.8°C', '40.9°C', '41.0°C', '41.1°C', '41.2°C', '41.3°C', '41.4°C', '41.5°C', '41.6°C',
  36. '41.7°C', '41.8°C', '41.9°C', '42.0°C'];
  37. }
  38. },
  39. columnsp:{
  40. default:function() {
  41. return ['37.0°C', '37.1°C', '37.2°C','37.3°C', '37.4°C', '37.5°C', '37.6°C', '37.7°C', '37.8°C', '37.9°C', '38.0°C',
  42. '38.1°C', '38.2°C', '38.3°C', '38.4°C', '38.5°C', '38.6C', '38.7°C', '38.8°C', '38.9°C',
  43. '39.0°C', '39.1°C', '39.2°C', '39.3°C', '39.4°C', '39.5°C', '39.6°C', '39.7°C', '39.8°C',
  44. '39.9°C', '40.0°C', '40.1°C', '40.2°C', '40.3°C', '40.4°C', '40.5°C', '40.6°C', '40.7°C',
  45. '40.8°C', '40.9°C', '41.0°C', '41.1°C', '41.2°C', '41.3°C', '41.4°C', '41.5°C', '41.6°C',
  46. '41.7°C', '41.8°C', '41.9°C', '42.0°C'];
  47. }
  48. }
  49. },
  50. data() {
  51. return {
  52. time: 100,
  53. selectIndex: 0,
  54. selectValue: '',
  55. selectValuep: '',
  56. }
  57. },
  58. mounted(){
  59. this.selectValue=this.defaultVal||this.columns[0];
  60. this.selectValuep=this.defaultVal||this.columnsp[0];
  61. },
  62. methods: {
  63. changeTemp(picker, value, index) {
  64. this.selectIndex = index;
  65. this.selectValuep = typeof(value)==="string"?value:value.join("");
  66. this.selectValue = typeof(value)==="string"?this.columns[index]:value.join("");
  67. },
  68. onConfirm() {
  69. let number = this.num;
  70. const value = this.selectValue;
  71. const valuep = this.selectValuep;
  72. if(+this.symptomResult.flag===1){ //为时间控件
  73. const orgChoose = this.$store.state.symptom.choose;
  74. orgChoose[0].special = value;
  75. orgChoose[0].specialP = valuep;
  76. this.$store.commit('setChoose', { choose: orgChoose, type: 1 });
  77. }
  78. this.$emit('confirm','', {val:value,valp:valuep,flag:this.symptomResult.flag}, ++number)
  79. },
  80. }
  81. }
  82. </script>
  83. <style lang="less" scoped>
  84. @import "../less/base.less";
  85. .pickerBox{
  86. position: fixed;
  87. width: 100%;
  88. height: 5.3rem;
  89. border-radius: 10px 10px 0 0;
  90. background: #fff;
  91. overflow-y: hidden;
  92. z-index: 99;
  93. bottom: 0;
  94. left: 0;
  95. box-shadow: 0 0 30px -10px rgba(104, 124, 189, 0.25);
  96. padding-top: 0.28rem;
  97. }
  98. .picker {
  99. position: relative;
  100. height: 180px;
  101. }
  102. /deep/.van-picker {
  103. position: relative;
  104. overflow-y: hidden;
  105. }
  106. .conBtn{
  107. height: 44px;
  108. line-height: 44px;
  109. background: #5B99EB;
  110. color: #fff;
  111. font-size: 16px;
  112. text-align: center;
  113. position: absolute;
  114. bottom: 0rem;
  115. width: 100%;
  116. }
  117. .selected {
  118. position: absolute;
  119. width: 100%;
  120. height: 36px;
  121. background: #5B99EB;
  122. top: 0;
  123. opacity: .1;
  124. }
  125. .confirm{
  126. color: #fff;
  127. }
  128. .sure{
  129. position: absolute;
  130. bottom: 0;
  131. }
  132. /deep/.van-picker-column__item {
  133. text-align: center;
  134. font-size: 14px;
  135. /*background: #F3F4F6;*/
  136. }
  137. /deep/.van-picker-column__item--selected{
  138. /*background: #F3F4F6;*/
  139. font-size: .3rem;
  140. color: #colors[theme];
  141. }
  142. /deep/van-picker__columns {
  143. position: relative;
  144. display: -webkit-box;
  145. display: -webkit-flex;
  146. display: flex;
  147. cursor: grab;
  148. }
  149. /deep/.van-picker__mask {
  150. position: absolute;
  151. top: 0;
  152. left: 0;
  153. z-index: 2;
  154. width: 100%;
  155. height: 100%;
  156. background-image: -webkit-linear-gradient(top, hsla(0, 0%, 100%, 0.9), hsla(0, 0%, 100%, 0.4)), -webkit-linear-gradient(bottom, hsla(0, 0%, 100%, 0.9), hsla(0, 0%, 100%, 0.4));
  157. background-image: linear-gradient(180deg, hsla(0, 0%, 100%, 0.9), hsla(0, 0%, 100%, 0.4)), linear-gradient(0deg, hsla(0, 0%, 100%, 0.9), hsla(0, 0%, 100%, 0.4));
  158. background-repeat: no-repeat;
  159. background-position: top, bottom;
  160. -webkit-backface-visibility: hidden;
  161. backface-visibility: hidden;
  162. pointer-events: none;
  163. }
  164. /deep/.van-picker__frame{
  165. position: absolute;
  166. top: 50%;
  167. left: 0;
  168. z-index: 3;
  169. width: 100%;
  170. -webkit-transform: translateY(-50%);
  171. transform: translateY(-50%);
  172. pointer-events: none;
  173. }
  174. /deep/[class*='van-hairline']::after {
  175. position: absolute;
  176. background: #5B99EB;
  177. opacity: .1;
  178. box-sizing: border-box;
  179. content: ' ';
  180. pointer-events: none;
  181. top: -50%;
  182. right: -50%;
  183. bottom: -50%;
  184. left: -50%;
  185. border: 0 solid #ebedf0;
  186. -webkit-transform: scale(0.5);
  187. transform: scale(0.5);
  188. }
  189. </style>