步骤文件示例
<?php
namespace app\steps;
use think\db\Query;
use tpScriptVueCurd\base\model\BaseModel;
use tpScriptVueCurd\base\model\VueCurlModel;
use tpScriptVueCurd\field\RadioField;
use tpScriptVueCurd\field\TextField;
use tpScriptVueCurd\FieldCollection;
use tpScriptVueCurd\ModelField;
use tpScriptVueCurd\option\FieldStep;
use tpScriptVueCurd\option\FieldStepBase;
use tpScriptVueCurd\option\FieldStepBaseConfig;
use tpScriptVueCurd\option\FieldStepTag;
use tpScriptVueCurd\option\FieldStepBeforeCheck;
/**
* 项目审核步骤
*/
class Check extends FieldStepBase
{
public static function name(): string
{
return 'check';
}
public static function make(): FieldStepBase
{
return new self([
RadioField::init('check_status','审核结果')->required(true)->listShow(false)->items([
['value'=>0,'title'=>'未核实','hide'=>true,'color'=>'#bfbfbf'],
['value'=>1,'title'=>'通过','color'=>'#1890ff'],
['value'=>2,'title'=>'不通过','color'=>'#d48806'],
]),
TextField::init('check_remarks','备注')->required(true)->setDefaultHideFilter(),
]);
}
public function config(FieldStepBaseConfig $config): void
{
$config->title='项目审核';
$config->listBtnText='审核';
$config->listBtnOpenHeight='350px';
$config->listBtnOpenWidth='700px';
$config->listBtnClass='yellow';
$config->listBtnUrl=url('project/check')->build();
}
/**
* 当数据步骤为当前步骤时,对列表中的数据进行处理
* @param VueCurlModel $info
* @param BaseModel|null $baseInfo
* @param FieldCollection $fields
* @param FieldStep $step
*/
public function listRowDo(VueCurlModel $info, ?BaseModel $baseInfo, FieldCollection $fields, FieldStep $step): void
{
parent::listRowDo($info, $baseInfo, $fields, $step);
//当前列表中步骤时执行
switch ((int)$info->check_status){
case 1:
$color='success';
$title='通过';
break;
case 2:
$color='default';
$title='不通过';
break;
default:
$color='error';
$title='未核实';
}
//根据审核结果给 列表中步骤设置标签
$step->setTags([new FieldStepTag($title,$color)]);
//如果审核不通过,在列表步骤旁显示备注信息
if((int)$info->check_status===2){
$step->setRemark($info->check_remarks);
}
}
/**
* 步骤判断,数据的下一步是否为当前步骤
* @return FieldStepBeforeCheck[] [stepclass=>FieldStepBeforeCheck::make('',function(BaseModel $info, BaseModel $parentInfo = null, ModelField $field = null){})]
*/
protected function beforeCheck(): array
{
return [
Input::class=>FieldStepBeforeCheck::make('提交后',function(BaseModel $info, BaseModel $parentInfo = null, ModelField $field = null){
//数据当前步骤是输入时,可执行本步骤
return true;
})
];
}
/**
* 人员是否有执行当前步骤的权限
* @param VueCurlModel|null $info
* @param BaseModel|null $baseInfo
* @param FieldCollection|null $fields
* @return bool
*/
protected function auth(VueCurlModel $info = null, BaseModel $baseInfo = null, FieldCollection $fields = null): bool
{
return true;
}
protected function authWhere(Query $query): void
{
// TODO: Implement authWhere() method.
}
}