Merge branch 'feature/mzl_dev' into develop
# Conflicts: # app/admin/service/SysDictService.php
This commit is contained in:
@@ -22,14 +22,14 @@ class ApprovalFlowsController extends BaseController
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
|
||||
public function desc()
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\ApprovalInstancesService;
|
||||
|
||||
class ApprovalInstancesController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new ApprovalInstancesService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\ApprovalRecordsService;
|
||||
use app\admin\service\SysDictService;
|
||||
use app\common\model\SysDictItem;
|
||||
use support\Request;
|
||||
|
||||
class ApprovalRecordsController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new ApprovalRecordsService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['records']) && count($data['records']) > 0) {
|
||||
foreach ($data['records'] as $key => &$record) {
|
||||
$result = [
|
||||
'id' => $record['id'],
|
||||
'flows_name' => $record['approvalInstance']['flows']['name'],
|
||||
|
||||
'instance_id' => $record['instance_id'],
|
||||
|
||||
'biz_id' => $record['approvalInstance']['biz_id'],
|
||||
'biz_desc' => '备货单【'.$record['approvalInstance']['bizInfo']['order_no'].'】',
|
||||
'biz_type' => $record['approvalInstance']['flow_type'],
|
||||
|
||||
'initiator_name' => $record['approvalInstance']['initiator']['name'],
|
||||
'initiator_avatar' => $record['approvalInstance']['initiator']['avatar'],
|
||||
|
||||
'approver_name' => $record['approver']['name'],
|
||||
'approver_avatar' => $record['approver']['avatar'],
|
||||
|
||||
'step_index' => $record['step_index'],
|
||||
'action' => $record['action'],
|
||||
'status' => SysDictItem::where('item_value', $record['status'])->where('status', 1)->value('item_label'),
|
||||
'comment' => $record['comment'],
|
||||
'approved_at' => $record['approved_at'],
|
||||
|
||||
'finished_at' => $record['approvalInstance']['finished_at'],
|
||||
'deadline_at' => $record['approvalInstance']['deadline_at'],
|
||||
|
||||
'created_at' => $record['created_at']
|
||||
];
|
||||
$record = $result;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function approve(Request $request)
|
||||
{
|
||||
try {
|
||||
$res = $this->service->serviceApprove($request);
|
||||
return $this->success([], $res['msg']);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\admin\model\ApprovalInstances;
|
||||
|
||||
class ApprovalInstancesLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = ApprovalInstances::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\admin\model\ApprovalRecords;
|
||||
|
||||
class ApprovalRecordsLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = ApprovalRecords::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use app\common\model\StockOrders;
|
||||
use app\common\model\User;
|
||||
use support\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class ApprovalInstances extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'approval_instances';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
// protected $fillable = ['id', 'flow_type', 'biz_id', 'biz_type', 'form_data', 'initiator_id', 'status', 'current_step', 'finished_at', 'deadline_at', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'flow_type',
|
||||
'biz_id',
|
||||
'biz_type',
|
||||
'form_data',
|
||||
'initiator_id',
|
||||
'status',
|
||||
'current_step',
|
||||
'finished_at',
|
||||
'deadline_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'form_data' => 'array', // 自动转换 JSON 字段为数组
|
||||
'finished_at' => 'datetime',
|
||||
'deadline_at' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* 一个审批实例可以有多个审批记录
|
||||
*/
|
||||
public function approvalRecords(): HasMany
|
||||
{
|
||||
return $this->hasMany(ApprovalRecords::class, 'instance_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前步骤的所有审批记录(pending 状态)
|
||||
*/
|
||||
public function currentStepRecords()
|
||||
{
|
||||
return $this->approvalRecords()
|
||||
->where('step_index', $this->current_step)
|
||||
->where('status', 'pending');
|
||||
}
|
||||
|
||||
public function flows()
|
||||
{
|
||||
return $this->belongsTo(ApprovalFlows::class, 'flow_type', 'type');
|
||||
}
|
||||
|
||||
public function initiator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'initiator_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function bizInfo()
|
||||
{
|
||||
return $this->hasOne(StockOrders::class, 'id', 'biz_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use app\common\model\User;
|
||||
use support\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ApprovalRecords extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'approval_records';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
// protected $fillable = ['id', 'instance_id', 'approver_id', 'step_index', 'action', 'status', 'comment', 'approved_at', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'instance_id',
|
||||
'approver_id',
|
||||
'step_index',
|
||||
'action',
|
||||
'status',
|
||||
'comment',
|
||||
'approved_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'approved_at' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* 一条审批记录属于一个审批实例
|
||||
*/
|
||||
public function approvalInstance(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ApprovalInstances::class, 'instance_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联审批人
|
||||
*/
|
||||
public function approver()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approver_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\ApprovalInstancesValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\admin\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,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\ApprovalRecordsValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\admin\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'] = [
|
||||
'approvalInstance',
|
||||
'approver',
|
||||
'approvalInstance.flows',
|
||||
'approvalInstance.initiator',
|
||||
'approvalInstance.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;
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,9 @@ namespace app\admin\service;
|
||||
use app\admin\validate\SysDictValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysDict;
|
||||
use app\common\model\SysDictCategory;
|
||||
use app\common\utils\translation\service\TranslationService;
|
||||
use app\queue\utils\Translat;
|
||||
use app\common\utils\translation\service\TranslationService;
|
||||
use app\queue\utils\Translat;
|
||||
use support\Request;
|
||||
@@ -151,4 +154,89 @@ class SysDictService
|
||||
$traitsourceFields
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
示例用法:
|
||||
|
||||
// 1) 获取分类为“车辆类型”的所有字典
|
||||
$list = $dictService->getDictsByCategoryName('车辆类型');
|
||||
// => [['dict_code' => 'SUV', 'dict_name' => '越野车'], …]
|
||||
|
||||
// 2) 获取某分类下某个 code 的名称
|
||||
$name = $dictService->getDictName('车辆类型', 'SUV');
|
||||
// => "越野车"
|
||||
|
||||
// 3) 获取某分类下拉选项
|
||||
$options = $dictService->getDictOptions('车辆类型');
|
||||
// => ['SUV' => '越野车', 'SEDAN' => '轿车', …]
|
||||
|
||||
// 4) 通过 code 直接拿名称(不管分类)
|
||||
$name = $dictService->getNameByCode('SUV');
|
||||
// => "越野车"
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 根据分类名获取字典列表
|
||||
*/
|
||||
public function getDictsByCategoryName(string $categoryName): array
|
||||
{
|
||||
$category = SysDictCategory::where('category_name', $categoryName)
|
||||
->where('status', 1)
|
||||
->first();
|
||||
|
||||
if (!$category) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $category->dicts()->get(['dict_code', 'dict_name'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类名 + 字典code 获取字典项名称
|
||||
*/
|
||||
public function getDictName(string $categoryName, string $dictCode): ?string
|
||||
{
|
||||
$dict = SysDict::whereHas('category', function ($q) use ($categoryName) {
|
||||
$q->where('category_name', $categoryName)->where('status', 1);
|
||||
})
|
||||
->where('dict_code', $dictCode)
|
||||
->where('status', 1)
|
||||
->whereNull('deleted_at')
|
||||
->first();
|
||||
|
||||
return $dict?->dict_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类名获取下拉键值对
|
||||
* 返回格式:['code1' => '名称1', 'code2' => '名称2']
|
||||
*/
|
||||
public function getDictOptions(string $categoryName): array
|
||||
{
|
||||
$dicts = $this->getDictsByCategoryName($categoryName);
|
||||
|
||||
$options = [];
|
||||
foreach ($dicts as $item) {
|
||||
$options[$item['dict_code']] = $item['dict_name'];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典 code 获取对应的名称(不依赖分类)
|
||||
*/
|
||||
public function getNameByCode(string $dictCode): ?string
|
||||
{
|
||||
$dict = SysDict::where('dict_code', $dictCode)
|
||||
->where('status', 1)
|
||||
->whereNull('deleted_at')
|
||||
->first();
|
||||
|
||||
return $dict?->dict_name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ApprovalInstancesValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ApprovalRecordsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -89,4 +89,10 @@ class StockOrders extends Model
|
||||
{
|
||||
return $this->hasOne(VehMoneyValue::class, 'object_id', 'id')->where('object_scene', 'stock_orders');
|
||||
}
|
||||
|
||||
|
||||
public function salesperson()
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'salesperson_id');
|
||||
}
|
||||
}
|
||||
@@ -56,4 +56,10 @@ class SysDict extends Model
|
||||
{
|
||||
return $this->hasMany(SysDictItem::class, 'dict_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(SysDictCategory::class, 'category_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -46,4 +46,13 @@ class SysDictCategory extends Model
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public function dicts()
|
||||
{
|
||||
return $this->hasMany(SysDict::class, 'category_id', 'id')
|
||||
->where('status', 1)
|
||||
->whereNull('deleted_at')
|
||||
->orderBy('id', 'asc');
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,7 @@ class StockOrdersService
|
||||
$config['with'][] = 'items.moneyValues';
|
||||
$config['with'][] = 'accounts';
|
||||
$config['with'][] = 'moneyValues';
|
||||
$config['with'][] = 'salesperson';
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
@@ -219,6 +220,10 @@ class StockOrdersService
|
||||
flg('备货单【'.$order->order_no.'】创建终版成功,但更新原单失败');
|
||||
}
|
||||
}
|
||||
// 启动审批
|
||||
$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
||||
$result = $appro->start('stock_order_flow', 'stock_orders', $res->id, $res->toArray(), $res->salesperson_id);
|
||||
var_dump($result);
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -242,7 +247,7 @@ class StockOrdersService
|
||||
$fileName = ($pdfData['order_no'] ?? date('YmdHis')) . '.pdf';
|
||||
|
||||
// 本地保存
|
||||
$filePath = \app\common\utils\pdf\service\PdfStorage::saveBinary(
|
||||
\app\common\utils\pdf\service\PdfStorage::saveBinary(
|
||||
$pdfBin,
|
||||
$dir,
|
||||
$fileName
|
||||
@@ -354,6 +359,9 @@ class StockOrdersService
|
||||
$veh = [
|
||||
'order_no' => $item->order_no,
|
||||
'salesperson_snapshot' => $item->salesperson_snapshot,
|
||||
// 'sign_img' => $item->salesperson->sign_img,
|
||||
'sign_img_url' => (!empty($item->salesperson->sign_img))?(new \app\common\service\OssService)->generatePrivateUrl($item->salesperson->sign_img):'',
|
||||
'created_at' => date('Y-m-d', strtotime($item->created_at)),
|
||||
|
||||
'pi_no' => $item->pi_no,
|
||||
'biz_date' => date('Y-m-d', $item->biz_date),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,620 +0,0 @@
|
||||
<?php
|
||||
namespace app\common\utils\approval\service;
|
||||
|
||||
use support\exception\BusinessException;
|
||||
use support\Db;
|
||||
|
||||
class ApprovalFlowService_bak2
|
||||
{
|
||||
// --- 公共方法 ---
|
||||
|
||||
/**
|
||||
* 启动审批流程
|
||||
*/
|
||||
public function start(string $flowType, string $bizType, string $bizId, array $formData, int $initiatorId): array
|
||||
{
|
||||
// 1. 获取流程定义
|
||||
$flow = Db::table('approval_flows')
|
||||
->where('type', $flowType)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if (!$flow) {
|
||||
throw new BusinessException("审批流程未找到或已停用: {$flowType}");
|
||||
}
|
||||
|
||||
$steps = json_decode($flow->steps, true);
|
||||
if (!is_array($steps) || empty($steps)) {
|
||||
throw new BusinessException("流程步骤配置错误");
|
||||
}
|
||||
|
||||
// 2. 查找第一个有效步骤(考虑 condition)
|
||||
$firstStep = $this->getNextValidStep($steps, $formData);
|
||||
if (!$firstStep) {
|
||||
throw new BusinessException("未找到可执行的审批步骤");
|
||||
}
|
||||
|
||||
// 3. 创建审批实例
|
||||
$instanceId = Db::table('approval_instances')->insertGetId([
|
||||
'flow_type' => $flowType,
|
||||
'biz_type' => $bizType,
|
||||
'biz_id' => $bizId,
|
||||
'form_data' => json_encode($formData, JSON_UNESCAPED_UNICODE),
|
||||
'initiator_id' => $initiatorId,
|
||||
'status' => 'processing',
|
||||
'current_step' => 0,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
// 4. 创建审批记录(待办)
|
||||
$approverIds = $this->resolveApprovers($firstStep, (object)['initiator_id' => $initiatorId]);
|
||||
foreach ($approverIds as $approverId) {
|
||||
Db::table('approval_records')->insert([
|
||||
'instance_id' => $instanceId,
|
||||
'step_name' => $firstStep['name'],
|
||||
'approver_id' => $approverId,
|
||||
'status' => 'pending',
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
|
||||
// 5. 通知审批人
|
||||
$this->sendNotification($approverIds, (object)['id' => $instanceId, 'flow_type' => $flowType], 'pending', false);
|
||||
|
||||
// 6. 通知抄送人(当前步骤)
|
||||
$this->notifyCCs($firstStep, (object)['id' => $instanceId, 'flow_type' => $flowType, 'form_data' => json_encode($formData)], 'pending');
|
||||
|
||||
return ['instance_id' => $instanceId];
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行审批
|
||||
*/
|
||||
public function approve(int $instanceId, int $approverId, string $action, string $comment = '')
|
||||
{
|
||||
$instance = Db::table('approval_instances')->where('id', $instanceId)->first();
|
||||
if (!$instance) {
|
||||
throw new BusinessException("审批实例未找到");
|
||||
}
|
||||
|
||||
$steps = json_decode($instance->steps, true) ?: json_decode(Db::table('approval_flows')->where('type', $instance->flow_type)->value('steps'), true);
|
||||
$currentStep = $steps[$instance->current_step] ?? null;
|
||||
|
||||
if (!$currentStep) {
|
||||
throw new BusinessException("当前步骤配置错误");
|
||||
}
|
||||
|
||||
// 检查用户是否有权限审批
|
||||
if (!$this->canUserApproveStep($currentStep, $approverId, $instance)) {
|
||||
throw new BusinessException("您无权审批此步骤");
|
||||
}
|
||||
|
||||
// 更新审批记录
|
||||
Db::table('approval_records')
|
||||
->where('instance_id', $instanceId)
|
||||
->where('approver_id', $approverId)
|
||||
->where('status', 'pending')
|
||||
->update([
|
||||
'status' => $action,
|
||||
'comment' => $comment,
|
||||
'approved_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
// 检查当前步骤是否完成(根据 type: any, all, sequential)
|
||||
$stepCompleted = $this->isStepCompleted($instanceId, $instance->current_step, $currentStep['type']);
|
||||
|
||||
if (!$stepCompleted) {
|
||||
// 步骤未完成,不进入下一步
|
||||
return ['status' => 'step_pending'];
|
||||
}
|
||||
|
||||
// 步骤已完成,进入下一步或结束
|
||||
$nextStep = $this->getNextValidStep($steps, json_decode($instance->form_data, true), $instance->current_step + 1);
|
||||
|
||||
if ($nextStep === null) {
|
||||
// 流程结束
|
||||
Db::table('approval_instances')->where('id', $instanceId)->update([
|
||||
'status' => $action === 'approve' ? 'approved' : 'rejected',
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
// 通知发起人结果
|
||||
$this->sendNotification([$instance->initiator_id], $instance, $action, false);
|
||||
|
||||
return ['status' => 'completed', 'result' => $action];
|
||||
}
|
||||
|
||||
// 进入下一步
|
||||
$nextStepIndex = array_search($nextStep, $steps);
|
||||
Db::table('approval_instances')->where('id', $instanceId)->update([
|
||||
'current_step' => $nextStepIndex,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
// 创建下一步的审批记录
|
||||
$nextApprovers = $this->resolveApprovers($nextStep, $instance);
|
||||
foreach ($nextApprovers as $approverId) {
|
||||
Db::table('approval_records')->insert([
|
||||
'instance_id' => $instanceId,
|
||||
'step_name' => $nextStep['name'],
|
||||
'approver_id' => $approverId,
|
||||
'status' => 'pending',
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
|
||||
// 通知下一步审批人
|
||||
$this->sendNotification($nextApprovers, $instance, 'pending', false);
|
||||
|
||||
// 通知下一步抄送人
|
||||
$this->notifyCCs($nextStep, $instance, 'pending');
|
||||
|
||||
return ['status' => 'next_step', 'step_name' => $nextStep['name']];
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析审批人
|
||||
*/
|
||||
private function resolveApprovers(array $step, object $instance): array
|
||||
{
|
||||
$resolved = [];
|
||||
$formData = json_decode($instance->form_data ?? '{}', true);
|
||||
|
||||
foreach ($step['approvers'] as $approverConfig) {
|
||||
$approverIds = [];
|
||||
|
||||
switch ($approverConfig['type']) {
|
||||
case 'role':
|
||||
$approverIds = $this->getUserIdsByRole($approverConfig['value']);
|
||||
break;
|
||||
case 'user':
|
||||
$approverIds = [(int)$approverConfig['value']];
|
||||
break;
|
||||
case 'initiator_leader':
|
||||
$leaderId = $this->getLeaderIdByUserId($instance->initiator_id);
|
||||
if ($leaderId) $approverIds = [$leaderId];
|
||||
break;
|
||||
case 'field_user':
|
||||
if (isset($formData[$approverConfig['value']])) {
|
||||
$approverIds = [(int)$formData[$approverConfig['value']]];
|
||||
}
|
||||
break;
|
||||
case 'dept_head':
|
||||
$approverIds = $this->getDeptHeadId($approverConfig['value']);
|
||||
if ($approverIds) $approverIds = [$approverIds];
|
||||
break;
|
||||
default:
|
||||
throw new BusinessException("不支持的审批人类型: {$approverConfig['type']}");
|
||||
}
|
||||
|
||||
$resolved = array_merge($resolved, $approverIds);
|
||||
}
|
||||
|
||||
return array_unique(array_filter($resolved));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知抄送人
|
||||
*/
|
||||
private function notifyCCs(array $step, object $instance, string $action = 'pending')
|
||||
{
|
||||
$ccConfig = $step['cc'] ?? [];
|
||||
$ccUserIds = [];
|
||||
$formData = json_decode($instance->form_data ?? '{}', true);
|
||||
|
||||
foreach ($ccConfig as $cc) {
|
||||
switch ($cc['type']) {
|
||||
case 'role':
|
||||
$ccUserIds = array_merge($ccUserIds, $this->getUserIdsByRole($cc['value']));
|
||||
break;
|
||||
case 'user':
|
||||
$ccUserIds[] = (int)$cc['value'];
|
||||
break;
|
||||
case 'initiator_leader':
|
||||
$leaderId = $this->getLeaderIdByUserId($instance->initiator_id);
|
||||
if ($leaderId) $ccUserIds[] = $leaderId;
|
||||
break;
|
||||
case 'field_user':
|
||||
if (isset($formData[$cc['value']])) {
|
||||
$ccUserIds[] = (int)$formData[$cc['value']];
|
||||
}
|
||||
break;
|
||||
case 'dept_head':
|
||||
$deptHeadId = $this->getDeptHeadId($cc['value']);
|
||||
if ($deptHeadId) $ccUserIds[] = $deptHeadId;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$ccUserIds = array_unique(array_filter($ccUserIds));
|
||||
|
||||
if (!empty($ccUserIds)) {
|
||||
$this->sendNotification($ccUserIds, $instance, $action, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估条件
|
||||
*/
|
||||
private function evaluateCondition(?string $condition, array $formData): bool
|
||||
{
|
||||
if (!$condition) return true;
|
||||
|
||||
$pattern = '/^(\w+)\s*(==|!=|>|<|>=|<=)\s*(.+)$/';
|
||||
if (!preg_match($pattern, $condition, $matches)) {
|
||||
throw new BusinessException("条件格式错误: {$condition}");
|
||||
}
|
||||
|
||||
$field = $matches[1];
|
||||
$op = $matches[2];
|
||||
$value = trim($matches[3], "\"'");
|
||||
|
||||
$actualValue = $formData[$field] ?? null;
|
||||
|
||||
if (is_numeric($value) && is_numeric($actualValue)) {
|
||||
$value = (float)$value;
|
||||
$actualValue = (float)$actualValue;
|
||||
}
|
||||
|
||||
switch ($op) {
|
||||
case '==': return $actualValue == $value;
|
||||
case '!=': return $actualValue != $value;
|
||||
case '>': return $actualValue > $value;
|
||||
case '<': $actualValue < $value;
|
||||
case '>=': return $actualValue >= $value;
|
||||
case '<=': return $actualValue <= $value;
|
||||
default: throw new BusinessException("不支持的操作符: {$op}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个有效步骤(考虑 condition)
|
||||
*/
|
||||
private function getNextValidStep(array $steps, array $formData, int $startIndex = 0): ?array
|
||||
{
|
||||
for ($i = $startIndex; $i < count($steps); $i++) {
|
||||
$step = $steps[$i];
|
||||
if (!isset($step['condition']) || $this->evaluateCondition($step['condition'], $formData)) {
|
||||
return $step;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否有权限审批
|
||||
*/
|
||||
private function canUserApproveStep(array $step, int $userId, object $instance): bool
|
||||
{
|
||||
$approvers = $this->resolveApprovers($step, $instance);
|
||||
return in_array($userId, $approvers);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前步骤是否完成
|
||||
*/
|
||||
private function isStepCompleted(int $instanceId, int $stepIndex, string $type): bool
|
||||
{
|
||||
$pendingCount = Db::table('approval_records')
|
||||
->where('instance_id', $instanceId)
|
||||
->where('status', 'pending')
|
||||
->count();
|
||||
|
||||
if ($type === 'any') {
|
||||
return $pendingCount === 0; // 任一通过即可
|
||||
}
|
||||
|
||||
if ($type === 'all' || $type === 'sequential') {
|
||||
return $pendingCount === 0; // 所有人都必须审批
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送通知(你可以替换为你的通知系统)
|
||||
*/
|
||||
private function sendNotification(array $userIds, object $instance, string $action, bool $isCC)
|
||||
{
|
||||
$actionText = [
|
||||
'pending' => '待审批',
|
||||
'approve' => '已通过',
|
||||
'reject' => '已拒绝'
|
||||
][$action] ?? $action;
|
||||
|
||||
$prefix = $isCC ? '[抄送]' : '';
|
||||
$message = "{$prefix}您有一条审批 {$actionText}:流程ID {$instance->id},类型 {$instance->flow_type}";
|
||||
|
||||
// TODO: 调用你的消息系统,如邮件、站内信、企业微信等
|
||||
// 示例:MessageService::send($userIds, $message);
|
||||
echo "通知用户 " . implode(',', $userIds) . ":$message\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户待审批列表
|
||||
* @param int $userId 用户ID
|
||||
* @return array
|
||||
*/
|
||||
public function getPendingApprovals(int $userId): array
|
||||
{
|
||||
// 简化查询:找到用户需要审批的实例ID
|
||||
// 更复杂的逻辑(如并行会签)需要更精细的查询
|
||||
$instanceIds = Db::table('approval_records')
|
||||
->where('approver_id', $userId)
|
||||
->pluck('instance_id')
|
||||
->unique()
|
||||
->toArray();
|
||||
|
||||
if (empty($instanceIds)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Db::table('approval_instances')
|
||||
->whereIn('id', $instanceIds)
|
||||
->where('status', 'processing')
|
||||
->get()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审批历史记录
|
||||
* @param int $instanceId
|
||||
* @return array
|
||||
*/
|
||||
public function getApprovalHistory(int $instanceId): array
|
||||
{
|
||||
return Db::table('approval_records')
|
||||
->where('instance_id', $instanceId)
|
||||
->orderBy('step_index')
|
||||
->orderBy('approved_at')
|
||||
->get()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审批流程图数据 (简化版)
|
||||
* @param int $instanceId
|
||||
* @return array
|
||||
*/
|
||||
public function getFlowDiagramData(int $instanceId): array
|
||||
{
|
||||
$instance = Db::table('approval_instances')->find($instanceId);
|
||||
if (!$instance) return [];
|
||||
|
||||
$flow = Db::table('approval_flows')->where('type', $instance->flow_type)->first();
|
||||
if (!$flow) return [];
|
||||
|
||||
$steps = json_decode($flow->steps, true);
|
||||
$records = Db::table('approval_records')
|
||||
->where('instance_id', $instanceId)
|
||||
->orderBy('step_index')
|
||||
->orderBy('approved_at')
|
||||
->get()
|
||||
->groupBy('step_index');
|
||||
|
||||
$diagramData = [];
|
||||
foreach ($steps as $index => $step) {
|
||||
$status = 'pending';
|
||||
$actions = $records->get($index, collect())->toArray();
|
||||
|
||||
if (!empty($actions)) {
|
||||
$hasReject = collect($actions)->contains('action', 'reject');
|
||||
if ($hasReject) {
|
||||
$status = 'rejected';
|
||||
} else {
|
||||
if ($step['type'] === 'parallel') {
|
||||
// 简化处理
|
||||
$status = 'approved';
|
||||
} else {
|
||||
$status = 'approved';
|
||||
}
|
||||
}
|
||||
} elseif ($index < $instance->current_step) {
|
||||
$status = 'approved';
|
||||
} elseif ($index == $instance->current_step) {
|
||||
$status = 'processing';
|
||||
}
|
||||
|
||||
$diagramData[] = [
|
||||
'index' => $index,
|
||||
'name' => $step['name'],
|
||||
'type' => $step['type'],
|
||||
'status' => $status,
|
||||
'actions' => $actions
|
||||
];
|
||||
}
|
||||
return $diagramData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理超时的审批实例 (定时任务调用)
|
||||
*/
|
||||
public function handleTimeouts()
|
||||
{
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$expiredInstances = Db::table('approval_instances')
|
||||
->where('status', 'processing')
|
||||
->where('deadline_at', '<=', $now)
|
||||
->get();
|
||||
|
||||
foreach ($expiredInstances as $instance) {
|
||||
$flow = Db::table('approval_flows')->where('type', $instance->flow_type)->first();
|
||||
if ($flow && $flow->timeout_action) {
|
||||
$updateData = [
|
||||
'finished_at' => $now,
|
||||
'updated_at' => $now
|
||||
];
|
||||
if ($flow->timeout_action === 'auto_reject') {
|
||||
$updateData['status'] = 'rejected';
|
||||
Db::table('approval_instances')->where('id', $instance->id)->update($updateData);
|
||||
$this->notifyInitiator($instance, 'rejected_timeout');
|
||||
} elseif ($flow->timeout_action === 'auto_approve') {
|
||||
$updateData['status'] = 'approved';
|
||||
Db::table('approval_instances')->where('id', $instance->id)->update($updateData);
|
||||
$this->notifyInitiator($instance, 'approved_timeout');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- 辅助方法 ---
|
||||
|
||||
// private function canUserApproveStep(array $step, int $userId, object $instance): bool
|
||||
// {
|
||||
// $approvers = $this->resolveApprovers($step, $instance);
|
||||
// return in_array($userId, $approvers);
|
||||
// }
|
||||
|
||||
// private function resolveApprovers(array $step, object $instance): array
|
||||
// {
|
||||
// $resolved = [];
|
||||
// foreach ($step['approvers'] as $approver) {
|
||||
// if ($approver['type'] === 'role') {
|
||||
// // 示例:根据角色查找用户ID,你需要替换为实际逻辑
|
||||
// if ($approver['value'] === 'admin') {
|
||||
// $resolved[] = 1; // 假设 admin 角色的用户ID是1
|
||||
// } elseif ($approver['value'] === 'manager') {
|
||||
// $resolved[] = 2; $resolved[] = 3; // 假设有多个manager
|
||||
// }
|
||||
// } elseif ($approver['type'] === 'user') {
|
||||
// $resolved[] = (int)$approver['value'];
|
||||
// } elseif ($approver['type'] === 'initiator_leader') {
|
||||
// // 示例:获取发起人的领导
|
||||
// $resolved[] = 4; // 假设领导ID是4
|
||||
// }
|
||||
// }
|
||||
// return array_unique($resolved);
|
||||
// }
|
||||
|
||||
// private function resolveApprovers(array $step, object $instance): array
|
||||
// {
|
||||
// $resolved = [];
|
||||
|
||||
// foreach ($step['approvers'] as $approverConfig) {
|
||||
// $approverIds = [];
|
||||
|
||||
// switch ($approverConfig['type']) {
|
||||
// // 1. 按角色查找
|
||||
// case 'role':
|
||||
// $roleCode = $approverConfig['value'];
|
||||
// // 所有拥有该角色的用户ID
|
||||
// $approverIds = $this->getUserIdsByRole($roleCode);
|
||||
// break;
|
||||
|
||||
// // 2. 按具体用户ID
|
||||
// case 'user':
|
||||
// $approverIds = [(int)$approverConfig['value']];
|
||||
// break;
|
||||
|
||||
// // 3. 按发起人的直属领导 (业务一般是组长)
|
||||
// case 'initiator_leader':
|
||||
// // 用户表中 report_to 字段
|
||||
// $approverIds = $this->getLeaderIdByUserId($instance->initiator_id);
|
||||
// if ($approverIds) {
|
||||
// $approverIds = [$approverIds];
|
||||
// } else {
|
||||
// $approverIds = []; // 没有领导,跳过
|
||||
// }
|
||||
// break;
|
||||
|
||||
// // 4. 按业务字段关联的用户 (高级功能)
|
||||
// case 'field_user':
|
||||
// $fieldName = $approverConfig['value']; // 如 'project_manager_id'
|
||||
// $formData = json_decode($instance->form_data, true);
|
||||
// if (isset($formData[$fieldName])) {
|
||||
// $approverIds = [(int)$formData[$fieldName]];
|
||||
// } else {
|
||||
// $approverIds = [];
|
||||
// }
|
||||
// break;
|
||||
|
||||
// // 5. 按组织架构层级 (如发起人所在部门的负责人)
|
||||
// case 'dept_head':
|
||||
// $deptId = $approverConfig['value']; // 也可以从 instance 或 formData 中获取
|
||||
// $approverIds = $this->getDeptHeadId($deptId);
|
||||
// if ($approverIds) {
|
||||
// $approverIds = [$approverIds];
|
||||
// } else {
|
||||
// $approverIds = [];
|
||||
// }
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// throw new BusinessException("不支持的审批人类型: {$approverConfig['type']}");
|
||||
// }
|
||||
|
||||
// $resolved = array_merge($resolved, $approverIds);
|
||||
// }
|
||||
|
||||
// return array_unique($resolved);
|
||||
// }
|
||||
|
||||
// 角色层
|
||||
private function getUserIdsByRole(string $roleCode): array
|
||||
{
|
||||
// user_roles 表和 roles 表
|
||||
return Db::table('user_roles as ur')
|
||||
->join('roles as r', 'ur.role_id', '=', 'r.id')
|
||||
->where('r.code', $roleCode) // 假设 roles 表有 code 字段
|
||||
->pluck('ur.user_id')
|
||||
->toArray();
|
||||
}
|
||||
|
||||
// 领导层
|
||||
private function getLeaderIdByUserId(int $userId): ?int
|
||||
{
|
||||
// users 表 report_to 字段
|
||||
return Db::table('user')->where('id', $userId)->value('report_to');
|
||||
}
|
||||
|
||||
// 组织架构层
|
||||
private function getDeptHeadId(int $deptId): ?int
|
||||
{
|
||||
// departments 表 head_user_id 字段(部门逻辑暂时不用,根据后续业务实际情况开发)
|
||||
return Db::table('departments')->where('id', $deptId)->value('head_user_id');
|
||||
}
|
||||
|
||||
private function calculateNextStepIndex(int $instanceId, int $currentStepIndex, array $currentStep): int
|
||||
{
|
||||
// 对于 sequential 和 any,单次 approve 即进入下一步
|
||||
if ($currentStep['type'] === 'sequential' || $currentStep['type'] === 'any') {
|
||||
return $currentStepIndex + 1;
|
||||
} elseif ($currentStep['type'] === 'parallel') {
|
||||
// 对于并行会签,需要检查是否所有审批人都已 approve
|
||||
// 这里简化处理,实际需要精确计算
|
||||
// 假设只要有一次 approve 就算完成(不准确,仅为示例)
|
||||
// 正确做法是查询所有 approvers 是否都 approve 了
|
||||
return $currentStepIndex + 1;
|
||||
}
|
||||
return $currentStepIndex + 1;
|
||||
}
|
||||
|
||||
private function notifyNextApprovers(int $instanceId)
|
||||
{
|
||||
// 实现你的通知逻辑,如发送站内信、邮件、企业微信等
|
||||
// 可以查询 instance_id 对应的当前步骤审批人
|
||||
echo "通知下一个审批人 (Instance ID: {$instanceId})\n";
|
||||
}
|
||||
|
||||
private function notifyInitiator(object $instance, string $result)
|
||||
{
|
||||
// 通知发起人审批结果
|
||||
echo "通知发起人 {$instance->initiator_id} 审批结果: {$result}\n";
|
||||
}
|
||||
|
||||
private function notifyAllApprovers(object $instance, string $status)
|
||||
{
|
||||
// 通知所有相关审批人(如撤回时)
|
||||
echo "通知所有审批人,实例 {$instance->id} 状态变为: {$status}\n";
|
||||
}
|
||||
|
||||
private function notifyCc(int $instanceId)
|
||||
{
|
||||
// 通知抄送人
|
||||
echo "通知抄送人 (Instance ID: {$instanceId})\n";
|
||||
}
|
||||
}
|
||||
@@ -244,10 +244,10 @@
|
||||
<div style="padding-top: 6mm; padding-bottom: 6mm; display: table; margin: 0 0 0 auto;">
|
||||
<div style="display: table-cell; vertical-align: middle;">
|
||||
<span>下单人:</span>
|
||||
<img src="https://mzl.dev.hnxinyouhe.com/01.jpg" style="width: 21mm; height: 12mm; vertical-align: middle;">
|
||||
<img src="<?php echo htmlspecialchars($data['sign_img_url'] ?? ' - '); ?>" style="width: 21mm; height: 12mm; vertical-align: middle;">
|
||||
</div>
|
||||
</div>
|
||||
<div>下单时间:2025-09-08</div>
|
||||
<div>下单时间:<?php echo htmlspecialchars($data['created_at'] ?? ' - '); ?></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -2,20 +2,10 @@
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use app\common\model\InquiryLog;
|
||||
use app\common\model\User;
|
||||
use app\common\model\UserRoles;
|
||||
use app\common\model\UserSystems;
|
||||
use app\common\service\MessageNotificationsService;
|
||||
use app\common\traits\DataPermission;
|
||||
use app\common\utils\email\MailSend;
|
||||
use app\common\utils\scaffold\Generate;
|
||||
use support\Request;
|
||||
use support\Db;
|
||||
use support\Cache;
|
||||
use app\inquiry\service\InquiryLogService;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use support\Redis;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
@@ -79,25 +69,25 @@ class IndexController
|
||||
$options = [
|
||||
'controller' => [
|
||||
'module' => 'admin',
|
||||
'name' => 'approval_flows'
|
||||
'name' => 'approval_instances'
|
||||
],
|
||||
'model' => [
|
||||
'module' => 'admin',
|
||||
'name' => 'approval_flows'
|
||||
'name' => 'approval_instances'
|
||||
],
|
||||
'service' => [
|
||||
'module' => 'admin',
|
||||
'name' => 'approval_flows'
|
||||
'name' => 'approval_instances'
|
||||
],
|
||||
'logic' => [
|
||||
'module' => 'admin',
|
||||
'name' => 'approval_flows'
|
||||
'name' => 'approval_instances'
|
||||
],
|
||||
'validate' => [
|
||||
'module' => 'admin',
|
||||
'name' => 'approval_flows'
|
||||
'name' => 'approval_instances'
|
||||
],
|
||||
'table' => 'approval_flows'
|
||||
'table' => 'approval_instances'
|
||||
];
|
||||
|
||||
$result = (new Generate($options))->doGenerate();
|
||||
@@ -116,9 +106,9 @@ class IndexController
|
||||
$initiatorId = 74;
|
||||
|
||||
$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
||||
// $sp = $appro->start($flowType, $bizType, $bizId, $formData, $initiatorId);
|
||||
$sp = $appro->start($flowType, $bizType, $bizId, $formData, $initiatorId);
|
||||
|
||||
$sp = $appro->approve(1, 1, 'approve');
|
||||
// $sp = $appro->approve(9, 1, 'reject');
|
||||
var_dump($sp);
|
||||
|
||||
return json([
|
||||
|
||||
@@ -298,6 +298,15 @@ Route::group('/admin', function () {
|
||||
Route::any('/update', [app\admin\controller\ApprovalFlowsController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\ApprovalFlowsController::class, 'destroy']);
|
||||
});
|
||||
|
||||
// 审批记录
|
||||
Route::group('/approval/records', function () {
|
||||
Route::any('/list', [app\admin\controller\ApprovalRecordsController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\ApprovalRecordsController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\ApprovalRecordsController::class, 'store']);
|
||||
Route::any('/action', [app\admin\controller\ApprovalRecordsController::class, 'approve']);
|
||||
Route::any('/destroy', [app\admin\controller\ApprovalRecordsController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user