<template> <enhance-table ref="table" :multiple="true" :otherTableParams="otherTableParams" :tableColumn="column" /> </template> <script> import EnhanceTable from "../components/EnhanceTable"
export default { data() { return { otherTableParams: {// table的参数 props: { border: true, stripe: true, size: 'small', 'default-sort': {prop: 'createTime', order: 'ascending'} } }, otherPaginationParams:{},// 分页的参数 column: [ // table的列 { prop: "roleId", label: "序号", width: 100, }, { prop: 'roleName', label: "角色名称", 'width': "110" }, { prop: "createTime", label: "创建时间", sortable: true }, { prop: 'roleName', label: "角色名称", //formatter 完全可以用render代替 render: (text, record) => { // 当前行的值,当前行数据 // console.log(record); return <h4>{text}</h4> }, }, { // 最后的操作列,可根据list里面展示要操作的按钮,和回调 type: 'button', width: '118', label: "设置", list: [ {title: '查看', disabled: false, styles: {color: '#777'}, cb: this.seeHandle}, {title: '编辑', cb: this.editHandle} ], // handleButtons: () => (<div>111</div>) // 自定义的内容 } ] } }, components: {EnhanceTable}, methods: { queryList() { // 子组件默认的请求名称 this.$nextTick(async () => { // 因为当前算是父组件,当执行到父组件的created周期才会执行它的子组件,所以这个时候子组件的data的一些方法获取不到,或者可以在mounted周期里面执行异步请求 const {paginationOptions: {pageSize, currentPage}, handlePageData} = this.$refs.table;// 获取子组件mixins里面的参数 const {data: {items, page: {totalRecord}}} = await this.$fetch(`http://xx..xx/role?pageSize=${pageSize}&pageNum=${currentPage}`, { headers: { Authentication: 'xxxxx' }, }); handlePageData(items, totalRecord); // mixin里面统一处理 }); }, editHandle(...options) { console.log(options, '编辑'); }, seeHandle(...options) { console.log(options, '查看'); } }, created() { this.queryList();//必须是这个名称 }, mounted() { } } </script>
<style type="text/scss" lang="scss" scoped>
</style>
|