|
@@ -1,15 +1,5 @@
|
|
|
<template>
|
|
|
- <div
|
|
|
- ref="wrapRef"
|
|
|
- :class="[
|
|
|
- prefixCls,
|
|
|
- $attrs.class,
|
|
|
- {
|
|
|
- [`${prefixCls}-form-container`]: getBindValues.useSearchForm,
|
|
|
- [`${prefixCls}--inset`]: getBindValues.inset,
|
|
|
- },
|
|
|
- ]"
|
|
|
- >
|
|
|
+ <div ref="wrapRef" :class="getWrapperClass">
|
|
|
<BasicForm
|
|
|
submitOnReset
|
|
|
v-bind="getFormProps"
|
|
@@ -32,9 +22,10 @@
|
|
|
v-show="getEmptyDataIsShowTable"
|
|
|
@change="handleTableChange"
|
|
|
>
|
|
|
- <template #[item]="data" v-for="item in Object.keys($slots)">
|
|
|
+ <template #[item]="data" v-for="item in Object.keys($slots)" :key="item">
|
|
|
<slot :name="item" v-bind="data"></slot>
|
|
|
</template>
|
|
|
+
|
|
|
<template #[`header-${column.dataIndex}`] v-for="column in columns" :key="column.dataIndex">
|
|
|
<HeaderCell :column="column" />
|
|
|
</template>
|
|
@@ -47,8 +38,8 @@
|
|
|
import { defineComponent, ref, computed, unref } from 'vue';
|
|
|
import { Table } from 'ant-design-vue';
|
|
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
|
|
-
|
|
|
- import { omit } from 'lodash-es';
|
|
|
+ import expandIcon from './components/ExpandIcon';
|
|
|
+ import HeaderCell from './components/HeaderCell.vue';
|
|
|
|
|
|
import { usePagination } from './hooks/usePagination';
|
|
|
import { useColumns } from './hooks/useColumns';
|
|
@@ -59,17 +50,16 @@
|
|
|
import { useCustomRow } from './hooks/useCustomRow';
|
|
|
import { useTableStyle } from './hooks/useTableStyle';
|
|
|
import { useTableHeader } from './hooks/useTableHeader';
|
|
|
+ import { useTableExpand } from './hooks/useTableExpand';
|
|
|
import { createTableContext } from './hooks/useTableContext';
|
|
|
import { useTableFooter } from './hooks/useTableFooter';
|
|
|
import { useTableForm } from './hooks/useTableForm';
|
|
|
import { useExpose } from '/@/hooks/core/useExpose';
|
|
|
import { useDesign } from '/@/hooks/web/useDesign';
|
|
|
|
|
|
+ import { omit } from 'lodash-es';
|
|
|
import { basicProps } from './props';
|
|
|
- import expandIcon from './components/ExpandIcon';
|
|
|
- import HeaderCell from './components/HeaderCell.vue';
|
|
|
|
|
|
- import './style/index.less';
|
|
|
export default defineComponent({
|
|
|
components: {
|
|
|
Table,
|
|
@@ -91,6 +81,7 @@
|
|
|
'edit-cancel',
|
|
|
'edit-row-end',
|
|
|
'edit-change',
|
|
|
+ 'expanded-rows-change',
|
|
|
],
|
|
|
setup(props, { attrs, emit, slots }) {
|
|
|
const tableElRef = ref<ComponentRef>(null);
|
|
@@ -175,6 +166,8 @@
|
|
|
|
|
|
const { getRowClassName } = useTableStyle(getProps, prefixCls);
|
|
|
|
|
|
+ const { getExpandOption, expandAll, collapseAll } = useTableExpand(getProps, tableData, emit);
|
|
|
+
|
|
|
const { getHeaderProps } = useTableHeader(getProps, slots);
|
|
|
|
|
|
const { getFooterProps } = useTableFooter(
|
|
@@ -208,6 +201,7 @@
|
|
|
pagination: unref(getPaginationInfo),
|
|
|
dataSource: unref(getDataSourceRef),
|
|
|
footer: unref(getFooterProps),
|
|
|
+ ...unref(getExpandOption),
|
|
|
};
|
|
|
if (slots.expandedRowRender) {
|
|
|
propsData = omit(propsData, 'scroll');
|
|
@@ -218,6 +212,18 @@
|
|
|
return propsData;
|
|
|
});
|
|
|
|
|
|
+ const getWrapperClass = computed(() => {
|
|
|
+ const values = unref(getBindValues);
|
|
|
+ return [
|
|
|
+ prefixCls,
|
|
|
+ attrs.class,
|
|
|
+ {
|
|
|
+ [`${prefixCls}-form-container`]: values.useSearchForm,
|
|
|
+ [`${prefixCls}--inset`]: values.inset,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ });
|
|
|
+
|
|
|
const getEmptyDataIsShowTable = computed(() => {
|
|
|
const { emptyDataIsShowTable, useSearchForm } = unref(getProps);
|
|
|
if (emptyDataIsShowTable || !useSearchForm) {
|
|
@@ -253,6 +259,8 @@
|
|
|
setShowPagination,
|
|
|
getShowPagination,
|
|
|
setCacheColumnsByField,
|
|
|
+ expandAll,
|
|
|
+ collapseAll,
|
|
|
getSize: () => {
|
|
|
return unref(getBindValues).size as SizeType;
|
|
|
},
|
|
@@ -278,9 +286,100 @@
|
|
|
getFormProps,
|
|
|
replaceFormSlotKey,
|
|
|
getFormSlotKeys,
|
|
|
- prefixCls,
|
|
|
+ getWrapperClass,
|
|
|
columns: getViewColumns,
|
|
|
};
|
|
|
},
|
|
|
});
|
|
|
</script>
|
|
|
+<style lang="less">
|
|
|
+ @border-color: #cecece4d;
|
|
|
+
|
|
|
+ @prefix-cls: ~'@{namespace}-basic-table';
|
|
|
+
|
|
|
+ .@{prefix-cls} {
|
|
|
+ &-form-container {
|
|
|
+ padding: 16px;
|
|
|
+
|
|
|
+ .ant-form {
|
|
|
+ padding: 12px 10px 6px 10px;
|
|
|
+ margin-bottom: 16px;
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 4px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &-row__striped {
|
|
|
+ td {
|
|
|
+ background: #fafafa;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &--inset {
|
|
|
+ .ant-table-wrapper {
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-tag {
|
|
|
+ margin-right: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-table-wrapper {
|
|
|
+ padding: 6px;
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 2px;
|
|
|
+
|
|
|
+ .ant-table-title {
|
|
|
+ padding: 0 0 8px 0 !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-table.ant-table-bordered .ant-table-title {
|
|
|
+ border: none !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ .ant-table {
|
|
|
+ width: 100%;
|
|
|
+ overflow-x: hidden;
|
|
|
+
|
|
|
+ &-title {
|
|
|
+ display: flex;
|
|
|
+ padding: 8px 6px;
|
|
|
+ border-bottom: none;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-table-tbody > tr.ant-table-row-selected td {
|
|
|
+ background: fade(@primary-color, 8%) !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-pagination {
|
|
|
+ margin: 10px 0 0 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-table-footer {
|
|
|
+ padding: 0;
|
|
|
+
|
|
|
+ .ant-table-wrapper {
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ table {
|
|
|
+ border: none !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-table-body {
|
|
|
+ overflow-x: hidden !important;
|
|
|
+ overflow-y: scroll !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ td {
|
|
|
+ padding: 12px 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|