1. Go to this page and download the library: Download mano-code/approval library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mano-code / approval example snippets
/**
* The event to listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
// ...........
\ManoCode\Corp\Events\DingNotify\DefaultEvent::class=>[
\ManoCode\Approval\Listeners\ApprovalEventHandler::class,
],
// ...........
];
namespace YourNameSpace;
use Illuminate\Database\Eloquent\Model;
use ManoCode\Approval\Library\DataSourcesAbstract;
/**
* 采购审批
*/
class PurchaseDataSources extends DataSourcesAbstract
{
/**
* 监听的事件 这里可以自定义事件 或者 created、saved 默认就是 created、saved 默认事件会在model数据操作变更时自动触发
* 如果需要手动提审则需要去掉 默认事件并且 自定义事件
*
* @return string[]
*/
public function getListenEvent(): array
{
return [
'push-process'
];
}
/**
* 流程名称
* @return string
*/
public function getName():string
{
return '采购审批';
}
/**
* 流程描述
* @return string
*/
public function getDescription():string
{
return '采购审批';
}
/**
* 获取数据模型 也就是需要审批的主表模型
* @return string
*/
public function getModel(): string
{
return MemberAccount::class;
}
/**
* 审批模板(自动创建时 审批模板时 使用 可以参考钉钉文档 )
* https://open.dingtalk.com/document/orgapp/create-or-update-approval-templates-new#h2-imr-6km-isq
* @return array[]
*/
public function getFormComponentsStruct(): array
{
return [
[
'componentType'=>'TextField',
'props'=>[
'componentId'=>'order_no',
'label'=>'采购单号',
'// 必填
'disabled'=>false, // 不允许修改
]
],
[
'componentType'=>'TextField',
'props'=>[
'componentId'=>'mobile',
'label'=>'联系电话',
'rn void
*/
public function reject(Model $model): void
{
$model->setAttribute('status',4);
$model->save();
}
/**
* 当发起审批时的回调
* @param Model $model
* @return void
*/
public function wait(Model $model): void
{
$model->setAttribute('status',0);
$model->save();
}
}