Merge pull request '代码生成器index.vue添加排序 修复代码生成器不生产remark列 代码生成器 editDialog 使用swaggerapi-service和model' (#26) from suncaomei/Admin.NET.Pro:main into main
Reviewed-on: http://101.43.53.74:3000/Admin.NET/Admin.NET.Pro/pulls/26
This commit is contained in:
commit
504878a6fd
@ -3,26 +3,26 @@
|
||||
@{string pkFieldName = LowerFirstLetter(pkField.PropertyName);}
|
||||
<template>
|
||||
<div class="@(@Model.LowerClassName)-container">
|
||||
<el-dialog v-model="isShowDialog" :width="800" draggable="" :close-on-click-modal="false">
|
||||
<el-dialog v-model="state.isShowDialog" :width="800" draggable="" :close-on-click-modal="false">
|
||||
<template #header>
|
||||
<div style="color: #fff">
|
||||
<!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
|
||||
<span>{{ props.title }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-form :model="ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
|
||||
<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
|
||||
<el-row :gutter="35">
|
||||
@foreach (var column in Model.TableField){
|
||||
if(@column.ColumnKey == "True"){
|
||||
@:<el-form-item v-show="false">
|
||||
<el-input v-model="ruleForm.@(@column.LowerPropertyName)" />
|
||||
<el-input v-model="state.ruleForm.@(@column.LowerPropertyName)" />
|
||||
</el-form-item>
|
||||
}else{
|
||||
if (@column.WhetherAddUpdate == "Y"){
|
||||
if(@column.EffectType == "fk"){
|
||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
@:<el-form-item label="@column.ColumnComment" prop="@(@column.LowerPropertyName)">
|
||||
@:<el-select clearable filterable v-model="ruleForm.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
||||
@:<el-select clearable filterable v-model="state.ruleForm.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
||||
@:<el-option v-for="(item,index) in @LowerFirstLetter(@column.FkEntityName)@(@column.PropertyName)DropdownList" :key="index" :value="item.value" :label="item.label" />
|
||||
@:
|
||||
</el-select>
|
||||
@ -39,7 +39,7 @@
|
||||
placeholder="请选择@(column.ColumnComment)"
|
||||
clearable=""
|
||||
class="w100"
|
||||
v-model="ruleForm.@(@column.LowerPropertyName)"
|
||||
v-model="state.ruleForm.@(@column.LowerPropertyName)"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<span>{{ data.name }}</span>
|
||||
@ -53,7 +53,7 @@
|
||||
}else if(@column.EffectType == "Input"){
|
||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
@:<el-form-item label="@column.ColumnComment" prop="@(@column.LowerPropertyName)">
|
||||
@:<el-input v-model="ruleForm.@(@column.LowerPropertyName)" placeholder="请输入@(@column.ColumnComment)" maxlength="@(@column.ColumnLength)" show-word-limit clearable />
|
||||
@:<el-input v-model="state.ruleForm.@(@column.LowerPropertyName)" placeholder="请输入@(@column.ColumnComment)" maxlength="@(@column.ColumnLength)" show-word-limit clearable />
|
||||
@:
|
||||
</el-form-item>
|
||||
@:
|
||||
@ -61,7 +61,7 @@
|
||||
}else if(@column.EffectType == "InputNumber"){
|
||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
@:<el-form-item label="@column.ColumnComment" prop="@(@column.LowerPropertyName)">
|
||||
@:<el-input-number v-model="ruleForm.@(@column.LowerPropertyName)" placeholder="请输入@(@column.ColumnComment)" clearable />
|
||||
@:<el-input-number v-model="state.ruleForm.@(@column.LowerPropertyName)" placeholder="请输入@(@column.ColumnComment)" clearable />
|
||||
@:
|
||||
</el-form-item>
|
||||
@:
|
||||
@ -69,7 +69,7 @@
|
||||
}else if(@column.EffectType == "InputTextArea"){
|
||||
@:<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||
@:<el-form-item label="@column.ColumnComment" prop="@(@column.LowerPropertyName)">
|
||||
@:<el-input v-model="ruleForm.@(@column.LowerPropertyName)" placeholder="请输入@(@column.ColumnComment)" type="textarea" maxlength="@(@column.ColumnLength)" show-word-limit clearable />
|
||||
@:<el-input v-model="state.ruleForm.@(@column.LowerPropertyName)" placeholder="请输入@(@column.ColumnComment)" type="textarea" maxlength="@(@column.ColumnLength)" show-word-limit clearable />
|
||||
@:
|
||||
</el-form-item>
|
||||
@:
|
||||
@ -77,7 +77,7 @@
|
||||
}else if(@column.EffectType == "Select"){
|
||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
@:<el-form-item label="@column.ColumnComment" prop="@(@column.LowerPropertyName)">
|
||||
@:<el-select clearable v-model="ruleForm.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
||||
@:<el-select clearable v-model="state.ruleForm.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
||||
@:<el-option v-for="(item,index) in dl('@(@column.DictTypeCode)')" :key="index" :value="@(@column.NetType.StartsWith("string") ? "item.code" : "Number(item.code)")" :label="`[${item.code}] ${item.value}`"></el-option>
|
||||
@:
|
||||
</el-select>
|
||||
@ -88,7 +88,7 @@
|
||||
}else if(@column.EffectType == "ConstSelector"){
|
||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
@:<el-form-item label="@column.ColumnComment" prop="@(@column.LowerPropertyName)">
|
||||
@:<el-select clearable v-model="ruleForm.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
||||
@:<el-select clearable v-model="state.ruleForm.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
||||
@:<el-option v-for="(item,index) in getConstType('@column.DictTypeCode')" :key="index" :label="item.name" :value="@(@column.NetType.StartsWith("string") ? "item.code" : "Number(item.code)")">{{ item.name }}</el-option>
|
||||
@:
|
||||
</el-select>
|
||||
@ -99,7 +99,7 @@
|
||||
}else if(@column.EffectType == "Switch"){
|
||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
@:<el-form-item label="@column.ColumnComment" prop="@(@column.LowerPropertyName)">
|
||||
@:<el-switch v-model="ruleForm.@(@column.LowerPropertyName)" active-text="是" inactive-text="否" />
|
||||
@:<el-switch v-model="state.ruleForm.@(@column.LowerPropertyName)" active-text="是" inactive-text="否" />
|
||||
@:
|
||||
</el-form-item>
|
||||
@:
|
||||
@ -107,7 +107,7 @@
|
||||
}else if(@column.EffectType == "DatePicker"){
|
||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
@:<el-form-item label="@column.ColumnComment" prop="@(@column.LowerPropertyName)">
|
||||
@:<el-date-picker v-model="ruleForm.@(@column.LowerPropertyName)" type="date" placeholder="@(@column.ColumnComment)" />
|
||||
@:<el-date-picker v-model="state.ruleForm.@(@column.LowerPropertyName)" type="date" placeholder="@(@column.ColumnComment)" />
|
||||
@:
|
||||
</el-form-item>
|
||||
@:
|
||||
@ -120,9 +120,9 @@
|
||||
@::show-file-list="false"
|
||||
@::http-request="upload@(@column.PropertyName)Handle">
|
||||
@:<img
|
||||
@:v-if="ruleForm.@(@column.LowerPropertyName)"
|
||||
@::src="ruleForm.@(@column.LowerPropertyName)"
|
||||
@:@@click="ruleForm.@(@column.LowerPropertyName)=''"
|
||||
@:v-if="state.ruleForm.@(@column.LowerPropertyName)"
|
||||
@::src="state.ruleForm.@(@column.LowerPropertyName)"
|
||||
@:@@click="state.ruleForm.@(@column.LowerPropertyName)=''"
|
||||
@:style="width: 100%; height: 100%; object-fit: contain"/>
|
||||
@:<el-icon v-else><Plus /></el-icon>
|
||||
@:
|
||||
@ -134,7 +134,7 @@
|
||||
}else if(@column.EffectType == "EnumSelector"){
|
||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
@:<el-form-item label="@column.ColumnComment" prop="@(@column.LowerPropertyName)">
|
||||
@:<el-select clearable v-model="ruleForm.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
||||
@:<el-select clearable v-model="state.ruleForm.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
||||
@:<el-option v-for="(item,index) in dl('@(@column.DictTypeCode)')" :key="index" :value="@(@column.NetType.StartsWith("string") ? "item.code" : "Number(item.code)")" :label="`${item.name} (${item.code}) [${item.value}]`"></el-option>
|
||||
@:
|
||||
</el-select>
|
||||
@ -166,9 +166,20 @@
|
||||
}
|
||||
</style>
|
||||
<script lang="ts" setup>
|
||||
import { ref,onMounted } from "vue";
|
||||
import { ref,onMounted, reactive } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import type { FormRules } from "element-plus";
|
||||
|
||||
// 接口函数
|
||||
import { getAPI } from '/@@/utils/axios-utils';
|
||||
|
||||
// 接口
|
||||
import { @(@Model.ClassName)Api } from '/@@/api-services/api';
|
||||
|
||||
// 模型
|
||||
import { Update@(@Model.ClassName)Input } from '/@@/api-services/models';
|
||||
|
||||
|
||||
@if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){
|
||||
@:import { getConstType } from "/@@/utils/constHelper";
|
||||
}
|
||||
@ -184,16 +195,10 @@
|
||||
@if(@Model.TableField.Any(x=>x.EffectType == "Upload")){
|
||||
@:import { Plus } from "@@element-plus/icons-vue";
|
||||
@:import { UploadRequestOptions } from "element-plus";
|
||||
@:import {@string.Join(",",Model.TableField.Where(x=>x.EffectType == "Upload").Select(x=>"upload"+x.PropertyName).ToList())} from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
|
||||
}
|
||||
import { add@(@Model.ClassName), update@(@Model.ClassName), detail@(@Model.ClassName) } from "/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)";
|
||||
@foreach (var column in Model.TableField){
|
||||
if(@column.EffectType == "ApiTreeSelect" && !definedObjects.ContainsKey("import__@(@column.FkEntityName)Tree")){
|
||||
@{definedObjects.Add("import__@(@column.FkEntityName)Tree", 1);}
|
||||
@:import { get@(@column.FkEntityName)Tree } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
|
||||
}
|
||||
if(@column.EffectType == "fk" && @column.WhetherAddUpdate == "Y"){
|
||||
@:import { get@(@column.FkEntityName)@(@column.PropertyName)Dropdown } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
|
||||
}
|
||||
}
|
||||
@if(@Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
|
||||
@ -211,8 +216,11 @@
|
||||
//父级传递来的函数,用于回调
|
||||
const emit = defineEmits(["reloadTable"]);
|
||||
const ruleFormRef = ref();
|
||||
const isShowDialog = ref(false);
|
||||
const ruleForm = ref<any>({});
|
||||
const state = reactive({
|
||||
isShowDialog: false,
|
||||
ruleForm: {} as Update@(@Model.ClassName)Input,
|
||||
});
|
||||
|
||||
//自行添加其他规则
|
||||
const rules = ref<FormRules>({
|
||||
@foreach (var column in Model.TableField){
|
||||
@ -233,36 +241,39 @@
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = async (row: any) => {
|
||||
// ruleForm.value = JSON.parse(JSON.stringify(row));
|
||||
// state.ruleForm = JSON.parse(JSON.stringify(row));
|
||||
// 改用detail获取最新数据来编辑
|
||||
let rowData = JSON.parse(JSON.stringify(row));
|
||||
if (rowData.id)
|
||||
ruleForm.value = (await detail@(@Model.ClassName)(rowData.id)).data.result;
|
||||
//state.ruleForm = (await detail@(@Model.ClassName)(rowData.id)).data.result;
|
||||
state.ruleForm = (await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)DetailGet(rowData.id)).data.result;
|
||||
else
|
||||
ruleForm.value = rowData;
|
||||
isShowDialog.value = true;
|
||||
state.ruleForm = rowData;
|
||||
state.isShowDialog = true;
|
||||
};
|
||||
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
emit("reloadTable");
|
||||
isShowDialog.value = false;
|
||||
state.isShowDialog = false;
|
||||
};
|
||||
|
||||
// 取消
|
||||
const cancel = () => {
|
||||
isShowDialog.value = false;
|
||||
state.isShowDialog = false;
|
||||
};
|
||||
|
||||
// 提交
|
||||
const submit = async () => {
|
||||
ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
|
||||
if (isValid) {
|
||||
let values = ruleForm.value;
|
||||
if (ruleForm.value.@(@pkFieldName) == undefined || ruleForm.value.@(@pkFieldName) == null || ruleForm.value.@(@pkFieldName) == "" || ruleForm.value.@(@pkFieldName) == 0) {
|
||||
await add@(@Model.ClassName)(values);
|
||||
let values = state.ruleForm;
|
||||
if (state.ruleForm.@(@pkFieldName) == undefined || state.ruleForm.@(@pkFieldName) == null || state.ruleForm.@(@pkFieldName) == "" || state.ruleForm.@(@pkFieldName) == 0) {
|
||||
//await add@(@Model.ClassName)(values);
|
||||
await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)AddPost(state.ruleForm);
|
||||
} else {
|
||||
await update@(@Model.ClassName)(values);
|
||||
//await update@(@Model.ClassName)(values);
|
||||
await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)UpdatePost(state.ruleForm);
|
||||
}
|
||||
closeDialog();
|
||||
} else {
|
||||
@ -278,7 +289,7 @@
|
||||
if(@column.EffectType == "fk" && @column.WhetherAddUpdate == "Y"){
|
||||
@:const @LowerFirstLetter(@column.FkEntityName)@(@column.PropertyName)DropdownList = ref<any>([]);
|
||||
@:const get@(@column.FkEntityName)@(@column.PropertyName)DropdownList = async () => {
|
||||
@:let list = await get@(@column.FkEntityName)@(@column.PropertyName)Dropdown();
|
||||
@:let list = await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)@(@column.FkEntityName)@(@column.PropertyName)DropdownGet();
|
||||
@:@LowerFirstLetter(@column.FkEntityName)@(@column.PropertyName)DropdownList.value = list.data.result ?? [];
|
||||
@:};
|
||||
@:get@(@column.FkEntityName)@(@column.PropertyName)DropdownList();
|
||||
@ -291,7 +302,7 @@
|
||||
@{definedObjects.Add("define_get@(@column.FkEntityName)TreeData", 1);}
|
||||
@:const @LowerFirstLetter(@column.FkEntityName)TreeData = ref<any>([]);
|
||||
@:const get@(@column.FkEntityName)TreeData = async () => {
|
||||
@:let list = await get@(@column.FkEntityName)Tree();
|
||||
@:let list = await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)@(@column.FkEntityName)TreeGet();
|
||||
@:@LowerFirstLetter(@column.FkEntityName)TreeData.value = list.data.result ?? [];
|
||||
@:};
|
||||
@:get@(@column.FkEntityName)TreeData();
|
||||
@ -314,8 +325,8 @@
|
||||
if(column.WhetherAddUpdate=="N") continue;
|
||||
if(@column.EffectType == "Upload"){
|
||||
@:const upload@(@column.PropertyName)Handle = async (options: UploadRequestOptions) => {
|
||||
@:const res = await upload@(@column.PropertyName)(options);
|
||||
@:ruleForm.value.@(column.LowerPropertyName) = res.data.result?.url;
|
||||
@:let list = await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)Upload@(@column.FkEntityName)PostForm(options);
|
||||
@:state.ruleForm.@(column.LowerPropertyName) = res.data.result?.url;
|
||||
@:};
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
} else if(@column.EffectType == "InputNumber") {
|
||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<el-form-item label="@column.ColumnComment">
|
||||
<el-input-number v-model="state.queryParams.@(@column.LowerPropertyName)" clearable placeholder="请输入@(@column.ColumnComment)" @@keyup.enter.native="handleQuery(true)" >
|
||||
<el-input-number v-model="state.queryParams.@(@column.LowerPropertyName)" clearable placeholder="请输入@(@column.ColumnComment)" @@keyup.enter.native="handleQuery(true)" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
} else if(@column.EffectType == "fk") {
|
||||
@ -262,29 +262,28 @@ const options = useVxeTable<@(@Model.ClassName)>({
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
|
||||
@foreach (var column in Model.TableField) {
|
||||
var whethersortable =column.WhetherSortable == "Y" ? "sortable: true" : "sortable: false";
|
||||
if(@column.WhetherTable == "Y") {
|
||||
if(@column.EffectType == "Upload" || @column.EffectType == "fk" || @column.EffectType == "ApiTreeSelect" || @column.EffectType == "Switch" || @column.EffectType == "ConstSelector") {
|
||||
if(@column.EffectType == "Upload") {
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' } },
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' }, @whethersortable },
|
||||
} else if(@column.EffectType == "fk") {
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' } },
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' }, @whethersortable },
|
||||
} else if(@column.EffectType == "ApiTreeSelect") {
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' } },
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' }, @whethersortable },
|
||||
} else if(@column.EffectType == "Switch") {
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' } },
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' }, @whethersortable },
|
||||
} else if(@column.EffectType == "ConstSelector") {
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' } },
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' }, @whethersortable },
|
||||
}
|
||||
} else if(@column.EffectType == "Select") {
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' } },
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' }, @whethersortable },
|
||||
} else if(@column.EffectType == "EnumSelector") {
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' } },
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' }, @whethersortable },
|
||||
} else if(@column.EffectType == "DatePicker") {
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' } },
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' }, @whethersortable },
|
||||
} else {
|
||||
if(@column.LowerPropertyName != "remark") {
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip' },
|
||||
}
|
||||
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', @whethersortable},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user