export let receiveSplitModule = {
    data() {
        return {
            splitVisible: false,
            splitOriginItem: null,
            confirmLoading: false,
        }
    },

    methods: {

        showSplitBill(item) {
            this.splitOriginItem = this.queryRefFromName('list').data.find((t) => t.asnLineId == item.asnLineId)
            this.splitVisible = true
        },

        splitedCallback(item) {
            item.pieceQty = item.conversionRate * item.oddCaseQty + item.oddPieceQty
            item.qty = (item.pieceQty / item.conversionRate).toFixed(2)
        },

        handleSpliteOk(list) {
            // let id = this.splitOriginItem.itemId
            let id = this.splitOriginItem.asnLineId;
            let nList = list.map((t, i) => ({
                ...this.splitOriginItem,
                ...t,
                asnLineId: i == 0 ? id : id + '_cus_' + Math.floor(Math.random() * 1000),
            }))
            let ref = this.queryRefFromName('list')
            let data = [...ref.data]
            data.splice(
                data.findIndex((t) => t.asnLineId == id),
                1,
                ...nList
            )
            ref.setItems(data)
            this.splitVisible = false
            // this.confirmLoading = false;
            this.$message.success(this.$lang('拆单成功'))
            // console.log(ref, ref.data, '拆单成功');
            // setTimeout(() => {
            //     ref.data.forEach((t, i) => {
            //         // if (t.stockStatus != '3') {
            //         //     ref.$refs.easyTable.setIndexByColRules(['bldgId', 'manufacturerLotNum', 'showProductionDate', 'showExpiredDate', 'batchExpiredDate'], i);
            //         // } else {
            //         //     ref.$refs.easyTable.clearIndexByColRules(['bldgId', 'manufacturerLotNum', 'showProductionDate', 'showExpiredDate', 'batchExpiredDate'], i);
            //         // }
            //         // if (t.isDelegate != 0) {
            //         //     ref.$refs.easyTable.setIndexByColRules(['delegationPartyName'], i);
            //         // }else{
            //         //     ref.$refs.easyTable.clearIndexByColRules(['delegationPartyName'], i);
            //         // }
            //     })
            // }, 500)

        },

    },


};