fix: use DataViewer instead of UrlWidget (UrlWidget ignores w/h; DataViewer works)

This commit is contained in:
yumoqing 2026-07-10 11:30:05 +08:00
parent e0dc9963b7
commit 749047814f
2 changed files with 6 additions and 18 deletions

View File

@ -49,10 +49,8 @@ async with DBPools().sqlorContext(dbname) as sor:
# Return CRUD page embedded in popup # Return CRUD page embedded in popup
return { return {
'widgettype': 'UrlWidget', 'widgettype': 'DataViewer',
'options': { 'options': {
'url': f'../distribution_agreements_list?sub_reseller_id={sub_reseller_id}', 'url': f'../distribution_agreements_list?sub_reseller_id={sub_reseller_id}&_webbricks_=1'
'width': '100%',
'height': '100%'
} }
} }

View File

@ -9,35 +9,28 @@ if not userorgid:
dbname = get_module_dbname('supplychain') dbname = get_module_dbname('supplychain')
async with DBPools().sqlorContext(dbname) as sor: async with DBPools().sqlorContext(dbname) as sor:
# Check existing
recs = await sor.sqlExe( recs = await sor.sqlExe(
'SELECT id FROM supply_contracts WHERE supplier_id = ${sid}$ AND resellerid = ${rid}$ AND status = ${st}$', 'SELECT id FROM supply_contracts WHERE supplier_id = ${sid}$ AND resellerid = ${rid}$ AND status = ${st}$',
{'sid': supplier_id, 'rid': userorgid, 'st': '1'} {'sid': supplier_id, 'rid': userorgid, 'st': '1'}
) )
if not recs: if not recs:
# Get supplier name
sub = await sor.sqlExe( sub = await sor.sqlExe(
'SELECT supplier_name FROM suppliers WHERE id = ${sid}$', 'SELECT supplier_name FROM suppliers WHERE id = ${sid}$',
{'sid': supplier_id} {'sid': supplier_id}
) )
sup_name = sub[0].supplier_name if sub else supplier_id sup_name = sub[0].supplier_name if sub else supplier_id
# Generate contract_code
prefix = f"SC-{datetime.datetime.now().strftime('%Y%m%d')}" prefix = f"SC-{datetime.datetime.now().strftime('%Y%m%d')}"
cnt_recs = await sor.sqlExe( cnt_recs = await sor.sqlExe(
'SELECT COUNT(*) as cnt FROM supply_contracts WHERE resellerid = ${rid}$ AND contract_code LIKE ${p}$', 'SELECT COUNT(*) as cnt FROM supply_contracts WHERE resellerid = ${rid}$ AND contract_code LIKE ${p}$',
{'rid': userorgid, 'p': prefix + '%'} {'rid': userorgid, 'p': prefix + '%'}
) )
seq = (cnt_recs[0].cnt if cnt_recs else 0) + 1 seq = (cnt_recs[0].cnt if cnt_recs else 0) + 1
contract_code = f"{prefix}-{seq:04d}"
now = timestampstr() now = timestampstr()
contract_id = getID()
await sor.C('supply_contracts', { await sor.C('supply_contracts', {
'id': contract_id, 'id': getID(),
'resellerid': userorgid, 'resellerid': userorgid,
'supplier_id': supplier_id, 'supplier_id': supplier_id,
'contract_code': contract_code, 'contract_code': f"{prefix}-{seq:04d}",
'contract_name': f'{sup_name}供销协议', 'contract_name': f'{sup_name}供销协议',
'start_date': curDateString(), 'start_date': curDateString(),
'status': '1', 'status': '1',
@ -47,12 +40,9 @@ async with DBPools().sqlorContext(dbname) as sor:
'updated_at': now, 'updated_at': now,
}) })
# Return CRUD page embedded in popup
return { return {
'widgettype': 'UrlWidget', 'widgettype': 'DataViewer',
'options': { 'options': {
'url': f'../supply_contracts_list?supplier_id={supplier_id}', 'url': f'../supply_contracts_list?supplier_id={supplier_id}&_webbricks_=1'
'width': '100%',
'height': '100%'
} }
} }