bugfix
This commit is contained in:
parent
39705f3e04
commit
81e9ebc041
@ -17,6 +17,47 @@
|
|||||||
"icon": "{{entire_url('/pricing/imgs/pricing_item.svg')}}",
|
"icon": "{{entire_url('/pricing/imgs/pricing_item.svg')}}",
|
||||||
"subtable": "pricing_item"
|
"subtable": "pricing_item"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"toolbar":{
|
||||||
|
"tools":[
|
||||||
|
{
|
||||||
|
"name": "download_pattern",
|
||||||
|
"label": "定价模版",
|
||||||
|
"selected_row": true,
|
||||||
|
"icon": "{{entire_url('/bricks/imgs/download.svg')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "upload_pricing_data",
|
||||||
|
"label": "上传定价数据",
|
||||||
|
"icon": "{{entire_url('/bricks/imgs/upload.svg')}}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"binds": [
|
||||||
|
{
|
||||||
|
"wid": "self",
|
||||||
|
"event": "download_pattern",
|
||||||
|
"actiontype": "urlwidget",
|
||||||
|
"target": "self",
|
||||||
|
"options":{
|
||||||
|
"params": {
|
||||||
|
"ppid": "{{params_kw.ppid}}"
|
||||||
|
},
|
||||||
|
"url": "{{entire_url('../download_pricing_pattern.dspy')}}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"wid": "self",
|
||||||
|
"event": "upload_pricing_data",
|
||||||
|
"actiontype": "urlwidget",
|
||||||
|
"target": "self",
|
||||||
|
"options": {
|
||||||
|
"params": {
|
||||||
|
"ppid": "{{params_kw.ppid}}"
|
||||||
|
},
|
||||||
|
"url": "{{entire_url('../uplaod_pricing_data.dspy')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,5 +6,7 @@ from ahserver.serverenv import ServerEnv
|
|||||||
|
|
||||||
def load_pricing():
|
def load_pricing():
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
env.write_patten = PricingProgram.write_patten
|
env.write_pricing_patten = PricingProgram.write_pricing_patten
|
||||||
|
env.load_pricing_data = PricingProgram.load_pricing_data
|
||||||
|
env.get_pricing_program = pricingProgram.get_pricing_program
|
||||||
env.calculate_prices = PricingProgram.pricing
|
env.calculate_prices = PricingProgram.pricing
|
||||||
|
|||||||
@ -157,10 +157,39 @@ def check_value(field, spec_value, data_value):
|
|||||||
|
|
||||||
class PricingProgram:
|
class PricingProgram:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def load_pricing(ppid, webpath_xlsx):
|
async def get_pricing_program(ppid):
|
||||||
pass
|
env = ServerEnv()
|
||||||
|
async with get_sor_context(env, 'pricing') as sor:
|
||||||
|
recs = await sor.R('pricing_program', {'id': ppid})
|
||||||
|
if recs:
|
||||||
|
return recs[0]
|
||||||
|
e = f'pricing_program(id={ppid}) not found'
|
||||||
|
raise e
|
||||||
|
e = f'read pricing_program(id={ppid}) failed')
|
||||||
|
raise e
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def write_patten(request, ppid):
|
async def load_pricing_data(pptid, webpath_xlsx):
|
||||||
|
fs = FileStorage()
|
||||||
|
fp = fs.realPath(webpath_xlsx)
|
||||||
|
d = load_xlsx_pricing(fp)
|
||||||
|
async with get_sor_context(env, 'pricing') as sor:
|
||||||
|
ppts = await sor.R('pricing_program_timing', {'id': pptid})
|
||||||
|
if ppts:
|
||||||
|
ppt = ppts[0]
|
||||||
|
ppt.pricing_data = yaml.dump(dd)
|
||||||
|
await sor.U('pricing_program_timing', {
|
||||||
|
'id': ppt.id,
|
||||||
|
'pricing_data': ppt.pricing_data
|
||||||
|
})
|
||||||
|
return True
|
||||||
|
e = f'pricing_program_timing(id={pptid}) not found')
|
||||||
|
raise e
|
||||||
|
e = f'pricing_program_timing(id={pptid}) read failed')
|
||||||
|
raise e
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
async def write_pricing_patten(request, ppid):
|
||||||
async with get_sor_context(request._run_ns, 'pricing') as sor:
|
async with get_sor_context(request._run_ns, 'pricing') as sor:
|
||||||
env = request._run_ns
|
env = request._run_ns
|
||||||
recs = await sor.R('pricing_program', {'id': ppid})
|
recs = await sor.R('pricing_program', {'id': ppid})
|
||||||
|
|||||||
3
wwwroot/download_pricing_pattern.dspy
Normal file
3
wwwroot/download_pricing_pattern.dspy
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
debug(f'download_pricing_pattern.dspy{params_kw=}')
|
||||||
|
url = await write_patten(request, params_kw.ppid)
|
||||||
|
await redirect(url)
|
||||||
4
wwwroot/get_platform_providers.dspy
Normal file
4
wwwroot/get_platform_providers.dspy
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
ret = [{None:None}]
|
||||||
|
ret += await get_platform_providers()
|
||||||
|
return ret
|
||||||
|
|
||||||
31
wwwroot/load_pricing_data.ui
Normal file
31
wwwroot/load_pricing_data.ui
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{% set pp = get_pricing_program(params_kw.ppid) %}
|
||||||
|
{
|
||||||
|
"widgettype": "Form",
|
||||||
|
"options": {
|
||||||
|
"title": "{{pp.id}}",
|
||||||
|
"description": "{{pp.description}}",
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "xlsx_file",
|
||||||
|
"label": "定价文件",
|
||||||
|
"uitype": "file",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"binds": [
|
||||||
|
{
|
||||||
|
"wid": "self",
|
||||||
|
"event": "submit",
|
||||||
|
"actiontype": "urlwidget",
|
||||||
|
"target": "self",
|
||||||
|
"options": {
|
||||||
|
"url": "{{entire_url('upload_pricing_data.dspy')}}",
|
||||||
|
"params": {
|
||||||
|
"pptid": "{{params_kw.id}}",
|
||||||
|
"ppid": "{{params_kw.ppid}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
6
wwwroot/pricing_item/get_spec_fields_by_psid.dspy
Normal file
6
wwwroot/pricing_item/get_spec_fields_by_psid.dspy
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
id = params_kw.id
|
||||||
|
async with get_sor_context(request._run_ns, 'pricing') as sor:
|
||||||
|
recs = await sor.R('pricing_spec', {'id': id})
|
||||||
|
if len(recs):
|
||||||
|
return recs.spec_names
|
||||||
|
return []
|
||||||
6
wwwroot/upload_pricing_data.dspy
Normal file
6
wwwroot/upload_pricing_data.dspy
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
debug(f'uplaod_pricing_data.dspy: {params_kw=}')
|
||||||
|
try:
|
||||||
|
x = await load_pricing_data(params_kw.pptid, xlsx_file)
|
||||||
|
return UiMessage(title='load pricing data', message='data load successful')
|
||||||
|
except Exception as e:
|
||||||
|
return UiError(title='load pricing data', message=f'data load failed({e})')
|
||||||
Loading…
x
Reference in New Issue
Block a user