This commit is contained in:
umono 2022-12-19 00:47:47 +08:00
parent a9e830801e
commit 4683f71efd
4 changed files with 45 additions and 31 deletions

View File

@ -1,6 +1,13 @@
# yaa-yii2
一个基于Vue3、Yii2的后台框架可快速助你CURD开发。
## 环境要求
- PHP >= 7.3
- Composer >= 2
- Node.js >= 14
## 安装
```shell
@ -14,33 +21,6 @@ cd yaa-yii2 && php yii init
基本使用,呈现数据表格(以用户表)为例:
### php 文件
```php
<?php
namespace app\modules\backend\api\controllers;
use app\modules\backend\api\Controller;
use app\modules\backend\api\models\other\User;
class UserController extends Controller
{
// 数据列表
public function actionIndex()
{
$get = $this->get;
$andWhere = [
['like', 'nickName', $get['nickName'] ?? ''],
['like', 'name', $get['name'] ?? ''],
['like', 'phone', $get['phone'] ?? ''],
];
return User::page()->andWhere($andWhere)->toTableDataArray();
}
// 创建、修改、删除
// ...
}
```
### vue 文件
```vue
<template>
@ -78,5 +58,38 @@ export default defineComponent({
</script>
```
### php 文件
```php
<?php
namespace app\modules\backend\api\controllers;
use app\modules\backend\api\Controller;
use app\modules\backend\api\models\other\User;
class UserController extends Controller
{
// 数据列表
public function actionIndex()
{
$get = $this->get;
$andWhere = [
['like', 'nickName', $get['nickName'] ?? ''],
['like', 'name', $get['name'] ?? ''],
['like', 'phone', $get['phone'] ?? ''],
];
return User::page()->andWhere($andWhere)->toTableDataArray();
}
// 创建、修改、删除
// ...
}
```
效果图如下:
![用户表界面](https://crustipfs.art/ipfs/QmYZwtxKxx72cWGhWVkYsAojjgw1xGpJbsQqmr6iNh2pva?filename=1671367264971.jpg)
## 文档

View File

@ -1,10 +1,10 @@
import { defineComponent, reactive } from "vue";
type SizeTyp = 'tiny' | 'small' | 'medium' | 'large';
type SizeType = 'tiny' | 'small' | 'medium' | 'large';
type BtnTypeStr = 'default' | 'tertiary' | 'primary' | 'info' | 'success' | 'warning' | 'error';
interface BtnType {
size?: SizeTyp | string,
size?: SizeType | string,
emitFunction: string,
text: string | Function | any,
type?:BtnTypeStr| string

View File

@ -25,7 +25,6 @@ const routes: any[] = [
{
path: '',
redirect: '/admin/home'
// component: ()=>import('@/views/Admin/home/Index.vue')
},
]

View File

@ -1,7 +1,9 @@
<template>
<TableData :subHeight="240" :search="search" ref="tables"
@view="openModal({ id: $event.id, isEdit: false }, 'formModal')"
@edit="openModal({ id: $event.id, isEdit: true }, 'formModal')" url="admin/api/user/index" :handle="_handleBtn">
@edit="openModal({ id: $event.id, isEdit: true }, 'formModal')"
url="admin/api/user/index"
:handle="_handleBtn">
<n-input v-model:value="search.nickName" filterable placeholder="用户昵称" />
<n-input v-model:value="search.name" filterable placeholder="姓名" />