tudo 图片库选择
parent
a8a199cbf4
commit
00c0fa5054
19
README.md
19
README.md
|
|
@ -76,6 +76,25 @@ public function update($primaryKey, $data)
|
|||
}
|
||||
```
|
||||
|
||||
### 图片上传(图片库选择)
|
||||
|
||||
```php
|
||||
amis()->ImageControl()->name('avatar')->label(__('users.avatar'))->id('user_avatar');
|
||||
amis()->DialogAction()->label("选择图片库")->dialog(
|
||||
amis()->Dialog()->title('图片库')->body(
|
||||
amis()->ListControl()->name('_library_images')->options([
|
||||
['value' => 'xxx.png', 'image' => 'xxx.png'],
|
||||
])
|
||||
)->onEvent([
|
||||
'confirm' => [
|
||||
'actions' => [
|
||||
['actionType' => 'setValue', 'componentId' => 'user_avatar', 'args' => ['value' => '${_library_images}']],
|
||||
]
|
||||
]
|
||||
])
|
||||
);
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
- 表单验证: 服务端返回 `errors` 错误信息, 未在输入框上显示, 示例文件: `app\Services\UserService.php`, [组件文档](https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%A0%A1%E9%AA%8C)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,17 @@ class Components
|
|||
public function keywordTreeSelectControl($params = [])
|
||||
{
|
||||
$url = amis()->BaseApi()->url(admin_url('api/keywords/tree-list'))->data($params);
|
||||
return amis()->TreeSelectControl()->source($url)->labelField('name')->valueField('id');
|
||||
return amis()->TreeSelectControl()->source($url)->labelField('name')->valueField('id')->showIcon(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典表-下拉框
|
||||
*
|
||||
* @param array $params 查询参数
|
||||
*/
|
||||
public function keywordSelectControl($params = [])
|
||||
{
|
||||
$url = amis()->BaseApi()->url(admin_url('api/keywords/tree-list'))->data($params);
|
||||
return amis()->SelectControl()->source($url)->labelField('name')->valueField('id')->showIcon(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,24 @@ class UserController extends AdminController
|
|||
public function form()
|
||||
{
|
||||
return $this->baseForm()->mode('horizontal')->body([
|
||||
amis()->ImageControl()->name('avatar')->label(__('users.avatar')),
|
||||
amis()->GroupControl()->body([
|
||||
amis()->ImageControl()->name('avatar')->label(__('users.avatar'))->id('user_avatar'),
|
||||
// amis()->DialogAction()->label("选择图片库")->dialog(
|
||||
// amis()->Dialog()->title('图片库')->body(
|
||||
// amis()->ListControl()->name('_library_images')->options([
|
||||
// ['value' => 'http://local.owl-admin-starter.host/storage/images/8U1JI1aJv7ltL8wTywPwxcApRVJOKdDRZi4s0jtd.jpg', 'image' => 'http://local.owl-admin-starter.host/storage/images/8U1JI1aJv7ltL8wTywPwxcApRVJOKdDRZi4s0jtd.jpg'],
|
||||
// ['value' => 'http://local.owl-admin-starter.host/storage/images/eA5fHnnWYMkgot1Xcj5Erfbq3uPgayLzgBzaNVdw.jpg', 'image' => 'http://local.owl-admin-starter.host/storage/images/eA5fHnnWYMkgot1Xcj5Erfbq3uPgayLzgBzaNVdw.jpg'],
|
||||
// ['value' => 'http://local.owl-admin-starter.host/admin-assets/default-avatar.png', 'image' => 'http://local.owl-admin-starter.host/admin-assets/default-avatar.png']
|
||||
// ])
|
||||
// )->onEvent([
|
||||
// 'confirm' => [
|
||||
// 'actions' => [
|
||||
// ['actionType' => 'setValue', 'componentId' => 'user_avatar', 'args' => ['value' => '${_library_images}']],
|
||||
// ]
|
||||
// ]
|
||||
// ])
|
||||
// ),
|
||||
]),
|
||||
amis()->TextControl()->name('phone')->label(__('users.phone'))->required(),
|
||||
amis()->TextControl()->name('name')->label(__('users.name')),
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue