This commit is contained in:
yumoqing 2024-03-12 18:46:05 +08:00
parent 64049ec932
commit 8473909019
8 changed files with 270 additions and 0 deletions

View File

@ -0,0 +1,23 @@
ns = params_kw.copy()
id = uuid()
ns['id'] = id
dbname = get_definition('codesdb')
db = DBPools()
async with db.sqlorContext(dbname) as sor:
r = await sor.C('appcodes', ns)
return {
"widgettype":"Message",
"options":{
"title":"Add Success",
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Add Error",
"message":"failed"
}
}

32
wwwroot/codes/add_kv.dspy Normal file
View File

@ -0,0 +1,32 @@
print(f'{params_kw=}, add_kv.dspy')
ns = params_kw.copy()
ns['id'] = uuid()
if ns.get('parentid') is None:
return {
"widgettype":"Error",
"options":{
"title":"Add Error",
"message":"need parentid"
}
}
dbname = get_definition('codesdb')
db = DBPools()
async with db.sqlorContext(dbname) as sor:
r = await sor.C('appcodes_kv', ns)
return {
"widgettype":"Message",
"options":{
"title":"Add Success",
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Add Error",
"message":"failed"
}
}

View File

46
wwwroot/codes/codekv.ui Normal file
View File

@ -0,0 +1,46 @@
{
"id":"kvlist",
"widgettype":"DynamicAccordion",
"options":{
"data_url":"{{entire_url('get_kvs.dspy')}}",
"data_params":{
"hierarchy_flg":"${hierarchy_flg}",
"pid":"${id}"
},
"editable":{
"form_cheight":4,
"add_icon":"{{entire_url('/imgs/add.png')}}",
"delete_icon":"{{entire_url('/imgs/delete.png')}}",
"update_icon":"{{entire_url('/imgs/update.png')}}",
"new_data_url":"{{entire_url('add_kv.dspy?parentid=${id}')}}",
"delete_data_url":"{{entire_url('delete_kv.dspy')}}",
"update_data_url":"{{entire_url('update_kv.dspy')}}"
},
"fields":[
{
"name":"k",
"lable":"k",
"uitype":"str"
},
{
"name":"v",
"lable":"v",
"uitype":"str"
}
],
"content_rely_on":"hierarchy_flg",
"content_rely_value":"1",
"record_view":{
"widgettype":"urlwidget",
"options":{
"url":"{{entire_url('codekv_record.ui')}}"
}
},
"content_view":{
"widgettype":"urlwidget",
"options":{
"url":"{{entire_url('codekv.ui')}}"
}
}
}
}

View File

@ -0,0 +1,28 @@
{
"widgettype":"HBox",
"options":{
"cheight":1.4
},
"subwidgets":[
{
"widgettype":"Text",
"options":{
"text":"${k}",
"cwidth":10,
"dynsize":true,
"wrap":true,
"halign":"left"
}
},
{
"widgettype":"Text",
"options":{
"text":"${v}",
"cwidth":12,
"dynsize":true,
"wrap":true,
"halign":"left"
}
}
]
}

View File

@ -0,0 +1,22 @@
ns = params_kw.copy()
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'name'
if ns.get('name'):
ns['name'] = '%' + params_kw['name'] + '%'
dbname = get_definition('codesdb')
print(f'dbname=', dbname)
db = DBPools()
async with db.sqlorContext(dbname) as sor:
sql = "select * from appcodes where del_flg='0' "
if ns.get('name'):
sql += ' and name like ${name}$ '
if ns.get('hierarchy_flg'):
sql += ' and hierarchy_flg = ${hierarchy}$ '
r = await sor.sqlPaging(sql, ns)
return r
return {
}

View File

@ -0,0 +1,17 @@
ns = params_kw.copy()
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'k'
print(f'{ns=}, get_kvs.dspy')
dbname = get_definition('codesdb')
print(f'dbname=', dbname)
db = DBPools()
async with db.sqlorContext(dbname) as sor:
sql = "select *, $[hierarchy_flg]$ as hierarchy_flg from appcodes_kv where del_flg='0' and parentid=${pid}$"
r = await sor.sqlPaging(sql, ns)
return r
return {
}

102
wwwroot/codes/index.ui Normal file
View File

@ -0,0 +1,102 @@
{
"widgettype":"VBox",
"options":{
"width":"100%",
"height":"100%",
"overflow":"auto"
},
"subwidgets":[
{
"widgettype":"Title4",
"options":{
"i18n":true,
"dynsize":true,
"wrap":true,
"halign":"left",
"otext":"Codes maintainment"
}
},
{
"widgettype":"Filler",
"options":{},
"subwidgets":[
{
"id":"codelist",
"widgettype":"DynamicAccordion",
"options":{
"editable":{
"form_cheight":4,
"delete_icon":"{{entire_url('/imgs/delete.png')}}",
"update_icon":"{{entire_url('/imgs/update.png')}}",
"new_data_url":"{{entire_url('add_code.dspy')}}",
"delete_data_url":"{{entire_url('delete_code.dspy')}}",
"update_data_url":"{{entire_url('update_code.dspy')}}"
},
"fields":[
{
"name":"name",
"lable":"CodeName",
"uitype":"str"
},
{
"name":"hierarchy_flg",
"lable":"isHierarchy",
"uitype":"code",
"textField":"text",
"valueField":"value",
"defaultvalue":"0",
"data":[
{
"value":"0",
"text":"No"
},
{
"value":"1",
"text":"Yes"
}
]
}
],
"data_url":"{{entire_url('get_codes.dspy')}}",
"record_view":{
"widgettype":"HBox",
"options":{
"cheight":1.4
},
"subwidgets":[
{
"widgettype":"Text",
"options":{
"text":"${name}",
"cwidth":10,
"dynsize":true,
"wrap":true,
"halign":"left"
}
},
{
"widgettype":"Text",
"options":{
"text":"${hierarchy_flg}",
"cwidth":1,
"dynsize":true,
"wrap":true,
"halign":"left"
}
}
]
},
"content_view":{
"widgettype":"urlwidget",
"options":{
"url":"{{entire_url('codekv.ui')}}"
}
}
}
}
]
}
]
}