123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <template>
- <view class="tm-pickers d-inline-block fulled">
- <view @click.stop.prevent="openPoup"><slot></slot></view>
- <tm-poup @change="toogle" ref="pop" v-model="showpop" :height="750" :bg-color="black_tmeme?'grey-darken-5':bgColor">
- <view class="tm-pickers-title pa-32 pb-16">
- <view class="text-size-n text-align-center" style="min-height: 48rpx;">{{title}}</view>
- <view class="tm-pickers-close rounded flex-center " :class="black_tmeme?'grey-darken-3':'grey-lighten-3'">
- <tm-icons @click="close" name="icon-times" size="24" :color="black_tmeme?'white':'grey'"></tm-icons>
- </view>
- </view>
- <tm-pickersView v-if="showpop" @change="$emit('change',$event)" @aniStart="aniisTrue=false" @aniEnd="aniisTrue=true" ref="tmPicKersTest" :defaultValue="dataValue"
- :itemHeight="itemHeight" :list="list" :rangKey="rangKey"
- :childrenKey="childrenKey" :black="black_tmeme" :indexfu="indexfu" :disabled="disabled"
- :bgColor="bgColor"
- ></tm-pickersView>
- <view class="pa-32">
- <tm-button :black="black_tmeme" @click="confirm" block itemeClass="round-24" :fllowTheme="fllowTheme" :theme="colorBtn_tmeme" fontSize="32">{{btnText}}</tm-button>
- </view>
- </tm-poup>
- </view>
- </template>
- <script>
-
- import tmButton from "@/tm-vuetify/components/tm-button/tm-button.vue"
- import tmPoup from "@/tm-vuetify/components/tm-poup/tm-poup.vue"
- import tmIcons from "@/tm-vuetify/components/tm-icons/tm-icons.vue"
- import tmPickersView from "@/tm-vuetify/components/tm-pickersView/tm-pickersView.vue"
- export default {
- components:{tmButton,tmPoup,tmIcons,tmPickersView},
- name:"tm-pickers",
- model:{
- prop:'value',
- event:'input'
- },
- props: {
-
- value: {
- type: String | Number,
- default: false
- },
-
-
-
-
- defaultValue:{
- type:Array,
- default:()=>{return []}
- },
-
- itemHeight: {
- type: String | Number,
- default: 40
- },
- list: {
- type: Array,
- default: () => {
- return []
- }
- },
-
- rangKey: {
- type: String,
- default: "text"
- },
-
- childrenKey: {
- type: String,
- default: "children"
- },
- black:{
- type:String|Boolean,
- default:null
- },
-
- disabled:{
- type:String|Boolean,
- default:false
- },
- indexfu:{
- type: String | Number,
- default: "text"
- },
-
- bgColor:{
- type:String,
- default:'white'
- },
-
- title:{
- type:String,
- default:'请选择选项'
- },
-
- btnText:{
- type:String,
- default:'确认'
- },
-
- btnColor:{
- type:String,
- default:'primary'
- },
-
- fllowTheme:{
- type:Boolean|String,
- default:true
- }
-
-
- },
- data() {
- return {
- showpop:false,
- dataValue:[],
- aniisTrue:true,
- };
- },
- computed: {
-
- black_tmeme: function() {
- if (this.black !== null) return this.black;
- return this.$tm.vx.state().tmVuetify.black;
- },
- colorBtn_tmeme:function(){
- if(this.$tm.vx.state().tmVuetify.color!==null&&this.$tm.vx.state().tmVuetify.color && this.fllowTheme){
- return this.$tm.vx.state().tmVuetify.color;
- }
- return this.btnColor;
- },
- },
- mounted() {
- this.showpop = this.value;
- this.$nextTick(function(){
- uni.hideKeyboard();
- })
- },
- watch:{
- value:function(val){
-
- this.showpop = val;
-
- }
- },
- methods: {
- confirm() {
-
- if(!this.aniisTrue){
- console.log('no');
- return ;
- }
- let sdata = this.$refs.tmPicKersTest.getSelectedValue();
-
- let saray = [];
- sdata.forEach(item=>{
- var obj={data:item.data,index:this.indexfu}
- saray.push(obj)
- })
- this.$emit('confirm',sdata)
- this.$emit('update:defaultValue',saray)
- this.showpop=false;
- },
- close(){
- this.showpop=false;
- },
- openPoup(){
- if(this.disabled==true) return;
- this.showpop=true;
- },
- toogle(e){
- console.log(this.showpop);
- if(e){
- this.$nextTick(function(){
-
- if(this.dataValue != this.defaultValue){
- this.dataValue = this.defaultValue;
- }
- this.$refs.tmPicKersTest.setDefaultValue(this.dataValue)
- })
- }
- this.$emit('input',e);
- this.$emit('update:value',e);
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .tm-pickers-title {
- position: relative;
- .tm-pickers-close {
- position: absolute;
- top: 32upx;
- right: 32upx;
- width: 50upx;
- height: 50upx;
-
- }
- }
- .tm-pickers{
-
- }
- </style>
|