123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <template>
- <div>
- <span @click="showDoubleMonth">
- <el-input v-model="choseQuarter" prefix-icon="el-icon-date" placeholder="请选择" />
- </span>
- <div v-show="showTime1a" class="show1">
- <p>
- <button type="button" aria-label="前一年" class="el-picker-panel__icon-btn el-date-picker__prev-btn el-icon-d-arrow-left"
- @click="prev" />
- <span role="button" class="span-year">{{ year }}年</span>
- <button type="button" aria-label="后一年" class="el-picker-panel__icon-btn el-date-picker__next-btn el-icon-d-arrow-right"
- @click="next" />
- </p>
- <div>
- <span v-for="(item,index) in fullMonth" :key="index" class="selectMonth" @click="selectQuarter(item)">
- {{ item }}
- </span>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: 'season',
- data() {
- return {
- value: '',
- showTime2: false,
- showTime1a: false,
- year: new Date().getFullYear(),
- fullMonth: ['第一季度', '第二季度', '第三季度', '第四季度'],
- choseQuarter: '',
- choseQuarter1: ''
- }
- },
- props:{
- isActive:{
- type:Boolean,
- default:false
- }
- },
- mounted() {
- if(!this.isActive){
- var date=new Date().getMonth()+1;
- var arrs=this.fullMonth;
- var str=""
- if(date<=3){
- str=arrs[0]
- }else if(date<=6){
- str=arrs[1]
- }else if(date<=9){
- str=arrs[2]
- }else{
- str=arrs[3]
- }
- this.selectQuarter(str);
- }
- },
- methods: {
- // 点击季度按钮
- quarterTime() {
- this.showTime2 = true
- this.choseQuarter = ''
- this.fullMonth = ['第一季度', '第二季度', '第三季度', '第四季度']
- },
- // 点击input框
- showDoubleMonth() {
- this.showTime1a = true
- },
- // 上一年
- prev() {
- this.year = this.year * 1 - 1
- },
- // 下一年
- next() {
- this.year = this.year * 1 + 1
- },
- // 点击选项事件
- selectQuarter(item) {
- switch (item) {
- case '第一季度':
- this.choseQuarter1 = this.year + '1'
- this.choseQuarter = this.year + '年 第一季度'
- break
- case '第二季度':
- this.choseQuarter1 = this.year + '2'
- this.choseQuarter = this.year + '年 第二季度'
- break
- case '第三季度':
- this.choseQuarter1 = this.year + '3'
- this.choseQuarter = this.year + '年 第三季度'
- break
- case '第四季度':
- this.choseQuarter1 = this.year + '4'
- this.choseQuarter = this.year + '年 第四季度'
- break
- }
- this.$emit('confirm', this.choseQuarter1)
- this.showTime1a = false
- }
- }
- }
- </script>
- <style scoped>
- * {
- margin: 0;
- padding: 0;
- list-style: none;
- }
- .show1 {
- width: 320px;
- margin-top: 5px;
- position: absolute;
- z-index: 2;
- height: auto;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
- background: #fff;
- padding: 5px;
- padding-right: 20px;
- }
- .show1 p:nth-child(1) {
- width: 100%;
- height: 40px;
- border-bottom: 1px solid #f5f5f5;
- display: flex;
- align-items: center;
- justify-content: end;
- padding: 0 10px;
- }
- .show1>div {
- width: 100%;
- height: auto;
- }
- .show1>div span {
- width: 50%;
- }
- .selectMonth {
- display: inline-block;
- float: left;
- width: 78px;
- height: 40px;
- line-height: 40px;
- text-align: center;
- }
- .selectMonth:hover {
- background: rgba(19, 131, 255, 0.052);
- }
- .span-year {
- width: 90%;
- margin: 0 auto;
- display: inline-block;
- text-align: center;
- line-height: 40px;
- }
- </style>
|