# -*- coding:utf-8 -*-
# 作者：齐振鋆
# 日期：2023/2/20
# 描述: 仓库发货页面
import logging
import allure

from component.GuKeYiTiHua import iframe, menu, list_page, button, order_detail_main, modal
from component.GuKeYiTiHua.StorageManage import first_menu

log = logging.getLogger(__name__)


class WarehouseDelivery(object):
    third_menu = '仓库发货'

    def __init__(self):
        self.iframe = iframe
        self.menu = menu
        self.list_page = list_page
        self.button = button
        self.order_detail_main = order_detail_main
        self.modal = modal

    @allure.step('打开菜单：{}'.format(third_menu))
    def open_menu_surgery_require(self):
        self.iframe.out_frame()
        self.menu.open_menu(first_menu, self.third_menu)

    @allure.step('查询：{}'.format(third_menu))
    def out_order_search(self, tap_name='待办', order_code=None, count=1):
        self.list_page.order_search(self.third_menu, tap_name, '订单号', order_code, count)

    @allure.step('全选当前数据')
    def all_order_delivery(self, order_code, count):
        self.out_order_search('出库订单池', order_code, count)
        self.list_page.checked_order(0)
        self.button.all_delivery()
        self.button.click_button("//*[contains(string(), '提示')]/ancestor::div[@class='el-message-box']", '确定')

    @allure.step('{}'.format(third_menu))
    def delivery_confirm(self, order_code):
        self.out_order_search(order_code=order_code)
        self.list_page.open_order('出货订单号')
        self.button.click_button(button_name='发货确认')
        self.list_page.edit_iframe_is_show()
