feat: hand-write discount_detail_list index.ui + get dspy with editable.binds cascading
This commit is contained in:
parent
80ef13af88
commit
d6d827fabb
@ -21,16 +21,16 @@
|
||||
"editable": {
|
||||
"new_data_url": "{{entire_url('../api/discount_detail_create.dspy')}}",
|
||||
"update_data_url": "{{entire_url('../api/discount_detail_update.dspy')}}",
|
||||
"delete_data_url": "{{entire_url('../api/discount_detail_delete.dspy')}}"
|
||||
},
|
||||
"form_binds": [
|
||||
{
|
||||
"wid": "prodtypeid",
|
||||
"event": "changed",
|
||||
"actiontype": "script",
|
||||
"target": "productid",
|
||||
"script": "await this.loadData({prodtypeid: event});"
|
||||
}
|
||||
]
|
||||
"delete_data_url": "{{entire_url('../api/discount_detail_delete.dspy')}}",
|
||||
"binds": [
|
||||
{
|
||||
"wid": "prodtypeid",
|
||||
"event": "changed",
|
||||
"actiontype": "script",
|
||||
"target": "productid",
|
||||
"script": "await this.loadData({prodtypeid: event});"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
45
wwwroot/discount_detail_list/get_discount_detail.dspy
Normal file
45
wwwroot/discount_detail_list/get_discount_detail.dspy
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
ns = params_kw.copy()
|
||||
|
||||
if not ns.get('page'):
|
||||
ns['page'] = 1
|
||||
if not ns.get('sort'):
|
||||
ns['sort'] = ['prodtypeid', 'productid']
|
||||
|
||||
sql = '''select a.*,
|
||||
b.name as discountid_text,
|
||||
c.name as prodtypeid_text,
|
||||
d.product_name as productid_text
|
||||
from (select * from discount_detail where 1=1 [[filterstr]]) a
|
||||
left join (select id, name from discount) b on a.discountid = b.id
|
||||
left join (select id, name from product_category) c on a.prodtypeid = c.id
|
||||
left join (select id, product_name from product) d on a.productid = d.id'''
|
||||
|
||||
fields = ['discountid', 'prodtypeid', 'productid', 'discount']
|
||||
filterjson = default_filterjson(fields, ns)
|
||||
|
||||
filterdic = ns.copy()
|
||||
filterdic['filterstr'] = ''
|
||||
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('discount')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
r = await sor.sqlPaging(sql, ns)
|
||||
return r
|
||||
return {
|
||||
"total": 0,
|
||||
"rows": []
|
||||
}
|
||||
140
wwwroot/discount_detail_list/index.ui
Normal file
140
wwwroot/discount_detail_list/index.ui
Normal file
@ -0,0 +1,140 @@
|
||||
|
||||
{
|
||||
"widgettype":"VBox",
|
||||
"options":{"height":"100%","width":"100%"},
|
||||
"subwidgets":[
|
||||
{
|
||||
"id":"discount_detail_tbl",
|
||||
"widgettype":"Tabular",
|
||||
"options":{
|
||||
"width":"100%",
|
||||
"height":"100%",
|
||||
"title":"折扣产品明细",
|
||||
"css":"card",
|
||||
"editable":{
|
||||
"new_data_url":"{{entire_url('../api/discount_detail_create.dspy')}}",
|
||||
"delete_data_url":"{{entire_url('../api/discount_detail_delete.dspy')}}",
|
||||
"update_data_url":"{{entire_url('../api/discount_detail_update.dspy')}}",
|
||||
"binds":[
|
||||
{
|
||||
"wid":"prodtypeid",
|
||||
"event":"changed",
|
||||
"actiontype":"script",
|
||||
"target":"productid",
|
||||
"script":"await this.loadData({prodtypeid: event});"
|
||||
}
|
||||
]
|
||||
},
|
||||
"data_url":"{{entire_url('./get_discount_detail.dspy')}}",
|
||||
"data_method":"GET",
|
||||
"data_params":{},
|
||||
"row_options":{
|
||||
"idField":"id",
|
||||
"browserfields": {
|
||||
"exclouded": ["id", "resellerid"]
|
||||
},
|
||||
"editexclouded":["id", "discountid", "resellerid"],
|
||||
"fields":[
|
||||
{
|
||||
"name": "id",
|
||||
"title": "id",
|
||||
"type": "str",
|
||||
"length": 32,
|
||||
"uitype": "str",
|
||||
"datatype": "str",
|
||||
"label": "id"
|
||||
},
|
||||
{
|
||||
"name": "discountid",
|
||||
"title": "折扣方案id",
|
||||
"type": "str",
|
||||
"length": 32,
|
||||
"label": "折扣方案",
|
||||
"uitype": "code",
|
||||
"valueField": "discountid",
|
||||
"textField": "discountid_text",
|
||||
"params": {
|
||||
"dbname": "{{get_module_dbname('discount')}}",
|
||||
"table": "discount",
|
||||
"tblvalue": "id",
|
||||
"tbltext": "name",
|
||||
"valueField": "discountid",
|
||||
"textField": "discountid_text"
|
||||
},
|
||||
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||
},
|
||||
{
|
||||
"name": "resellerid",
|
||||
"title": "商户id",
|
||||
"type": "str",
|
||||
"length": 32,
|
||||
"label": "商户",
|
||||
"uitype": "code",
|
||||
"valueField": "resellerid",
|
||||
"textField": "resellerid_text",
|
||||
"params": {
|
||||
"dbname": "{{get_module_dbname('discount')}}",
|
||||
"table": "organization",
|
||||
"tblvalue": "id",
|
||||
"tbltext": "orgname",
|
||||
"valueField": "resellerid",
|
||||
"textField": "resellerid_text"
|
||||
},
|
||||
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||
},
|
||||
{
|
||||
"name": "prodtypeid",
|
||||
"title": "产品种类id",
|
||||
"type": "str",
|
||||
"length": 32,
|
||||
"label": "产品种类",
|
||||
"uitype": "code",
|
||||
"valueField": "prodtypeid",
|
||||
"textField": "prodtypeid_text",
|
||||
"params": {
|
||||
"dbname": "{{get_module_dbname('discount')}}",
|
||||
"table": "product_category",
|
||||
"tblvalue": "id",
|
||||
"tbltext": "name",
|
||||
"valueField": "prodtypeid",
|
||||
"textField": "prodtypeid_text"
|
||||
},
|
||||
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||
},
|
||||
{
|
||||
"name": "productid",
|
||||
"title": "产品id",
|
||||
"type": "str",
|
||||
"length": 32,
|
||||
"label": "产品",
|
||||
"uitype": "code",
|
||||
"valueField": "productid",
|
||||
"textField": "productid_text",
|
||||
"params": {
|
||||
"dbname": "{{get_module_dbname('discount')}}",
|
||||
"table": "product",
|
||||
"tblvalue": "id",
|
||||
"tbltext": "product_name",
|
||||
"valueField": "productid",
|
||||
"textField": "productid_text",
|
||||
"cond": "category_id=[[prodtypeid]]"
|
||||
},
|
||||
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||
},
|
||||
{
|
||||
"name": "discount",
|
||||
"title": "折扣",
|
||||
"type": "float",
|
||||
"length": 5,
|
||||
"dec": 4,
|
||||
"uitype": "float",
|
||||
"datatype": "float",
|
||||
"label": "折扣"
|
||||
}
|
||||
]
|
||||
},
|
||||
"page_rows":160,
|
||||
"cache_limit":5
|
||||
}
|
||||
}]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user