feat: 备货单列表支持 view_scope(all/self) 视图切换(仅 user_id=73)
在 /crm/stock/order/list 的 buildQueryConfig index 分支最前面短路: - 仅当前用户 uid=73 且传 view_scope 时生效,最高优先级,覆盖角色范围逻辑 - all:自己和别人的单,排除草稿(approval_status>=1) - self:只看自己(salesperson_id=73,含自己草稿) - 非73用户或未传该参数:走原逻辑,向后兼容,无越权 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,25 @@ class StockOrdersService extends \app\common\service\StockOrdersService
|
|||||||
switch ($scene) {
|
switch ($scene) {
|
||||||
case 'index':
|
case 'index':
|
||||||
|
|
||||||
|
// ====== view_scope:仅 user_id=73 生效,最高优先级,覆盖下方业务id默认值与角色范围逻辑 ======
|
||||||
|
$viewScope = $p['view_scope'] ?? '';
|
||||||
|
if ($request->user->uid == 73 && in_array($viewScope, ['all', 'self'], true)) {
|
||||||
|
if ($viewScope === 'self') {
|
||||||
|
$config['where']['salesperson_id'] = $request->user->uid; // 只看自己(含自己草稿)
|
||||||
|
} else { // 'all':自己和别人的,排除草稿(approval_status=0)
|
||||||
|
$config['where']['approval_status'] = ['>=', 1];
|
||||||
|
}
|
||||||
|
$config['where']['is_final'] = $p['is_final'] ?? 0;
|
||||||
|
if (isset($p['keyword']) && $p['keyword']) {
|
||||||
|
$k = '%' . $p['keyword'] . '%';
|
||||||
|
foreach (['pi_no', 'order_no', 'customer_snapshot'] as $col) {
|
||||||
|
$config['orWhere'][] = [$col, 'like', $k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$config['order']['id'] = 'desc';
|
||||||
|
break; // 最高优先级:跳过下方业务id默认值与角色范围逻辑
|
||||||
|
}
|
||||||
|
|
||||||
// ====== ====== 筛选 ====== ======
|
// ====== ====== 筛选 ====== ======
|
||||||
// 业务id
|
// 业务id
|
||||||
if (isset($p['salesperson_id']) && $p['salesperson_id']) {
|
if (isset($p['salesperson_id']) && $p['salesperson_id']) {
|
||||||
|
|||||||
Reference in New Issue
Block a user