修复模板报错,整理模板

This commit is contained in:
侯炯 2025-07-18 18:14:34 +08:00
parent 4dcad4a403
commit 0c27fb620f
4 changed files with 61 additions and 109 deletions

View File

@ -202,40 +202,33 @@
import { onMounted, reactive, ref } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import { ElMessageBox, ElMessage } from "element-plus"; import { ElMessageBox, ElMessage } from "element-plus";
import { useUserInfo } from '/@@/stores/userInfo'; import { useUserInfo } from '/@@/stores/userInfo';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table'; import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@@/hooks/useVxeTableOptionsHook'; import { useVxeTable } from '/@@/hooks/useVxeTableOptionsHook';
import { Local } from '/@@/utils/storage'; import { Local } from '/@@/utils/storage';
import { auth } from '/@@/utils/authFunction'; import { auth } from '/@@/utils/authFunction';
import EditDialog from '/@@/views/@(@Model.PagePath)/@(@Model.LowerClassName)/component/editDialog.vue';
import ModifyRecord from '/@@/components/table/modifyRecord.vue';
@if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){ @if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){
@:// 日历控件
@:import { formatDate } from '/@@/utils/formatTime'; @:import { formatDate } from '/@@/utils/formatTime';
} }
@if(@Model.PrintType != "off"){ @if(@Model.PrintType != "off"){
@:// 推荐设置操作 width 为 200 @://打印控件
@:import { hiprint } from 'vue-plugin-hiprint'; @:import { hiprint } from 'vue-plugin-hiprint';
@:import { SysPrintApi } from '/@@/api-services/api'; @:import { SysPrintApi } from '/@@/api-monkey/api';
@:import { SysPrint } from '/@@/api-services/models'; @:import { SysPrint } from '/@@/api-monkey/models';
}
// 子窗口
@if(@Model.PrintType != "off") {
@:import PrintDialog from '/@@/views/system/print/component/hiprint/preview.vue'; @:import PrintDialog from '/@@/views/system/print/component/hiprint/preview.vue';
} }
import EditDialog from '/@@/views/@(@Model.PagePath)/@(@Model.LowerClassName)/component/editDialog.vue';
import ModifyRecord from '/@@/components/table/modifyRecord.vue';
@if (@Model.IsApiService) { @if (@Model.IsApiService) {
// 接口函数 @://接口控件
@:import { getAPI } from '/@@/utils/axios-utils'; @:import { getAPI } from '/@@/utils/axios-utils';
// 接口
@:import { @(@Model.ClassName)Api } from '/@@/api-services/api'; @:import { @(@Model.ClassName)Api } from '/@@/api-services/api';
// 模型
@:import { @(@Model.ClassName), @(@Model.ClassName)Input, @(@Model.ClassName)Output } from '/@@/api-services/models'; @:import { @(@Model.ClassName), @(@Model.ClassName)Input, @(@Model.ClassName)Output } from '/@@/api-services/models';
} else { } else {
//下面这个是废弃的
@:import { page@(@Model.ClassName), delete@(@Model.ClassName), get@(@Model.ClassName)TotalSum } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)'; @:import { page@(@Model.ClassName), delete@(@Model.ClassName), get@(@Model.ClassName)TotalSum } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
foreach (var column in Model.QueryWhetherList){ foreach (var column in Model.QueryWhetherList){
if(@column.EffectType == "ForeignKey"){ if(@column.EffectType == "ForeignKey"){
@ -247,24 +240,26 @@ foreach (var column in Model.QueryWhetherList){
} }
} }
// 子窗口对象 //基础变量
const xGrid = ref<VxeGridInstance>(); const xGrid = ref<VxeGridInstance>();
@if(@Model.PrintType != "off") {
@:const printDialogRef = ref<InstanceType<typeof PrintDialog>>();
}
const editDialogRef = ref<InstanceType<typeof EditDialog>>(); const editDialogRef = ref<InstanceType<typeof EditDialog>>();
const userStore = useUserInfo(); const userStore = useUserInfo();
@if(@Model.PrintType != "off") {
@://打印控件
@:const printDialogRef = ref<InstanceType<typeof PrintDialog>>();
}
@if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){ @if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){
@://常量控件
@:const codeToName = userStore.codeToName; @:const codeToName = userStore.codeToName;
} }
@if(@Model.TableField.Any(x=>x.EffectType == "DictSelector") || @Model.TableField.Any(x=>x.EffectType == "EnumSelector")){ @if(@Model.TableField.Any(x=>x.EffectType == "DictSelector") || @Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
@//字典枚举控件
@:const dc = userStore.getDictItemByValue; @:const dc = userStore.getDictItemByValue;
@:const dv = userStore.getDictItemByLabel; @:const dv = userStore.getDictItemByLabel;
@:const dl = userStore.getDictDataByCode; @:const dl = userStore.getDictDataByCode;
} }
// 变量 // 变量赋值
const state = reactive({ const state = reactive({
showAdvanceQueryUI: false, showAdvanceQueryUI: false,
queryParams: { queryParams: {
@ -339,7 +334,7 @@ const checkTableColumnVisible = (tableColumnName: any) => {
} }
} }
@if(@Model.TableField.Any(t => t.ColumnName == "CreateTime") && @Model.TableField.Any(t => t.ColumnName == "UpdateTime") && @Model.TableField.Any(t => t.ColumnName == "CreateUserId")){ @if(@Model.TableField.Any(t => t.ColumnName == "CreateTime") && @Model.TableField.Any(t => t.ColumnName == "UpdateTime") && @Model.TableField.Any(t => t.ColumnName == "CreateUserId")){
@:{ title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } }, @:{ field: 'record', title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
} }
{ field: 'buttons', title: '操作', fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } }, { field: 'buttons', title: '操作', fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } },
], ],
@ -427,6 +422,7 @@ const listhandleQuery= async (qparams: any) => {
if(qparams) state.queryParams=qparams; if(qparams) state.queryParams=qparams;
await handleQuery(true); await handleQuery(true);
}; };
// 重置操作 // 重置操作
const resetQuery = async () => { const resetQuery = async () => {
state.queryParams.searchKey = undefined; state.queryParams.searchKey = undefined;
@ -569,13 +565,3 @@ const listClick = (row: any,column:any) => {
defineExpose({ listhandleQuery }); defineExpose({ listhandleQuery });
</script> </script>
<style lang="scss" scoped>
:deep(.el-input),
:deep(.el-select),
:deep(.el-input-number) {
width: 100%;
}
:deep(.el-slider .el-input-number){
width: auto;
}
</style>

View File

@ -179,9 +179,9 @@
} }
} }
} }
<!-- <template #row_record="{ row }"> <template #row_record="{ row }">
<ModifyRecord :data="row" /> <ModifyRecord :data="row" />
</template> --> </template>
<template #row_buttons="{ row }"> <template #row_buttons="{ row }">
@if(@Model.PrintType != "off") { @if(@Model.PrintType != "off") {
<el-tooltip content="打印" placement="top"> <el-tooltip content="打印" placement="top">
@ -203,43 +203,34 @@
<EditDialog ref="editDialogRef" :title="state.title" @@reloadTable="handleQuery" /> <EditDialog ref="editDialogRef" :title="state.title" @@reloadTable="handleQuery" />
</template> </template>
<script lang="ts" setup name="@(@Model.LowerClassName)list"> <script lang="ts" setup name="@(@Model.LowerClassName)">
import { onMounted, reactive, ref } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import { ElMessageBox, ElMessage } from "element-plus"; import { ElMessageBox, ElMessage } from "element-plus";
import { useUserInfo } from '/@@/stores/userInfo'; import { useUserInfo } from '/@@/stores/userInfo';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table'; import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@@/hooks/useVxeTableOptionsHook'; import { useVxeTable } from '/@@/hooks/useVxeTableOptionsHook';
import { Local } from '/@@/utils/storage'; import { Local } from '/@@/utils/storage';
@if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){
@:import { formatDate } from '/@@/utils/formatTime';
}
@if(@Model.PrintType != "off"){
@:// 推荐设置操作 width 为 200
@:import { hiprint } from 'vue-plugin-hiprint';
@:import { SysPrintApi } from '/@@/api-services/api';
@:import { SysPrint } from '/@@/api-services/models';
}
// 子窗口
@if(@Model.PrintType != "off") {
@:import PrintDialog from '/@@/views/system/print/component/hiprint/preview.vue';
}
import EditDialog from '/@@/views/@(@Model.PagePath)/@(@Model.LowerClassName)/component/editDialog.vue'; import EditDialog from '/@@/views/@(@Model.PagePath)/@(@Model.LowerClassName)/component/editDialog.vue';
import ModifyRecord from '/@@/components/table/modifyRecord.vue'; import ModifyRecord from '/@@/components/table/modifyRecord.vue';
@if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){
@://日期控件
@:import { formatDate } from '/@@/utils/formatTime';
}
@if(@Model.PrintType != "off"){
@:// 推荐设置操作 width 为 200
@:import { hiprint } from 'vue-plugin-hiprint';
@:import { SysPrintApi } from '/@@/api-monkey/api';
@:import { SysPrint } from '/@@/api-monkey/models';
@:import PrintDialog from '/@@/views/system/print/component/hiprint/preview.vue';
}
@if (@Model.IsApiService) { @if (@Model.IsApiService) {
// 接口函数 @:// 接口函数
@:import { getAPI } from '/@@/utils/axios-utils'; @:import { getAPI } from '/@@/utils/axios-utils';
// 接口
@:import { @(@Model.ClassName)Api } from '/@@/api-services/api'; @:import { @(@Model.ClassName)Api } from '/@@/api-services/api';
// 模型
@:import { @(@Model.ClassName), @(@Model.ClassName)Input, @(@Model.ClassName)Output } from '/@@/api-services/models'; @:import { @(@Model.ClassName), @(@Model.ClassName)Input, @(@Model.ClassName)Output } from '/@@/api-services/models';
} else { } else {
@://HJ: 废弃,没有使用和适配
@:import { treelist@(@Model.ClassName), delete@(@Model.ClassName) } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)'; @:import { treelist@(@Model.ClassName), delete@(@Model.ClassName) } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
@:import { @(@Model.ClassName) } from '/@@/api/models/@(@Model.LowerClassName)'; @:import { @(@Model.ClassName) } from '/@@/api/models/@(@Model.LowerClassName)';
foreach (var column in Model.QueryWhetherList){ foreach (var column in Model.QueryWhetherList){
@ -251,15 +242,13 @@ foreach (var column in Model.QueryWhetherList){
} }
} }
} }
// 子窗口对象 // 子窗口对象
const xGrid = ref<VxeGridInstance>(); const xGrid = ref<VxeGridInstance>();
const editDialogRef = ref<InstanceType<typeof EditDialog>>();
const userStore = useUserInfo();
@if(@Model.PrintType != "off") { @if(@Model.PrintType != "off") {
@:const printDialogRef = ref<InstanceType<typeof PrintDialog>>(); @:const printDialogRef = ref<InstanceType<typeof PrintDialog>>();
} }
const editDialogRef = ref<InstanceType<typeof EditDialog>>();
const userStore = useUserInfo();
@if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){ @if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){
@:const codeToName = userStore.codeToName; @:const codeToName = userStore.codeToName;
} }
@ -269,7 +258,7 @@ const userStore = useUserInfo();
@:const dl = userStore.getDictDataByCode; @:const dl = userStore.getDictDataByCode;
} }
// 变量 // 变量初始化
const state = reactive({ const state = reactive({
showAdvanceQueryUI: false, showAdvanceQueryUI: false,
treeData: [] as Array<@(@Model.ClassName)>, // 树所有数据 treeData: [] as Array<@(@Model.ClassName)>, // 树所有数据
@ -343,9 +332,9 @@ const checkTableColumnVisible = (tableColumnName: any) => {
} }
} }
@if(@Model.TableField.Any(t => t.ColumnName == "CreateTime") && @Model.TableField.Any(t => t.ColumnName == "UpdateTime") && @Model.TableField.Any(t => t.ColumnName == "CreateUserId")){ @if(@Model.TableField.Any(t => t.ColumnName == "CreateTime") && @Model.TableField.Any(t => t.ColumnName == "UpdateTime") && @Model.TableField.Any(t => t.ColumnName == "CreateUserId")){
@:{ title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } }, @:{ field: 'record',title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
} }
{ title: '操作', fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } }, { field: 'buttons',title: '操作', fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } },
], ],
}, },
// vxeGrid配置参数(此处可覆写任何参数)参考vxe-table官方文档 // vxeGrid配置参数(此处可覆写任何参数)参考vxe-table官方文档
@ -393,12 +382,14 @@ const handleQuery = async (updateTree: boolean = false) => {
options.loading = false; options.loading = false;
// 是否更新左侧树 // 是否更新左侧树
if (updateTree == true) { if (updateTree == true) {
emits('list-reload'); //HJ 暂无该功能 emits('list-reload');
} }
// 若无选择节点并且查询条件为空时,更新编辑页面机构列表树 // 若无选择节点并且查询条件为空时,更新编辑页面机构列表树
if (state.queryParams.id == 0 && state.queryParams.name == undefined && state.queryParams.code == undefined && state.queryParams.type == undefined && updateTree == false) if (state.queryParams.id == 0 && state.queryParams.name == undefined && state.queryParams.code == undefined && state.queryParams.type == undefined && updateTree == false)
state.treeData = res.data.result ?? []; state.treeData = res.data.result ?? [];
}; };
// 列表点击事件
const listhandleQuery= async (qparams: any,key:string,val:any) => { const listhandleQuery= async (qparams: any,key:string,val:any) => {
console.log('listhandleQuery--', JSON.stringify(qparams)); console.log('listhandleQuery--', JSON.stringify(qparams));
state.key=key; state.key=key;
@ -406,6 +397,7 @@ const listhandleQuery= async (qparams: any,key:string,val:any) => {
if(qparams) state.queryParams=qparams; if(qparams) state.queryParams=qparams;
await handleQuery(true); await handleQuery(true);
}; };
// 重置操作 // 重置操作
const resetQuery = async () => { const resetQuery = async () => {
state.queryParams.searchKey = undefined; state.queryParams.searchKey = undefined;
@ -483,6 +475,7 @@ const handleDelete = (row: any) => {
}) })
.catch(() => {}); .catch(() => {});
}; };
// 表格事件 // 表格事件
@if (@Model.IsApiService) { @if (@Model.IsApiService) {
@:const gridEvents: VxeGridListeners<@(@Model.ClassName)> = { @:const gridEvents: VxeGridListeners<@(@Model.ClassName)> = {
@ -537,6 +530,7 @@ const handleDelete = (row: any) => {
@:get@(@column.FkEntityName)TreeData(); @:get@(@column.FkEntityName)TreeData();
} }
} }
// 全部展开 // 全部展开
const handleExpand = () => { const handleExpand = () => {
xGrid.value?.setAllTreeExpand(true); xGrid.value?.setAllTreeExpand(true);
@ -546,22 +540,13 @@ const handleExpand = () => {
const handleFold = () => { const handleFold = () => {
xGrid.value?.clearTreeExpand(); xGrid.value?.clearTreeExpand();
}; };
// 与父组件的交互逻辑 // 与父组件的交互逻辑
const emits = defineEmits(['list-click']); const emits = defineEmits(['list-click']);
const listClick = (row: any,column:any) => { const listClick = (row: any,column:any) => {
emits('list-click', row,column); emits('list-click', row,column);
}; };
// 将属性或者函数暴露给父组件 // 将属性或者函数暴露给父组件
defineExpose({ listhandleQuery }); defineExpose({ listhandleQuery });
</script> </script>
<style lang="scss" scoped>
:deep(.el-input),
:deep(.el-select),
:deep(.el-input-number) {
width: 100%;
}
:deep(.el-slider .el-input-number){
width: auto;
}
</style>

View File

@ -134,7 +134,7 @@
@::src="state.ruleForm.@(@column.LowerPropertyName)" @::src="state.ruleForm.@(@column.LowerPropertyName)"
@:@@click="state.ruleForm.@(@column.LowerPropertyName)=''" @:@@click="state.ruleForm.@(@column.LowerPropertyName)=''"
@:style="width: 100%; height: 100%; object-fit: contain"/> @:style="width: 100%; height: 100%; object-fit: contain"/>
@:<el-icon v-else><Plus /></el-icon> @:<el-icon v-else></el-icon>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -170,35 +170,25 @@
</div> </div>
</template> </template>
<style lang="scss" scoped> <script lang="ts" setup name="@(@Model.LowerClassName)">
:deep(.el-select),
:deep(.el-input-number) {
width: 100%;
}
:deep(.el-slider .el-input-number){
width: auto;
}
</style>
<script lang="ts" setup>
import { ref,onMounted, reactive } from "vue"; import { ref,onMounted, reactive } from "vue";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import type { FormRules } from "element-plus"; import type { FormRules } from "element-plus";
import { useUserInfo } from '/@@/stores/userInfo'; import { useUserInfo } from '/@@/stores/userInfo';
//HJ:添加富文本插件
@if(@Model.TableField.Any(x=>x.EffectType == "RichTextEditor")){ @if(@Model.TableField.Any(x=>x.EffectType == "RichTextEditor")){
@://HJ:添加富文本插件
@:import Editor from '/@@/components/editor/index.vue'; @:import Editor from '/@@/components/editor/index.vue';
} }
@if (@Model.IsApiService) { @if (@Model.IsApiService) {
// 接口函数 @://接口控件
@:import { getAPI } from '/@@/utils/axios-utils'; @:import { getAPI } from '/@@/utils/axios-utils';
// 接口
@:import { @(@Model.ClassName)Api } from '/@@/api-services/api'; @:import { @(@Model.ClassName)Api } from '/@@/api-services/api';
// 模型
@:import { Update@(@Model.ClassName)Input } from '/@@/api-services/models'; @:import { Update@(@Model.ClassName)Input } from '/@@/api-services/models';
} else { }
else{
@://HJ:废弃,不要用这个接口 Begin
@:import { @:import {
@if(Model.RemoteVerify){ @if(Model.RemoteVerify){
@:exists@(RemoteField), @:exists@(RemoteField),
@ -212,14 +202,16 @@ import { useUserInfo } from '/@@/stores/userInfo';
@:add@(@Model.ClassName), @:add@(@Model.ClassName),
@:update@(@Model.ClassName), @:update@(@Model.ClassName),
@:detail@(@Model.ClassName) } from "/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)"; @:detail@(@Model.ClassName) } from "/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)";
if(@Model.TableField.Any(x=>x.EffectType == "Upload")){ if(@Model.TableField.Any(x=>x.EffectType == "Upload")){
@:import { Plus } from "@@element-plus/icons-vue"; @:import { Plus } from "@@element-plus/icons-vue";
@:import { UploadRequestOptions } from "element-plus"; @: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 { @string.Join(",",Model.TableField.Where(x=>x.EffectType == "Upload").Select(x=>"upload"+x.PropertyName).ToList()) } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
} }
@://HJ:废弃,不要用这个接口 END
} }
@if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){ @if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){
@://日期控件
@:import { formatDate } from '/@@/utils/formatTime'; @:import { formatDate } from '/@@/utils/formatTime';
} }
@foreach (var column in Model.TableField){ @foreach (var column in Model.TableField){
@ -228,6 +220,7 @@ if(@column.EffectType == "ApiTreeSelector" && !definedObjects.ContainsKey("impor
} }
} }
@if(@Model.TableField.Any(x=>x.EffectType == "EnumSelector")){ @if(@Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
@://枚举控件
@:import { SysEnumApi } from '/@@/api-services/api'; @:import { SysEnumApi } from '/@@/api-services/api';
} }

View File

@ -25,10 +25,9 @@
<script lang="ts" setup name="@(@Model.LowerClassName)"> <script lang="ts" setup name="@(@Model.LowerClassName)">
import { onMounted, reactive, ref } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import { ElMessageBox, ElMessage } from "element-plus";
import IndexList from '/@@/views/@(@Model.PagePath)/@(@Model.LowerClassName)/component/@(@Model.LowerClassName)List.vue'; import IndexList from '/@@/views/@(@Model.PagePath)/@(@Model.LowerClassName)/component/@(@Model.LowerClassName)List.vue';
const indexListRef = ref<InstanceType<typeof IndexList>>(); const indexListRef = ref<InstanceType<typeof IndexList>>();
// 变量 // 变量初始化
const state = reactive({ const state = reactive({
queryParams: { queryParams: {
searchKey: undefined, searchKey: undefined,
@ -39,10 +38,9 @@ const state = reactive({
} }
} }
}); });
// 页面初始化,列表控件初始化不请求数据,这里要请求一下
// 页面初始化
onMounted(() => { onMounted(() => {
indexListRef.value?.listhandleQuery(state.queryParams);//列表控件初始化不请求数据,这里要请求一下 indexListRef.value?.listhandleQuery(state.queryParams);
}); });
// 主表List组件点击 // 主表List组件点击
const handleIndexChange = async (row: any,column: any) => { const handleIndexChange = async (row: any,column: any) => {
@ -51,13 +49,3 @@ const handleIndexChange = async (row: any,column: any) => {
}; };
</script> </script>
<style lang="scss" scoped>
:deep(.el-input),
:deep(.el-select),
:deep(.el-input-number) {
width: 100%;
}
:deep(.el-slider .el-input-number){
width: auto;
}
</style>