feat: add DDL, CRUD dspy and list pages for all supplychain tables
This commit is contained in:
parent
74579d115c
commit
5942e78968
394
models/mysql.ddl.sql
Normal file
394
models/mysql.ddl.sql
Normal file
@ -0,0 +1,394 @@
|
|||||||
|
|
||||||
|
-- ./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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists sub_resellers;
|
||||||
|
CREATE TABLE sub_resellers
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
||||||
|
`sub_reseller_code` VARCHAR(64) NOT NULL comment '二级分销商编号',
|
||||||
|
`sub_reseller_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 sub_resellers_idx_sr_reseller ON sub_resellers(resellerid);
|
||||||
|
CREATE UNIQUE INDEX sub_resellers_idx_sr_code ON sub_resellers(resellerid,sub_reseller_code);
|
||||||
|
|
||||||
|
-- ./supplychain_accounting.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists supplychain_accounting;
|
||||||
|
CREATE TABLE supplychain_accounting
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`resellerid` VARCHAR(32) NOT NULL comment '所属主分销商机构ID',
|
||||||
|
`supply_contract_id` VARCHAR(32) comment '供销合同ID',
|
||||||
|
`supply_contract_item_id` VARCHAR(32) comment '供销合同产品明细ID',
|
||||||
|
`distribution_agreement_id` VARCHAR(32) comment '分销协议ID',
|
||||||
|
`distribution_agreement_item_id` VARCHAR(32) comment '分销协议产品明细ID',
|
||||||
|
`sub_distributor_id` VARCHAR(32) comment '二级分销商ID',
|
||||||
|
`supplier_id` VARCHAR(32) comment '供应商ID',
|
||||||
|
`prodtypeid` VARCHAR(32) comment '产品分类ID',
|
||||||
|
`productid` VARCHAR(32) comment '产品ID',
|
||||||
|
`quantity` double(15,4) NOT NULL DEFAULT '0' comment '数量',
|
||||||
|
`unit_price` double(15,4) NOT NULL DEFAULT '0' comment '销售单价',
|
||||||
|
`supply_discount` double(5,4) comment '进货折扣',
|
||||||
|
`supply_amount` double(15,2) NOT NULL DEFAULT '0' comment '进货金额(应付供应商)',
|
||||||
|
`dist_discount` double(5,4) comment '分销折扣',
|
||||||
|
`dist_amount` double(15,2) NOT NULL DEFAULT '0' comment '分销金额(二级分销商应付)',
|
||||||
|
`profit_amount` double(15,2) NOT NULL DEFAULT '0' comment '利润金额',
|
||||||
|
`sale_date` date NOT NULL comment '销售日期',
|
||||||
|
`source_type` CHAR(1) DEFAULT '1' comment '来源类型',
|
||||||
|
`source_id` VARCHAR(32) comment '来源记录ID',
|
||||||
|
`remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment '备注',
|
||||||
|
`created_by` VARCHAR(32) comment '创建人',
|
||||||
|
`created_at` datetime NOT NULL comment '创建时间'
|
||||||
|
|
||||||
|
|
||||||
|
,primary key(id)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
CHARACTER SET utf8mb4
|
||||||
|
COLLATE utf8mb4_unicode_ci
|
||||||
|
engine=innodb
|
||||||
|
comment '供销记账表'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE INDEX supplychain_accounting_idx_sa_reseller ON supplychain_accounting(resellerid);
|
||||||
|
CREATE INDEX supplychain_accounting_idx_sa_sale_date ON supplychain_accounting(sale_date);
|
||||||
|
CREATE INDEX supplychain_accounting_idx_sa_product ON supplychain_accounting(productid);
|
||||||
|
CREATE INDEX supplychain_accounting_idx_sa_subdist ON supplychain_accounting(sub_distributor_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);
|
||||||
|
|
||||||
|
-- ./sub_distributors.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists sub_distributors;
|
||||||
|
CREATE TABLE sub_distributors
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`resellerid` VARCHAR(32) NOT NULL comment '所属主分销商机构ID',
|
||||||
|
`sub_dist_code` VARCHAR(64) NOT NULL comment '二级分销商编号',
|
||||||
|
`sub_dist_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 '银行账号',
|
||||||
|
`managed_by` VARCHAR(32) comment '负责销售ID',
|
||||||
|
`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 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 INDEX sub_distributors_idx_sd_manager ON sub_distributors(managed_by);
|
||||||
|
|
||||||
|
-- ./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_contracts.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 建库时请用以下语句,支持emoji字符
|
||||||
|
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
drop table if exists supply_contracts;
|
||||||
|
CREATE TABLE supply_contracts
|
||||||
|
(
|
||||||
|
|
||||||
|
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||||
|
`resellerid` VARCHAR(32) NOT NULL comment '所属分销商机构ID',
|
||||||
|
`supplier_id` VARCHAR(32) NOT NULL comment '供应商ID',
|
||||||
|
`contract_code` VARCHAR(64) NOT NULL comment '合同编号',
|
||||||
|
`contract_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 supply_contracts_idx_sc_reseller ON supply_contracts(resellerid);
|
||||||
|
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);
|
||||||
|
|
||||||
|
-- ./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);
|
||||||
|
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('distribution_agreement_items', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"title":"Add Success",
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Add Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('distribution_agreement_items', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_distribution_agreement_items.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["prodtypeid","productid"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.agreement_id_text
|
||||||
|
from (select * from distribution_agreement_items where 1=1 [[filterstr]]) a left join (select id as agreement_id,
|
||||||
|
agreement_name as agreement_id_text from distribution_agreements where 1 = 1) b on a.agreement_id = b.agreement_id'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "agreement_id",
|
||||||
|
"title": "分销协议ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prodtypeid",
|
||||||
|
"title": "产品分类ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "productid",
|
||||||
|
"title": "产品ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "discount",
|
||||||
|
"title": "分销折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1.0000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "min_order_qty",
|
||||||
|
"title": "最小订购量",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sale_price",
|
||||||
|
"title": "分销指导价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
ori_fields = json.loads(fields_str)
|
||||||
|
if not filterjson:
|
||||||
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
|
filterjson = default_filterjson(fields, ns)
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
174
wwwroot/distribution_agreement_items_list/index.ui
Normal file
174
wwwroot/distribution_agreement_items_list/index.ui
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"id":"distribution_agreement_items_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"分销协议产品折扣明细表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_distribution_agreement_items.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_distribution_agreement_items.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_distribution_agreement_items.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_distribution_agreement_items.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id",
|
||||||
|
"agreement_id",
|
||||||
|
"resellerid"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "agreement_id",
|
||||||
|
"title": "分销协议ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "分销协议ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "agreement_id",
|
||||||
|
"textField": "agreement_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "distribution_agreements",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "agreement_name",
|
||||||
|
"valueField": "agreement_id",
|
||||||
|
"textField": "agreement_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "所属分销商机构ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prodtypeid",
|
||||||
|
"title": "产品分类ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "产品分类ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "productid",
|
||||||
|
"title": "产品ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "产品ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "discount",
|
||||||
|
"title": "分销折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1.0000",
|
||||||
|
"cwidth": 5,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "分销折扣"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "min_order_qty",
|
||||||
|
"title": "最小订购量",
|
||||||
|
"type": "int",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "int",
|
||||||
|
"datatype": "int",
|
||||||
|
"label": "最小订购量"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sale_price",
|
||||||
|
"title": "分销指导价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "分销指导价"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "备注"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "创建时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"resellerid": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('distribution_agreement_items', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('distribution_agreement_items', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('distribution_agreements', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"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,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('distribution_agreements', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,157 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_distribution_agreements.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["created_at desc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.sub_reseller_id_text, c.resellerid_text
|
||||||
|
from (select * from distribution_agreements where 1=1 [[filterstr]]) a left join (select id as sub_reseller_id,
|
||||||
|
sub_reseller_name as sub_reseller_id_text from sub_resellers where 1 = 1) b on a.sub_reseller_id = b.sub_reseller_id left join (select id as resellerid,
|
||||||
|
orgname as resellerid_text from organization where 1 = 1) c on a.resellerid = c.resellerid'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_reseller_id",
|
||||||
|
"title": "二级分销商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "agreement_code",
|
||||||
|
"title": "协议编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "agreement_name",
|
||||||
|
"title": "协议名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sign_date",
|
||||||
|
"title": "签署日期",
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "start_date",
|
||||||
|
"title": "生效日期",
|
||||||
|
"type": "date",
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "end_date",
|
||||||
|
"title": "到期日期",
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default_discount",
|
||||||
|
"title": "默认分销折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"default": "1.0000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
291
wwwroot/distribution_agreements_list/index.ui
Normal file
291
wwwroot/distribution_agreements_list/index.ui
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"id":"distribution_agreements_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"分销协议表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"toolbar":{
|
||||||
|
"tools": [
|
||||||
|
{
|
||||||
|
"selected_row": true,
|
||||||
|
"name": "distribution_agreement_items",
|
||||||
|
"icon": "{{entire_url('/imgs/distribution_agreement_items.svg')}}",
|
||||||
|
"label": "产品分销折扣"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_distribution_agreements.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_distribution_agreements.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_distribution_agreements.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_distribution_agreements.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"alters": {
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "生效中"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "2",
|
||||||
|
"text": "已到期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "已终止"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "所属分销商机构ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "organization",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "orgname",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_reseller_id",
|
||||||
|
"title": "二级分销商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "二级分销商ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "sub_reseller_id",
|
||||||
|
"textField": "sub_reseller_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "sub_resellers",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "sub_reseller_name",
|
||||||
|
"valueField": "sub_reseller_id",
|
||||||
|
"textField": "sub_reseller_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "agreement_code",
|
||||||
|
"title": "协议编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "协议编号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "agreement_name",
|
||||||
|
"title": "协议名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "协议名称"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sign_date",
|
||||||
|
"title": "签署日期",
|
||||||
|
"type": "date",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "签署日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "start_date",
|
||||||
|
"title": "生效日期",
|
||||||
|
"type": "date",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "生效日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "end_date",
|
||||||
|
"title": "到期日期",
|
||||||
|
"type": "date",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "到期日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1",
|
||||||
|
"cwidth": 4,
|
||||||
|
"uitype": "code",
|
||||||
|
"datatype": "char",
|
||||||
|
"label": "状态",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "生效中"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "2",
|
||||||
|
"text": "已到期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "已终止"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default_discount",
|
||||||
|
"title": "默认分销折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"default": "1.0000",
|
||||||
|
"cwidth": 5,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "默认分销折扣"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "备注"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "创建人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "创建时间"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "更新时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[
|
||||||
|
{
|
||||||
|
"wid": "self",
|
||||||
|
"event": "distribution_agreement_items",
|
||||||
|
"actiontype": "urlwidget",
|
||||||
|
"target": "PopupWindow",
|
||||||
|
"popup_options": {
|
||||||
|
"title": "产品分销折扣",
|
||||||
|
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=distribution_agreement_items",
|
||||||
|
"resizable": true,
|
||||||
|
"height": "70%",
|
||||||
|
"width": "70%"
|
||||||
|
},
|
||||||
|
"params_mapping": {
|
||||||
|
"mapping": {
|
||||||
|
"id": "agreement_id",
|
||||||
|
"referer_widget": "referer_widget"
|
||||||
|
},
|
||||||
|
"need_other": false
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"method": "POST",
|
||||||
|
"params": {},
|
||||||
|
"url": "{{entire_url('../distribution_agreement_items_list')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"resellerid": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('distribution_agreements', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('distribution_agreements', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
51
wwwroot/sales_ledger_list/add_sales_ledger.dspy
Normal file
51
wwwroot/sales_ledger_list/add_sales_ledger.dspy
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('sales_ledger', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"title":"Add Success",
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Add Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
wwwroot/sales_ledger_list/delete_sales_ledger.dspy
Normal file
47
wwwroot/sales_ledger_list/delete_sales_ledger.dspy
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('sales_ledger', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
208
wwwroot/sales_ledger_list/get_sales_ledger.dspy
Normal file
208
wwwroot/sales_ledger_list/get_sales_ledger.dspy
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_sales_ledger.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["sale_date desc","created_at desc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.sub_reseller_id_text, c.supplier_id_text, d.agreement_id_text, e.contract_id_text, f.resellerid_text
|
||||||
|
from (select * from sales_ledger where 1=1 [[filterstr]]) a left join (select id as sub_reseller_id,
|
||||||
|
sub_reseller_name as sub_reseller_id_text from sub_resellers where 1 = 1) b on a.sub_reseller_id = b.sub_reseller_id left join (select id as supplier_id,
|
||||||
|
supplier_name as supplier_id_text from suppliers where 1 = 1) c on a.supplier_id = c.supplier_id left join (select id as agreement_id,
|
||||||
|
agreement_name as agreement_id_text from distribution_agreements where 1 = 1) d on a.agreement_id = d.agreement_id left join (select id as contract_id,
|
||||||
|
contract_name as contract_id_text from supply_contracts where 1 = 1) e on a.contract_id = e.contract_id left join (select id as resellerid,
|
||||||
|
orgname as resellerid_text from organization where 1 = 1) f on a.resellerid = f.resellerid'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_reseller_id",
|
||||||
|
"title": "二级分销商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_id",
|
||||||
|
"title": "供应商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "agreement_id",
|
||||||
|
"title": "分销协议ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contract_id",
|
||||||
|
"title": "供销合同ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prodtypeid",
|
||||||
|
"title": "产品分类ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "productid",
|
||||||
|
"title": "产品ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sale_date",
|
||||||
|
"title": "销售日期",
|
||||||
|
"type": "date",
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "quantity",
|
||||||
|
"title": "销售数量",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unit_price",
|
||||||
|
"title": "销售单价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_discount",
|
||||||
|
"title": "进货折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_amount",
|
||||||
|
"title": "进货金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distribution_discount",
|
||||||
|
"title": "分销折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distribution_amount",
|
||||||
|
"title": "分销金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "profit_amount",
|
||||||
|
"title": "利润金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "settlement_status",
|
||||||
|
"title": "结算状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
ori_fields = json.loads(fields_str)
|
||||||
|
if not filterjson:
|
||||||
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
|
filterjson = default_filterjson(fields, ns)
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
349
wwwroot/sales_ledger_list/index.ui
Normal file
349
wwwroot/sales_ledger_list/index.ui
Normal file
@ -0,0 +1,349 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"id":"sales_ledger_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"销售记账表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_sales_ledger.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_sales_ledger.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_sales_ledger.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_sales_ledger.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"alters": {
|
||||||
|
"settlement_status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "未结算"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "已结算"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "所属分销商机构ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "organization",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "orgname",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_reseller_id",
|
||||||
|
"title": "二级分销商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "二级分销商ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "sub_reseller_id",
|
||||||
|
"textField": "sub_reseller_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "sub_resellers",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "sub_reseller_name",
|
||||||
|
"valueField": "sub_reseller_id",
|
||||||
|
"textField": "sub_reseller_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_id",
|
||||||
|
"title": "供应商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "供应商ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "supplier_id",
|
||||||
|
"textField": "supplier_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "suppliers",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "supplier_name",
|
||||||
|
"valueField": "supplier_id",
|
||||||
|
"textField": "supplier_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "agreement_id",
|
||||||
|
"title": "分销协议ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "分销协议ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "agreement_id",
|
||||||
|
"textField": "agreement_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "distribution_agreements",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "agreement_name",
|
||||||
|
"valueField": "agreement_id",
|
||||||
|
"textField": "agreement_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contract_id",
|
||||||
|
"title": "供销合同ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "供销合同ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "contract_id",
|
||||||
|
"textField": "contract_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "supply_contracts",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "contract_name",
|
||||||
|
"valueField": "contract_id",
|
||||||
|
"textField": "contract_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prodtypeid",
|
||||||
|
"title": "产品分类ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "产品分类ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "productid",
|
||||||
|
"title": "产品ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "产品ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sale_date",
|
||||||
|
"title": "销售日期",
|
||||||
|
"type": "date",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "销售日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "quantity",
|
||||||
|
"title": "销售数量",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "销售数量"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unit_price",
|
||||||
|
"title": "销售单价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "销售单价"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_discount",
|
||||||
|
"title": "进货折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"cwidth": 5,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "进货折扣"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_amount",
|
||||||
|
"title": "进货金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "进货金额"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distribution_discount",
|
||||||
|
"title": "分销折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"cwidth": 5,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "分销折扣"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distribution_amount",
|
||||||
|
"title": "分销金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "分销金额"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "profit_amount",
|
||||||
|
"title": "利润金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "利润金额"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "settlement_status",
|
||||||
|
"title": "结算状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 4,
|
||||||
|
"uitype": "code",
|
||||||
|
"datatype": "char",
|
||||||
|
"label": "结算状态",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "未结算"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "已结算"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "备注"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "创建人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "创建时间"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "更新时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}
|
||||||
70
wwwroot/sales_ledger_list/update_sales_ledger.dspy
Normal file
70
wwwroot/sales_ledger_list/update_sales_ledger.dspy
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"resellerid": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('sales_ledger', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('sales_ledger', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
51
wwwroot/sub_distributors_list/add_sub_distributors.dspy
Normal file
51
wwwroot/sub_distributors_list/add_sub_distributors.dspy
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('sub_distributors', 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
wwwroot/sub_distributors_list/delete_sub_distributors.dspy
Normal file
47
wwwroot/sub_distributors_list/delete_sub_distributors.dspy
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('sub_distributors', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
173
wwwroot/sub_distributors_list/get_sub_distributors.dspy
Normal file
173
wwwroot/sub_distributors_list/get_sub_distributors.dspy
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_sub_distributors.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["created_at desc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.resellerid_text
|
||||||
|
from (select * from sub_distributors where 1=1 [[filterstr]]) a left join (select id as resellerid,
|
||||||
|
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属主分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_dist_code",
|
||||||
|
"title": "二级分销商编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_dist_name",
|
||||||
|
"title": "二级分销商名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_person",
|
||||||
|
"title": "联系人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_phone",
|
||||||
|
"title": "联系电话",
|
||||||
|
"type": "str",
|
||||||
|
"length": 50
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_email",
|
||||||
|
"title": "联系邮箱",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "address",
|
||||||
|
"title": "地址",
|
||||||
|
"type": "str",
|
||||||
|
"length": 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tax_number",
|
||||||
|
"title": "税号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_name",
|
||||||
|
"title": "开户银行",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_account",
|
||||||
|
"title": "银行账号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "managed_by",
|
||||||
|
"title": "负责销售ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
ori_fields = json.loads(fields_str)
|
||||||
|
if not filterjson:
|
||||||
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
|
filterjson = default_filterjson(fields, ns)
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
251
wwwroot/sub_distributors_list/index.ui
Normal file
251
wwwroot/sub_distributors_list/index.ui
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"id":"sub_distributors_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"二级分销商表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_sub_distributors.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_sub_distributors.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_sub_distributors.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_sub_distributors.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"created_by",
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"editexclouded":[
|
||||||
|
"id",
|
||||||
|
"resellerid",
|
||||||
|
"created_by",
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
],
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属主分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "所属主分销商机构ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "organization",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "orgname",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_dist_code",
|
||||||
|
"title": "二级分销商编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "二级分销商编号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_dist_name",
|
||||||
|
"title": "二级分销商名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "二级分销商名称"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_person",
|
||||||
|
"title": "联系人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 100,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "联系人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_phone",
|
||||||
|
"title": "联系电话",
|
||||||
|
"type": "str",
|
||||||
|
"length": 50,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "联系电话"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_email",
|
||||||
|
"title": "联系邮箱",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "联系邮箱"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "address",
|
||||||
|
"title": "地址",
|
||||||
|
"type": "str",
|
||||||
|
"length": 500,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "地址"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tax_number",
|
||||||
|
"title": "税号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "税号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_name",
|
||||||
|
"title": "开户银行",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "开户银行"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_account",
|
||||||
|
"title": "银行账号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "银行账号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "managed_by",
|
||||||
|
"title": "负责销售ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "负责销售ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1",
|
||||||
|
"cwidth": 4,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "char",
|
||||||
|
"label": "状态"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "备注"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "创建人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "创建时间"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "更新时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}
|
||||||
70
wwwroot/sub_distributors_list/update_sub_distributors.dspy
Normal file
70
wwwroot/sub_distributors_list/update_sub_distributors.dspy
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"resellerid": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('sub_distributors', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('sub_distributors', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
51
wwwroot/sub_resellers_list/add_sub_resellers.dspy
Normal file
51
wwwroot/sub_resellers_list/add_sub_resellers.dspy
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('sub_resellers', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"title":"Add Success",
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Add Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
wwwroot/sub_resellers_list/delete_sub_resellers.dspy
Normal file
47
wwwroot/sub_resellers_list/delete_sub_resellers.dspy
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('sub_resellers', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
167
wwwroot/sub_resellers_list/get_sub_resellers.dspy
Normal file
167
wwwroot/sub_resellers_list/get_sub_resellers.dspy
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_sub_resellers.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["created_at desc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.resellerid_text
|
||||||
|
from (select * from sub_resellers where 1=1 [[filterstr]]) a left join (select id as resellerid,
|
||||||
|
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_reseller_code",
|
||||||
|
"title": "二级分销商编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_reseller_name",
|
||||||
|
"title": "二级分销商名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_person",
|
||||||
|
"title": "联系人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_phone",
|
||||||
|
"title": "联系电话",
|
||||||
|
"type": "str",
|
||||||
|
"length": 50
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_email",
|
||||||
|
"title": "联系邮箱",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "address",
|
||||||
|
"title": "地址",
|
||||||
|
"type": "str",
|
||||||
|
"length": 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tax_number",
|
||||||
|
"title": "税号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_name",
|
||||||
|
"title": "开户银行",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_account",
|
||||||
|
"title": "银行账号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
ori_fields = json.loads(fields_str)
|
||||||
|
if not filterjson:
|
||||||
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
|
filterjson = default_filterjson(fields, ns)
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
256
wwwroot/sub_resellers_list/index.ui
Normal file
256
wwwroot/sub_resellers_list/index.ui
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"id":"sub_resellers_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"二级分销商表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_sub_resellers.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_sub_resellers.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_sub_resellers.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_sub_resellers.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"alters": {
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "正常"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "停用"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "所属分销商机构ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "organization",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "orgname",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_reseller_code",
|
||||||
|
"title": "二级分销商编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "二级分销商编号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_reseller_name",
|
||||||
|
"title": "二级分销商名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "二级分销商名称"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_person",
|
||||||
|
"title": "联系人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 100,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "联系人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_phone",
|
||||||
|
"title": "联系电话",
|
||||||
|
"type": "str",
|
||||||
|
"length": 50,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "联系电话"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_email",
|
||||||
|
"title": "联系邮箱",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "联系邮箱"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "address",
|
||||||
|
"title": "地址",
|
||||||
|
"type": "str",
|
||||||
|
"length": 500,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "地址"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tax_number",
|
||||||
|
"title": "税号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "税号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_name",
|
||||||
|
"title": "开户银行",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "开户银行"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_account",
|
||||||
|
"title": "银行账号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "银行账号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1",
|
||||||
|
"cwidth": 4,
|
||||||
|
"uitype": "code",
|
||||||
|
"datatype": "char",
|
||||||
|
"label": "状态",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "正常"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "停用"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "备注"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "创建人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "创建时间"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "更新时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}
|
||||||
70
wwwroot/sub_resellers_list/update_sub_resellers.dspy
Normal file
70
wwwroot/sub_resellers_list/update_sub_resellers.dspy
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"resellerid": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('sub_resellers', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('sub_resellers', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
51
wwwroot/suppliers_list/add_suppliers.dspy
Normal file
51
wwwroot/suppliers_list/add_suppliers.dspy
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('suppliers', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"title":"Add Success",
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Add Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
wwwroot/suppliers_list/delete_suppliers.dspy
Normal file
47
wwwroot/suppliers_list/delete_suppliers.dspy
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('suppliers', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
167
wwwroot/suppliers_list/get_suppliers.dspy
Normal file
167
wwwroot/suppliers_list/get_suppliers.dspy
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_suppliers.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["created_at desc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.resellerid_text
|
||||||
|
from (select * from suppliers where 1=1 [[filterstr]]) a left join (select id as resellerid,
|
||||||
|
orgname as resellerid_text from organization where 1 = 1) b on a.resellerid = b.resellerid'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_code",
|
||||||
|
"title": "供应商编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_name",
|
||||||
|
"title": "供应商名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_person",
|
||||||
|
"title": "联系人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_phone",
|
||||||
|
"title": "联系电话",
|
||||||
|
"type": "str",
|
||||||
|
"length": 50
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_email",
|
||||||
|
"title": "联系邮箱",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "address",
|
||||||
|
"title": "地址",
|
||||||
|
"type": "str",
|
||||||
|
"length": 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tax_number",
|
||||||
|
"title": "税号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_name",
|
||||||
|
"title": "开户银行",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_account",
|
||||||
|
"title": "银行账号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "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":[]
|
||||||
|
}
|
||||||
256
wwwroot/suppliers_list/index.ui
Normal file
256
wwwroot/suppliers_list/index.ui
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"id":"suppliers_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"供应商表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_suppliers.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_suppliers.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_suppliers.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_suppliers.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"alters": {
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "正常"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "停用"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "所属分销商机构ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "organization",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "orgname",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_code",
|
||||||
|
"title": "供应商编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "供应商编号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_name",
|
||||||
|
"title": "供应商名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "供应商名称"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_person",
|
||||||
|
"title": "联系人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 100,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "联系人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_phone",
|
||||||
|
"title": "联系电话",
|
||||||
|
"type": "str",
|
||||||
|
"length": 50,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "联系电话"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact_email",
|
||||||
|
"title": "联系邮箱",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "联系邮箱"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "address",
|
||||||
|
"title": "地址",
|
||||||
|
"type": "str",
|
||||||
|
"length": 500,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "地址"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tax_number",
|
||||||
|
"title": "税号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "税号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_name",
|
||||||
|
"title": "开户银行",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "开户银行"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bank_account",
|
||||||
|
"title": "银行账号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "银行账号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1",
|
||||||
|
"cwidth": 4,
|
||||||
|
"uitype": "code",
|
||||||
|
"datatype": "char",
|
||||||
|
"label": "状态",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "正常"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "停用"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "备注"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "创建人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "创建时间"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "更新时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}
|
||||||
70
wwwroot/suppliers_list/update_suppliers.dspy
Normal file
70
wwwroot/suppliers_list/update_suppliers.dspy
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"resellerid": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('suppliers', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('suppliers', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('supply_contract_items', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"title":"Add Success",
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Add Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('supply_contract_items', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,129 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_supply_contract_items.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["prodtypeid","productid"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.contract_id_text, c.prodtypeid_text, d.productid_text
|
||||||
|
from (select * from supply_contract_items where 1=1 [[filterstr]]) a left join (select id as contract_id,
|
||||||
|
contract_name as contract_id_text from supply_contracts where 1 = 1) b on a.contract_id = b.contract_id left join (select id as prodtypeid,
|
||||||
|
type_name as prodtypeid_text from product_types where 1 = 1) c on a.prodtypeid = c.prodtypeid left join (select id as productid,
|
||||||
|
product_name as productid_text from products where 1 = 1) d on a.productid = d.productid'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contract_id",
|
||||||
|
"title": "供销合同ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prodtypeid",
|
||||||
|
"title": "产品分类ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "productid",
|
||||||
|
"title": "产品ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "discount",
|
||||||
|
"title": "进货折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1.0000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "settlement_price",
|
||||||
|
"title": "结算单价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
ori_fields = json.loads(fields_str)
|
||||||
|
if not filterjson:
|
||||||
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
|
filterjson = default_filterjson(fields, ns)
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
183
wwwroot/supply_contract_items_list/index.ui
Normal file
183
wwwroot/supply_contract_items_list/index.ui
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"id":"supply_contract_items_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"供销合同产品折扣明细表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_supply_contract_items.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_supply_contract_items.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_supply_contract_items.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_supply_contract_items.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id",
|
||||||
|
"contract_id",
|
||||||
|
"resellerid"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contract_id",
|
||||||
|
"title": "供销合同ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "供销合同ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "contract_id",
|
||||||
|
"textField": "contract_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "supply_contracts",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "contract_name",
|
||||||
|
"valueField": "contract_id",
|
||||||
|
"textField": "contract_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "所属分销商机构ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prodtypeid",
|
||||||
|
"title": "产品分类ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "产品分类ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "prodtypeid",
|
||||||
|
"textField": "prodtypeid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "product_types",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "type_name",
|
||||||
|
"valueField": "prodtypeid",
|
||||||
|
"textField": "prodtypeid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "productid",
|
||||||
|
"title": "产品ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "产品ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "productid",
|
||||||
|
"textField": "productid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "products",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "product_name",
|
||||||
|
"valueField": "productid",
|
||||||
|
"textField": "productid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "discount",
|
||||||
|
"title": "进货折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1.0000",
|
||||||
|
"cwidth": 5,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "进货折扣"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "settlement_price",
|
||||||
|
"title": "结算单价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "结算单价"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "备注"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "创建时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"resellerid": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('supply_contract_items', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('supply_contract_items', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
51
wwwroot/supply_contracts_list/add_supply_contracts.dspy
Normal file
51
wwwroot/supply_contracts_list/add_supply_contracts.dspy
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('supply_contracts', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
wwwroot/supply_contracts_list/delete_supply_contracts.dspy
Normal file
47
wwwroot/supply_contracts_list/delete_supply_contracts.dspy
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('supply_contracts', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
157
wwwroot/supply_contracts_list/get_supply_contracts.dspy
Normal file
157
wwwroot/supply_contracts_list/get_supply_contracts.dspy
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_supply_contracts.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["created_at desc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.supplier_id_text, c.resellerid_text
|
||||||
|
from (select * from supply_contracts where 1=1 [[filterstr]]) a left join (select id as supplier_id,
|
||||||
|
supplier_name as supplier_id_text from suppliers where 1 = 1) b on a.supplier_id = b.supplier_id left join (select id as resellerid,
|
||||||
|
orgname as resellerid_text from organization where 1 = 1) c on a.resellerid = c.resellerid'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_id",
|
||||||
|
"title": "供应商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contract_code",
|
||||||
|
"title": "合同编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contract_name",
|
||||||
|
"title": "合同名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sign_date",
|
||||||
|
"title": "签署日期",
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "start_date",
|
||||||
|
"title": "生效日期",
|
||||||
|
"type": "date",
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "end_date",
|
||||||
|
"title": "到期日期",
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default_discount",
|
||||||
|
"title": "默认折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"default": "1.0000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
291
wwwroot/supply_contracts_list/index.ui
Normal file
291
wwwroot/supply_contracts_list/index.ui
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"id":"supply_contracts_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"供销合同表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"toolbar":{
|
||||||
|
"tools": [
|
||||||
|
{
|
||||||
|
"selected_row": true,
|
||||||
|
"name": "supply_contract_items",
|
||||||
|
"icon": "{{entire_url('/imgs/supply_contract_items.svg')}}",
|
||||||
|
"label": "产品折扣明细"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_supply_contracts.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_supply_contracts.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_supply_contracts.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_supply_contracts.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"alters": {
|
||||||
|
"status": {
|
||||||
|
"uitype": "code",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "生效中"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "2",
|
||||||
|
"text": "已到期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "已终止"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "所属分销商机构ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "organization",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "orgname",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_id",
|
||||||
|
"title": "供应商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "供应商ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "supplier_id",
|
||||||
|
"textField": "supplier_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "suppliers",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "supplier_name",
|
||||||
|
"valueField": "supplier_id",
|
||||||
|
"textField": "supplier_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contract_code",
|
||||||
|
"title": "合同编号",
|
||||||
|
"type": "str",
|
||||||
|
"length": 64,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "合同编号"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contract_name",
|
||||||
|
"title": "合同名称",
|
||||||
|
"type": "str",
|
||||||
|
"length": 255,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "合同名称"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sign_date",
|
||||||
|
"title": "签署日期",
|
||||||
|
"type": "date",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "签署日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "start_date",
|
||||||
|
"title": "生效日期",
|
||||||
|
"type": "date",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "生效日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "end_date",
|
||||||
|
"title": "到期日期",
|
||||||
|
"type": "date",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "到期日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"title": "状态",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "1",
|
||||||
|
"cwidth": 4,
|
||||||
|
"uitype": "code",
|
||||||
|
"datatype": "char",
|
||||||
|
"label": "状态",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"value": "1",
|
||||||
|
"text": "生效中"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "2",
|
||||||
|
"text": "已到期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "0",
|
||||||
|
"text": "已终止"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default_discount",
|
||||||
|
"title": "默认折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"default": "1.0000",
|
||||||
|
"cwidth": 5,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "默认折扣"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "备注"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "创建人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "创建时间"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"title": "更新时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "更新时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[
|
||||||
|
{
|
||||||
|
"wid": "self",
|
||||||
|
"event": "supply_contract_items",
|
||||||
|
"actiontype": "urlwidget",
|
||||||
|
"target": "PopupWindow",
|
||||||
|
"popup_options": {
|
||||||
|
"title": "产品折扣明细",
|
||||||
|
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=supply_contract_items",
|
||||||
|
"resizable": true,
|
||||||
|
"height": "70%",
|
||||||
|
"width": "70%"
|
||||||
|
},
|
||||||
|
"params_mapping": {
|
||||||
|
"mapping": {
|
||||||
|
"id": "contract_id",
|
||||||
|
"referer_widget": "referer_widget"
|
||||||
|
},
|
||||||
|
"need_other": false
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"method": "POST",
|
||||||
|
"params": {},
|
||||||
|
"url": "{{entire_url('../supply_contract_items_list')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
70
wwwroot/supply_contracts_list/update_supply_contracts.dspy
Normal file
70
wwwroot/supply_contracts_list/update_supply_contracts.dspy
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"resellerid": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('supply_contracts', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('supply_contracts', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
id = params_kw.id
|
||||||
|
if not id or len(id) > 32:
|
||||||
|
id = uuid()
|
||||||
|
ns['id'] = id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.C('supplychain_accounting', ns.copy())
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"title":"Add Success",
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Add Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
ns = {
|
||||||
|
'id':params_kw['id'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
r = await sor.D('supplychain_accounting', ns)
|
||||||
|
debug('delete success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Success",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('Delete failed');
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Delete Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,230 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
ns['userorgid'] = userorgid
|
||||||
|
|
||||||
|
debug(f'get_supplychain_accounting.dspy:{ns=}')
|
||||||
|
if not ns.get('page'):
|
||||||
|
ns['page'] = 1
|
||||||
|
if not ns.get('sort'):
|
||||||
|
|
||||||
|
|
||||||
|
ns['sort'] = ["sale_date desc","created_at desc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql = '''select a.*, b.supply_contract_id_text, c.distribution_agreement_id_text, d.sub_distributor_id_text, e.supplier_id_text, f.prodtypeid_text, g.productid_text, h.resellerid_text
|
||||||
|
from (select * from supplychain_accounting where 1=1 [[filterstr]]) a left join (select id as supply_contract_id,
|
||||||
|
contract_name as supply_contract_id_text from supply_contracts where 1 = 1) b on a.supply_contract_id = b.supply_contract_id left join (select id as distribution_agreement_id,
|
||||||
|
agreement_name as distribution_agreement_id_text from distribution_agreements where 1 = 1) c on a.distribution_agreement_id = c.distribution_agreement_id left join (select id as sub_distributor_id,
|
||||||
|
sub_dist_name as sub_distributor_id_text from sub_distributors where 1 = 1) d on a.sub_distributor_id = d.sub_distributor_id left join (select id as supplier_id,
|
||||||
|
supplier_name as supplier_id_text from suppliers where 1 = 1) e on a.supplier_id = e.supplier_id left join (select id as prodtypeid,
|
||||||
|
type_name as prodtypeid_text from product_types where 1 = 1) f on a.prodtypeid = f.prodtypeid left join (select id as productid,
|
||||||
|
product_name as productid_text from products where 1 = 1) g on a.productid = g.productid left join (select id as resellerid,
|
||||||
|
orgname as resellerid_text from organization where 1 = 1) h on a.resellerid = h.resellerid'''
|
||||||
|
|
||||||
|
filterjson = params_kw.get('data_filter')
|
||||||
|
fields_str=r'''[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属主分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_contract_id",
|
||||||
|
"title": "供销合同ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_contract_item_id",
|
||||||
|
"title": "供销合同产品明细ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distribution_agreement_id",
|
||||||
|
"title": "分销协议ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distribution_agreement_item_id",
|
||||||
|
"title": "分销协议产品明细ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_distributor_id",
|
||||||
|
"title": "二级分销商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_id",
|
||||||
|
"title": "供应商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prodtypeid",
|
||||||
|
"title": "产品分类ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "productid",
|
||||||
|
"title": "产品ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "quantity",
|
||||||
|
"title": "数量",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unit_price",
|
||||||
|
"title": "销售单价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_discount",
|
||||||
|
"title": "进货折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_amount",
|
||||||
|
"title": "进货金额(应付供应商)",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dist_discount",
|
||||||
|
"title": "分销折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dist_amount",
|
||||||
|
"title": "分销金额(二级分销商应付)",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "profit_amount",
|
||||||
|
"title": "利润金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sale_date",
|
||||||
|
"title": "销售日期",
|
||||||
|
"type": "date",
|
||||||
|
"nullable": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "source_type",
|
||||||
|
"title": "来源类型",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"default": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "source_id",
|
||||||
|
"title": "来源记录ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no"
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
ori_fields = json.loads(fields_str)
|
||||||
|
if not filterjson:
|
||||||
|
fields = [ f['name'] for f in ori_fields ]
|
||||||
|
filterjson = default_filterjson(fields, ns)
|
||||||
|
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":[]
|
||||||
|
}
|
||||||
378
wwwroot/supplychain_accounting_list/index.ui
Normal file
378
wwwroot/supplychain_accounting_list/index.ui
Normal file
@ -0,0 +1,378 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"id":"supplychain_accounting_tbl",
|
||||||
|
"widgettype":"Tabular",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
|
||||||
|
|
||||||
|
"title":"供销记账表",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"css":"card",
|
||||||
|
|
||||||
|
|
||||||
|
"editable":{
|
||||||
|
|
||||||
|
"new_data_url":"{{entire_url('add_supplychain_accounting.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"delete_data_url":"{{entire_url('delete_supplychain_accounting.dspy')}}",
|
||||||
|
|
||||||
|
|
||||||
|
"update_data_url":"{{entire_url('update_supplychain_accounting.dspy')}}"
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"data_url":"{{entire_url('./get_supplychain_accounting.dspy')}}",
|
||||||
|
|
||||||
|
"data_method":"GET",
|
||||||
|
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
|
||||||
|
"row_options":{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"browserfields": {
|
||||||
|
"exclouded": [
|
||||||
|
"created_by",
|
||||||
|
"created_at"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"editexclouded":[
|
||||||
|
"id",
|
||||||
|
"resellerid",
|
||||||
|
"created_by",
|
||||||
|
"created_at"
|
||||||
|
],
|
||||||
|
|
||||||
|
"fields":[
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"title": "主键ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "主键ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "resellerid",
|
||||||
|
"title": "所属主分销商机构ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"nullable": "no",
|
||||||
|
"label": "所属主分销商机构ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "organization",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "orgname",
|
||||||
|
"valueField": "resellerid",
|
||||||
|
"textField": "resellerid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_contract_id",
|
||||||
|
"title": "供销合同ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "供销合同ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "supply_contract_id",
|
||||||
|
"textField": "supply_contract_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "supply_contracts",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "contract_name",
|
||||||
|
"valueField": "supply_contract_id",
|
||||||
|
"textField": "supply_contract_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_contract_item_id",
|
||||||
|
"title": "供销合同产品明细ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "供销合同产品明细ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distribution_agreement_id",
|
||||||
|
"title": "分销协议ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "分销协议ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "distribution_agreement_id",
|
||||||
|
"textField": "distribution_agreement_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "distribution_agreements",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "agreement_name",
|
||||||
|
"valueField": "distribution_agreement_id",
|
||||||
|
"textField": "distribution_agreement_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "distribution_agreement_item_id",
|
||||||
|
"title": "分销协议产品明细ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "分销协议产品明细ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sub_distributor_id",
|
||||||
|
"title": "二级分销商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "二级分销商ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "sub_distributor_id",
|
||||||
|
"textField": "sub_distributor_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "sub_distributors",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "sub_dist_name",
|
||||||
|
"valueField": "sub_distributor_id",
|
||||||
|
"textField": "sub_distributor_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supplier_id",
|
||||||
|
"title": "供应商ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "供应商ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "supplier_id",
|
||||||
|
"textField": "supplier_id_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "suppliers",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "supplier_name",
|
||||||
|
"valueField": "supplier_id",
|
||||||
|
"textField": "supplier_id_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prodtypeid",
|
||||||
|
"title": "产品分类ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "产品分类ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "prodtypeid",
|
||||||
|
"textField": "prodtypeid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "product_types",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "type_name",
|
||||||
|
"valueField": "prodtypeid",
|
||||||
|
"textField": "prodtypeid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "productid",
|
||||||
|
"title": "产品ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"label": "产品ID",
|
||||||
|
"uitype": "code",
|
||||||
|
"valueField": "productid",
|
||||||
|
"textField": "productid_text",
|
||||||
|
"params": {
|
||||||
|
"dbname": "{{get_module_dbname('supplychain')}}",
|
||||||
|
"table": "products",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "product_name",
|
||||||
|
"valueField": "productid",
|
||||||
|
"textField": "productid_text"
|
||||||
|
},
|
||||||
|
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "quantity",
|
||||||
|
"title": "数量",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "数量"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unit_price",
|
||||||
|
"title": "销售单价",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 4,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "销售单价"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_discount",
|
||||||
|
"title": "进货折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"cwidth": 5,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "进货折扣"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supply_amount",
|
||||||
|
"title": "进货金额(应付供应商)",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "进货金额(应付供应商)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dist_discount",
|
||||||
|
"title": "分销折扣",
|
||||||
|
"type": "double",
|
||||||
|
"length": 5,
|
||||||
|
"dec": 4,
|
||||||
|
"cwidth": 5,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "分销折扣"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dist_amount",
|
||||||
|
"title": "分销金额(二级分销商应付)",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "分销金额(二级分销商应付)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "profit_amount",
|
||||||
|
"title": "利润金额",
|
||||||
|
"type": "double",
|
||||||
|
"length": 15,
|
||||||
|
"dec": 2,
|
||||||
|
"nullable": "no",
|
||||||
|
"default": "0",
|
||||||
|
"cwidth": 15,
|
||||||
|
"uitype": "float",
|
||||||
|
"datatype": "double",
|
||||||
|
"label": "利润金额"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sale_date",
|
||||||
|
"title": "销售日期",
|
||||||
|
"type": "date",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "date",
|
||||||
|
"datatype": "date",
|
||||||
|
"label": "销售日期"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "source_type",
|
||||||
|
"title": "来源类型",
|
||||||
|
"type": "char",
|
||||||
|
"length": 1,
|
||||||
|
"default": "1",
|
||||||
|
"cwidth": 4,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "char",
|
||||||
|
"label": "来源类型"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "source_id",
|
||||||
|
"title": "来源记录ID",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "来源记录ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "remark",
|
||||||
|
"title": "备注",
|
||||||
|
"type": "text",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "text",
|
||||||
|
"datatype": "text",
|
||||||
|
"label": "备注"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_by",
|
||||||
|
"title": "创建人",
|
||||||
|
"type": "str",
|
||||||
|
"length": 32,
|
||||||
|
"cwidth": 18,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "str",
|
||||||
|
"label": "创建人"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "created_at",
|
||||||
|
"title": "创建时间",
|
||||||
|
"type": "datetime",
|
||||||
|
"nullable": "no",
|
||||||
|
"length": 0,
|
||||||
|
"uitype": "str",
|
||||||
|
"datatype": "datetime",
|
||||||
|
"label": "创建时间"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"page_rows":160,
|
||||||
|
"cache_limit":5
|
||||||
|
}
|
||||||
|
|
||||||
|
,"binds":[]
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
ns = params_kw.copy()
|
||||||
|
for k,v in ns.items():
|
||||||
|
if v == 'NaN' or v == 'null':
|
||||||
|
ns[k] = None
|
||||||
|
|
||||||
|
|
||||||
|
userorgid = await get_userorgid()
|
||||||
|
if not userorgid:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Authorization Error",
|
||||||
|
"timeout":3,
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"message":"Please login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns['resellerid'] = userorgid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('supplychain')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
|
||||||
|
ns1 = {
|
||||||
|
|
||||||
|
"resellerid": userorgid,
|
||||||
|
|
||||||
|
|
||||||
|
"id": params_kw.id
|
||||||
|
}
|
||||||
|
recs = await sor.R('supplychain_accounting', ns1)
|
||||||
|
if len(recs) < 1:
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"Record no exist or with wrong ownership"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r = await sor.U('supplychain_accounting', ns)
|
||||||
|
debug('update success');
|
||||||
|
return {
|
||||||
|
"widgettype":"Message",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Success",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"ok"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"widgettype":"Error",
|
||||||
|
"options":{
|
||||||
|
"title":"Update Error",
|
||||||
|
"cwidth":16,
|
||||||
|
"cheight":9,
|
||||||
|
"timeout":3,
|
||||||
|
"message":"failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user