<template>
    <basic-container>
        <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">
            <template #menu-left>
                <el-button type="danger" icon="el-icon-delete" @click="handleDelete">删除
                </el-button>
            </template>
            <template #menu-right>
                <el-button type="primary" icon="el-icon-upload" @click="handleImport">导入
                </el-button>
            </template>
            <template #menu="scope">
                
            </template>

        </avue-crud>
    </basic-container>
</template>
<script>
export default {
    data() {
        return {
            selectionList: [],
            option: {
                height: 'auto',
                calcHeight: 32,
                tip: false,
                size: 'medium',
                simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                searchIcon: true,
                searchIndex: 3,
                tree: false,
                border: true,
                index: true,
                selection: true,
                viewBtn: false,
                delBtn: false,
                addBtn: true,
                editBtnText: '修改',
                viewBtnIcon: ' ',
                delBtnIcon: ' ',
                editBtnIcon: ' ',
                viewBtnText: '详情',
                labelWidth: 120,
                menuWidth: 180,
                dialogWidth: 1040,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: false,
                filterBtn: true,
                searchShowBtn: false,
                columnSort: true,
                excelBtn: true,
                columnSort: true,
                index: false,
                showOverflowTooltip: true,
                searchLabelPosition:'left',
searchLabelPosition:'left',
 searchGutter:24,
  searchSpan:6,
menuAlign: 'left',
gridBtn:false,
searchMenuPosition:'right',
addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',

                column: [
                    {
                        label: '日期',
                        prop: 'emMonth',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: true,
                        width: 130,
                        rules: [
                            {
                                required: true,
                                message: '请输入日期',
                                trigger: 'blur'
                            }
                        ]
                    },
                    {
                        label: '上年度月用水',
                        prop: 'lastYearWater',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 140,

                    },
                    {
                        label: '上年度月用电',
                        prop: 'lastYearElectric',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 140,

                    },
                    {
                        label: '上年度月产值',
                        prop: 'lastYearNum',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 140,

                    },
                    {
                        label: '本年度月用水',
                        prop: 'yearWater',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 140,

                    },
                    {
                        label: '本年度月用电',
                        prop: 'yearElectric',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 140,

                    },
                    {
                        label: '本年度月产值',
                        prop: 'yearNum',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 140,

                    },
                    {
                        label: '本年度月用水目标',
                        prop: 'yearWaterTarget',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 170,

                    },
                    {
                        label: '本年度月用电目标',
                        prop: 'yearElectricTarget',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 170,

                    },
                    {
                        label: '上年度月用水实际完成',
                        prop: 'lastYearWaterOk',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 200,

                    },
                    {
                        label: '上年度月用电实际完成',
                        prop: 'lastYearWaterOk',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 200,

                    },
                    {
                        label: '上年度月用水实际完成',
                        prop: 'lastYearElectricOk',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 200,

                    },
                    {
                        label: '本年度月用电实际完成',
                        prop: 'yearWaterOk',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 200,

                    },
                    {
                        label: '本年度月用水实际完成',
                        prop: 'yearElectricOk',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 200,

                    },
                    {
                        label: '创建人',
                        prop: 'userName',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 140,

                    },
                    {
                        label: '创建时间',
                        prop: 'uploadTime',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 12,
                        width: 140,

                    },
                ]
            },
            form: {

            },
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
        }
    },
    methods: {
        handleDelete() {
            if (this.selectionList.length === 0) {
                this.$message.warning('请选择至少一条数据');
                return;
            }
            this.$confirm('确定将选择数据删除?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
            })
        },
        // 多选
        selectionChange(list) {
            this.selectionList = list;
        },
        onLoad() {
            this.loading = true
            this.data = [
                {
                    "createMan": {
                        "accountId": null,
                        "card": null,
                        "createTime": "2022-08-31",
                        "curStatus": 1,
                        "deleted": false,
                        "deptName": null,
                        "dimissionTime": null,
                        "factoryId": 41,
                        "head": 0,
                        "jobName": "总工",
                        "keyValue": 1,
                        "ldapName": "admin",
                        "mail": "13699999999@136.com",
                        "mobile": "13699999999",
                        "pfDepartment": {
                            "appLink": null,
                            "createTime": "2022-08-31",
                            "deleted": false,
                            "deptCode": "001",
                            "deptId": 1,
                            "deptName": "MES开发部",
                            "deptType": 1,
                            "deptTypeTitle": "厂",
                            "keyValue": 1,
                            "memo": null,
                            "orders": "00",
                            "parentDeptId": null,
                            "parentPath": null,
                            "ucDeptId": null,
                            "updateTime": "2022-08-31 16:32:46"
                        },
                        "pinyinIndex": "ADMIN,ADMIN",
                        "ucUserId": null,
                        "updateTime": "2022-08-31 16:32:46",
                        "userCode": "00",
                        "userId": 1,
                        "userName": "admin",
                        "userSex": 1,
                        "userSources": "admin",
                        "userString": "1:A:admin",
                        "userType": "A"
                    },
                    "emId": 5,
                    "emMonth": "2024-06-01 00:00:00",
                    "keyValue": 5,
                    "lastYearElectric": "33",
                    "lastYearElectricOk": null,
                    "lastYearNum": null,
                    "lastYearWater": "23",
                    "lastYearWaterOk": null,
                    "uploadTime": "2024-05-30 18:25:52",
                    "yearElectric": null,
                    "yearElectricOk": null,
                    "yearElectricTarget": null,
                    "yearNum": null,
                    "yearWater": null,
                    "yearWaterOk": null,
                    "yearWaterTarget": null
                },
                {
                    "createMan": {
                        "accountId": null,
                        "card": null,
                        "createTime": "2022-08-31",
                        "curStatus": 1,
                        "deleted": false,
                        "deptName": null,
                        "dimissionTime": null,
                        "factoryId": 41,
                        "head": 0,
                        "jobName": "总工",
                        "keyValue": 1,
                        "ldapName": "admin",
                        "mail": "13699999999@136.com",
                        "mobile": "13699999999",
                        "pfDepartment": {
                            "appLink": null,
                            "createTime": "2022-08-31",
                            "deleted": false,
                            "deptCode": "001",
                            "deptId": 1,
                            "deptName": "MES开发部",
                            "deptType": 1,
                            "deptTypeTitle": "厂",
                            "keyValue": 1,
                            "memo": null,
                            "orders": "00",
                            "parentDeptId": null,
                            "parentPath": null,
                            "ucDeptId": null,
                            "updateTime": "2022-08-31 16:32:46"
                        },
                        "pinyinIndex": "ADMIN,ADMIN",
                        "ucUserId": null,
                        "updateTime": "2022-08-31 16:32:46",
                        "userCode": "00",
                        "userId": 1,
                        "userName": "admin",
                        "userSex": 1,
                        "userSources": "admin",
                        "userString": "1:A:admin",
                        "userType": "A"
                    },
                    "emId": 4,
                    "emMonth": "2024-01-01 00:00:00",
                    "keyValue": 4,
                    "lastYearElectric": null,
                    "lastYearElectricOk": null,
                    "lastYearNum": null,
                    "lastYearWater": "1",
                    "lastYearWaterOk": null,
                    "uploadTime": "2024-05-30 18:20:05",
                    "yearElectric": null,
                    "yearElectricOk": null,
                    "yearElectricTarget": null,
                    "yearNum": null,
                    "yearWater": null,
                    "yearWaterOk": null,
                    "yearWaterTarget": null
                }
            ]
            this.page.total = this.data.length
            this.loading = false
            setTimeout(() => {
                this.selectionClear()
            }, 500)
        }
    }
}
</script>
<style lang="scss" scoped></style>