vben admin form 表单 常见问题

1.template中的代码

<BasicTable @register="registerTable" :canResize="false">
        <!-- 表格左边的插槽 -->
      <template #tableTitle>
        <div class="btn-group">
          <a-button
            ghost
            type="primary"
            preIcon="ant-design:plus-circle-outlined"
            @click="handleCreate"
            >新增</a-button
          >
          <a-button ghost type="success" preIcon="ant-design:vertical-align-bottom-outlined">
            导入</a-button
          >
          <a-button ghost type="warning" preIcon="ant-design:upload-outlined">导出</a-button>
          <a-button ghost type="danger" preIcon="ant-design:delete-outlined">删除</a-button>
        </div>
      </template>
      <!-- 表格右边的插槽 -->
      <!-- <template #toolbar> </template> -->
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              label: '详情',
              color: 'success',
              onClick: queryDetails.bind(null, record),
            },
            {
              label: '编辑',
              onClick: handleEdit.bind(null, record),
            },
            {
              label: '删除',
              color: 'error',
              popConfirm: {
                title: '是否删除该数据',
                confirm: handleDelete.bind(null, record),
              },
            },
            {
              label: '生成代码',
              color: 'warning',
              onClick: handleCode.bind(null, record),
            },
          ]"
        />
      </template>
    </BasicTable>
2.script中代码:

const [registerTable, { reload }] = useTable({
         api: list,  // 请求接口
        columns: columns, // 设置表格的表头
        dataSource: dataSources, //表格的数据
        formConfig: {
            labelWidth: 80,
          schemas: searchFormSchema,
          resetFunc: resetFunc,
        },
        pagination: true,   //展示表格下方的分页
        clickToRowSelect: true, //点击当前行多选框不选中,默认是true
        // striped: false,  //是否斑马纹(隔行变色),默认true
        rowSelection: { type: 'checkbox' },   //是否有多选功能
        useSearchForm: true, // 是否有搜索功能
        // showTableSetting: true,  // 是否有刷新和列设置
        bordered: false, // 是否显示边框
        showIndexColumn: true, // 是否显示序号列
        actionColumn: {
          width: 240,
          title: '操作',
          dataIndex: 'action',
          slots: { customRender: 'action' },
        },
      });
 

猜你喜欢

转载自blog.csdn.net/lyinshaofeng/article/details/128220429
今日推荐