CloudGamingAdmin/admin-server/CloudGaming.Api.Admin/wwwroot/code_generation/template/Game/tempClientInfo.cshtml
2024-11-15 02:58:48 +08:00

153 lines
4.7 KiB
Plaintext

@model GenDbTableDto
@{
var className = Model.EntityName;
var tableName = Model.TableName;
var ignores = new string[] {
"Id",
"CreationTime",
"CreatorUserId",
"LastModificationTime",
"LastModifierUserId",
"DeletionTime",
"DeleterUserId",
"IsDeleted",
"id",
"creation_time",
"creator_user_id",
"last_modification_time",
"last_modifier_user_id" ,
"deletion_time",
"deleter_user_id",
"is_deleted",
};
var tableInfos = Model.TableInfos
.Where(w => !ignores.Contains(w.ColumnName))
.OrderBy(w => w.Position)
.ToList()
;
var dateList = Model.TableInfos.Where(w => w.CsType == "DateTime" && (w.ColumnName.Contains("Create") || w.ColumnName.Contains("Update"))).OrderBy(w => w.Position).Select(w => w.ColumnName).ToList();
// var selectTable = Model.TableInfos.Where(it => it.IsTableSelect ?? false).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 "@@/services/apps/@(Model.DataBase)/@(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;
@foreach (var item in tableInfos)
{
if ("Boolean" == item.CsType)
{
<pre>
if (res.data.form.@(item.ColumnName.ToFirstCharConvertLower()) == null)
{
res.data.form.@(item.ColumnName.ToFirstCharConvertLower()) = false;
}
</pre>
}
}
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" :maskClosable="false" :width="900">
<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)
{
if (dateList.Contains(item.ColumnName))
{
continue;
}
var name = item.ColumnName.ToFirstCharConvertLower();
var title = item.DisplayName ?? item.Describe;
title = string.IsNullOrWhiteSpace(title) ? "请设置列信息 " + item.ColumnName : title;
if ("Boolean" == item.CsType)
{
<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-radio-group v-model:value="state.vm.form.@(name)" name="@(name)">
<a-radio :value="false">否</a-radio>
<a-radio :value="true">是</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
continue;
}
<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>