export let daiGuanModule = {

    data() {
        return {

        };
    },

    methods: {
        //是否显示代管
        showDaiGuan(main) {
            if (main.rcvType === '1') {
                this.$refs.detail.triggerFormItemVisible('main', true, ['inventoryOpType'])
                return
            } else {
                this.$refs.detail.triggerFormItemVisible('main', false, ['inventoryOpType'])
                return
            }
        },
        //代管库位弹框
        hostClick(record, dataSource) {
            this.showHost = true
            this.hostData = record
            this.hostList = dataSource
        },
        //判断是否代管
        checkDG(p1) {
            let data = this.queryRefFromName('list')
            //根据是否代管判断对应列是否禁用
            if (p1&&p1.target.value === '1') {
                data.setDataSource({ inventoryOpType: 0 })
                data.showCols(['locatorCode']);
            } else {
                data.setDataSource({ inventoryOpType: null })
                data.hideCols(['locatorCode']);
                this.reset(data)
            }
        },
            //清空代管关联字段数据
            reset(data) {
                setTimeout(() => {
                    data.getDataSource(false, false).then(data => {
                        // 校验是否代管
                        console.log(data, '校验是否代管');
                        data.forEach(t => {
                            if(!t.locatorCode)return
                            else{
                                t.locatorCode = ''
                                t.batchId = ''
                                t.batchNum = ''
                                t.hostLocatorId = ''
                                t.locatorName = ''
                                t.manufacturerLotNum = ''
                                t.showProductionDate = ''
                                t.batchProductionDate = ''
                                t.showExpiredDate = ''
                                t.batchExpiredDate = ''
                                t.rqcReportNo = ''
                                t.tempQty = 0
                                t.oddCaseQty = 0
                                t.oddPieceQty = 0
                                t.pieceQty = 0
                            }
                        });
                        data.setDataSourceAll(data)
                    }).catch(err => {
                        // 捕获验证错误，进行错误处理
                    });
                }, 1000)
            },
        /* checkDG(p1) {
            let data = this.queryRefFromName('list')
            let columns = data.$refs.easyTable.columns
            //根据是否代管判断对应列是否禁用
            if (!p1) {
                columns.forEach((t) => {
                    if (t.dataIndex === 'locatorCode') {
                        t.hidden = true
                    }
                    if (
                        t.dataIndex === 'manufacturerLotNum' ||
                        t.dataIndex === 'showProductionDate' ||
                        t.dataIndex === 'showExpiredDate' ||
                        t.dataIndex === 'batchExpiredDate'
                    ) {
                        t.disabled = false
                    }
                })
                return
            }
            if (p1.target.value === '1') {
                data.data.inventoryOpType = 0
                columns.forEach((t) => {
                    if (t.dataIndex === 'locatorCode') {
                        t.hidden = false
                    }
                    if (
                        t.dataIndex === 'manufacturerLotNum' ||
                        t.dataIndex === 'showProductionDate' ||
                        t.dataIndex === 'showExpiredDate' ||
                        t.dataIndex === 'batchExpiredDate'
                    ) {
                        t.disabled = true
                    }
                })
            } else {
                columns.forEach((t) => {
                    if (t.dataIndex === 'locatorCode') {
                        t.hidden = true
                    }
                    if (
                        t.dataIndex === 'manufacturerLotNum' ||
                        t.dataIndex === 'showProductionDate' ||
                        t.dataIndex === 'showExpiredDate' ||
                        t.dataIndex === 'batchExpiredDate'
                    ) {
                        t.disabled = false
                    }
                })
            }
        }, */



    }

}