步骤文件示例
<?php
namespace app\steps;
use think\db\Query;
use tpScriptVueCurd\base\model\BaseModel;
use tpScriptVueCurd\base\model\VueCurlModel;
use tpScriptVueCurd\field\DateField;
use tpScriptVueCurd\field\RadioField;
use tpScriptVueCurd\field\StringField;
use tpScriptVueCurd\FieldCollection;
use tpScriptVueCurd\ModelField;
use tpScriptVueCurd\option\FieldStepBase;
use tpScriptVueCurd\option\FieldStepBaseConfig;
use tpScriptVueCurd\option\FieldStepBeforeCheck;
/**
* 项目录入步骤
*/
class Input extends FieldStepBase
{
public static function name(): string
{
return 'input';
}
public static function make(): FieldStepBase
{
return new self([
//input输入框
StringField::init('name','项目名称')
->required(true) //必填
->listShow(true)//在列表中显示此字段
//单选
,RadioField::init('type','项目类型')
->items(['A类项目','B类项目'])//选项
->required(true) //必填
->listShow(true)//在列表中显示此字段
//日期选择
,DateField::init('start_time','项目开始时间')
->required(true) //必填
->listShow(true)//在列表中显示此字段
//日期选择
,DateField::init('end_time','项目结束时间')
->required(true) //必填
->listShow(true),
]);
}
public function config(FieldStepBaseConfig $config): void
{
$config->title='项目信息';
$config->listBtnText='项目信息';
$config->listBtnUrl=url('project/edit')->build();
//更多属性请查看 https://gitee.com/tjztjspz/tp-script-vue-curd/blob/master/src/option/FieldStepBaseConfig.php
}
/**
* 是否可修改编辑
* @param VueCurlModel|null $info
* @param BaseModel|null $baseInfo
* @param FieldCollection|null $fields
* @return bool
*/
public function canEdit(VueCurlModel $info = null, BaseModel $baseInfo = null, FieldCollection $fields = null): bool
{
return eqEndStep(self::name(),$info);
}
/**
* 步骤判断,数据的下一步是否为当前步骤
* @return FieldStepBeforeCheck[]|callable[] [stepclass=>FieldStepBeforeCheck::make('',function(BaseModel $info, BaseModel $parentInfo = null, ModelField $field = null){})]
*/
protected function beforeCheck(): array
{
return [
''=>function(BaseModel $info, BaseModel $parentInfo = null, ModelField $field = null){
//key 为 空字符串,表示新增数据是,使用此步骤
return true;
},
Withdrawal::class=>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.
}
}