chore: untrack CRUD intermediate files (already in .gitignore)

This commit is contained in:
yumoqing 2026-07-14 18:03:46 +08:00
parent b3c61a6758
commit a42d362995
61 changed files with 0 additions and 8273 deletions

View File

@ -1,52 +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
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['created_at'] = timestampstr()
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('distribution_agreement_items', ns.copy())
return {
"widgettype":"Message",
"options":{
"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"
}
}

View File

@ -1,47 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('distribution_agreement_items', 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"
}
}

View File

@ -1,148 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['userorgid'] = userorgid
debug(f'get_distribution_agreement_items.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["prodtypeid", "productid"]
sql = '''select a.*, b.agreement_id_text
from (select * from distribution_agreement_items where 1=1 [[filterstr]]) a left join (select id as agreement_id,
agreement_name as agreement_id_text from distribution_agreements where 1 = 1) b on a.agreement_id = b.agreement_id'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "agreement_id",
"title": "分销协议ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "prodtypeid",
"title": "产品分类ID",
"type": "str",
"length": 32
},
{
"name": "productid",
"title": "产品ID",
"type": "str",
"length": 32
},
{
"name": "discount",
"title": "分销折扣",
"type": "double",
"length": 5,
"dec": 4,
"nullable": "no",
"default": "1.0000"
},
{
"name": "min_order_qty",
"title": "最小订购量",
"type": "int"
},
{
"name": "sale_price",
"title": "分销指导价",
"type": "double",
"length": 15,
"dec": 4
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
# 确保 logined 过滤条件始终生效
if filterjson:
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
filterjson = {'AND': [filterjson] if filterjson else []}
filterjson['AND'].append({'field': 'resellerid', 'op': '=', 'var': '__logined_orgid__'})
ns['__logined_orgid__'] = userorgid
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,214 +0,0 @@
{
"widgettype":"VBox",
"options":{"width":"100%"},
"subwidgets":[{
"id":"distribution_agreement_items_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"title":"分销协议产品折扣明细表",
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/distribution_agreement_items_list/add_distribution_agreement_items.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/distribution_agreement_items_list/delete_distribution_agreement_items.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/distribution_agreement_items_list/update_distribution_agreement_items.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/distribution_agreement_items_list/get_distribution_agreement_items.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"agreement_id",
"resellerid"
],
"alters": {
"agreement_id": {
"uitype": "code",
"dataurl": "{{entire_url('/supplychain/api/get_search_agreement_id.dspy')}}",
"valueField": "agreement_id",
"textField": "agreement_id_text"
},
"prodtypeid": {
"uitype": "code",
"dataurl": "{{entire_url('/supplychain/api/get_search_prodtypeid.dspy')}}",
"valueField": "prodtypeid",
"textField": "prodtypeid_text"
},
"productid": {
"uitype": "code",
"dataurl": "{{entire_url('/supplychain/api/get_search_productid.dspy')}}",
"valueField": "productid",
"textField": "productid_text"
}
}
},
"editexclouded":[
"id",
"resellerid",
"agreement_id",
"created_at"
],
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "agreement_id",
"title": "分销协议ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "分销协议ID",
"uitype": "code",
"valueField": "agreement_id",
"textField": "agreement_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "distribution_agreements",
"tblvalue": "id",
"tbltext": "agreement_name",
"valueField": "agreement_id",
"textField": "agreement_id_text"
},
"dataurl": "{{entire_url('/supplychain/api/get_search_agreement_id.dspy')}}"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "所属分销商机构ID"
},
{
"name": "prodtypeid",
"title": "产品分类ID",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "code",
"datatype": "str",
"label": "产品分类ID",
"dataurl": "{{entire_url('/supplychain/api/get_search_prodtypeid.dspy')}}",
"valueField": "prodtypeid",
"textField": "prodtypeid_text"
},
{
"name": "productid",
"title": "产品ID",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "code",
"datatype": "str",
"label": "产品ID",
"dataurl": "{{entire_url('/supplychain/api/get_search_productid.dspy')}}",
"valueField": "productid",
"textField": "productid_text"
},
{
"name": "discount",
"title": "分销折扣",
"type": "double",
"length": 5,
"dec": 4,
"nullable": "no",
"default": "1.0000",
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "分销折扣"
},
{
"name": "min_order_qty",
"title": "最小订购量",
"type": "int",
"length": 0,
"uitype": "int",
"datatype": "int",
"label": "最小订购量"
},
{
"name": "sale_price",
"title": "分销指导价",
"type": "double",
"length": 15,
"dec": 4,
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "分销指导价"
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}]
}

View File

@ -1,70 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"resellerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('distribution_agreement_items', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('distribution_agreement_items', ns)
debug('update success');
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"
}
}

View File

@ -1,52 +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
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('distribution_agreements', 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"
}
}

View File

@ -1,47 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('distribution_agreements', 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"
}
}

View File

@ -1,155 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['userorgid'] = userorgid
debug(f'get_distribution_agreements.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["created_at desc"]
sql = '''select a.*, b.sub_reseller_id_text, c.resellerid_text
from (select * from distribution_agreements where 1=1 [[filterstr]]) a left join (select id as sub_reseller_id,
sub_reseller_name as sub_reseller_id_text from sub_resellers where 1 = 1) b on a.sub_reseller_id = b.sub_reseller_id left join (select id as resellerid,
orgname as resellerid_text from organization where 1 = 1) c on a.resellerid = c.resellerid'''
filterjson = params_kw.get('data_filter')
if not filterjson:
fields = [ f['name'] for f in [
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "sub_reseller_id",
"title": "二级分销商ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "agreement_code",
"title": "协议编号",
"type": "str",
"length": 64,
"nullable": "no"
},
{
"name": "agreement_name",
"title": "协议名称",
"type": "str",
"length": 255,
"nullable": "no"
},
{
"name": "sign_date",
"title": "签署日期",
"type": "date"
},
{
"name": "start_date",
"title": "生效日期",
"type": "date",
"nullable": "no"
},
{
"name": "end_date",
"title": "到期日期",
"type": "date"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1"
},
{
"name": "default_discount",
"title": "默认分销折扣",
"type": "double",
"length": 5,
"dec": 4,
"default": "1.0000"
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime"
}
] ]
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,340 +0,0 @@
{
"id":"distribution_agreements_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"分销协议表",
"toolbar":{
"tools": [
{
"selected_row": true,
"name": "distribution_agreement_items",
"icon": "{{entire_url('/imgs/distribution_agreement_items.svg')}}",
"label": "产品分销折扣"
},
{
"selected_row": true,
"name": "contract_attach",
"icon": "{{entire_url('/imgs/contract_attach.svg')}}",
"label": "合同附件"
}
]
},
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_distribution_agreements.dspy')}}",
"delete_data_url":"{{entire_url('delete_distribution_agreements.dspy')}}",
"update_data_url":"{{entire_url('update_distribution_agreements.dspy')}}"
},
"data_url":"{{entire_url('./get_distribution_agreements.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"resellerid"
],
"alters": {
"sub_reseller_id": {
"uitype": "code",
"dataurl": "{{entire_url('/supplychain/api/get_search_sub_reseller_id.dspy')}}",
"valueField": "sub_reseller_id",
"textField": "sub_reseller_id_text"
},
"status": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "生效中"
},
{
"value": "2",
"text": "已到期"
},
{
"value": "0",
"text": "已终止"
}
]
}
}
},
"editexclouded":[
"id",
"resellerid",
"sub_reseller_id",
"agreement_code",
"created_by",
"created_at",
"updated_at"
],
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "所属分销商机构ID",
"uitype": "code",
"valueField": "resellerid",
"textField": "resellerid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "resellerid",
"textField": "resellerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "sub_reseller_id",
"title": "二级分销商ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "二级分销商ID",
"uitype": "code",
"valueField": "sub_reseller_id",
"textField": "sub_reseller_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "sub_resellers",
"tblvalue": "id",
"tbltext": "sub_reseller_name",
"valueField": "sub_reseller_id",
"textField": "sub_reseller_id_text"
},
"dataurl": "{{entire_url('/supplychain/api/get_search_sub_reseller_id.dspy')}}"
},
{
"name": "agreement_code",
"title": "协议编号",
"type": "str",
"length": 64,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "协议编号"
},
{
"name": "agreement_name",
"title": "协议名称",
"type": "str",
"length": 255,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "协议名称"
},
{
"name": "sign_date",
"title": "签署日期",
"type": "date",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "签署日期"
},
{
"name": "start_date",
"title": "生效日期",
"type": "date",
"nullable": "no",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "生效日期"
},
{
"name": "end_date",
"title": "到期日期",
"type": "date",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "到期日期"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1",
"cwidth": 4,
"uitype": "code",
"datatype": "char",
"label": "状态",
"data": [
{
"value": "1",
"text": "生效中"
},
{
"value": "2",
"text": "已到期"
},
{
"value": "0",
"text": "已终止"
}
]
},
{
"name": "default_discount",
"title": "默认分销折扣",
"type": "double",
"length": 5,
"dec": 4,
"default": "1.0000",
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "默认分销折扣"
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "创建人"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "更新时间"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[
{
"wid": "self",
"event": "distribution_agreement_items",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "产品分销折扣",
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=distribution_agreement_items",
"resizable": true,
"height": "70%",
"width": "70%"
},
"params_mapping": {
"mapping": {
"id": "agreement_id",
"referer_widget": "referer_widget"
},
"need_other": false
},
"options": {
"method": "POST",
"params": {},
"url": "{{entire_url('/supplychain/agreement_discount_setting.ui')}}"
}
},
{
"wid": "self",
"event": "contract_attach",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "合同附件",
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=contract_attach",
"resizable": true,
"height": "70%",
"width": "70%"
},
"params_mapping": {
"mapping": {
"id": "contract_id",
"referer_widget": "referer_widget",
"contract_id": "id"
},
"need_other": false
},
"options": {
"method": "POST",
"params": {},
"url": "{{entire_url('/supplychain/api/contract_attach.ui')}}?contract_type=distribution"
}
}
]
}

View File

@ -1,70 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"resellerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('distribution_agreements', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('distribution_agreements', ns)
debug('update success');
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"
}
}

View File

@ -1,37 +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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('platform_supply_products', ns.copy())
return {
"widgettype":"Message",
"options":{
"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"
}
}

View File

@ -1,33 +0,0 @@
ns = {
'id':params_kw['id'],
}
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('platform_supply_products', 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"
}
}

View File

@ -1,158 +0,0 @@
ns = params_kw.copy()
debug(f'get_platform_supply_products.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["created_at desc"]
sql = '''select a.*, b.relation_id_text, c.supplier_org_id_text, d.buyer_org_id_text, e.source_product_id_text, f.status_text
from (select * from platform_supply_products where 1=1 [[filterstr]]) a left join (select id as relation_id,
relation_name as relation_id_text from platform_supply_relations where 1 = 1) b on a.relation_id = b.relation_id left join (select id as supplier_org_id,
orgname as supplier_org_id_text from organization where 1 = 1) c on a.supplier_org_id = c.supplier_org_id left join (select id as buyer_org_id,
orgname as buyer_org_id_text from organization where 1 = 1) d on a.buyer_org_id = d.buyer_org_id left join (select id as source_product_id,
product_name as source_product_id_text from product where 1 = 1) e on a.source_product_id = e.source_product_id left join (select k as status,
v as status_text from appcodes_kv where parentid='sc_product_status') f on a.status = f.status'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "relation_id",
"title": "供销关系ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "supplier_org_id",
"title": "供应方机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "buyer_org_id",
"title": "需求方机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "source_product_id",
"title": "供应方产品ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "supply_price",
"title": "供货价",
"type": "double",
"length": 15,
"dec": 4,
"nullable": "no",
"default": "0"
},
{
"name": "suggested_retail_price",
"title": "建议零售价",
"type": "double",
"length": 15,
"dec": 4
},
{
"name": "discount",
"title": "折扣率",
"type": "double",
"length": 5,
"dec": 4,
"default": "1.0000"
},
{
"name": "commission_rate",
"title": "佣金率",
"type": "double",
"length": 5,
"dec": 4,
"default": "0.0000"
},
{
"name": "min_order_qty",
"title": "最小订货量",
"type": "int"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1"
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,311 +0,0 @@
{
"widgettype":"VBox",
"options":{"cheight":40,"width":"100%"},
"subwidgets":[{
"id":"platform_supply_products_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"cheight":40,
"title":"平台供销产品明细表",
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/platform_supply_products_list/add_platform_supply_products.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/platform_supply_products_list/delete_platform_supply_products.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/platform_supply_products_list/update_platform_supply_products.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/platform_supply_products_list/get_platform_supply_products.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"supplier_org_id",
"buyer_org_id"
],
"alters": {
"status": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "启用"
},
{
"value": "0",
"text": "停用"
}
]
}
}
},
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "relation_id",
"title": "供销关系ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "供销关系ID",
"uitype": "code",
"valueField": "relation_id",
"textField": "relation_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "platform_supply_relations",
"tblvalue": "id",
"tbltext": "relation_name",
"valueField": "relation_id",
"textField": "relation_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supplier_org_id",
"title": "供应方机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "供应方机构ID",
"uitype": "code",
"valueField": "supplier_org_id",
"textField": "supplier_org_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "supplier_org_id",
"textField": "supplier_org_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "buyer_org_id",
"title": "需求方机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "需求方机构ID",
"uitype": "code",
"valueField": "buyer_org_id",
"textField": "buyer_org_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "buyer_org_id",
"textField": "buyer_org_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "source_product_id",
"title": "供应方产品ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "供应方产品ID",
"uitype": "code",
"valueField": "source_product_id",
"textField": "source_product_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "product",
"tblvalue": "id",
"tbltext": "product_name",
"valueField": "source_product_id",
"textField": "source_product_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supply_price",
"title": "供货价",
"type": "double",
"length": 15,
"dec": 4,
"nullable": "no",
"default": "0",
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "供货价"
},
{
"name": "suggested_retail_price",
"title": "建议零售价",
"type": "double",
"length": 15,
"dec": 4,
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "建议零售价"
},
{
"name": "discount",
"title": "折扣率",
"type": "double",
"length": 5,
"dec": 4,
"default": "1.0000",
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "折扣率"
},
{
"name": "commission_rate",
"title": "佣金率",
"type": "double",
"length": 5,
"dec": 4,
"default": "0.0000",
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "佣金率"
},
{
"name": "min_order_qty",
"title": "最小订货量",
"type": "int",
"length": 0,
"uitype": "int",
"datatype": "int",
"label": "最小订货量"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1",
"label": "状态",
"uitype": "code",
"valueField": "status",
"textField": "status_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "status",
"textField": "status_text",
"cond": "parentid='sc_product_status'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
"data": [
{
"value": "1",
"text": "启用"
},
{
"value": "0",
"text": "停用"
}
]
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "更新时间"
}
]
},
"data_filter":{
"AND": [
{
"field": "relation_id",
"op": "=",
"var": "relation_id"
},
{
"field": "status",
"op": "=",
"var": "status"
}
]
},
"filter_labels":{
"relation_id": "供销关系",
"status": "状态"
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}]
}

View File

@ -1,36 +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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.U('platform_supply_products', ns)
debug('update success');
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"
}
}

View File

@ -1,37 +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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('platform_supply_relations', ns.copy())
return {
"widgettype":"Message",
"options":{
"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"
}
}

View File

@ -1,33 +0,0 @@
ns = {
'id':params_kw['id'],
}
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('platform_supply_relations', 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"
}
}

View File

@ -1,175 +0,0 @@
ns = params_kw.copy()
debug(f'get_platform_supply_relations.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["created_at desc"]
sql = '''select a.*, b.supplier_org_id_text, c.buyer_org_id_text, d.relation_type_text, e.settlement_mode_text, f.status_text
from (select * from platform_supply_relations where 1=1 [[filterstr]]) a left join (select id as supplier_org_id,
orgname as supplier_org_id_text from organization where 1 = 1) b on a.supplier_org_id = b.supplier_org_id left join (select id as buyer_org_id,
orgname as buyer_org_id_text from organization where 1 = 1) c on a.buyer_org_id = c.buyer_org_id left join (select k as relation_type,
v as relation_type_text from appcodes_kv where parentid='sc_relation_type') d on a.relation_type = d.relation_type left join (select k as settlement_mode,
v as settlement_mode_text from appcodes_kv where parentid='sc_settlement_mode') e on a.settlement_mode = e.settlement_mode left join (select k as status,
v as status_text from appcodes_kv where parentid='sc_relation_status') f on a.status = f.status'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "supplier_org_id",
"title": "供应方机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "buyer_org_id",
"title": "需求方机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "relation_code",
"title": "关系编号",
"type": "str",
"length": 64,
"nullable": "no"
},
{
"name": "relation_name",
"title": "关系名称",
"type": "str",
"length": 255,
"nullable": "no"
},
{
"name": "relation_type",
"title": "合作类型",
"type": "str",
"length": 32,
"nullable": "no",
"default": "distribution"
},
{
"name": "settlement_mode",
"title": "结算方式",
"type": "str",
"length": 32,
"nullable": "no",
"default": "discount"
},
{
"name": "default_discount",
"title": "默认折扣率",
"type": "double",
"length": 5,
"dec": 4,
"default": "1.0000"
},
{
"name": "default_commission_rate",
"title": "默认佣金率",
"type": "double",
"length": 5,
"dec": 4,
"default": "0.0000"
},
{
"name": "sign_date",
"title": "签署日期",
"type": "date"
},
{
"name": "start_date",
"title": "生效日期",
"type": "date",
"nullable": "no"
},
{
"name": "end_date",
"title": "到期日期",
"type": "date"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1"
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,459 +0,0 @@
{
"widgettype":"VBox",
"options":{"cheight":40,"width":"100%"},
"subwidgets":[{
"id":"platform_supply_relations_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"cheight":40,
"title":"平台内供销关系表",
"toolbar":{
"tools": [
{
"selected_row": true,
"name": "platform_supply_products",
"icon": "{{entire_url('/imgs/platform_supply_products.svg')}}",
"label": "供销产品明细"
}
]
},
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/platform_supply_relations_list/add_platform_supply_relations.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/platform_supply_relations_list/delete_platform_supply_relations.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/platform_supply_relations_list/update_platform_supply_relations.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/platform_supply_relations_list/get_platform_supply_relations.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id"
],
"alters": {
"status": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "生效中"
},
{
"value": "2",
"text": "已到期"
},
{
"value": "0",
"text": "已终止"
}
]
},
"relation_type": {
"uitype": "code",
"data": [
{
"value": "distribution",
"text": "分销"
},
{
"value": "agency",
"text": "代理"
},
{
"value": "direct",
"text": "直供"
}
]
},
"settlement_mode": {
"uitype": "code",
"data": [
{
"value": "discount",
"text": "折扣"
},
{
"value": "rebate",
"text": "返佣"
},
{
"value": "fixed",
"text": "固定价"
}
]
}
}
},
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "supplier_org_id",
"title": "供应方机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "供应方机构ID",
"uitype": "code",
"valueField": "supplier_org_id",
"textField": "supplier_org_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "supplier_org_id",
"textField": "supplier_org_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "buyer_org_id",
"title": "需求方机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "需求方机构ID",
"uitype": "code",
"valueField": "buyer_org_id",
"textField": "buyer_org_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "buyer_org_id",
"textField": "buyer_org_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "relation_code",
"title": "关系编号",
"type": "str",
"length": 64,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "关系编号"
},
{
"name": "relation_name",
"title": "关系名称",
"type": "str",
"length": 255,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "关系名称"
},
{
"name": "relation_type",
"title": "合作类型",
"type": "str",
"length": 32,
"nullable": "no",
"default": "distribution",
"label": "合作类型",
"uitype": "code",
"valueField": "relation_type",
"textField": "relation_type_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "relation_type",
"textField": "relation_type_text",
"cond": "parentid='sc_relation_type'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
"data": [
{
"value": "distribution",
"text": "分销"
},
{
"value": "agency",
"text": "代理"
},
{
"value": "direct",
"text": "直供"
}
]
},
{
"name": "settlement_mode",
"title": "结算方式",
"type": "str",
"length": 32,
"nullable": "no",
"default": "discount",
"label": "结算方式",
"uitype": "code",
"valueField": "settlement_mode",
"textField": "settlement_mode_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "settlement_mode",
"textField": "settlement_mode_text",
"cond": "parentid='sc_settlement_mode'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
"data": [
{
"value": "discount",
"text": "折扣"
},
{
"value": "rebate",
"text": "返佣"
},
{
"value": "fixed",
"text": "固定价"
}
]
},
{
"name": "default_discount",
"title": "默认折扣率",
"type": "double",
"length": 5,
"dec": 4,
"default": "1.0000",
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "默认折扣率"
},
{
"name": "default_commission_rate",
"title": "默认佣金率",
"type": "double",
"length": 5,
"dec": 4,
"default": "0.0000",
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "默认佣金率"
},
{
"name": "sign_date",
"title": "签署日期",
"type": "date",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "签署日期"
},
{
"name": "start_date",
"title": "生效日期",
"type": "date",
"nullable": "no",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "生效日期"
},
{
"name": "end_date",
"title": "到期日期",
"type": "date",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "到期日期"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1",
"label": "状态",
"uitype": "code",
"valueField": "status",
"textField": "status_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "status",
"textField": "status_text",
"cond": "parentid='sc_relation_status'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
"data": [
{
"value": "1",
"text": "生效中"
},
{
"value": "2",
"text": "已到期"
},
{
"value": "0",
"text": "已终止"
}
]
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "创建人"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "更新时间"
}
]
},
"data_filter":{
"AND": [
{
"field": "relation_name",
"op": "LIKE",
"var": "relation_name"
},
{
"field": "relation_code",
"op": "LIKE",
"var": "relation_code"
},
{
"field": "relation_type",
"op": "=",
"var": "relation_type"
},
{
"field": "status",
"op": "=",
"var": "status"
}
]
},
"filter_labels":{
"relation_name": "关系名称",
"relation_code": "关系编号",
"relation_type": "合作类型",
"status": "状态"
},
"page_rows":160,
"cache_limit":5
}
,"binds":[
{
"wid": "self",
"event": "platform_supply_products",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "供销产品明细",
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=platform_supply_products",
"resizable": true,
"height": "70%",
"width": "70%"
},
"params_mapping": {
"mapping": {
"id": "relation_id",
"referer_widget": "referer_widget"
},
"need_other": false
},
"options": {
"method": "POST",
"params": {},
"url": "{{entire_url('/supplychain/platform_supply_products_list')}}"
}
}
]
}]
}

View File

@ -1,36 +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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.U('platform_supply_relations', ns)
debug('update success');
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"
}
}

View File

@ -1,37 +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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('product_supplier_mapping', ns.copy())
return {
"widgettype":"Message",
"options":{
"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"
}
}

View File

@ -1,33 +0,0 @@
ns = {
'id':params_kw['id'],
}
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('product_supplier_mapping', 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"
}
}

View File

@ -1,176 +0,0 @@
ns = params_kw.copy()
debug(f'get_product_supplier_mapping.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["created_at desc"]
sql = '''select a.*, b.product_id_text, c.product_category_id_text, d.supplier_type_text, e.supplier_org_id_text, f.external_supplier_id_text, g.buyer_org_id_text, h.relation_id_text, j.contract_id_text, k.is_preferred_text
from (select * from product_supplier_mapping where 1=1 [[filterstr]]) a left join (select id as product_id,
product_name as product_id_text from product where 1 = 1) b on a.product_id = b.product_id left join (select id as product_category_id,
name as product_category_id_text from product_category where 1 = 1) c on a.product_category_id = c.product_category_id left join (select k as supplier_type,
v as supplier_type_text from appcodes_kv where parentid='sc_supplier_type') d on a.supplier_type = d.supplier_type left join (select id as supplier_org_id,
orgname as supplier_org_id_text from organization where 1 = 1) e on a.supplier_org_id = e.supplier_org_id left join (select id as external_supplier_id,
supplier_name as external_supplier_id_text from suppliers where 1 = 1) f on a.external_supplier_id = f.external_supplier_id left join (select id as buyer_org_id,
orgname as buyer_org_id_text from organization where 1 = 1) g on a.buyer_org_id = g.buyer_org_id left join (select id as relation_id,
relation_name as relation_id_text from platform_supply_relations where 1 = 1) h on a.relation_id = h.relation_id left join (select id as contract_id,
contract_name as contract_id_text from supply_contracts where 1 = 1) j on a.contract_id = j.contract_id left join (select k as is_preferred,
v as is_preferred_text from appcodes_kv where parentid='yn') k on a.is_preferred = k.is_preferred'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "product_id",
"title": "产品ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "product_category_id",
"title": "产品分类ID",
"type": "str",
"length": 32
},
{
"name": "supplier_type",
"title": "供应商类型",
"type": "str",
"length": 32,
"nullable": "no",
"default": "internal"
},
{
"name": "supplier_org_id",
"title": "供应方机构ID(平台内)",
"type": "str",
"length": 32
},
{
"name": "external_supplier_id",
"title": "外部供应商ID",
"type": "str",
"length": 32
},
{
"name": "buyer_org_id",
"title": "采购方机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "supply_price",
"title": "供货价",
"type": "double",
"length": 15,
"dec": 4
},
{
"name": "currency",
"title": "币种",
"type": "str",
"length": 16,
"default": "CNY"
},
{
"name": "min_order_qty",
"title": "最小订货量",
"type": "int",
"default": "1"
},
{
"name": "lead_time_days",
"title": "交付周期(天)",
"type": "int"
},
{
"name": "is_preferred",
"title": "是否首选",
"type": "char",
"length": 1,
"default": "0"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1"
},
{
"name": "relation_id",
"title": "关联供销关系ID",
"type": "str",
"length": 32
},
{
"name": "contract_id",
"title": "关联供销合同ID",
"type": "str",
"length": 32
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,424 +0,0 @@
{
"widgettype":"VBox",
"options":{"cheight":40,"width":"100%"},
"subwidgets":[{
"id":"product_supplier_mapping_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"cheight":40,
"title":"产品供应映射表",
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/product_supplier_mapping_list/add_product_supplier_mapping.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/product_supplier_mapping_list/delete_product_supplier_mapping.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/product_supplier_mapping_list/update_product_supplier_mapping.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/product_supplier_mapping_list/get_product_supplier_mapping.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id"
],
"alters": {
"supplier_type": {
"uitype": "code",
"data": [
{
"value": "internal",
"text": "平台内部"
},
{
"value": "external",
"text": "外部供应商"
}
]
},
"is_preferred": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "是"
},
{
"value": "0",
"text": "否"
}
]
},
"status": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "启用"
},
{
"value": "0",
"text": "停用"
}
]
}
}
},
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "product_id",
"title": "产品ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "产品ID",
"uitype": "code",
"valueField": "product_id",
"textField": "product_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "product",
"tblvalue": "id",
"tbltext": "product_name",
"valueField": "product_id",
"textField": "product_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "product_category_id",
"title": "产品分类ID",
"type": "str",
"length": 32,
"label": "产品分类ID",
"uitype": "code",
"valueField": "product_category_id",
"textField": "product_category_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "product_category",
"tblvalue": "id",
"tbltext": "name",
"valueField": "product_category_id",
"textField": "product_category_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supplier_type",
"title": "供应商类型",
"type": "str",
"length": 32,
"nullable": "no",
"default": "internal",
"label": "供应商类型",
"uitype": "code",
"valueField": "supplier_type",
"textField": "supplier_type_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "supplier_type",
"textField": "supplier_type_text",
"cond": "parentid='sc_supplier_type'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
"data": [
{
"value": "internal",
"text": "平台内部"
},
{
"value": "external",
"text": "外部供应商"
}
]
},
{
"name": "supplier_org_id",
"title": "供应方机构ID(平台内)",
"type": "str",
"length": 32,
"label": "供应方机构ID(平台内)",
"uitype": "code",
"valueField": "supplier_org_id",
"textField": "supplier_org_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "supplier_org_id",
"textField": "supplier_org_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "external_supplier_id",
"title": "外部供应商ID",
"type": "str",
"length": 32,
"label": "外部供应商ID",
"uitype": "code",
"valueField": "external_supplier_id",
"textField": "external_supplier_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "suppliers",
"tblvalue": "id",
"tbltext": "supplier_name",
"valueField": "external_supplier_id",
"textField": "external_supplier_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "buyer_org_id",
"title": "采购方机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "采购方机构ID",
"uitype": "code",
"valueField": "buyer_org_id",
"textField": "buyer_org_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "buyer_org_id",
"textField": "buyer_org_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supply_price",
"title": "供货价",
"type": "double",
"length": 15,
"dec": 4,
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "供货价"
},
{
"name": "currency",
"title": "币种",
"type": "str",
"length": 16,
"default": "CNY",
"cwidth": 16,
"uitype": "str",
"datatype": "str",
"label": "币种"
},
{
"name": "min_order_qty",
"title": "最小订货量",
"type": "int",
"default": "1",
"length": 0,
"uitype": "int",
"datatype": "int",
"label": "最小订货量"
},
{
"name": "lead_time_days",
"title": "交付周期(天)",
"type": "int",
"length": 0,
"uitype": "int",
"datatype": "int",
"label": "交付周期(天)"
},
{
"name": "is_preferred",
"title": "是否首选",
"type": "char",
"length": 1,
"default": "0",
"label": "是否首选",
"uitype": "code",
"valueField": "is_preferred",
"textField": "is_preferred_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "is_preferred",
"textField": "is_preferred_text",
"cond": "parentid='yn'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}",
"data": [
{
"value": "1",
"text": "是"
},
{
"value": "0",
"text": "否"
}
]
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1",
"cwidth": 4,
"uitype": "code",
"datatype": "char",
"label": "状态",
"data": [
{
"value": "1",
"text": "启用"
},
{
"value": "0",
"text": "停用"
}
]
},
{
"name": "relation_id",
"title": "关联供销关系ID",
"type": "str",
"length": 32,
"label": "关联供销关系ID",
"uitype": "code",
"valueField": "relation_id",
"textField": "relation_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "platform_supply_relations",
"tblvalue": "id",
"tbltext": "relation_name",
"valueField": "relation_id",
"textField": "relation_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "contract_id",
"title": "关联供销合同ID",
"type": "str",
"length": 32,
"label": "关联供销合同ID",
"uitype": "code",
"valueField": "contract_id",
"textField": "contract_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "supply_contracts",
"tblvalue": "id",
"tbltext": "contract_name",
"valueField": "contract_id",
"textField": "contract_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "更新时间"
}
]
},
"data_filter":{
"AND": [
{
"field": "supplier_type",
"op": "=",
"var": "supplier_type"
},
{
"field": "buyer_org_id",
"op": "=",
"var": "buyer_org_id"
},
{
"field": "status",
"op": "=",
"var": "status"
}
]
},
"filter_labels":{
"supplier_type": "供应商类型",
"buyer_org_id": "采购方",
"status": "状态"
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}]
}

View File

@ -1,36 +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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.U('product_supplier_mapping', ns)
debug('update success');
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"
}
}

View File

@ -1,51 +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
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('sales_ledger', ns.copy())
return {
"widgettype":"Message",
"options":{
"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"
}
}

View File

@ -1,47 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('sales_ledger', 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"
}
}

View File

@ -1,224 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['userorgid'] = userorgid
debug(f'get_sales_ledger.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["sale_date desc","created_at desc"]
sql = '''select a.*, b.sub_reseller_id_text, c.supplier_id_text, d.agreement_id_text, e.contract_id_text, f.resellerid_text
from (select * from sales_ledger where 1=1 [[filterstr]]) a left join (select id as sub_reseller_id,
sub_reseller_name as sub_reseller_id_text from sub_resellers where 1 = 1) b on a.sub_reseller_id = b.sub_reseller_id left join (select id as supplier_id,
supplier_name as supplier_id_text from suppliers where 1 = 1) c on a.supplier_id = c.supplier_id left join (select id as agreement_id,
agreement_name as agreement_id_text from distribution_agreements where 1 = 1) d on a.agreement_id = d.agreement_id left join (select id as contract_id,
contract_name as contract_id_text from supply_contracts where 1 = 1) e on a.contract_id = e.contract_id left join (select id as resellerid,
orgname as resellerid_text from organization where 1 = 1) f on a.resellerid = f.resellerid'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "sub_reseller_id",
"title": "二级分销商ID",
"type": "str",
"length": 32
},
{
"name": "supplier_id",
"title": "供应商ID",
"type": "str",
"length": 32
},
{
"name": "agreement_id",
"title": "分销协议ID",
"type": "str",
"length": 32
},
{
"name": "contract_id",
"title": "供销合同ID",
"type": "str",
"length": 32
},
{
"name": "prodtypeid",
"title": "产品分类ID",
"type": "str",
"length": 32
},
{
"name": "productid",
"title": "产品ID",
"type": "str",
"length": 32
},
{
"name": "sale_date",
"title": "销售日期",
"type": "date",
"nullable": "no"
},
{
"name": "quantity",
"title": "销售数量",
"type": "double",
"length": 15,
"dec": 2,
"nullable": "no"
},
{
"name": "unit_price",
"title": "销售单价",
"type": "double",
"length": 15,
"dec": 4,
"nullable": "no"
},
{
"name": "supply_discount",
"title": "进货折扣",
"type": "double",
"length": 5,
"dec": 4
},
{
"name": "supply_amount",
"title": "进货金额",
"type": "double",
"length": 15,
"dec": 2
},
{
"name": "distribution_discount",
"title": "分销折扣",
"type": "double",
"length": 5,
"dec": 4
},
{
"name": "distribution_amount",
"title": "分销金额",
"type": "double",
"length": 15,
"dec": 2
},
{
"name": "profit_amount",
"title": "利润金额",
"type": "double",
"length": 15,
"dec": 2
},
{
"name": "settlement_status",
"title": "结算状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "0"
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
# 确保 logined 过滤条件始终生效
if filterjson:
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
filterjson = {'AND': [filterjson] if filterjson else []}
filterjson['AND'].append({'field': 'resellerid', 'op': '=', 'var': '__logined_orgid__'})
ns['__logined_orgid__'] = userorgid
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,389 +0,0 @@
{
"widgettype":"VBox",
"options":{"cheight":40,"width":"100%"},
"subwidgets":[{
"id":"sales_ledger_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"cheight":40,
"title":"销售记账表",
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/sales_ledger_list/add_sales_ledger.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/sales_ledger_list/delete_sales_ledger.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/sales_ledger_list/update_sales_ledger.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/sales_ledger_list/get_sales_ledger.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id"
],
"alters": {
"settlement_status": {
"uitype": "code",
"data": [
{
"value": "0",
"text": "未结算"
},
{
"value": "1",
"text": "已结算"
}
]
}
}
},
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "所属分销商机构ID",
"uitype": "code",
"valueField": "resellerid",
"textField": "resellerid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "resellerid",
"textField": "resellerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "sub_reseller_id",
"title": "二级分销商ID",
"type": "str",
"length": 32,
"label": "二级分销商ID",
"uitype": "code",
"valueField": "sub_reseller_id",
"textField": "sub_reseller_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "sub_resellers",
"tblvalue": "id",
"tbltext": "sub_reseller_name",
"valueField": "sub_reseller_id",
"textField": "sub_reseller_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supplier_id",
"title": "供应商ID",
"type": "str",
"length": 32,
"label": "供应商ID",
"uitype": "code",
"valueField": "supplier_id",
"textField": "supplier_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "suppliers",
"tblvalue": "id",
"tbltext": "supplier_name",
"valueField": "supplier_id",
"textField": "supplier_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "agreement_id",
"title": "分销协议ID",
"type": "str",
"length": 32,
"label": "分销协议ID",
"uitype": "code",
"valueField": "agreement_id",
"textField": "agreement_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "distribution_agreements",
"tblvalue": "id",
"tbltext": "agreement_name",
"valueField": "agreement_id",
"textField": "agreement_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "contract_id",
"title": "供销合同ID",
"type": "str",
"length": 32,
"label": "供销合同ID",
"uitype": "code",
"valueField": "contract_id",
"textField": "contract_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "supply_contracts",
"tblvalue": "id",
"tbltext": "contract_name",
"valueField": "contract_id",
"textField": "contract_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "prodtypeid",
"title": "产品分类ID",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "产品分类ID"
},
{
"name": "productid",
"title": "产品ID",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "产品ID"
},
{
"name": "sale_date",
"title": "销售日期",
"type": "date",
"nullable": "no",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "销售日期"
},
{
"name": "quantity",
"title": "销售数量",
"type": "double",
"length": 15,
"dec": 2,
"nullable": "no",
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "销售数量"
},
{
"name": "unit_price",
"title": "销售单价",
"type": "double",
"length": 15,
"dec": 4,
"nullable": "no",
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "销售单价"
},
{
"name": "supply_discount",
"title": "进货折扣",
"type": "double",
"length": 5,
"dec": 4,
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "进货折扣"
},
{
"name": "supply_amount",
"title": "进货金额",
"type": "double",
"length": 15,
"dec": 2,
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "进货金额"
},
{
"name": "distribution_discount",
"title": "分销折扣",
"type": "double",
"length": 5,
"dec": 4,
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "分销折扣"
},
{
"name": "distribution_amount",
"title": "分销金额",
"type": "double",
"length": 15,
"dec": 2,
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "分销金额"
},
{
"name": "profit_amount",
"title": "利润金额",
"type": "double",
"length": 15,
"dec": 2,
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "利润金额"
},
{
"name": "settlement_status",
"title": "结算状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "0",
"cwidth": 4,
"uitype": "code",
"datatype": "char",
"label": "结算状态",
"data": [
{
"value": "0",
"text": "未结算"
},
{
"value": "1",
"text": "已结算"
}
]
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "创建人"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "更新时间"
}
]
},
"data_filter":{
"AND": [
{
"field": "sale_date",
"op": ">=",
"var": "sale_date_start"
},
{
"field": "sale_date",
"op": "<=",
"var": "sale_date_end"
},
{
"field": "productid",
"op": "=",
"var": "productid"
},
{
"field": "settlement_status",
"op": "=",
"var": "settlement_status"
}
]
},
"filter_labels":{
"sale_date_start": "销售开始日期",
"sale_date_end": "销售结束日期",
"productid": "产品ID",
"settlement_status": "结算状态"
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}]
}

View File

@ -1,70 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"resellerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('sales_ledger', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('sales_ledger', ns)
debug('update success');
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"
}
}

View File

@ -1,7 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
env = request._run_ns
r = await env.create_sub_reseller(request, ns)
return r

View File

@ -1,57 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
# Cascade delete distribution_agreement_items first (by agreement_id)
_agreements = await sor.sqlExe(
"SELECT id FROM distribution_agreements WHERE sub_reseller_id = ${sid}$",
{"sid": ns['id']}
)
for _ag in (_agreements or []):
await sor.D('distribution_agreement_items', {'agreement_id': _ag.id})
# Cascade delete distribution_agreements
await sor.D('distribution_agreements', {'sub_reseller_id': ns['id']})
# Delete the sub_distributor
r = await sor.D('sub_distributors', 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"
}
}

View File

@ -1,189 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['userorgid'] = userorgid
debug(f'get_sub_distributors.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["created_at desc"]
sql = '''select a.*, b.resellerid_text
from (select * from sub_distributors where 1=1 [[filterstr]]) a left join (select id as resellerid,
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "resellerid",
"title": "所属主分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "sub_dist_code",
"title": "二级分销商编号",
"type": "str",
"length": 64,
"nullable": "no"
},
{
"name": "sub_dist_name",
"title": "二级分销商名称",
"type": "str",
"length": 255,
"nullable": "no"
},
{
"name": "contact_person",
"title": "联系人",
"type": "str",
"length": 100
},
{
"name": "contact_phone",
"title": "联系电话",
"type": "str",
"length": 50
},
{
"name": "contact_email",
"title": "联系邮箱",
"type": "str",
"length": 255
},
{
"name": "address",
"title": "地址",
"type": "str",
"length": 500
},
{
"name": "tax_number",
"title": "税号",
"type": "str",
"length": 64
},
{
"name": "bank_name",
"title": "开户银行",
"type": "str",
"length": 255
},
{
"name": "bank_account",
"title": "银行账号",
"type": "str",
"length": 64
},
{
"name": "managed_by",
"title": "负责销售ID",
"type": "str",
"length": 32
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1"
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
# 确保 logined 过滤条件始终生效
if filterjson:
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
filterjson = {'AND': [filterjson] if filterjson else []}
filterjson['AND'].append({'field': 'resellerid', 'op': '=', 'var': '__logined_orgid__'})
ns['__logined_orgid__'] = userorgid
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,393 +0,0 @@
{
"widgettype":"VBox",
"options":{"width":"100%"},
"subwidgets":[{
"id":"sub_distributors_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"title":"二级分销商表",
"toolbar":{
"tools": [
{
"selected_row": true,
"name": "distribution_agreements",
"icon": "{{entire_url('/imgs/distribution_agreement_items.svg')}}",
"label": "分销协议"
},
{
"selected_row": true,
"name": "add_admin",
"icon": "{{entire_url('/imgs/userrole.svg')}}",
"label": "添加管理员"
},
{
"selected_row": true,
"name": "reset_admin_pwd",
"icon": "{{entire_url('/imgs/key.svg')}}",
"label": "重置管理员密码"
}
]
},
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/sub_distributors_list/add_sub_distributors.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/sub_distributors_list/delete_sub_distributors.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/sub_distributors_list/update_sub_distributors.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/sub_distributors_list/get_sub_distributors.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"resellerid",
"created_by",
"created_at",
"updated_at"
],
"alters": {
"status": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "正常"
},
{
"value": "0",
"text": "停用"
}
]
}
}
},
"editexclouded":[
"id",
"resellerid",
"sub_dist_code",
"created_by",
"created_at",
"updated_at"
],
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "resellerid",
"title": "所属主分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "所属主分销商机构ID",
"uitype": "code",
"valueField": "resellerid",
"textField": "resellerid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "resellerid",
"textField": "resellerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "sub_dist_code",
"title": "二级分销商编号",
"type": "str",
"length": 64,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "二级分销商编号"
},
{
"name": "sub_dist_name",
"title": "二级分销商名称",
"type": "str",
"length": 255,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "二级分销商名称"
},
{
"name": "contact_person",
"title": "联系人",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系人"
},
{
"name": "contact_phone",
"title": "联系电话",
"type": "str",
"length": 50,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系电话"
},
{
"name": "contact_email",
"title": "联系邮箱",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系邮箱"
},
{
"name": "address",
"title": "地址",
"type": "str",
"length": 500,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "地址"
},
{
"name": "tax_number",
"title": "税号",
"type": "str",
"length": 64,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "税号"
},
{
"name": "bank_name",
"title": "开户银行",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "开户银行"
},
{
"name": "bank_account",
"title": "银行账号",
"type": "str",
"length": 64,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "银行账号"
},
{
"name": "managed_by",
"title": "负责销售ID",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "负责销售ID"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1",
"cwidth": 4,
"uitype": "code",
"datatype": "char",
"label": "状态",
"data": [
{
"value": "1",
"text": "正常"
},
{
"value": "0",
"text": "停用"
}
]
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "创建人"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "更新时间"
}
]
},
"data_filter":{
"AND": [
{
"field": "sub_dist_name",
"op": "LIKE",
"var": "sub_dist_name"
},
{
"field": "sub_dist_code",
"op": "LIKE",
"var": "sub_dist_code"
},
{
"field": "status",
"op": "=",
"var": "status"
}
]
},
"filter_labels":{
"sub_dist_name": "分销商名称",
"sub_dist_code": "分销商编号",
"status": "状态"
},
"page_rows":160,
"cache_limit":5
}
,"binds":[
{
"wid": "self",
"event": "distribution_agreements",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "分销协议",
"height": "80%",
"width": "85%"
},
"params_mapping": {
"mapping": {"id": "sub_reseller_id"},
"need_other": false
},
"options": {
"method": "GET",
"url": "{{entire_url('/supplychain/distribution_agreements_list')}}?sub_reseller_id={{params_kw.get('id','')}}"
}
},
{
"wid": "self",
"event": "add_admin",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "添加管理员",
"height": "250px",
"width": "400px"
},
"params_mapping": {
"mapping": {"id": "sub_distributor_id"},
"need_other": false
},
"options": {
"method": "POST",
"url": "{{entire_url('/supplychain/api/add_sub_distributor_admin.dspy')}}"
}
},
{
"wid": "self",
"event": "reset_admin_pwd",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "重置管理员密码",
"height": "250px",
"width": "400px"
},
"params_mapping": {
"mapping": {"id": "sub_distributor_id"},
"need_other": false
},
"options": {
"method": "POST",
"url": "{{entire_url('/supplychain/api/reset_sub_distributor_admin_pwd.dspy')}}"
}
}
]
}]
}

View File

@ -1,70 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"resellerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('sub_distributors', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('sub_distributors', ns)
debug('update success');
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"
}
}

View File

@ -1,51 +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
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('sub_resellers', ns.copy())
return {
"widgettype":"Message",
"options":{
"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"
}
}

View File

@ -1,47 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('sub_resellers', 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"
}
}

View File

@ -1,183 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['userorgid'] = userorgid
debug(f'get_sub_resellers.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["created_at desc"]
sql = '''select a.*, b.resellerid_text
from (select * from sub_resellers where 1=1 [[filterstr]]) a left join (select id as resellerid,
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "sub_reseller_code",
"title": "二级分销商编号",
"type": "str",
"length": 64,
"nullable": "no"
},
{
"name": "sub_reseller_name",
"title": "二级分销商名称",
"type": "str",
"length": 255,
"nullable": "no"
},
{
"name": "contact_person",
"title": "联系人",
"type": "str",
"length": 100
},
{
"name": "contact_phone",
"title": "联系电话",
"type": "str",
"length": 50
},
{
"name": "contact_email",
"title": "联系邮箱",
"type": "str",
"length": 255
},
{
"name": "address",
"title": "地址",
"type": "str",
"length": 500
},
{
"name": "tax_number",
"title": "税号",
"type": "str",
"length": 64
},
{
"name": "bank_name",
"title": "开户银行",
"type": "str",
"length": 255
},
{
"name": "bank_account",
"title": "银行账号",
"type": "str",
"length": 64
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1"
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
# 确保 logined 过滤条件始终生效
if filterjson:
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
filterjson = {'AND': [filterjson] if filterjson else []}
filterjson['AND'].append({'field': 'resellerid', 'op': '=', 'var': '__logined_orgid__'})
ns['__logined_orgid__'] = userorgid
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,283 +0,0 @@
{
"widgettype":"VBox",
"options":{"width":"100%"},
"subwidgets":[{
"id":"sub_resellers_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"title":"二级分销商表",
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/sub_resellers_list/add_sub_resellers.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/sub_resellers_list/delete_sub_resellers.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/sub_resellers_list/update_sub_resellers.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/sub_resellers_list/get_sub_resellers.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id"
],
"alters": {
"status": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "正常"
},
{
"value": "0",
"text": "停用"
}
]
}
}
},
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "所属分销商机构ID",
"uitype": "code",
"valueField": "resellerid",
"textField": "resellerid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "resellerid",
"textField": "resellerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "sub_reseller_code",
"title": "二级分销商编号",
"type": "str",
"length": 64,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "二级分销商编号"
},
{
"name": "sub_reseller_name",
"title": "二级分销商名称",
"type": "str",
"length": 255,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "二级分销商名称"
},
{
"name": "contact_person",
"title": "联系人",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系人"
},
{
"name": "contact_phone",
"title": "联系电话",
"type": "str",
"length": 50,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系电话"
},
{
"name": "contact_email",
"title": "联系邮箱",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系邮箱"
},
{
"name": "address",
"title": "地址",
"type": "str",
"length": 500,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "地址"
},
{
"name": "tax_number",
"title": "税号",
"type": "str",
"length": 64,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "税号"
},
{
"name": "bank_name",
"title": "开户银行",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "开户银行"
},
{
"name": "bank_account",
"title": "银行账号",
"type": "str",
"length": 64,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "银行账号"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1",
"cwidth": 4,
"uitype": "code",
"datatype": "char",
"label": "状态",
"data": [
{
"value": "1",
"text": "正常"
},
{
"value": "0",
"text": "停用"
}
]
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "创建人"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "更新时间"
}
]
},
"data_filter":{
"AND": [
{
"field": "sub_reseller_name",
"op": "LIKE",
"var": "sub_reseller_name"
},
{
"field": "status",
"op": "=",
"var": "status"
}
]
},
"filter_labels":{
"sub_reseller_name": "二级分销商名称",
"status": "状态"
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}]
}

View File

@ -1,70 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"resellerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('sub_resellers', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('sub_resellers', ns)
debug('update success');
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"
}
}

View File

@ -1,73 +0,0 @@
{
"widgettype": "VBox",
"options": {"width": "100%", "padding": "8px", "gap": "8px"},
"subwidgets": [
{
"widgettype": "InlineForm",
"id": "price_filter",
"options": {
"css": "card", "padding": "8px", "submit_label": "查询",
"fields": [
{"name": "supplier_org_id", "label": "供应商", "uitype": "str", "cwidth": 12},
{"name": "resource_type", "label": "资源类型", "uitype": "code", "cwidth": 10,
"data": [{"value": "", "text": "全部"}, {"value": "llm_model", "text": "大模型按量"}, {"value": "llm_monthly", "text": "大模型包月"}, {"value": "compute", "text": "算力"}]},
{"name": "status", "label": "状态", "uitype": "code", "cwidth": 8,
"data": [{"value": "", "text": "全部"}, {"value": "1", "text": "有效"}, {"value": "0", "text": "无效"}]}
]
},
"binds": [{
"wid": "self", "event": "submit",
"actiontype": "script", "target": "price_table",
"script": "var tbl = bricks.getWidgetById('price_table', bricks.app.root); if(tbl) await tbl.render(params);"
}]
},
{
"widgettype": "Tabular",
"id": "price_table",
"options": {
"width": "100%", "css": "card",
"data_url": "{{entire_url('/supplychain/supplier_resource_price_list/get_supplier_resource_price.dspy')}}",
"data_method": "GET", "page_rows": 20,
"toolbar": {
"tools": [
{"name": "add_price", "label": "新增定价"}
]
},
"row_options": {
"browserfields": {
"exclouded": ["id", "created_at", "updated_at"],
"alters": {
"supplier_org_id": {
"uitype": "code", "valueField": "supplier_org_id", "textField": "supplier_org_id_text",
"params": {"dbname": "supplychain", "table": "suppliers", "tblvalue": "org_id", "tbltext": "supplier_name", "valueField": "supplier_org_id", "textField": "supplier_org_id_text"},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
"resource_type": {"uitype": "code", "data": [{"value": "llm_model", "text": "大模型按量"}, {"value": "llm_monthly", "text": "大模型包月"}, {"value": "compute", "text": "算力"}]},
"price_unit": {"uitype": "code", "data": [{"value": "per_1k_tokens", "text": "每千tokens"}, {"value": "per_request", "text": "每次"}, {"value": "per_gpu_hour", "text": "每GPU时"}]},
"status": {"uitype": "code", "data": [{"value": "1", "text": "有效"}, {"value": "0", "text": "无效"}]}
}
},
"fields": [
{"name": "supplier_org_id", "title": "供应商", "type": "str", "length": 32, "cwidth": 14},
{"name": "resource_type", "title": "资源类型", "type": "str", "length": 32, "cwidth": 10},
{"name": "resource_ref_id", "title": "资源ID", "type": "str", "length": 32, "cwidth": 12},
{"name": "resource_ref_name", "title": "资源名称", "type": "str", "length": 255, "cwidth": 12},
{"name": "unit_price", "title": "统一单价", "type": "double", "length": 15, "dec": 8, "cwidth": 10},
{"name": "input_price", "title": "输入价", "type": "double", "length": 15, "dec": 8, "cwidth": 10},
{"name": "output_price", "title": "输出价", "type": "double", "length": 15, "dec": 8, "cwidth": 10},
{"name": "price_unit", "title": "单位", "type": "str", "length": 32, "cwidth": 8},
{"name": "effective_date", "title": "生效日", "type": "date", "cwidth": 10},
{"name": "expiry_date", "title": "失效日", "type": "date", "cwidth": 10},
{"name": "status", "title": "状态", "type": "char", "length": 1, "cwidth": 6}
]
}
},
"binds": [{
"wid": "self", "event": "add_price",
"actiontype": "urlwidget", "target": "PopupWindow",
"popup_options": {"title": "新增定价", "cwidth": 45, "cheight": 28},
"options": {"url": "{{entire_url('/supplychain/supplier_resource_price_list/add_supplier_resource_price.dspy')}}"}
}]
}
]
}

View File

@ -1,51 +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
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('suppliers', ns.copy())
return {
"widgettype":"Message",
"options":{
"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"
}
}

View File

@ -1,47 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('suppliers', 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"
}
}

View File

@ -1,216 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['userorgid'] = userorgid
debug(f'get_suppliers.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["created_at desc"]
sql = '''select a.*, b.resellerid_text, c.orgid_text
from (select * from suppliers where 1=1 [[filterstr]]) a left join (select id as resellerid,
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid left join (select id as orgid,
orgname as orgid_text from organization where 1 = 1) c on a.orgid = c.orgid'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "supplier_code",
"title": "供应商编号",
"type": "str",
"length": 64,
"nullable": "no"
},
{
"name": "supplier_name",
"title": "供应商名称",
"type": "str",
"length": 255,
"nullable": "no"
},
{
"name": "contact_person",
"title": "联系人",
"type": "str",
"length": 100
},
{
"name": "contact_phone",
"title": "联系电话",
"type": "str",
"length": 50
},
{
"name": "contact_email",
"title": "联系邮箱",
"type": "str",
"length": 255
},
{
"name": "address",
"title": "地址",
"type": "str",
"length": 500
},
{
"name": "tax_number",
"title": "税号",
"type": "str",
"length": 64
},
{
"name": "bank_name",
"title": "开户银行",
"type": "str",
"length": 255
},
{
"name": "bank_account",
"title": "银行账号",
"type": "str",
"length": 64
},
{
"name": "orgid",
"title": "机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "is_external",
"title": "是否外部供应商",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1"
},
{
"name": "settlement_cycle",
"title": "结算周期",
"type": "str",
"length": 20
},
{
"name": "settlement_day",
"title": "结算日",
"type": "int"
},
{
"name": "payment_type",
"title": "付款方式",
"type": "str",
"length": 20
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1"
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
# 确保 logined 过滤条件始终生效
if filterjson:
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
filterjson = {'AND': [filterjson] if filterjson else []}
filterjson['AND'].append({'field': 'resellerid', 'op': '=', 'var': '__logined_orgid__'})
ns['__logined_orgid__'] = userorgid
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,475 +0,0 @@
{
"widgettype":"VBox",
"options":{"width":"100%"},
"subwidgets":[{
"id":"suppliers_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"title":"供应商表",
"toolbar":{
"tools": [
{
"selected_row": true,
"name": "supply_contracts",
"icon": "{{entire_url('/imgs/supply_contract_items.svg')}}",
"label": "供销协议"
}
]
},
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/api/suppliers_create.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/api/suppliers_delete.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/api/suppliers_update.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/suppliers_list/get_suppliers.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"resellerid",
"created_by"
],
"alters": {
"is_external": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "外部供应商"
},
{
"value": "0",
"text": "内部供应商"
}
]
},
"payment_type": {
"uitype": "code",
"data": [
{
"value": "prepaid",
"text": "预付费"
},
{
"value": "postpaid",
"text": "后付费"
}
]
},
"settlement_cycle": {
"uitype": "code",
"data": [
{
"value": "monthly",
"text": "月结"
},
{
"value": "weekly",
"text": "周结"
},
{
"value": "biweekly",
"text": "半月结"
},
{
"value": "quarterly",
"text": "季结"
}
]
},
"status": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "正常"
},
{
"value": "0",
"text": "停用"
}
]
}
}
},
"editexclouded":[
"id",
"resellerid",
"status",
"created_by",
"created_at",
"updated_at"
],
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "所属分销商机构ID",
"uitype": "code",
"valueField": "resellerid",
"textField": "resellerid_text",
"params": {
"dbname": "sage",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "resellerid",
"textField": "resellerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supplier_code",
"title": "供应商编号",
"type": "str",
"length": 64,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "供应商编号"
},
{
"name": "supplier_name",
"title": "供应商名称",
"type": "str",
"length": 255,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "供应商名称"
},
{
"name": "contact_person",
"title": "联系人",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系人"
},
{
"name": "contact_phone",
"title": "联系电话",
"type": "str",
"length": 50,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系电话"
},
{
"name": "contact_email",
"title": "联系邮箱",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系邮箱"
},
{
"name": "address",
"title": "地址",
"type": "str",
"length": 500,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "地址"
},
{
"name": "tax_number",
"title": "税号",
"type": "str",
"length": 64,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "税号"
},
{
"name": "bank_name",
"title": "开户银行",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "开户银行"
},
{
"name": "bank_account",
"title": "银行账号",
"type": "str",
"length": 64,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "银行账号"
},
{
"name": "orgid",
"title": "机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "机构ID",
"uitype": "code",
"valueField": "orgid",
"textField": "orgid_text",
"params": {
"dbname": "sage",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "orgid",
"textField": "orgid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "is_external",
"title": "是否外部供应商",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1",
"cwidth": 4,
"uitype": "code",
"datatype": "char",
"label": "是否外部供应商",
"data": [
{
"value": "1",
"text": "外部供应商"
},
{
"value": "0",
"text": "内部供应商"
}
]
},
{
"name": "settlement_cycle",
"title": "结算周期",
"type": "str",
"length": 20,
"cwidth": 18,
"uitype": "code",
"datatype": "str",
"label": "结算周期",
"data": [
{
"value": "monthly",
"text": "月结"
},
{
"value": "weekly",
"text": "周结"
},
{
"value": "biweekly",
"text": "半月结"
},
{
"value": "quarterly",
"text": "季结"
}
]
},
{
"name": "settlement_day",
"title": "结算日",
"type": "int",
"length": 0,
"uitype": "int",
"datatype": "int",
"label": "结算日"
},
{
"name": "payment_type",
"title": "付款方式",
"type": "str",
"length": 20,
"cwidth": 18,
"uitype": "code",
"datatype": "str",
"label": "付款方式",
"data": [
{
"value": "prepaid",
"text": "预付费"
},
{
"value": "postpaid",
"text": "后付费"
}
]
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1",
"cwidth": 4,
"uitype": "code",
"datatype": "char",
"label": "状态",
"data": [
{
"value": "1",
"text": "正常"
},
{
"value": "0",
"text": "停用"
}
]
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "创建人"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "更新时间"
}
]
},
"data_filter":{
"AND": [
{
"field": "supplier_name",
"op": "LIKE",
"var": "supplier_name"
},
{
"field": "is_external",
"op": "=",
"var": "is_external"
},
{
"field": "status",
"op": "=",
"var": "status"
}
]
},
"filter_labels":{
"supplier_name": "供应商名称",
"is_external": "供应商类型",
"status": "状态"
},
"page_rows":160,
"cache_limit":5
}
,"binds":[
{
"wid": "self",
"event": "supply_contracts",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "供销协议",
"height": "80%",
"width": "85%"
},
"params_mapping": {
"mapping": {"id": "supplier_id"},
"need_other": false
},
"options": {
"method": "GET",
"url": "{{entire_url('/supplychain/supply_contracts_list')}}?supplier_id={{params_kw.get('id','')}}"
}
}
]
}]
}

View File

@ -1,70 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"resellerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('suppliers', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('suppliers', ns)
debug('update success');
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"
}
}

View File

@ -1,51 +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
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('supply_contract_items', ns.copy())
return {
"widgettype":"Message",
"options":{
"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"
}
}

View File

@ -1,47 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('supply_contract_items', 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"
}
}

View File

@ -1,145 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['userorgid'] = userorgid
debug(f'get_supply_contract_items.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["prodtypeid", "productid"]
sql = '''select a.*, b.contract_id_text, c.prodtypeid_text, d.productid_text
from (select * from supply_contract_items where 1=1 [[filterstr]]) a left join (select id as contract_id,
contract_name as contract_id_text from supply_contracts where 1 = 1) b on a.contract_id = b.contract_id left join (select id as prodtypeid,
type_name as prodtypeid_text from product_types where 1 = 1) c on a.prodtypeid = c.prodtypeid left join (select id as productid,
product_name as productid_text from products where 1 = 1) d on a.productid = d.productid'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "contract_id",
"title": "供销合同ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "prodtypeid",
"title": "产品分类ID",
"type": "str",
"length": 32
},
{
"name": "productid",
"title": "产品ID",
"type": "str",
"length": 32
},
{
"name": "discount",
"title": "进货折扣",
"type": "double",
"length": 5,
"dec": 4,
"nullable": "no",
"default": "1.0000"
},
{
"name": "settlement_price",
"title": "结算单价",
"type": "double",
"length": 15,
"dec": 4
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
# 确保 logined 过滤条件始终生效
if filterjson:
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
filterjson = {'AND': [filterjson] if filterjson else []}
filterjson['AND'].append({'field': 'resellerid', 'op': '=', 'var': '__logined_orgid__'})
ns['__logined_orgid__'] = userorgid
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,217 +0,0 @@
{
"widgettype":"VBox",
"options":{"width":"100%"},
"subwidgets":[{
"id":"supply_contract_items_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"title":"供销合同产品折扣明细表",
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/api/supply_contract_items_create.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/api/supply_contract_items_delete.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/api/supply_contract_items_update.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/supply_contract_items_list/get_supply_contract_items.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"contract_id",
"resellerid"
],
"alters": {
"contract_id": {
"uitype": "code",
"dataurl": "{{entire_url('/supplychain/api/get_search_contract_id.dspy')}}",
"valueField": "contract_id",
"textField": "contract_id_text"
},
"prodtypeid": {
"uitype": "code",
"dataurl": "{{entire_url('/supplychain/api/get_search_prodtypeid.dspy')}}",
"valueField": "prodtypeid",
"textField": "prodtypeid_text"
},
"productid": {
"uitype": "code",
"dataurl": "{{entire_url('/supplychain/api/get_search_productid.dspy')}}",
"valueField": "productid",
"textField": "productid_text"
}
}
},
"editexclouded":[
"id",
"resellerid",
"contract_id",
"created_at"
],
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "contract_id",
"title": "供销合同ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "供销合同ID",
"uitype": "code",
"valueField": "contract_id",
"textField": "contract_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "supply_contracts",
"tblvalue": "id",
"tbltext": "contract_name",
"valueField": "contract_id",
"textField": "contract_id_text"
},
"dataurl": "{{entire_url('/supplychain/api/get_search_contract_id.dspy')}}"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "所属分销商机构ID"
},
{
"name": "prodtypeid",
"title": "产品分类ID",
"type": "str",
"length": 32,
"label": "产品分类ID",
"uitype": "code",
"valueField": "prodtypeid",
"textField": "prodtypeid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "product_types",
"tblvalue": "id",
"tbltext": "type_name",
"valueField": "prodtypeid",
"textField": "prodtypeid_text"
},
"dataurl": "{{entire_url('/supplychain/api/get_search_prodtypeid.dspy')}}"
},
{
"name": "productid",
"title": "产品ID",
"type": "str",
"length": 32,
"label": "产品ID",
"uitype": "code",
"valueField": "productid",
"textField": "productid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "products",
"tblvalue": "id",
"tbltext": "product_name",
"valueField": "productid",
"textField": "productid_text"
},
"dataurl": "{{entire_url('/supplychain/api/get_search_productid.dspy')}}"
},
{
"name": "discount",
"title": "进货折扣",
"type": "double",
"length": 5,
"dec": 4,
"nullable": "no",
"default": "1.0000",
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "进货折扣"
},
{
"name": "settlement_price",
"title": "结算单价",
"type": "double",
"length": 15,
"dec": 4,
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "结算单价"
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}]
}

View File

@ -1,70 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"resellerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('supply_contract_items', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('supply_contract_items', ns)
debug('update success');
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"
}
}

View File

@ -1,52 +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
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('supply_contracts', 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"
}
}

View File

@ -1,47 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('supply_contracts', 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"
}
}

View File

@ -1,155 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['userorgid'] = userorgid
debug(f'get_supply_contracts.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["created_at desc"]
sql = '''select a.*, b.supplier_id_text, c.resellerid_text
from (select * from supply_contracts where 1=1 [[filterstr]]) a left join (select id as supplier_id,
supplier_name as supplier_id_text from suppliers where 1 = 1) b on a.supplier_id = b.supplier_id left join (select id as resellerid,
orgname as resellerid_text from organization where 1 = 1) c on a.resellerid = c.resellerid'''
filterjson = params_kw.get('data_filter')
if not filterjson:
fields = [ f['name'] for f in [
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "supplier_id",
"title": "供应商ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "contract_code",
"title": "合同编号",
"type": "str",
"length": 64,
"nullable": "no"
},
{
"name": "contract_name",
"title": "合同名称",
"type": "str",
"length": 255,
"nullable": "no"
},
{
"name": "sign_date",
"title": "签署日期",
"type": "date"
},
{
"name": "start_date",
"title": "生效日期",
"type": "date",
"nullable": "no"
},
{
"name": "end_date",
"title": "到期日期",
"type": "date"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1"
},
{
"name": "default_discount",
"title": "默认折扣",
"type": "double",
"length": 5,
"dec": 4,
"default": "1.0000"
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime"
}
] ]
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,340 +0,0 @@
{
"id":"supply_contracts_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"供销合同表",
"toolbar":{
"tools": [
{
"selected_row": true,
"name": "supply_contract_items",
"icon": "{{entire_url('/imgs/supply_contract_items.svg')}}",
"label": "产品折扣明细"
},
{
"selected_row": true,
"name": "contract_attach",
"icon": "{{entire_url('/imgs/contract_attach.svg')}}",
"label": "合同附件"
}
]
},
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_supply_contracts.dspy')}}",
"delete_data_url":"{{entire_url('delete_supply_contracts.dspy')}}",
"update_data_url":"{{entire_url('update_supply_contracts.dspy')}}"
},
"data_url":"{{entire_url('./get_supply_contracts.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"resellerid"
],
"alters": {
"supplier_id": {
"uitype": "code",
"dataurl": "{{entire_url('/supplychain/api/get_search_supplier_id.dspy')}}",
"valueField": "supplier_id",
"textField": "supplier_id_text"
},
"status": {
"uitype": "code",
"data": [
{
"value": "1",
"text": "生效中"
},
{
"value": "2",
"text": "已到期"
},
{
"value": "0",
"text": "已终止"
}
]
}
}
},
"editexclouded":[
"id",
"resellerid",
"supplier_id",
"contract_code",
"created_by",
"created_at",
"updated_at"
],
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "resellerid",
"title": "所属分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "所属分销商机构ID",
"uitype": "code",
"valueField": "resellerid",
"textField": "resellerid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "resellerid",
"textField": "resellerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supplier_id",
"title": "供应商ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "供应商ID",
"uitype": "code",
"valueField": "supplier_id",
"textField": "supplier_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "suppliers",
"tblvalue": "id",
"tbltext": "supplier_name",
"valueField": "supplier_id",
"textField": "supplier_id_text"
},
"dataurl": "{{entire_url('/supplychain/api/get_search_supplier_id.dspy')}}"
},
{
"name": "contract_code",
"title": "合同编号",
"type": "str",
"length": 64,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "合同编号"
},
{
"name": "contract_name",
"title": "合同名称",
"type": "str",
"length": 255,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "合同名称"
},
{
"name": "sign_date",
"title": "签署日期",
"type": "date",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "签署日期"
},
{
"name": "start_date",
"title": "生效日期",
"type": "date",
"nullable": "no",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "生效日期"
},
{
"name": "end_date",
"title": "到期日期",
"type": "date",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "到期日期"
},
{
"name": "status",
"title": "状态",
"type": "char",
"length": 1,
"nullable": "no",
"default": "1",
"cwidth": 4,
"uitype": "code",
"datatype": "char",
"label": "状态",
"data": [
{
"value": "1",
"text": "生效中"
},
{
"value": "2",
"text": "已到期"
},
{
"value": "0",
"text": "已终止"
}
]
},
{
"name": "default_discount",
"title": "默认折扣",
"type": "double",
"length": 5,
"dec": 4,
"default": "1.0000",
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "默认折扣"
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "创建人"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
},
{
"name": "updated_at",
"title": "更新时间",
"type": "datetime",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "更新时间"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[
{
"wid": "self",
"event": "supply_contract_items",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "产品折扣明细",
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=supply_contract_items",
"resizable": true,
"height": "70%",
"width": "70%"
},
"params_mapping": {
"mapping": {
"id": "contract_id",
"referer_widget": "referer_widget"
},
"need_other": false
},
"options": {
"method": "POST",
"params": {},
"url": "{{entire_url('/supplychain/contract_discount_setting.ui')}}"
}
},
{
"wid": "self",
"event": "contract_attach",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "合同附件",
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=contract_attach",
"resizable": true,
"height": "70%",
"width": "70%"
},
"params_mapping": {
"mapping": {
"id": "contract_id",
"referer_widget": "referer_widget",
"contract_id": "id"
},
"need_other": false
},
"options": {
"method": "POST",
"params": {},
"url": "{{entire_url('/supplychain/api/contract_attach.ui')}}?contract_type=supply"
}
}
]
}

View File

@ -1,70 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"resellerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('supply_contracts', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('supply_contracts', ns)
debug('update success');
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"
}
}

View File

@ -1,51 +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
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('supplychain_accounting', ns.copy())
return {
"widgettype":"Message",
"options":{
"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"
}
}

View File

@ -1,47 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('supplychain_accounting', 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"
}
}

View File

@ -1,246 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
ns['userorgid'] = userorgid
debug(f'get_supplychain_accounting.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = ["sale_date desc","created_at desc"]
sql = '''select a.*, b.supply_contract_id_text, c.distribution_agreement_id_text, d.sub_distributor_id_text, e.supplier_id_text, f.prodtypeid_text, g.productid_text, h.resellerid_text
from (select * from supplychain_accounting where 1=1 [[filterstr]]) a left join (select id as supply_contract_id,
contract_name as supply_contract_id_text from supply_contracts where 1 = 1) b on a.supply_contract_id = b.supply_contract_id left join (select id as distribution_agreement_id,
agreement_name as distribution_agreement_id_text from distribution_agreements where 1 = 1) c on a.distribution_agreement_id = c.distribution_agreement_id left join (select id as sub_distributor_id,
sub_dist_name as sub_distributor_id_text from sub_distributors where 1 = 1) d on a.sub_distributor_id = d.sub_distributor_id left join (select id as supplier_id,
supplier_name as supplier_id_text from suppliers where 1 = 1) e on a.supplier_id = e.supplier_id left join (select id as prodtypeid,
type_name as prodtypeid_text from product_types where 1 = 1) f on a.prodtypeid = f.prodtypeid left join (select id as productid,
product_name as productid_text from products where 1 = 1) g on a.productid = g.productid left join (select id as resellerid,
orgname as resellerid_text from organization where 1 = 1) h on a.resellerid = h.resellerid'''
filterjson = params_kw.get('data_filter')
if filterjson and isinstance(filterjson, str):
try:
filterjson = json.loads(filterjson)
except (json.JSONDecodeError, TypeError):
filterjson = None
fields_str=r'''[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "resellerid",
"title": "所属主分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "supply_contract_id",
"title": "供销合同ID",
"type": "str",
"length": 32
},
{
"name": "supply_contract_item_id",
"title": "供销合同产品明细ID",
"type": "str",
"length": 32
},
{
"name": "distribution_agreement_id",
"title": "分销协议ID",
"type": "str",
"length": 32
},
{
"name": "distribution_agreement_item_id",
"title": "分销协议产品明细ID",
"type": "str",
"length": 32
},
{
"name": "sub_distributor_id",
"title": "二级分销商ID",
"type": "str",
"length": 32
},
{
"name": "supplier_id",
"title": "供应商ID",
"type": "str",
"length": 32
},
{
"name": "prodtypeid",
"title": "产品分类ID",
"type": "str",
"length": 32
},
{
"name": "productid",
"title": "产品ID",
"type": "str",
"length": 32
},
{
"name": "quantity",
"title": "数量",
"type": "double",
"length": 15,
"dec": 4,
"nullable": "no",
"default": "0"
},
{
"name": "unit_price",
"title": "销售单价",
"type": "double",
"length": 15,
"dec": 4,
"nullable": "no",
"default": "0"
},
{
"name": "supply_discount",
"title": "进货折扣",
"type": "double",
"length": 5,
"dec": 4
},
{
"name": "supply_amount",
"title": "进货金额(应付供应商)",
"type": "double",
"length": 15,
"dec": 2,
"nullable": "no",
"default": "0"
},
{
"name": "dist_discount",
"title": "分销折扣",
"type": "double",
"length": 5,
"dec": 4
},
{
"name": "dist_amount",
"title": "分销金额(二级分销商应付)",
"type": "double",
"length": 15,
"dec": 2,
"nullable": "no",
"default": "0"
},
{
"name": "profit_amount",
"title": "利润金额",
"type": "double",
"length": 15,
"dec": 2,
"nullable": "no",
"default": "0"
},
{
"name": "sale_date",
"title": "销售日期",
"type": "date",
"nullable": "no"
},
{
"name": "source_type",
"title": "来源类型",
"type": "char",
"length": 1,
"default": "1"
},
{
"name": "source_id",
"title": "来源记录ID",
"type": "str",
"length": 32
},
{
"name": "remark",
"title": "备注",
"type": "text"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
# 确保 logined 过滤条件始终生效
if filterjson:
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
filterjson = {'AND': [filterjson] if filterjson else []}
filterjson['AND'].append({'field': 'resellerid', 'op': '=', 'var': '__logined_orgid__'})
ns['__logined_orgid__'] = userorgid
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('supplychain')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,386 +0,0 @@
{
"widgettype":"VBox",
"options":{"cheight":40,"width":"100%"},
"subwidgets":[{
"id":"supplychain_accounting_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"cheight":40,
"title":"供销记账表",
"css":"card",
"editable":{
"new_data_url":"{{entire_url('/supplychain/supplychain_accounting_list/add_supplychain_accounting.dspy')}}",
"delete_data_url":"{{entire_url('/supplychain/supplychain_accounting_list/delete_supplychain_accounting.dspy')}}",
"update_data_url":"{{entire_url('/supplychain/supplychain_accounting_list/update_supplychain_accounting.dspy')}}"
},
"data_url":"{{entire_url('/supplychain/supplychain_accounting_list/get_supplychain_accounting.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"created_by",
"created_at"
]
},
"editexclouded":[
"id",
"resellerid",
"created_by",
"created_at"
],
"fields":[
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "主键ID"
},
{
"name": "resellerid",
"title": "所属主分销商机构ID",
"type": "str",
"length": 32,
"nullable": "no",
"label": "所属主分销商机构ID",
"uitype": "code",
"valueField": "resellerid",
"textField": "resellerid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "resellerid",
"textField": "resellerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supply_contract_id",
"title": "供销合同ID",
"type": "str",
"length": 32,
"label": "供销合同ID",
"uitype": "code",
"valueField": "supply_contract_id",
"textField": "supply_contract_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "supply_contracts",
"tblvalue": "id",
"tbltext": "contract_name",
"valueField": "supply_contract_id",
"textField": "supply_contract_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supply_contract_item_id",
"title": "供销合同产品明细ID",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "供销合同产品明细ID"
},
{
"name": "distribution_agreement_id",
"title": "分销协议ID",
"type": "str",
"length": 32,
"label": "分销协议ID",
"uitype": "code",
"valueField": "distribution_agreement_id",
"textField": "distribution_agreement_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "distribution_agreements",
"tblvalue": "id",
"tbltext": "agreement_name",
"valueField": "distribution_agreement_id",
"textField": "distribution_agreement_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "distribution_agreement_item_id",
"title": "分销协议产品明细ID",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "分销协议产品明细ID"
},
{
"name": "sub_distributor_id",
"title": "二级分销商ID",
"type": "str",
"length": 32,
"label": "二级分销商ID",
"uitype": "code",
"valueField": "sub_distributor_id",
"textField": "sub_distributor_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "sub_distributors",
"tblvalue": "id",
"tbltext": "sub_dist_name",
"valueField": "sub_distributor_id",
"textField": "sub_distributor_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "supplier_id",
"title": "供应商ID",
"type": "str",
"length": 32,
"label": "供应商ID",
"uitype": "code",
"valueField": "supplier_id",
"textField": "supplier_id_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "suppliers",
"tblvalue": "id",
"tbltext": "supplier_name",
"valueField": "supplier_id",
"textField": "supplier_id_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "prodtypeid",
"title": "产品分类ID",
"type": "str",
"length": 32,
"label": "产品分类ID",
"uitype": "code",
"valueField": "prodtypeid",
"textField": "prodtypeid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "product_types",
"tblvalue": "id",
"tbltext": "type_name",
"valueField": "prodtypeid",
"textField": "prodtypeid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "productid",
"title": "产品ID",
"type": "str",
"length": 32,
"label": "产品ID",
"uitype": "code",
"valueField": "productid",
"textField": "productid_text",
"params": {
"dbname": "{{get_module_dbname('supplychain')}}",
"table": "products",
"tblvalue": "id",
"tbltext": "product_name",
"valueField": "productid",
"textField": "productid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "quantity",
"title": "数量",
"type": "double",
"length": 15,
"dec": 4,
"nullable": "no",
"default": "0",
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "数量"
},
{
"name": "unit_price",
"title": "销售单价",
"type": "double",
"length": 15,
"dec": 4,
"nullable": "no",
"default": "0",
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "销售单价"
},
{
"name": "supply_discount",
"title": "进货折扣",
"type": "double",
"length": 5,
"dec": 4,
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "进货折扣"
},
{
"name": "supply_amount",
"title": "进货金额(应付供应商)",
"type": "double",
"length": 15,
"dec": 2,
"nullable": "no",
"default": "0",
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "进货金额(应付供应商)"
},
{
"name": "dist_discount",
"title": "分销折扣",
"type": "double",
"length": 5,
"dec": 4,
"cwidth": 5,
"uitype": "float",
"datatype": "double",
"label": "分销折扣"
},
{
"name": "dist_amount",
"title": "分销金额(二级分销商应付)",
"type": "double",
"length": 15,
"dec": 2,
"nullable": "no",
"default": "0",
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "分销金额(二级分销商应付)"
},
{
"name": "profit_amount",
"title": "利润金额",
"type": "double",
"length": 15,
"dec": 2,
"nullable": "no",
"default": "0",
"cwidth": 15,
"uitype": "float",
"datatype": "double",
"label": "利润金额"
},
{
"name": "sale_date",
"title": "销售日期",
"type": "date",
"nullable": "no",
"length": 0,
"uitype": "date",
"datatype": "date",
"label": "销售日期"
},
{
"name": "source_type",
"title": "来源类型",
"type": "char",
"length": 1,
"default": "1",
"cwidth": 4,
"uitype": "str",
"datatype": "char",
"label": "来源类型"
},
{
"name": "source_id",
"title": "来源记录ID",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "来源记录ID"
},
{
"name": "remark",
"title": "备注",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "备注"
},
{
"name": "created_by",
"title": "创建人",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "创建人"
},
{
"name": "created_at",
"title": "创建时间",
"type": "datetime",
"nullable": "no",
"length": 0,
"uitype": "str",
"datatype": "datetime",
"label": "创建时间"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}]
}

View File

@ -1,70 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['resellerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('supplychain')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"resellerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('supplychain_accounting', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('supplychain_accounting', ns)
debug('update success');
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"
}
}