autumnal_wind@yeah.net
2024-05-29 646ff849dbe8e07a63d81ae86917373cd39ef223
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