修改审批

This commit is contained in:
mzl
2025-09-18 06:46:15 +00:00
parent 8f8d07044b
commit e5441d51ae
40 changed files with 440 additions and 761 deletions
@@ -0,0 +1,62 @@
<?php
namespace app\common\service;
use app\common\validate\ApprovalFlowsValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\ApprovalFlows;
use support\Request;
class ApprovalFlowsService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = ApprovalFlows::class;
/**
* 验证器
*/
protected $validator = ApprovalFlowsValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
protected function buildQueryConfig(Request $request, string $scene = 'index'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'index':
$config['order']['id'] = 'desc';
break;
case 'show':
$config['where']['id'] = $p['id'];
break;
case 'store':
break;
case 'update':
$config['where']['id'] = $p['id'];
break;
case 'destroy':
$config['where']['id'] = $p['id'];
break;
}
return $config;
}
}
@@ -0,0 +1,31 @@
<?php
namespace app\common\service;
use app\common\validate\ApprovalInstancesValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\ApprovalInstances;
class ApprovalInstancesService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = ApprovalInstances::class;
/**
* 验证器
*/
protected $validator = ApprovalInstancesValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
}
@@ -0,0 +1,118 @@
<?php
namespace app\common\service;
use app\common\validate\ApprovalRecordsValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\ApprovalRecords;
use support\Request;
class ApprovalRecordsService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = ApprovalRecords::class;
/**
* 验证器
*/
protected $validator = ApprovalRecordsValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'index':
$config['order']['id'] = 'desc';
$config['with'] = [
'instance',
'approver',
'instance.flows',
'instance.initiator',
'instance.bizInfo'
];
// $config['dataLimit']['type'] = 'relation';
// $config['dataLimit']['userId'] = $request->user->uid;
// $config['dataLimit']['userField'] = 'approver_id';
break;
case 'todo':
if ($p['scene'] === 'todo') {
// if (!in_array(1, $request->user->role_ids)) {
$config['where']['approver_id'] = $request->user->uid;
// }
$config['where']['status'] = 'pending';
$config['where']['instance.status'] = 'processing';
}
if ($p['scene'] === 'history') {
if (!in_array(1, $request->user->role_ids)) {
$config['where']['approver_id'] = $request->user->uid;
}
$config['where']['status'] = ['!=', 'pending'];
}
$config['order']['id'] = 'desc';
$config['with'] = [
'instance',
'approver',
'instance.flows',
'instance.initiator',
'instance.bizInfo'
];
break;
case 'show':
$config['where']['id'] = $p['id'];
break;
case 'store':
break;
case 'update':
$config['where']['id'] = $p['id'];
break;
case 'destroy':
$config['where']['id'] = $p['id'];
break;
case 'logs':
$config['where']['instance_id'] = $p['instance_id'];
$config['order']['id'] = 'desc';
break;
}
return $config;
}
public function serviceApprove(Request $request)
{
$param = $request->all();
$appro = new \app\common\utils\approval\service\ApprovalFlowService();
return $appro->approve($param['instance_id'], $request->user->uid, $param['action'], $param['comment']);
}
public function serviceLogs(Request $request)
{
$config = $this->buildQueryConfig($request, 'logs');
$item = $this->logicListAll($config);
return $this->postProcess('Logs', $item);
}
}
@@ -86,7 +86,7 @@ class MessageNotificationsService
return ['msg_id' => $msgId];
}
public function afterServiceList($data)
public function afterServiceIndex($data)
{
$data->each(function (&$item) {
$temp = explode(',', $item->recipient);
@@ -97,7 +97,7 @@ class MessageUserStatusService
}
protected function afterServiceList($res)
protected function afterServiceIndex($res)
{
$res->each(function (&$item) {
if (isset($item->message)) {
+1 -1
View File
@@ -95,7 +95,7 @@ class ResourceService
}
protected function afterServiceListAll($data)
protected function afterServiceDefault($data)
{
$data = Tree::buildMenuTreeWithReference($data->toArray());
return $data;
+6 -4
View File
@@ -28,23 +28,25 @@ class SysDictService
public static function pluckValuesByCode(string $dictCode): \Illuminate\Support\Collection
public static function pluckValuesByCode(string $dictCode): array
{
return SysDict::where('dict_code', $dictCode)
->where('status', 1)
->first()?->items()
->where('status', 1)
->orderBy('sort')
->pluck('item_value') ?? collect();
->pluck('item_value')
->toArray() ?? [];
}
public static function pluckKeyValueByCode(string $dictCode): \Illuminate\Support\Collection
public static function pluckKeyValueByCode(string $dictCode): array
{
return SysDict::where('dict_code', $dictCode)
->where('status', 1)
->first()?->items()
->where('status', 1)
->orderBy('sort')
->pluck('item_value', 'item_label') ?? collect();
->pluck('item_value', 'item_label')
->toArray() ?? [];
}
}