| | |
| | | </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' }) |
| | |
| | | // const props = defineProps({}) |
| | | |
| | | const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
| | | // 国际化 |
| | | const { t } = useI18n() |
| | | |
| | | #if(${dicts} != '') |
| | | #set($dictsNoSymbol=$dicts.replace("'", "")) |
| | | /** 数据字典 */ |
| | |
| | | // 表单数据 |
| | | 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 |
| | |
| | | #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 |