季度到季度的組件選擇

在這里插入圖片描述

組件:
<template><div class="quarter"><div class="input-wrap" id="closeId" @mouseover="handler" @click.stop="btn" :style="{color:colorItem}"><i class="el-icon-date"></i>{{seasonValue}}<i class="el-icon-circle-close" :style="{display:displayShow}" @click.stop="close"></i></div><div v-show="showSeason" ref="shows" class="selectPop"><div v-for="(item, index) in timeList" :key="index" style="width: 47%; height: 140px;"><template><div class="card-header"><el-row style="width: 100%; height: 100%;"><el-col :span="6" style="height: 100%; text-align:left"><div class="el-icon-d-arrow-left" v-show="prevShow(index)" @click="prev(item)" style="width: 16px;cursor: pointer; "></div></el-col><el-col :span="12"><div class="text-year" style="text-align:center">{{ item.year }}</div></el-col><el-col :span="6" style="height: 100%; text-align:right"><div class="el-icon-d-arrow-right" v-show="nextShow(index)" @click="next(item)" style="width: 16px;cursor: pointer; "></div></el-col></el-row></div></template><div class="text-item" style="text-align:center;"><el-button type="text" size="medium" class="no-choose" :class="{choose: item.QOneSelect}" style="cursor: pointer;width:46%; float:left;" @click="selectSeason(index, 1, '第一季度')">第一季度</el-button><el-button type="text" size="medium" class="no-choose" :class="{choose: item.QTwoSelect}" style="cursor: pointer;float:right;width:46%;" @click="selectSeason(index, 2, '第二季度')">第二季度</el-button></div><div class="text-item" style="text-align:center;"><el-button type="text" size="medium" class="no-choose" :class="{choose: item.QThreeSelect}" style="cursor: pointer;width:46%;float:left;" @click="selectSeason(index, 3, '第三季度')">第三季度</el-button><el-button type="text" size="medium" class="no-choose" :class="{choose: item.QFourSelect}" style="cursor: pointer;float:right;width:46%;" @click="selectSeason(index, 4, '第四季度')">第四季度</el-button><!--  --></div></div></div></div>
</template>
<script>
export default {computed: {prevShow() {return (data) => {//右邊部分年份左箭頭顯示判斷if (data === 1 && this.timeList[1].year - this.timeList[0].year === 1) {return false;} else {return true;}};},nextShow() {return (data) => {//左邊部分年份右箭頭顯示判斷if (data === 0 && this.timeList[1].year - this.timeList[0].year === 1) {return false;} else {return true;}};},},data() {return {showSeason: false, //是否顯示選擇季度面板year: new Date().getFullYear(), //默認當前年seasonValue: "請選擇季", //input中顯示的內容time: {stTime: "",edTime: "",},colorItem: "#c0c4cc",displayShow: "none",timeList: [{year: new Date().getFullYear() - 1,QOneSelect: false,QTwoSelect: false,QThreeSelect: false,QFourSelect: false,},{year: new Date().getFullYear(),QOneSelect: false,QTwoSelect: false,QThreeSelect: false,QFourSelect: false,},],selectNum: 0, //計數器firstSelect: "", //第一次選中的值拼接firstSelectQuarter: "", //第一次選中的季度firstIndex: "", //第一次選中的是數組中的哪一個secondSelect: "", //第二次選中的值拼接secondSelectQuarter: "", //第二次選中的季度secondIndex: "", //第二次選中的是數組中的哪一個};},created() {// 點擊頁面的任何一個地方,都隱藏提示this.text();},watch: {//方法1seasonValue(newVal, oldVal) {//  color: #606266;if (newVal == "請選擇季") {this.colorItem = "#c0c4cc";} else {this.colorItem = "#606266";}},},methods: {handler() {if (this.seasonValue == "請選擇季") {this.displayShow = "none";} else {this.displayShow = "block";}},text() {document.addEventListener("click", (e) => {if (this.$refs.shows) {let self = this.$refs.shows.contains(e.target);if (!self) {this.showSeason = false;}}});},btn() {this.showSeason = !this.showSeason;//再次打開的時候回顯上次選中的 必須是之前選過而非首次打開if (this.showSeason && this.firstSelectQuarter && this.secondSelectQuarter) {const nameOne = this.transQuarter(this.firstSelectQuarter);this.timeList[this.firstIndex][nameOne] = true;const nameTwo = this.transQuarter(this.secondSelectQuarter);this.timeList[this.secondIndex][nameTwo] = true;}},close() {this.seasonValue = "請選擇";this.showSeason = false;},//年向前prev(obj) {obj.year -= 1;// this.year = +this.year - 1;},//年向后next(obj) {obj.year += 1;// this.year = +this.year + 1;},//選擇季度處罰selectSeason(index, quarterNum, quarterString) {//每選中一次計數器加一 計數器是2的時候重置計數器this.selectNum += 1; //非首次打開 會回顯上次選中的結果再次選中會清空上次選中this.timeList.forEach(item => {item.QOneSelect = falseitem.QTwoSelect = falseitem.QThreeSelect = falseitem.QFourSelect = false})//將選中的季度項改變顏色const attName = this.transQuarter(quarterNum);this.timeList[index][attName] = true;//選中賦值const selectValue = this.timeList[index].year.toString() + quarterString;const selectQuarter = quarterNum;const selectIndex = index;if (this.selectNum === 1) {//打開選擇框選中第一個季度項賦值this.firstSelect = selectValue;this.firstSelectQuarter = selectQuarter;this.firstIndex = selectIndex;} else {//打開選擇框選中第二個季度項賦值this.secondSelect = selectValue;this.secondSelectQuarter = selectQuarter;this.secondIndex = selectIndex;}//當計數器為2時,說明已經選中了兩個季度,比較兩次選中的值 進行賦值if (this.selectNum === 2) {//索引小的為選擇框左邊  索引大的為選擇框右邊if (this.firstIndex < this.secondIndex) {//從左往右選直接拼接this.seasonValue = this.firstSelect + " - " + this.secondSelect;} else if (this.firstIndex > this.secondIndex) {//從右往左選反過來拼接this.seasonValue = this.secondSelect + " - " + this.firstSelect;} else {//索引一樣說明兩次選的是同一邊 須比較兩次選的季度值的大小if (this.firstSelectQuarter < this.secondSelectQuarter) {this.seasonValue = this.firstSelect + " - " + this.secondSelect;} else {this.seasonValue = this.secondSelect + " - " + this.firstSelect;}}//選擇結束,關閉彈窗以及計數器重置處理this.selectEnd();}// this.seasonValue = this.year.toString() + "-" + quarter.toString();// this.showSeason = false;// switch (quarter) {//   case "第一季度"://     this.time.stTime = this.year.toString() + "-01-01" + " " + "00:00:00";//     this.time.edTime = this.year.toString() + "-03-31" + " " + "23:59:59";//     break;//   case "第二季度"://     this.time.stTime = this.year.toString() + "-04-01" + " " + "00:00:00";//     this.time.edTime = this.year.toString() + "-06-30" + " " + "23:59:59";//     break;//   case "第三季度"://     this.time.stTime = this.year.toString() + "-07-01" + " " + "00:00:00";//     this.time.edTime = this.year.toString() + "-09-30" + " " + "23:59:59";//     break;//   case "第四季度"://     this.time.stTime = this.year.toString() + "-10-01" + " " + "00:00:00";//     this.time.edTime = this.year.toString() + "-12-31" + " " + "23:59:59";//     break;// }// this.$emit("getQuarter", this.time); //傳值給父組件},selectEnd() {this.showSeason = false;this.selectNum = 0;// this.timeList.forEach(item => {//   item.QOneSelect = false//   item.QTwoSelect = false//   item.QThreeSelect = false//   item.QFourSelect = false// })},transQuarter(quarterNum) {let name = "";switch (quarterNum) {case 1:name = "QOneSelect";break;case 2:name = "QTwoSelect";break;case 3:name = "QThreeSelect";break;case 4:name = "QFourSelect";break;}return name;},},
};
</script>
<style lang="scss" scoped>
.quarter {position: relative;.input-wrap {width: 260px;height: 36px;border: 1px solid #dcdfe6;border-radius: 4px;color: #606266;position: relative;.el-icon-date {color: #c0c4cc;margin-left: 10px;margin-right: 8px;}.el-icon-circle-close {position: absolute;top: 50%;transform: translateY(-50%);right: 10px;color: #c0c4cc;display: none;cursor: pointer;}}.no-choose {color: #606266;}.choose {color: #409eff;}.selectPop {display: flex;justify-content: space-between;width: 400px;position: absolute;background: #fff;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);border: 1px solid #dfe4ed;border-radius: 4px;color: #606266;padding: 8px 15px 15px 15px;top: 52px;z-index: 10;.card-header {width: 100%;height: 40px;border-bottom: 1px solid #e6ebf5;display: flex;justify-content: space-between;align-items: center;margin-bottom: 10px;.text-year {font-size: 16px;}}&::before {content: "";border-bottom: 10px solid #dfe4ed;border-left: 8px solid transparent;border-right: 8px solid transparent;position: absolute;left: 13%;-webkit-transform: translateX(-50%);transform: translateX(-50%);top: -8px;border-radius: 5px;}&::after {content: "";border-bottom: 8px solid #fff;border-left: 8px solid transparent;border-right: 8px solid transparent;position: absolute;left: 13%;-webkit-transform: translateX(-50%);transform: translateX(-50%);top: -6px;border-radius: 5px;}}
}
</style>
使用:
 <QuarterRange @getQuarter="getQuarter"></QuarterRange>//獲取季度子組件傳回的數據
getQuarter(val) {console.log("季節:", val);
},

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/39118.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/39118.shtml
英文地址,請注明出處:http://en.pswp.cn/news/39118.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【Java】BF算法(串模式匹配算法)

?? 什么是BF算法 BF算法&#xff0c;即暴力算法&#xff0c;是普通的模式匹配算法&#xff0c;BF算法的思想就是將目標串S的第一個與模式串T的第一個字符串進行匹配&#xff0c;若相等&#xff0c;則繼續比較S的第二個字符和T的第二個字符&#xff1b;若不相等&#xff0c;則…

【計算機視覺|生成對抗】用深度卷積生成對抗網絡進行無監督表示學習(DCGAN)

本系列博文為深度學習/計算機視覺論文筆記&#xff0c;轉載請注明出處 標題&#xff1a;Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks 鏈接&#xff1a;[1511.06434] Unsupervised Representation Learning with Deep Conv…

騰訊云CVM服務器競價實例是什么?和按量計費有什么區別?

騰訊云服務器CVM計費模式分為包年包月、按量計費和競價實例&#xff0c;什么是競價實例&#xff1f;競價實例和按量付費相類似&#xff0c;優勢是價格更劃算&#xff0c;缺點是云服務器實例有被自動釋放風險&#xff0c;騰訊云服務器網來詳細說下什么是競價實例&#xff1f;以及…

NLP——操作步驟講義與實踐鏈接

數據集與語料 語料是NLP的生命之源&#xff0c;所有NLP問題都是從語料中學到數據分布的規律語料的分類&#xff1a;單語料&#xff0c;平行語料&#xff0c;復雜結構 語料的例子&#xff1a;Penn Treebank, Daily Dialog, WMT-1x翻譯數據集&#xff0c;中文閑聊數據集&#xf…

大數據:Numpy基礎應用詳解

Numpy基礎應用 Numpy 是一個開源的 Python 科學計算庫&#xff0c;用于快速處理任意維度的數組。Numpy 支持常見的數組和矩陣操作&#xff0c;對于同樣的數值計算任務&#xff0c;使用 NumPy 不僅代碼要簡潔的多&#xff0c;而且 NumPy 的性能遠遠優于原生 Python&#xff0c;…

mysql-5.5.62-win32安裝與使用

1.為啥是這個版本而不是當前最新的8.0&#xff1f; 因為我要用32位。目前mysql支持win32的版本最新只到5.7.33。 首先&#xff0c;到官網MySQL :: MySQL Downloads 然后選 選一個自己喜歡的版本就好。我這里是如標題版本。下載32位的zip。然后回來解壓。 完了創建系統環境變…

項目實施方案案例模板-拿來即用

《項目實施方案》實際案例模板&#xff0c;拿來即用&#xff0c;原件可獲取。 項目背景 項目目標 項目范圍 項目總體計劃 項目組織架構 5.1. 項目職責分工 項目風險點 6.1. 項目風險分析 6.2. 項目實施關鍵點 項目管理規范 7.1. 項目實施約束 7.2. 項目變更凍結 7…

(三) CUDA 硬件實現

一組帶有on-chip 共享內存的SIMD多處理器 GPU可以被看作一組多處理器, 每個多處理器使用單一指令&#xff0c;多數據架構(SIMD)【單指令流多數據流】 在任何給定的時鐘周期內&#xff0c;多處理器的每個處理器執行同一指令&#xff0c;但操作不同的數據 每個多處理器使用以下…

HASH索引,AVL樹,B樹,B+樹的區別?

1. 什么是 Hash 1.1 Hash 函數 Hash 本身其實是一個函數&#xff0c;又被稱為散列函數&#xff0c;它可以大幅提高我們對數據的檢索效率。因為它是散列的&#xff0c;所以在存儲數據的時候&#xff0c;它也是無序的。 Hash 算法是通過某種確定性的算法(例如MD5&#xff0c;S…

virtualBox橋接模式下openEuler鏡像修改IP地址、openEule修改IP地址、openEule設置IP地址

安裝好openEuler后,設置遠程登入前,必不可少的一步,主機與虛擬機之間的通信要解決,下面給出詳細步驟: 第一步:檢查虛擬機適配器模式:橋接模式 第二步:登入虛擬機修改IP cd /etc/sysconfig/network-scripts vim ifcfg-enpgs3 沒有vim的安裝或者用vi代替:sudo dnf …

關于consul的下載方法

linux下 sudo yum install -y yum-utils sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo sudo yum -y install consulwindow下 https://developer.hashicorp.com/consul/downloads 然后把里面的exe文件放在gopath下就行了 驗證…

打造專屬花店展示小程序

在當今社會&#xff0c;微信小程序已經成為了各行各業拓展客戶資源的利器&#xff0c;而花店行業也不例外。通過打造一個獨特的花店小程序&#xff0c;你可以為你的花店帶來更多的曝光和客戶資源。那么&#xff0c;如何制作一個專屬的花店小程序呢&#xff1f;下面我們就來一步…

圖像像素梯度

梯度 在高數中&#xff0c;梯度是一個向量&#xff0c;是有方向有大小。假設一二元函數f(x,y)&#xff0c;在某點的梯度有&#xff1a; 結果為&#xff1a; 即方向導數。梯度的方向是函數變化最快的方向&#xff0c;沿著梯度的方向容易找到最大值。 圖像梯度 在一幅模糊圖…

電子商務類網站需要什么配置的服務器?

隨著電子商務的迅猛發展&#xff0c;越來越多的企業和創業者選擇在互聯網上開設自己的電商網站。為了確保電商網站能夠高效運行&#xff0c;給用戶提供良好的體驗&#xff0c;選擇合適的服務器配置至關重要。今天飛飛將和你分享電子商務類網站所需的服務器配置&#xff0c;希望…

【實際開發19】- 壓測 / 調優準備

目錄 1. Jmeter 2. Jmeter 環境部署 1. 配置 : 臨時修改語言 ~ Options → Choose Language → Chinese 3. Jmeter 并發測試 0. 提示 : Postman 測試是“串行”的 , 無法測試并發請求 1. daiding 1. Jmeter 下載 : Apache JMeter - Download Apache JMeter 詳參&#xf…

Mac下編譯32位Qt

不建議&#xff0c;MAC新版不支持32位程序&#xff01;&#xff01;&#xff01; Mac下編譯32位Qt 關于Mac10.11.4下編譯32bit Qt5.6.1的問題

【已解決】mac端 sourceTree 解決remote: HTTP Basic: Access denied報錯

又是在一次使用sourcetree拉取或者提交代碼時候&#xff0c;遇到了sourcetree報錯&#xff1b; 排查了一會&#xff0c;比如查看了SSH keys是否有問題、是否與sourcetree賬戶狀態有問題等等&#xff0c;最終才發現并解決問題 原因&#xff1a; 因為之前公司要求企業gitlab中…

【Java】異常處理 之 使用SLF4J 和 Logback

使用SLF4J和Logback 前面介紹了Commons Logging 和Log4j 這一對好基友&#xff0c;它們一個負責充當日志 API&#xff0c;一個負責實現日志底層&#xff0c;搭配使用非常便于開發。 有的童鞋可能還聽說過SLF4J和Logback。這兩個東東看上去也像日志&#xff0c;它們又是啥&…

JavaEE初階:多線程 - 編程

1.認識線程 我們在之前認識了什么是多進程&#xff0c;今天我們來了解線程。 一個線程就是一個 "執行流". 每個線程之間都可以按照順訊執行自己的代碼. 多個線程之間 "同時" 執行 著多份代碼. 引入進程這個概念&#xff0c;主要是為了解決并發編程這樣的…

編譯工具:CMake(三)| 最簡單的實例升級

編譯工具&#xff1a;CMake&#xff08;三&#xff09;| 最簡單的實例升級 前言過程語法解釋ADD_SUBDIRECTORY 指令 如何安裝目標文件的安裝普通文件的安裝&#xff1a;非目標文件的可執行程序安裝(比如腳本之類)目錄的安裝 修改 Helloworld 支持安裝測試 前言 本篇博客的任務…