123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
- <view class="tm-pickersDate 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-pickersDate-title pa-32 pb-16">
- <view class="text-size-n text-align-center" style="min-height: 48rpx;">{{title}}</view>
- <view class="tm-pickersDate-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-pickersDateView ref="gg"
- @aniStart="aniisTrue=false" @aniEnd="aniisTrue=true"
- :modeValue="modeValue"
- :black="black_tmeme"
- :start="start"
- :end="end"
- :defaultValue="dataValue"
- :itemHeight="itemHeight"
- :disabled="disabled"
- :bgColor="bgColor"
- :showDetail="showDetail"
- :mode="mode"
- :fullNumber="fullNumber"
- ></tm-pickersDateView>
- <view class="pa-32">
- <tm-button :black="black_tmeme" @click="confirm" block itemeClass="round-24" :theme="btnColor" 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 tmPickersDateView from "@/tm-vuetify/components/tm-pickersDateView/tm-pickersDateView.vue"
- export default {
- components:{tmButton,tmPoup,tmIcons,tmPickersDateView},
- name:"tm-pickersDate",
- model:{
- prop:'value',
- event:'input'
- },
- mounted() {
- this.showpop = this.value;
- },
- props: {
-
- itemHeight: {
- type: String | Number,
- default: 40
- },
-
- value: {
- type: String | Number,
- default: false
- },
- black:{
- type:String|Boolean,
- default:null
- },
-
- disabled:{
- type:String|Boolean,
- default:false
- },
-
- bgColor:{
- type:String,
- default:'white'
- },
-
- showDetail:{
- type:Object,
- default:()=>{
- return {
- year:true,
- month:true,
- day:true,
- hour:false,
- min:false,
- sec:false
- }
- }
- },
- start:{
- type:String,
- default:'1949-1-1 00:00:00'
- },
- end:{
- type:String,
- default:''
- },
- defaultValue:'',
-
- mode:{
- type:String|Boolean,
- default:true
- },
-
- fullNumber:{
- type:String|Boolean,
- default:true
- },
-
- title:{
- type:String,
- default:'请选择时间'
- },
-
- btnText:{
- type:String,
- default:'确认'
- },
-
- btnColor:{
- type:String,
- default:'primary'
- },
-
- modeValue:{
- type:Object,
- default:()=>{
- return {
- year:'年',
- month:'月',
- day:'日',
- hour:'时',
- min:'分',
- sec:'秒'
- }
- }
- },
-
- },
- data() {
- return {
- showpop:false,
- dataValue:'1949',
- aniisTrue:true,
-
- };
- },
- computed: {
-
- black_tmeme: function() {
- if (this.black !== null) return this.black;
- return this.$tm.vx.state().tmVuetify.black;
- }
- },
- watch:{
- value:function(val){
- this.showpop = val;
- if(val){
- this.$nextTick(function(){
- setTimeout(function() {
- uni.hideKeyboard();
-
- }, 20);
- })
- }
- }
- },
- mounted() {
- this.$nextTick(function(){
- this.$refs.gg.resetVal(this.dataValue)
- })
- },
- methods: {
- confirm() {
- if(!this.aniisTrue){
- console.log('no');
- return ;
- }
- let value = this.$refs.gg.getSelectedValue();
- this.$emit('confirm',value)
-
-
- this.$refs.pop.close();
- },
- close(){
- this.$refs.pop.close();
- },
- openPoup(){
- if(this.disabled==true) return;
- this.showpop=!this.showpop
- },
- toogle(e){
- let t = this;
- if(e){
- if(this.dataValue != this.defaultValue){
- t.dataValue = t.defaultValue;
- }
-
- this.$nextTick(function(){
- setTimeout(function(){
- t.$refs.gg.resetVal(t.dataValue)
- },500)
- })
-
-
-
- t.$refs.gg.resetVal(t.dataValue)
-
- }
- this.$emit('input',e);
- this.$emit('update:value',e);
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .tm-pickersDate-title {
- position: relative;
- .tm-pickersDate-close {
- position: absolute;
- top: 32upx;
- right: 32upx;
- width: 50upx;
- height: 50upx;
-
- }
- }
- </style>
|