antd design 自定义表头

<template>
  <a-card :bordered="false">
    <div class="contentWrap">
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :md="6" :sm="12">
              <a-form-item label="登录账号">
                <a-input placeholder="请输入登录账号" :max-length="40" v-model="queryParam.manufactureEnterprise"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="用户姓名">
                <a-input placeholder="请输入用户姓名" :max-length="40" v-model="queryParam.model"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- 操作按钮区域 -->
      <div class="table-operator" style="border-top: 5px">
        <a-button @click="handleAdd" type="primary" icon="plus">新增账号</a-button>
      </div>
      <!-- table区域-begin -->
      <div>
        <a-table
          ref="table"
          bordered
          size="middle"
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          @change="handleTableChange"
        >
          <template slot="account" slot-scope="text">
            <j-ellipsis :value="text" :length="30"></j-ellipsis>
          </template>
          <template slot="passwordTitle">
            登录密码
            <a-tooltip title="说明" slot="action">
              <a-icon type="info-circle-o" />
            </a-tooltip>
          </template>
          <template slot="passwordType" slot-scope="text">
            <span>
              {{ filterDictText(passwordTypeOption, text) }}
            </span>
          </template>
          <template slot="loginLimit" slot-scope="text">
            <span>
              {{ filterDictText(loginLimitOption, text) }}
            </span>
          </template>
          <template slot="status" slot-scope="text">
            <span>
              {{ filterDictText(statusOption, text) }}
            </span>
          </template>
          <span slot="action" slot-scope="text, record">
            <a v-if="record.passwordType == '原始密码'" @click="handlePwd(record.passwordType)">原始密码</a>
            <a-popconfirm v-else @confirm="() => handlePwd(record.passwordType)">
              <template slot="title">
                <div>是否重置密码?</div>
              </template>
              <a>重置密码</a>
            </a-popconfirm>
            <a-divider type="vertical" />

            <a @click="handleEdit(record)">编辑</a>
            <a-divider type="vertical" />

            <a-popconfirm @confirm="() => handleDelete(record.modelId)">
              <template slot="title">
                <div>删除后该账户无法登陆平台。</div>
                <div>账户不可找回。</div>
              </template>
              <a>删除</a>
            </a-popconfirm>
            <a-divider type="vertical" />
            
            <a-popconfirm @confirm="() => handleStatus(record.modelId)">
              <template slot="title">
                <div>是否改为{{record.status == '启用' ? '禁用' : '启用'}}状态?</div>
              </template>
              <a>{{record.status == '启用' ? '禁用' : '启用'}}</a>
            </a-popconfirm>
          </span>
        </a-table>
      </div>
    </div>
    <AddModal ref="modalForm" @ok="modalFormOk" :loginLimitOption="loginLimitOption" :statusOption="statusOption"></AddModal>
  
  </a-card>
  
</template>

<script>
// @ is an alias to /src
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import AddModal from './modules/AddModal'
import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil'

export default {
  name: 'model',
  mixins: [JeecgListMixin],
  components: { AddModal },
  data() {
    return {
      queryParam: {},
      passwordTypeOption: [],
      loginLimitOption: [],
      statusOption: [],
      columns: [
        {
          title: '登录账户',
          align: 'center',
          dataIndex: 'account',
          scopedSlots: { customRender: 'account' },
          width: 100,
        },
        {
          title: '用户姓名',
          align: 'center',
          dataIndex: 'userName',
          scopedSlots: { customRender: 'userName' },
          width: 100,
        },
        {
          // title: '登录密码',
          // slots: { title: '登录密码' },
          align: 'center',
          width: 100,
          dataIndex: 'passwordType',
          scopedSlots: { customRender: 'passwordType', title: 'passwordTitle' },
        },
        {
          title: '登录权限',
          align: 'center',
          width: 100,
          dataIndex: 'loginLimit',
          scopedSlots: { customRender: 'loginLimit' },
        },
        {
          title: '启用状态',
          align: 'center',
          width: 80,
          dataIndex: 'status',
          scopedSlots: { customRender: 'status' },
        },
        {
          title: '创建时间',
          align: 'center',
          width: 80,
          dataIndex: 'creatTime',
          scopedSlots: { customRender: 'creatTime' },
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
          align: 'center',
          width: 100,
        },
      ],
      url: {
        list: 'jeccgApi'+'/sys/energy/storageCabinetModel/list',
        delete: 'jeccgApi'+'/sys/energy/storageCabinetModel/delete',
      },
    }
  },
  created() {
    this.getDictOptions()
  },
  mounted() {},
  methods: {
    filterDictText,
    getDictOptions() {
      initDictOptions('material_type').then((res) => {
        // console.log('mmmm', res)
        if (res.success) {
          this.passwordTypeOption = res.result
        }
      })
      initDictOptions('material_type').then((res) => {
        // console.log('mmmm', res)
        if (res.success) {
          this.loginLimitOption = res.result
        }
      })
      initDictOptions('material_type').then((res) => {
        // console.log('mmmm', res)
        if (res.success) {
          this.statusOption = res.result
        }
      })
    },
    handleAdd() {
      this.$nextTick(() => {
        this.$refs.modalForm.add()
      })
    },
    handleEdit(row) {
      this.$nextTick(() => {
        this.$refs.modalForm.edit(row)
      })
    },
    modalFormOk() {
      // 新增/修改 成功时,重载列表
      this.loadData(1)
    },
    handlePwd(type) {
      if(type == '原始密码') {
        // 复制密码

      } else {
        // 重置密码
      }
    },
    handleStatus(row) {
      
    }
  },
}
</script>

<style scoped>
</style>

<think>好的,我需要帮助用户了解Ant Designantd)的Table组件表头高度的问题。首先,我应该回忆一下antd Table的相关文档和常见配置。表头高度通常由CSS样式控制,可能涉及到默认值以及如何自定义。 用户可能想知道如何调整表头的高度,或者遇到了表头高度不符合需求的情况。我需要分步骤解释:首先,默认的表头高度是多少;其次,如何通过CSS覆盖默认样式;然后,可能需要提到使用组件提供的API,比如className或style属性;最后,提醒用户注意响应式设计或浏览器兼容性问题。 需要确保回答结构清晰,每一步都有明确的指导。同时,按照用户的要求,所有行内数学表达式用$...$,独立公式用$$...$$,但这里可能更多涉及代码和CSS示例,所以需要正确使用代码块。不过用户没有特别提到代码块的格式,但根据问题类型,代码示例是必要的。 另外,要使用中文回答,避免专业术语错误。可能需要检查antd的最新版本是否有变化,但假设用户使用的是较新版本,保持答案的通用性。最后,确保LaTeX语法正确,尽管在这个问题中可能用不到数学公式,但如果有涉及到计算或尺寸关系的话需要注意。 总结回答的结构:默认高度说明、自定义方法(内联样式、CSS类、全局样式)、注意事项,可能加上示例代码。需要验证每个步骤的正确性,比如正确的CSS类名和属性,例如.ant-table-thead > tr > th。</think>Ant Designantd)的Table组件表头高度可通过以下方式理解与调整: --- ### 1. **默认表头高度** - antd Table的默认表头高度为 **$54px$**(包含上下各$12px$的padding和$1px$的边框)。 - 计算公式为: $$ \text{高度} = \text{内容高度} + \text{padding-top} + \text{padding-bottom} + \text{border宽度} $$ 即: $$ 54px = 28px + 12px + 12px + 2px $$ --- ### 2. **自定义表头高度** #### 方法1:通过CSS覆盖样式 ```css /* 修改全局表头样式 */ .ant-table-thead > tr > th { height: 60px; /* 自定义高度 */ padding: 8px 16px; /* 调整padding */ } ``` #### 方法2:使用`components`API(antd v4+) ```jsx <Table components={{ header: { cell: ({ children, ...props }) => ( <th {...props} style={{ ...props.style, height: 60 }}> {children} </th> ), }, }} /> ``` #### 方法3:内联样式 ```jsx <Table columns={[ { title: '列名', dataIndex: 'data', onHeaderCell: () => ({ style: { height: 60 } }), }, ]} /> ``` --- ### 3. **注意事项** - **内容溢出**:高度减小时需确保标题文本不换行(可配合`white-space: nowrap`)。 - **全局影响**:直接修改`.ant-table-thead`会影响所有Table组件,建议通过`className`局部作用域控制。 - **版本差异**:antd v4与v5的默认高度一致,但样式细节可能有差异,需检查版本文档。 --- 通过上述方法,可灵活控制表头高度以适应业务需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值