|
|
@@ -3,7 +3,7 @@ import {
|
|
|
Button, DropdownButton, PaginationProps
|
|
|
} from 'ant-design-vue'
|
|
|
import { DownOutlined } from '@ant-design/icons-vue'
|
|
|
-import { PropType, computed, defineComponent, reactive, ref } from 'vue'
|
|
|
+import { PropType, computed, defineComponent, reactive, ref, defineEmits, FunctionalComponent } from 'vue'
|
|
|
|
|
|
/**
|
|
|
* @description Table Pro 超级table 将各种业务与操作融合起来
|
|
|
@@ -13,153 +13,21 @@ interface GenericListProps<T> {
|
|
|
dataSource: T;
|
|
|
}
|
|
|
|
|
|
-// export default /* #__PURE__ */ defineComponent<T>({
|
|
|
-// name: 'table-pro-v2',
|
|
|
-// props: {
|
|
|
-// columns: {
|
|
|
-// type: Array as PropType<TableColumnProps[]>,
|
|
|
-// default: () => [],
|
|
|
-// required: true
|
|
|
-// },
|
|
|
-// pagination: {
|
|
|
-// type: Object as PropType<PaginationProps> || false,
|
|
|
-// required: true,
|
|
|
-// default: () => {
|
|
|
-// return {
|
|
|
-// page: 1,
|
|
|
-// pageSize: 10,
|
|
|
-// total: 0
|
|
|
-// }
|
|
|
-// }
|
|
|
-// },
|
|
|
-// request: {
|
|
|
-// type: Object as PropType<{get: Function, params: Object}>,
|
|
|
-// default: () => {
|
|
|
-// return {
|
|
|
-// params: {},
|
|
|
-// get: () => {}
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// },
|
|
|
-// emits: ['reload', 'add'],
|
|
|
-// setup (props, ctx) {
|
|
|
-// const { request, columns } = props
|
|
|
-
|
|
|
-// const columnsPro = ref<TableColumnProps & {hidden: boolean} []>(columns.map(column => ({ ...column, hidden: false })))
|
|
|
-
|
|
|
-// const rowCustomized = computed(() => props.columns.map(item => ({ title: item.title, key: item.key })))
|
|
|
-
|
|
|
-// const loading = ref<Boolean>(false)
|
|
|
-
|
|
|
-// const dataSource = ref([])
|
|
|
-
|
|
|
-// const pagination = reactive<PaginationProps>(Object.assign({}, {
|
|
|
-// current: 1,
|
|
|
-// pageSize: 10,
|
|
|
-// total: 0,
|
|
|
-// onChange: (page: number, pageSize: number) => onChangePage(page, pageSize)
|
|
|
-// }, { ...props.pagination }))
|
|
|
-
|
|
|
-// const opraMeun = (
|
|
|
-// <Menu>
|
|
|
-// <Menu.item key={0} onClick={ctx.emit('add')} > 新增 </Menu.item>
|
|
|
-// <Menu.item key={2} onClick={() => exportExcel()}> 导出 </Menu.item>
|
|
|
-// <Menu.item key={3} onClick={() => pure()}> 纯净 </Menu.item>
|
|
|
-// </Menu>
|
|
|
-// )
|
|
|
-
|
|
|
-// const exportExcel = () => {}
|
|
|
-
|
|
|
-// const pure = () => {}
|
|
|
-
|
|
|
-// const onChangePage = (page: number, pageSize: number) => {
|
|
|
-// pagination.current = page
|
|
|
-// pagination.pageSize = pageSize
|
|
|
-// dispatchRequest()
|
|
|
-// }
|
|
|
-
|
|
|
-// const dispatchRequest = async () => {
|
|
|
-// loading.value = true
|
|
|
-// const { data, sum } = await request.get({
|
|
|
-// ...request.params,
|
|
|
-// page: pagination.current,
|
|
|
-// pageSize: pagination.pageSize
|
|
|
-// })
|
|
|
-// loading.value = false
|
|
|
-// pagination.total = sum
|
|
|
-// dataSource.value = data
|
|
|
-// }
|
|
|
-
|
|
|
-// const init = () => {
|
|
|
-
|
|
|
-// }
|
|
|
-
|
|
|
-// init()
|
|
|
-
|
|
|
-// return () => (
|
|
|
-// <>
|
|
|
-// <Row gutter={[8, 8]}>
|
|
|
-// <Col>
|
|
|
-// <solt name="search" ></solt>
|
|
|
-// </Col>
|
|
|
-// <Col>
|
|
|
-// <Space>
|
|
|
-// <Tooltip title='列表定制' >
|
|
|
-// {/* @click.prevent */}
|
|
|
-// {/* <a class="ant-dropdown-link"> <menu-outlined /> </a> */}
|
|
|
-// <Dropdown
|
|
|
-// trigger={['click']}
|
|
|
-// overlay={
|
|
|
-// <Menu>
|
|
|
-// {
|
|
|
-// rowCustomized.value.map(item => (
|
|
|
-// <Menu.item key={item.key}>
|
|
|
-// {item.title}
|
|
|
-// </Menu.item>
|
|
|
-// ))
|
|
|
-// }
|
|
|
-// </Menu>}
|
|
|
-// >
|
|
|
-// </Dropdown>
|
|
|
-// </Tooltip>
|
|
|
-// {/* @click.prevent */}
|
|
|
-// {/* <a class="ant-dropdown-link"> <menu-outlined /> </a> */}
|
|
|
-// <DropdownButton
|
|
|
-// trigger={['click']}
|
|
|
-// overlay={opraMeun}
|
|
|
-// icon={<DownOutlined />}
|
|
|
-// onClick={dispatchRequest}
|
|
|
-// >
|
|
|
-// <Button>操作</Button>
|
|
|
-// </DropdownButton>
|
|
|
-// </Space>
|
|
|
-// </Col>
|
|
|
-// </Row>
|
|
|
-// <Table
|
|
|
-// columns={columns}
|
|
|
-// loading={loading}
|
|
|
-// pagination={pagination}
|
|
|
-// dataSource={dataSource}
|
|
|
-// >
|
|
|
-// <slot name='action'></slot>
|
|
|
-// </Table>
|
|
|
-// </>
|
|
|
-// )
|
|
|
-// }
|
|
|
-// })
|
|
|
-
|
|
|
-// export default
|
|
|
-
|
|
|
-const com = defineComponent((props: {
|
|
|
+interface Props {
|
|
|
columns: TableColumnProps[],
|
|
|
pagination: PaginationProps | false
|
|
|
request: {
|
|
|
get: (record: any) => {data, sum},
|
|
|
params: any
|
|
|
}
|
|
|
-}) => {
|
|
|
- const { columns, request } = props
|
|
|
+}
|
|
|
+
|
|
|
+const TablePro: FunctionalComponent<Props> = (props) => {
|
|
|
+ const { request } = props
|
|
|
+
|
|
|
+ console.log('defineComponent:', props)
|
|
|
+
|
|
|
+ const columns = [{ title: '', key: 'ky' }]
|
|
|
|
|
|
const emits = defineEmits(['add'])
|
|
|
|
|
|
@@ -219,13 +87,14 @@ const com = defineComponent((props: {
|
|
|
columnsPro.value[index].hidden = !columnsPro.value[index].hidden
|
|
|
}
|
|
|
|
|
|
- return () => (
|
|
|
+ return (
|
|
|
<>
|
|
|
+
|
|
|
<Row gutter={[8, 8]}>
|
|
|
- <Col>
|
|
|
- <solt name="search" ></solt>
|
|
|
+ <Col span={12} >
|
|
|
+ {/* <solt name="search" ></solt> */}
|
|
|
</Col>
|
|
|
- <Col>
|
|
|
+ <Col span={12} >
|
|
|
<Space>
|
|
|
<Tooltip title='列表定制' >
|
|
|
{/* @click.prevent */}
|
|
|
@@ -235,11 +104,11 @@ const com = defineComponent((props: {
|
|
|
overlay={
|
|
|
<Menu>
|
|
|
{
|
|
|
- rowCustomized.value.map((item, index) => (
|
|
|
- <Menu.item key={item.key} onClick={() => swicthColumn(index)} >
|
|
|
- {item.title}
|
|
|
- </Menu.item>
|
|
|
- ))
|
|
|
+ // rowCustomized.value.map((item, index) => (
|
|
|
+ // <Menu.item key={item.key} onClick={() => swicthColumn(index)} >
|
|
|
+ // {item.title}
|
|
|
+ // </Menu.item>
|
|
|
+ // ))
|
|
|
}
|
|
|
</Menu>}
|
|
|
>
|
|
|
@@ -259,20 +128,16 @@ const com = defineComponent((props: {
|
|
|
</Col>
|
|
|
</Row>
|
|
|
{/* dataSource={dataSource} */}
|
|
|
- <Table
|
|
|
+ {/* <Table
|
|
|
columns={columnsFilter.value}
|
|
|
loading={loading.value}
|
|
|
pagination={typeof props.pagination === 'boolean' ? false : pagination}
|
|
|
-
|
|
|
>
|
|
|
<slot></slot>
|
|
|
<slot name='action'></slot>
|
|
|
- </Table>
|
|
|
+ </Table> */}
|
|
|
</>
|
|
|
)
|
|
|
-})
|
|
|
-
|
|
|
-export {
|
|
|
- com
|
|
|
- // 这里直接导出ref有没有可能优雅一些
|
|
|
}
|
|
|
+
|
|
|
+export default TablePro
|