步骤文件示例

    1. <?php
    2. namespace app\steps;
    3. use think\db\Query;
    4. use tpScriptVueCurd\base\model\BaseModel;
    5. use tpScriptVueCurd\base\model\VueCurlModel;
    6. use tpScriptVueCurd\field\DateField;
    7. use tpScriptVueCurd\field\RadioField;
    8. use tpScriptVueCurd\field\StringField;
    9. use tpScriptVueCurd\FieldCollection;
    10. use tpScriptVueCurd\ModelField;
    11. use tpScriptVueCurd\option\FieldStepBase;
    12. use tpScriptVueCurd\option\FieldStepBaseConfig;
    13. use tpScriptVueCurd\option\FieldStepBeforeCheck;
    14. /**
    15. * 项目录入步骤
    16. */
    17. class Input extends FieldStepBase
    18. {
    19. public static function name(): string
    20. {
    21. return 'input';
    22. }
    23. public static function make(): FieldStepBase
    24. {
    25. return new self([
    26. //input输入框
    27. StringField::init('name','项目名称')
    28. ->required(true) //必填
    29. ->listShow(true)//在列表中显示此字段
    30. //单选
    31. ,RadioField::init('type','项目类型')
    32. ->items(['A类项目','B类项目'])//选项
    33. ->required(true) //必填
    34. ->listShow(true)//在列表中显示此字段
    35. //日期选择
    36. ,DateField::init('start_time','项目开始时间')
    37. ->required(true) //必填
    38. ->listShow(true)//在列表中显示此字段
    39. //日期选择
    40. ,DateField::init('end_time','项目结束时间')
    41. ->required(true) //必填
    42. ->listShow(true),
    43. ]);
    44. }
    45. public function config(FieldStepBaseConfig $config): void
    46. {
    47. $config->title='项目信息';
    48. $config->listBtnText='项目信息';
    49. $config->listBtnUrl=url('project/edit')->build();
    50. //更多属性请查看 https://gitee.com/tjztjspz/tp-script-vue-curd/blob/master/src/option/FieldStepBaseConfig.php
    51. }
    52. /**
    53. * 是否可修改编辑
    54. * @param VueCurlModel|null $info
    55. * @param BaseModel|null $baseInfo
    56. * @param FieldCollection|null $fields
    57. * @return bool
    58. */
    59. public function canEdit(VueCurlModel $info = null, BaseModel $baseInfo = null, FieldCollection $fields = null): bool
    60. {
    61. return eqEndStep(self::name(),$info);
    62. }
    63. /**
    64. * 步骤判断,数据的下一步是否为当前步骤
    65. * @return FieldStepBeforeCheck[]|callable[] [stepclass=>FieldStepBeforeCheck::make('',function(BaseModel $info, BaseModel $parentInfo = null, ModelField $field = null){})]
    66. */
    67. protected function beforeCheck(): array
    68. {
    69. return [
    70. ''=>function(BaseModel $info, BaseModel $parentInfo = null, ModelField $field = null){
    71. //key 为 空字符串,表示新增数据是,使用此步骤
    72. return true;
    73. },
    74. Withdrawal::class=>function(BaseModel $info, BaseModel $parentInfo = null, ModelField $field = null){
    75. //表示当前数据是退回时,数据可执行此步骤
    76. return true;
    77. },
    78. ];
    79. }
    80. /**
    81. * 人员是否有执行当前步骤的权限
    82. * @param VueCurlModel|null $info
    83. * @param BaseModel|null $baseInfo
    84. * @param FieldCollection|null $fields
    85. * @return bool
    86. */
    87. protected function auth(VueCurlModel $info = null, BaseModel $baseInfo = null, FieldCollection $fields = null): bool
    88. {
    89. return true;
    90. }
    91. protected function authWhere(Query $query): void
    92. {
    93. // TODO: Implement authWhere() method.
    94. }
    95. }