hPicker.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="hPicker posi-absolute" v-if="is_show">
  3. <hPopup ref="popup" :forbidden_event="true">
  4. <view class="con posi-fixed posi-fixed-bottom">
  5. <view class="act flew flew-between bgc-white">
  6. <view class="cancel color-gray" @tap="cancel">取消</view>
  7. <view class="title font-size28 color-gray" v-if="title">{{title}}</view>
  8. <view class="sure " @tap.stop="sure">确定</view>
  9. </view>
  10. <picker-view class="picker-view bgc-white " :value="value" @change="change" indicator-style="height:68upx">
  11. <picker-view-column class="picker-view-item" v-for="(item,index) in list" :key="index">
  12. <view class="item" v-for="(it,ind) in item" :key="ind">
  13. {{range_key ? it[range_key] : it }}{{suffixes[index]||''}}
  14. </view>
  15. </picker-view-column>
  16. </picker-view>
  17. </view>
  18. </hPopup>
  19. </view>
  20. </template>
  21. <script>
  22. import hPopup from "../func/hPopup";
  23. export default {
  24. name: "hPicker",
  25. components: {hPopup},
  26. data() {
  27. return {
  28. is_show:false,
  29. _value:[],
  30. }
  31. },
  32. computed: {
  33. list() { //column 传参可是一个数组 也可是数组嵌套
  34. let column = this.column;
  35. let re = column;
  36. if (column.length === 1) {
  37. re = [column]
  38. }
  39. return re;
  40. }
  41. },
  42. props: {
  43. column: {
  44. default() {
  45. return []
  46. }
  47. },
  48. suffixes: {
  49. default() {
  50. return []
  51. }
  52. },
  53. range_key: {
  54. default: ''
  55. },
  56. value: {
  57. default() {
  58. return []
  59. }
  60. },
  61. title: ''
  62. },
  63. methods: {
  64. hide() {
  65. this.is_show = false;
  66. },
  67. show() {
  68. this.is_show = true;
  69. },
  70. cancel() {
  71. this.hide();
  72. this.$emit('cancel', {})
  73. },
  74. change(e) {
  75. let _value = e.detail.value;
  76. this._value = _value;
  77. this.$emit('change', {_value})
  78. },
  79. sure() {
  80. this.$emit('sure', this._value)
  81. this.hide()
  82. }
  83. },
  84. mounted() {
  85. this._value = this.list.map(v=>{
  86. return 0
  87. })
  88. }
  89. }
  90. </script>
  91. <style scoped lang="scss">
  92. .act {
  93. height: 90upx;
  94. line-height: 90upx;
  95. padding: 0 30upx;
  96. }
  97. .picker-view {
  98. height: 500upx;
  99. background-color: #fff;
  100. }
  101. .picker-view-item{
  102. height: 500upx;
  103. }
  104. .sure {
  105. color: #2C7BE8;
  106. }
  107. .con{
  108. z-index: 9999;
  109. height: 590upx;
  110. width: 750upx;
  111. }
  112. .item {
  113. height: 68upx;
  114. line-height: 68upx;
  115. text-align: center;
  116. }
  117. </style>