<template>
<el-form label-width="100" style="width: 18.75rem;">
<el-form-item label="季度">
<mark class="_mark" v-show="showSeason" @click.stop="showSeason = false"></mark>
<el-input size="mini" placeholder="请选择日期" v-model="time" @focus="showSeason = true">
<i slot="prefix" class="el-input__icon el-icon-date"></i>
</el-input>
<el-card class="box-card" v-show="showSeason">
<div slot="header" class="clearfix yearBtn">
<button type="button" class="el-picker-panel__icon-btn el-date-picker__prev-btn el-icon-d-arrow-left" @click="prev"></button>
<span role="button" class="el-date-picker__header-label">{{ year }}年</span>
<button type="button" @click="next" class="el-picker-panel__icon-btn el-date-picker__next-btn el-icon-d-arrow-right"></button>
</div>
<div class="div-quarter">
<el-button v-for="(item, key) in quarterList" :key="key" type="text" size="medium" @click="selectSeason(key)">{{ item }}</el-button>
</div>
</el-card>
</el-form-item>
</el-form>
</template>
<script>
export default {
data() {
return {
showSeason: false,
season: '',
year: new Date().getFullYear(),
quarterList: ['第一季度', '第二季度', '第三季度', '第四季度']
}
},
methods: {
prev() {
this.year = this.year * 1 - 1
},
next() {
this.year = this.year * 1 + 1
},
selectSeason(i) {
this.season = i + 1
this.showSeason = false
this.time = `${this.year}年${this.season}季度`
}
}
}
</script>
<style scoped lang="scss">
._mark {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0);
z-index: 999;
}
.box-card {
width: 322px;
padding: 0 3px 20px;
margin-top: 10px;
position: fixed;
z-index: 9999;
& > ::v-deep .el-card__body {
padding-top: 0;
padding-bottom: 0;
}
.yearBtn {
text-align: center;
height: 30px;
line-height: 1.875rem;
}
.div-quarter {
button {
border: 1px solid;
width: 130px;
}
button:nth-child(3) {
margin-left: 0px;
}
}
}
</style>
时间季度组件
最新推荐文章于 2024-07-02 15:48:16 发布