<script>
import BaseComponent from 'primevue/basecomponent';
import DataTableStyle from 'primevue/datatable/style';

export default {
    name: 'BaseDataTable',
    extends: BaseComponent,
    props: {
        value: {
            type: Array,
            default: null
        },
        paginator: {
            type: Boolean,
            default: false
        },
        pageSize:{
            type:Number,
            default:20
        },
        paginatorTemplate: {
            type: [Object, String],
            default: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown'
        },
        pageLinkSize: {
            type: Number,
            default: 5
        },
        rowsPerPageOptions: {
            type: Array,
            default:()=>[20,50,100,200,500,1000] // 解决直接定义为数组时报以下错误 Type of the default value for 'rowsPerPageOptions' prop must be a function 
        },

        currentPageReportTemplate: {
            type: String,
            default: ' {currentPage} / {pageCount}'
        },

        alwaysShowPaginator: {
            type: Boolean,
            default: true
        },
        
        loading: {
            type: Boolean,
            default: false
        },
        loadingIcon: {
            type: String,
            default: undefined
        },
        sortField: {
            type: [String, Function],
            default: null
        },
        sortOrder: {
            type: Number,
            default: null
        },
        defaultSortOrder: {
            type: Number,
            default: 1
        },
        nullSortOrder: {
            type: Number,
            default: 1
        },
        multiSortMeta: {
            type: Array,
            default: null
        },
        sortMode: {
            type: String,
            default: 'single'
        },
        removableSort: {
            type: Boolean,
            default: false
        },
        filters: {
            type: Object,
            default: null
        },
        filterDisplay: {
            type: String,
            default: null
        },
        globalFilterFields: {
            type: Array,
            default: null
        },
        filterLocale: {
            type: String,
            default: undefined
        },
        selection: {
            type: [Array, Object],
            default: null
        },
        selectionMode: {
            type: String,
            default: null
        },
        compareSelectionBy: {
            type: String,
            default: 'deepEquals'
        },
        metaKeySelection: {
            type: Boolean,
            default: false
        },
        contextMenu: {
            type: Boolean,
            default: false
        },
        contextMenuSelection: {
            type: Object,
            default: null
        },
        selectAll: {
            type: Boolean,
            default: null
        },
        rowHover: {
            type: Boolean,
            default: false
        },
        
        csvSeparator: {
            type: String,
            default: ','
        },
        exportFilename: {
            type: String,
            default: 'download'
        },
        exportFunction: {
            type: Function,
            default: null
        },
        resizableColumns: {
            type: Boolean,
            default: false
        },
        columnResizeMode: {
            type: String,
            default: 'fit'
        },
        reorderableColumns: {
            type: Boolean,
            default: false
        },
        expandedRows: {
            type: [Array, Object],
            default: null
        },
        expandedRowIcon: {
            type: String,
            default: undefined
        },
        collapsedRowIcon: {
            type: String,
            default: undefined
        },
        rowGroupMode: {
            type: String,
            default: null
        },
        groupRowsBy: {
            type: [Array, String, Function],
            default: null
        },
        expandableRowGroups: {
            type: Boolean,
            default: false
        },
        expandedRowGroups: {
            type: Array,
            default: null
        },
        stateStorage: {
            type: String,
            default: 'session'
        },
        stateKey: {
            type: String,
            default: null
        },
        rowClass: {
            type: Function,
            default: null
        },
        rowStyle: {
            type: Function,
            default: null
        },
        scrollable: {
            type: Boolean,
            default: true   /*默认改为滚动显示*/
        },
        /*
        scrollHeight: {
            type: String,
            default: null
        },
        */
        frozenValue: {
            type: Array,
            default: null
        },
        breakpoint: {
            type: String,
            default: '960px'
        },
        showGridlines: {
            type: Boolean,
            default: false
        },
        stripedRows: {
            type: Boolean,
            default: false
        },
        highlightOnSelect: {
            type: Boolean,
            default: false
        },
        size: {
            type: String,
            default: null
        },
        tableStyle: {
            type: null,
            default: null
        },
        tableClass: {
            type: [String, Object],
            default: null
        },
        tableProps: {
            type: Object,
            default: null
        },
        filterInputProps: {
            type: null,
            default: null
        },
        currentRowHighlight:{
            type: Boolean,
            default: true
        },
         /*按回车是跳入下一行还是下一列*/
         enterToNextRow:{
            type: Boolean,
            default: false
        },
        disabled:{
             type:Boolean,
             default:false
         },
        readonly:{
            type:Boolean,
            default:false
        },
    },
    style: DataTableStyle,
    provide() {
        return {
            $parentInstance: this
        };
    }
};
</script>
