123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <template>
- <view>
- <view class="mcalendar">
- <view class="con">
- <text class="icon"></text>
- <text class="date" :disabled="true" @click="updateShow()">{{param.data}}</text>
- <text class="icon del" @click="clear()" v-if="param.data"></text>
- <text class="label" @click="today()">今天</text>
- </view>
- </view>
- <u-calendar :show="show" mode="range" :minDate="minDate" @confirm="confirm" @close="show = false" :closeOnClickOverlay="true"></u-calendar>
- </view>
- </template>
- <script>
- export default {
- name: 'mcalendar',
- props: {
- value: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- show: false,
- minDate: this.util.getDate('lm'),
- param: {
- data: '选择日期范围'
- }
- };
- },
- watch: {
- value(newValue) {
- this.show = newValue;
- }
- },
- methods: {
- confirm(e) {
- console.log('==='+e)
- console.log('==='+e.length)
- this.$emit('input', false);
- this.param.dateBegin = e[0];
- let end = e.length - 1;
- this.param.dateEnd = e[end];
- this.param.data = e[0] + ' - ' + e[end];
- this.show = false;
- this.$emit('confirm', e);
- },
- updateShow() {
- this.show = true;
- },
- today() {
- this.param.dateBegin = this.util.getDate('day');
- this.param.dateEnd = this.util.getDate('day');
- this.param.data = this.util.getDate('day') + ' - ' + this.util.getDate('day');
- this.$forceUpdate();
- this.$emit('today', [this.util.getDate('day'), this.util.getDate('day')]);
- },
- clear() {
- this.param.dateBegin = '';
- this.param.dateEnd = '';
- this.param.data = '选择日期范围';
- this.$forceUpdate();
- this.$emit('clear');
- }
- }
- };
- </script>
- <style lang="scss">
- .mcalendar {
- padding: 10px 10px 0px 10px;
- .con {
- padding: 10px 15px 10px 15px;
- background-color: white;
- border-radius: 20px;
- color: $font-c;
- overflow: hidden;
- .icon {
- padding-right: 10px;
- float: left;
- margin-top: 2px;
- }
- .del {
- padding-left: 9px;
- }
- .date {
- float: left;
- width: 60%;
- }
- .label {
- float: right;
- color: $main-color;
- padding-right: 5px;
- }
- }
- }
- </style>
|