Merge branch 'master' into net6.0
This commit is contained in:
167
ZR.Admin.WebApi/Controllers/Business/GendemoController.cs
Normal file
167
ZR.Admin.WebApi/Controllers/Business/GendemoController.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Mapster;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.Models;
|
||||
using ZR.Service.Business.IBusinessService;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Common;
|
||||
using Infrastructure.Extensions;
|
||||
using System.Linq;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 演示Controller
|
||||
///
|
||||
/// @author zz
|
||||
/// @date 2022-03-31
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("business/GenDemo")]
|
||||
public class GenDemoController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 演示接口
|
||||
/// </summary>
|
||||
private readonly IGenDemoService _GenDemoService;
|
||||
|
||||
public GenDemoController(IGenDemoService GenDemoService)
|
||||
{
|
||||
_GenDemoService = GenDemoService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询演示列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
[ActionPermissionFilter(Permission = "business:gendemo:list")]
|
||||
public IActionResult QueryGenDemo([FromQuery] GenDemoQueryDto parm)
|
||||
{
|
||||
var response = _GenDemoService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询演示详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{Id}")]
|
||||
[ActionPermissionFilter(Permission = "business:gendemo:query")]
|
||||
public IActionResult GetGenDemo(int Id)
|
||||
{
|
||||
var response = _GenDemoService.GetFirst(x => x.Id == Id);
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加演示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ActionPermissionFilter(Permission = "business:gendemo:add")]
|
||||
[Log(Title = "演示", BusinessType = BusinessType.INSERT)]
|
||||
public IActionResult AddGenDemo([FromBody] GenDemoDto parm)
|
||||
{
|
||||
if (parm == null)
|
||||
{
|
||||
throw new CustomException("请求参数错误");
|
||||
}
|
||||
//从 Dto 映射到 实体
|
||||
var modal = parm.Adapt<GenDemo>().ToCreate(HttpContext);
|
||||
|
||||
var response = _GenDemoService.Insert(modal, it => new
|
||||
{
|
||||
it.Name,
|
||||
it.Icon,
|
||||
it.ShowStatus,
|
||||
it.Sex,
|
||||
it.Sort,
|
||||
it.Remark,
|
||||
it.BeginTime,
|
||||
it.EndTime,
|
||||
it.Feature,
|
||||
});
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新演示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[ActionPermissionFilter(Permission = "business:gendemo:edit")]
|
||||
[Log(Title = "演示", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult UpdateGenDemo([FromBody] GenDemoDto parm)
|
||||
{
|
||||
if (parm == null)
|
||||
{
|
||||
throw new CustomException("请求实体不能为空");
|
||||
}
|
||||
//从 Dto 映射到 实体
|
||||
var modal = parm.Adapt<GenDemo>().ToUpdate(HttpContext);
|
||||
|
||||
var response = _GenDemoService.Update(w => w.Id == modal.Id, it => new GenDemo()
|
||||
{
|
||||
//Update 字段映射
|
||||
Name = modal.Name,
|
||||
Icon = modal.Icon,
|
||||
ShowStatus = modal.ShowStatus,
|
||||
Sex = modal.Sex,
|
||||
Sort = modal.Sort,
|
||||
Remark = modal.Remark,
|
||||
BeginTime = modal.BeginTime,
|
||||
EndTime = modal.EndTime,
|
||||
Feature = modal.Feature,
|
||||
});
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除演示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "business:gendemo:delete")]
|
||||
[Log(Title = "演示", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult DeleteGenDemo(string ids)
|
||||
{
|
||||
int[] idsArr = Tools.SpitIntArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
|
||||
var response = _GenDemoService.Delete(idsArr);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出演示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Log(Title = "演示", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||||
[HttpGet("export")]
|
||||
[ActionPermissionFilter(Permission = "business:gendemo:export")]
|
||||
public IActionResult Export([FromQuery] GenDemoQueryDto parm)
|
||||
{
|
||||
parm.PageSize = 10000;
|
||||
var list = _GenDemoService.GetList(parm).Result;
|
||||
|
||||
string sFileName = ExportExcel(list, "GenDemo", "演示");
|
||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
return SUCCESS(new
|
||||
{
|
||||
url = file.AccessUrl,
|
||||
fileName,
|
||||
fileName = file.FileName,
|
||||
fileId = file.Id.ToString()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure;
|
||||
using ZR.Service.System.IService;
|
||||
using ZR.Common;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.System
|
||||
{
|
||||
@@ -106,9 +107,10 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
[HttpDelete("{id}")]
|
||||
[ActionPermissionFilter(Permission = "system:post:remove")]
|
||||
[Log(Title = "岗位删除", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult Delete(int id = 0)
|
||||
public IActionResult Delete(string id)
|
||||
{
|
||||
return ToResponse(ToJson(PostService.Delete(id)));
|
||||
int[] ids = Tools.SpitIntArrary(id);
|
||||
return ToResponse(ToJson(PostService.Delete(ids)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,6 +15,8 @@ using ZR.Common;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
using Infrastructure.Extensions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.System
|
||||
{
|
||||
@@ -27,6 +29,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
private readonly ISysRoleService RoleService;
|
||||
private readonly ISysUserPostService UserPostService;
|
||||
private readonly ISysDeptService DeptService;
|
||||
private readonly ISysFileService FileService;
|
||||
private OptionsSetting OptionsSetting;
|
||||
private IWebHostEnvironment hostEnvironment;
|
||||
|
||||
@@ -35,6 +38,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
ISysRoleService roleService,
|
||||
ISysUserPostService postService,
|
||||
ISysDeptService deptService,
|
||||
ISysFileService sysFileService,
|
||||
IOptions<OptionsSetting> options,
|
||||
IWebHostEnvironment hostEnvironment)
|
||||
{
|
||||
@@ -42,6 +46,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
RoleService = roleService;
|
||||
UserPostService = postService;
|
||||
DeptService = deptService;
|
||||
FileService = sysFileService;
|
||||
OptionsSetting = options.Value;
|
||||
this.hostEnvironment = hostEnvironment;
|
||||
}
|
||||
@@ -124,28 +129,17 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
[HttpPost("Avatar")]
|
||||
[ActionPermissionFilter(Permission = "common")]
|
||||
[Log(Title = "修改头像", BusinessType = BusinessType.UPDATE, IsSaveRequestData = false)]
|
||||
public IActionResult Avatar([FromForm(Name = "picture")] IFormFile formFile)
|
||||
public async Task<IActionResult> Avatar([FromForm(Name = "picture")] IFormFile formFile)
|
||||
{
|
||||
LoginUser loginUser = Framework.JwtUtil.GetLoginUser(HttpContext);
|
||||
|
||||
if (formFile == null) throw new CustomException("请选择文件");
|
||||
|
||||
string fileExt = Path.GetExtension(formFile.FileName);
|
||||
string savePath = Path.Combine(hostEnvironment.WebRootPath, FileUtil.GetdirPath("uploads"));
|
||||
string fileName = FileUtil.HashFileName() + (fileExt.IsEmpty() ? ".png" : fileExt);
|
||||
SysFile file = await FileService.SaveFileToLocal(hostEnvironment.WebRootPath, fileName, "", HttpContext.GetName(), formFile);
|
||||
|
||||
if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); }
|
||||
|
||||
string fileName = FileUtil.HashFileName() + fileExt;
|
||||
string finalFilePath = savePath + fileName;
|
||||
|
||||
using (var stream = new FileStream(finalFilePath, FileMode.Create))
|
||||
{
|
||||
formFile.CopyTo(stream);
|
||||
}
|
||||
string accessUrl = $"{OptionsSetting.Upload.UploadUrl}/{FileUtil.GetdirPath("uploads")}{fileName}";
|
||||
|
||||
UserService.UpdatePhoto(new SysUser() { Avatar = accessUrl, UserId = loginUser.UserId });
|
||||
return SUCCESS(new { imgUrl = accessUrl });
|
||||
UserService.UpdatePhoto(new SysUser() { Avatar = file.AccessUrl, UserId = loginUser.UserId });
|
||||
return SUCCESS(new { imgUrl = file.AccessUrl });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
using ZR.Tasks;
|
||||
using Snowflake.Core;
|
||||
using Infrastructure.Extensions;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
@@ -62,14 +63,14 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
/// <param name="id">编码</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
[HttpGet("get")]
|
||||
public IActionResult Get(string id)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
return SUCCESS(_tasksQzService.GetId(id));
|
||||
}
|
||||
return SUCCESS(_tasksQzService.GetAll());
|
||||
return SUCCESS(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,7 +91,10 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
throw new CustomException($"cron表达式不正确");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(parm.ApiUrl) && parm.TaskType == 2)
|
||||
{
|
||||
throw new CustomException($"地址不能为空");
|
||||
}
|
||||
//从 Dto 映射到 实体
|
||||
var tasksQz = parm.Adapt<SysTasksQz>().ToCreate();
|
||||
var worker = new IdWorker(1, 1);
|
||||
@@ -98,7 +102,13 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
tasksQz.ID = worker.NextId().ToString();
|
||||
tasksQz.IsStart = false;
|
||||
tasksQz.Create_by = HttpContext.GetName();
|
||||
|
||||
tasksQz.TaskType = parm.TaskType;
|
||||
tasksQz.ApiUrl = parm.ApiUrl;
|
||||
if (parm.ApiUrl.IfNotEmpty() && parm.TaskType == 2)
|
||||
{
|
||||
tasksQz.AssemblyName = "ZR.Tasks";
|
||||
tasksQz.ClassName = "TaskScheduler.HttpResultfulJob";
|
||||
}
|
||||
return SUCCESS(_tasksQzService.Add(tasksQz));
|
||||
}
|
||||
|
||||
@@ -125,7 +135,15 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
throw new CustomException($"cron表达式不正确");
|
||||
}
|
||||
var tasksQz = _tasksQzService.GetFirst(m => m.ID == parm.ID);
|
||||
|
||||
if (string.IsNullOrEmpty(parm.ApiUrl) && parm.TaskType == 2)
|
||||
{
|
||||
throw new CustomException($"api地址不能为空");
|
||||
}
|
||||
if (parm.ApiUrl.IfNotEmpty() && parm.TaskType == 2)
|
||||
{
|
||||
parm.AssemblyName = "ZR.Tasks";
|
||||
parm.ClassName = "TaskScheduler.HttpResultfulJob";
|
||||
}
|
||||
if (tasksQz.IsStart)
|
||||
{
|
||||
throw new CustomException($"该任务正在运行中,请先停止在更新");
|
||||
@@ -142,10 +160,12 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
TriggerType = parm.TriggerType,
|
||||
IntervalSecond = parm.IntervalSecond,
|
||||
JobParams = parm.JobParams,
|
||||
Update_by = User.Identity.Name,
|
||||
Update_by = HttpContextExtension.GetName(HttpContext),
|
||||
Update_time = DateTime.Now,
|
||||
BeginTime = parm.BeginTime,
|
||||
EndTime = parm.EndTime
|
||||
EndTime = parm.EndTime,
|
||||
TaskType = parm.TaskType,
|
||||
ApiUrl = parm.ApiUrl,
|
||||
});
|
||||
if (response > 0)
|
||||
{
|
||||
|
||||
21
ZR.Admin.WebApi/Dockerfile
Normal file
21
ZR.Admin.WebApi/Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||
#<23><><EFBFBD><EFBFBD> /app<70>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
WORKDIR /app
|
||||
#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼,<2C><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#VOLUME /app
|
||||
#<23><><EFBFBD><EFBFBD>docker<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱪ¶<E2B1A9>˿<EFBFBD>
|
||||
EXPOSE 8888
|
||||
VOLUME /app/logs
|
||||
#COPY bin/Release/net5.0/publish/ app/
|
||||
COPY . app/
|
||||
|
||||
#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Ĭ<EFBFBD><C4AC>ʱ<EFBFBD><CAB1><EFBFBD>DZ<EFBFBD>ʱ<D7BC><CAB1><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>8<EFBFBD><38>Сʱ
|
||||
RUN echo "Asia/shanghai" > /etc/timezone
|
||||
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
# <20><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
||||
#COPY . app/
|
||||
WORKDIR /app
|
||||
|
||||
#<23>ȼ<EFBFBD><C8BC><EFBFBD> dotnet ZR.Admin.WebApi.dll<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>docker<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF><EFBFBD>80<38>˿<EFBFBD>
|
||||
ENTRYPOINT ["dotnet", "ZR.Admin.WebApi.dll", "--server.urls","http://*:8888"]
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>False</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
552
ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
Normal file
552
ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
Normal file
@@ -0,0 +1,552 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
|
||||
<el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch"
|
||||
@submit.prevent>
|
||||
|
||||
$foreach(column in genTable.Columns)
|
||||
$set(labelName = "")
|
||||
$set(columnName = "")
|
||||
$set(numLabel = "")
|
||||
$if(column.IsQuery == true)
|
||||
$set(columnName = column.CsharpFieldFl)
|
||||
$if(column.ColumnComment != "")
|
||||
$set(labelName = column.ColumnComment)
|
||||
$else
|
||||
$set(labelName = column.CsharpFieldFl)
|
||||
$end
|
||||
$if(column.CsharpType == "int" || column.CsharpType == "long")
|
||||
$set(numLabel = ".number")
|
||||
$end
|
||||
|
||||
$if(column.HtmlType == "datetime")
|
||||
<el-form-item label="$labelName">
|
||||
<el-date-picker v-model="dateRange${column.CsharpField}" style="width: 240px" type="daterange" range-separator="-"
|
||||
start-placeholder="开始日期" end-placeholder="结束日期" placeholder="请选择$labelName" :picker-options="{ firstDayOfWeek: 1}"></el-date-picker>
|
||||
</el-form-item>
|
||||
$elseif(column.HtmlType == "select" || column.HtmlType == "radio")
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<el-select v-model="queryParams.${columnName}" placeholder="请选择${labelName}">
|
||||
<el-option v-for="item in ${columnName}Options" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
$else
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<el-input v-model${numLabel}="queryParams.${columnName}" placeholder="请输入${labelName}" />
|
||||
</el-form-item>
|
||||
$end
|
||||
$end
|
||||
$end
|
||||
|
||||
<el-form-item>
|
||||
<el-button icon="search" size="small" type="primary" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="refresh" size="small" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 工具区域 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
$if(replaceDto.ShowBtnAdd)
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" size="small" v-hasPermi="['${replaceDto.PermissionPrefix}:add']" plain icon="plus" @click="handleAdd">新增</el-button>
|
||||
</el-col>
|
||||
$end
|
||||
$if(replaceDto.ShowBtnEdit)
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" size="small" :disabled="single" v-hasPermi="['${replaceDto.PermissionPrefix}:edit']" plain icon="edit" @click="handleUpdate">修改</el-button>
|
||||
</el-col>
|
||||
$end
|
||||
$if(replaceDto.ShowBtnDelete)
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" size="small" :disabled="multiple" v-hasPermi="['${replaceDto.PermissionPrefix}:delete']" plain icon="delete" @click="handleDelete">删除</el-button>
|
||||
</el-col>
|
||||
$end
|
||||
$if(replaceDto.ShowBtnExport)
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" size="small" plain icon="download" @click="handleExport" v-hasPermi="['${replaceDto.PermissionPrefix}:export']">导出</el-button>
|
||||
</el-col>
|
||||
$end
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<!-- 数据区域 -->
|
||||
<el-table :data="dataList" v-loading="loading" ref="table" border highlight-current-row @sort-change="sortChange" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="50" align="center"/>
|
||||
|
||||
$foreach(column in genTable.Columns)
|
||||
$set(labelName = "")
|
||||
$set(checkboxHtml = "")
|
||||
$set(showToolTipHtml = "")
|
||||
$set(columnName = column.CsharpFieldFl)
|
||||
$if(column.CsharpType == "string" || column.HtmlType == "datetime")
|
||||
$set(showToolTipHtml = " :show-overflow-tooltip=\"true\"")
|
||||
$end
|
||||
$if(column.ColumnComment != "")
|
||||
$set(labelName = column.ColumnComment)
|
||||
$else
|
||||
$set(labelName = column.CsharpFieldFl)
|
||||
$end
|
||||
$if(column.IsList == true)
|
||||
$if(column.HtmlType == "customInput" && column.IsPk == false)
|
||||
<el-table-column prop="${columnName}" label="${labelName}" width="90" sortable align="center">
|
||||
<template #default="scope">
|
||||
<span v-show="editIndex != scope.${index}index" @click="editCurrRow(scope.${index}index,'rowkeY')">{{scope.row.${columnName}}}</span>
|
||||
<el-input :id="scope.${index}index+'rowkeY'" size="mini" v-show="(editIndex == scope.${index}index)"
|
||||
v-model="scope.row.${columnName}" @blur="handleChangeSort(scope.row)"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
$elseif(column.HtmlType == "imageUpload")
|
||||
<el-table-column prop="${columnName}" label="${labelName}" align="center">
|
||||
<template #default="scope">
|
||||
<el-image class="table-td-thumb" fit="contain" :src="scope.row.${columnName}" :preview-src-list="[scope.row.${columnName}]">
|
||||
<div><i class="el-icon-document" /></div>
|
||||
</el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
$elseif(column.HtmlType == "checkbox" || column.HtmlType == "select" || column.HtmlType == "radio")
|
||||
<el-table-column prop="${columnName}" label="${labelName}" align="center">
|
||||
<template #default="scope">
|
||||
$if(column.HtmlType == "checkbox")
|
||||
<dict-tag :options="${columnName}Options" :value="scope.row.${columnName} ? scope.row.${columnName}.split(',') : []" />
|
||||
$else
|
||||
<dict-tag :options="${columnName}Options" :value="scope.row.${columnName}" />
|
||||
$end
|
||||
</template>
|
||||
</el-table-column>
|
||||
$else
|
||||
<el-table-column prop="${columnName}" label="${labelName}" align="center"${showToolTipHtml} />
|
||||
$end
|
||||
$end
|
||||
$end
|
||||
|
||||
<el-table-column label="操作" align="center" width="140">
|
||||
<template #default="scope">
|
||||
$if(replaceDto.ShowBtnEdit)
|
||||
<el-button v-hasPermi="['${replaceDto.PermissionPrefix}:edit']" type="success" icon="edit" title="编辑"
|
||||
@click="handleUpdate(scope.row)"></el-button>
|
||||
$end
|
||||
$if(replaceDto.ShowBtnDelete)
|
||||
<el-button v-hasPermi="['${replaceDto.PermissionPrefix}:delete']" type="danger" icon="delete" title="删除"
|
||||
@click="handleDelete(scope.row)"></el-button>
|
||||
$end
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination class="mt10" background :total="total" :page="queryParams.pageNum" :limit="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 添加或修改${genTable.functionName}对话框 -->
|
||||
<el-dialog :title="title" :lock-scroll="false" v-model="open" >
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row :gutter="20">
|
||||
|
||||
$foreach(column in genTable.Columns)
|
||||
$set(labelName = "")
|
||||
$set(labelDisabled = "")
|
||||
$set(columnName = column.CsharpFieldFl)
|
||||
$set(value = "item.dictValue")
|
||||
|
||||
$if(column.ColumnComment != "")
|
||||
$set(labelName = column.ColumnComment)
|
||||
$else
|
||||
$set(labelName = column.CsharpFieldFl)
|
||||
$end
|
||||
$if(column.IsPk == true)
|
||||
$set(labelDisabled = ":disabled=true")
|
||||
$end
|
||||
$if(column.CsharpType == "int" || column.CsharpType == "long")
|
||||
$set(value = "parseInt(item.dictValue)")
|
||||
$end
|
||||
|
||||
$if(column.IsInsert == false && column.IsEdit == false)
|
||||
<el-col :lg="12" v-if="opertype == 2">
|
||||
<el-form-item label="${labelName}">{{form.${columnName}}}</el-form-item>
|
||||
</el-col>
|
||||
$elseif(column.IsPK || column.IsIncrement)
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
$if(column.IsIncrement == false)
|
||||
<el-input-number v-model.number="form.${columnName}" controls-position="right" placeholder="请输入${labelName}" :disabled="title=='修改数据'"/>
|
||||
$else
|
||||
<span v-html="form.${columnName}"/>
|
||||
$end
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$else
|
||||
$if(column.HtmlType == "inputNumber")
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<el-input-number v-model.number="form.${columnName}" controls-position="right" placeholder="请输入${labelName}" ${labelDisabled}/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$elseif(column.HtmlType == "datetime")
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<el-date-picker v-model="form.${columnName}" type="datetime" placeholder="选择日期时间"></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$elseif(column.HtmlType == "imageUpload")
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<UploadImage v-model="form.${columnName}" column="${columnName}" @success="handleUploadSuccess" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$elseif(column.HtmlType == "fileUpload")
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<UploadFile v-model="form.${columnName}" column="${columnName}" @success="handleUploadSuccess" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$elseif(column.HtmlType == "radio")
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<el-radio-group v-model="form.${columnName}">
|
||||
<el-radio v-for="item in ${columnName}Options" :key="item.dictValue" :label="${value}">{{item.dictLabel}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$elseif(column.HtmlType == "textarea")
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<el-input type="textarea" v-model="form.${columnName}" placeholder="请输入${labelName}"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$elseif(column.HtmlType == "editor")
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<editor v-model="form.${columnName}" :min-height="200" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$elseif(column.HtmlType == "select")
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<el-select v-model="form.${columnName}" placeholder="请选择${labelName}">
|
||||
<el-option v-for="item in ${columnName}Options" :key="item.dictValue" :label="item.dictLabel" :value="${value}"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$elseif(column.HtmlType == "checkbox")
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<el-checkbox-group v-model="form.${columnName}Checked">
|
||||
<el-checkbox v-for="item in ${columnName}Options" :key="item.dictValue" :label="item.dictValue">{{item.dictLabel}}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$else
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="${labelName}" prop="${columnName}">
|
||||
<el-input v-model="form.${columnName}" placeholder="请输入${labelName}" ${labelDisabled}/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
$end
|
||||
$end
|
||||
$end
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="text" @click="cancel">取 消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import {
|
||||
list${genTable.BusinessName},
|
||||
add${genTable.BusinessName},
|
||||
del${genTable.BusinessName},
|
||||
update${genTable.BusinessName},
|
||||
get${genTable.BusinessName},
|
||||
$if(replaceDto.ShowBtnExport)
|
||||
export${genTable.BusinessName},
|
||||
$end
|
||||
$if(showCustomInput)
|
||||
changeSort
|
||||
$end
|
||||
} from '@/api/${tool.FirstLowerCase(genTable.ModuleName)}/${tool.FirstLowerCase(genTable.BusinessName)}.js';
|
||||
|
||||
import { reactive, ref, toRefs, getCurrentInstance } from "vue";
|
||||
export default {
|
||||
name: "${genTable.BusinessName.ToLower()}",
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance();
|
||||
// 选中${replaceDto.FistLowerPk}数组数组
|
||||
const ids = ref([]);
|
||||
// 非单选禁用
|
||||
const single = ref(true);
|
||||
// 非多个禁用
|
||||
const multiple = ref(true);
|
||||
// 遮罩层
|
||||
const loading = ref(false);
|
||||
// 显示搜索条件
|
||||
const showSearch = ref(true);
|
||||
// 查询参数
|
||||
const queryParams = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
sort: undefined,
|
||||
sortType: undefined,
|
||||
$foreach(item in genTable.Columns)
|
||||
$if(item.IsQuery == true)
|
||||
${item.CsharpFieldFl}: undefined,
|
||||
$end
|
||||
$end
|
||||
});
|
||||
// 弹出层标题
|
||||
const title = ref("");
|
||||
// 操作类型 1、add 2、edit
|
||||
const opertype = ref(0);
|
||||
// 是否显示弹出层
|
||||
const open = ref(false);
|
||||
// 表单参数
|
||||
const data = reactive({
|
||||
form: {},
|
||||
});
|
||||
const { form } = toRefs(data);
|
||||
// 总记录数
|
||||
const total = ref(0);
|
||||
const dataList = ref([]);
|
||||
const queryRef = ref(null);
|
||||
const formRef = ref(null);
|
||||
$foreach(item in genTable.Columns)
|
||||
$if((item.HtmlType == "radio" || item.HtmlType == "select" || item.HtmlType == "checkbox"))
|
||||
// ${item.ColumnComment}选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
|
||||
const ${item.CsharpFieldFl}Options = ref([]);
|
||||
$elseif(item.HtmlType == "datetime" && item.IsQuery == true)
|
||||
//${item.ColumnComment}时间范围
|
||||
const dateRange${item.CsharpField} = ref([]);
|
||||
$elseif(item.HtmlType == "customInput")
|
||||
const editIndex = ref(-1);
|
||||
$end
|
||||
$end
|
||||
|
||||
$set(index = 0)
|
||||
var dictParams = [
|
||||
$foreach(item in genTable.Columns)
|
||||
$if((item.HtmlType == "radio" || item.HtmlType == "select" || item.HtmlType == "checkbox") && item.DictType != "")
|
||||
{ dictType: "${item.DictType}", columnName: "${item.CsharpFieldFl}Options" },
|
||||
$set(index = index + 1)
|
||||
$end
|
||||
$end
|
||||
];
|
||||
$if(index > 0)
|
||||
proxy.getDicts(dictParams).then((response) => {
|
||||
response.data.forEach((element) => {
|
||||
proxy[element.columnName] = element.list;
|
||||
});
|
||||
});
|
||||
$end
|
||||
|
||||
// 表单规则校验
|
||||
const rules = reactive({
|
||||
$foreach(column in genTable.Columns)
|
||||
$if(column.IsRequired && column.IsIncrement == false)
|
||||
${column.CsharpFieldFl}: [
|
||||
{ required: true, message: "${column.ColumnComment}不能为空", trigger: $if(column.htmlType == "select")"change"$else"blur"$end
|
||||
$if(column.CsharpType == "int" || column.CsharpType == "long"), type: "number"$end }
|
||||
],
|
||||
$end
|
||||
$end
|
||||
});
|
||||
function getList(){
|
||||
$foreach(item in genTable.Columns)
|
||||
$if(item.HtmlType == "datetime" && item.IsQuery == true)
|
||||
proxy.addDateRange(queryParams, proxy.dateRange${item.CsharpField}, '${item.CsharpField}');
|
||||
$end
|
||||
$end
|
||||
loading.value = true;
|
||||
list${genTable.BusinessName}(queryParams).then(res => {
|
||||
if (res.code == 200) {
|
||||
dataList.value = res.data.result;
|
||||
total.value = res.data.totalNum;
|
||||
loading.value = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
function cancel(){
|
||||
open.value = false;
|
||||
reset();
|
||||
}
|
||||
// 重置表单
|
||||
function reset() {
|
||||
proxy.resetForm("formRef");
|
||||
}
|
||||
|
||||
// 查询
|
||||
function handleQuery() {
|
||||
queryParams.pageNum = 1;
|
||||
getList();
|
||||
}
|
||||
// 添加
|
||||
function handleAdd() {
|
||||
reset();
|
||||
open.value = true;
|
||||
title.value = '添加';
|
||||
opertype.value = 1;
|
||||
}
|
||||
// 删除按钮操作
|
||||
function handleDelete(row) {
|
||||
const Ids = row.${replaceDto.FistLowerPk} || ids.value;
|
||||
|
||||
proxy.${confirm}confirm('是否确认删除参数编号为"' + Ids + '"的数据项?')
|
||||
.then(function () {
|
||||
//return del${genTable.BusinessName}(Ids);
|
||||
})
|
||||
.then(() => {
|
||||
handleQuery();
|
||||
proxy.${modal}modal.msgSuccess("删除成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
// 修改按钮操作
|
||||
function handleUpdate(row) {
|
||||
reset();
|
||||
const id = row.${replaceDto.FistLowerPk} || ids.value;
|
||||
get${genTable.BusinessName}(id).then((res) => {
|
||||
const { code, data } = res;
|
||||
if (code == 200) {
|
||||
open.value = true;
|
||||
title.value = "修改数据";
|
||||
opertype.value = 2;
|
||||
|
||||
form.value = {
|
||||
...data,
|
||||
$foreach(item in genTable.Columns)
|
||||
$if(item.HtmlType == "checkbox")
|
||||
${item.CsharpFieldFl}Checked: data.${item.CsharpFieldFl} ? data.${item.CsharpFieldFl}.split(',') : [],
|
||||
$end
|
||||
$end
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 表单提交
|
||||
function submitForm() {
|
||||
proxy.${refs}refs["formRef"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (form.value.${replaceDto.FistLowerPk} != undefined && opertype.value === 2) {
|
||||
update${genTable.BusinessName}(form.value)
|
||||
.then((res) => {
|
||||
proxy.${modal}modal.msgSuccess("修改成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
})
|
||||
.catch((err) => {
|
||||
//TODO 错误逻辑
|
||||
});
|
||||
} else {
|
||||
add${genTable.BusinessName}(form.value)
|
||||
.then((res) => {
|
||||
proxy.${modal}modal.msgSuccess("新增成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
})
|
||||
.catch((err) => {
|
||||
//TODO 错误逻辑
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// 重置查询操作
|
||||
function resetQuery(){
|
||||
$foreach(item in genTable.Columns)
|
||||
$if(item.HtmlType == "datetime" && item.IsQuery == true)
|
||||
//${item.ColumnComment}时间范围
|
||||
dateRange${item.CsharpField}.value = [];
|
||||
$end
|
||||
$end
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
$if(replaceDto.ShowBtnExport)
|
||||
// 导出按钮操作
|
||||
function handleExport() {
|
||||
proxy.${confirm}confirm("是否确认导出所有${genTable.functionName}数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(function () {
|
||||
return export${genTable.BusinessName}(queryParams);
|
||||
})
|
||||
.then((response) => {
|
||||
proxy.download(response.data.path);
|
||||
});
|
||||
}
|
||||
$end
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map((item) => item.${replaceDto.FistLowerPk});
|
||||
single.value = selection.length != 1
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
// 自定义排序
|
||||
function sortChange(column) {
|
||||
if (column.prop == null || column.order == null) {
|
||||
queryParams.sort = undefined;
|
||||
queryParams.sortType = undefined;
|
||||
} else {
|
||||
queryParams.sort = column.prop;
|
||||
queryParams.sortType = column.order;
|
||||
}
|
||||
|
||||
handleQuery();
|
||||
}
|
||||
$if(replaceDto.UploadFile == 1)
|
||||
//图片上传成功方法
|
||||
function handleUploadSuccess(column, filelist) {
|
||||
form[column] = filelist;
|
||||
}
|
||||
$end
|
||||
|
||||
return {
|
||||
single,
|
||||
multiple,
|
||||
loading,
|
||||
showSearch,
|
||||
queryParams,
|
||||
total,
|
||||
rules,
|
||||
title,
|
||||
opertype,
|
||||
open,
|
||||
form,
|
||||
dataList,
|
||||
$foreach(item in genTable.Columns)
|
||||
$if((item.HtmlType == "radio" || item.HtmlType == "select" || item.HtmlType == "checkbox"))
|
||||
${item.CsharpFieldFl}Options,
|
||||
$elseif(item.HtmlType == "datetime" && item.IsQuery == true)
|
||||
dateRange${item.CsharpField},
|
||||
$elseif(item.HtmlType == "customInput")
|
||||
editIndex,
|
||||
$end
|
||||
$end
|
||||
handleQuery,
|
||||
handleAdd,
|
||||
submitForm,
|
||||
$if(replaceDto.ShowBtnExport)
|
||||
handleExport,
|
||||
$end
|
||||
resetQuery,
|
||||
handleDelete,
|
||||
handleUpdate,
|
||||
reset,
|
||||
cancel,
|
||||
queryRef,
|
||||
formRef,
|
||||
sortChange,
|
||||
getList,
|
||||
handleSelectionChange,
|
||||
$if(replaceDto.UploadFile == 1)
|
||||
handleUploadSuccess,
|
||||
$end
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user