feat(form): table新增showIndex配置,用于控制是否显示行索引

This commit is contained in:
roymondchen 2022-09-20 20:21:52 +08:00 committed by jia000
parent afe1e0f20e
commit 560a3acfae
3 changed files with 14 additions and 17 deletions

View File

@ -76,7 +76,7 @@
width="45"
></el-table-column>
<el-table-column width="60" label="序号">
<el-table-column width="60" label="序号" v-if="showIndex">
<template v-slot="scope">{{ scope.$index + 1 + pagecontext * pagesize }}</template>
</el-table-column>
@ -163,12 +163,7 @@ import { asyncLoadJs, sleep } from '@tmagic/utils';
import { ColumnConfig, FormState, SortProp, TableConfig } from '../schema';
import { display, initValue } from '../utils/form';
let loadedAMapJS = false; // js
let firstLoadingAMapJS = true; //
export default defineComponent({
name: 'm-form-table',
props: {
name: {
type: String,
@ -215,12 +210,17 @@ export default defineComponent({
type: Boolean,
default: true,
},
showIndex: {
type: Boolean,
default: true,
},
},
emits: ['change', 'select'],
setup(props, { emit }) {
let timer: NodeJS.Timeout | null = null;
let timer: number | null = null;
const mForm = inject<FormState | undefined>('mForm');
const elTable = ref<any>();
@ -348,20 +348,15 @@ export default defineComponent({
emit('change', props.model[modelName.value]);
};
if (!loadedAMapJS && firstLoadingAMapJS && !(globalThis as any).XLSX) {
firstLoadingAMapJS = false; // false createdjs
asyncLoadJs('https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js')
.then(() => {
loadedAMapJS = true;
})
.catch(() => {
firstLoadingAMapJS = true; // true js
});
if (!(globalThis as any).XLSX) {
asyncLoadJs('https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js');
}
onMounted(() => {
if (props.config.defautSort) {
sortChange(props.config.defautSort);
} else if (props.config.defaultSort) {
sortChange(props.config.defaultSort);
}
if (props.sort && props.sortKey) {

View File

@ -100,7 +100,7 @@ const install = (app: App, opt: any) => {
app.component(Panel.name, Panel);
app.component(Row.name, Row);
app.component(MStep.name, MStep);
app.component(Table.name, Table);
app.component('m-form-table', Table);
app.component(Tabs.name, Tabs);
app.component(Text.name, Text);
app.component(Number.name, Number);

View File

@ -573,6 +573,7 @@ export interface TableConfig extends FormItem {
max?: number;
maxHeight?: number | string;
border?: boolean;
showIndex?: boolean;
enum?: any[];
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
delete?: (model: any, index: number, values: any) => boolean | boolean;
@ -581,6 +582,7 @@ export interface TableConfig extends FormItem {
defaultAdd?: (mForm: FormState | undefined, data: any) => any;
onSelect?: (mForm: FormState | undefined, data: any) => any;
defautSort?: SortProp;
defaultSort?: SortProp;
dropSort?: boolean;
enableFullscreen?: boolean;
fixed?: boolean;