From 646ff849dbe8e07a63d81ae86917373cd39ef223 Mon Sep 17 00:00:00 2001
From: autumnal_wind@yeah.net <autumnal_wind@yeah.net>
Date: 星期三, 29 五月 2024 16:12:05 +0800
Subject: [PATCH] feat: 代码生成器优化(前端index.vue和DetailForm.vue模板)
---
hs-modules/hs-generator/src/main/resources/vm/vue/DetailForm.vue.vm | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/hs-modules/hs-generator/src/main/resources/vm/vue/DetailForm.vue.vm b/hs-modules/hs-generator/src/main/resources/vm/vue/DetailForm.vue.vm
index 765cf3c..16777ae 100644
--- a/hs-modules/hs-generator/src/main/resources/vm/vue/DetailForm.vue.vm
+++ b/hs-modules/hs-generator/src/main/resources/vm/vue/DetailForm.vue.vm
@@ -114,8 +114,8 @@
</template>
<script setup name="${BusinessName}" lang="ts">
-import * as ${businessName}Api from '@/api/${moduleName}/${businessName}';
-import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types';
+import * as ${BusinessName}Api from '@/api/${moduleName}/${businessName}';
+import { ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types';
import {useI18n} from "vue-i18n";
defineOptions({ name: '${BusinessName}Form' })
@@ -124,6 +124,9 @@
// const props = defineProps({})
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+// 国际化
+const { t } = useI18n()
+
#if(${dicts} != '')
#set($dictsNoSymbol=$dicts.replace("'", ""))
/** 数据字典 */
@@ -145,9 +148,9 @@
// 表单数据
const formData = ref<${BusinessName}Form>({
#foreach ($column in $columns)
- #if($column.query)
+ #if($column.insert || $column.edit)
#if($column.htmlType != "datetime" || $column.queryType != "BETWEEN")
- $column.javaField: undefined,
+ $column.javaField: '',
#end
#end
#end
@@ -170,14 +173,31 @@
#end
#end
})
-
+/** 当前组件方法 */
+/** 窗体打开事件 */
+const open = async (type: string, id?: number) => {
+ dialog.visible = true
+ dialog.title = t('action.' + type)
+ formType.value = type
+ resetForm()
+ // 修改时,设置数据
+ if (id) {
+ formLoading.value = true
+ try {
+ const res = await ${BusinessName}Api.get${BusinessName}(id);
+ Object.assign(formData.value, res.data);
+ } finally {
+ formLoading.value = false
+ }
+ }
+}
/** 表单重置 */
const resetForm = () => {
formData.value = {
#foreach ($column in $columns)
- #if($column.query)
+ #if($column.insert || $column.edit)
#if($column.htmlType != "datetime" || $column.queryType != "BETWEEN")
- $column.javaField: undefined,
+ $column.javaField: '',
#end
#end
#end
--
Gitblit v1.8.0