完善前端默认模板文件,确保创建的模板vue文件不会引起错误
This commit is contained in:
parent
bef1955fde
commit
7d2959b708
@ -77,29 +77,40 @@ async def create_pagetypes(payload: Dict[str, Any]):
|
|||||||
frontend_exists = True
|
frontend_exists = True
|
||||||
else:
|
else:
|
||||||
# 创建字段类型组件的模板
|
# 创建字段类型组件的模板
|
||||||
field_content = f'''<script setup lang="ts">
|
field_content = '''<script setup lang="ts">
|
||||||
import {{ computed }} from 'vue'
|
import { computed } from 'vue'
|
||||||
|
import { NInput } from 'naive-ui'
|
||||||
|
|
||||||
const props = defineProps<{{
|
const props = defineProps<{
|
||||||
df: any;
|
df: any;
|
||||||
record: Record<string, any>;
|
record: Record<string, any>;
|
||||||
canEdit: boolean;
|
canEdit: boolean;
|
||||||
ctx: any
|
ctx: any
|
||||||
}}>()
|
}>()
|
||||||
|
|
||||||
// TODO: 实现 {field_type_name} 字段类型逻辑
|
// Label布局:上下结构(vertical) 或 左右结构(horizontal)
|
||||||
|
const labelLayout = computed(() => props.df.label_layout || 'vertical')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="field-{field_type_name.lower()}">
|
<div :class="['field-wrapper', `layout-${labelLayout}`]">
|
||||||
<!-- TODO: 实现 {field_type_name} 界面 -->
|
<label class="field-label">
|
||||||
|
{{ ctx.t(df.label || df.fieldname) }}
|
||||||
|
<span v-if="df.reqd" class="required">*</span>
|
||||||
|
</label>
|
||||||
|
<n-input
|
||||||
|
v-model:value="record[df.fieldname]"
|
||||||
|
type="text"
|
||||||
|
:placeholder="ctx.t(df.fieldname)"
|
||||||
|
:disabled="!canEdit"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.field-{field_type_name.lower()} {{
|
.field-wrapper :deep(.n-input) {
|
||||||
/* TODO: 添加样式 */
|
flex: 1;
|
||||||
}}
|
}
|
||||||
</style>
|
</style>
|
||||||
'''
|
'''
|
||||||
field_file.write_text(field_content, encoding="utf-8")
|
field_file.write_text(field_content, encoding="utf-8")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user