Commit 012bcf67 by Sxy

feat: 添加 数据权限过滤

parent fcc92d36
...@@ -59,8 +59,10 @@ class CtlBase { ...@@ -59,8 +59,10 @@ class CtlBase {
//添加组织结构路径,如果是上级,取上级 //添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != "") { if (req.xctx.ptags && req.xctx.ptags != "") {
pobj.opath = req.xctx.ptags pobj.opath = req.xctx.ptags
pob.isPrincipal = true
} else { } else {
pobj.opath = req.xctx.opath pobj.opath = req.xctx.opath
pob.isPrincipal = false
} }
if (!req.xctx.appkey) { if (!req.xctx.appkey) {
return [-200, "请求头缺少应用x-app-key"] return [-200, "请求头缺少应用x-app-key"]
......
...@@ -5,33 +5,65 @@ class DeliverybillDao extends Dao { ...@@ -5,33 +5,65 @@ class DeliverybillDao extends Dao {
super(Dao.getModelName(DeliverybillDao)); super(Dao.getModelName(DeliverybillDao));
} }
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件 extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件
qc.raw = true;
let filters = []
// 公司数据过滤
filters.push({
facilitator_id: Number(qobj.company_id || -1)
});
/** /**
* 权限 过滤 * 数据权限过滤
* 1. 管理员 (opath 为空)、 销售主管(isPrincipal = true) 、 销售 (isPrincipal = false && opath不为空)
*/ */
if (!qobj.opath) { // 管理员 不做处理
//需要添加公司查询条件 } else if (qobj.isPrincipal) { // 销售主管 查询为空和自己组织结构下的
qc.where["facilitator_id"] = Number(qobj.company_id || -1); filters.push({
// 组织结构 $or: [
if (qobj.opath && qobj.opath != "") {
qc.where['$or'] = [
{
delivery_man_opcode: { [this.db.Op.like]: `%${qobj.opath}%` },
},
{ {
salesman_opcode: { [this.db.Op.like]: `%${qobj.opath}%` }, salesman_opcode: {
$eq: null
}
}, {
salesman_opcode: { $like: `%${qobj.opath}%` }
} }
] ]
});
} else { // 销售 查询自己的
filters.push({
salesman_opcode: { $like: `%${qobj.opath}%` }
});
} }
qc.raw = true; // 产品类型过滤
/**
* 筛选 条件 TODO: 筛选功能字段(filter)、确定产品码是多少
*/
let filters = []
filters.push({ filters.push({
product_code: system.SERVICECODE.FT product_code: system.SERVICECODE.FT
}) })
// 根据 页面 过滤 交付状态
switch (qobj.bizpath) {
case "/configManageMent/deliveryRecord": // 交付单记录
filters.push({
delivery_status: {
$in: [
system.SERVERSESTATUS.INSERVICE, system.SERVERSESTATUS.CLOSED
]
}
});
break
case "/configManageMent/deliveryManage": //交付单处理
filters.push({
delivery_status: {
$in: [
system.SERVERSESTATUS.RECEIVED, system.SERVERSESTATUS.WAITUSERCONFIRM
]
}
});
break
}
/**
* 筛选 条件 TODO: 筛选功能字段(filter)
*/
qc.where["$and"] = filters; qc.where["$and"] = filters;
return qw; return qw;
} }
......
...@@ -363,7 +363,7 @@ System.FLOWCODE = { ...@@ -363,7 +363,7 @@ System.FLOWCODE = {
} }
// 服务名称 // 服务名称
System.SERVICECODE = { System.SERVICECODE = {
FT: 'ft' // 财税项目 FT: 'bookkeeping' // 财税项目
} }
// 资质服务单状态 // 资质服务单状态
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment