You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 lines
2.1 KiB

# -*- coding: utf-8 -*-
"""票 12 补验 r3:customer/search 用库内真名(三维模糊含联系人名)"""
import io, json, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
from playwright.sync_api import sync_playwright
URL = 'file:///E:/code/crm-backend-matt/.scratch/customer-demo-ref/demo/index.html'
errors = []
out = {}
with sync_playwright() as p:
b = p.chromium.launch()
pg = b.new_page(viewport={'width': 1720, 'height': 1080})
pg.on('pageerror', lambda e: errors.append(str(e)))
pg.goto(URL)
pg.wait_for_timeout(600)
pg.fill('#uidInput', '739564171091247104')
pg.evaluate('loginByUid()')
pg.wait_for_timeout(2500)
out['by_customer_name'] = pg.evaluate('''async () => {
const d = await api('/api/customer/search', { method: 'POST', body: 'keyword=' + encodeURIComponent('佛山季华铝业') });
return { total: d && d.total, row0: d && d.content && d.content[0] ? { customerNo: d.content[0].customerNo, customerType: d.content[0].customerType, ownerDeptId: d.content[0].ownerDeptId, archiveStatus: d.content[0].archiveStatus } : null };
}''')
out['by_contact_name_3d'] = pg.evaluate('''async () => {
// 三维模糊验证:用联系人姓名「梁诗敏」搜——应命中其所属客户
const d = await api('/api/customer/search', { method: 'POST', body: 'keyword=' + encodeURIComponent('梁诗敏') });
return { total: d && d.total, name0: d && d.content && d.content[0] ? d.content[0].customerName : null };
}''')
out['exclude_dup_key'] = pg.evaluate('''async () => {
// excludeCustomerIds 重复键排除后 total 应减少
const a = await api('/api/customer/search', { method: 'POST', body: 'keyword=' + encodeURIComponent('佛山') });
const d = await api('/api/customer/search', { method: 'POST', body: 'keyword=' + encodeURIComponent('佛山') + '&excludeCustomerIds=' + (a.content && a.content[0] ? a.content[0].id : '0') });
return { before: a && a.total, after: d && d.total };
}''')
b.close()
out['pageerror'] = errors
print(json.dumps(out, ensure_ascii=False, indent=1))