<template>
    <basic-container>
        <el-tabs v-model="tabPosition" class="demo-tabs" @tab-change="tabPositionChange">
            <el-tab-pane label="物料类别" name="materialCategory"></el-tab-pane>
            <el-tab-pane label="物料标记" name="materialMarking"></el-tab-pane>
        </el-tabs>
        <avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page" ref="crud"
            @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
            @refresh-change="refreshChange" @on-load="onLoad">
        </avue-crud>
    </basic-container>
</template>

<script>
import materialAttribute from './js/materialAttribute'
export default {
    data() {
        return {
            tabPosition: 'materialCategory',
            option: {
                columnSort: true,
                tip: false,
                height: 'auto',
                align: 'center',
                calcHeight: 32,
                simplePage: false,
                searchShow: true,
                searchMenuSpan: 6,
                searchIcon: true,
                searchIndex: 3,
                tree: false,
                border: true,
                index: true,
                selection: false,
                viewBtn: false,
                delBtn: true,
                editBtn: true,
                delBtnIcon: ' ',
                editBtnIcon: ' ',
                addBtn: true,
                labelWidth: 120,
                searchLabelWidth: 120,
                menu: true,
                menuWidth: 200,
                dialogWidth: 600,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: true,
                gridBtn: false,
                searchShowBtn: false,
                showOverflowTooltip: true,
                searchLabelPosition:'left',
searchLabelPosition:'left',
 searchGutter:24,
  searchSpan:6,
menuAlign: 'left',
gridBtn:false,
searchMenuPosition:'right',
                addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
                column: []
            },
            data: [],
            loading: false,
            form: {},
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            }
        }
    },
    mounted() {
        this.option.column = materialAttribute[this.tabPosition]
    },
    methods: {
        tabPositionChange(val) {
            this.option.column = materialAttribute[this.tabPosition]
            if (this.tabPosition == 'materialMarking') {
                this.data = [
                    {
                        "bcId": 49,
                        "code": "11",
                        "keyValue": 49,
                        "memo": "11",
                        "name": "bj01",
                        "type": 1
                    },
                    {
                        "bcId": 69,
                        "code": "bj02",
                        "keyValue": 69,
                        "memo": "22",
                        "name": "bj02",
                        "type": 1
                    }
                ]
            } else {
                this.data = [
                    {
                        "createTime": "2023-08-10 09:35:48",
                        "deleted": false,
                        "gcCode": "RB_CODE_WL_001",
                        "gcId": 21,
                        "gcName": "RB_CODE_WL_001",
                        "memo": "物料类别",
                        "updateTime": null
                    },
                    {
                        "createTime": "2023-08-10 09:35:59",
                        "deleted": false,
                        "gcCode": "RB_CODE_WL_002",
                        "gcId": 22,
                        "gcName": "RB_CODE_WL_002",
                        "memo": null,
                        "updateTime": null
                    }
                ]
            }
            this.page.total = this.data.length
        },
        rowDel() {
            this.$confirm('确定删除此条数据?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {

            })
        },
        onLoad() {
            this.data = [
                {
                    "createTime": "2023-08-10 09:35:48",
                    "deleted": false,
                    "gcCode": "RB_CODE_WL_001",
                    "gcId": 21,
                    "gcName": "RB_CODE_WL_001",
                    "memo": "物料类别",
                    "updateTime": null
                },
                {
                    "createTime": "2023-08-10 09:35:59",
                    "deleted": false,
                    "gcCode": "RB_CODE_WL_002",
                    "gcId": 22,
                    "gcName": "RB_CODE_WL_002",
                    "memo": null,
                    "updateTime": null
                }
            ]
            this.page.total = this.data.length
        }
    }
}
</script>

<style></style>