antd-vue表格二次封装定制化

在这里插入图片描述
index.vue

<template>
  <div class="table">
    <a-table
      :row-selection="
        isRowSelection
          ? {
              selectedRowKeys: selectedRowKeys,
              onChange: onSelectChange,
            }
          : null
      "
      :loading="loading"
      :locale="locale"
      :columns="columnsData"
      :components="components"
      :data-source="sourceData"
      :pagination="false"
      :scroll="isScroll ? { x: scrollXwidth } : {}"
      :defaultExpandedRowKeys="defaultExpandedRowKeys"
      @change="handleTableChange"
    >
      <!-- 角色管理 -->
      <div
      slot="filterDropdown"
      class="filter-dropdown"
    >
      <a-row>
        <a-col :span="24">
          <a-col :span="5">企业管理员:</a-col>
          <a-col :span="19" class="num-style">{
   {
   countRoleData.adminTotal}}</a-col>
          <a-col :span="24" class="c9">(支持查看所有页面、管理演练员工、编辑模板、发布/删除演练、管理团队成员)</a-col>
        </a-col>
        <a-col :span="24">
          <a-col :span="4">操作者:</a-col>
          <a-col :span="19" class="num-style">{
   {
   countRoleData.handlersTotal}}</a-col>
          <a-col :span="24" class="c9">(支持查看数据报表、管理演练员工、编辑模板、发布演练)</a-col>
        </a-col>
        <a-col :span="24">
          <a-col :span="4">查看者:</a-col>
          <a-col :span="19" class="num-style">{
   {
   countRoleData.viewerTotal}}</a-col>
          <a-col :span="24" class="c9">(支持查看数据报表、查看演练数据)</a-col>
        </a-col>
      </a-row>
    </div>
    <icon
      slot="filterIcon"
      slot-scope="filtered"
      name="warning-circle"
      :style="{ color: filtered ? '' : undefined }"
    />
      <!-- defaultHeader 为true时 表头定制 -->
      <template v-for="(componentObj, key) in customTitleObj" :slot="key">
        <span :key="key">
          <component :is="componentObj" />
        </span>
      </template>

      <!-- slot -->
      <template
        v-for="(col, index) in slotList"
        :slot="col.dataIndex"
        slot-scope="text, record"
      >
        <span :key="index">
          <!-- 有定制展示某一列的走此处 -->
          <template v-if="slotObj[col.dataIndex]">
            <component
              :is="slotObj[col.dataIndex].colComponent"
              :record="record"
              :text="text"
              :dataIndex="col.dataIndex"
              @operationFuClick="operationClick"
            />
          </template>
          <!-- 没有定制展示某一列的走此处 -->
          <template v-else>
            <template
              v-if="
                text === '' ||
                text === null ||
                text === undefined ||
                typeof text === 'null' ||
                typeof text === 'undefined'
              "
            >
              <span v-if="col.config.tableType === 'overdue'">全部</span>
              <span v-else-if="col.config.type != 'switch'">暂无</span>
            </template>

            <template v-else-if="col.config.type === 'popover'">
              <a-popover placement="topLeft">
                <template slot="content">
                  <div style="max-width: 200px">{
   {
    text }}</div>
                </template>
                <div
                  class="ellipsis"
                  :style="{
                    'max-width': col.config.maxWidth
                      ? col.config.maxWidth
                      : '90%',
                  }"
                >
                  <span>{
   {
    text }}</span>
                </div>
              </a-popover>
            </template>

            <template v-else-if="col.config.type === 'switch'">
              <a-switch
                :default-checked="text"
                @change="
                  (val) => {
                    operationClick({}, record, {
                      switchValue: { dataIndex: col.dataIndex, value: val },
                    });
                  }
                "
              />
            </template>
            <template v-else>
              <span v-if="col.config.showZero">{
   {
    text }}</span>
              <span v-else>{
   {
    text == 0 ? "暂无" : text }}</span>
            </template>
          </template>
        </span>
      </template>

      <!-- 操作栏定制 -->
      <template slot="operation" slot-scope="text, record">
        <template v-if="operationObj[record.op_id]">
          <span
            v-for="(item, index) in operationObj[record.op_id]"
            :key="index + 'operation'"
            class="table-icon_wrap"
          >
            <!-- 有定制化按钮 -->
            <template
              v-if="
                item.operationComName && optationNameObj[item.operationComName]
              "
            >
              <!-- //权限判断(buttonHash[item.buttonHash] || !item.buttonHash) -->
              <!-- v-if="buttonHash(item.buttonHash) || !item.buttonHash" -->
              <component
                :is="optationNameObj[item.operationComName]"
                
                :record="record"
                :item="item"
                @operationFuClick="operationClick"
              />
            </template>
            <template v-else-if="item.operationComponent">
              <!-- //权限判断(buttonHash[item.buttonHash] || !item.buttonHash) -->
              <!-- v-if="buttonHash(item.buttonHash) || !item.buttonHash" -->
              <component
                :is="item.operationComponent"
                
                :record="record"
                :item="item"
                @operationFuClick="operationClick"
              />
            </template>
            <!-- 默认 -->
            <template v-else>
              <a-tooltip>
                <template slot="title">{
   {
    item.name }}</template>
                <!-- v-if="buttonHash(item.buttonHash) || !item.buttonHash" -->
                <div
                  
                  class="option-btn"
                  @click="operationClick(item, record)"
                >
                  <icon :name="item.icon" />
                
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

左撇子没秃头

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值