当前位置: 首页 > news >正文

vue季度选择器(antd2.0 版本无此控件,单独写一个)

vue季度选择器

  • 效果显示

效果显示

在这里插入图片描述

<template><div><a-popoverplacement="bottom"overlayClassName="season-picker"trigger="click"v-model="showSeason"><template #content><div class="season-picker-box"><div class="season-picker-box_header"><a-icontitle="前一年"class="season-picker-box_header-left"type="double-left"@click="prev"></a-icon><spanrole="button"class="season-picker-box_header-label">{{ year }}年</span><a-icontype="double-right"title="后一年"@click="next"class="season-picker-box_header-right"></a-icon></div><div class="season-picker_content"><table class="el-month-table"><tr><td><div><a:class="{ choose: seasonValue[0] === year && seasonValue[1] === 1 }"class="cell"@click="selectSeason(1)">一季度</a></div></td><td><div><a:class="{ choose: seasonValue[0] === year && seasonValue[1] === 2 }"class="cell"@click="selectSeason(2)">二季度</a></div></td></tr><tr><td><div><a:class="{ choose: seasonValue[0] === year && seasonValue[1] === 3 }"class="cell"@click="selectSeason(3)">三季度</a></div></td><td><div><a:class="{ choose: seasonValue[0] === year && seasonValue[1] === 4 }"class="cell"@click="selectSeason(4)">四季度</a></div></td></tr></table></div></div></template><a-inputv-model="strValue"readOnly/></a-popover></div>
</template>

<script>
const CNNUM = ["一", "二", "三", "四"];
const CHOOSEMONTH = [["01", "02", "03"],["04", "05", "06"],["07", "08", "09"],["10", "11", "12"],
];
// 季度选择器 antd当前版本没有 所以写一个
export default {name: "quarterPicker",model: {prop: "value",event: "change",},props: {value: {type: Array,default: () => [],},defaultValue: {type: Array,default: () => [],},},watch: {defaultValue: {handler(newVal) {// ['2024-07', '2024-09']if (newVal && newVal.length) {this.dealDate(newVal);}},deep: true,immediate: true,},value(newVal) {// ['2024-07', '2024-09']if (newVal && newVal.length) {this.dealDate(newVal, true);}},},data() {return {showSeason: false,year: new Date().getFullYear(),strValue: "",seasonValue: ["", ""],};},methods: {dealDate(date, isValue) {this.year = Number(date[0].split("-")[0]);const month = date[0].split("-")[1];CHOOSEMONTH.forEach((item, index) => {if (item.indexOf(month) !== -1) {this.selectSeason(index + 1, isValue);}});},prev() {this.year = this.year * 1 - 1;},next() {this.year = this.year * 1 + 1;},selectSeason(i, isValue = false) {this.strValue = `${this.year}-${CNNUM[i - 1]}季度`;if (!isValue) {// 传入该季度的开始月份和结束月份this.$emit("change", [`${this.year}-${CHOOSEMONTH[i - 1][0]}`,`${this.year}-${CHOOSEMONTH[i - 1][2]}`,]);}this.seasonValue = [this.year, i];this.showSeason = false;},},
};
</script>
<style lang="less" scoped>
.season-picker {margin: 0;padding: 0;color: #000000d9;font-size: 14px;.ant-popover-inner-content {overflow: hidden;vertical-align: top;background: #fff;border-radius: 2px;box-shadow: 0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d;transition: margin 0.3s;width: 200px;color: #000000d9;padding: 0 8px !important;.ant-popover-arrow {display: none !important;}}&-box {&_header {display: flex;height: 34px;line-height: 28px;color: #000000d9;box-sizing: border-box;border-bottom: 1px solid #f0f0f0;justify-content: space-between;margin-bottom: 15px;&-left,&-right {line-height: 28px;color: #00000040;&:hover {color: #000000d9;}}}.el-month-table {width: 100%;}.el-month-table td div {margin: 10px;font-size: 14px;.cell {font-size: 12px;color: #333333;padding: 8px;&:hover {color: #40a9ff;background: #e6f7ff;cursor: pointer;}}}.choose {color: #fff !important;background: #1890ff !important;}}
}
</style>
http://www.lryc.cn/news/504491.html

相关文章:

  • C/C++代码性能优化技巧的书籍及资料
  • 通俗易懂的 Nginx 反向代理 配置
  • docker设置容器自动启动
  • 蓝桥杯刷题——day1
  • Leetcode 面试150题 399.除法求值
  • 活动预告 |【Part2】Microsoft 安全在线技术公开课:安全性、合规性和身份基础知识
  • Unity游戏实战
  • SQL中的替换函数replace() 使用
  • Python面试常见问题及答案5
  • (css)element中el-select下拉框整体样式修改
  • 点击按钮打开dialog嵌套表格checked数据关闭dialog回显checked数据
  • 《拉依达的嵌入式\驱动面试宝典》—C/CPP基础篇(三)
  • 大模型呼出机器人有哪些优势和劣势?
  • Python鼠标轨迹算法(游戏防检测)
  • 安宝特分享 | AR技术助力医院总院与分院间的远程面诊
  • css中的字体单位
  • 如何使用程序查询域名whois信息?(带PHP/C#示例)
  • 在C#中编程绘制和移动线段
  • web自动化测试框架playwright
  • 【报错记录】Ubuntu22.04解决开机卡在 /dev/sda5 : clean , *files , *blocks
  • 【AIGC】如何高效使用ChatGPT挖掘AI最大潜能?26个Prompt提问秘诀帮你提升300%效率的!
  • 免费生成AI PPT产品推荐?
  • ubuntu22.04 使用crash
  • Linux高性能服务器编程 | 读书笔记 |9.定时器
  • OSG开发笔记(三十九):OSG中模型的透明度实现、球体透明度Demo
  • phpSpider如何处理网页内容的动态加载问题
  • 【Go】-倒排索引的简单实现
  • Python:基于PyCharm的简单程序创建及运行-HelloWorld
  • 设置HP条UI
  • 开源分布式系统追踪-03-CNCF jaeger-02-快速开始