126 lines
3.8 KiB
Plaintext
126 lines
3.8 KiB
Plaintext
@model GenDbTableDto
|
|
@{
|
|
var className = Model.EntityName;
|
|
var tableName = Model.TableName;
|
|
var clientServiceNamespace = Model.ClientServiceNamespace;
|
|
var ignores = new string[] {
|
|
"Id",
|
|
"CreationTime",
|
|
"CreatorUserId",
|
|
"LastModificationTime",
|
|
"LastModifierUserId" ,
|
|
"DeletionTime",
|
|
"CreateAt",
|
|
"UpdateAt",
|
|
"CreateTime",
|
|
"UpdateTime",
|
|
"IsDeleted"
|
|
};
|
|
|
|
var tableInfos = Model.TableInfos
|
|
.Where(w => !ignores.Contains(w.ColumnName))
|
|
.OrderBy(w => (w.OrderById ?? 10))
|
|
.ToList()
|
|
;
|
|
|
|
}
|
|
|
|
<pre>
|
|
<script lang="ts" setup>
|
|
import { reactive, ref } from "vue";
|
|
import { FormInstance } from "ant-design-vue";
|
|
import Tools from "@@/core/utils/Tools";
|
|
import @(className)Service from "@(clientServiceNamespace)/@(className)Service";
|
|
|
|
//定义组件事件
|
|
const props = defineProps<{ onSuccess: () => void }>();
|
|
|
|
const state = reactive({
|
|
vm: {
|
|
id: "",
|
|
form: {} as any,
|
|
},
|
|
visible: false,
|
|
loading: false,
|
|
});
|
|
|
|
//表单实例
|
|
const refForm = ref<FormInstance>();
|
|
|
|
//向父级导出 函数
|
|
defineExpose({
|
|
/**
|
|
* 打开表单初始化
|
|
* @@param key
|
|
*/
|
|
open: (key: string = "") => {
|
|
state.visible = true;
|
|
if (state.visible) {
|
|
state.vm.id = key;
|
|
}
|
|
refForm.value?.resetFields();
|
|
//初始化表单数据
|
|
state.loading = true;
|
|
@(className)Service.findForm(key).then((res) => {
|
|
state.loading = false;
|
|
if (res.code != 200) return;
|
|
state.vm = res.data;
|
|
});
|
|
},
|
|
});
|
|
|
|
/**
|
|
*保存数据
|
|
*/
|
|
function save() {
|
|
refForm.value?.validate().then(async () => {
|
|
try {
|
|
state.loading = true;
|
|
const result = await @(className)Service.saveForm(state.vm.id, state.vm.form);
|
|
state.loading = false;
|
|
if (result.code != 200) return;
|
|
Tools.message.success("操作成功!");
|
|
props.onSuccess();
|
|
state.visible = false;
|
|
} catch (error) {
|
|
state.loading = false;
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<a-modal v-model:open="state.visible" :title="state.vm.id ? '编辑' : '新建'" centered @@ok="state.visible = false" :width="800">
|
|
<template #footer>
|
|
<a-button type="primary" :loading="state.loading" @@click="save()"> 提交</a-button>
|
|
<a-button @@click="state.visible = false">关闭</a-button>
|
|
</template>
|
|
<a-spin :spinning="state.loading">
|
|
<a-form ref="refForm" layout="vertical" :model="state.vm.form">
|
|
<a-row :gutter="[16, 0]">
|
|
|
|
@foreach (var item in tableInfos)
|
|
{
|
|
|
|
var name = item.ColumnName.ToFirstCharConvertLower();
|
|
var title = item.DisplayName ?? item.Describe;
|
|
title = string.IsNullOrWhiteSpace(title) ? "请设置列信息 " + item.ColumnName : title;
|
|
if (name == "tenantId")
|
|
{
|
|
}
|
|
else
|
|
{
|
|
|
|
<a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
|
<a-form-item label="@(title ?? "请设置列信息 > " + item.ColumnName)" name="@(name)" :rules="[{ required: true, message: '请输入', trigger: 'blur' }]">
|
|
<a-input v-model:value="state.vm.form.@(name)" placeholder="请输入" />
|
|
</a-form-item>
|
|
</a-col>
|
|
}
|
|
}
|
|
</a-row>
|
|
</a-form>
|
|
</a-spin>
|
|
</a-modal>
|
|
</template>
|
|
</pre> |