签入版本
This commit is contained in:
@@ -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 组件 |
|
||||
|
||||
## 相关文档
|
||||
|
||||
Reference in New Issue
Block a user