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. // 首位为0则去掉
  29. if(value.charAt(0) == 0){
  30. this.val = value.substr(1);
  31. }else{
  32. this.val = value;
  33. }
  34. this.showTime = false;
  35. const newData = Object.assign({},this.item,{value:this.val,valueP:this.val});
  36. this.$emit("updata",newData);
  37. $(".btscroll").css({'position':'absolute'})
  38. },
  39. close(){//点击蒙层关闭
  40. this.showTime = false;
  41. $(".btscroll").css({'position':'absolute'})
  42. }
  43. },
  44. components:{
  45. Picker
  46. }
  47. };
  48. </script>
  49. <style lang="less" scoped>
  50. @import '../less/base.less';
  51. .toast-wrap{
  52. margin-bottom: .2rem;
  53. position: relative;
  54. z-index: 116;
  55. .ptab{
  56. width:100%;
  57. height: .8rem;
  58. line-height: .8rem;
  59. text-align: center;
  60. border:1px solid #E6E6E6;
  61. border-radius: .1rem;
  62. color:#7C828E;
  63. }
  64. .check{
  65. color: #colors[theme] !important;
  66. }
  67. .tip{
  68. color: #7C828E;
  69. }
  70. }
  71. </style>