签入版本
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
| `ui/src/views/{app}/{name}/index.vue` | index.vue.tpl | 列表页(含搜索、表格、新增/编辑/详情弹窗、导入导出按钮) |
|
||||
| `ui/src/views/{app}/{name}/edit.vue` | edit.vue.tpl | 编辑弹窗(新增/复用) |
|
||||
| `ui/src/views/{app}/{name}/detail.vue` | detail.vue.tpl | 详情弹窗 |
|
||||
| `ui/src/views/{app}/{name}/columns.ts` | columns.ts.tpl | 表格列配置(含图片 ElAvatar、选项 ElTag、链接等渲染) |
|
||||
| `ui/src/views/{app}/{name}/columns.ts` | columns.ts.tpl | 表格列配置(含图片 AAvatar、选项 ATag、链接等渲染) |
|
||||
| `ui/src/views/{app}/{name}/querySchemas.ts` | querySchemas.ts.tpl | 查询表单配置(按字段类型自动选 Input/Select/InputNumber/DatePicker) |
|
||||
|
||||
### 前端文件(ui2/ 树形模板 — 4 个文件)
|
||||
|
||||
@@ -65,7 +65,7 @@ public function getTableList(): array
|
||||
| 类型 | VARCHAR |
|
||||
| 匹配 | 注释或字段名匹配 `/图片\|封面\|头像\|logo\|icon\|image\|avatar\|photo/i` |
|
||||
|
||||
识别后:`is_image = true`,归入 `file` 字段组,前端用 ElAvatar 渲染。
|
||||
识别后:`is_image = true`,归入 `file` 字段组,前端用 AAvatar(`Avatar`)渲染。
|
||||
|
||||
### 富文本字段
|
||||
|
||||
@@ -103,12 +103,14 @@ public function getTableList(): array
|
||||
|
||||
标签颜色映射(`guessChoiceTagType()`):
|
||||
|
||||
| 选项值 | 标签颜色 | Element Plus type |
|
||||
|--------|---------|-------------------|
|
||||
| 1 | 绿色 | `success` |
|
||||
| 2 | 红色 | `danger` |
|
||||
| 3 | 橙色 | `warning` |
|
||||
| 其他 | 灰色 | `info` |
|
||||
| 选项值 | 标签颜色 | type(`guessChoiceTagType()`) | AntDesign `color`(模板映射) |
|
||||
|--------|---------|-------------------|-------------------|
|
||||
| 1 | 绿色 | `success` | `success` |
|
||||
| 2 | 红色 | `danger` | `error` |
|
||||
| 3 | 橙色 | `warning` | `warning` |
|
||||
| 其他 | 灰色 | `info` | `default` |
|
||||
|
||||
(后端生成 `type`,`columns.ts.tpl` 渲染时映射为 ant-design-vue `Tag` 的 `color`:`danger`→`error`、`info`→`default`。)
|
||||
|
||||
识别后:`choices` 数组非空,自动归入 `eq` 字段组(精确匹配)和 `serialize_maps`(字典映射,编码为 `{模块名}_{字段名}`)。
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ $field = [
|
||||
'in_list' => true, // 是否进列表
|
||||
'filterable' => false, // 是否可筛选
|
||||
'filter_type' => '', // 筛选方式:'精确匹配' / '' / '模糊'
|
||||
'choices' => [ // 选项列表(有值时可生成 ElTag 渲染)
|
||||
'choices' => [ // 选项列表(有值时可生成 ATag 渲染)
|
||||
['value' => 0, 'label' => '正常', 'type' => 'success'],
|
||||
['value' => 1, 'label' => '禁用', 'type' => 'danger'],
|
||||
],
|
||||
@@ -177,28 +177,28 @@ class <?php echo $model_class_name ?>Service extends <?php echo $is_tree ? 'Base
|
||||
|
||||
```typescript
|
||||
import { h } from 'vue';
|
||||
import { ElAvatar, ElTag } from 'element-plus';
|
||||
import { Tag, Avatar } from 'ant-design-vue';
|
||||
|
||||
export const columns = [
|
||||
{ type: 'selection' },
|
||||
{ label: 'ID', prop: 'id', fixed: 'left', width: 50 },
|
||||
{ title: 'ID', dataIndex: 'id', fixed: 'left', width: 50 },
|
||||
<?php foreach ($list_fields as $field): ?>
|
||||
{
|
||||
label: '<?php echo $field['label'] ?>',
|
||||
prop: '<?php echo $field['camel_name'] ?>',
|
||||
title: '<?php echo $field['label'] ?>',
|
||||
dataIndex: '<?php echo $field['camel_name'] ?>',
|
||||
key: '<?php echo $field['camel_name'] ?>',
|
||||
<?php if ($field['is_image']): ?>
|
||||
render(record) {
|
||||
return h(ElAvatar, { size: 48, src: record.row.<?php echo $field['camel_name'] ?> });
|
||||
customRender({ record }) {
|
||||
return h(Avatar, { size: 48, src: record.<?php echo $field['camel_name'] ?>, shape: 'square' });
|
||||
},
|
||||
<?php elseif ($field['choices']): ?>
|
||||
render(record) {
|
||||
customRender({ record }) {
|
||||
const map = {
|
||||
<?php foreach ($field['choices'] as $choice): ?>
|
||||
<?php echo $choice['value'] ?>: { text: '<?php echo $choice['label'] ?>', type: '<?php echo $choice['type'] ?>' },
|
||||
<?php echo $choice['value'] ?>: { text: '<?php echo $choice['label'] ?>', color: '<?php echo ($choice['type'] === 'danger') ? 'error' : (($choice['type'] === 'info') ? 'default' : $choice['type']) ?>' },
|
||||
<?php endforeach; ?>
|
||||
};
|
||||
const s = map[record.row.<?php echo $field['camel_name'] ?>];
|
||||
return h(ElTag, { type: s?.type || 'info' }, { default: () => s?.text });
|
||||
const s = map[record.<?php echo $field['camel_name'] ?>];
|
||||
return h(Tag, { color: s?.color || 'default' }, { default: () => s?.text });
|
||||
},
|
||||
<?php endif; ?>
|
||||
},
|
||||
@@ -240,7 +240,7 @@ export const columns = [
|
||||
| `index.vue` | 列表页 | 导入 columns.ts、querySchemas.ts |
|
||||
| `edit.vue` | 编辑弹窗 | 被 index.vue 动态加载 |
|
||||
| `detail.vue` | 详情弹窗 | 被 index.vue 动态加载 |
|
||||
| `columns.ts` | 表格列配置 | 被 index.vue 导入,含 ElTag/ElAvatar 渲染 |
|
||||
| `columns.ts` | 表格列配置 | 被 index.vue 导入,含 ATag/AAvatar 渲染 |
|
||||
| `querySchemas.ts` | 查询表单配置 | 被 index.vue 导入,含 Select/Input/DatePicker 组件 |
|
||||
|
||||
## 相关文档
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
# GET /api/generator/preview
|
||||
# Content-Type: application/json
|
||||
# Authorization: Bearer <token>
|
||||
curl -X GET http://localhost:8000/api/generator/preview \
|
||||
curl -X GET http://admin.laravel13.antdvue/api/generator/preview \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer <token>" \
|
||||
-d '{
|
||||
|
||||
Reference in New Issue
Block a user