refactor(table): 重构表格组件使用方式
- 移除 CuteDragTable 和 CuteSimpleTable 组件中的 columns 和 operateColumn 属性- 使用 slot 方式插入表格列和操作列 - 更新表格组件的文档注释 - 调整示例代码以适应新的表格组件用法
This commit is contained in:
@@ -14,35 +14,17 @@
|
||||
@selection-change="onTableSelectionChange"
|
||||
>
|
||||
<el-table-column v-if="mode === 'multi'" type="selection" width="55" />
|
||||
<el-table-column
|
||||
v-for="(column, index) in crud.columns"
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:fixed="column.fixed ? column.fixed:false"
|
||||
:formatter="column.formatter ? column.formatter : null"
|
||||
:width="column.width ? column.width:null"
|
||||
:min-width="column.width ? column.width:null"
|
||||
:show-overflow-tooltip="true"
|
||||
<slot />
|
||||
<el-pagination
|
||||
:current-page="pageProps.current"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
:page-size="pageProps.pageSize"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="pageProps.total"
|
||||
@size-change="(size) => crud.onPageChange(pageProps.current, size, pageProps.total)"
|
||||
@current-change="(current) => crud.onPageChange(current, pageProps.pageSize, pageProps.total)"
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="crud.operateColumn"
|
||||
:width="crud.operateColumn.width"
|
||||
label="操作"
|
||||
:formatter="crud.operateColumn.formatter"
|
||||
:fixed="crud.operateColumn.fixed"
|
||||
/>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
:current-page="pageProps.current"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
:page-size="pageProps.pageSize"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="pageProps.total"
|
||||
@size-change="(size) => crud.onPageChange(pageProps.current, size, pageProps.total)"
|
||||
@current-change="(current) => crud.onPageChange(current, pageProps.pageSize, pageProps.total)"
|
||||
/>
|
||||
</div>
|
||||
</el-table></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -56,16 +38,6 @@ export default {
|
||||
required: true,
|
||||
default: null
|
||||
},
|
||||
columns: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: null
|
||||
},
|
||||
operateColumn: {
|
||||
type: [Object, Boolean],
|
||||
required: true,
|
||||
default: null
|
||||
},
|
||||
fetch: {
|
||||
type: Function,
|
||||
required: false,
|
||||
@@ -103,8 +75,6 @@ export default {
|
||||
crud: {
|
||||
loading: false,
|
||||
primaryKey: this.primaryKey ? this.primaryKey : 'id',
|
||||
columns: this.columns && this.columns.length > 0 ? this.columns : [],
|
||||
operateColumn: this.operateColumn,
|
||||
fetchUrl: null,
|
||||
dataSource: [],
|
||||
onPageChange: (currentPage, pageSize) => {
|
||||
|
||||
@@ -14,24 +14,7 @@
|
||||
@selection-change="onTableSelectionChange"
|
||||
>
|
||||
<el-table-column v-if="mode === 'multi'" type="selection" width="55" />
|
||||
<el-table-column
|
||||
v-for="(column, index) in crud.columns"
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:fixed="column.fixed ? column.fixed:false"
|
||||
:formatter="column.formatter ? column.formatter : null"
|
||||
:width="column.width ? column.width:null"
|
||||
:min-width="column.width ? column.width:null"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="crud.operateColumn"
|
||||
:width="crud.operateColumn.width"
|
||||
label="操作"
|
||||
:formatter="crud.operateColumn.formatter"
|
||||
:fixed="crud.operateColumn.fixed"
|
||||
/>
|
||||
<slot />
|
||||
</el-table>
|
||||
<el-pagination
|
||||
:current-page="pageProps.current"
|
||||
@@ -55,16 +38,6 @@ export default {
|
||||
required: true,
|
||||
default: null
|
||||
},
|
||||
columns: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: null
|
||||
},
|
||||
operateColumn: {
|
||||
type: [Object, Boolean],
|
||||
required: true,
|
||||
default: null
|
||||
},
|
||||
fetch: {
|
||||
type: Function,
|
||||
required: false,
|
||||
@@ -102,8 +75,6 @@ export default {
|
||||
crud: {
|
||||
loading: false,
|
||||
primaryKey: this.primaryKey ? this.primaryKey : 'id',
|
||||
columns: this.columns && this.columns.length > 0 ? this.columns : [],
|
||||
operateColumn: this.operateColumn,
|
||||
fetchUrl: null,
|
||||
dataSource: [],
|
||||
onPageChange: (currentPage, pageSize) => {
|
||||
|
||||
Reference in New Issue
Block a user