<template>
    <basic-container>
        <!-- 定期类检查项配置 -->
        <el-tabs v-model="tabPosition" class="demo-tabs" @tab-change="tabPositionChange">
            <el-tab-pane label="槽液检查" name="bathInspection"></el-tab-pane>
            <el-tab-pane label="设备检查" name="deviceInspection"></el-tab-pane>
        </el-tabs>
        <avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page" ref="crud"
            @row-update="rowUpdate" @row-save="rowSave" @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" @click="handleAdd">新增</el-button>
            </template>

            <template #menu="scope">
                <el-button type="text" @click="editRow(scope.row)">修改</el-button>
                <el-button type="text" @click="deleteRow(scope.row)">删除</el-button>
            </template>
        </avue-crud>
        <el-dialog :title="title" append-to-body v-model="showDialog" width="80%">
            <div style="margin-bottom: 10px;">
                <el-button type="primary" icon="el-icon-plus" @click="insertEvent()">插入一行</el-button>
                <el-button plain type="danger" @click="remove">删除选择行</el-button>
                <el-button type="primary" @click="handleSave">保存</el-button>
            </div>
            <el-table :data="tableData" @select="selectChange">
                <el-table-column type="selection"></el-table-column>
                <el-table-column align="center" label="作业中心" prop="bsWorkCenter.wcId">
                    <template #default="scope">
                        <el-select v-model="scope.row.bsWorkCenter.wcId">
                            <el-option v-for="item in wcData" :key="item.wcId" :value="item.wcId"
                                :label="item.wcName"></el-option>
                        </el-select>
                    </template>
                </el-table-column>
                <el-table-column align="center" :label="tabPosition == 'bathInspection' ? '槽号槽名' : '设备检查项'"
                    prop="batchNo">
                    <template #default="scope">
                        <el-input v-if="tabPosition == 'deviceInspection'" v-model="scope.row.batchNo"></el-input>
                        <el-select v-if="tabPosition == 'bathInspection'" v-model="scope.row.batchNo">
                            <el-option label="#21" value="1"></el-option>
                            <el-option label="11" value="11"></el-option>
                            <el-option label="#22" value="3"></el-option>
                        </el-select>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="维护内容" prop="preserveContent">
                    <template #default="scope">
                        <el-input v-model="scope.row.preserveContent"></el-input>
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>
    </basic-container>
</template>

<script>
import periodColumnData from './js/periodColumnData';
export default {
    data() {
        return {
            tabPosition: "bathInspection",
            loading: false,
            title: "新增",
            tableData: [],
            showDialog: false,
            data: [],
            form: {},
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            wcData: [
                {
                    "area": 13000.0,
                    "batchNo": null,
                    "bigBatch": false,
                    "bsJfCenter": {
                        "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"
                        },
                        "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": {
                        "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"
                    },
                    "createTime": "2023-02-06 12:31:36",
                    "deleted": false,
                    "describe": null,
                    "endPoint": null,
                    "keyValue": 81,
                    "leaderUser": {
                        "accountId": 541,
                        "card": null,
                        "createTime": "2023-05-04",
                        "curStatus": 1,
                        "deleted": false,
                        "deptName": null,
                        "dimissionTime": null,
                        "factoryId": 102,
                        "head": 0,
                        "jobName": "MES开发",
                        "keyValue": 541,
                        "ldapName": "cdl",
                        "mail": null,
                        "mobile": null,
                        "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": "CUIDIANLONG,CDL",
                        "ucUserId": null,
                        "updateTime": "2023-05-04 09:16:54",
                        "userCode": "cdl",
                        "userId": 541,
                        "userName": "崔殿龙",
                        "userSex": 1,
                        "userSources": "崔殿龙",
                        "userString": "541:A:崔殿龙",
                        "userType": "A"
                    },
                    "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
                },
                {
                    "area": 0.0,
                    "batchNo": null,
                    "bigBatch": false,
                    "bsJfCenter": {
                        "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"
                        },
                        "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": {
                        "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"
                    },
                    "createTime": "2023-02-06 12:48:41",
                    "deleted": false,
                    "describe": null,
                    "endPoint": null,
                    "keyValue": 85,
                    "leaderUser": {
                        "accountId": 541,
                        "card": null,
                        "createTime": "2023-05-04",
                        "curStatus": 1,
                        "deleted": false,
                        "deptName": null,
                        "dimissionTime": null,
                        "factoryId": 102,
                        "head": 0,
                        "jobName": "MES开发",
                        "keyValue": 541,
                        "ldapName": "cdl",
                        "mail": null,
                        "mobile": null,
                        "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": "CUIDIANLONG,CDL",
                        "ucUserId": null,
                        "updateTime": "2023-05-04 09:16:54",
                        "userCode": "cdl",
                        "userId": 541,
                        "userName": "崔殿龙",
                        "userSex": 1,
                        "userSources": "崔殿龙",
                        "userString": "541:A:崔殿龙",
                        "userType": "A"
                    },
                    "limitType": 0,
                    "processes": "镀后接收",
                    "quantity": null,
                    "roundCycle": null,
                    "saturation": null,
                    "sign": "4",
                    "startPoint": null,
                    "team": "零件管理班",
                    "updateTime": "2023-03-06 18:23:20",
                    "wcCode": "004",
                    "wcId": 85,
                    "wcName": "镀后库作业中心",
                    "whetherPlate": true
                },
                {
                    "area": 0.0,
                    "batchNo": null,
                    "bigBatch": false,
                    "bsJfCenter": {
                        "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"
                        },
                        "createTime": "2024-12-09 00:00:00",
                        "deleted": false,
                        "jcCode": "RBZX",
                        "jcId": 1,
                        "jcName": "热表中心",
                        "keyValue": 1,
                        "updateTime": "2024-12-09 00:00:00"
                    },
                    "checkout": true,
                    "craftAbility": "镀后检验",
                    "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"
                    },
                    "createTime": "2023-02-06 12:49:33",
                    "deleted": false,
                    "describe": null,
                    "endPoint": null,
                    "keyValue": 86,
                    "leaderUser": {
                        "accountId": 541,
                        "card": null,
                        "createTime": "2023-05-04",
                        "curStatus": 1,
                        "deleted": false,
                        "deptName": null,
                        "dimissionTime": null,
                        "factoryId": 102,
                        "head": 0,
                        "jobName": "MES开发",
                        "keyValue": 541,
                        "ldapName": "cdl",
                        "mail": null,
                        "mobile": null,
                        "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": "CUIDIANLONG,CDL",
                        "ucUserId": null,
                        "updateTime": "2023-05-04 09:16:54",
                        "userCode": "cdl",
                        "userId": 541,
                        "userName": "崔殿龙",
                        "userSex": 1,
                        "userSources": "崔殿龙",
                        "userString": "541:A:崔殿龙",
                        "userType": "A"
                    },
                    "limitType": 0,
                    "processes": "镀后检验、性能检测、镀后自检外观检验、镀后自检尺寸检验",
                    "quantity": null,
                    "roundCycle": null,
                    "saturation": null,
                    "sign": "4",
                    "startPoint": null,
                    "team": "检验班",
                    "updateTime": "2023-06-06 15:07:27",
                    "wcCode": "005",
                    "wcId": 86,
                    "wcName": "检验作业中心",
                    "whetherPlate": false
                },
            ],
            option: {
                height: 'auto',
                align: 'center',
                calcHeight: 32,
                rowKey: 'twlId',
                tip: false,
                size: 'medium',
                simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                searchIcon: true,
                searchIndex: 3,
                tree: false,
                border: true,
                index: true,
                selection: false,
                viewBtn: false,
                delBtn: false,
                addBtn: false,
                editBtn: false,
                editBtnText: '修改',
                addBtnIcon: ' ',
                viewBtnIcon: ' ',
                delBtnIcon: ' ',
                editBtnIcon: ' ',
                viewBtnText: '详情',
                labelWidth: 120,
                searchLabelWidth: 120,
                menu: true,
                menuWidth: 220,
                dialogWidth: 1200,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: false,
                filterBtn: true,
                searchShowBtn: false,
                columnSort: true,
                excelBtn: true,
                columnSort: true,
                showOverflowTooltip: true,
                menuAlign: 'left',
                gridBtn: false,
                searchLabelPosition: 'left',
                searchGutter: 24,
                searchSpan: 6,
                searchMenuPosition:'right',
                column: []
            }
        }
    },
    mounted() {
        this.option.column = periodColumnData[this.tabPosition]
    },
    methods: {
        selectChange(list, row) {
            row._select = !row._select
        },
        //删除所选行
        remove() {
            let arr = this.tableData.filter(item => item._select)
            if (arr.length != 0) {
                this.$confirm('确定将选择数据删除?', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                }).then(() => {
                    if (this.rowId) {
                        let deleteData = this.tableData.filter(item => item._select)
                        this.deleteProcessArr = deleteData.filter(item => item.tidId)
                    }
                    let deleteArr = this.tableData.filter(item => !item._select)
                    this.tableData = deleteArr
                })
            } else {
                this.$message.error('请至少选择一条数据进行操作！')
            }
        },
        insertEvent() {
            const record = { bsWorkCenter: { wcId: '' }, _select: false }
            this.tableData.push(record)
        },
        editRow(row) {
            this.tableData = []
            this.tableData.push(row)
            this.title = '修改'
            this.showDialog = true
        },
        handleSave() {
            this.showDialog = false
        },
        deleteRow(row) {
            this.$confirm('确定将选择数据删除?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => { })
        },
        handleAdd() {
            this.title = '新增'
            this.tableData = []
            this.showDialog = true
        },
        tabPositionChange(val) {
            this.option.column = periodColumnData[this.tabPosition]
            if (val == 'bathInspection') {
                this.data = [
                    {
                        "approvalStatus": -1,
                        "arrangeTime": null,
                        "batchNo": "11",
                        "bbpType": 3,
                        "bbpTypeTitle": "定期类-槽液",
                        "bppId": 66,
                        "bsWorkCenter": {
                            "wcId": 81,
                            "wcName": "化学镀镍作业中心"
                        },
                        "businessBeanCreateDate": "2024-03-04 16:10:06",
                        "businessBeanCreateMan": {
                            "userId": 541,
                            "userName": "崔殿龙"
                        },
                        "businessBeanCurStatus": -1,
                        "deleted": false,
                        "flowCode": "FLOW_DS_010",
                        "flowRecDescription": "槽位维护计划-维护计划类审核",
                        "frequency": null,
                        "keepMan": {
                            "userId": 541,
                            "userName": "崔殿龙"
                        },
                        "keepTime": "2024-03-04 16:10:06",
                        "keyValue": 66,
                        "lastTaskTime": null,
                        "parameterOne": null,
                        "parameterTwo": null,
                        "preserveContent": "222",
                        "ruleType": null,
                        "ruleTypeTitle": null
                    }
                ]
                this.page.total = this.data.length
            } else {
                this.data = [
                    {
                        "approvalStatus": -1,
                        "arrangeTime": null,
                        "batchNo": "111",
                        "bbpType": 4,
                        "bbpTypeTitle": "定期类-设备",
                        "bppId": 67,
                        "bsWorkCenter": {
                            "wcId": 81,
                            "wcName": "化学镀镍作业中心"
                        },
                        "businessBeanCreateDate": "2024-03-04 16:10:19",
                        "businessBeanCreateMan": {
                            "userId": 541,
                            "userName": "崔殿龙"
                        },
                        "businessBeanCurStatus": -1,
                        "deleted": false,
                        "flowCode": "FLOW_DS_010",
                        "flowRecDescription": "槽位维护计划-维护计划类审核",
                        "frequency": null,
                        "keepMan": {
                            "userId": 541,
                            "userName": "崔殿龙"
                        },
                        "keepTime": "2024-03-04 16:10:19",
                        "keyValue": 67,
                        "lastTaskTime": null,
                        "parameterOne": null,
                        "parameterTwo": null,
                        "preserveContent": "2222",
                        "ruleType": null,
                        "ruleTypeTitle": null
                    }
                ]
                this.page.total = this.data.length
            }
        },
        searchReset() {
            this.query = {};
            this.onLoad(this.page);
        },
        searchChange(params, done) {
            // this.query = params;
            // this.page.currentPage = 1;
            // this.onLoad(this.page, params);
            done();
        },
        currentChange(currentPage) {
            this.page.currentPage = currentPage;
        },
        sizeChange(pageSize) {
            this.page.pageSize = pageSize;
        },
        refreshChange() {
            this.onLoad(this.page, this.query);
        },
        onLoad() {
            this.data = [
                {
                    "approvalStatus": -1,
                    "arrangeTime": null,
                    "batchNo": "11",
                    "bbpType": 3,
                    "bbpTypeTitle": "定期类-槽液",
                    "bppId": 66,
                    "bsWorkCenter": {
                        "wcId": 81,
                        "wcName": "化学镀镍作业中心"
                    },
                    "businessBeanCreateDate": "2024-03-04 16:10:06",
                    "businessBeanCreateMan": {
                        "userId": 541,
                        "userName": "崔殿龙"
                    },
                    "businessBeanCurStatus": -1,
                    "deleted": false,
                    "flowCode": "FLOW_DS_010",
                    "flowRecDescription": "槽位维护计划-维护计划类审核",
                    "frequency": null,
                    "keepMan": {
                        "userId": 541,
                        "userName": "崔殿龙"
                    },
                    "keepTime": "2024-03-04 16:10:06",
                    "keyValue": 66,
                    "lastTaskTime": null,
                    "parameterOne": null,
                    "parameterTwo": null,
                    "preserveContent": "222",
                    "ruleType": null,
                    "ruleTypeTitle": null
                }
            ]
            this.page.total = this.data.length
        }
    }
}
</script>

<style></style>