<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="primary"  @click="approval()">批量审批</el-button>
            </template>
            <template #menu-right>

            </template>
            <template #menu="scope">
                <el-button type="text"  @click="approval(scope.row.tbId)">审批</el-button>

            </template>

        </avue-crud>

        <approvalDialog v-if="isOpen" :showDialog="isOpen" @closeDialog="closeDialog"></approvalDialog>
    </basic-container>
</template>
<script>
import approvalDialog from './approvalDialog.vue'
export default {
    components: {
        approvalDialog
    },
    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: 120,
                dialogWidth: 1040,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: false,
                filterBtn: true,
                searchShowBtn: false,
                columnSort: true,
                excelBtn: true,
                columnSort: true,
                showOverflowTooltip: true,
                searchLabelPosition: 'left',
                searchLabelPosition: 'left',
                searchGutter: 24,
                searchSpan: 6,
                menuAlign: 'left',
                gridBtn: false,
                searchMenuPosition: 'right',
                addBtnIcon: ' ',
                viewBtnIcon: ' ',
                delBtnIcon: ' ',
                editBtnIcon: ' ',
                align: 'center',

                column: [
                    {
                        label: '车间订单号',
                        prop: 'woCode',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: true,
                        width: 120,
                        searchLabelWidth: 90,
                    },
                    {
                        label: '零件号',
                        prop: 'partCode',
                        bind: 'prWorkOrder.pjYieldOrder.partCode',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: true,
                        width: 120,
                    },
                    {
                        label: '批次号',
                        prop: 'batchNo',
                        bind: 'prWorkOrder.batchNo',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: true,
                        width: 120,
                    },
                    {
                        label: '产品名称',
                        prop: 'partName',
                        bind: 'prWorkOrder.pjYieldOrder.partName',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '生产标识',
                        prop: 'prodIdent',
                        bind: 'prWorkOrder.pjYieldOrder.prodIdent',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '生产数量',
                        prop: 'makeQty',
                        bind: 'prWorkOrder.makeQty',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '面积(d㎡)',
                        prop: 'poArea',
                        bind: 'prWorkOrder.pjYieldOrder.poArea',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '建立时间',
                        prop: 'createTime',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: true,
                        width: 120,
                    },
                    {
                        label: '备注',
                        prop: 'memo',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '审核状态',
                        prop: 'runStatusTitle',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: true,
                        width: 120,
                        type:'select',
                        searchOrder:5,
                         searchValue:1,
                        dicData:[
                            {
                                label:'待审核',
                                value:1
                            },
                            {
                                label:'审核通过',
                                value:2
                            },
                            {
                                label:'审核不通过',
                                value:3
                            },
                        ],
                    },
                    {
                        label: '申请人',
                        prop: 'userName',
                        bind: 'createMan.userName',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: true,
                        width: 120,
                    },
                    {
                        label: '审批人',
                        prop: 'userName',
                        bind: 'approvalMan.userName',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '审批时间',
                        prop: 'approvalTime',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '处理意见',
                        prop: 'approvalMemo',
                        sortable: true,
                        filter: true,
                        span: 12,
                        search: false,
                        width: 120,
                    },

                ]
            },
            form: {

            },
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            isOpen: false,
        }
    },
    methods: {
        approval(row) {
            this.isOpen = true
        },
        closeDialog() {
            this.isOpen = false
        },
        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 = [
                {
                    "approvalMan": null,
                    "approvalMemo": null,
                    "approvalTime": null,
                    "collaborate": true,
                    "createMan": {
                        "userId": 541,
                        "userName": "崔殿龙"
                    },
                    "createTime": "2024-01-22 09:48:54",
                    "deliverKey": null,
                    "inCustomer": null,
                    "inTeam": null,
                    "keyValue": 8246,
                    "memo": "11111",
                    "outCustomer": null,
                    "outTeam": {
                        "tsCode": "006",
                        "tsId": 66,
                        "tsName": "化学镀镍一班郭家梁"
                    },
                    "prWorkOrder": {
                        "approvalStatus": 2,
                        "batchArea": 43.48,
                        "batchNo": "Y0382304283",
                        "bsOemCustomer": null,
                        "ca": "E386-化学镀镍",
                        "cardNo": "1016870429",
                        "closeMan": null,
                        "closeTime": null,
                        "collaborate": false,
                        "collaborateText": "否",
                        "createTime": "2023-04-14 18:19:35",
                        "currentBsOemCustomer": null,
                        "currentMakeTeam": {
                            "tsCode": "006",
                            "tsId": 66,
                            "tsName": "化学镀镍一班郭家梁"
                        },
                        "demandDate": "2023-04-18",
                        "dispatcher": {
                            "userId": 355,
                            "userName": "07188"
                        },
                        "frontProcedureSet": null,
                        "handoverTime": null,
                        "hrTypeBool": null,
                        "inventoryQty": 0.0,
                        "jcName": null,
                        "keyValue": 2485,
                        "lastInstoreTime": null,
                        "lossQty": 0,
                        "mainProcessingUnit": "化学镀镍一班郭家梁",
                        "makeQty": 100.0,
                        "makeTeam": {
                            "tsCode": "006",
                            "tsId": 66,
                            "tsName": "化学镀镍一班郭家梁"
                        },
                        "makeUnit": "化学镀镍一班郭家梁",
                        "meetCycle": 0,
                        "memo": null,
                        "mesCardNo": null,
                        "moCode": null,
                        "moLocal": null,
                        "nextBsOemCustomer": null,
                        "nextMakeTeam": {
                            "tsCode": "006",
                            "tsId": 66,
                            "tsName": "化学镀镍一班郭家梁"
                        },
                        "nextOrders": "0010",
                        "nextProcedureSet": {
                            "assist": false,
                            "assistTitle": "否",
                            "createMan": {
                                "userId": 1,
                                "userName": "admin"
                            },
                            "createTime": "2022-11-15 10:30:45",
                            "cycle": 0.0,
                            "cyropactorControl": true,
                            "deleted": false,
                            "eleRate": true,
                            "eleStream": true,
                            "keyValue": 7,
                            "mainProcess": true,
                            "mainProcessTitle": "是",
                            "niValue": true,
                            "phValue": true,
                            "ppsCode": "003",
                            "ppsId": 7,
                            "ppsName": "化学镀镍",
                            "special": false,
                            "specialTitle": "否",
                            "team": null,
                            "updateTime": "2022-11-15 10:30:45",
                            "vSpeed": true
                        },
                        "notInQty": 100.0,
                        "nowWorkCenter": {
                            "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
                        },
                        "oem": false,
                        "oemOut": true,
                        "oemType": -1,
                        "oldRunStatus": null,
                        "orderMarkTitle": "热表中心",
                        "orderWoCode": "WO-221296443-R06",
                        "orderWoCodeDeliverKey": null,
                        "orders": "0005",
                        "outTime": null,
                        "pgrId": null,
                        "pickingStatus": 0,
                        "pickingStatusTitle": "未领取",
                        "pjYieldOrder": {
                            "batchNo": "Y0382304283",
                            "bsProcedureQua": null,
                            "businessType": 1,
                            "businessTypeTitle": "热表中心",
                            "cardNo": "1016870429",
                            "craftId": null,
                            "curStatus": 0,
                            "curStatusTitle": "待接收",
                            "custodian": "杨肖肖",
                            "demandDate": "2023-06-16",
                            "dsCraft": null,
                            "dsPart": null,
                            "entrustDept": "采购与物流中心(成件)",
                            "failureMan": {
                                "userId": 326,
                                "userName": "02051"
                            },
                            "failureMemo": "分派成功！",
                            "failureTime": null,
                            "fatherYoId": null,
                            "keyValue": 156703,
                            "manualIncrease": false,
                            "memo": "XXXX",
                            "newlevFlag": null,
                            "nextRoam": null,
                            "nextRoamName": null,
                            "partCode": "21E8-154-1516-E9",
                            "partName": "18-线夹",
                            "pdmUrl": null,
                            "planUser": "白洁",
                            "plate": "XXX",
                            "poArea": 0.4348,
                            "poCode": "WO-221296443",
                            "poMemo": null,
                            "poProdLine": null,
                            "poQty": 100.0,
                            "primaryCraft": "库1-2（机加）-4（表）-库2",
                            "priority": 1,
                            "prodIdent": "JII",
                            "produceBool": false,
                            "productType": "XXXX",
                            "recseqno": null,
                            "releaseDate": "2022-12-17",
                            "reworkCode": null,
                            "reworkMemo": null,
                            "reworkNo": null,
                            "roamName": null,
                            "roamNo": "B5286963",
                            "siteWork": false,
                            "sjKitPreparation": null,
                            "sjMoldPreparation": null,
                            "syncTime": "2023-04-14 14:42:49",
                            "useDept": "制造一部(38999)",
                            "useDeptcode": null,
                            "yieldType": 1,
                            "yoCode": "WX-2212694911",
                            "yoId": 156703
                        },
                        "planEndDate": "2023-04-18 18:19:35",
                        "planner": {
                            "userId": 355,
                            "userName": "07188"
                        },
                        "plateGoodsCode": null,
                        "plateSingleQuota": 0.0,
                        "plateSingleQuotaTotal": 0.0,
                        "printCode": "HZQD20230509001",
                        "printFlag": true,
                        "printMan": {
                            "userId": 541,
                            "userName": "崔殿龙"
                        },
                        "printTime": "2023-05-09 19:08:13",
                        "priority": 1,
                        "priorityTitle": "正常",
                        "procedureSet": {
                            "assist": false,
                            "assistTitle": "否",
                            "createMan": {
                                "userId": 1,
                                "userName": "admin"
                            },
                            "createTime": "2022-11-15 10:30:29",
                            "cycle": 0.0,
                            "cyropactorControl": false,
                            "deleted": false,
                            "eleRate": true,
                            "eleStream": true,
                            "keyValue": 6,
                            "mainProcess": true,
                            "mainProcessTitle": "是",
                            "niValue": false,
                            "phValue": false,
                            "ppsCode": "002",
                            "ppsId": 6,
                            "ppsName": "上挂",
                            "special": false,
                            "specialTitle": "否",
                            "team": null,
                            "updateTime": "2022-11-15 10:30:29",
                            "vSpeed": false
                        },
                        "processingUnit": "化学镀镍一班郭家梁",
                        "producycle": 4,
                        "pushFlag": true,
                        "putStoreTime": null,
                        "qcReworkCode": null,
                        "quotaExceptional": false,
                        "reInStore": false,
                        "readStatus": null,
                        "readStatusTiTle": "未准备",
                        "recDept": null,
                        "receptionTime": null,
                        "reworkCode": null,
                        "reworkMemo": null,
                        "reworkNo": null,
                        "rsCode": null,
                        "runStatus": 3,
                        "runStatusTitle": "加工中",
                        "schedStatus": 0,
                        "scrapQty": 0.0,
                        "sendDownTime": "2023-04-14 18:19:35",
                        "smBatch": "是",
                        "subList": null,
                        "subRunStatus": null,
                        "testQty": 0,
                        "tools": null,
                        "totalArea": 43.48,
                        "woCode": "WO-221296443-R06",
                        "woId": 2485,
                        "wpId": 14788,
                        "ybCode": null,
                        "ybLocal": null
                    },
                    "printFlag": false,
                    "printMan": null,
                    "runStatus": 2,
                    "runStatusTitle": "审批中",
                    "runType": 1,
                    "runTypeTitle": "转外协",
                    "systemData": false,
                    "woCode": "WO-221296443-R06",
                    "worId": 8246
                }
            ]
            this.page.total = this.data.length
            this.loading = false
            setTimeout(() => {
                this.selectionClear()
            }, 500)
        }
    }
}
</script>
<style lang="scss" scoped></style>