mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-19 03:55:50 +08:00
feat(form): table新增showIndex配置,用于控制是否显示行索引
This commit is contained in:
parent
afe1e0f20e
commit
560a3acfae
@ -76,7 +76,7 @@
|
|||||||
width="45"
|
width="45"
|
||||||
></el-table-column>
|
></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>
|
<template v-slot="scope">{{ scope.$index + 1 + pagecontext * pagesize }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
@ -163,12 +163,7 @@ import { asyncLoadJs, sleep } from '@tmagic/utils';
|
|||||||
import { ColumnConfig, FormState, SortProp, TableConfig } from '../schema';
|
import { ColumnConfig, FormState, SortProp, TableConfig } from '../schema';
|
||||||
import { display, initValue } from '../utils/form';
|
import { display, initValue } from '../utils/form';
|
||||||
|
|
||||||
let loadedAMapJS = false; // 是否加载完js
|
|
||||||
let firstLoadingAMapJS = true; // 否是第一次请求
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'm-form-table',
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -215,12 +210,17 @@ export default defineComponent({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showIndex: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['change', 'select'],
|
emits: ['change', 'select'],
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
let timer: NodeJS.Timeout | null = null;
|
let timer: number | null = null;
|
||||||
const mForm = inject<FormState | undefined>('mForm');
|
const mForm = inject<FormState | undefined>('mForm');
|
||||||
|
|
||||||
const elTable = ref<any>();
|
const elTable = ref<any>();
|
||||||
@ -348,20 +348,15 @@ export default defineComponent({
|
|||||||
emit('change', props.model[modelName.value]);
|
emit('change', props.model[modelName.value]);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!loadedAMapJS && firstLoadingAMapJS && !(globalThis as any).XLSX) {
|
if (!(globalThis as any).XLSX) {
|
||||||
firstLoadingAMapJS = false; // 马上置为false 只让第一个created组件去请求js
|
asyncLoadJs('https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js');
|
||||||
asyncLoadJs('https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js')
|
|
||||||
.then(() => {
|
|
||||||
loadedAMapJS = true;
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
firstLoadingAMapJS = true; // 出错置为true 下次进来还是能重新请求js
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.config.defautSort) {
|
if (props.config.defautSort) {
|
||||||
sortChange(props.config.defautSort);
|
sortChange(props.config.defautSort);
|
||||||
|
} else if (props.config.defaultSort) {
|
||||||
|
sortChange(props.config.defaultSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.sort && props.sortKey) {
|
if (props.sort && props.sortKey) {
|
||||||
|
@ -100,7 +100,7 @@ const install = (app: App, opt: any) => {
|
|||||||
app.component(Panel.name, Panel);
|
app.component(Panel.name, Panel);
|
||||||
app.component(Row.name, Row);
|
app.component(Row.name, Row);
|
||||||
app.component(MStep.name, MStep);
|
app.component(MStep.name, MStep);
|
||||||
app.component(Table.name, Table);
|
app.component('m-form-table', Table);
|
||||||
app.component(Tabs.name, Tabs);
|
app.component(Tabs.name, Tabs);
|
||||||
app.component(Text.name, Text);
|
app.component(Text.name, Text);
|
||||||
app.component(Number.name, Number);
|
app.component(Number.name, Number);
|
||||||
|
@ -573,6 +573,7 @@ export interface TableConfig extends FormItem {
|
|||||||
max?: number;
|
max?: number;
|
||||||
maxHeight?: number | string;
|
maxHeight?: number | string;
|
||||||
border?: boolean;
|
border?: boolean;
|
||||||
|
showIndex?: boolean;
|
||||||
enum?: any[];
|
enum?: any[];
|
||||||
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
||||||
delete?: (model: any, index: number, values: any) => boolean | 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;
|
defaultAdd?: (mForm: FormState | undefined, data: any) => any;
|
||||||
onSelect?: (mForm: FormState | undefined, data: any) => any;
|
onSelect?: (mForm: FormState | undefined, data: any) => any;
|
||||||
defautSort?: SortProp;
|
defautSort?: SortProp;
|
||||||
|
defaultSort?: SortProp;
|
||||||
dropSort?: boolean;
|
dropSort?: boolean;
|
||||||
enableFullscreen?: boolean;
|
enableFullscreen?: boolean;
|
||||||
fixed?: boolean;
|
fixed?: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user