|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div class="p-2">
|
|
|
<el-dialog v-model="dialog.visible" :title="dialog.title" width="600px" :draggable="draggable">
|
|
|
- <el-form ref="formRef" v-loading="formLoading" :model="formData" :rules="formRules" label-width="80px">
|
|
|
+ <el-form ref="formRef" v-loading="formLoading" :model="formData" :rules="formRules" label-width="80px">
|
|
|
#foreach($column in $columns)
|
|
|
#set($field=$column.javaField)
|
|
|
#if(($column.insert || $column.edit) && !$column.pk)
|
|
|
@@ -88,11 +88,7 @@
|
|
|
</el-form-item>
|
|
|
#elseif($column.htmlType == "datetime")
|
|
|
<el-form-item label="${comment}" prop="${field}">
|
|
|
- <el-date-picker clearable
|
|
|
- v-model="form.${field}"
|
|
|
- type="datetime"
|
|
|
- value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
- placeholder="请选择${comment}">
|
|
|
+ <el-date-picker v-model="formData.${field}" clearable type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择${comment}">
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
#elseif($column.htmlType == "textarea")
|
|
|
@@ -118,14 +114,14 @@ 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' })
|
|
|
+defineOptions({ name: '${BusinessName}Form' });
|
|
|
|
|
|
// 接收父组件传入属性
|
|
|
// const props = defineProps({})
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
// 国际化
|
|
|
-const { t } = useI18n()
|
|
|
+const { t } = useI18n();
|
|
|
|
|
|
#if(${dicts} != '')
|
|
|
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
|
|
@@ -172,7 +168,7 @@ const formRules = reactive({
|
|
|
#else
|
|
|
#set($comment=$column.columnComment)
|
|
|
#end
|
|
|
- $column.javaField: [{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }]#if($foreach.count != $columns.size()),#end
|
|
|
+ $column.javaField: [{ required: true, message: '$comment不能为空', trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")'change'#else'blur'#end }]#if($foreach.count != $columns.size()),#end
|
|
|
#end
|
|
|
#end
|
|
|
#end
|
|
|
@@ -181,17 +177,17 @@ const formRules = reactive({
|
|
|
/** 窗体打开事件 */
|
|
|
const open = async (type: string, id?: number) => {
|
|
|
dialog.visible = true;
|
|
|
- dialog.title = t('action.' + type)
|
|
|
- formType.value = type
|
|
|
- resetForm()
|
|
|
+ dialog.title = t('action.' + type);
|
|
|
+ formType.value = type;
|
|
|
+ resetForm();
|
|
|
// 修改时,设置数据
|
|
|
if (id) {
|
|
|
- formLoading.value = true
|
|
|
+ formLoading.value = true;
|
|
|
try {
|
|
|
const res = await ${BusinessName}Api.get${BusinessName}(id);
|
|
|
Object.assign(formData.value, res.data);
|
|
|
} finally {
|
|
|
- formLoading.value = false
|
|
|
+ formLoading.value = false;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -201,11 +197,19 @@ const resetForm = () => {
|
|
|
#foreach ($column in $columns)
|
|
|
#if($column.insert || $column.edit)
|
|
|
#if($column.htmlType != "datetime" || $column.queryType != "BETWEEN")
|
|
|
- $column.javaField: '',
|
|
|
+ #if($column.htmlType == "checkbox")
|
|
|
+ $column.javaField: []#if($foreach.count != $columns.size()),#end
|
|
|
+ #elseif($column.javaType == "String")
|
|
|
+ $column.javaField: ''#if($foreach.count != $columns.size()),#end
|
|
|
+ #elseif($column.javaType == "Integer" || $column.javaType == "Long")
|
|
|
+ $column.javaField: 0#if($foreach.count != $columns.size()),#end
|
|
|
+ #else
|
|
|
+ $column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
|
|
#end
|
|
|
#end
|
|
|
#end
|
|
|
- }
|
|
|
+ #end
|
|
|
+ };
|
|
|
formRef.value?.resetFields();
|
|
|
};
|
|
|
// 传回给父组件的属性与方法
|
|
|
@@ -226,16 +230,16 @@ const submitForm = async () => {
|
|
|
const data = formData.value as unknown as ${BusinessName}Form;
|
|
|
if (formType.value === 'create') {
|
|
|
await ${BusinessName}Api.add${BusinessName}(data);
|
|
|
- proxy?.$modal.msgSuccess("新增成功");
|
|
|
+ proxy?.$modal.msgSuccess('新增成功');
|
|
|
} else {
|
|
|
await ${BusinessName}Api.update${BusinessName}(data);
|
|
|
- proxy?.$modal.msgSuccess("修改成功");
|
|
|
+ proxy?.$modal.msgSuccess('修改成功');
|
|
|
}
|
|
|
dialog.visible = false;
|
|
|
// 发送操作成功的事件
|
|
|
emit('success');
|
|
|
} finally {
|
|
|
- formLoading.value = false;
|
|
|
+ formLoading.value = false;
|
|
|
}
|
|
|
};
|
|
|
|