remove: pricing_item CRUD and related functions (not used)
This commit is contained in:
parent
ac3d7c6d91
commit
7df8e530a4
@ -3,7 +3,4 @@ from pricing.pricing import (
|
|||||||
test_pricing,
|
test_pricing,
|
||||||
generate_formula_from_factors,
|
generate_formula_from_factors,
|
||||||
get_pricing_display,
|
get_pricing_display,
|
||||||
get_pricing_specs_by_pptid,
|
|
||||||
sor_get_spec_fields,
|
|
||||||
get_all_spec_fields_by_pptid,
|
|
||||||
)
|
)
|
||||||
|
|||||||
@ -5,9 +5,6 @@ from pricing.pricing import (
|
|||||||
test_pricing,
|
test_pricing,
|
||||||
generate_formula_from_factors,
|
generate_formula_from_factors,
|
||||||
get_pricing_display,
|
get_pricing_display,
|
||||||
get_pricing_specs_by_pptid,
|
|
||||||
sor_get_spec_fields,
|
|
||||||
get_all_spec_fields_by_pptid,
|
|
||||||
)
|
)
|
||||||
from ahserver.serverenv import ServerEnv
|
from ahserver.serverenv import ServerEnv
|
||||||
|
|
||||||
@ -40,9 +37,6 @@ def load_pricing():
|
|||||||
env.test_pricing = test_pricing
|
env.test_pricing = test_pricing
|
||||||
env.generate_formula_from_factors = generate_formula_from_factors
|
env.generate_formula_from_factors = generate_formula_from_factors
|
||||||
env.get_pricing_display = get_pricing_display
|
env.get_pricing_display = get_pricing_display
|
||||||
env.get_pricing_specs_by_pptid = get_pricing_specs_by_pptid
|
|
||||||
env.sor_get_spec_fields = sor_get_spec_fields
|
|
||||||
env.get_all_spec_fields_by_pptid = get_all_spec_fields_by_pptid
|
|
||||||
# Bind hot_reload event — only when running in ahserver (event_dispatcher available)
|
# Bind hot_reload event — only when running in ahserver (event_dispatcher available)
|
||||||
if getattr(env, 'event_dispatcher', None) is not None:
|
if getattr(env, 'event_dispatcher', None) is not None:
|
||||||
env.event_dispatcher.bind('hot_reload', PricingProgram.on_hot_reload)
|
env.event_dispatcher.bind('hot_reload', PricingProgram.on_hot_reload)
|
||||||
@ -53,4 +47,3 @@ def load_pricing():
|
|||||||
debug(f'Pricing event listeners bound for database: {dbname}')
|
debug(f'Pricing event listeners bound for database: {dbname}')
|
||||||
else:
|
else:
|
||||||
debug('Pricing event listeners skipped: no database configured for pricing module')
|
debug('Pricing event listeners skipped: no database configured for pricing module')
|
||||||
|
|
||||||
|
|||||||
@ -982,71 +982,6 @@ async def test_pricing(pptid, data):
|
|||||||
amount += p.amount
|
amount += p.amount
|
||||||
return amount
|
return amount
|
||||||
|
|
||||||
async def get_pricing_specs_by_pptid(pptid):
|
|
||||||
"""Get all pricing_spec records associated with a pricing_program_timing."""
|
|
||||||
if not pptid:
|
|
||||||
return []
|
|
||||||
env = ServerEnv()
|
|
||||||
async with get_sor_context(env, 'pricing') as sor:
|
|
||||||
recs = await sor.sqlExe(
|
|
||||||
"SELECT DISTINCT s.* FROM pricing_spec s "
|
|
||||||
"INNER JOIN pricing_item pi ON pi.psid = s.id "
|
|
||||||
"WHERE pi.pptid = ${pptid}$",
|
|
||||||
{'pptid': pptid}
|
|
||||||
)
|
|
||||||
return list(recs)
|
|
||||||
|
|
||||||
|
|
||||||
async def sor_get_spec_fields(sor, item_id):
|
|
||||||
"""Get spec field names for a pricing_item by looking up its psid."""
|
|
||||||
if not item_id:
|
|
||||||
return []
|
|
||||||
recs = await sor.R('pricing_item', {'id': item_id})
|
|
||||||
if not recs or not recs[0].psid:
|
|
||||||
return []
|
|
||||||
spec_recs = await sor.R('pricing_spec', {'id': recs[0].psid})
|
|
||||||
if not spec_recs or not spec_recs[0].spec_names:
|
|
||||||
return []
|
|
||||||
try:
|
|
||||||
spec_data = json.loads(spec_recs[0].spec_names)
|
|
||||||
if isinstance(spec_data, list):
|
|
||||||
return [f['name'] for f in spec_data if isinstance(f, dict) and 'name' in f]
|
|
||||||
except (json.JSONDecodeError, TypeError, KeyError):
|
|
||||||
pass
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
async def get_all_spec_fields_by_pptid(request, pptid):
|
|
||||||
"""Template function: returns JSON string of dynamic field definitions
|
|
||||||
from pricing_spec.spec_names for all specs linked to the given pptid.
|
|
||||||
Used in index.ui to inject extra fields into the fields array."""
|
|
||||||
if not pptid:
|
|
||||||
return ''
|
|
||||||
env = ServerEnv()
|
|
||||||
async with get_sor_context(env, 'pricing') as sor:
|
|
||||||
specs = await sor.sqlExe(
|
|
||||||
"SELECT DISTINCT s.spec_names FROM pricing_spec s "
|
|
||||||
"INNER JOIN pricing_item pi ON pi.psid = s.id "
|
|
||||||
"WHERE pi.pptid = ${pptid}$ AND s.spec_names IS NOT NULL AND s.spec_names != ''",
|
|
||||||
{'pptid': pptid}
|
|
||||||
)
|
|
||||||
all_fields = []
|
|
||||||
seen = set()
|
|
||||||
for spec in specs:
|
|
||||||
try:
|
|
||||||
fields = json.loads(spec.spec_names)
|
|
||||||
if isinstance(fields, list):
|
|
||||||
for f in fields:
|
|
||||||
if isinstance(f, dict) and 'name' in f and f['name'] not in seen:
|
|
||||||
seen.add(f['name'])
|
|
||||||
all_fields.append(f)
|
|
||||||
except (json.JSONDecodeError, TypeError):
|
|
||||||
continue
|
|
||||||
if not all_fields:
|
|
||||||
return ''
|
|
||||||
return ',\n'.join(json.dumps(f, ensure_ascii=False) for f in all_fields)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
MyLogger('Pricing', levelname='info')
|
MyLogger('Pricing', levelname='info')
|
||||||
yamlstr = """fields:
|
yamlstr = """fields:
|
||||||
|
|||||||
@ -59,7 +59,6 @@ PATHS_LOGINED = [
|
|||||||
f"/{MOD}/download_pricing_pattern.dspy",
|
f"/{MOD}/download_pricing_pattern.dspy",
|
||||||
f"/{MOD}/get_all_pricing_programs.dspy",
|
f"/{MOD}/get_all_pricing_programs.dspy",
|
||||||
f"/{MOD}/get_platform_providers.dspy",
|
f"/{MOD}/get_platform_providers.dspy",
|
||||||
f"/{MOD}/pi_get_all_specs.dspy",
|
|
||||||
f"/{MOD}/test_pricing_program.dspy",
|
f"/{MOD}/test_pricing_program.dspy",
|
||||||
f"/{MOD}/upload_pricing_data.dspy",
|
f"/{MOD}/upload_pricing_data.dspy",
|
||||||
|
|
||||||
@ -81,15 +80,6 @@ PATHS_LOGINED = [
|
|||||||
f"/{MOD}/pricing_program_timing/add_pricing_program_timing.dspy",
|
f"/{MOD}/pricing_program_timing/add_pricing_program_timing.dspy",
|
||||||
f"/{MOD}/pricing_program_timing/update_pricing_program_timing.dspy",
|
f"/{MOD}/pricing_program_timing/update_pricing_program_timing.dspy",
|
||||||
f"/{MOD}/pricing_program_timing/delete_pricing_program_timing.dspy",
|
f"/{MOD}/pricing_program_timing/delete_pricing_program_timing.dspy",
|
||||||
|
|
||||||
# CRUD: pricing_item (git-tracked)
|
|
||||||
f"/{MOD}/pricing_item",
|
|
||||||
f"/{MOD}/pricing_item/index.ui",
|
|
||||||
f"/{MOD}/pricing_item/get_pricing_item.dspy",
|
|
||||||
f"/{MOD}/pricing_item/get_spec_fields_by_psid.dspy",
|
|
||||||
f"/{MOD}/pricing_item/add_pricing_item.dspy",
|
|
||||||
f"/{MOD}/pricing_item/update_pricing_item.dspy",
|
|
||||||
f"/{MOD}/pricing_item/delete_pricing_item.dspy",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
return await get_pricing_specs_by_pptid(params_kw.pptid)
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
|
|
||||||
ns = params_kw.copy()
|
|
||||||
for k,v in ns.items():
|
|
||||||
if v == 'NaN' or v == 'null':
|
|
||||||
ns[k] = None
|
|
||||||
id = params_kw.id
|
|
||||||
if not id or len(id) > 32:
|
|
||||||
id = uuid()
|
|
||||||
ns['id'] = id
|
|
||||||
|
|
||||||
db = DBPools()
|
|
||||||
dbname = get_module_dbname('pricing')
|
|
||||||
async with db.sqlorContext(dbname) as sor:
|
|
||||||
fs = await sor_get_spec_fields(sor, ns.id)
|
|
||||||
if len(fs):
|
|
||||||
ns1 = {k:ns[k] for k in fs}
|
|
||||||
ns.spec_value = json.dumps(ns1)
|
|
||||||
r = await sor.C('pricing_item', ns.copy())
|
|
||||||
return {
|
|
||||||
"widgettype":"Message",
|
|
||||||
"options":{
|
|
||||||
"user_data":ns,
|
|
||||||
"cwidth":16,
|
|
||||||
"cheight":9,
|
|
||||||
"title":"Add Success",
|
|
||||||
"timeout":3,
|
|
||||||
"message":"ok"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
"widgettype":"Error",
|
|
||||||
"options":{
|
|
||||||
"title":"Add Error",
|
|
||||||
"cwidth":16,
|
|
||||||
"cheight":9,
|
|
||||||
"timeout":3,
|
|
||||||
"message":"failed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
|
|
||||||
ns = {
|
|
||||||
'id':params_kw['id'],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
db = DBPools()
|
|
||||||
dbname = get_module_dbname('pricing')
|
|
||||||
async with db.sqlorContext(dbname) as sor:
|
|
||||||
r = await sor.D('pricing_item', ns)
|
|
||||||
debug('delete success');
|
|
||||||
return {
|
|
||||||
"widgettype":"Message",
|
|
||||||
"options":{
|
|
||||||
"title":"Delete Success",
|
|
||||||
"timeout":3,
|
|
||||||
"cwidth":16,
|
|
||||||
"cheight":9,
|
|
||||||
"message":"ok"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
debug('Delete failed');
|
|
||||||
return {
|
|
||||||
"widgettype":"Error",
|
|
||||||
"options":{
|
|
||||||
"title":"Delete Error",
|
|
||||||
"timeout":3,
|
|
||||||
"cwidth":16,
|
|
||||||
"cheight":9,
|
|
||||||
"message":"failed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,118 +0,0 @@
|
|||||||
|
|
||||||
ns = params_kw.copy()
|
|
||||||
|
|
||||||
|
|
||||||
debug(f'get_pricing_item.dspy:{ns=}')
|
|
||||||
if not ns.get('page'):
|
|
||||||
ns['page'] = 1
|
|
||||||
if not ns.get('sort'):
|
|
||||||
|
|
||||||
|
|
||||||
ns['sort'] = 'name'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sql = '''select a.*, b.pptid_text, c.psid_text, d.subppid_text
|
|
||||||
from (select * from pricing_item where 1=1 [[filterstr]]) a left join (select id as pptid,
|
|
||||||
id as pptid_text from pricing_program_timing where 1 = 1) b on a.pptid = b.pptid left join (select id as psid,
|
|
||||||
name as psid_text from pricing_spec where 1 = 1) c on a.psid = c.psid left join (select id as subppid,
|
|
||||||
name as subppid_text from pricing_program where 1 = 1) d on a.subppid = d.subppid'''
|
|
||||||
|
|
||||||
filterjson = params_kw.get('data_filter')
|
|
||||||
if not filterjson:
|
|
||||||
fields = [ f['name'] for f in [
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"title": "id",
|
|
||||||
"type": "str",
|
|
||||||
"length": 32
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "name",
|
|
||||||
"title": "定价项名",
|
|
||||||
"type": "str",
|
|
||||||
"length": 256
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "description",
|
|
||||||
"title": "描述",
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pptid",
|
|
||||||
"title": "项目id",
|
|
||||||
"type": "str",
|
|
||||||
"length": 32
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "psid",
|
|
||||||
"title": "定价规格id",
|
|
||||||
"type": "str",
|
|
||||||
"length": 32
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "subppid",
|
|
||||||
"title": "子项目id",
|
|
||||||
"type": "str",
|
|
||||||
"length": 32,
|
|
||||||
"nullable": "yes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "spec_value",
|
|
||||||
"title": "规格值",
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pricing_unit",
|
|
||||||
"title": "定价单位",
|
|
||||||
"type": "float",
|
|
||||||
"length": 18,
|
|
||||||
"dec": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pricing_amount",
|
|
||||||
"title": "定价金额",
|
|
||||||
"type": "float",
|
|
||||||
"length": 18,
|
|
||||||
"dec": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cost_amount",
|
|
||||||
"title": "成本金额",
|
|
||||||
"type": "float",
|
|
||||||
"length": 18,
|
|
||||||
"dec": 5
|
|
||||||
}
|
|
||||||
] ]
|
|
||||||
filterjson = default_filterjson(fields, ns)
|
|
||||||
filterdic = ns.copy()
|
|
||||||
filterdic['filterstr'] = ''
|
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
|
||||||
filterdic['userid'] = '${userid}$'
|
|
||||||
if filterjson:
|
|
||||||
dbf = DBFilter(filterjson)
|
|
||||||
conds = dbf.gen(ns)
|
|
||||||
if conds:
|
|
||||||
ns.update(dbf.consts)
|
|
||||||
conds = f' and {conds}'
|
|
||||||
filterdic['filterstr'] = conds
|
|
||||||
ac = ArgsConvert('[[', ']]')
|
|
||||||
vars = ac.findAllVariables(sql)
|
|
||||||
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
|
|
||||||
filterdic.update(NameSpace)
|
|
||||||
sql = ac.convert(sql, filterdic)
|
|
||||||
|
|
||||||
debug(f'{sql=}')
|
|
||||||
db = DBPools()
|
|
||||||
dbname = get_module_dbname('pricing')
|
|
||||||
async with db.sqlorContext(dbname) as sor:
|
|
||||||
r = await sor.sqlPaging(sql, ns)
|
|
||||||
for d in r['rows']:
|
|
||||||
if d.spec_value:
|
|
||||||
ad = json.loads(d.spec_value)
|
|
||||||
d.update(ad)
|
|
||||||
return r
|
|
||||||
return {
|
|
||||||
"total":0,
|
|
||||||
"rows":[]
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
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 []
|
|
||||||
@ -1,198 +0,0 @@
|
|||||||
{
|
|
||||||
"widgettype": "VBox",
|
|
||||||
"options": {
|
|
||||||
"css": "filler", "height": "100%",
|
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"pricing_item_tbl",
|
|
||||||
"widgettype":"Tabular",
|
|
||||||
"options":{
|
|
||||||
"width":"100%",
|
|
||||||
"height":"100%",
|
|
||||||
|
|
||||||
|
|
||||||
"title":"项目定价项",
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"css":"card",
|
|
||||||
|
|
||||||
|
|
||||||
"editable":{
|
|
||||||
|
|
||||||
"new_data_url":"{{entire_url('add_pricing_item.dspy')}}",
|
|
||||||
|
|
||||||
|
|
||||||
"delete_data_url":"{{entire_url('delete_pricing_item.dspy')}}",
|
|
||||||
|
|
||||||
|
|
||||||
"update_data_url":"{{entire_url('update_pricing_item.dspy')}}"
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
"data_url":"{{entire_url('./get_pricing_item.dspy')}}",
|
|
||||||
|
|
||||||
"data_method":"GET",
|
|
||||||
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
|
||||||
"row_options":{
|
|
||||||
"browserfields": {
|
|
||||||
"exclouded": [
|
|
||||||
"id",
|
|
||||||
"pptid"
|
|
||||||
],
|
|
||||||
"alters": {
|
|
||||||
"psid": {
|
|
||||||
"dataurl": "{{entire_url('../pi_get_all_specs.dspy')}}",
|
|
||||||
"textField": "name",
|
|
||||||
"valueField": "id",
|
|
||||||
"params": {
|
|
||||||
"pptid": "{{params_kw.pptid}}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"editexclouded":[
|
|
||||||
"id",
|
|
||||||
"pptid"
|
|
||||||
],
|
|
||||||
|
|
||||||
"fields":[
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"title": "id",
|
|
||||||
"type": "str",
|
|
||||||
"length": 32,
|
|
||||||
"cwidth": 18,
|
|
||||||
"uitype": "str",
|
|
||||||
"datatype": "str",
|
|
||||||
"label": "id"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "name",
|
|
||||||
"title": "定价项名",
|
|
||||||
"type": "str",
|
|
||||||
"length": 256,
|
|
||||||
"cwidth": 18,
|
|
||||||
"uitype": "str",
|
|
||||||
"datatype": "str",
|
|
||||||
"label": "定价项名"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "description",
|
|
||||||
"title": "描述",
|
|
||||||
"type": "text",
|
|
||||||
"length": 0,
|
|
||||||
"uitype": "text",
|
|
||||||
"datatype": "text",
|
|
||||||
"label": "描述"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pptid",
|
|
||||||
"title": "项目id",
|
|
||||||
"type": "str",
|
|
||||||
"length": 32,
|
|
||||||
"label": "项目id",
|
|
||||||
"uitype": "code",
|
|
||||||
"valueField": "pptid",
|
|
||||||
"textField": "pptid_text",
|
|
||||||
"params": {
|
|
||||||
"dbname": "{{get_module_dbname('pricing')}}",
|
|
||||||
"table": "pricing_program_timing",
|
|
||||||
"tblvalue": "id",
|
|
||||||
"tbltext": "id",
|
|
||||||
"valueField": "pptid",
|
|
||||||
"textField": "pptid_text"
|
|
||||||
},
|
|
||||||
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "psid",
|
|
||||||
"title": "定价规格id",
|
|
||||||
"type": "str",
|
|
||||||
"length": 32,
|
|
||||||
"label": "定价规格id",
|
|
||||||
"uitype": "code",
|
|
||||||
"valueField": "id",
|
|
||||||
"textField": "name",
|
|
||||||
"params": {
|
|
||||||
"pptid": "{{params_kw.pptid}}"
|
|
||||||
},
|
|
||||||
"dataurl": "{{entire_url('../pi_get_all_specs.dspy')}}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "subppid",
|
|
||||||
"title": "子项目id",
|
|
||||||
"type": "str",
|
|
||||||
"length": 32,
|
|
||||||
"nullable": "yes",
|
|
||||||
"label": "子项目id",
|
|
||||||
"uitype": "code",
|
|
||||||
"valueField": "subppid",
|
|
||||||
"textField": "subppid_text",
|
|
||||||
"params": {
|
|
||||||
"dbname": "{{get_module_dbname('pricing')}}",
|
|
||||||
"table": "pricing_program",
|
|
||||||
"tblvalue": "id",
|
|
||||||
"tbltext": "name",
|
|
||||||
"valueField": "subppid",
|
|
||||||
"textField": "subppid_text"
|
|
||||||
},
|
|
||||||
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pricing_unit",
|
|
||||||
"title": "定价单位",
|
|
||||||
"type": "float",
|
|
||||||
"length": 18,
|
|
||||||
"dec": 5,
|
|
||||||
"cwidth": 18,
|
|
||||||
"uitype": "float",
|
|
||||||
"datatype": "float",
|
|
||||||
"label": "定价单位"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pricing_amount",
|
|
||||||
"title": "定价金额",
|
|
||||||
"type": "float",
|
|
||||||
"length": 18,
|
|
||||||
"dec": 5,
|
|
||||||
"cwidth": 18,
|
|
||||||
"uitype": "float",
|
|
||||||
"datatype": "float",
|
|
||||||
"label": "定价金额"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cost_amount",
|
|
||||||
"title": "成本金额",
|
|
||||||
"type": "float",
|
|
||||||
"length": 18,
|
|
||||||
"dec": 5,
|
|
||||||
"cwidth": 18,
|
|
||||||
"uitype": "float",
|
|
||||||
"datatype": "float",
|
|
||||||
"label": "成本金额"
|
|
||||||
}
|
|
||||||
{{get_all_spec_fields_by_pptid(request, params_kw.pptid)}}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"page_rows":160,
|
|
||||||
"cache_limit":5
|
|
||||||
}
|
|
||||||
|
|
||||||
,"binds":[
|
|
||||||
{
|
|
||||||
"wid":"psid",
|
|
||||||
"event":"changed",
|
|
||||||
"actiontype":"script",
|
|
||||||
"target":"self",
|
|
||||||
"script":"this.hide_field(params.psid);"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
|
|
||||||
ns = params_kw.copy()
|
|
||||||
for k,v in ns.items():
|
|
||||||
if v == 'NaN' or v == 'null':
|
|
||||||
ns[k] = None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
db = DBPools()
|
|
||||||
dbname = get_module_dbname('pricing')
|
|
||||||
async with db.sqlorContext(dbname) as sor:
|
|
||||||
ori = await sor.R('pricing_item', {'id': ns.id})
|
|
||||||
ori_sv = {}
|
|
||||||
if ori.spec_value:
|
|
||||||
ori_sv = json.loads(ori.spec_value)
|
|
||||||
fs = await sor_get_spec_fields(sor, ns.id)
|
|
||||||
if len(fs):
|
|
||||||
new_sv = {k:ns[k] for k in fs}
|
|
||||||
if new_sv:
|
|
||||||
ori_sv.update(new_sv)
|
|
||||||
ns.spec_value = json.dumps(ori_sv, indent=4)
|
|
||||||
r = await sor.U('pricing_item', ns.copy())
|
|
||||||
debug('update success, {ns=}');
|
|
||||||
return {
|
|
||||||
"widgettype":"Message",
|
|
||||||
"options":{
|
|
||||||
"title":"Update Success",
|
|
||||||
"cwidth":16,
|
|
||||||
"cheight":9,
|
|
||||||
"timeout":3,
|
|
||||||
"message":"ok"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
"widgettype":"Error",
|
|
||||||
"options":{
|
|
||||||
"title":"Update Error",
|
|
||||||
"cwidth":16,
|
|
||||||
"cheight":9,
|
|
||||||
"timeout":3,
|
|
||||||
"message":"failed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user