签入版本
This commit is contained in:
@@ -107,7 +107,7 @@ $field = [
|
||||
'default' => 0, // 默认值
|
||||
'is_image' => false, // 是否为图片字段
|
||||
'is_rich_text' => false, // 是否为富文本字段
|
||||
'choices' => [ // 选项列表(有值时可生成 ElTag 渲染)
|
||||
'choices' => [ // 选项列表(有值时可生成 Tag 渲染)
|
||||
['value' => 0, 'label' => '正常', 'type' => 'success'],
|
||||
['value' => 1, 'label' => '禁用', 'type' => 'danger'],
|
||||
],
|
||||
@@ -159,28 +159,37 @@ class <?php echo $model_class_name ?>Logic extends BaseLogic
|
||||
|
||||
```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: '<?php echo $primary_key ?>',
|
||||
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) {
|
||||
const map = {
|
||||
customRender({ record }) {
|
||||
const statusMap = {
|
||||
<?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 status = statusMap[record.<?php echo $field['camel_name'] ?>];
|
||||
return h(Tag, { color: status?.color || 'default' }, { default: () => status?.text });
|
||||
},
|
||||
<?php endif; ?>
|
||||
},
|
||||
@@ -221,7 +230,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 导入,含 Tag/Avatar 渲染 |
|
||||
| `querySchemas.ts` | 查询表单配置 | 被 index.vue 导入,含 Select/Input/DatePicker 组件 |
|
||||
|
||||
## 相关文档
|
||||
|
||||
Reference in New Issue
Block a user