From e06339f95d4259fc3e6cd9ac0bf7e1a167d438ca Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 5 Jul 2026 14:44:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=A2=E6=88=B7=E5=BD=92=E5=B1=9E?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E2=80=94=E2=80=94=E5=88=97=E5=87=BA=E6=9C=BA?= =?UTF-8?q?=E6=9E=84=E5=AE=A2=E6=88=B7+=E5=88=86=E9=85=8D=E9=94=80?= =?UTF-8?q?=E5=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- json/customer_sale_list.json | 52 +++++++++++++++++++++++++ wwwroot/api/assign_customer_sale.dspy | 3 ++ wwwroot/api/get_customer_sale_list.dspy | 18 +++++++++ wwwroot/api/get_sales.dspy | 15 +++++++ wwwroot/customer_sale_assign_form.ui | 20 ++++++++++ 5 files changed, 108 insertions(+) create mode 100644 json/customer_sale_list.json create mode 100644 wwwroot/api/assign_customer_sale.dspy create mode 100644 wwwroot/api/get_customer_sale_list.dspy create mode 100644 wwwroot/api/get_sales.dspy create mode 100644 wwwroot/customer_sale_assign_form.ui diff --git a/json/customer_sale_list.json b/json/customer_sale_list.json new file mode 100644 index 0000000..0ee35ea --- /dev/null +++ b/json/customer_sale_list.json @@ -0,0 +1,52 @@ +{ + "tblname": "discount_customer_bind", + "alias": "customer_sale_list", + "title": "客户销售归属", + "params": { + "editable": { + "get_data_url": "{{entire_url('../api/get_customer_sale_list.dspy')}}" + }, + "browserfields": { + "exclouded": ["id", "customerid", "bind_id", "sale_id"], + "customer_name": { + "title": "客户名称", + "width": 200 + }, + "sale_name": { + "title": "归属销售", + "width": 150 + } + }, + "sortby": "customer_name", + "editexclouded": ["customerid", "customer_name", "bind_id", "sale_name"], + "toolbar": { + "tools": [ + { + "name": "assign_sale", + "label": "分配销售", + "selected_row": true + } + ] + }, + "binds": [ + { + "wid": "self", + "event": "assign_sale", + "actiontype": "urlwidget", + "target": "PopupWindow", + "popup_options": { + "title": "分配销售", + "cwidth": 15, + "cheight": 12 + }, + "options": { + "url": "{{entire_url('customer_sale_assign_form.ui')}}", + "params": { + "customerid": "${customerid}$", + "customer_name": "${customer_name}$" + } + } + } + ] + } +} diff --git a/wwwroot/api/assign_customer_sale.dspy b/wwwroot/api/assign_customer_sale.dspy new file mode 100644 index 0000000..6585807 --- /dev/null +++ b/wwwroot/api/assign_customer_sale.dspy @@ -0,0 +1,3 @@ +# 手动分配客户给销售 +result = await assign_customer_to_sale(request, params_kw) +return result diff --git a/wwwroot/api/get_customer_sale_list.dspy b/wwwroot/api/get_customer_sale_list.dspy new file mode 100644 index 0000000..097dde9 --- /dev/null +++ b/wwwroot/api/get_customer_sale_list.dspy @@ -0,0 +1,18 @@ +# 获取机构下所有客户及销售归属 +db = DBPools() +resellerid = params_kw.get('resellerid') or '0' + +sql = """ +select o.id as customerid, o.orgname as customer_name, + dcb.id as bind_id, dcb.sale_id, + u.name as sale_name +from organization o +left join discount_customer_bind dcb on dcb.customerid = o.id and dcb.resellerid = ${resellerid}$ +left join user u on u.id = dcb.sale_id +where 1=1 +order by o.orgname +""" + +async with db.sqlorContext('sage') as sor: + rows = await sor.sqlExe(sql, {'resellerid': resellerid}) + return rows diff --git a/wwwroot/api/get_sales.dspy b/wwwroot/api/get_sales.dspy new file mode 100644 index 0000000..00a582b --- /dev/null +++ b/wwwroot/api/get_sales.dspy @@ -0,0 +1,15 @@ +# 获取销售用户列表(供下拉选择) +db = DBPools() +resellerid = params_kw.get('resellerid') or '0' +sql = """ +select u.id as sale_id, u.name as sale_name +from user u +join org_user ou on ou.user_id = u.id +where ou.org_id = ${resellerid}$ +order by u.name +""" +async with db.sqlorContext('sage') as sor: + rows = await sor.sqlExe(sql, {'resellerid': resellerid}) + # CRUD framework expects [{value, text}] format for combobox + result = [{'value': r.sale_id, 'text': r.sale_name} for r in rows] + return result diff --git a/wwwroot/customer_sale_assign_form.ui b/wwwroot/customer_sale_assign_form.ui new file mode 100644 index 0000000..d78322f --- /dev/null +++ b/wwwroot/customer_sale_assign_form.ui @@ -0,0 +1,20 @@ +{ + "widgettype": "Form", + "options": { + "width": "100%", "height": "100%", + "url": "{{entire_url('../api/assign_customer_sale.dspy')}}", + "method": "POST", + "fields": [ + {"name": "customer_name", "label": "客户", "uitype": "str", "readonly": true}, + { + "name": "sale_id", "label": "分配销售", "uitype": "select", + "data_url": "{{entire_url('../api/get_sales.dspy')}}", + "tip": "选择销售负责人" + } + ] + }, + "binds": [ + {"wid": "self", "event": "submited", "actiontype": "script", "target": "self", + "script": "await bricks.show_resp_message_or_error(event.params)"} + ] +}