步骤文件示例
<?php
namespace app\steps;
use app\admin\model\RegulateProblem;
use app\model\Project;
use think\db\Query;
use tpScriptVueCurd\base\model\BaseModel;
use tpScriptVueCurd\base\model\VueCurlModel;
use tpScriptVueCurd\field\StringField;
use tpScriptVueCurd\FieldCollection;
use tpScriptVueCurd\filter\EmptyFilter;
use tpScriptVueCurd\ModelField;
use tpScriptVueCurd\option\FieldStep;
use tpScriptVueCurd\option\FieldStepBase;
use tpScriptVueCurd\option\FieldStepBaseConfig;
use tpScriptVueCurd\option\FieldStepTag;
use tpScriptVueCurd\option\FieldStepBeforeCheck;
class Withdrawal extends FieldStepBase
{
//列表中点击撤回按钮时,弹出的确认框
protected string $listDirectSubmit='您确定要撤回审核吗?';
public static function name(): string
{
return 'withdrawal';
}
public static function make(): FieldStepBase
{
//撤回的时候不需要用户填写信息,但这里又必须有。所以这里随便放了个字段,不在外面显示出来
return new self([
StringField::init('WithdrawalStepField','')
//此字段不自动生成
->generateColumn(false)
->listShow(false)->editShow(false)->showPage(false)->filter(new EmptyFilter())
]);
}
public function config(FieldStepBaseConfig $config): void
{
$config->title='撤回审核';
$config->listBtnText='撤回审核';
$config->listBtnColor='#722ed1';
$config->listBtnUrl=url('project/withdrawal')->build();
}
public function listRowDo(VueCurlModel $info, ?BaseModel $baseInfo, FieldCollection $fields, FieldStep $step): void
{
parent::listRowDo($info, $baseInfo, $fields, $step);
//当前列表中步骤时执行
$step->setTags([new FieldStepTag('等待重新编辑','cyan')]);
}
/**
* 步骤判断,数据的下一步是否为当前步骤
* @return FieldStepBeforeCheck[] [stepclass=>FieldStepBeforeCheck::make('',function(BaseModel $info, BaseModel $parentInfo = null, ModelField $field = null){})]
*/
protected function beforeCheck(): array
{
return [
//需要审核过后的数据才能撤回
Check::class=>FieldStepBeforeCheck::make('审核通过后',function(BaseModel $info, BaseModel $parentInfo = null, ModelField $field = null){
//如果数据当前步骤是 Check ,数据可执行此步骤
return true;
})
];
}
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.
}
}