# -*- coding:utf-8 -*-
# 作者：齐振鋆
# 日期：2023/2/23
# 描述: 仓库出库集成
import allure

from component.GuKeYiTiHua.StorageManage.StorageOut.warehouse_check import WarehouseCheck
from component.GuKeYiTiHua.StorageManage.StorageOut.warehouse_delivery import WarehouseDelivery
from component.GuKeYiTiHua.StorageManage.StorageOut.warehouse_pick import WarehousePick
from page.GuKeYiTiHua.Public.common import CommonElement
from unit.public.DataDic import DataDic


class StorageOut(object):
    def __init__(self):
        self.dd = DataDic()
        self.common = CommonElement()
        self.wd = WarehouseDelivery()
        self.wp = WarehousePick()
        self.wc = WarehouseCheck()

    def storage_out_integration(self, order_code, lines):
        """
        parameter field_value: 订单号
        parameter check_data: [[商品编码, 发货数量, 复核数量], ...]
        """
        # 仓库发货
        with allure.step("仓库：发货"):
            self.wd.open_menu_surgery_require()
            self.wd.all_order_delivery(order_code, lines)
            self.wd.delivery_confirm(order_code=order_code)
            self.wd.out_order_search(tap_name='已办', order_code=order_code)
            self.common.close_tap()

        # 仓库拣货
        with allure.step("仓库：拣货"):
            self.wp.open_menu_warehouse_pick()
            self.wp.pick_confirm(order_code)
            self.wp.pick_order_search(tap_name='已办', order_code=order_code)
            self.common.close_tap()

        # 出库复核
        with allure.step("仓库：复核"):
            self.wc.open_menu_warehouse_check()
            self.wc.check_confirm(order_code)
            self.wc.check_order_search(tap_name='已办', order_code=order_code)
            self.common.close_tap()
