123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <template>
- <view class="hPicker posi-absolute" v-if="is_show">
- <hPopup ref="popup" :forbidden_event="true">
- <view class="con posi-fixed posi-fixed-bottom">
- <view class="act flew flew-between bgc-white">
- <view class="cancel color-gray" @tap="cancel">取消</view>
- <view class="title font-size28 color-gray" v-if="title">{{title}}</view>
- <view class="sure " @tap.stop="sure">确定</view>
- </view>
- <picker-view class="picker-view bgc-white " :value="value" @change="change" indicator-style="height:68upx">
- <picker-view-column class="picker-view-item" v-for="(item,index) in list" :key="index">
- <view class="item" v-for="(it,ind) in item" :key="ind">
- {{range_key ? it[range_key] : it }}{{suffixes[index]||''}}
- </view>
- </picker-view-column>
- </picker-view>
- </view>
- </hPopup>
- </view>
- </template>
- <script>
- import hPopup from "../func/hPopup";
- export default {
- name: "hPicker",
- components: {hPopup},
- data() {
- return {
- is_show:false,
- _value:[],
- }
- },
- computed: {
- list() { //column 传参可是一个数组 也可是数组嵌套
- let column = this.column;
- let re = column;
- if (column.length === 1) {
- re = [column]
- }
- return re;
- }
- },
- props: {
- column: {
- default() {
- return []
- }
- },
- suffixes: {
- default() {
- return []
- }
- },
- range_key: {
- default: ''
- },
- value: {
- default() {
- return []
- }
- },
- title: ''
- },
- methods: {
- hide() {
- this.is_show = false;
- },
- show() {
- this.is_show = true;
- },
- cancel() {
- this.hide();
- this.$emit('cancel', {})
- },
- change(e) {
- let _value = e.detail.value;
- this._value = _value;
- this.$emit('change', {_value})
- },
- sure() {
- this.$emit('sure', this._value)
- this.hide()
- }
- },
- mounted() {
- this._value = this.list.map(v=>{
- return 0
- })
- }
- }
- </script>
- <style scoped lang="scss">
- .act {
- height: 90upx;
- line-height: 90upx;
- padding: 0 30upx;
- }
- .picker-view {
- height: 500upx;
- background-color: #fff;
- }
- .picker-view-item{
- height: 500upx;
- }
- .sure {
- color: #2C7BE8;
- }
- .con{
- z-index: 9999;
- height: 590upx;
- width: 750upx;
- }
- .item {
- height: 68upx;
- line-height: 68upx;
- text-align: center;
- }
- </style>
|