feat(supplychain): P0 平台内供应链 - 供销关系/产品映射/跨组织引入
新增3张核心表: - platform_supply_relations: 平台内org-to-org供销关系(分销/代理/直供) - platform_supply_products: 供销产品明细(供货价/折扣/佣金) - product_supplier_mapping: 统一产品供应映射(内部+外部) 新增3个业务API: - query_platform_suppliers: 查询平台可用供应方机构 - query_platform_products: 查询供应方产品目录 - import_supplier_product: 引入供应方产品到需求方 更新: init/data.json(6组appcodes), load_path.py(RBAC权限), menu.ui(分组菜单)
This commit is contained in:
parent
b8f361af41
commit
dff8b0de2a
@ -1 +1,55 @@
|
|||||||
{}
|
{
|
||||||
|
"appcodes": [
|
||||||
|
{
|
||||||
|
"parentid": "sc_relation_type",
|
||||||
|
"parentname": "供销关系合作类型",
|
||||||
|
"items": [
|
||||||
|
{"k": "distribution", "v": "分销"},
|
||||||
|
{"k": "agency", "v": "代理"},
|
||||||
|
{"k": "direct", "v": "直供"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parentid": "sc_settlement_mode",
|
||||||
|
"parentname": "供销结算方式",
|
||||||
|
"items": [
|
||||||
|
{"k": "discount", "v": "折扣"},
|
||||||
|
{"k": "rebate", "v": "返佣"},
|
||||||
|
{"k": "fixed", "v": "固定价"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parentid": "sc_relation_status",
|
||||||
|
"parentname": "供销关系状态",
|
||||||
|
"items": [
|
||||||
|
{"k": "1", "v": "生效中"},
|
||||||
|
{"k": "2", "v": "已到期"},
|
||||||
|
{"k": "0", "v": "已终止"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parentid": "sc_product_status",
|
||||||
|
"parentname": "供销产品状态",
|
||||||
|
"items": [
|
||||||
|
{"k": "1", "v": "启用"},
|
||||||
|
{"k": "0", "v": "停用"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parentid": "sc_supplier_type",
|
||||||
|
"parentname": "供应商类型",
|
||||||
|
"items": [
|
||||||
|
{"k": "internal", "v": "平台内部"},
|
||||||
|
{"k": "external", "v": "外部供应商"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parentid": "yn",
|
||||||
|
"parentname": "是否",
|
||||||
|
"items": [
|
||||||
|
{"k": "1", "v": "是"},
|
||||||
|
{"k": "0", "v": "否"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
35
json/platform_supply_products_list.json
Normal file
35
json/platform_supply_products_list.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"tblname": "platform_supply_products",
|
||||||
|
"alias": "platform_supply_products_list",
|
||||||
|
"title": "平台供销产品明细",
|
||||||
|
"params": {
|
||||||
|
"sortby": ["created_at desc"],
|
||||||
|
"data_filter": {
|
||||||
|
"AND": [
|
||||||
|
{"field": "relation_id", "op": "=", "var": "relation_id"},
|
||||||
|
{"field": "status", "op": "=", "var": "status"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"filter_labels": {
|
||||||
|
"relation_id": "供销关系",
|
||||||
|
"status": "状态"
|
||||||
|
},
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": ["id", "supplier_org_id", "buyer_org_id"],
|
||||||
|
"alters": {
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{"value": "1", "text": "启用"},
|
||||||
|
{"value": "0", "text": "停用"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"editable": {
|
||||||
|
"new_data_url": "{{entire_url('../api/platform_supply_products_create.dspy')}}",
|
||||||
|
"update_data_url": "{{entire_url('../api/platform_supply_products_update.dspy')}}",
|
||||||
|
"delete_data_url": "{{entire_url('../api/platform_supply_products_delete.dspy')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
64
json/platform_supply_relations_list.json
Normal file
64
json/platform_supply_relations_list.json
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"tblname": "platform_supply_relations",
|
||||||
|
"alias": "platform_supply_relations_list",
|
||||||
|
"title": "平台供销关系管理",
|
||||||
|
"params": {
|
||||||
|
"sortby": ["created_at desc"],
|
||||||
|
"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": "状态"
|
||||||
|
},
|
||||||
|
"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": "固定价"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"subtables": [
|
||||||
|
{
|
||||||
|
"field": "relation_id",
|
||||||
|
"title": "供销产品明细",
|
||||||
|
"url": "{{entire_url('../platform_supply_products_list')}}",
|
||||||
|
"subtable": "platform_supply_products"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"editable": {
|
||||||
|
"new_data_url": "{{entire_url('../api/platform_supply_relations_create.dspy')}}",
|
||||||
|
"update_data_url": "{{entire_url('../api/platform_supply_relations_update.dspy')}}",
|
||||||
|
"delete_data_url": "{{entire_url('../api/platform_supply_relations_delete.dspy')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
51
json/product_supplier_mapping_list.json
Normal file
51
json/product_supplier_mapping_list.json
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"tblname": "product_supplier_mapping",
|
||||||
|
"alias": "product_supplier_mapping_list",
|
||||||
|
"title": "产品供应映射管理",
|
||||||
|
"params": {
|
||||||
|
"sortby": ["created_at desc"],
|
||||||
|
"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": "状态"
|
||||||
|
},
|
||||||
|
"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": "停用"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"editable": {
|
||||||
|
"new_data_url": "{{entire_url('../api/product_supplier_mapping_create.dspy')}}",
|
||||||
|
"update_data_url": "{{entire_url('../api/product_supplier_mapping_update.dspy')}}",
|
||||||
|
"delete_data_url": "{{entire_url('../api/product_supplier_mapping_delete.dspy')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,126 +1,4 @@
|
|||||||
|
|
||||||
-- ./distribution_agreement_items.json
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- 建库时请用以下语句,支持emoji字符
|
|
||||||
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
||||||
drop table if exists distribution_agreement_items;
|
|
||||||
CREATE TABLE distribution_agreement_items
|
|
||||||
(
|
|
||||||
|
|
||||||
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
|
||||||
`agreement_id` VARCHAR(32) NOT NULL comment '分销协议ID',
|
|
||||||
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
|
||||||
`prodtypeid` VARCHAR(32) comment '产品分类ID',
|
|
||||||
`productid` VARCHAR(32) comment '产品ID',
|
|
||||||
`discount` double(5,4) NOT NULL DEFAULT '1.0000' comment '分销折扣',
|
|
||||||
`min_order_qty` int comment '最小订购量',
|
|
||||||
`sale_price` double(15,4) comment '分销指导价',
|
|
||||||
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
|
||||||
`created_at` datetime NOT NULL comment '创建时间'
|
|
||||||
|
|
||||||
|
|
||||||
,primary key(id)
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
CHARACTER SET utf8mb4
|
|
||||||
COLLATE utf8mb4_unicode_ci
|
|
||||||
engine=innodb
|
|
||||||
comment '分销协议产品折扣明细表'
|
|
||||||
;
|
|
||||||
|
|
||||||
CREATE INDEX distribution_agreement_items_idx_dai_agreement ON distribution_agreement_items(agreement_id);
|
|
||||||
CREATE INDEX distribution_agreement_items_idx_dai_product ON distribution_agreement_items(agreement_id,prodtypeid,productid);
|
|
||||||
|
|
||||||
-- ./suppliers.json
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- 建库时请用以下语句,支持emoji字符
|
|
||||||
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
||||||
drop table if exists suppliers;
|
|
||||||
CREATE TABLE suppliers
|
|
||||||
(
|
|
||||||
|
|
||||||
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
|
||||||
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
|
||||||
`supplier_code` VARCHAR(64) NOT NULL comment '供应商编号',
|
|
||||||
`supplier_name` VARCHAR(255) NOT NULL comment '供应商名称',
|
|
||||||
`contact_person` VARCHAR(100) comment '联系人',
|
|
||||||
`contact_phone` VARCHAR(50) comment '联系电话',
|
|
||||||
`contact_email` VARCHAR(255) comment '联系邮箱',
|
|
||||||
`address` VARCHAR(500) comment '地址',
|
|
||||||
`tax_number` VARCHAR(64) comment '税号',
|
|
||||||
`bank_name` VARCHAR(255) comment '开户银行',
|
|
||||||
`bank_account` VARCHAR(64) comment '银行账号',
|
|
||||||
`status` CHAR(1) NOT NULL DEFAULT '1' comment '状态',
|
|
||||||
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
|
||||||
`created_by` VARCHAR(32) comment '创建人',
|
|
||||||
`created_at` datetime NOT NULL comment '创建时间',
|
|
||||||
`updated_at` datetime comment '更新时间'
|
|
||||||
|
|
||||||
|
|
||||||
,primary key(id)
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
CHARACTER SET utf8mb4
|
|
||||||
COLLATE utf8mb4_unicode_ci
|
|
||||||
engine=innodb
|
|
||||||
comment '供应商表'
|
|
||||||
;
|
|
||||||
|
|
||||||
CREATE INDEX suppliers_idx_suppliers_reseller ON suppliers(resellerid);
|
|
||||||
CREATE UNIQUE INDEX suppliers_idx_suppliers_code ON suppliers(resellerid,supplier_code);
|
|
||||||
|
|
||||||
-- ./distribution_agreements.json
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- 建库时请用以下语句,支持emoji字符
|
|
||||||
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
||||||
drop table if exists distribution_agreements;
|
|
||||||
CREATE TABLE distribution_agreements
|
|
||||||
(
|
|
||||||
|
|
||||||
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
|
||||||
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
|
||||||
`sub_reseller_id` VARCHAR(32) NOT NULL comment '二级分销商ID',
|
|
||||||
`agreement_code` VARCHAR(64) NOT NULL comment '协议编号',
|
|
||||||
`agreement_name` VARCHAR(255) NOT NULL comment '协议名称',
|
|
||||||
`sign_date` date comment '签署日期',
|
|
||||||
`start_date` date NOT NULL comment '生效日期',
|
|
||||||
`end_date` date comment '到期日期',
|
|
||||||
`status` CHAR(1) NOT NULL DEFAULT '1' comment '状态',
|
|
||||||
`default_discount` double(5,4) DEFAULT '1.0000' comment '默认分销折扣',
|
|
||||||
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
|
||||||
`created_by` VARCHAR(32) comment '创建人',
|
|
||||||
`created_at` datetime NOT NULL comment '创建时间',
|
|
||||||
`updated_at` datetime comment '更新时间'
|
|
||||||
|
|
||||||
|
|
||||||
,primary key(id)
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
CHARACTER SET utf8mb4
|
|
||||||
COLLATE utf8mb4_unicode_ci
|
|
||||||
engine=innodb
|
|
||||||
comment '分销协议表'
|
|
||||||
;
|
|
||||||
|
|
||||||
CREATE INDEX distribution_agreements_idx_da_reseller ON distribution_agreements(resellerid);
|
|
||||||
CREATE INDEX distribution_agreements_idx_da_sub_reseller ON distribution_agreements(sub_reseller_id);
|
|
||||||
CREATE UNIQUE INDEX distribution_agreements_idx_da_code ON distribution_agreements(resellerid,agreement_code);
|
|
||||||
|
|
||||||
-- ./sub_resellers.json
|
-- ./sub_resellers.json
|
||||||
|
|
||||||
|
|
||||||
@ -164,6 +42,135 @@ comment '二级分销商表'
|
|||||||
CREATE INDEX sub_resellers_idx_sr_reseller ON sub_resellers(resellerid);
|
CREATE INDEX sub_resellers_idx_sr_reseller ON sub_resellers(resellerid);
|
||||||
CREATE UNIQUE INDEX sub_resellers_idx_sr_code ON sub_resellers(resellerid,sub_reseller_code);
|
CREATE UNIQUE INDEX sub_resellers_idx_sr_code ON sub_resellers(resellerid,sub_reseller_code);
|
||||||
|
|
||||||
|
-- ./distribution_agreements.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists distribution_agreements;
|
||||||
|
CREATE TABLE distribution_agreements
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
||||||
|
`sub_reseller_id` VARCHAR(32) NOT NULL comment '二级分销商ID',
|
||||||
|
`agreement_code` VARCHAR(64) NOT NULL comment '协议编号',
|
||||||
|
`agreement_name` VARCHAR(255) NOT NULL comment '协议名称',
|
||||||
|
`sign_date` date comment '签署日期',
|
||||||
|
`start_date` date NOT NULL comment '生效日期',
|
||||||
|
`end_date` date comment '到期日期',
|
||||||
|
`status` CHAR(1) NOT NULL DEFAULT '1' comment '状态',
|
||||||
|
`default_discount` double(5,4) DEFAULT '1.0000' comment '默认分销折扣',
|
||||||
|
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
||||||
|
`created_by` VARCHAR(32) comment '创建人',
|
||||||
|
`created_at` datetime NOT NULL comment '创建时间',
|
||||||
|
`updated_at` datetime comment '更新时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '分销协议表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX distribution_agreements_idx_da_reseller ON distribution_agreements(resellerid);
|
||||||
|
CREATE INDEX distribution_agreements_idx_da_sub_reseller ON distribution_agreements(sub_reseller_id);
|
||||||
|
CREATE UNIQUE INDEX distribution_agreements_idx_da_code ON distribution_agreements(resellerid,agreement_code);
|
||||||
|
|
||||||
|
-- ./sales_ledger.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists sales_ledger;
|
||||||
|
CREATE TABLE sales_ledger
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
||||||
|
`sub_reseller_id` VARCHAR(32) comment '二级分销商ID',
|
||||||
|
`supplier_id` VARCHAR(32) comment '供应商ID',
|
||||||
|
`agreement_id` VARCHAR(32) comment '分销协议ID',
|
||||||
|
`contract_id` VARCHAR(32) comment '供销合同ID',
|
||||||
|
`prodtypeid` VARCHAR(32) comment '产品分类ID',
|
||||||
|
`productid` VARCHAR(32) comment '产品ID',
|
||||||
|
`sale_date` date NOT NULL comment '销售日期',
|
||||||
|
`quantity` double(15,2) NOT NULL comment '销售数量',
|
||||||
|
`unit_price` double(15,4) NOT NULL comment '销售单价',
|
||||||
|
`supply_discount` double(5,4) comment '进货折扣',
|
||||||
|
`supply_amount` double(15,2) comment '进货金额',
|
||||||
|
`distribution_discount` double(5,4) comment '分销折扣',
|
||||||
|
`distribution_amount` double(15,2) comment '分销金额',
|
||||||
|
`profit_amount` double(15,2) comment '利润金额',
|
||||||
|
`settlement_status` CHAR(1) NOT NULL DEFAULT '0' comment '结算状态',
|
||||||
|
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
||||||
|
`created_by` VARCHAR(32) comment '创建人',
|
||||||
|
`created_at` datetime NOT NULL comment '创建时间',
|
||||||
|
`updated_at` datetime comment '更新时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '销售记账表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX sales_ledger_idx_sl_reseller ON sales_ledger(resellerid);
|
||||||
|
CREATE INDEX sales_ledger_idx_sl_sale_date ON sales_ledger(sale_date);
|
||||||
|
CREATE INDEX sales_ledger_idx_sl_product ON sales_ledger(prodtypeid,productid);
|
||||||
|
CREATE INDEX sales_ledger_idx_sl_sub_reseller ON sales_ledger(sub_reseller_id);
|
||||||
|
CREATE INDEX sales_ledger_idx_sl_supplier ON sales_ledger(supplier_id);
|
||||||
|
|
||||||
|
-- ./supply_contract_items.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists supply_contract_items;
|
||||||
|
CREATE TABLE supply_contract_items
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`contract_id` VARCHAR(32) NOT NULL comment '供销合同ID',
|
||||||
|
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
||||||
|
`prodtypeid` VARCHAR(32) comment '产品分类ID',
|
||||||
|
`productid` VARCHAR(32) comment '产品ID',
|
||||||
|
`discount` double(5,4) NOT NULL DEFAULT '1.0000' comment '进货折扣',
|
||||||
|
`settlement_price` double(15,4) comment '结算单价',
|
||||||
|
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
||||||
|
`created_at` datetime NOT NULL comment '创建时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '供销合同产品折扣明细表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX supply_contract_items_idx_sci_contract ON supply_contract_items(contract_id);
|
||||||
|
CREATE INDEX supply_contract_items_idx_sci_product ON supply_contract_items(contract_id,prodtypeid,productid);
|
||||||
|
|
||||||
-- ./supplychain_accounting.json
|
-- ./supplychain_accounting.json
|
||||||
|
|
||||||
|
|
||||||
@ -218,6 +225,49 @@ CREATE INDEX supplychain_accounting_idx_sa_subdist ON supplychain_accounting(su
|
|||||||
CREATE INDEX supplychain_accounting_idx_sa_supplier ON supplychain_accounting(supplier_id);
|
CREATE INDEX supplychain_accounting_idx_sa_supplier ON supplychain_accounting(supplier_id);
|
||||||
CREATE INDEX supplychain_accounting_idx_sa_source ON supplychain_accounting(source_type,source_id);
|
CREATE INDEX supplychain_accounting_idx_sa_source ON supplychain_accounting(source_type,source_id);
|
||||||
|
|
||||||
|
-- ./platform_supply_products.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists platform_supply_products;
|
||||||
|
CREATE TABLE platform_supply_products
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`relation_id` VARCHAR(32) NOT NULL comment '供销关系ID',
|
||||||
|
`supplier_org_id` VARCHAR(32) NOT NULL comment '供应方机构ID',
|
||||||
|
`buyer_org_id` VARCHAR(32) NOT NULL comment '需求方机构ID',
|
||||||
|
`source_product_id` VARCHAR(32) NOT NULL comment '供应方产品ID',
|
||||||
|
`supply_price` double(15,4) NOT NULL DEFAULT '0' comment '供货价',
|
||||||
|
`suggested_retail_price` double(15,4) comment '建议零售价',
|
||||||
|
`discount` double(5,4) DEFAULT '1.0000' comment '折扣率',
|
||||||
|
`commission_rate` double(5,4) DEFAULT '0.0000' comment '佣金率',
|
||||||
|
`min_order_qty` int comment '最小订货量',
|
||||||
|
`status` CHAR(1) NOT NULL DEFAULT '1' comment '状态',
|
||||||
|
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
||||||
|
`created_at` datetime NOT NULL comment '创建时间',
|
||||||
|
`updated_at` datetime comment '更新时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '平台供销产品明细表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX platform_supply_products_idx_psp_relation ON platform_supply_products(relation_id);
|
||||||
|
CREATE INDEX platform_supply_products_idx_psp_supplier_product ON platform_supply_products(supplier_org_id,source_product_id);
|
||||||
|
CREATE INDEX platform_supply_products_idx_psp_buyer ON platform_supply_products(buyer_org_id);
|
||||||
|
CREATE UNIQUE INDEX platform_supply_products_idx_psp_unique ON platform_supply_products(relation_id,source_product_id);
|
||||||
|
|
||||||
-- ./sub_distributors.json
|
-- ./sub_distributors.json
|
||||||
|
|
||||||
|
|
||||||
@ -263,7 +313,7 @@ CREATE INDEX sub_distributors_idx_sd_reseller ON sub_distributors(resellerid);
|
|||||||
CREATE UNIQUE INDEX sub_distributors_idx_sd_code ON sub_distributors(resellerid,sub_dist_code);
|
CREATE UNIQUE INDEX sub_distributors_idx_sd_code ON sub_distributors(resellerid,sub_dist_code);
|
||||||
CREATE INDEX sub_distributors_idx_sd_manager ON sub_distributors(managed_by);
|
CREATE INDEX sub_distributors_idx_sd_manager ON sub_distributors(managed_by);
|
||||||
|
|
||||||
-- ./sales_ledger.json
|
-- ./platform_supply_relations.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -271,27 +321,23 @@ CREATE INDEX sub_distributors_idx_sd_manager ON sub_distributors(managed_by);
|
|||||||
|
|
||||||
-- 建库时请用以下语句,支持emoji字符
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
drop table if exists sales_ledger;
|
drop table if exists platform_supply_relations;
|
||||||
CREATE TABLE sales_ledger
|
CREATE TABLE platform_supply_relations
|
||||||
(
|
(
|
||||||
|
|
||||||
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
`supplier_org_id` VARCHAR(32) NOT NULL comment '供应方机构ID',
|
||||||
`sub_reseller_id` VARCHAR(32) comment '二级分销商ID',
|
`buyer_org_id` VARCHAR(32) NOT NULL comment '需求方机构ID',
|
||||||
`supplier_id` VARCHAR(32) comment '供应商ID',
|
`relation_code` VARCHAR(64) NOT NULL comment '关系编号',
|
||||||
`agreement_id` VARCHAR(32) comment '分销协议ID',
|
`relation_name` VARCHAR(255) NOT NULL comment '关系名称',
|
||||||
`contract_id` VARCHAR(32) comment '供销合同ID',
|
`relation_type` VARCHAR(32) NOT NULL DEFAULT 'distribution' comment '合作类型',
|
||||||
`prodtypeid` VARCHAR(32) comment '产品分类ID',
|
`settlement_mode` VARCHAR(32) NOT NULL DEFAULT 'discount' comment '结算方式',
|
||||||
`productid` VARCHAR(32) comment '产品ID',
|
`default_discount` double(5,4) DEFAULT '1.0000' comment '默认折扣率',
|
||||||
`sale_date` date NOT NULL comment '销售日期',
|
`default_commission_rate` double(5,4) DEFAULT '0.0000' comment '默认佣金率',
|
||||||
`quantity` double(15,2) NOT NULL comment '销售数量',
|
`sign_date` date comment '签署日期',
|
||||||
`unit_price` double(15,4) NOT NULL comment '销售单价',
|
`start_date` date NOT NULL comment '生效日期',
|
||||||
`supply_discount` double(5,4) comment '进货折扣',
|
`end_date` date comment '到期日期',
|
||||||
`supply_amount` double(15,2) comment '进货金额',
|
`status` CHAR(1) NOT NULL DEFAULT '1' comment '状态',
|
||||||
`distribution_discount` double(5,4) comment '分销折扣',
|
|
||||||
`distribution_amount` double(15,2) comment '分销金额',
|
|
||||||
`profit_amount` double(15,2) comment '利润金额',
|
|
||||||
`settlement_status` CHAR(1) NOT NULL DEFAULT '0' comment '结算状态',
|
|
||||||
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
||||||
`created_by` VARCHAR(32) comment '创建人',
|
`created_by` VARCHAR(32) comment '创建人',
|
||||||
`created_at` datetime NOT NULL comment '创建时间',
|
`created_at` datetime NOT NULL comment '创建时间',
|
||||||
@ -305,14 +351,141 @@ CREATE TABLE sales_ledger
|
|||||||
CHARACTER SET utf8mb4
|
CHARACTER SET utf8mb4
|
||||||
COLLATE utf8mb4_unicode_ci
|
COLLATE utf8mb4_unicode_ci
|
||||||
engine=innodb
|
engine=innodb
|
||||||
comment '销售记账表'
|
comment '平台内供销关系表'
|
||||||
;
|
;
|
||||||
|
|
||||||
CREATE INDEX sales_ledger_idx_sl_reseller ON sales_ledger(resellerid);
|
CREATE INDEX platform_supply_relations_idx_psr_supplier ON platform_supply_relations(supplier_org_id);
|
||||||
CREATE INDEX sales_ledger_idx_sl_sale_date ON sales_ledger(sale_date);
|
CREATE INDEX platform_supply_relations_idx_psr_buyer ON platform_supply_relations(buyer_org_id);
|
||||||
CREATE INDEX sales_ledger_idx_sl_product ON sales_ledger(prodtypeid,productid);
|
CREATE INDEX platform_supply_relations_idx_psr_pair ON platform_supply_relations(supplier_org_id,buyer_org_id);
|
||||||
CREATE INDEX sales_ledger_idx_sl_sub_reseller ON sales_ledger(sub_reseller_id);
|
CREATE UNIQUE INDEX platform_supply_relations_idx_psr_code ON platform_supply_relations(supplier_org_id,buyer_org_id,relation_code);
|
||||||
CREATE INDEX sales_ledger_idx_sl_supplier ON sales_ledger(supplier_id);
|
CREATE INDEX platform_supply_relations_idx_psr_status ON platform_supply_relations(status);
|
||||||
|
|
||||||
|
-- ./suppliers.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists suppliers;
|
||||||
|
CREATE TABLE suppliers
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
||||||
|
`supplier_code` VARCHAR(64) NOT NULL comment '供应商编号',
|
||||||
|
`supplier_name` VARCHAR(255) NOT NULL comment '供应商名称',
|
||||||
|
`contact_person` VARCHAR(100) comment '联系人',
|
||||||
|
`contact_phone` VARCHAR(50) comment '联系电话',
|
||||||
|
`contact_email` VARCHAR(255) comment '联系邮箱',
|
||||||
|
`address` VARCHAR(500) comment '地址',
|
||||||
|
`tax_number` VARCHAR(64) comment '税号',
|
||||||
|
`bank_name` VARCHAR(255) comment '开户银行',
|
||||||
|
`bank_account` VARCHAR(64) comment '银行账号',
|
||||||
|
`status` CHAR(1) NOT NULL DEFAULT '1' comment '状态',
|
||||||
|
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
||||||
|
`created_by` VARCHAR(32) comment '创建人',
|
||||||
|
`created_at` datetime NOT NULL comment '创建时间',
|
||||||
|
`updated_at` datetime comment '更新时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '供应商表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX suppliers_idx_suppliers_reseller ON suppliers(resellerid);
|
||||||
|
CREATE UNIQUE INDEX suppliers_idx_suppliers_code ON suppliers(resellerid,supplier_code);
|
||||||
|
|
||||||
|
-- ./product_supplier_mapping.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists product_supplier_mapping;
|
||||||
|
CREATE TABLE product_supplier_mapping
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`product_id` VARCHAR(32) NOT NULL comment '产品ID',
|
||||||
|
`product_category_id` VARCHAR(32) comment '产品分类ID',
|
||||||
|
`supplier_type` VARCHAR(32) NOT NULL DEFAULT 'internal' comment '供应商类型',
|
||||||
|
`supplier_org_id` VARCHAR(32) comment '供应方机构ID(平台内)',
|
||||||
|
`external_supplier_id` VARCHAR(32) comment '外部供应商ID',
|
||||||
|
`buyer_org_id` VARCHAR(32) NOT NULL comment '采购方机构ID',
|
||||||
|
`supply_price` double(15,4) comment '供货价',
|
||||||
|
`currency` VARCHAR(16) DEFAULT 'CNY' comment '币种',
|
||||||
|
`min_order_qty` int DEFAULT '1' comment '最小订货量',
|
||||||
|
`lead_time_days` int comment '交付周期(天)',
|
||||||
|
`is_preferred` CHAR(1) DEFAULT '0' comment '是否首选',
|
||||||
|
`status` CHAR(1) NOT NULL DEFAULT '1' comment '状态',
|
||||||
|
`relation_id` VARCHAR(32) comment '关联供销关系ID',
|
||||||
|
`contract_id` VARCHAR(32) comment '关联供销合同ID',
|
||||||
|
`created_at` datetime NOT NULL comment '创建时间',
|
||||||
|
`updated_at` datetime comment '更新时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '产品供应映射表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX product_supplier_mapping_idx_psm_product ON product_supplier_mapping(product_id);
|
||||||
|
CREATE INDEX product_supplier_mapping_idx_psm_supplier_org ON product_supplier_mapping(supplier_org_id);
|
||||||
|
CREATE INDEX product_supplier_mapping_idx_psm_ext_supplier ON product_supplier_mapping(external_supplier_id);
|
||||||
|
CREATE INDEX product_supplier_mapping_idx_psm_buyer ON product_supplier_mapping(buyer_org_id);
|
||||||
|
CREATE UNIQUE INDEX product_supplier_mapping_idx_psm_unique ON product_supplier_mapping(product_id,supplier_type,supplier_org_id,external_supplier_id,buyer_org_id);
|
||||||
|
|
||||||
|
-- ./distribution_agreement_items.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists distribution_agreement_items;
|
||||||
|
CREATE TABLE distribution_agreement_items
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`agreement_id` VARCHAR(32) NOT NULL comment '分销协议ID',
|
||||||
|
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
||||||
|
`prodtypeid` VARCHAR(32) comment '产品分类ID',
|
||||||
|
`productid` VARCHAR(32) comment '产品ID',
|
||||||
|
`discount` double(5,4) NOT NULL DEFAULT '1.0000' comment '分销折扣',
|
||||||
|
`min_order_qty` int comment '最小订购量',
|
||||||
|
`sale_price` double(15,4) comment '分销指导价',
|
||||||
|
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
||||||
|
`created_at` datetime NOT NULL comment '创建时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '分销协议产品折扣明细表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX distribution_agreement_items_idx_dai_agreement ON distribution_agreement_items(agreement_id);
|
||||||
|
CREATE INDEX distribution_agreement_items_idx_dai_product ON distribution_agreement_items(agreement_id,prodtypeid,productid);
|
||||||
|
|
||||||
-- ./supply_contracts.json
|
-- ./supply_contracts.json
|
||||||
|
|
||||||
@ -356,39 +529,3 @@ CREATE INDEX supply_contracts_idx_sc_reseller ON supply_contracts(resellerid);
|
|||||||
CREATE INDEX supply_contracts_idx_sc_supplier ON supply_contracts(supplier_id);
|
CREATE INDEX supply_contracts_idx_sc_supplier ON supply_contracts(supplier_id);
|
||||||
CREATE UNIQUE INDEX supply_contracts_idx_sc_code ON supply_contracts(resellerid,contract_code);
|
CREATE UNIQUE INDEX supply_contracts_idx_sc_code ON supply_contracts(resellerid,contract_code);
|
||||||
|
|
||||||
-- ./supply_contract_items.json
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- 建库时请用以下语句,支持emoji字符
|
|
||||||
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
||||||
drop table if exists supply_contract_items;
|
|
||||||
CREATE TABLE supply_contract_items
|
|
||||||
(
|
|
||||||
|
|
||||||
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
|
||||||
`contract_id` VARCHAR(32) NOT NULL comment '供销合同ID',
|
|
||||||
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
|
||||||
`prodtypeid` VARCHAR(32) comment '产品分类ID',
|
|
||||||
`productid` VARCHAR(32) comment '产品ID',
|
|
||||||
`discount` double(5,4) NOT NULL DEFAULT '1.0000' comment '进货折扣',
|
|
||||||
`settlement_price` double(15,4) comment '结算单价',
|
|
||||||
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
|
||||||
`created_at` datetime NOT NULL comment '创建时间'
|
|
||||||
|
|
||||||
|
|
||||||
,primary key(id)
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
CHARACTER SET utf8mb4
|
|
||||||
COLLATE utf8mb4_unicode_ci
|
|
||||||
engine=innodb
|
|
||||||
comment '供销合同产品折扣明细表'
|
|
||||||
;
|
|
||||||
|
|
||||||
CREATE INDEX supply_contract_items_idx_sci_contract ON supply_contract_items(contract_id);
|
|
||||||
CREATE INDEX supply_contract_items_idx_sci_product ON supply_contract_items(contract_id,prodtypeid,productid);
|
|
||||||
|
|
||||||
|
|||||||
163
models/platform_supply_products.json
Normal file
163
models/platform_supply_products.json
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
{
|
||||||
|
"summary": [
|
||||||
|
{
|
||||||
|
"name": "platform_supply_products",
|
||||||
|
"title": "平台供销产品明细表",
|
||||||
|
"primary": ["id"],
|
||||||
|
"catelog": "relation"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"name": "idx_psp_relation",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["relation_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psp_supplier_product",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["supplier_org_id", "source_product_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psp_buyer",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["buyer_org_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psp_unique",
|
||||||
|
"idxtype": "unique",
|
||||||
|
"idxfields": ["relation_id", "source_product_id"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"codes": [
|
||||||
|
{
|
||||||
|
"field": "relation_id",
|
||||||
|
"table": "platform_supply_relations",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "relation_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "supplier_org_id",
|
||||||
|
"table": "organization",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "orgname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "buyer_org_id",
|
||||||
|
"table": "organization",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "orgname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "source_product_id",
|
||||||
|
"table": "product",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "product_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='sc_product_status'"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
187
models/platform_supply_relations.json
Normal file
187
models/platform_supply_relations.json
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
{
|
||||||
|
"summary": [
|
||||||
|
{
|
||||||
|
"name": "platform_supply_relations",
|
||||||
|
"title": "平台内供销关系表",
|
||||||
|
"primary": ["id"],
|
||||||
|
"catelog": "entity"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"name": "idx_psr_supplier",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["supplier_org_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psr_buyer",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["buyer_org_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psr_pair",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["supplier_org_id", "buyer_org_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psr_code",
|
||||||
|
"idxtype": "unique",
|
||||||
|
"idxfields": ["supplier_org_id", "buyer_org_id", "relation_code"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psr_status",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["status"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"codes": [
|
||||||
|
{
|
||||||
|
"field": "supplier_org_id",
|
||||||
|
"table": "organization",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "orgname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "buyer_org_id",
|
||||||
|
"table": "organization",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "orgname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "relation_type",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='sc_relation_type'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "settlement_mode",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='sc_settlement_mode'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='sc_relation_status'"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
207
models/product_supplier_mapping.json
Normal file
207
models/product_supplier_mapping.json
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
{
|
||||||
|
"summary": [
|
||||||
|
{
|
||||||
|
"name": "product_supplier_mapping",
|
||||||
|
"title": "产品供应映射表",
|
||||||
|
"primary": ["id"],
|
||||||
|
"catelog": "relation"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"name": "idx_psm_product",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["product_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psm_supplier_org",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["supplier_org_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psm_ext_supplier",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["external_supplier_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psm_buyer",
|
||||||
|
"idxtype": "index",
|
||||||
|
"idxfields": ["buyer_org_id"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "idx_psm_unique",
|
||||||
|
"idxtype": "unique",
|
||||||
|
"idxfields": ["product_id", "supplier_type", "supplier_org_id", "external_supplier_id", "buyer_org_id"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"codes": [
|
||||||
|
{
|
||||||
|
"field": "product_id",
|
||||||
|
"table": "product",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "product_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "product_category_id",
|
||||||
|
"table": "product_category",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "supplier_type",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='sc_supplier_type'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "supplier_org_id",
|
||||||
|
"table": "organization",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "orgname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "external_supplier_id",
|
||||||
|
"table": "suppliers",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "supplier_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "buyer_org_id",
|
||||||
|
"table": "organization",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "orgname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "relation_id",
|
||||||
|
"table": "platform_supply_relations",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "relation_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "contract_id",
|
||||||
|
"table": "supply_contracts",
|
||||||
|
"valuefield": "id",
|
||||||
|
"textfield": "contract_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "is_preferred",
|
||||||
|
"table": "appcodes_kv",
|
||||||
|
"valuefield": "k",
|
||||||
|
"textfield": "v",
|
||||||
|
"cond": "parentid='yn'"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -58,6 +58,9 @@ PATHS_ANY = [
|
|||||||
"/supplychain/distribution_agreements_list",
|
"/supplychain/distribution_agreements_list",
|
||||||
"/supplychain/distribution_agreement_items_list",
|
"/supplychain/distribution_agreement_items_list",
|
||||||
"/supplychain/supplychain_accounting_list",
|
"/supplychain/supplychain_accounting_list",
|
||||||
|
"/supplychain/platform_supply_relations_list",
|
||||||
|
"/supplychain/platform_supply_products_list",
|
||||||
|
"/supplychain/product_supplier_mapping_list",
|
||||||
]
|
]
|
||||||
|
|
||||||
# logined — 需要认证的页面和 API
|
# logined — 需要认证的页面和 API
|
||||||
@ -111,6 +114,26 @@ PATHS_LOGINED = [
|
|||||||
"/supplychain/api/calculate_accounting.dspy",
|
"/supplychain/api/calculate_accounting.dspy",
|
||||||
"/supplychain/api/query_supply_discount.dspy",
|
"/supplychain/api/query_supply_discount.dspy",
|
||||||
"/supplychain/api/query_dist_discount.dspy",
|
"/supplychain/api/query_dist_discount.dspy",
|
||||||
|
# 平台供销关系
|
||||||
|
"/supplychain/platform_supply_relations_list/index.ui",
|
||||||
|
"/supplychain/platform_supply_products_list/index.ui",
|
||||||
|
"/supplychain/product_supplier_mapping_list/index.ui",
|
||||||
|
# CRUD API — platform_supply_relations
|
||||||
|
"/supplychain/api/platform_supply_relations_create.dspy",
|
||||||
|
"/supplychain/api/platform_supply_relations_update.dspy",
|
||||||
|
"/supplychain/api/platform_supply_relations_delete.dspy",
|
||||||
|
# CRUD API — platform_supply_products
|
||||||
|
"/supplychain/api/platform_supply_products_create.dspy",
|
||||||
|
"/supplychain/api/platform_supply_products_update.dspy",
|
||||||
|
"/supplychain/api/platform_supply_products_delete.dspy",
|
||||||
|
# CRUD API — product_supplier_mapping
|
||||||
|
"/supplychain/api/product_supplier_mapping_create.dspy",
|
||||||
|
"/supplychain/api/product_supplier_mapping_update.dspy",
|
||||||
|
"/supplychain/api/product_supplier_mapping_delete.dspy",
|
||||||
|
# 平台供应链业务 API
|
||||||
|
"/supplychain/api/query_platform_suppliers.dspy",
|
||||||
|
"/supplychain/api/query_platform_products.dspy",
|
||||||
|
"/supplychain/api/import_supplier_product.dspy",
|
||||||
]
|
]
|
||||||
|
|
||||||
# 角色专属权限
|
# 角色专属权限
|
||||||
@ -132,6 +155,25 @@ PATHS_OPERATOR = [
|
|||||||
"/supplychain/api/supply_contract_items_create.dspy",
|
"/supplychain/api/supply_contract_items_create.dspy",
|
||||||
"/supplychain/api/supply_contract_items_update.dspy",
|
"/supplychain/api/supply_contract_items_update.dspy",
|
||||||
"/supplychain/api/supply_contract_items_delete.dspy",
|
"/supplychain/api/supply_contract_items_delete.dspy",
|
||||||
|
# 平台供销关系管理
|
||||||
|
"/supplychain/platform_supply_relations_list",
|
||||||
|
"/supplychain/platform_supply_relations_list/index.ui",
|
||||||
|
"/supplychain/api/platform_supply_relations_create.dspy",
|
||||||
|
"/supplychain/api/platform_supply_relations_update.dspy",
|
||||||
|
"/supplychain/api/platform_supply_relations_delete.dspy",
|
||||||
|
"/supplychain/platform_supply_products_list",
|
||||||
|
"/supplychain/platform_supply_products_list/index.ui",
|
||||||
|
"/supplychain/api/platform_supply_products_create.dspy",
|
||||||
|
"/supplychain/api/platform_supply_products_update.dspy",
|
||||||
|
"/supplychain/api/platform_supply_products_delete.dspy",
|
||||||
|
"/supplychain/product_supplier_mapping_list",
|
||||||
|
"/supplychain/product_supplier_mapping_list/index.ui",
|
||||||
|
"/supplychain/api/product_supplier_mapping_create.dspy",
|
||||||
|
"/supplychain/api/product_supplier_mapping_update.dspy",
|
||||||
|
"/supplychain/api/product_supplier_mapping_delete.dspy",
|
||||||
|
"/supplychain/api/query_platform_suppliers.dspy",
|
||||||
|
"/supplychain/api/query_platform_products.dspy",
|
||||||
|
"/supplychain/api/import_supplier_product.dspy",
|
||||||
]
|
]
|
||||||
|
|
||||||
PATHS_SALE = [
|
PATHS_SALE = [
|
||||||
|
|||||||
45
wwwroot/api/import_supplier_product.dspy
Normal file
45
wwwroot/api/import_supplier_product.dspy
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import json
|
||||||
|
from sqlor import sqlExe
|
||||||
|
from uuid import uuid4
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
# 引入供应方产品到需求方:创建 product_supplier_mapping 记录
|
||||||
|
source_product_id = params_kw.get("source_product_id", "")
|
||||||
|
supplier_org_id = params_kw.get("supplier_org_id", "")
|
||||||
|
relation_id = params_kw.get("relation_id", "")
|
||||||
|
supply_price = params_kw.get("supply_price", "0")
|
||||||
|
suggested_retail_price = params_kw.get("suggested_retail_price", "")
|
||||||
|
min_order_qty = params_kw.get("min_order_qty", "1")
|
||||||
|
|
||||||
|
if not all([source_product_id, supplier_org_id, relation_id]):
|
||||||
|
print(json.dumps({"status": "error", "message": "source_product_id, supplier_org_id, relation_id are required"}))
|
||||||
|
else:
|
||||||
|
user_org_id = await get_user_orgid()
|
||||||
|
new_id = uuid4().hex
|
||||||
|
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
# 获取产品分类
|
||||||
|
prod_sql = "SELECT category_id FROM product WHERE id = ${pid}$"
|
||||||
|
prod = await sqlExe(prod_sql, {"pid": source_product_id})
|
||||||
|
cat_id = prod[0].category_id if prod else ""
|
||||||
|
|
||||||
|
sql = """
|
||||||
|
INSERT INTO product_supplier_mapping
|
||||||
|
(id, product_id, product_category_id, supplier_type, supplier_org_id,
|
||||||
|
buyer_org_id, supply_price, min_order_qty, status, relation_id, created_at)
|
||||||
|
VALUES
|
||||||
|
(${id}$, ${product_id}$, ${category_id}$, 'internal', ${supplier_org_id}$,
|
||||||
|
${buyer_org_id}$, ${supply_price}$, ${min_order_qty}$, '1', ${relation_id}$, ${created_at}$)
|
||||||
|
"""
|
||||||
|
await sqlExe(sql, {
|
||||||
|
"id": new_id,
|
||||||
|
"product_id": source_product_id,
|
||||||
|
"category_id": cat_id,
|
||||||
|
"supplier_org_id": supplier_org_id,
|
||||||
|
"buyer_org_id": user_org_id,
|
||||||
|
"supply_price": supply_price,
|
||||||
|
"min_order_qty": min_order_qty,
|
||||||
|
"relation_id": relation_id,
|
||||||
|
"created_at": now
|
||||||
|
})
|
||||||
|
print(json.dumps({"status": "ok", "message": "产品引入成功", "id": new_id}))
|
||||||
9
wwwroot/api/platform_supply_products_create.dspy
Normal file
9
wwwroot/api/platform_supply_products_create.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
env = ServerEnv()
|
||||||
|
create_func = getattr(env, 'create_platform_supply_products', None)
|
||||||
|
if create_func is None:
|
||||||
|
print(json.dumps({"status": "error", "message": "create_platform_supply_products function not found"}))
|
||||||
|
else:
|
||||||
|
result = await create_func(request, params_kw)
|
||||||
|
print(result)
|
||||||
9
wwwroot/api/platform_supply_products_delete.dspy
Normal file
9
wwwroot/api/platform_supply_products_delete.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
env = ServerEnv()
|
||||||
|
delete_func = getattr(env, 'delete_platform_supply_products', None)
|
||||||
|
if delete_func is None:
|
||||||
|
print(json.dumps({"status": "error", "message": "delete_platform_supply_products function not found"}))
|
||||||
|
else:
|
||||||
|
result = await delete_func(request, params_kw)
|
||||||
|
print(result)
|
||||||
9
wwwroot/api/platform_supply_products_update.dspy
Normal file
9
wwwroot/api/platform_supply_products_update.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
env = ServerEnv()
|
||||||
|
update_func = getattr(env, 'update_platform_supply_products', None)
|
||||||
|
if update_func is None:
|
||||||
|
print(json.dumps({"status": "error", "message": "update_platform_supply_products function not found"}))
|
||||||
|
else:
|
||||||
|
result = await update_func(request, params_kw)
|
||||||
|
print(result)
|
||||||
9
wwwroot/api/platform_supply_relations_create.dspy
Normal file
9
wwwroot/api/platform_supply_relations_create.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
env = ServerEnv()
|
||||||
|
create_func = getattr(env, 'create_platform_supply_relations', None)
|
||||||
|
if create_func is None:
|
||||||
|
print(json.dumps({"status": "error", "message": "create_platform_supply_relations function not found"}))
|
||||||
|
else:
|
||||||
|
result = await create_func(request, params_kw)
|
||||||
|
print(result)
|
||||||
9
wwwroot/api/platform_supply_relations_delete.dspy
Normal file
9
wwwroot/api/platform_supply_relations_delete.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
env = ServerEnv()
|
||||||
|
delete_func = getattr(env, 'delete_platform_supply_relations', None)
|
||||||
|
if delete_func is None:
|
||||||
|
print(json.dumps({"status": "error", "message": "delete_platform_supply_relations function not found"}))
|
||||||
|
else:
|
||||||
|
result = await delete_func(request, params_kw)
|
||||||
|
print(result)
|
||||||
9
wwwroot/api/platform_supply_relations_update.dspy
Normal file
9
wwwroot/api/platform_supply_relations_update.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
env = ServerEnv()
|
||||||
|
update_func = getattr(env, 'update_platform_supply_relations', None)
|
||||||
|
if update_func is None:
|
||||||
|
print(json.dumps({"status": "error", "message": "update_platform_supply_relations function not found"}))
|
||||||
|
else:
|
||||||
|
result = await update_func(request, params_kw)
|
||||||
|
print(result)
|
||||||
9
wwwroot/api/product_supplier_mapping_create.dspy
Normal file
9
wwwroot/api/product_supplier_mapping_create.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
env = ServerEnv()
|
||||||
|
create_func = getattr(env, 'create_product_supplier_mapping', None)
|
||||||
|
if create_func is None:
|
||||||
|
print(json.dumps({"status": "error", "message": "create_product_supplier_mapping function not found"}))
|
||||||
|
else:
|
||||||
|
result = await create_func(request, params_kw)
|
||||||
|
print(result)
|
||||||
9
wwwroot/api/product_supplier_mapping_delete.dspy
Normal file
9
wwwroot/api/product_supplier_mapping_delete.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
env = ServerEnv()
|
||||||
|
delete_func = getattr(env, 'delete_product_supplier_mapping', None)
|
||||||
|
if delete_func is None:
|
||||||
|
print(json.dumps({"status": "error", "message": "delete_product_supplier_mapping function not found"}))
|
||||||
|
else:
|
||||||
|
result = await delete_func(request, params_kw)
|
||||||
|
print(result)
|
||||||
9
wwwroot/api/product_supplier_mapping_update.dspy
Normal file
9
wwwroot/api/product_supplier_mapping_update.dspy
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
from ahserver.serverenv import ServerEnv
|
||||||
|
env = ServerEnv()
|
||||||
|
update_func = getattr(env, 'update_product_supplier_mapping', None)
|
||||||
|
if update_func is None:
|
||||||
|
print(json.dumps({"status": "error", "message": "update_product_supplier_mapping function not found"}))
|
||||||
|
else:
|
||||||
|
result = await update_func(request, params_kw)
|
||||||
|
print(result)
|
||||||
23
wwwroot/api/query_platform_products.dspy
Normal file
23
wwwroot/api/query_platform_products.dspy
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import json
|
||||||
|
from sqlor import sqlExe
|
||||||
|
|
||||||
|
# 查询某供应方机构的可用产品列表
|
||||||
|
supplier_org_id = params_kw.get("supplier_org_id", "")
|
||||||
|
if not supplier_org_id:
|
||||||
|
print(json.dumps({"status": "error", "message": "supplier_org_id is required"}))
|
||||||
|
else:
|
||||||
|
sql = """
|
||||||
|
SELECT p.id, p.product_code, p.product_name, p.product_type,
|
||||||
|
p.brief_intro, p.price, p.currency, p.status,
|
||||||
|
pc.name as category_name
|
||||||
|
FROM product p
|
||||||
|
LEFT JOIN product_category pc ON p.category_id = pc.id
|
||||||
|
WHERE p.org_id = ${supplier_org_id}$
|
||||||
|
AND p.status = '1'
|
||||||
|
ORDER BY p.sort_order, p.product_name
|
||||||
|
"""
|
||||||
|
rows = await sqlExe(sql, {"supplier_org_id": supplier_org_id})
|
||||||
|
print(json.dumps([{"id": r.id, "product_code": r.product_code,
|
||||||
|
"product_name": r.product_name, "product_type": r.product_type,
|
||||||
|
"brief_intro": r.brief_intro, "price": r.price, "currency": r.currency,
|
||||||
|
"category_name": r.category_name} for r in rows], ensure_ascii=False))
|
||||||
16
wwwroot/api/query_platform_suppliers.dspy
Normal file
16
wwwroot/api/query_platform_suppliers.dspy
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import json
|
||||||
|
from sqlor import sqlExe
|
||||||
|
|
||||||
|
# 查询平台上所有可作为供应方的机构(排除当前用户的机构)
|
||||||
|
user_org_id = await get_user_orgid()
|
||||||
|
sql = """
|
||||||
|
SELECT id, orgname, orgabbr, contactor, contactor_phone, main_business
|
||||||
|
FROM organization
|
||||||
|
WHERE id != ${user_org_id}$
|
||||||
|
AND (del_flg IS NULL OR del_flg = '0')
|
||||||
|
ORDER BY orgname
|
||||||
|
"""
|
||||||
|
rows = await sqlExe(sql, {"user_org_id": user_org_id})
|
||||||
|
print(json.dumps([{"id": r.id, "orgname": r.orgname, "orgabbr": r.orgabbr,
|
||||||
|
"contactor": r.contactor, "contactor_phone": r.contactor_phone,
|
||||||
|
"main_business": r.main_business} for r in rows], ensure_ascii=False))
|
||||||
@ -32,6 +32,11 @@ from (select * from distribution_agreement_items where 1=1 [[filterstr]]) a left
|
|||||||
agreement_name as agreement_id_text from distribution_agreements where 1 = 1) b on a.agreement_id = b.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')
|
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'''[
|
fields_str=r'''[
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -103,6 +108,17 @@ ori_fields = json.loads(fields_str)
|
|||||||
if not filterjson:
|
if not filterjson:
|
||||||
fields = [ f['name'] for f in ori_fields ]
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
filterjson = default_filterjson(fields, ns)
|
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 = ns.copy()
|
||||||
filterdic['filterstr'] = ''
|
filterdic['filterstr'] = ''
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"widgettype":"VBox",
|
"widgettype":"VBox",
|
||||||
"options": {
|
"options":{"cheight":40,"width":"100%"},
|
||||||
"cheight": 40,
|
"subwidgets":[{
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"distribution_agreement_items_tbl",
|
"id":"distribution_agreement_items_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
@ -171,12 +168,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"page_rows":160,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
|
|
||||||
,"binds":[]
|
,"binds":[]
|
||||||
|
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@ -33,6 +33,11 @@ from (select * from distribution_agreements where 1=1 [[filterstr]]) a left join
|
|||||||
orgname as resellerid_text from organization where 1 = 1) c on a.resellerid = c.resellerid'''
|
orgname as resellerid_text from organization where 1 = 1) c on a.resellerid = c.resellerid'''
|
||||||
|
|
||||||
filterjson = params_kw.get('data_filter')
|
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'''[
|
fields_str=r'''[
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -128,6 +133,17 @@ ori_fields = json.loads(fields_str)
|
|||||||
if not filterjson:
|
if not filterjson:
|
||||||
fields = [ f['name'] for f in ori_fields ]
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
filterjson = default_filterjson(fields, ns)
|
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 = ns.copy()
|
||||||
filterdic['filterstr'] = ''
|
filterdic['filterstr'] = ''
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"widgettype":"VBox",
|
"widgettype":"VBox",
|
||||||
"options": {
|
"options":{"cheight":40,"width":"100%"},
|
||||||
"cheight": 40,
|
"subwidgets":[{
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"distribution_agreements_tbl",
|
"id":"distribution_agreements_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
@ -262,6 +259,36 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"data_filter":{
|
||||||
|
"AND": [
|
||||||
|
{
|
||||||
|
"field": "agreement_name",
|
||||||
|
"op": "LIKE",
|
||||||
|
"var": "agreement_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "agreement_code",
|
||||||
|
"op": "LIKE",
|
||||||
|
"var": "agreement_code"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"op": "=",
|
||||||
|
"var": "status"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"filter_labels":{
|
||||||
|
"agreement_name": "协议名称",
|
||||||
|
"agreement_code": "协议编号",
|
||||||
|
"status": "状态"
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"page_rows":160,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
@ -294,6 +321,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@ -3,6 +3,11 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"label": "供销管理",
|
"label": "供销管理",
|
||||||
"items": [
|
"items": [
|
||||||
|
{
|
||||||
|
"name": "--- 外部供应商 ---",
|
||||||
|
"url": "",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "供应商管理",
|
"name": "供应商管理",
|
||||||
"url": "{{entire_url('suppliers_list')}}"
|
"url": "{{entire_url('suppliers_list')}}"
|
||||||
@ -11,6 +16,24 @@
|
|||||||
"name": "供销合同",
|
"name": "供销合同",
|
||||||
"url": "{{entire_url('supply_contracts_list')}}"
|
"url": "{{entire_url('supply_contracts_list')}}"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "--- 平台内供应链 ---",
|
||||||
|
"url": "",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "平台供销关系",
|
||||||
|
"url": "{{entire_url('platform_supply_relations_list')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "产品供应映射",
|
||||||
|
"url": "{{entire_url('product_supplier_mapping_list')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "--- 分销管理 ---",
|
||||||
|
"url": "",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "二级分销商",
|
"name": "二级分销商",
|
||||||
"url": "{{entire_url('sub_resellers_list')}}"
|
"url": "{{entire_url('sub_resellers_list')}}"
|
||||||
@ -19,6 +42,11 @@
|
|||||||
"name": "分销协议",
|
"name": "分销协议",
|
||||||
"url": "{{entire_url('distribution_agreements_list')}}"
|
"url": "{{entire_url('distribution_agreements_list')}}"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "--- 账务 ---",
|
||||||
|
"url": "",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "销售记账",
|
"name": "销售记账",
|
||||||
"url": "{{entire_url('sales_ledger_list')}}"
|
"url": "{{entire_url('sales_ledger_list')}}"
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,158 @@
|
|||||||
|
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
311
wwwroot/platform_supply_products_list/index.ui
Normal file
311
wwwroot/platform_supply_products_list/index.ui
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"widgettype":"VBox",
|
||||||
|
"options":{"cheight":40,"width":"100%"},
|
||||||
|
"subwidgets":[{
|
||||||
|
"id":"platform_supply_products_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"平台供销产品明细表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_platform_supply_products.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_platform_supply_products.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_platform_supply_products.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./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":[]
|
||||||
|
|
||||||
|
}]
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,175 @@
|
|||||||
|
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
459
wwwroot/platform_supply_relations_list/index.ui
Normal file
459
wwwroot/platform_supply_relations_list/index.ui
Normal file
@ -0,0 +1,459 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"widgettype":"VBox",
|
||||||
|
"options":{"cheight":40,"width":"100%"},
|
||||||
|
"subwidgets":[{
|
||||||
|
"id":"platform_supply_relations_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"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('add_platform_supply_relations.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_platform_supply_relations.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_platform_supply_relations.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./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('../platform_supply_products_list')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}]
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,176 @@
|
|||||||
|
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
424
wwwroot/product_supplier_mapping_list/index.ui
Normal file
424
wwwroot/product_supplier_mapping_list/index.ui
Normal file
@ -0,0 +1,424 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"widgettype":"VBox",
|
||||||
|
"options":{"cheight":40,"width":"100%"},
|
||||||
|
"subwidgets":[{
|
||||||
|
"id":"product_supplier_mapping_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"产品供应映射表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_product_supplier_mapping.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_product_supplier_mapping.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_product_supplier_mapping.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./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":[]
|
||||||
|
|
||||||
|
}]
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -36,6 +36,11 @@ from (select * from sales_ledger where 1=1 [[filterstr]]) a left join (select id
|
|||||||
orgname as resellerid_text from organization where 1 = 1) f on a.resellerid = f.resellerid'''
|
orgname as resellerid_text from organization where 1 = 1) f on a.resellerid = f.resellerid'''
|
||||||
|
|
||||||
filterjson = params_kw.get('data_filter')
|
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'''[
|
fields_str=r'''[
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -179,6 +184,17 @@ ori_fields = json.loads(fields_str)
|
|||||||
if not filterjson:
|
if not filterjson:
|
||||||
fields = [ f['name'] for f in ori_fields ]
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
filterjson = default_filterjson(fields, ns)
|
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 = ns.copy()
|
||||||
filterdic['filterstr'] = ''
|
filterdic['filterstr'] = ''
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"widgettype":"VBox",
|
"widgettype":"VBox",
|
||||||
"options": {
|
"options":{"cheight":40,"width":"100%"},
|
||||||
"cheight": 40,
|
"subwidgets":[{
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"sales_ledger_tbl",
|
"id":"sales_ledger_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
@ -346,12 +343,47 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"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,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
|
|
||||||
,"binds":[]
|
,"binds":[]
|
||||||
|
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@ -32,6 +32,11 @@ from (select * from sub_distributors where 1=1 [[filterstr]]) a left join (selec
|
|||||||
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
|
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
|
||||||
|
|
||||||
filterjson = params_kw.get('data_filter')
|
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'''[
|
fields_str=r'''[
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -144,6 +149,17 @@ ori_fields = json.loads(fields_str)
|
|||||||
if not filterjson:
|
if not filterjson:
|
||||||
fields = [ f['name'] for f in ori_fields ]
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
filterjson = default_filterjson(fields, ns)
|
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 = ns.copy()
|
||||||
filterdic['filterstr'] = ''
|
filterdic['filterstr'] = ''
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"widgettype":"VBox",
|
"widgettype":"VBox",
|
||||||
"options": {
|
"options":{"cheight":40,"width":"100%"},
|
||||||
"cheight": 40,
|
"subwidgets":[{
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"sub_distributors_tbl",
|
"id":"sub_distributors_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
@ -248,12 +245,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"page_rows":160,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
|
|
||||||
,"binds":[]
|
,"binds":[]
|
||||||
|
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@ -32,6 +32,11 @@ from (select * from sub_resellers where 1=1 [[filterstr]]) a left join (select i
|
|||||||
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
|
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
|
||||||
|
|
||||||
filterjson = params_kw.get('data_filter')
|
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'''[
|
fields_str=r'''[
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -138,6 +143,17 @@ ori_fields = json.loads(fields_str)
|
|||||||
if not filterjson:
|
if not filterjson:
|
||||||
fields = [ f['name'] for f in ori_fields ]
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
filterjson = default_filterjson(fields, ns)
|
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 = ns.copy()
|
||||||
filterdic['filterstr'] = ''
|
filterdic['filterstr'] = ''
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"widgettype":"VBox",
|
"widgettype":"VBox",
|
||||||
"options": {
|
"options":{"cheight":40,"width":"100%"},
|
||||||
"cheight": 40,
|
"subwidgets":[{
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"sub_resellers_tbl",
|
"id":"sub_resellers_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
@ -253,12 +250,35 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"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,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
|
|
||||||
,"binds":[]
|
,"binds":[]
|
||||||
|
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@ -32,6 +32,11 @@ from (select * from suppliers where 1=1 [[filterstr]]) a left join (select id as
|
|||||||
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
|
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
|
||||||
|
|
||||||
filterjson = params_kw.get('data_filter')
|
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'''[
|
fields_str=r'''[
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -138,6 +143,17 @@ ori_fields = json.loads(fields_str)
|
|||||||
if not filterjson:
|
if not filterjson:
|
||||||
fields = [ f['name'] for f in ori_fields ]
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
filterjson = default_filterjson(fields, ns)
|
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 = ns.copy()
|
||||||
filterdic['filterstr'] = ''
|
filterdic['filterstr'] = ''
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"widgettype":"VBox",
|
"widgettype":"VBox",
|
||||||
"options": {
|
"options":{"cheight":40,"width":"100%"},
|
||||||
"cheight": 40,
|
"subwidgets":[{
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"suppliers_tbl",
|
"id":"suppliers_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
@ -253,12 +250,35 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"data_filter":{
|
||||||
|
"AND": [
|
||||||
|
{
|
||||||
|
"field": "supplier_name",
|
||||||
|
"op": "LIKE",
|
||||||
|
"var": "supplier_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"op": "=",
|
||||||
|
"var": "status"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"filter_labels":{
|
||||||
|
"supplier_name": "供应商名称",
|
||||||
|
"status": "状态"
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"page_rows":160,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
|
|
||||||
,"binds":[]
|
,"binds":[]
|
||||||
|
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@ -34,6 +34,11 @@ from (select * from supply_contract_items where 1=1 [[filterstr]]) a left join (
|
|||||||
product_name as productid_text from products where 1 = 1) d on a.productid = d.productid'''
|
product_name as productid_text from products where 1 = 1) d on a.productid = d.productid'''
|
||||||
|
|
||||||
filterjson = params_kw.get('data_filter')
|
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'''[
|
fields_str=r'''[
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -100,6 +105,17 @@ ori_fields = json.loads(fields_str)
|
|||||||
if not filterjson:
|
if not filterjson:
|
||||||
fields = [ f['name'] for f in ori_fields ]
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
filterjson = default_filterjson(fields, ns)
|
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 = ns.copy()
|
||||||
filterdic['filterstr'] = ''
|
filterdic['filterstr'] = ''
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"widgettype":"VBox",
|
"widgettype":"VBox",
|
||||||
"options": {
|
"options":{"cheight":40,"width":"100%"},
|
||||||
"cheight": 40,
|
"subwidgets":[{
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"supply_contract_items_tbl",
|
"id":"supply_contract_items_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
@ -180,12 +177,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"page_rows":160,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
|
|
||||||
,"binds":[]
|
,"binds":[]
|
||||||
|
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@ -33,6 +33,11 @@ from (select * from supply_contracts where 1=1 [[filterstr]]) a left join (selec
|
|||||||
orgname as resellerid_text from organization where 1 = 1) c on a.resellerid = c.resellerid'''
|
orgname as resellerid_text from organization where 1 = 1) c on a.resellerid = c.resellerid'''
|
||||||
|
|
||||||
filterjson = params_kw.get('data_filter')
|
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'''[
|
fields_str=r'''[
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -128,6 +133,17 @@ ori_fields = json.loads(fields_str)
|
|||||||
if not filterjson:
|
if not filterjson:
|
||||||
fields = [ f['name'] for f in ori_fields ]
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
filterjson = default_filterjson(fields, ns)
|
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 = ns.copy()
|
||||||
filterdic['filterstr'] = ''
|
filterdic['filterstr'] = ''
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"widgettype":"VBox",
|
"widgettype":"VBox",
|
||||||
"options": {
|
"options":{"cheight":40,"width":"100%"},
|
||||||
"cheight": 40,
|
"subwidgets":[{
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"supply_contracts_tbl",
|
"id":"supply_contracts_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
@ -262,6 +259,36 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"data_filter":{
|
||||||
|
"AND": [
|
||||||
|
{
|
||||||
|
"field": "contract_name",
|
||||||
|
"op": "LIKE",
|
||||||
|
"var": "contract_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "contract_code",
|
||||||
|
"op": "LIKE",
|
||||||
|
"var": "contract_code"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "status",
|
||||||
|
"op": "=",
|
||||||
|
"var": "status"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"filter_labels":{
|
||||||
|
"contract_name": "合同名称",
|
||||||
|
"contract_code": "合同编号",
|
||||||
|
"status": "状态"
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"page_rows":160,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
@ -294,6 +321,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@ -38,6 +38,11 @@ from (select * from supplychain_accounting where 1=1 [[filterstr]]) a left join
|
|||||||
orgname as resellerid_text from organization where 1 = 1) h on a.resellerid = h.resellerid'''
|
orgname as resellerid_text from organization where 1 = 1) h on a.resellerid = h.resellerid'''
|
||||||
|
|
||||||
filterjson = params_kw.get('data_filter')
|
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'''[
|
fields_str=r'''[
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -201,6 +206,17 @@ ori_fields = json.loads(fields_str)
|
|||||||
if not filterjson:
|
if not filterjson:
|
||||||
fields = [ f['name'] for f in ori_fields ]
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
filterjson = default_filterjson(fields, ns)
|
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 = ns.copy()
|
||||||
filterdic['filterstr'] = ''
|
filterdic['filterstr'] = ''
|
||||||
filterdic['userorgid'] = '${userorgid}$'
|
filterdic['userorgid'] = '${userorgid}$'
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"widgettype":"VBox",
|
"widgettype":"VBox",
|
||||||
"options": {
|
"options":{"cheight":40,"width":"100%"},
|
||||||
"cheight": 40,
|
"subwidgets":[{
|
||||||
"width": "100%"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"id":"supplychain_accounting_tbl",
|
"id":"supplychain_accounting_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
@ -375,12 +372,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"page_rows":160,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
|
|
||||||
,"binds":[]
|
,"binds":[]
|
||||||
|
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user