<template>
    <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>
</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: 640,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: false,
                filterBtn: true,
                searchShowBtn: false,
                columnSort: true,
                excelBtn: true,
                columnSort: true,
                index: false,
                showOverflowTooltip: true,
                column: [
                    {
                        label: '作业中心',
                        prop: 'workCenterNames',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入日期',
                                trigger: 'blur'
                            }
                        ]
                    },
                    {
                        label: '设备',
                        prop: 'deEquipmentCard.deviceName',
                        bind:'deEquipmentCard.deviceName',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: '请输入日期',
                                trigger: 'blur'
                            }
                        ]
                    },
                    {
                        label: '日期',
                        prop: 'uqDate',
                        search: true,
                        sortable: true,
                        filter: true,
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: '请输入日期',
                                trigger: 'blur'
                            }
                        ]
                    },
                    {
                        label: '定额单位面积用电量(kWh/dm²)',
                        prop: 'useElectric',
                        search: false,
                        sortable: true,
                        filter: true,
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: '请输入日期',
                                trigger: 'blur'
                            }
                        ]
                    },

                ]
            },
            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 = [
                {
                    "bsTeamSet": null,
                    "bsWorkCenter": {
                        "area": 13000.0,
                        "batchNo": null,
                        "bigBatch": false,
                        "bsJfCenter": {
                            "createMan": {
                                "userId": 1,
                                "userName": "admin"
                            },
                            "createTime": "2024-12-09 00:00:00",
                            "deleted": false,
                            "jcCode": "RBZX",
                            "jcId": 1,
                            "jcName": "热表中心",
                            "keyValue": 1,
                            "updateTime": "2024-12-09 00:00:00"
                        },
                        "checkout": false,
                        "craftAbility": "化学镀镍",
                        "createMan": {
                            "userId": 1,
                            "userName": "admin"
                        },
                        "createTime": "2023-02-06 12:31:36",
                        "deleted": false,
                        "describe": null,
                        "endPoint": null,
                        "keyValue": 81,
                        "leaderUser": {
                            "userId": 541,
                            "userName": "崔殿龙"
                        },
                        "limitType": 0,
                        "processes": "上挂、下挂、交检、化学镀镍、喷砂",
                        "quantity": null,
                        "roundCycle": null,
                        "saturation": 85.0,
                        "sign": "4",
                        "startPoint": null,
                        "team": "化学镀镍一班崔胜伟、化学镀镍一班郭家梁",
                        "updateTime": "2023-03-06 18:42:47",
                        "wcCode": "001",
                        "wcId": 81,
                        "wcName": "化学镀镍作业中心",
                        "whetherPlate": false
                    },
                    "createMan": {
                        "userId": 1,
                        "userName": "admin"
                    },
                    "createTime": "2025-04-09 11:27:09",
                    "deEquipmentCard": {
                        "bindQty": 4,
                        "categorys": "产线设备",
                        "deviceCode": "9652247",
                        "deviceIp": "192.168.43.179",
                        "deviceName": "化学镀镍",
                        "docking": true,
                        "ecId": 1,
                        "keyValue": 1,
                        "macCode": "9652247",
                        "macSpec": null,
                        "memo": null,
                        "rfId": "SYM-HCP-L4",
                        "status": true,
                        "typeName": "9652247",
                        "updateTime": null,
                        "used": 1,
                        "usedText": "正常服役",
                        "virtualMac": false
                    },
                    "keyValue": 121,
                    "pureWater": 1.0,
                    "quotaArea": 0.0,
                    "tapWater": 1.0,
                    "updateTime": "2025-04-09 11:27:09",
                    "uqDate": "2025-04-09",
                    "uqId": 121,
                    "uqType": 0,
                    "useElectric": 0.0,
                    "workCenterId": "[81]",
                    "workCenterName": "[\"化学镀镍作业中心\"]",
                    "workCenterNames": "化学镀镍作业中心"
                }
            ]
            this.page.total = this.data.length
            this.loading = false
            setTimeout(() => {
                this.selectionClear()
            }, 500)
        }
    }
}
</script>
<style lang="scss" scoped></style>