模版第一版本
This commit is contained in:
commit
9622d173b2
@ -1,364 +1,277 @@
|
|||||||
@{
|
@{
|
||||||
var pkField = Model.TableField.Where(c => c.ColumnKey == "True").FirstOrDefault();
|
var pkField = Model.TableField.Where(c => c.ColumnKey == "True").FirstOrDefault();
|
||||||
string pkFieldName = null;
|
string pkFieldName = null;
|
||||||
if(pkField != null && !string.IsNullOrEmpty(pkField.PropertyName))
|
if(pkField != null && !string.IsNullOrEmpty(pkField.PropertyName))
|
||||||
{
|
{
|
||||||
pkFieldName = LowerFirstLetter(pkField.PropertyName);
|
pkFieldName = LowerFirstLetter(pkField.PropertyName);
|
||||||
}
|
}
|
||||||
Dictionary<string, int> definedObjects = new Dictionary<string, int>();
|
Dictionary<string, int> definedObjects = new Dictionary<string, int>();
|
||||||
bool haveLikeCdt = false;
|
bool haveLikeCdt = false;
|
||||||
foreach (var column in Model.TableField){
|
foreach (var column in Model.TableField){
|
||||||
if (column.QueryWhether == "Y" && column.QueryType == "like"){
|
if (column.QueryWhether == "Y" && column.QueryType == "like"){
|
||||||
haveLikeCdt = true;
|
haveLikeCdt = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<template>
|
<template>
|
||||||
<div class="@(@Model.LowerClassName)-container">
|
<div class="@(@Model.LowerEntityName)-container" v-loading="options.loading">
|
||||||
<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
|
<el-card shadow="hover" :body-style="{ padding: '5px 5px 0 5px', display: 'flex', width: '100%', height: '100%', alignItems: 'start' }">
|
||||||
@<el-form :model="queryParams" ref="queryForm" labelWidth="90">
|
<el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true" :label-width="'60px'" style="flex: 1 1 0%">
|
||||||
@<el-row>
|
<el-row :gutter="10">
|
||||||
@if(Model.QueryWhetherList.Count > 0){
|
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||||
@if(haveLikeCdt){
|
<el-form-item label="标题" prop="title">
|
||||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
|
<el-input v-model="state.queryParams.title" placeholder="标题" clearable @@keyup.enter.native="handleQuery(true)" />
|
||||||
@:<el-form-item label="关键字">
|
</el-form-item>
|
||||||
@:<el-input v-model="queryParams.searchKey" clearable="" placeholder="请输入模糊查询关键字"/>
|
</el-col>
|
||||||
@:
|
</el-row>
|
||||||
</el-form-item>
|
</el-form>
|
||||||
</el-col>
|
|
||||||
}
|
<el-divider style="height: calc(100% - 5px); margin: 0 10px" direction="vertical" />
|
||||||
foreach (var column in Model.QueryWhetherList){
|
|
||||||
@:<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUI">
|
<el-row>
|
||||||
if(@column.EffectType == "Input" || @column.EffectType == "InputTextArea"){
|
<el-col>
|
||||||
@:<el-form-item label="@column.ColumnComment">
|
<el-button-group>
|
||||||
@:<el-input v-model="queryParams.@(@column.LowerPropertyName)" clearable="" placeholder="请输入@(@column.ColumnComment)"/>
|
<el-button type="primary" icon="ele-Search" @@click="handleQuery(true)" v-auth="'@(@Model.LowerEntityName):page'" :loading="options.loading"> 查询 </el-button>
|
||||||
@:
|
<el-button icon="ele-Refresh" @@click="resetQuery" :loading="options.loading"> 重置 </el-button>
|
||||||
</el-form-item>
|
</el-button-group>
|
||||||
}else if(@column.EffectType == "InputTextArea"){
|
</el-col>
|
||||||
@:<el-form-item label="@column.ColumnComment">
|
</el-row>
|
||||||
@:<el-input-number v-model="queryParams.@(@column.LowerPropertyName)" clearable="" placeholder="请输入@(@column.ColumnComment)"/>
|
</el-card>
|
||||||
@:
|
|
||||||
</el-form-item>
|
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
|
||||||
}else if(@column.EffectType == "InputNumber"){
|
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" @@sort-change="sortChange">
|
||||||
@:<el-form-item label="@column.ColumnComment">
|
<template #toolbar_buttons>
|
||||||
@:<el-input-number v-model="queryParams.@(@column.LowerPropertyName)" clearable="" placeholder="请输入@(@column.ColumnComment)"/>
|
<el-button type="primary" icon="ele-Plus" @@click="handleAdd" v-auth="'@(@Model.LowerEntityName):add'"> 新增 </el-button>
|
||||||
@:
|
</template>
|
||||||
</el-form-item>
|
<template #toolbar_tools> </template>
|
||||||
}else if(@column.EffectType == "fk"){
|
<template #empty>
|
||||||
@:<el-form-item label="@column.ColumnComment">
|
<el-empty :image-size="200" />
|
||||||
@:<el-select clearable="" filterable="" v-model="queryParams.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
</template>
|
||||||
@:<el-option v-for="(item,index) in @LowerFirstLetter(@column.FkEntityName)@(@column.PropertyName)DropdownList" :key="index" :value="item.value" :label="item.label" />
|
@foreach (var column in Model.TableField) {
|
||||||
@:
|
if(@column.WhetherTable == "Y") {
|
||||||
</el-select>
|
if(@column.EffectType == "EnumSelector") {
|
||||||
@:
|
@:<template #row_@(@column.LowerPropertyName)="{ row }">
|
||||||
</el-form-item>
|
@:<el-tag :type="dv('@(@column.DictTypeCode)', row.@(@column.LowerPropertyName))?.tagType"> {{dv('@(@column.DictTypeCode)', row.@column.LowerPropertyName)?.name}}</el-tag>
|
||||||
}else if(@column.EffectType == "Select"){
|
@:</template>
|
||||||
@:<el-form-item label="@column.ColumnComment">
|
|
||||||
@:<el-select clearable="" v-model="queryParams.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
|
||||||
@:<el-option v-for="(item,index) in dl('@(@column.DictTypeCode)')" :key="index" :value="item.code" :label="`[${item.code}] ${item.value}`" />
|
|
||||||
@:
|
|
||||||
</el-select>
|
|
||||||
@:
|
|
||||||
</el-form-item>
|
|
||||||
}else if(@column.EffectType == "EnumSelector"){
|
|
||||||
@:<el-form-item label="@column.ColumnComment">
|
|
||||||
@:<el-select clearable="" v-model="queryParams.@(@column.LowerPropertyName)" placeholder="请选择@(@column.ColumnComment)">
|
|
||||||
@:<el-option v-for="(item,index) in dl('@(@column.DictTypeCode)')" :key="index" :value="item.value" :label="`${item.name} (${item.code}) [${item.value}] `" />
|
|
||||||
@:
|
|
||||||
</el-select>
|
|
||||||
@:
|
|
||||||
</el-form-item>
|
|
||||||
}else if(@column.EffectType == "DatePicker"){
|
|
||||||
@:<el-form-item label="@column.ColumnComment">
|
|
||||||
if(@column.QueryType == "~"){
|
|
||||||
@:<el-date-picker type="daterange" v-model="queryParams.@(@column.LowerPropertyName)Range" value-format="YYYY-MM-DD HH:mm:ss" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" />
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
@:<el-date-picker placeholder="请选择@(@column.ColumnComment)" value-format="YYYY/MM/DD" v-model="queryParams.@(@column.LowerPropertyName)" />
|
|
||||||
}
|
|
||||||
@:
|
|
||||||
</el-form-item>
|
|
||||||
}
|
|
||||||
@:</el-col>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
|
|
||||||
@<el-form-item @(Model.QueryWhetherList.Count > 0?"":"label-width=\"0px\"")>
|
|
||||||
@<el-button-group style="display: flex; align-items: center;">
|
|
||||||
@<el-button type="primary" icon="ele-Search" @@click="handleQuery" v-auth="'@(@Model.LowerClassName):page'"> @(Model.QueryWhetherList.Count > 0?"查询":"刷新") </el-button>
|
|
||||||
@if(Model.QueryWhetherList.Count > 0){
|
|
||||||
@:<el-button icon="ele-Refresh" @@click="() => queryParams = {}"> 重置 </el-button>
|
|
||||||
@if(haveLikeCdt){
|
|
||||||
@:<el-button icon="ele-ZoomIn" @@click="changeAdvanceQueryUI" v-if="!showAdvanceQueryUI" style="margin-left:5px;"> 高级查询 </el-button>
|
|
||||||
@:<el-button icon="ele-ZoomOut" @@click="changeAdvanceQueryUI" v-if="showAdvanceQueryUI" style="margin-left:5px;"> 隐藏 </el-button>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@<el-button type="primary" style="margin-left:5px;" icon="ele-Plus" @@click="openAdd@(@Model.ClassName)" v-auth="'@(@Model.LowerClassName):add'"> 新增 </el-button>
|
|
||||||
@
|
|
||||||
</el-button-group>
|
|
||||||
</el-form-item>
|
|
||||||
@
|
|
||||||
@</el-col>
|
|
||||||
</el-row>
|
|
||||||
@* 操作区另起一行
|
|
||||||
@:<el-row>
|
|
||||||
@:<el-col>
|
|
||||||
@:<el-button-group style="margin-left:20px;margin-bottom:5px;">
|
|
||||||
@:<el-button type="primary" icon="ele-Plus" @@click="openAdd@(@Model.ClassName)" v-auth="'@(@Model.LowerClassName):add'"> 新增 </el-button>
|
|
||||||
</el-button-group>
|
|
||||||
@:</el-col>
|
|
||||||
</el-row>
|
|
||||||
*@
|
|
||||||
</el-form>
|
|
||||||
</el-card>
|
|
||||||
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
|
|
||||||
<el-table
|
|
||||||
:data="tableData"
|
|
||||||
style="width: 100%"
|
|
||||||
v-loading="loading"
|
|
||||||
tooltip-effect="light"
|
|
||||||
@if(@pkFieldName != null)
|
|
||||||
{
|
|
||||||
@:row-key="@(@pkFieldName)"
|
|
||||||
}
|
}
|
||||||
@@sort-change="sortChange"
|
<template #row_record="{ row }">
|
||||||
border="">
|
<ModifyRecord :data="row" />
|
||||||
<el-table-column type="index" label="序号" width="55" align="center"/>
|
</template>
|
||||||
@foreach (var column in Model.TableField){
|
<template #row_buttons="{ row }">
|
||||||
if(@column.WhetherTable == "Y"){
|
@if(@Model.PrintType == "custom") {
|
||||||
if(@column.EffectType == "Upload"||@column.EffectType == "fk"||@column.EffectType == "ApiTreeSelect"||@column.EffectType == "Switch"||@column.EffectType == "ConstSelector"){
|
<el-tooltip content="打印" placement="top">
|
||||||
@:<el-table-column prop="@column.LowerPropertyName" label="@column.ColumnComment" @(column.WhetherSortable == "Y" ? "sortable='custom'" : "") show-overflow-tooltip="">
|
<el-button icon="ele-Printer" size="small" text type="primary" @@click="handlePrint(row)" v-auth="'@(@Model.LowerEntityName):print'" :disabled="row.status === 1" />
|
||||||
@:<template #default="scope">
|
</el-tooltip>
|
||||||
if(@column.EffectType == "Upload"){
|
}
|
||||||
@:<el-image
|
<el-tooltip content="编辑" placement="top">
|
||||||
@:v-if="scope.row.@column.LowerPropertyName"
|
<el-button icon="ele-Edit" size="small" text type="primary" @@click="handleEdit(row)" v-auth="'@(@Model.LowerEntityName):update'" :disabled="row.status === 1" />
|
||||||
@:style="width: 60px; height: 60px"
|
</el-tooltip>
|
||||||
@::src="scope.row.@column.LowerPropertyName"
|
<el-tooltip content="删除" placement="top">
|
||||||
@::lazy="true"
|
<el-button icon="ele-Delete" size="small" text type="danger" @@click="handleDelete(row)" v-auth="'@(@Model.LowerEntityName):delete'" :disabled="row.status === 1" />
|
||||||
@::hide-on-click-modal="true"
|
</el-tooltip>
|
||||||
@::preview-src-list="[scope.row.@column.LowerPropertyName]"
|
</template>
|
||||||
@::initial-index="0"
|
<template #pager>
|
||||||
@:fit="scale-down"
|
<vxe-pager
|
||||||
@:preview-teleported=""/>
|
:loading="options.loading"
|
||||||
}else if(@column.EffectType == "fk"){
|
v-model:current-page="state.tableParams.page"
|
||||||
@:<span>{{scope.row.@LowerFirstLetter(@column.PropertyName)@(@column.FkColumnName)}}</span>
|
v-model:page-size="state.tableParams.pageSize"
|
||||||
}else if(@column.EffectType == "ApiTreeSelect"){
|
:total="state.tableParams.total"
|
||||||
@:<span>{{scope.row.@LowerFirstLetter(@column.PropertyName)@(column.DisplayColumn)}}</span>
|
@@page-change="pageChange"
|
||||||
}else if(@column.EffectType == "Switch"){
|
/>
|
||||||
@:<el-tag v-if="scope.row.@(@column.LowerPropertyName)"> 是 </el-tag>
|
</template>
|
||||||
@:<el-tag type="danger" v-else> 否 </el-tag>
|
</vxe-grid>
|
||||||
}else if(@column.EffectType == "ConstSelector"){
|
</el-card>
|
||||||
@:<span>{{codeToName(scope.row.@(@column.LowerPropertyName), '@(@column.DictTypeCode)')}}</span>
|
|
||||||
}
|
<PrintDialog ref="printDialogRef" :title="state.title" @@reloadTable="handleQuery" />
|
||||||
@:
|
<EditDialog ref="editDialogRef" :title="state.title" @@reloadTable="handleQuery" />
|
||||||
</template>
|
</div>
|
||||||
@:
|
|
||||||
</el-table-column>
|
|
||||||
}
|
|
||||||
else if(@column.EffectType == "Select"){
|
|
||||||
@:<el-table-column prop="@column.LowerPropertyName" label="@column.ColumnComment" @(column.WhetherSortable == "Y" ? "sortable='custom'" : "") show-overflow-tooltip="" >
|
|
||||||
@:<template #default="scope">
|
|
||||||
@:<el-tag :type="di('@(@column.DictTypeCode)', scope.row.@(@column.LowerPropertyName))?.tagType"> {{di("@(@column.DictTypeCode)", scope.row.@(@column.LowerPropertyName))?.value}} </el-tag>
|
|
||||||
@:</template>
|
|
||||||
@:</el-table-column>
|
|
||||||
}
|
|
||||||
else if(@column.EffectType == "EnumSelector"){
|
|
||||||
@:<el-table-column prop="@column.LowerPropertyName" label="@column.ColumnComment" @(column.WhetherSortable == "Y" ? "sortable='custom'" : "") show-overflow-tooltip="" >
|
|
||||||
@:<template #default="scope">
|
|
||||||
@:<el-tag :type="dv('@(@column.DictTypeCode)', scope.row.@(@column.LowerPropertyName))?.tagType"> {{dv('@(@column.DictTypeCode)', scope.row.@column.LowerPropertyName)?.name}}</el-tag>
|
|
||||||
@:</template>
|
|
||||||
@:</el-table-column>
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
@:<el-table-column prop="@column.LowerPropertyName" label="@column.ColumnComment" @(column.WhetherSortable == "Y" ? "sortable='custom'" : "") show-overflow-tooltip="" />
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@if(@Model.PrintType == "custom"){
|
|
||||||
@:<el-table-column label="操作" width="200" align="center" fixed="right" show-overflow-tooltip="" v-if="auth('@(@Model.LowerClassName):update') || auth('@(@Model.LowerClassName):delete')">
|
|
||||||
@:<template #default="scope">
|
|
||||||
@:<el-button icon="ele-Printer" size="small" text="" type="primary" @@click="openPrint@(@Model.ClassName)(scope.row)" v-auth="'@(@Model.LowerClassName):print'"> 打印 </el-button>
|
|
||||||
}else{
|
|
||||||
@:<el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" v-if="auth('@(@Model.LowerClassName):update') || auth('@(@Model.LowerClassName):delete')">
|
|
||||||
@:<template #default="scope">
|
|
||||||
}
|
|
||||||
<el-button icon="ele-Edit" size="small" text="" type="primary" @@click="openEdit@(@Model.ClassName)(scope.row)" v-auth="'@(@Model.LowerClassName):update'"> 编辑 </el-button>
|
|
||||||
<el-button icon="ele-Delete" size="small" text="" type="primary" @@click="del@(@Model.ClassName)(scope.row)" v-auth="'@(@Model.LowerClassName):delete'"> 删除 </el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<el-pagination
|
|
||||||
v-model:currentPage="tableParams.page"
|
|
||||||
v-model:page-size="tableParams.pageSize"
|
|
||||||
:total="tableParams.total"
|
|
||||||
:page-sizes="[10, 20, 50, 100, 200, 500]"
|
|
||||||
size="small"
|
|
||||||
background=""
|
|
||||||
@@size-change="handleSizeChange"
|
|
||||||
@@current-change="handleCurrentChange"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
/>
|
|
||||||
<printDialog
|
|
||||||
ref="printDialogRef"
|
|
||||||
:title="print@(@Model.ClassName)Title"
|
|
||||||
@@reloadTable="handleQuery" />
|
|
||||||
<editDialog
|
|
||||||
ref="editDialogRef"
|
|
||||||
:title="edit@(@Model.ClassName)Title"
|
|
||||||
@@reloadTable="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup="" name="@(@Model.LowerClassName)">
|
<script lang="ts" setup name="@(@Model.LowerEntityName)">
|
||||||
import { ref } from "vue";
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
import { ElMessageBox, ElMessage } from "element-plus";
|
import { ElMessageBox, ElMessage } from "element-plus";
|
||||||
import { auth } from '/@@/utils/authFunction';
|
import { auth } from '/@@/utils/authFunction';
|
||||||
|
import { VxeGridInstance, VxePagerEvents, VxePagerDefines } from 'vxe-table';
|
||||||
|
import { useVxeTable } from '/@@/hooks/vxeTableOptionsHook';
|
||||||
|
|
||||||
@if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){
|
@if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){
|
||||||
@:import { codeToName, getConstType } from "/@@/utils/constHelper";
|
@:import { codeToName, getConstType } from "/@@/utils/constHelper";
|
||||||
}
|
|
||||||
@if(@Model.TableField.Any(x=>x.EffectType == "Select") || @Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
|
|
||||||
@:import { getDictDataItem as di, getDictDataList as dl } from '/@@/utils/dict-utils';
|
|
||||||
}
|
|
||||||
@if(@Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
|
|
||||||
@:import { getDictLabelByVal as dv } from '/@@/utils/dict-utils';
|
|
||||||
}
|
|
||||||
@if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){
|
|
||||||
@:import { formatDate } from '/@@/utils/formatTime';
|
|
||||||
}
|
|
||||||
|
|
||||||
@if(@Model.PrintType == "custom"){
|
|
||||||
@:// 推荐设置操作 width 为 200
|
|
||||||
@:import { hiprint } from 'vue-plugin-hiprint';
|
|
||||||
@:import { SysPrintApi } from '/@@/api-services/api';
|
|
||||||
@:import { SysPrint } from '/@@/api-services/models';
|
|
||||||
}
|
|
||||||
|
|
||||||
import printDialog from '/@@/views/system/print/component/hiprint/preview.vue'
|
|
||||||
import editDialog from '/@@/views/@(@Model.PagePath)/@(@Model.LowerClassName)/component/editDialog.vue'
|
|
||||||
import { page@(@Model.ClassName), delete@(@Model.ClassName) } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
|
|
||||||
@foreach (var column in Model.QueryWhetherList){
|
|
||||||
if(@column.EffectType == "fk"){
|
|
||||||
@:import { get@(@column.FkEntityName)@(@column.PropertyName)Dropdown } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@if(@Model.QueryWhetherList.Any(x=>x.EffectType == "EnumSelector")){
|
|
||||||
@:import { getAPI } from '/@@/utils/axios-utils';
|
|
||||||
@:import { SysEnumApi } from '/@@/api-services/api';
|
|
||||||
@:import commonFunction from '/@@/utils/commonFunction';
|
|
||||||
}
|
|
||||||
|
|
||||||
@if(haveLikeCdt){
|
|
||||||
@:const showAdvanceQueryUI = ref(false);
|
|
||||||
}else {
|
|
||||||
@:const showAdvanceQueryUI = ref(true);
|
|
||||||
}
|
|
||||||
const printDialogRef = ref();
|
|
||||||
const editDialogRef = ref();
|
|
||||||
const loading = ref(false);
|
|
||||||
const tableData = ref<any>([]);
|
|
||||||
const queryParams = ref<any>({});
|
|
||||||
const tableParams = ref({
|
|
||||||
page: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
total: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const print@(@Model.ClassName)Title = ref("");
|
|
||||||
const edit@(@Model.ClassName)Title = ref("");
|
|
||||||
|
|
||||||
// 改变高级查询的控件显示状态
|
|
||||||
const changeAdvanceQueryUI = () => {
|
|
||||||
showAdvanceQueryUI.value = !showAdvanceQueryUI.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询操作
|
|
||||||
const handleQuery = async () => {
|
|
||||||
loading.value = true;
|
|
||||||
var res = await page@(@Model.ClassName)(Object.assign(queryParams.value, tableParams.value));
|
|
||||||
tableData.value = res.data.result?.items ?? [];
|
|
||||||
tableParams.value.total = res.data.result?.total;
|
|
||||||
loading.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 列排序
|
|
||||||
const sortChange = async (column: any) => {
|
|
||||||
queryParams.value.field = column.prop;
|
|
||||||
queryParams.value.order = column.order;
|
|
||||||
await handleQuery();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 打开新增页面
|
|
||||||
const openAdd@(@Model.ClassName) = () => {
|
|
||||||
edit@(@Model.ClassName)Title.value = '添加@(@Model.BusName)';
|
|
||||||
editDialogRef.value.openDialog({});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 打开打印页面
|
|
||||||
const openPrint@(@Model.ClassName) = async (row: any) => {
|
|
||||||
print@(@Model.ClassName)Title.value = '打印@(@Model.BusName)';
|
|
||||||
@if(@Model.PrintType == "custom"){
|
|
||||||
@:var res = await getAPI(SysPrintApi).apiSysPrintPrintNameGet('@Model.PrintName');
|
|
||||||
@:var printTemplate = res.data.result as SysPrint;
|
|
||||||
@:var template = JSON.parse(printTemplate.template);
|
|
||||||
@:row['printDate'] = formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS')
|
|
||||||
@:printDialogRef.value.showDialog(new hiprint.PrintTemplate({template: template}), row, template.panels[0].width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 打开编辑页面
|
|
||||||
const openEdit@(@Model.ClassName) = (row: any) => {
|
|
||||||
edit@(@Model.ClassName)Title.value = '编辑@(@Model.BusName)';
|
|
||||||
editDialogRef.value.openDialog(row);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 删除
|
|
||||||
const del@(@Model.ClassName) = (row: any) => {
|
|
||||||
ElMessageBox.confirm(`确定要删除吗?`, "提示", {
|
|
||||||
confirmButtonText: "确定",
|
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning",
|
|
||||||
})
|
|
||||||
.then(async () => {
|
|
||||||
await delete@(@Model.ClassName)(row);
|
|
||||||
handleQuery();
|
|
||||||
ElMessage.success("删除成功");
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 改变页面容量
|
|
||||||
const handleSizeChange = (val: number) => {
|
|
||||||
tableParams.value.pageSize = val;
|
|
||||||
handleQuery();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 改变页码序号
|
|
||||||
const handleCurrentChange = (val: number) => {
|
|
||||||
tableParams.value.page = val;
|
|
||||||
handleQuery();
|
|
||||||
};
|
|
||||||
|
|
||||||
@foreach (var column in Model.QueryWhetherList){
|
|
||||||
if(@column.EffectType == "fk"){
|
|
||||||
@: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();
|
|
||||||
@:@LowerFirstLetter(@column.FkEntityName)@(@column.PropertyName)DropdownList.value = list.data.result ?? [];
|
|
||||||
@:};
|
|
||||||
@:get@(@column.FkEntityName)@(@column.PropertyName)DropdownList();
|
|
||||||
@:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
handleQuery();
|
@if(@Model.TableField.Any(x=>x.EffectType == "Select") || @Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
|
||||||
|
@:import { getDictDataItem as di, getDictDataList as dl } from '/@@/utils/dict-utils';
|
||||||
|
}
|
||||||
|
@if(@Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
|
||||||
|
@:import { getDictLabelByVal as dv } from '/@@/utils/dict-utils';
|
||||||
|
}
|
||||||
|
@if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){
|
||||||
|
@:import { formatDate } from '/@@/utils/formatTime';
|
||||||
|
}
|
||||||
|
|
||||||
|
import { newValue } from '/@@/utils/desensitization';
|
||||||
|
|
||||||
|
@if(@Model.PrintType != "off"){
|
||||||
|
@:// 推荐设置操作 width 为 200
|
||||||
|
@:import { hiprint } from 'vue-plugin-hiprint';
|
||||||
|
@:import { SysPrintApi } from '/@@/api-services/_system/api';
|
||||||
|
@:import { SysPrint } from '/@@/api-services/_system/models';
|
||||||
|
}
|
||||||
|
// 子窗口
|
||||||
|
import PrintDialog from '/@@/views/system/print/component/hiprint/preview.vue';
|
||||||
|
import EditDialog from '/@@/views/@(@Model.PagePath)/@(@Model.LowerEntityName)/component/editDialog.vue';
|
||||||
|
import ModifyRecord from '/@@/components/table/modifyRecord.vue';
|
||||||
|
|
||||||
|
// 接口函数
|
||||||
|
import { getAPI } from '/@@/utils/axios-utils';
|
||||||
|
|
||||||
|
// 接口
|
||||||
|
import { @(@Model.EntityName)Api } from '/@@/api-services/_lab/api';
|
||||||
|
|
||||||
|
// 模型
|
||||||
|
import { @(@Model.EntityName), @(@Model.EntityName)Input, @(@Model.EntityName)Output } from '/@@/api-services/_lab/models';
|
||||||
|
|
||||||
|
// 子窗口对象
|
||||||
|
const xGrid = ref<VxeGridInstance>();
|
||||||
|
const printDialogRef = ref<InstanceType<typeof PrintDialog>>();
|
||||||
|
const editDialogRef = ref<InstanceType<typeof EditDialog>>();
|
||||||
|
|
||||||
|
// 变量
|
||||||
|
const state = reactive({
|
||||||
|
queryParams: {
|
||||||
|
title: undefined,
|
||||||
|
type: undefined,
|
||||||
|
},
|
||||||
|
tableParams: {
|
||||||
|
page: 1,
|
||||||
|
pageSize: 50,
|
||||||
|
field: 'id', // 默认的排序字段
|
||||||
|
order: 'aes', // 排序方向
|
||||||
|
descStr: 'desc', // 降序排序的关键字符
|
||||||
|
total: 0 as any,
|
||||||
|
},
|
||||||
|
visible: false,
|
||||||
|
title: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格参数配置
|
||||||
|
const options = useVxeTable<@(@Model.EntityName)>({
|
||||||
|
id: '@(@Model.EntityName)',
|
||||||
|
name: '@(@Model.BusName)',
|
||||||
|
columns: [
|
||||||
|
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
|
||||||
|
@foreach (var column in Model.TableField) {
|
||||||
|
if(@column.WhetherTable == "Y") {
|
||||||
|
if(@column.EffectType == "Upload" || @column.EffectType == "fk" || @column.EffectType == "ApiTreeSelect" || @column.EffectType == "Switch" || @column.EffectType == "ConstSelector") {
|
||||||
|
if(@column.EffectType == "Upload") {
|
||||||
|
|
||||||
|
} else if(@column.EffectType == "fk") {
|
||||||
|
|
||||||
|
} else if(@column.EffectType == "ApiTreeSelect") {
|
||||||
|
|
||||||
|
} else if(@column.EffectType == "Switch") {
|
||||||
|
|
||||||
|
} else if(@column.EffectType == "ConstSelector") {
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if(@column.EffectType == "Select") {
|
||||||
|
|
||||||
|
} else if(@column.EffectType == "EnumSelector") {
|
||||||
|
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_@column.LowerPropertyName' } },
|
||||||
|
} else {
|
||||||
|
if(@column.LowerPropertyName != "remark") {
|
||||||
|
@:{ field: '@column.LowerPropertyName', title: '@column.ColumnComment', minWidth: 100, showOverflow: 'tooltip' },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{ field: '', title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
|
||||||
|
{ title: '操作', fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } },
|
||||||
|
],
|
||||||
|
enableExport: auth('@(@Model.LowerEntityName):export'),
|
||||||
|
searchCallback: () => handleQuery(),
|
||||||
|
queryAllCallback: () => fetchData({ pageSize: 99999 }),
|
||||||
|
});
|
||||||
|
|
||||||
|
// 页面初始化
|
||||||
|
onMounted(async () => {
|
||||||
|
await handleQuery();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 查询操作
|
||||||
|
const handleQuery = async (reset = false) => {
|
||||||
|
options.loading = true;
|
||||||
|
if (reset) state.tableParams.page = 1;
|
||||||
|
var res = await fetchData(null);
|
||||||
|
xGrid.value?.loadData(res.data.result?.items ?? []);
|
||||||
|
state.tableParams.total = res.data.result?.total;
|
||||||
|
options.loading = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
const fetchData = async (tableParams: any) => {
|
||||||
|
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
|
||||||
|
return getAPI(@(@Model.EntityName)Api).api@(@Model.EntityName)PagePost(params);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 重置操作
|
||||||
|
const resetQuery = () => {
|
||||||
|
state.queryParams.title = undefined;
|
||||||
|
state.queryParams.type = undefined;
|
||||||
|
handleQuery(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 改变页码序号或页面容量
|
||||||
|
const pageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }: VxePagerDefines.PageChangeEventParams) => {
|
||||||
|
state.tableParams.page = currentPage;
|
||||||
|
state.tableParams.pageSize = pageSize;
|
||||||
|
handleQuery();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 列排序
|
||||||
|
const sortChange = (options: any) => {
|
||||||
|
state.tableParams.field = options.field;
|
||||||
|
state.tableParams.order = options.order;
|
||||||
|
handleQuery();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 打开新增页面
|
||||||
|
const handleAdd = () => {
|
||||||
|
state.title = '添加@(@Model.BusName)';
|
||||||
|
editDialogRef.value?.openDialog({ type: 1 });
|
||||||
|
};
|
||||||
|
|
||||||
|
// 打开编辑页面
|
||||||
|
const handleEdit = (row: any) => {
|
||||||
|
state.title = '编辑@(@Model.BusName)';
|
||||||
|
editDialogRef.value?.openDialog(row);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 打开打印页面
|
||||||
|
const handlePrint = (row: any) => {
|
||||||
|
editTitle.value = '打印@(@Model.BusName)';
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
const handleDelete = (row: any) => {
|
||||||
|
ElMessageBox.confirm(`确定删除@(@Model.BusName):【${row.title}】?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}).then(async () => {
|
||||||
|
await getAPI(@(@Model.EntityName)Api).api@(@Model.EntityName)DeletePost({ id: row.id });
|
||||||
|
handleQuery();
|
||||||
|
ElMessage.success('删除成功');
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
:deep(.el-input),
|
:deep(.el-input),
|
||||||
:deep(.el-select),
|
:deep(.el-select),
|
||||||
:deep(.el-input-number) {
|
:deep(.el-input-number) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user