el-calendar的样式修改使用记录

博客围绕el-calendar组件展开,介绍其尺寸由内部日历块决定,还提及取消右上角上月下月及显示今天的css样式,阐述了点击块出现背景色与下方小点的效果,以及上月下月点击事件相关内容,属于前端开发范畴。

效果图与element原图

 

 el-calendar的尺寸

el-calendar的大小是根据内部每一个日历块进行决定的

    .el-calendar-day {
      height: 47px !important;
      border: none;
      text-align: center;
      padding: 0;
    }

右上角的上月下月,取消显示今天的css

// 今天按钮隐藏
    .el-button-group > .el-button:not(:first-child):not(:last-child) {
      display: none;
    }
    // 更改上月和下月样式
    .el-button-group > .el-button:first-child:before {
      content: "<";
      border: none;
      font-size: 20px;
      color: #979797;
    }

    .el-button-group > .el-button:last-child:before {
      content: ">";
      border: none;
      font-size: 20px;
      color: #979797;
    }
    // 按钮隐藏
    .el-button-group > .el-button:first-child span,
    .el-button-group > .el-button:last-child span {
      display: none;
    }

点击块出现背景色与下方小点

<template slot="dateCell" slot-scope="{ date, data }">
        <div
          :class="data.isSelected ? 'selected' : ''" //选中的状态
          style="width: 100%;height: 100%;padding-top: 5px;box-sizing: border-box;"
          @click="AddNewmsg(data)"
        >
          <p>{{ data.day.split("-")[2] }}</p>
          <div v-for="(i, index) in List">
            <div v-if='根据后端数据进行是否显示'  class="fleck"></div>
          </div>
        </div>
      </template>

上月下月点击事件

  mounted() {
    // 如果使用监听绑定数据会在点击今天按钮出现
    this.$nextTick(() => {
      // 点击前一个月
      let prevBtn = document.querySelector(
        ".el-calendar__button-group .el-button-group>button:nth-child(1)"
      );
      prevBtn.addEventListener("click", () => {
       //调用点击前一个月的函数,自己出入当前月份
            this.judgeDate(this.calendarDate);
      });
      let dayBtn = document.querySelector(
        ".el-calendar__button-group .el-button-group>button:nth-child(2)"
      );
      dayBtn.addEventListener("click", () => {
        this.judgeDate(this.calendarDate);
      });
      let nextBtn = document.querySelector(
        ".el-calendar__button-group .el-button-group>button:nth-child(3)"
      );
      nextBtn.addEventListener("click", () => {
        this.judgeDate(this.calendarDate);
      });
    });
  },

<template> <div> <el-dialog v-model="visible" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" class="mydialog" > <el-tabs v-model="activeFunc" @tab-click="changeActive"> <el-tab-pane :label="$t('func.jobAnalysis.integratedPage_basicInfo')" name="1"> <BlockBasicInfo ref="blockBasicInfo" :map="map" :blockInfo="blockInfo" :dataScreen="true" /> </el-tab-pane> <el-tab-pane :label="$t('func.jobAnalysis.jobRecords')" name="2"> <BlockWorkInfo :blockInfo="blockInfo" dialogClass="screenSa" :dataScreen="true" v-if="activeFunc == '2'" /> </el-tab-pane> </el-tabs> <div @click="handleBack" class="back">{{ $t('commen.button.return') }}</div> </el-dialog> </div> </template> <script> import BlockBasicInfo from '@/views/ywIndex/blockInfo/BlockBasicInfo'; import BlockWorkInfo from '@/views/ywIndex/blockInfo/BlockWorkInfo'; import { blockDetail } from '@/api/plot'; export default { name: 'BlockInfoDialog', components: { BlockBasicInfo, BlockWorkInfo }, props: { map: Object }, data() { return { blockId: false, visible: false, loading: false, blockInfo: null, activeFunc: '1' }; }, computed: { width() { return this.activeFunc == '2' ? 1050 : 500; } }, watch: { blockId() { this.$refs.blockBasicInfo.clearABline(); this.$refs.blockBasicInfo.clearABText(); this.$refs.blockBasicInfo.functionName = this.$t('func.mapMode.abshow'); this.$refs.blockBasicInfo.abLineFature = null; } }, methods: { open(id) { this.activeFunc = '1'; this.blockId = id; this.visible = true; this.$nextTick(() => { this.$emit('widthChange', this.width); }); this.loading = true; blockDetail({ blockId: this.blockId }) .then((res) => { this.blockInfo = res.data.data; }) .catch((res) => { console.error(res); }) .finally(() => { this.loading = false; }); }, handleBack() { this.visible = false; }, close() { if (this.visible) { this.visible = false; this.$emit('widthChange', 0); } }, changeActive(item) { this.$nextTick(() => { this.$emit('widthChange', this.width); }); }, openedHandler() { if (this.$refs.blockWorkInfo?.resize) { this.$refs.blockWorkInfo.resize(); } }, closeHandler() { this.$emit('close'); } } }; </script> <style scoped lang="scss"> :deep(.mydialog ){ width: 98%; height: 86%; background-image: var(--theme-dataScreen_dialog_bg_full); background-size: 100% 100%; background-repeat: no-repeat; pointer-events: all; position: absolute; bottom: 20rem; left: 1%; overflow: hidden; padding: 20rem; .el-dialog__header { display: none; } .el-tabs__active-bar { background: #646f9eff; } .el-dialog__body { height: 100%; background: transparent; overflow: hidden; position: relative; .back { width: 100px; height: 42px; line-height: 42px; text-align: center; color: #d0d7ec; position: absolute; top: 0; right: 10px; background: var(--theme-screen_plot_checkbox_bg_color); border-radius: 4px; border: var(--theme-dataScreen_back_border); } .el-button--primary { background: rgba(134, 164, 255, 0.3); border-radius: 4px; border: 1rem solid #bbccff; color: #d0d7ec; } .el-tabs { height: 100%; } .el-tabs__content { height: calc(100% - 70rem); } .el-tab-pane { height: 100%; } .el-tabs__nav-wrap { margin-top: 8rem; } .el-descriptions__body, .page-singleStatistics, .el-table, .singleMachineInfo, .page-singleStatistics .data-box .charts-box .date-box, .page-singleStatistics .data-box .charts-box .table-box .card, .page-singleStatistics .data-box .data-label .label-item, .timeRule, .page-singleStatistics .data-box .data-label .label-item .img, .timeRule .timeRuleContainer .ruleSymbol .symbol, .el-tabs__item, .el-cascader__dropdown, .el-calendar, .page-singleStatistics .data-box .data-label .label-item .text .label-item-num, .el-radio-button__inner { background: transparent; color: white; } .el-cascader-menu { background: #151c29ff; } .main .bottom .rightMainMap .topLeft, .el-checkbox { color: #9ba1b2ff; } } .el-checkbox__input.is-checked + .el-checkbox__label, .main .bottom .rightMainMap .topLeft .lockContainer { color: white; } .year-box .monthContainer .month.active { border-top-color: #646f9eff; } .el-cascader .el-input.is-focus .el-input__inner, .el-input__inner:hover { border-color: #9ba1b2ff; } .el-checkbox__input.is-checked .el-checkbox__inner, .page-singleStatistics .data-box .charts-box .date-box[data-v-c5fe9bfa] .el-radio-button__orig-radio:checked + .el-radio-button__inner, [data-v-1ab050e6] .el-dialog .el-table .el-table__empty-text, [data-v-1ab050e6] .el-dialog .el-table thead, [data-v-1ab050e6] .el-dialog .el-table tr { background: var(--theme-dataScreen_input_inner); color: #d0d7ec; } .el-cascader__search-input { background: #272f40ff; } .el-table { margin-top: 10rem; height: calc(100% - 128rem); background: var(--theme-dataScreen_elTabs_header); color: #d0d7ec; overflow-y: auto; & tr, & thead, .el-table__empty-text { background: var(--theme-dataScreen_elTabs_header); color: #d0d7ec; } .el-table__row.statistics-warning-row { background: #272f40; } .el-table__row.default-row td.el-table__cell { background: #2a3243; } .el-table tbody tr:hover > td { background-color: #c0c4cc !important; color: #ffffff; } ::-webkit-scrollbar-thumb { border-radius: 10rem; -webkit-box-shadow: inset 0 0 10rem rgba(53, 116, 55, 0.2); background-color: var(--theme-dataScreen_chartandTable_active); } } .el-pagination { color: #d0d7ec; } .el-input__inner { background: var(--theme-dataScreen_input_bg_color)!important; color: #d8e5f7; outline: 1rem solid rgba(255, 255, 255, 0.4); } :deep(.el-pagination span:not([class*='suffix']) ){ color: rgba(208, 215, 236, 1); } :deep(.el-pagination__editor.el-input .el-input__inner ){ background: var(--theme-dataScreen_input_bg_color) !important; color: rgba(208, 215, 236, 1); border: 1rem solid var(--theme-dataScreen_input_border_color); } .el-input__inner, .el-pagination__jump, .el-range-input { background: var(--theme-dataScreen_input_bg_color) !important; color: #d0d7ec; } } :deep(.el-tabs__active-bar){ background: var(--theme-dataScreen_elTabs_active)!important; } :deep(.el-tabs__item.is-active){ color: var(--theme-dataScreen_elTabs_active_color)!important; } :deep(.el-table thead){ background: var(--theme-dataScreen_elTabs_header)!important; } </style> <style lang="scss"> .mapMode.screenSa { .cardHeader::before { background: var(--theme-dataScreen_cardHeader); } .leftFuncContainer .content { background: rgba(45, 59, 81, 0.2) !important; } .recordList { &::-webkit-scrollbar-thumb { background-color: var(--theme-dataScreen_chartandTable_active); } } .card { &.active { background: var(--theme-dataScreen_cardHeader_car_active); } .cardHeader .cardTitle { span:nth-of-type(1) { color: #d8e5f7 !important; } span:last-of-type { color: #8e94a5 !important; } } .cardContent .agType { span:first-of-type { color: #8e94a5 !important; } span:last-of-type { color: #d8e5f7 !important; } } } .legend { background: rgba(30, 45, 66, 1) !important; .legendTitle, .legendText { color: rgba(216, 229, 247, 1) !important; } .legendBorder { border-bottom-color: rgba(216, 229, 247, 0.2) !important; } .legendEdit .editContainer .legendContiner > div { .el-input-number { .el-input-number__decrease, .el-input-number__increase { color: var(--color_info) !important; } } & > .opButton { color: var(--color_info) !important; } } .legendEdit .editContainer .configContiner .el-form { .el-form-item__label { color: var(--color_info) !important; } .el-input-number { .el-input-number__decrease, .el-input-number__increase { color: var(--color_info) !important; } } .el-radio { color: var(--color_info) !important; } } } .machineSingleInfo { background: var(--theme-dataScreen_machineSingleInfo) !important; .machineSingleSelect .el-select__caret { color: var(--color_info) !important; } } :deep(.el-checkbox){ color:white!important; } :deep(.el-dialog .el-checkbox__input.is-checked .el-checkbox__inner){ background:green!important; } } :deep(.el-tabs__header){ position:absolute!important; top:20rem!important; left:20rem!important; } </style> 这段代码帮我修改elementplus+vue2的写法,目前存在el-tabs__header is-top在el-tabs__content下方
最新发布
11-04
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值