vue element Tooltip套用Popover

 需求:同一个图标,鼠标移入显示提示语,点击显示列表

鼠标移入:

鼠标点击:

 

 

<template>
  <div class="table-list">
 <!-- 注意点1: 使用 tooltip 将 popover 包裹住, 如果是 popover 包裹 tooltip 会导致显示问题  --
    <el-tooltip
      class="item"
      effect="dark"
      content="Top Center 提示文字"
      placement="bottom"
      ref="tooltip"
      :disabled="tooltipShow"
    >
      <!-- popover -->
      <!-- 注意点2: 使用ref来命中指定的作用域 -->
      <el-popover width="160" :ref="popover">
        <div style="position: relative">
          <template>
            <el-checkbox
              :indeterminate="isIndeterminate"
              v-model="checkAll"
              @change="handleCheckAllChange"
            >列表展示</el-checkbox
            >
            <div style="margin: 15px 0;"></div>
            <el-checkbox-group
              v-model="checkedCities"
              @change="handleCheckedCitiesChange"
            >
              <el-checkbox
                v-for="city in checkedOptions"
                :label="city"
                :key="city"
                >{{city}}</el-checkbox>
            </el-checkbox-group>
          </template>
          <span
            style="position: absolute;top: 0;right: 0;color: rgb(64, 158, 255)"
            >重置</span
          >
        </div>
        <!-- popover 触发源 -->
        <img
          class="ser-img"
          slot="reference"
          src="@/assets/img/set.png"
          alt=""
          @click="closeToolip"
        >
      </el-popover>
    </el-tooltip>
  </div>

</template>

<script>
import { createExportData } from '@/api/commonAPI'
export default {
  name: 'TableList',
  components: {},
  props: {
    checkedOptions: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      tooltipShow: false,
      checkAll: true,
      isIndeterminate: true,
      checkedCities:[] // 勾选的数据
    }
  },
  created() {},
  mounted() {},
  methods: {
    closeToolip() {
      this.tooltipShow = !this.tooltipShow
    },
    handleCheckAllChange(val) {
      this.checkedCities = val ? this.checkedOptions : []
      this.isIndeterminate = false
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length
      this.checkAll = checkedCount === this.checkedOptions.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.checkedOptions.length;
    },
    exportExcel() {
      this.exporting = true
      let _event = event
      const data = {
        params: this.filterForm,
        exportUrl: this.exportUrl
      }
      createExportData(data)
        .then(res => {
          if (res.code === 0) {
            this.$message.success(res.message)
          } else {
            this.$message.error(res.message)
          }
          this.$store.dispatch('app/SetDownloadIconCoord', {
            x: _event.x,
            y: _event.y
          })
          this.$store.dispatch('app/ToggleShowDownloadIcon', true)
        })
        .finally(() => {
          this.exporting = false
        })
    }
  }
}
</script>

<style lang="scss">
.table-list {
  display: inline-block;
  float: right;
  .el-tooltip {
    float: right; //解决整体右浮动.提示语位置偏差
  }
  .ser-img {
    width: 40px;
    height: 40px;
  }
  .reset {
    position: absolute;
    top: 0;
    left: 0;
  }
}
</style>

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值