PickTime.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!-- 时间类型控件 -->
  2. <template>
  3. <div class="toast-wrap">
  4. <p v-show="val" :class="['ptab',{'check':val != '请选择'}]" @click="showPicker">{{val}}</p>
  5. <p v-show="val != '请选择'" class="tip">点击可修改</p>
  6. <Picker :show="showTime" @comfirn="getTimeVal" @cancel="close"/>
  7. </div>
  8. </template>
  9. <script type="text/javascript">
  10. import $ from 'jquery';
  11. import Picker from './Picker.vue';
  12. export default {
  13. name:'PickTime',
  14. data() {
  15. return {
  16. val:this.item.value || '请选择',
  17. showTime:false
  18. }
  19. },
  20. props:['item'],
  21. methods: {
  22. showPicker(){
  23. this.showTime = true;
  24. $(".btscroll").css({'position':'fixed'})
  25. $(".foot").css({'position':'fixed'})
  26. },
  27. getTimeVal(value){//确定
  28. if(value.charAt(0) == 0){
  29. this.val = value.substr(1);
  30. }else{
  31. this.val = value;
  32. }
  33. this.showTime = false;
  34. const newData = Object.assign({},this.item,{value:this.val,valueP:this.val});
  35. this.$emit("updata",newData);
  36. $(".btscroll").css({'position':'absolute'})
  37. },
  38. close(){//点击蒙层关闭
  39. this.showTime = false;
  40. $(".btscroll").css({'position':'absolute'})
  41. }
  42. },
  43. components:{
  44. Picker
  45. }
  46. };
  47. </script>
  48. <style lang="less" scoped>
  49. @import '../less/base.less';
  50. .toast-wrap{
  51. margin-bottom: .2rem;
  52. position: relative;
  53. z-index: 116;
  54. .ptab{
  55. width:100%;
  56. height: .8rem;
  57. line-height: .8rem;
  58. text-align: center;
  59. border:1px solid #E6E6E6;
  60. border-radius: .1rem;
  61. color:#7C828E;
  62. }
  63. .check{
  64. color: #colors[theme] !important;
  65. }
  66. .tip{
  67. color: #7C828E;
  68. }
  69. }
  70. </style>