feat: 客户归属管理——列出机构客户+分配销售
This commit is contained in:
parent
62f07bc8bb
commit
e06339f95d
52
json/customer_sale_list.json
Normal file
52
json/customer_sale_list.json
Normal file
@ -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}$"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
3
wwwroot/api/assign_customer_sale.dspy
Normal file
3
wwwroot/api/assign_customer_sale.dspy
Normal file
@ -0,0 +1,3 @@
|
||||
# 手动分配客户给销售
|
||||
result = await assign_customer_to_sale(request, params_kw)
|
||||
return result
|
||||
18
wwwroot/api/get_customer_sale_list.dspy
Normal file
18
wwwroot/api/get_customer_sale_list.dspy
Normal file
@ -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
|
||||
15
wwwroot/api/get_sales.dspy
Normal file
15
wwwroot/api/get_sales.dspy
Normal file
@ -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
|
||||
20
wwwroot/customer_sale_assign_form.ui
Normal file
20
wwwroot/customer_sale_assign_form.ui
Normal file
@ -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)"}
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user