mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-20 20:39:55 +00:00
refactor(module_generator): 统一使用column_name替换python_field字段名
修改模板文件中的字段引用,从python_field改为column_name以保持命名一致性
This commit is contained in:
@@ -107,12 +107,12 @@ export interface {{ class_name }}PageQuery extends PageQuery {
|
|||||||
end_time?: string;
|
end_time?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 列表查询结果
|
// 列表展示项
|
||||||
export interface {{ class_name }}Table {
|
export interface {{ class_name }}Table {
|
||||||
index?: number;
|
index?: number;
|
||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{{ column.python_field }}?: {{
|
{{ column.column_name }}?: {{
|
||||||
'boolean' if ('status' in (column.python_field|lower)) or (column.html_type == 'radio')
|
'boolean' if ('status' in (column.column_name|lower)) or (column.html_type == 'radio')
|
||||||
else 'number' if column.is_pk == 1
|
else 'number' if column.is_pk == 1
|
||||||
else 'string'
|
else 'string'
|
||||||
}};
|
}};
|
||||||
@@ -123,9 +123,9 @@ export interface {{ class_name }}Table {
|
|||||||
// 新增/修改/详情表单参数
|
// 新增/修改/详情表单参数
|
||||||
export interface {{ class_name }}Form {
|
export interface {{ class_name }}Form {
|
||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{% if (column.is_insert == 1 or column.is_edit == 1) and column.python_field not in ['creatorId', 'createdAt', 'updatedAt'] %}
|
{% if (column.is_insert == 1 or column.is_edit == 1) and column.column_name not in ['creator_id', 'created_at', 'updated_at'] %}
|
||||||
{{ column.python_field }}?: {{
|
{{ column.column_name }}?: {{
|
||||||
'boolean' if ('status' in (column.python_field|lower)) or (column.html_type == 'radio')
|
'boolean' if ('status' in (column.column_name|lower)) or (column.html_type == 'radio')
|
||||||
else 'number' if column.is_pk == 1
|
else 'number' if column.is_pk == 1
|
||||||
else 'string'
|
else 'string'
|
||||||
}};
|
}};
|
||||||
|
|||||||
@@ -10,24 +10,24 @@
|
|||||||
{% set parentheseIndex = column_comment.find("(") %}
|
{% set parentheseIndex = column_comment.find("(") %}
|
||||||
{% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %}
|
{% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %}
|
||||||
{% if column.html_type == "input" %}
|
{% if column.html_type == "input" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}">
|
||||||
<el-input v-model="queryFormData.{{ column.python_field }}" placeholder="请输入{{ comment }}" clearable />
|
<el-input v-model="queryFormData.{{ column.column_name }}" placeholder="请输入{{ comment }}" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif (column.html_type == "select" or column.html_type == "radio") and dict_type != "" %}
|
{% elif (column.html_type == "select" or column.html_type == "radio") and dict_type != "" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}">
|
||||||
<el-select v-model="queryFormData.{{ column.python_field }}" placeholder="请选择{{ comment }}" style="width: 180px" clearable>
|
<el-select v-model="queryFormData.{{ column.column_name }}" placeholder="请选择{{ comment }}" style="width: 180px" clearable>
|
||||||
<el-option v-for="dict in dictStore.getDictArray('{{ dict_type }}')" :key="dict.dict_value" :label="dict.dict_label" :value="dict.dict_value" />
|
<el-option v-for="dict in dictStore.getDictArray('{{ dict_type }}')" :key="dict.dict_value" :label="dict.dict_label" :value="dict.dict_value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif (column.html_type == "select" or column.html_type == "radio") and dict_type %}
|
{% elif (column.html_type == "select" or column.html_type == "radio") and dict_type %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}">
|
||||||
<el-select v-model="queryFormData.{{ column.python_field }}" placeholder="请选择{{ comment }}" clearable>
|
<el-select v-model="queryFormData.{{ column.column_name }}" placeholder="请选择{{ comment }}" clearable>
|
||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif column.html_type == "datetime" and column.query_type != "BETWEEN" %}
|
{% elif column.html_type == "datetime" and column.query_type != "BETWEEN" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}">
|
||||||
<el-date-picker v-model="queryFormData.{{ column.python_field }}" type="date" value-format="YYYY-MM-DD" clearable placeholder="请选择{{ comment }}" />
|
<el-date-picker v-model="queryFormData.{{ column.column_name }}" type="date" value-format="YYYY-MM-DD" clearable placeholder="请选择{{ comment }}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{% set python_field = column.python_field %}
|
{% set python_field = column.column_name %}
|
||||||
{% set column_comment = column.column_comment if column.column_comment else '' %}
|
{% set column_comment = column.column_comment if column.column_comment else '' %}
|
||||||
{% set parentheseIndex = column_comment.find("(") %}
|
{% set parentheseIndex = column_comment.find("(") %}
|
||||||
{% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %}
|
{% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %}
|
||||||
@@ -194,7 +194,7 @@
|
|||||||
<template v-if="dialogVisible.type === 'detail'">
|
<template v-if="dialogVisible.type === 'detail'">
|
||||||
<el-descriptions :column="4" border>
|
<el-descriptions :column="4" border>
|
||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{% set python_field = column.python_field %}
|
{% set python_field = column.column_name %}
|
||||||
{% set column_comment = column.column_comment if column.column_comment else '' %}
|
{% set column_comment = column.column_comment if column.column_comment else '' %}
|
||||||
{% set parentheseIndex = column_comment.find("(") %}
|
{% set parentheseIndex = column_comment.find("(") %}
|
||||||
{% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %}
|
{% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %}
|
||||||
@@ -214,7 +214,7 @@
|
|||||||
{% set parentheseIndex = column_comment.find("(") %}
|
{% set parentheseIndex = column_comment.find("(") %}
|
||||||
{% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %}
|
{% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %}
|
||||||
{% set required = 'true' if column.is_nullable == '1' else 'false' %}
|
{% set required = 'true' if column.is_nullable == '1' else 'false' %}
|
||||||
{% if column.python_field == "status" %}
|
{% if column.column_name == "status" %}
|
||||||
<el-form-item label="状态" prop="status" :required="true">
|
<el-form-item label="状态" prop="status" :required="true">
|
||||||
<el-radio-group v-model="formData.status">
|
<el-radio-group v-model="formData.status">
|
||||||
<el-radio :value="true">启用</el-radio>
|
<el-radio :value="true">启用</el-radio>
|
||||||
@@ -222,40 +222,40 @@
|
|||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif column.html_type == "input" %}
|
{% elif column.html_type == "input" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}" :required="{{ required }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}" :required="{{ required }}">
|
||||||
<el-input v-model="formData.{{ column.python_field }}" placeholder="请输入{{ comment }}" />
|
<el-input v-model="formData.{{ column.column_name }}" placeholder="请输入{{ comment }}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif column.html_type == "textarea" %}
|
{% elif column.html_type == "textarea" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}" :required="{{ required }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}" :required="{{ required }}">
|
||||||
<el-input v-model="formData.{{ column.python_field }}" type="textarea" placeholder="请输入{{ comment }}" rows="4" />
|
<el-input v-model="formData.{{ column.column_name }}" type="textarea" placeholder="请输入{{ comment }}" rows="4" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif (column.html_type == "select" or column.html_type == "radio") and dict_type != "" %}
|
{% elif (column.html_type == "select" or column.html_type == "radio") and dict_type != "" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}" :required="{{ required }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}" :required="{{ required }}">
|
||||||
<el-select v-model="formData.{{ column.python_field }}" placeholder="请选择{{ comment }}">
|
<el-select v-model="formData.{{ column.column_name }}" placeholder="请选择{{ comment }}">
|
||||||
<el-option v-for="dict in dictStore.getDictArray('{{ dict_type }}')" :key="dict.dict_value" :label="dict.dict_label" :value="dict.dict_value" />
|
<el-option v-for="dict in dictStore.getDictArray('{{ dict_type }}')" :key="dict.dict_value" :label="dict.dict_label" :value="dict.dict_value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif (column.html_type == "select" or column.html_type == "radio") and dict_type %}
|
{% elif (column.html_type == "select" or column.html_type == "radio") and dict_type %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}" :required="{{ required }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}" :required="{{ required }}">
|
||||||
<el-select v-model="formData.{{ column.python_field }}" placeholder="请选择{{ comment }}">
|
<el-select v-model="formData.{{ column.column_name }}" placeholder="请选择{{ comment }}">
|
||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif column.html_type == "date" %}
|
{% elif column.html_type == "date" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}" :required="{{ required }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}" :required="{{ required }}">
|
||||||
<el-date-picker v-model="formData.{{ column.python_field }}" type="date" value-format="YYYY-MM-DD" placeholder="请选择{{ comment }}" />
|
<el-date-picker v-model="formData.{{ column.column_name }}" type="date" value-format="YYYY-MM-DD" placeholder="请选择{{ comment }}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif column.html_type == "datetime" %}
|
{% elif column.html_type == "datetime" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}" :required="{{ required }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}" :required="{{ required }}">
|
||||||
<el-date-picker v-model="formData.{{ column.python_field }}" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择{{ comment }}" />
|
<el-date-picker v-model="formData.{{ column.column_name }}" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择{{ comment }}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif column.html_type == "checkbox" %}
|
{% elif column.html_type == "checkbox" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}">
|
||||||
<el-checkbox v-model="formData.{{ column.python_field }}">{{ comment }}</el-checkbox>
|
<el-checkbox v-model="formData.{{ column.column_name }}">{{ comment }}</el-checkbox>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% elif column.html_type == "imageUpload" %}
|
{% elif column.html_type == "imageUpload" %}
|
||||||
<el-form-item label="{{ comment }}" prop="{{ column.python_field }}">
|
<el-form-item label="{{ comment }}" prop="{{ column.column_name }}">
|
||||||
<SingleImageUpload v-model="formData.{{ column.python_field }}" />
|
<SingleImageUpload v-model="formData.{{ column.column_name }}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -338,7 +338,7 @@ const tableColumns = ref([
|
|||||||
{ prop: 'index', label: '序号', show: true },
|
{ prop: 'index', label: '序号', show: true },
|
||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{% if column.is_list == 1 %}
|
{% if column.is_list == 1 %}
|
||||||
{ prop: '{{ column.python_field }}', label: '{{ column.column_comment or column.python_field }}', show: true },
|
{ prop: '{{ column.column_name }}', label: '{{ column.column_comment or column.column_name }}', show: true },
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{ prop: 'operation', label: '操作', show: true }
|
{ prop: 'operation', label: '操作', show: true }
|
||||||
@@ -348,7 +348,7 @@ const tableColumns = ref([
|
|||||||
const exportColumns = [
|
const exportColumns = [
|
||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{% if column.is_list == 1 %}
|
{% if column.is_list == 1 %}
|
||||||
{ prop: '{{ column.python_field }}', label: '{{ column.column_comment or column.python_field }}' },
|
{ prop: '{{ column.column_name }}', label: '{{ column.column_comment or column.column_name }}' },
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
@@ -390,7 +390,7 @@ const formData = reactive<{{ class_name }}Form>({
|
|||||||
id: undefined,
|
id: undefined,
|
||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{% if column.is_insert == 1 or column.is_edit == 1 %}
|
{% if column.is_insert == 1 or column.is_edit == 1 %}
|
||||||
{{ column.python_field }}: undefined,
|
{{ column.column_name }}: undefined,
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
})
|
})
|
||||||
@@ -400,7 +400,7 @@ const initialFormData: {{ class_name }}Form = {
|
|||||||
id: undefined,
|
id: undefined,
|
||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{% if column.is_insert == 1 or column.is_edit == 1 %}
|
{% if column.is_insert == 1 or column.is_edit == 1 %}
|
||||||
{{ column.python_field }}: {{ 'true' if column.python_field == 'status' else ('' if column.html_type == 'textarea' else 'undefined') }},
|
{{ column.column_name }}: {{ 'true' if column.column_name == 'status' else ('' if column.html_type == 'textarea' else 'undefined') }},
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
@@ -420,8 +420,8 @@ const rules = reactive({
|
|||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{% if column.is_insert == 1 or column.is_edit == 1 %}
|
{% if column.is_insert == 1 or column.is_edit == 1 %}
|
||||||
{% set required = 'true' if column.is_nullable == 1 else 'false' %}
|
{% set required = 'true' if column.is_nullable == 1 else 'false' %}
|
||||||
{{ column.python_field }}: [
|
{{ column.column_name }}: [
|
||||||
{ required: {{ required }}, message: '请输入{{ column.column_comment or column.python_field }}', trigger: 'blur' },
|
{ required: {{ required }}, message: '请输入{{ column.column_comment or column.column_name }}', trigger: 'blur' },
|
||||||
],
|
],
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -450,7 +450,7 @@ const queryFormData = reactive<{{ class_name }}PageQuery>({
|
|||||||
page_size: 10,
|
page_size: 10,
|
||||||
{% for column in columns %}
|
{% for column in columns %}
|
||||||
{% if column.is_query == 1 and column.query_type != "BETWEEN" %}
|
{% if column.is_query == 1 and column.query_type != "BETWEEN" %}
|
||||||
{{ column.python_field }}: undefined,
|
{{ column.column_name }}: undefined,
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
start_time: undefined,
|
start_time: undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user