<template>
    <div>
        <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="primary" icon="el-icon-plus" @click="addEdit">新增
                </el-button>
                <el-button type="danger" icon="el-icon-delete" @click="handleDelete">删除
                </el-button>
            </template>
            <template #menu-right>

            </template>
            <template #menu="scope">
                <el-button type="text" @click="editFn(scope.row)">编辑
                </el-button>
                <el-button type="text" @click="handleDelete">删除
                </el-button>
            </template>
            <template #produceTsTarget="scope">

            </template>

        </avue-crud>
        <addEditDosing v-if="isOpen" :showDialog="isOpen" @closeDialog="closeDialog"></addEditDosing>
        <workCenterSet v-if="isWorkOpen" :showDialog="isWorkOpen" @closeDialog="closeDialog"></workCenterSet>
    </div>
</template>
<script>
import addEditDosing from './components/addEditDosing.vue'
import workCenterSet from './components/workCenterSet.vue'
export default {
    components: {
        addEditDosing,
        workCenterSet
    },
    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: false,
                editBtn: false,
                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,
                showOverflowTooltip: true,
                column: [
                    {
                        label: '公式名称',
                        prop: 'partCode',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                    },
                    {
                        label: '公式内容',
                        prop: 'subCode',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                    },
                    {
                        label: '操作人',
                        prop: 'subName',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        display: true,
                    },
                    {
                        label: '更新时间',
                        prop: 'subName',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        display: true,
                    },
                ]
            },
            form: {

            },
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            isOpen: false,
            isWorkOpen: false
        }
    },
    methods: {
        addEdit() {
            this.isOpen = true
        },
        editFn(row) {
            this.isWorkOpen = true
        },
        closeDialog() {
            this.isOpen = false
            this.isWorkOpen = false
        },
        maintenanceClick() {
            //   this.$refs.myTable.fullValidate((errMap) => {
            //     if (errMap) {
            //       return;
            //     }
            //     const dataList = this.$refs.myTable.getRecordset().updateRecords;
            //     this.$ajax
            //       .post('oemMerits/maintenance', {
            //         dataList,
            //         status: 2,
            //         type: 'produce'
            //       })
            //       .then((res) => {
            //         if (res.code === 0) {
            //           this.$message.success('维护成功');
            //           this.queryTable();
            //         }
            //       });
            //   });
        },
        proofreadClick() {
            //   const dataList = this.$refs.myTable.getTableData().tableData;
            //   this.$ajax
            //     .post('oemMerits/proofread', {
            //       dataList,
            //       status: 3,
            //       type: 'produce'
            //     })
            //     .then((res) => {
            //       if (res.code === 0) {
            //         this.$message.success('校对成功');
            //         this.queryTable();
            //       }
            //     });
        },
        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 = [
                {
                    "area": null,
                    "configNo": null,
                    "keyValue": 27721,
                    "material": null,
                    "memo": null,
                    "partCode": "21E6-040-4006-B1",
                    "plate": null,
                    "plateCode": null,
                    "plateThickness": null,
                    "prepared": false,
                    "productType": "XXXX",
                    "psId": 27721,
                    "quota": 1.0,
                    "sinTerType": null,
                    "sinTerTypeTitle": null,
                    "subCode": "107-50-003",
                    "subName": null,
                    "subType": "B",
                    "subTypeTitle": "外购件",
                    "updateMan": null,
                    "updateTime": null
                },
                {
                    "area": null,
                    "configNo": null,
                    "keyValue": 27727,
                    "material": null,
                    "memo": null,
                    "partCode": "21E6-040-4271-B1",
                    "plate": null,
                    "plateCode": null,
                    "plateThickness": null,
                    "prepared": false,
                    "productType": "XXXX",
                    "psId": 27727,
                    "quota": 1.0,
                    "sinTerType": null,
                    "sinTerTypeTitle": null,
                    "subCode": "21E6-040-4218-B1",
                    "subName": null,
                    "subType": "A",
                    "subTypeTitle": "组合件",
                    "updateMan": null,
                    "updateTime": null
                },
                {
                    "area": null,
                    "configNo": null,
                    "keyValue": 27728,
                    "material": null,
                    "memo": null,
                    "partCode": "21E6-040-4271-B1",
                    "plate": null,
                    "plateCode": null,
                    "plateThickness": null,
                    "prepared": false,
                    "productType": "XXXX",
                    "psId": 27728,
                    "quota": 1.0,
                    "sinTerType": null,
                    "sinTerTypeTitle": null,
                    "subCode": "05-01-1613",
                    "subName": null,
                    "subType": "B",
                    "subTypeTitle": "外购件",
                    "updateMan": null,
                    "updateTime": null
                }
            ]
            this.page.total = this.data.length
            this.loading = false
            setTimeout(() => {
                this.selectionClear()
            }, 500)
        }
    }
}
</script>
<style lang="scss" scoped></style>