|
|
@@ -1,13 +1,10 @@
|
|
|
import {
|
|
|
- TableColumnProps, Table, Row, Col, Space, Tooltip, Dropdown, Menu,
|
|
|
- Button, DropdownButton, PaginationProps
|
|
|
+ TableColumnProps, Table, Row, Col, Space, Dropdown, Menu,
|
|
|
+ Button, DropdownButton
|
|
|
} from 'ant-design-vue'
|
|
|
import { DownOutlined, CheckOutlined } from '@ant-design/icons-vue'
|
|
|
import {
|
|
|
- PropType, computed, defineComponent, reactive, ref, defineEmits, FunctionalComponent,
|
|
|
- onMounted,
|
|
|
- toRefs,
|
|
|
- watch
|
|
|
+ PropType, computed, defineComponent, ref, onMounted, toRefs, Teleport, cloneVNode
|
|
|
} from 'vue'
|
|
|
|
|
|
/**
|
|
|
@@ -84,17 +81,29 @@ const TablePro = defineComponent({
|
|
|
paginationRef.value.pageSize = pageSize
|
|
|
}
|
|
|
|
|
|
- const changeColumnActive = (index: number) => {
|
|
|
- columnsPro.value[index]._active = !columnsPro.value[index]._active
|
|
|
- }
|
|
|
+ const pureVisible = ref(true)
|
|
|
|
|
|
onMounted(() => {
|
|
|
service && dispatchRequest()
|
|
|
})
|
|
|
|
|
|
+ const pure = () => {
|
|
|
+ pureVisible.value = false
|
|
|
+
|
|
|
+ const pureNode = document.getElementById('teleport-full-container')
|
|
|
+ pureNode!.style.zIndex = '1000'
|
|
|
+ const close = () => {
|
|
|
+ pureVisible.value = true
|
|
|
+ pureNode!.style.zIndex = '-1'
|
|
|
+ pureNode?.removeEventListener('click', close)
|
|
|
+ }
|
|
|
+ pureNode?.addEventListener('click', close)
|
|
|
+ }
|
|
|
+
|
|
|
const opraMeun = (
|
|
|
<Menu>
|
|
|
<Menu.Item key={0} onClick={() => ctx.emit('add')} > 新增 </Menu.Item>
|
|
|
+ <Menu.Item key={1} onClick={() => pure()} > 放大 </Menu.Item>
|
|
|
</Menu>
|
|
|
)
|
|
|
|
|
|
@@ -102,61 +111,64 @@ const TablePro = defineComponent({
|
|
|
|
|
|
return () => (
|
|
|
|
|
|
- <Row style={{ width: '100%' }} >
|
|
|
- <Col span={24} >
|
|
|
- <Row style={{ width: '100%' }} >
|
|
|
- <Col span={12} >
|
|
|
- {ctx.slots.search?.()}
|
|
|
- </Col>
|
|
|
- <Col span={12} style={{ display: 'flex', justifyContent: 'end' }} >
|
|
|
- <Space>
|
|
|
- <Dropdown
|
|
|
- onUpdate:open={ () => columnsProPlanVisible.value = !columnsProPlanVisible.value }
|
|
|
- open={ columnsProPlanVisible.value}
|
|
|
- overlay={
|
|
|
- <Menu
|
|
|
- >
|
|
|
- {
|
|
|
- columnsPro.value.map((column, index) =>
|
|
|
- <Menu.Item key={column.key} onClick={ () => column._active = !column._active } >
|
|
|
- <Row gutter={[8, 8]} justify='space-between' >
|
|
|
- <Col>{column.title}</Col>
|
|
|
- <Col>{column._active ? <CheckOutlined /> : null}</Col>
|
|
|
- </Row>
|
|
|
- </Menu.Item>
|
|
|
- )
|
|
|
- }
|
|
|
- </Menu>
|
|
|
- }
|
|
|
- >
|
|
|
- <Button type={ hiddenMeunKeys.value.length !== 1 ? 'default' : 'primary'} >筛选 { hiddenMeunKeys.value.length !== 1 ? <DownOutlined /> : null }</Button>
|
|
|
- </Dropdown>
|
|
|
- <Dropdown
|
|
|
- trigger={['click', 'hover']}
|
|
|
- overlay={ hiddenMeunKeys.value.length !== 1 ? opraMeun : null}
|
|
|
- >
|
|
|
- <Button onClick={() => reload()} type={ hiddenMeunKeys.value.length !== 1 ? 'default' : 'primary'} >刷新 { hiddenMeunKeys.value.length !== 1 ? <DownOutlined /> : null }</Button>
|
|
|
- </Dropdown>
|
|
|
- </Space>
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- </Col>
|
|
|
- <Col span={24} >
|
|
|
- <Table
|
|
|
- style={{ marginTop: '20px' }}
|
|
|
- columns={columnsPro.value.filter(item => item._active)}
|
|
|
- loading={loading.value}
|
|
|
- pagination={ typeof pagination === 'boolean' ? pagination : { ...paginationRef.value, onChange: onChangePage }}
|
|
|
- dataSource={dataSource.value}
|
|
|
- v-slots={{
|
|
|
- bodyCell (scope) {
|
|
|
- return ctx.slots.render?.({ column: scope.column, record: scope.record })
|
|
|
- }
|
|
|
- }}
|
|
|
- >
|
|
|
- </Table>
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
+ <Row style={{ width: '100%' }} >
|
|
|
+ <Col span={24} >
|
|
|
+ <Row style={{ width: '100%' }} >
|
|
|
+ <Col span={12} >
|
|
|
+ {ctx.slots.search?.()}
|
|
|
+ </Col>
|
|
|
+ <Col span={12} style={{ display: 'flex', justifyContent: 'end' }} >
|
|
|
+ <Space>
|
|
|
+ <DropdownButton
|
|
|
+ onUpdate:open={ () => columnsProPlanVisible.value = !columnsProPlanVisible.value }
|
|
|
+ open={ columnsProPlanVisible.value}
|
|
|
+ overlay={
|
|
|
+ <Menu
|
|
|
+ >
|
|
|
+ {
|
|
|
+ columnsPro.value.map(column =>
|
|
|
+ <Menu.Item key={column.key} onClick={ () => column._active = !column._active } >
|
|
|
+ <Row gutter={[8, 8]} justify='space-between' >
|
|
|
+ <Col>{column.title}</Col>
|
|
|
+ <Col>{column._active ? <CheckOutlined /> : null}</Col>
|
|
|
+ </Row>
|
|
|
+ </Menu.Item>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ </Menu>
|
|
|
+ }
|
|
|
+ >
|
|
|
+ 筛选
|
|
|
+ </DropdownButton>
|
|
|
+ <DropdownButton
|
|
|
+ trigger={['click', 'hover']}
|
|
|
+ overlay={ hiddenMeunKeys.value.length !== 1 ? opraMeun : null}
|
|
|
+ >
|
|
|
+ <div onClick={() => reload()} >刷新 </div>
|
|
|
+ </DropdownButton>
|
|
|
+ </Space>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ </Col>
|
|
|
+ <Col span={24} >
|
|
|
+
|
|
|
+ <Teleport disabled={pureVisible.value} to="#teleport-full-container" >
|
|
|
+ <Table
|
|
|
+ style={{ marginTop: '20px', width: pureVisible.value ? '100%' : '100vw', cursor: 'not-allowed' }}
|
|
|
+ columns={columnsPro.value.filter(item => item._active)}
|
|
|
+ loading={loading.value}
|
|
|
+ pagination={ typeof pagination === 'boolean' ? pagination : { ...paginationRef.value, onChange: onChangePage }}
|
|
|
+ dataSource={columnsPro.value.filter(item => item._active).length ? dataSource.value : []}
|
|
|
+ v-slots={{
|
|
|
+ bodyCell (scope) {
|
|
|
+ return ctx.slots.render?.({ column: scope.column, record: scope.record })
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ </Table>
|
|
|
+ </Teleport>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
|
|
|
)
|
|
|
}
|