# -*- encoding=utf8 -*-
from common.fileUtls import FileUtils

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,a7供货关系申请_客户类型_医院_分页查询分页查询供货申请单4,id2255,id2255-7,sit,on
主数据平台:a7供货关系申请_客户类型_医院_分页查询分页查询供货申请单4 
"""

from common.common_func import commonFuc
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
from airtest.core.api import using
import sys


def select_upply_and_marketing():
    module = "a4_mdm3_cm"
    info = FileUtils().r_info("a4_mdm3_cm", "供货关系申请")
    print(info)
    e_corpId = info['e_corpId']
    h_corpId = info['h_corpId']
    e_username = info['e_username']
    h_name = info['h_name']
    token, projectCode, uxid, corpId, info = login_system(e_username,
                                                          commonFuc().get_business_data(module, 'password')).get_token()
    # print(token, projectCode, uxid, corpId, info )
    """
     场景:a7供货关系申请_客户类型_医院_分页查询分页查询供货申请单4
     用例名称：a7供货关系申请_客户类型_医院_分页查询分页查询供货申请单4
     输入：e_corpId
     输出："rtn_msg": data
    """

    #a4供货关系申请_客户类型_医院_分页查询分页查询供货申请单1
    url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "listVoPage_url")
    # 获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            projectCode)

    request_body = commonFuc().get_business_data(module, "payload4",e_corpId)
    # # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    print('result',result)
    # # #获取接口返回数据
    code=commonFuc().analysis_json('code',result)
    pageSize = commonFuc().analysis_json('pageSize',commonFuc().analysis_json('data',result))
    if code==0 and pageSize==100:
        commonFuc().check_text_exist(code,result)
    else:
        commonFuc().check_text_exist(-1, result)

select_upply_and_marketing()
