IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> JavaScript知识库 -> data-picker -> 正文阅读

[JavaScript知识库]data-picker

<template>
	<view class="list">
		<view class="grey-block"></view>

		<view class="list-item">

			<view class="item-content" @tap="handleTap('picker5')">
				<text class="item-title">绑定值:{{ JSON.stringify(value5) }}</text>
				<view class="item-value">
					<text class="item-placeholder">点我打开选择器</text>
				</view>
			</view>
			<lb-picker ref="picker5" v-model="value5" mode="unlinkedSelector" :list="list2" @change="handleChange"
				@confirm="handleConfirm" >
				<view slot="action-center">年龄</view>


			</lb-picker>
		</view>
		<view class="grey-block"></view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				list_unlimit:['不限'],
				min_age : 18,
				max_age: 30, 


				value5: ['18', '20'],




				list2: [
					[],
					[]
				],
				list3: []
			}
		},
		onReady() {
			this.$nextTick(() => {
				// 此处可以调用getColumnsInfo方法获取默认值的选项信息
				const info = this.$refs.picker3.getColumnsInfo(this.value3)
				console.log('根据value获取的信息:', info)
				this.label3 = info.item.map(m => m.label).join('-')
			})
			
			// this.list2[0] = genXList(this.min_age)
		},
		onLoad() {
			// var x  = 
			this.list2[0] = this.genXList(this.min_age)
		}
		,
		methods: {

			genComList(start, end) {

				return Array.from({
					length: end - start
				}, (_, i) => (i + start).toString())
			},
			
			genXList (start) {
				return this.list_unlimit.concat(this.genComList(start,this.max_age))
			},



		 
			handleTap(picker) {
				this.$refs[picker].show()
			},
			handleChange(item) {
				console.log('change::', JSON.stringify(item))
				if (item.value[0] == '不限'){
					this.list2[1] = this.genXList( parseInt(this.min_age))
				}else {
						this.list2[1] = this.genXList( parseInt(item.value[0]))
				}
			
			 
			
			},

		 
			handleConfirm(e) {
				// 如果存在多个picker,可以在picker上设置dataset属性,confirm中获取,就能区分是哪个picker了
				console.log('confirm::', e)
			 
				
				console.log("comfir " + e.value[0] + e.value[1])
			},
			 
		}
	}
</script>

<style lang="scss" scoped>
	@import "../../index/index.scss";
</style>

<template>
  <view :class="['lb-picker', inline ? 'lb-picker-inline' : '']">

    <!-- 默认插槽 -->
    <view v-if="!inline"
      class="lb-picker-default-slot"
      @tap="show">
      <slot></slot>
    </view>

    <!-- 遮罩层 -->
    <view v-if="visible && showMask && !inline"
      :class="['lb-picker-mask', animation ? 'lb-picker-mask-animation' : '']"
      :style="{
        backgroundColor: maskBgColor,
        zIndex: zIndex - 1
      }"
      @tap.stop="handleMaskTap"
      @touchmove.stop.prevent="moveHandle">
    </view>

    <view v-if="visible || inline"
      ref="container"
      :class="[
        'lb-picker-container',
        !inline ? 'lb-picker-container-fixed' : '',
        animation ? 'lb-picker-container-animation' : '',
        containerVisible ? 'lb-picker-container-show' : ''
      ]"
      :style="{
        borderRadius: `${radius} ${radius} 0 0`,
        zIndex: zIndex
      }">
      <view v-if="showHeader"
        class="lb-picker-header">

        <!-- 头部顶部插槽 -->
        <slot name="header-top"></slot>

        <view class="lb-picker-header-actions">
          <!-- 取消 -->
          <view class="lb-picker-action lb-picker-action-cancel"
            @tap.stop="handleCancel">
            
          </view>

          <!-- 中间 -->
          <view class="lb-picker-action lb-picker-center"
            v-if="$slots['action-center']">
            <slot name="action-center"></slot>
          </view>

          <!-- 确定 -->
          <view class="lb-picker-action lb-picker-action-confirm"
            @tap.stop="handleConfirm">
          
          </view>
        </view>

        <!-- 头部底部插槽 -->
        <slot name="header-bottom"></slot>
      </view>

      <view :class="[
        'lb-picker-content',
        safeAreaInsetBottom ? 'lb-picker-content-safe-buttom' : ''
      ]">

        <!-- 选择器顶部插槽 -->
        <slot name="picker-top"></slot>

        <view class="lb-picker-content-main"
          :style="{ height: pickerContentHeight }">
          <!-- loading -->
          <view v-if="loading"
            class="lb-picker-loading">
            <slot name="loading">
              <image class="lb-picker-loading-img"
                src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAPFklEQVR4Xu2dTXbUOBeGpToHF7OGFTSsAFhBJytoWAFkUnKNoFdAWEGHUVmZJKygwwpIVkB6BYQVdDIj4Ry5zw3210W++pFtSb6S3pqWpHv9Xj2WZMtXUuAHBaDAWgUktIECUGC9AgAEvQMKbFAAgKB7QAEAgj4ABfopgBGkn26olYkCACSTQOMy+ykAQPrphlqZKABARg700dHRg+vr69+klE/run5E7kgpL+q6Pp9Op2d7e3uXI7uYtXkAMmL4tdZvhRBvhBAP1rhBcBwopd6N6GbWpgHICOGnUePm5uaTEOKppfnzoih2MZpYquWwGABxKKZtU1VVfZJS7tiWp3J1XZ+WZbnbpQ7KDlcAgAzXsFMLi8Xi1WQyOepUqSlsjNmbz+fHfeqiTj8FAEg/3XrX0lp/7jC1umvnXCn1rLdxVOysAADpLFn/Cs3a45/+LQhRFMVDrEWGKNitLgDppteg0ovFYmcymdDivPfPGLM7n89PezeAip0UACCd5BpWGIAM02+M2gAkoOoAJKDYjkwBEEdC2jQDQGxU4lUGgASMBwAJKLYjUwDEkZA2zQAQG5V4lQEgAeMBQAKK7cgUAHEkpE0zAMRGJV5lAEjAeACQgGI7MgVAHAlp0wwAsVGJVxkAEjAeACSg2I5MARBHQto0A0BsVOJVBoAEjAcACSi2I1MAxJGQNs0AEBuVeJUBIAHjAUACiu3IFABxJKRNMwDERiVeZQBIwHgAkIBiOzIFQBwJadMMALFRiVcZloA0ydReSilfLX+/Xdf1hZTyuCiK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AcI7o2rwL9NuZ5QQgPItwAAAABJRU5ErkJggg==">
              </image>
            </slot>
          </view>

          <!-- 暂无数据 -->
          <view v-if="isEmpty && !loading && mode !== 'dateSelector'"
            class="lb-picker-empty">
            <slot name="empty">
              <text class="lb-picker-empty-text"
                :style="{ color: emptyColor }">{{ emptyText }}</text>
            </slot>
          </view>

          <!-- 单选 -->
          <selector-picker v-if="mode === 'selector' && !loading && !isEmpty"
            :ref="mode"
            :value="value"
            :list="list"
            :mode="mode"
            :props="pickerProps"
            :height="pickerContentHeight"
            :inline="inline"
            :column-style="columnStyle"
            :active-column-style="activeColumnStyle"
            :align="align"
            :press-enable="pressEnable"
            :press-time="pressTime"
            :formatter="formatter"
            @change="handleChange">
          </selector-picker>

          <!-- 多列联动 -->
          <multi-selector-picker v-if="mode === 'multiSelector' && !loading && !isEmpty"
            :ref="mode"
            :value="value"
            :list="list"
            :mode="mode"
            :level="level"
            :visible="visible"
            :props="pickerProps"
            :height="pickerContentHeight"
            :inline="inline"
            :column-style="columnStyle"
            :active-column-style="activeColumnStyle"
            :align="align"
            :press-enable="pressEnable"
            :press-time="pressTime"
            :formatter="formatter"
            @change="handleChange">
          </multi-selector-picker>

          <!-- 非联动选择 -->
          <unlinked-selector-picker v-if="mode === 'unlinkedSelector' && !loading && !isEmpty"
            :ref="mode"
            :value="value"
            :list="list"
            :mode="mode"
            :visible="visible"
            :props="pickerProps"
            :height="pickerContentHeight"
            :inline="inline"
            :column-style="columnStyle"
            :active-column-style="activeColumnStyle"
            :align="align"
            :press-enable="pressEnable"
            :press-time="pressTime"
            :formatter="formatter"
            @change="handleChange">
          </unlinked-selector-picker>

          <!-- 日期选择 -->
          <date-selector-picker v-if="mode === 'dateSelector' && !loading"
            :ref="mode"
            :value="value"
            :mode="mode"
            :visible="visible"
            :height="pickerContentHeight"
            :inline="inline"
            :column-style="columnStyle"
            :active-column-style="activeColumnStyle"
            :align="align"
            :formatter="formatter"
            :format="format"
            :display-format="displayFormat"
            :start-date="startDate"
            :end-date="endDate"
            :default-time-limit="defaultTimeLimit"
            :is-show-chinese="isShowChinese"
            :ch-config="pickerChConfig"
            :filter="filter"
            @change="handleChange">
          </date-selector-picker>
        </view>
		
		
		<view v-if="showHeader"
		  class="lb-picker-header">
		
		  <!-- 头部顶部插槽 -->
		  <slot name="header-top"></slot>
		
		  <view class="lb-picker-header-actions">
		    <!-- 取消 -->
		    <view class="lb-picker-action lb-picker-action-cancel"
		      @tap.stop="handleCancel">
		      <slot v-if="$slots['cancel-text']"
		        name="cancel-text">
		      </slot>
		      <text v-else
		        class="lb-picker-action-cancel-text"
		        :style="{ color: cancelColor }">{{ cancelText }}</text>
		    </view>
		
		    <!-- 中间 -->
		    
		
		    <!-- 确定 -->
		    <view class="lb-picker-action lb-picker-action-confirm"
		      @tap.stop="handleConfirm">
		      <slot v-if="$slots['confirm-text']"
		        name="confirm-text"> </slot>
		      <text v-else
		        class="lb-picker-action-confirm-text"
		        :style="{ color: confirmColor }">{{ confirmText }}</text>
		    </view>
		  </view>
		
		  <!-- 头部底部插槽 -->
		  <slot name="header-bottom"></slot>
		</view>

        <!-- 选择器底部插槽 -->
        <slot name="picker-bottom"></slot>
      </view>
    </view>
  </view>
</template>

<script>
const defaultMaskBgColor = 'rgba(0, 0, 0, 0)'
const defaultProps = {
  label: 'label',
  value: 'value',
  children: 'children'
}
const defaultChConfig = {
  year: '年',
  month: '月',
  day: '日',
  hour: '时',
  minute: '分',
  second: '秒'
}
// #ifdef APP-NVUE
const animation = weex.requireModule('animation')
// #endif
import { getColumns } from './utils'
import SelectorPicker from './pickers/selector-picker'
import MultiSelectorPicker from './pickers/multi-selector-picker'
import UnlinkedSelectorPicker from './pickers/unlinked-selector-picker'
import DateSelectorPicker from './pickers/date-selector-picker'
export default {
  components: {
    SelectorPicker,
    MultiSelectorPicker,
    UnlinkedSelectorPicker,
    DateSelectorPicker
  },
  props: {
    value: [String, Number, Array],
    list: Array,
    mode: {
      type: String,
      default: 'selector'
    },
    level: {
      type: Number,
      default: 1
    },
    props: {
      type: Object
    },
    cancelText: {
      type: String,
      default: '取消'
    },
    cancelColor: {
      type: String,
      default: '#999'
    },
    confirmText: {
      type: String,
      default: '确定'
    },
    confirmColor: {
      type: String,
      default: '#007aff'
    },
    canHide: {
      type: Boolean,
      default: true
    },
    emptyColor: {
      type: String,
      default: '#999'
    },
    emptyText: {
      type: String,
      default: '暂无数据'
    },
    radius: String,
    columnNum: {
      type: Number,
      default: 5
    },
    loading: Boolean,
    closeOnClickMask: {
      type: Boolean,
      default: true
    },
    showMask: {
      type: Boolean,
      default: true
    },
    maskColor: {
      type: String,
      default: 'rgba(0, 0, 0, 0.4)'
    },
    dataset: Object,
    inline: Boolean,
    showHeader: {
      type: Boolean,
      default: true
    },
    animation: {
      type: Boolean,
      default: true
    },
    zIndex: {
      type: Number,
      default: 999
    },
    safeAreaInsetBottom: {
      type: Boolean,
      default: true
    },
    disabled: Boolean,
    columnStyle: Object,
    activeColumnStyle: Object,
    align: {
      type: String,
      default: 'center'
    },
    pressEnable: Boolean,
    pressTime: {
      type: Number,
      default: 500
    },
    formatter: Function,
    format: {
      type: String,
      default: 'YYYY-MM-DD'
    },
    displayFormat: {
      type: String,
      default: 'YYYY-MM-DD'
    },
    startDate: String,
    endDate: String,
    defaultTimeLimit: {
      type: Number,
      default: 20
    },
    isShowChinese: {
      type: Boolean,
      default: true
    },
    chConfig: Object,
    filter: Function
  },
  data () {
    return {
      visible: false,
      containerVisible: false,
      maskBgColor: defaultMaskBgColor,
      myValue: this.value,
      picker: {},
      pickerProps: Object.assign({}, defaultProps, this.props),
      pickerChConfig: Object.assign({}, defaultChConfig, this.chConfig)
    }
  },
  computed: {
    pickerContentHeight () {
      return 34 * this.columnNum + 'px'
    },
    isEmpty () {
      if (this.mode === 'dateSelector') return false
      if (!this.list && this.mode !== 'dateSelector') return true
      if (this.list && !this.list.length) return true
      return false
    }
  },
  methods: {
    show () {
      if (this.inline || this.disabled) return
      this.visible = true
      setTimeout(() => {
        this.maskBgColor = this.maskColor
				// #ifndef APP-NVUE
				this.containerVisible = true
				// #endif
        // #ifdef APP-NVUE
        this.wxAnimation(0)
        // #endif
      }, 20)
    },
    hide () {
      if (this.inline) return
      this.maskBgColor = defaultMaskBgColor
			// #ifndef APP-NVUE
			this.containerVisible = false
			// #endif
      // #ifdef APP-NVUE
      this.wxAnimation('100%')
      // #endif
      setTimeout(() => {
        this.visible = false
      }, 300)
    },
    handleCancel () {
      this.$emit('cancel', this.picker)
      if (this.canHide && !this.inline) {
        this.hide()
      }
    },
    handleConfirm () {
      if (this.isEmpty) {
        this.$emit('confirm', null)
        this.hide()
      } else {
        const picker = { ...this.picker }
        this.$refs[this.mode].isConfirmChange = true
        this.myValue = picker.value
        this.$emit('confirm', this.picker)
        if (this.canHide) this.hide()
      }
    },
    handleChange ({ value, valueArr, item, index, change }) {
      if (this.mode === 'dateSelector') {
        this.picker.valueArr = valueArr
      }
      this.picker.value = value
      this.picker.item = item
      this.picker.index = index
      this.picker.change = change
      this.picker.dataset = this.dataset || {}
      if (this.$refs[this.mode] && this.inline) {
        this.$refs[this.mode].isConfirmChange = true
      }
      this.$emit('change', this.picker)
    },
    handleMaskTap () {
      if (this.closeOnClickMask) {
        this.hide()
      }
    },
    moveHandle () {},
    // #ifdef APP-NVUE
    wxAnimation (num) {
      const $container = this.$refs.container
      animation.transition($container, {
        styles: {
          transform: `translateY(${num})`
        },
        duration: 300
      })
    },
    // #endif 
    getColumnsInfo (value, type = 1) {
      let columnsInfo = getColumns(
        {
          value,
          list: this.list,
          mode: this.mode,
          props: this.pickerProps,
          level: this.level
        },
        type
      )
      if (columnsInfo) {
        if (this.mode === 'selector') {
          columnsInfo.index = columnsInfo.index[0]
        }
      } else {
        columnsInfo = {}
      }
      columnsInfo.dataset = this.dataset || {}
      return columnsInfo
    }
  },
  watch: {
    value (newVal) {
      this.myValue = newVal
    },
    myValue (newVal) {
      this.$emit('input', newVal)
    },
    visible (newVisible) {
      if (newVisible) {
        this.$emit('show')
      } else {
        this.$emit('hide')
      }
    },
    props (newProps) {
      this.pickerProps = Object.assign({}, defaultProps, newProps)
    },
    chConfig (newVal) {
      this.pickerChConfig = Object.assign({}, defaultChConfig, newVal)
    }
  }
}
</script>

<style lang="scss" scoped>
@import "./style/picker.scss";
</style>

  JavaScript知识库 最新文章
ES6的相关知识点
react 函数式组件 & react其他一些总结
Vue基础超详细
前端JS也可以连点成线(Vue中运用 AntVG6)
Vue事件处理的基本使用
Vue后台项目的记录 (一)
前后端分离vue跨域,devServer配置proxy代理
TypeScript
初识vuex
vue项目安装包指令收集
上一篇文章      下一篇文章      查看所有文章
加:2022-03-16 22:12:45  更:2022-03-16 22:14:18 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 6:56:57-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码