开发代码生成功能
This commit is contained in:
parent
37155011f0
commit
18d8051d65
@ -7,6 +7,7 @@ namespace Infrastructure
|
||||
public class OptionsSetting
|
||||
{
|
||||
public static string ConnAdmin = "Conn_admin";
|
||||
public static string Conn = "ConnDynamic";
|
||||
public static string DbType = "DbType";
|
||||
public static string DbKey = "DbKey";
|
||||
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.CodeGenerator;
|
||||
using ZR.CodeGenerator.Service;
|
||||
using ZR.Model;
|
||||
using ZR.Model.CodeGenerator;
|
||||
using ZR.Model.Vo;
|
||||
@ -19,11 +23,12 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
[Route("codeGenerator")]
|
||||
public class CodeGeneratorController : BaseController
|
||||
{
|
||||
public ICodeGeneratorService CodeGeneratorService;
|
||||
public CodeGeneratorController(ICodeGeneratorService codeGeneratorService)
|
||||
{
|
||||
CodeGeneratorService = codeGeneratorService;
|
||||
}
|
||||
//public ICodeGeneratorService CodeGeneratorService;
|
||||
//public CodeGeneratorController(ICodeGeneratorService codeGeneratorService)
|
||||
//{
|
||||
// CodeGeneratorService = codeGeneratorService;
|
||||
//}
|
||||
private CodeGeneraterService _CodeGeneraterService = new CodeGeneraterService();
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有数据库的信息
|
||||
@ -34,38 +39,53 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
//[NoPermissionRequired]
|
||||
public IActionResult GetListDataBase()
|
||||
{
|
||||
List<DataBaseInfo> listTable = CodeGeneratorService.GetAllDataBases("SqlServer");
|
||||
|
||||
return SUCCESS(listTable);
|
||||
return SUCCESS(_CodeGeneraterService.GetAllDataBases());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///获取所有表根据数据名
|
||||
/// </summary>
|
||||
/// <param name="enCode">数据库名</param>
|
||||
/// <param name="keywords">表名</param>
|
||||
/// <param name="dbName">数据库名</param>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="pager">分页信息</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("FindListTable")]
|
||||
public IActionResult FindListTable(string enCode, string keywords, PagerInfo pager)
|
||||
public IActionResult FindListTable(string dbName, string tableName, PagerInfo pager)
|
||||
{
|
||||
if (string.IsNullOrEmpty(enCode))
|
||||
if (string.IsNullOrEmpty(dbName))
|
||||
{
|
||||
return ToRespose(ResultCode.PARAM_ERROR);
|
||||
dbName = "ZrAdmin";
|
||||
}
|
||||
List<DbTableInfo> list = CodeGeneratorService.GetTablesWithPage(keywords, enCode, pager);
|
||||
var vm = new VMPageResult<DbTableInfo>(list, pager);
|
||||
List<SqlSugar.DbTableInfo> list = _CodeGeneraterService.GetAllTables(dbName, tableName, pager);
|
||||
var vm = new VMPageResult<SqlSugar.DbTableInfo>(list, pager);
|
||||
|
||||
return SUCCESS(vm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成代码
|
||||
/// 代码生成器
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
/// <param name="tables">要生成代码的表</param>
|
||||
/// <param name="baseSpace">项目命名空间</param>
|
||||
/// <param name="replaceTableNameStr">要删除表名的字符串用英文逗号","隔开</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Generate")]
|
||||
public IActionResult Generate()
|
||||
[Log(Title = "代码生成", BusinessType = BusinessType.OTHER)]
|
||||
public IActionResult Generate(string dbName, string baseSpace, string tables, string replaceTableNameStr)
|
||||
{
|
||||
if (string.IsNullOrEmpty(baseSpace))
|
||||
{
|
||||
throw new CustomException(ResultCode.CUSTOM_ERROR, "命名空间不能为空");
|
||||
}
|
||||
string[] tableList = tables.Split(",");
|
||||
List<DbTableInfo> tableInfos = new List<DbTableInfo>();// CodeGeneratorService.GetAllTables(tables);
|
||||
foreach (var item in tableList)
|
||||
{
|
||||
tableInfos.Add(new DbTableInfo() { TableName = item });
|
||||
}
|
||||
|
||||
CodeGeneratorTool.Generate(dbName, baseSpace, tableInfos, replaceTableNameStr, true);
|
||||
|
||||
return SUCCESS(null);
|
||||
}
|
||||
|
||||
14
ZR.Admin.WebApi/Template/ModelTemplate.txt
Normal file
14
ZR.Admin.WebApi/Template/ModelTemplate.txt
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace {ModelsNamespace}
|
||||
{
|
||||
/// <summary>
|
||||
/// {TableNameDesc},数据实体对象
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("{TableName}")]
|
||||
public class {ModelTypeName}
|
||||
{
|
||||
{ModelContent}
|
||||
}
|
||||
}
|
||||
@ -32,6 +32,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZR.CodeGenerator\ZR.CodeGenerator.csproj" />
|
||||
<ProjectReference Include="..\ZR.Service\ZR.Service.csproj" />
|
||||
<ProjectReference Include="..\ZR.Tasks\ZR.Tasks.csproj" />
|
||||
</ItemGroup>
|
||||
@ -56,6 +57,9 @@
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Controller.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Template\ModelTemplate.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
54
ZR.CodeGenerator/CodeGenerateOption.cs
Normal file
54
ZR.CodeGenerator/CodeGenerateOption.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZR.CodeGenerator
|
||||
{
|
||||
public class CodeGenerateOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 项目命名空间
|
||||
/// </summary>
|
||||
public string BaseNamespace { get; set; }
|
||||
/// <summary>
|
||||
/// 数据实体命名空间
|
||||
/// </summary>
|
||||
public string ModelsNamespace { get; set; }
|
||||
/// <summary>
|
||||
/// 输入输出数据实体名称空间
|
||||
/// </summary>
|
||||
public string DtosNamespace { get; set; }
|
||||
/// <summary>
|
||||
/// 仓储接口命名空间
|
||||
/// </summary>
|
||||
public string IRepositoriesNamespace { get; set; }
|
||||
/// <summary>
|
||||
/// 仓储实现名称空间
|
||||
/// </summary>
|
||||
public string RepositoriesNamespace { get; set; }
|
||||
/// <summary>
|
||||
/// 服务接口命名空间
|
||||
/// </summary>
|
||||
public string IServicsNamespace { get; set; }
|
||||
/// <summary>
|
||||
/// 服务接口实现命名空间
|
||||
/// </summary>
|
||||
public string ServicesNamespace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Api控制器命名空间
|
||||
/// </summary>
|
||||
public string ApiControllerNamespace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 去掉的表头字符
|
||||
/// </summary>
|
||||
public string ReplaceTableNameStr { get; set; }
|
||||
/// <summary>
|
||||
/// 要生数据的表,用“,”分割
|
||||
/// </summary>
|
||||
public string TableList { get; set; }
|
||||
}
|
||||
}
|
||||
322
ZR.CodeGenerator/CodeGeneratorTool.cs
Normal file
322
ZR.CodeGenerator/CodeGeneratorTool.cs
Normal file
@ -0,0 +1,322 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.CodeGenerator.CodeGenerator;
|
||||
using ZR.CodeGenerator.Service;
|
||||
using ZR.Model;
|
||||
|
||||
namespace ZR.CodeGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// 代码生成器。
|
||||
/// <remarks>
|
||||
/// 根据指定的实体域名空间生成Repositories和Services层的基础代码文件。
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public class CodeGeneratorTool
|
||||
{
|
||||
/// <summary>
|
||||
/// 代码生成器配置
|
||||
/// </summary>
|
||||
private static CodeGenerateOption _option = new CodeGenerateOption();
|
||||
/// <summary>
|
||||
/// InputDto输入实体是不包含字段
|
||||
/// </summary>
|
||||
private static string inputDtoNoField = "DeleteMark,CreatorTime,CreatorUserId,CompanyId,DeptId,LastModifyTime,LastModifyUserId,DeleteTime,DeleteUserId,";
|
||||
|
||||
/// <summary>
|
||||
/// 代码生成器入口方法
|
||||
/// </summary>
|
||||
/// <param name="baseNamespace"></param>
|
||||
/// <param name="tableList">要生成代码的表</param>
|
||||
/// <param name="listTable"></param>
|
||||
/// <param name="listField"></param>
|
||||
/// <param name="replaceTableNameStr">要删除表名称的字符</param>
|
||||
/// <param name="ifExsitedCovered">是否替换现有文件,为true时替换</param>
|
||||
public static void Generate(string dbName, string baseNamespace, List<DbTableInfo> listTable, string replaceTableNameStr, bool ifExsitedCovered = false)
|
||||
{
|
||||
_option.DtosNamespace = baseNamespace + ".Dtos";
|
||||
_option.ModelsNamespace = baseNamespace + ".Model";
|
||||
_option.IRepositoriesNamespace = baseNamespace + ".IRepositories";
|
||||
_option.RepositoriesNamespace = baseNamespace + ".Repositories";
|
||||
_option.IServicsNamespace = baseNamespace + ".IServices";
|
||||
_option.ServicesNamespace = baseNamespace + ".Services";
|
||||
_option.ApiControllerNamespace = baseNamespace + "Api";
|
||||
_option.ReplaceTableNameStr = replaceTableNameStr;
|
||||
//_option.TableList = listTable;
|
||||
_option.BaseNamespace = baseNamespace;
|
||||
|
||||
CodeGeneraterService codeGeneraterService = new CodeGeneraterService();
|
||||
//List<DbTableInfo> listTable = dbExtractor.GetWhereTables(_option.TableList);
|
||||
string profileContent = string.Empty;
|
||||
foreach (DbTableInfo dbTableInfo in listTable)
|
||||
{
|
||||
List<SqlSugar.DbColumnInfo> listField = codeGeneraterService.GetColumnInfo(dbName, dbTableInfo.TableName);
|
||||
GenerateSingle(listField, dbTableInfo, ifExsitedCovered);
|
||||
string tableName = dbTableInfo.TableName;
|
||||
if (!string.IsNullOrEmpty(_option.ReplaceTableNameStr))
|
||||
{
|
||||
string[] rel = _option.ReplaceTableNameStr.Split(';');
|
||||
for (int i = 0; i < rel.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(rel[i].ToString()))
|
||||
{
|
||||
tableName = tableName.Replace(rel[i].ToString(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
tableName = tableName.Substring(0, 1).ToUpper() + tableName.Substring(1);
|
||||
profileContent += string.Format(" CreateMap<{0}, {0}OutputDto>();\n", tableName);
|
||||
profileContent += string.Format(" CreateMap<{0}InputDto, {0}>();\n", tableName);
|
||||
}
|
||||
|
||||
//GenerateDtoProfile(_option.ModelsNamespace, profileContent, ifExsitedCovered);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单表生成代码
|
||||
/// </summary>
|
||||
/// <param name="listField">表字段集合</param>
|
||||
/// <param name="tableInfo">表信息</param>
|
||||
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
||||
public static void GenerateSingle(List<SqlSugar.DbColumnInfo> listField, DbTableInfo tableInfo, bool ifExsitedCovered = false)
|
||||
{
|
||||
var modelsNamespace = _option.ModelsNamespace;
|
||||
var modelTypeName = tableInfo.TableName;//表名
|
||||
var modelTypeDesc = tableInfo.Description;//表描述
|
||||
if (!string.IsNullOrEmpty(_option.ReplaceTableNameStr))
|
||||
{
|
||||
string[] rel = _option.ReplaceTableNameStr.Split(';');
|
||||
for (int i = 0; i < rel.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(rel[i].ToString()))
|
||||
{
|
||||
modelTypeName = modelTypeName.Replace(rel[i].ToString(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
modelTypeName = modelTypeName.Substring(0, 1).ToUpper() + modelTypeName.Substring(1);
|
||||
string keyTypeName = "string";//主键数据类型
|
||||
string modelcontent = "";//数据库模型字段
|
||||
string InputDtocontent = "";//输入模型
|
||||
string outputDtocontent = "";//输出模型
|
||||
string vueViewListContent = string.Empty;//Vue列表输出内容
|
||||
string vueViewFromContent = string.Empty;//Vue表单输出内容
|
||||
string vueViewEditFromContent = string.Empty;//Vue变量输出内容
|
||||
string vueViewEditFromBindContent = string.Empty;//Vue显示初始化输出内容
|
||||
string vueViewSaveBindContent = string.Empty;//Vue保存时输出内容
|
||||
string vueViewEditFromRuleContent = string.Empty;//Vue数据校验
|
||||
|
||||
foreach (SqlSugar.DbColumnInfo dbFieldInfo in listField)
|
||||
{
|
||||
string columnName = dbFieldInfo.DbColumnName.Substring(0, 1).ToUpper() + dbFieldInfo.DbColumnName.Substring(1);
|
||||
|
||||
modelcontent += " /// <summary>\n";
|
||||
modelcontent += ($" /// {dbFieldInfo.ColumnDescription}\n");
|
||||
modelcontent += " /// </summary>\n";
|
||||
if (dbFieldInfo.IsIdentity || dbFieldInfo.IsPrimarykey)
|
||||
{
|
||||
modelcontent += $" [SugarColumn(IsPrimaryKey = {dbFieldInfo.IsPrimarykey}, IsIdentity = {dbFieldInfo.IsIdentity})]\n";
|
||||
}
|
||||
modelcontent += $" public {TableMappingHelper.GetPropertyDatatype(dbFieldInfo.DataType)} {columnName} {{ get; set; }}\n\r";
|
||||
|
||||
//主键
|
||||
if (dbFieldInfo.IsIdentity)
|
||||
{
|
||||
keyTypeName = dbFieldInfo.DataType;
|
||||
//outputDtocontent += " /// <summary>\n";
|
||||
//outputDtocontent += string.Format(" /// 设置或获取{0}\n", dbFieldInfo.ColumnDescription);
|
||||
//outputDtocontent += " /// </summary>\n";
|
||||
|
||||
//outputDtocontent += string.Format(" [SqlSugar.SugarColumn(IsIdentity = true, IsPrimaryKey = true)]\n");
|
||||
//outputDtocontent += string.Format(" public {0} {1}", TableMappingHelper.GetPropertyDatatype(dbFieldInfo.DataType), columnName);
|
||||
//outputDtocontent += " { get; set; }\n\r";
|
||||
}
|
||||
else //非主键
|
||||
{
|
||||
modelcontent += " /// <summary>\n";
|
||||
modelcontent += string.Format(" /// 设置或获取{0}\n", dbFieldInfo.ColumnDescription);
|
||||
modelcontent += " /// </summary>\n";
|
||||
//if (dbFieldInfo.DataType == "string")
|
||||
//{
|
||||
// modelcontent += string.Format(" [MaxLength({0})]\n", dbFieldInfo.FieldMaxLength);
|
||||
//}
|
||||
modelcontent += string.Format(" public {0} {1}", TableMappingHelper.GetPropertyDatatype(dbFieldInfo.DataType), columnName);
|
||||
modelcontent += " { get; set; }\n\r";
|
||||
|
||||
|
||||
//outputDtocontent += " /// <summary>\n";
|
||||
//outputDtocontent += string.Format(" /// 设置或获取{0}\n", dbFieldInfo.ColumnDescription);
|
||||
//outputDtocontent += " /// </summary>\n";
|
||||
//if (dbFieldInfo.DataType == "string")
|
||||
//{
|
||||
// outputDtocontent += string.Format(" [MaxLength({0})]\n", dbFieldInfo.FieldMaxLength);
|
||||
//}
|
||||
//outputDtocontent += string.Format(" public {0} {1}", dbFieldInfo.DataType, columnName);
|
||||
//outputDtocontent += " { get; set; }\n\r";
|
||||
//if (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint")
|
||||
//{
|
||||
|
||||
// vueViewListContent += string.Format(" <el-table-column prop=\"{0}\" label=\"{1}\" sortable=\"custom\" width=\"120\" >\n", columnName, dbFieldInfo.ColumnDescription);
|
||||
// vueViewListContent += " <template slot-scope=\"scope\">\n";
|
||||
// vueViewListContent += string.Format(" <el-tag :type=\"scope.row.{0} === true ? 'success' : 'info'\" disable-transitions >", columnName);
|
||||
// vueViewListContent += "{{ ";
|
||||
// vueViewListContent += string.Format("scope.row.{0}===true?'启用':'禁用' ", columnName);
|
||||
// vueViewListContent += "}}</el-tag>\n";
|
||||
// vueViewListContent += " </template>\n";
|
||||
// vueViewListContent += " </el-table-column>\n";
|
||||
|
||||
// vueViewFromContent += string.Format(" <el-form-item label=\"{0}\" :label-width=\"formLabelWidth\" prop=\"{1}\">", dbFieldInfo.ColumnDescription, columnName);
|
||||
// vueViewFromContent += string.Format(" <el-radio-group v-model=\"editFrom.{0}\">\n", columnName);
|
||||
// vueViewFromContent += " <el-radio label=\"true\">是</el-radio>\n";
|
||||
// vueViewFromContent += " <el-radio label=\"false\">否</el-radio>\n";
|
||||
// vueViewFromContent += " </el-radio-group>\n";
|
||||
// vueViewFromContent += " </el-form-item>\n";
|
||||
|
||||
// vueViewEditFromContent += string.Format(" {0}: 'true',\n", columnName);
|
||||
// vueViewEditFromBindContent += string.Format(" this.editFrom.{0} = res.ResData.{0}+''\n", columnName);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// vueViewListContent += string.Format(" <el-table-column prop=\"{0}\" label=\"{1}\" sortable=\"custom\" width=\"120\" />\n", columnName, dbFieldInfo.ColumnDescription);
|
||||
|
||||
// vueViewFromContent += string.Format(" <el-form-item label=\"{0}\" :label-width=\"formLabelWidth\" prop=\"{1}\">\n", dbFieldInfo.ColumnDescription, columnName);
|
||||
// vueViewFromContent += string.Format(" <el-input v-model=\"editFrom.{0}\" placeholder=\"请输入{1}\" autocomplete=\"off\" clearable />\n", columnName, dbFieldInfo.ColumnDescription);
|
||||
// vueViewFromContent += " </el-form-item>\n";
|
||||
// vueViewEditFromContent += string.Format(" {0}: '',\n", columnName);
|
||||
// vueViewEditFromBindContent += string.Format(" this.editFrom.{0} = res.ResData.{0}\n", columnName);
|
||||
//}
|
||||
//vueViewSaveBindContent += string.Format(" '{0}':this.editFrom.{0},\n", columnName);
|
||||
//if (!dbFieldInfo.IsNullable)
|
||||
//{
|
||||
// vueViewEditFromRuleContent += string.Format(" {0}: [\n", columnName);
|
||||
// vueViewEditFromRuleContent += " {";
|
||||
// vueViewEditFromRuleContent += string.Format("required: true, message:\"请输入{0}\", trigger: \"blur\"", dbFieldInfo.ColumnDescription);
|
||||
// vueViewEditFromRuleContent += "},\n { min: 2, max: 50, message: \"长度在 2 到 50 个字符\", trigger:\"blur\" }\n";
|
||||
// vueViewEditFromRuleContent += " ],\n";
|
||||
//}
|
||||
}
|
||||
|
||||
//if (!inputDtoNoField.Contains(columnName) || columnName == "Id")
|
||||
//{
|
||||
// InputDtocontent += " /// <summary>\n";
|
||||
// InputDtocontent += string.Format(" /// 设置或获取{0}\n", dbFieldInfo.ColumnDescription);
|
||||
// InputDtocontent += " /// </summary>\n";
|
||||
// //if (dbFieldInfo.FieldType == "string")
|
||||
// //{
|
||||
// // InputDtocontent += string.Format(" [MaxLength({0})]\n", dbFieldInfo.FieldMaxLength);
|
||||
// //}
|
||||
// InputDtocontent += string.Format(" public {0} {1}", dbFieldInfo.DataType, columnName);
|
||||
// InputDtocontent += " { get; set; }\n\r";
|
||||
//}
|
||||
//
|
||||
}
|
||||
GenerateModels(modelsNamespace, modelTypeName, tableInfo.TableName, modelcontent, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||
//GenerateIRepository(modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||
//GenerateRepository(modelTypeName, modelTypeDesc, tableInfo.TableName, keyTypeName, ifExsitedCovered);
|
||||
//GenerateIService(modelsNamespace, modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||
//GenerateService(modelsNamespace, modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||
//GenerateOutputDto(modelTypeName, modelTypeDesc, outputDtocontent, ifExsitedCovered);
|
||||
//GenerateInputDto(modelsNamespace, modelTypeName, modelTypeDesc, InputDtocontent, keyTypeName, ifExsitedCovered);
|
||||
//GenerateControllers(modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||
//GenerateVueViews(modelTypeName, modelTypeDesc, vueViewListContent, vueViewFromContent, vueViewEditFromContent, vueViewEditFromBindContent, vueViewSaveBindContent, vueViewEditFromRuleContent, ifExsitedCovered);
|
||||
}
|
||||
|
||||
|
||||
#region 生成Model
|
||||
|
||||
/// <summary>
|
||||
/// 生成Models文件
|
||||
/// </summary>
|
||||
/// <param name="modelsNamespace">命名空间</param>
|
||||
/// <param name="modelTypeName">类名</param>
|
||||
/// <param name="tableName">表名称</param>
|
||||
/// <param name="modelTypeDesc">表描述</param>
|
||||
/// <param name="modelContent">数据库表实体内容</param>
|
||||
/// <param name="keyTypeName">主键数据类型</param>
|
||||
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
||||
private static void GenerateModels(string modelsNamespace, string modelTypeName, string tableName, string modelContent, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
|
||||
{
|
||||
var path = AppDomain.CurrentDomain.BaseDirectory;
|
||||
//path = path.Substring(0, path.IndexOf("\\bin"));
|
||||
var parentPath = path.Substring(0, path.LastIndexOf("\\"));
|
||||
var servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\" + modelsNamespace;
|
||||
if (!Directory.Exists(servicesPath))
|
||||
{
|
||||
servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\Models";
|
||||
Directory.CreateDirectory(servicesPath);
|
||||
}
|
||||
var fullPath = servicesPath + "\\" + modelTypeName + ".cs";
|
||||
if (File.Exists(fullPath) && !ifExsitedCovered)
|
||||
return;
|
||||
var content = ReadTemplate("ModelTemplate.txt");
|
||||
content = content
|
||||
.Replace("{ModelsNamespace}", modelsNamespace)
|
||||
.Replace("{ModelTypeName}", modelTypeName)
|
||||
.Replace("{TableNameDesc}", modelTypeDesc)
|
||||
.Replace("{KeyTypeName}", keyTypeName)
|
||||
.Replace("{ModelContent}", modelContent)
|
||||
.Replace("{TableName}", tableName);
|
||||
WriteAndSave(fullPath, content);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 帮助方法
|
||||
|
||||
/// <summary>
|
||||
/// 从代码模板中读取内容
|
||||
/// </summary>
|
||||
/// <param name="templateName">模板名称,应包括文件扩展名称。比如:template.txt</param>
|
||||
/// <returns></returns>
|
||||
private static string ReadTemplate(string templateName)
|
||||
{
|
||||
var path = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string fullName = $"{path}\\Template\\{templateName}";
|
||||
string temp = fullName;
|
||||
string str = "";
|
||||
if (!File.Exists(temp))
|
||||
{
|
||||
return str;
|
||||
}
|
||||
StreamReader sr = null;
|
||||
try
|
||||
{
|
||||
sr = new StreamReader(temp);
|
||||
str = sr.ReadToEnd(); // 读取文件
|
||||
}
|
||||
catch { }
|
||||
sr?.Close();
|
||||
sr?.Dispose();
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写文件
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="content"></param>
|
||||
private static void WriteAndSave(string fileName, string content)
|
||||
{
|
||||
//实例化一个文件流--->与写入文件相关联
|
||||
using var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
|
||||
//实例化一个StreamWriter-->与fs相关联
|
||||
using var sw = new StreamWriter(fs);
|
||||
//开始写入
|
||||
sw.Write(content);
|
||||
//清空缓冲区
|
||||
sw.Flush();
|
||||
//关闭流
|
||||
sw.Close();
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
30
ZR.CodeGenerator/DbProvider.cs
Normal file
30
ZR.CodeGenerator/DbProvider.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Infrastructure;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZR.CodeGenerator
|
||||
{
|
||||
public class DbProvider
|
||||
{
|
||||
|
||||
public SqlSugarClient GetSugarDbContext(string dbName)
|
||||
{
|
||||
string connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.Conn).Replace("{DbName}", dbName);
|
||||
int dbType = ConfigUtils.Instance.GetAppConfig(OptionsSetting.DbType, 0);
|
||||
|
||||
return new SqlSugarClient(new List<ConnectionConfig>()
|
||||
{
|
||||
new ConnectionConfig(){
|
||||
ConnectionString = connStr,
|
||||
DbType = (DbType)dbType,
|
||||
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样
|
||||
InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
88
ZR.CodeGenerator/Service/CodeGeneraterService.cs
Normal file
88
ZR.CodeGenerator/Service/CodeGeneraterService.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using Infrastructure;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model;
|
||||
using ZR.Model.CodeGenerator;
|
||||
|
||||
namespace ZR.CodeGenerator.Service
|
||||
{
|
||||
public class CodeGeneraterService: DbProvider
|
||||
{
|
||||
///// <summary>
|
||||
///// 获取表所有列
|
||||
///// </summary>
|
||||
///// <param name="tableName"></param>
|
||||
///// <returns></returns>
|
||||
//public List<DbFieldInfo> GetAllColumns(string tableName)
|
||||
//{
|
||||
// var dbType = ConfigUtils.Instance.GetConfig("CodeGenDbType");
|
||||
// if (tableName == null)
|
||||
// throw new ArgumentException(nameof(tableName));
|
||||
// List<DbFieldInfo> list = new List<DbFieldInfo>();
|
||||
// if (dbType == "1")
|
||||
// {
|
||||
// list = CodeGeneratorRepository.GetAllColumns(tableName);
|
||||
// }
|
||||
// return list;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有数据库名
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DataBaseInfo> GetAllDataBases()
|
||||
{
|
||||
var dbType = ConfigUtils.Instance.GetConfig("CodeGenDbType");
|
||||
List<DataBaseInfo> list = new List<DataBaseInfo>();
|
||||
if (dbType == "1")
|
||||
{
|
||||
var db = GetSugarDbContext("ZrAdmin");
|
||||
var templist = db.DbMaintenance.GetDataBaseList(db);
|
||||
templist.ForEach(item =>
|
||||
{
|
||||
list.Add(new DataBaseInfo() { DbName = item });
|
||||
});
|
||||
}
|
||||
else if (dbType == "0")
|
||||
{
|
||||
// list = mssqlExtractor.GetAllDataBases();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有表
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="tableStrs"></param>
|
||||
/// <param name="pager"></param>
|
||||
/// <returns></returns>
|
||||
public List<SqlSugar.DbTableInfo> GetAllTables(string dbName, string tableName, PagerInfo pager)
|
||||
{
|
||||
var tableList = GetSugarDbContext(dbName).DbMaintenance.GetTableInfoList(true);
|
||||
if (!string.IsNullOrEmpty(tableName))
|
||||
{
|
||||
tableList = tableList.Where(f => f.Name.Contains(tableName)).ToList();
|
||||
}
|
||||
pager.TotalNum = tableList.Count;
|
||||
return tableList.Skip(pager.PageSize * (pager.PageNum - 1)).Take(pager.PageSize).OrderBy(f => f.Name).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取列信息
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
public List<DbColumnInfo> GetColumnInfo(string dbName, string tableName)
|
||||
{
|
||||
return GetSugarDbContext(dbName).DbMaintenance.GetColumnInfosByTableName(tableName, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -34,6 +34,8 @@ namespace ZR.CodeGenerator.CodeGenerator
|
||||
public static string GetClassNamePrefix(string tableName)
|
||||
{
|
||||
string[] arr = tableName.Split('_');
|
||||
if (arr.Length <= 0) return tableName;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 1; i < arr.Length; i++)
|
||||
{
|
||||
|
||||
@ -12,7 +12,16 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Model\" />
|
||||
<Folder Include="Template\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Template\ModelTemplate.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -10,6 +10,7 @@ namespace ZR.Model
|
||||
/// </summary>
|
||||
public class DbFieldInfo
|
||||
{
|
||||
public string TableName { get; set; }
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
|
||||
1
ZR.Model/Models/README.txt
Normal file
1
ZR.Model/Models/README.txt
Normal file
@ -0,0 +1 @@
|
||||
此文件夹用于存放业务代码数据库实体类
|
||||
@ -42,6 +42,7 @@ namespace ZR.Repository.DbProvider
|
||||
//调式代码 用来打印SQL
|
||||
Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("【SQL语句】" + sql.ToLower() + "\r\n" + Db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
};
|
||||
//出错打印日志
|
||||
@ -51,5 +52,21 @@ namespace ZR.Repository.DbProvider
|
||||
Console.WriteLine();
|
||||
};
|
||||
}
|
||||
|
||||
public SqlSugarClient GetSugarDbContext(string dbName)
|
||||
{
|
||||
string connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.Conn).Replace("{DbName}", dbName);
|
||||
int dbType = ConfigUtils.Instance.GetAppConfig(OptionsSetting.DbType, 0);
|
||||
|
||||
return new SqlSugarClient(new List<ConnectionConfig>()
|
||||
{
|
||||
new ConnectionConfig(){
|
||||
ConnectionString = connStr,
|
||||
DbType = (DbType)dbType,
|
||||
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样
|
||||
InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,33 +13,62 @@ namespace ZR.Repository.System
|
||||
public class CodeGeneratorRepository : BaseRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取数据库信息
|
||||
/// 获取数据库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DataBaseInfo> GetAllDataBaseInfos()
|
||||
public List<DataBaseInfo> GetAllDb()
|
||||
{
|
||||
return Db.Ado.SqlQuery<DataBaseInfo>("select name as DbName from master..sysdatabases ");
|
||||
//return Db.Ado.SqlQuery<DataBaseInfo>("select name as DbName from master..sysdatabases ");
|
||||
var list = Db.DbMaintenance.GetDataBaseList(Db);
|
||||
List<DataBaseInfo> dataBases = new List<DataBaseInfo>();
|
||||
list.ForEach(item =>
|
||||
{
|
||||
dataBases.Add(new DataBaseInfo() { DbName = item });
|
||||
});
|
||||
return dataBases;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的表
|
||||
/// 根据数据库名获取所有的表
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
/// <param name="pager"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
public List<DbTableInfo> GetAllTables(string dbName, string tableName, PagerInfo pager)
|
||||
public List<SqlSugar.DbTableInfo> GetAllTables(string dbName, string tableName, PagerInfo pager)
|
||||
{
|
||||
string sql = $"SELECT name as TableName FROM {dbName}..SysObjects Where XType='U'";
|
||||
int total = 0;
|
||||
var list = Db.SqlQueryable<DbTableInfo>(sql)
|
||||
//.WithCache(60 * 10)
|
||||
.WhereIF(!string.IsNullOrEmpty(tableName), it => it.TableName.Contains(tableName))
|
||||
.AddParameters(new { dbName })
|
||||
.OrderBy(x => x.TableName)
|
||||
.ToPageList(pager.PageNum, pager.PageSize, ref total);
|
||||
pager.TotalNum = total;
|
||||
return list;
|
||||
var tableList = GetSugarDbContext(dbName).DbMaintenance.GetTableInfoList(true);
|
||||
if (!string.IsNullOrEmpty(tableName))
|
||||
{
|
||||
tableList = tableList.Where(f => f.Name.Contains(tableName)).ToList();
|
||||
}
|
||||
pager.TotalNum = tableList.Count;
|
||||
return tableList.Skip(pager.PageSize * (pager.PageNum - 1)).Take(pager.PageSize).OrderBy(f => f.Name).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取表格列信息
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
public List<SqlSugar.DbColumnInfo> GetColumnInfo(string dbName, string tableName)
|
||||
{
|
||||
return GetSugarDbContext(dbName).DbMaintenance.GetColumnInfosByTableName(tableName, true);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前数据库表名
|
||||
/// </summary>
|
||||
/// <param name="tabList"></param>
|
||||
/// <returns></returns>
|
||||
public List<DbTableInfo> GetAllTables(string[] tabList)
|
||||
{
|
||||
string sql = @"SELECT tbs.name as TableName ,ds.value as Description FROM sys.tables tbs
|
||||
left join sys.extended_properties ds on ds.major_id=tbs.object_id and ds.minor_id=0";
|
||||
|
||||
return Db.SqlQueryable<DbTableInfo>(sql).WhereIF(tabList.Length > 0, x => tabList.Contains(x.TableName)).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,10 +8,16 @@ using ZR.Model.CodeGenerator;
|
||||
|
||||
namespace ZR.Service.IService
|
||||
{
|
||||
public interface ICodeGeneratorService
|
||||
{
|
||||
List<DataBaseInfo> GetAllDataBases(string dbType);
|
||||
//public interface ICodeGeneratorService
|
||||
//{
|
||||
// List<DataBaseInfo> GetAllDataBases();
|
||||
|
||||
List<DbTableInfo> GetTablesWithPage(string tablename, string dbName, PagerInfo info);
|
||||
}
|
||||
// List<SqlSugar.DbTableInfo> GetTablesWithPage(string tablename, string dbName, PagerInfo info);
|
||||
|
||||
// List<DbFieldInfo> GetAllColumns(string tableName);
|
||||
|
||||
// List<DbTableInfo> GetAllTables(string tabList);
|
||||
|
||||
// List<SqlSugar.DbColumnInfo> GetColumnInfo(string dbName, string tableName);
|
||||
//}
|
||||
}
|
||||
|
||||
@ -15,53 +15,85 @@ namespace ZR.Service.System
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ICodeGeneratorService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class CodeGeneratorService: ICodeGeneratorService
|
||||
//[AppService(ServiceType = typeof(ICodeGeneratorService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class CodeGeneratorService //: ICodeGeneratorService
|
||||
{
|
||||
public CodeGeneratorRepository CodeGeneratorRepository;
|
||||
//public CodeGeneratorRepository CodeGeneratorRepository;
|
||||
|
||||
public CodeGeneratorService(CodeGeneratorRepository codeGeneratorRepository)
|
||||
{
|
||||
CodeGeneratorRepository = codeGeneratorRepository;
|
||||
}
|
||||
//public CodeGeneratorService(CodeGeneratorRepository codeGeneratorRepository)
|
||||
//{
|
||||
// CodeGeneratorRepository = codeGeneratorRepository;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取表所有列
|
||||
///// </summary>
|
||||
///// <param name="tableName"></param>
|
||||
///// <returns></returns>
|
||||
//public List<DbFieldInfo> GetAllColumns(string tableName)
|
||||
//{
|
||||
// var dbType = ConfigUtils.Instance.GetConfig("CodeGenDbType");
|
||||
// if (tableName == null)
|
||||
// throw new ArgumentException(nameof(tableName));
|
||||
// List<DbFieldInfo> list = new List<DbFieldInfo>();
|
||||
// if (dbType == "1")
|
||||
// {
|
||||
// list = CodeGeneratorRepository.GetAllColumns(tableName);
|
||||
// }
|
||||
// return list;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取所有数据库名
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public List<DataBaseInfo> GetAllDataBases()
|
||||
//{
|
||||
// var dbType = ConfigUtils.Instance.GetConfig("CodeGenDbType");
|
||||
// List<DataBaseInfo> list = new List<DataBaseInfo>();
|
||||
// if (dbType == "1")
|
||||
// {
|
||||
// list = CodeGeneratorRepository.GetAllDb();
|
||||
// }
|
||||
// else if (dbType == "0")
|
||||
// {
|
||||
// // list = mssqlExtractor.GetAllDataBases();
|
||||
// }
|
||||
// return list;
|
||||
//}
|
||||
|
||||
//public List<DbTableInfo> GetAllTables(string tableStrs)
|
||||
//{
|
||||
// string[] tabList = tableStrs.Split(",");
|
||||
|
||||
// return CodeGeneratorRepository.GetAllTables(tabList);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有数据库名
|
||||
/// 获取列信息
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
public List<DataBaseInfo> GetAllDataBases(string dbType)
|
||||
{
|
||||
List<DataBaseInfo> list = new List<DataBaseInfo>();
|
||||
if (dbType.Contains("SqlServer"))
|
||||
{
|
||||
list = CodeGeneratorRepository.GetAllDataBaseInfos();
|
||||
}
|
||||
else if (dbType.Contains("MySql"))
|
||||
{
|
||||
// list = mssqlExtractor.GetAllDataBases();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
//public List<SqlSugar.DbColumnInfo> GetColumnInfo(string dbName, string tableName)
|
||||
//{
|
||||
// return CodeGeneratorRepository.GetColumnInfo(dbName, tableName);
|
||||
//}
|
||||
|
||||
public List<DbTableInfo> GetTablesWithPage(string tablename, string dbName, PagerInfo pager)
|
||||
{
|
||||
var dbType = ConfigUtils.Instance.GetConfig("CodeGenDbType");
|
||||
List<DbTableInfo> list = new List<DbTableInfo>();
|
||||
if (dbType == "1")
|
||||
{
|
||||
list = CodeGeneratorRepository.GetAllTables(dbName, tablename, pager);
|
||||
}
|
||||
else if (dbType.Contains("MySql"))
|
||||
{
|
||||
//list = mysqlExtractor.GetAllTables(this.dbName, tablename, fieldNameToSort, isDescending, info);
|
||||
}
|
||||
//if (!string.IsNullOrEmpty(tablename))
|
||||
//{
|
||||
// list = list.Where(f => f.TableName.Contains(tablename)).ToList();
|
||||
//}
|
||||
|
||||
return list;
|
||||
}
|
||||
//public List<SqlSugar.DbTableInfo> GetTablesWithPage(string tablename, string dbName, PagerInfo pager)
|
||||
//{
|
||||
// var dbType = ConfigUtils.Instance.GetConfig("CodeGenDbType");
|
||||
// List<SqlSugar.DbTableInfo> list = new List<SqlSugar.DbTableInfo>();
|
||||
// if (dbType == "1")
|
||||
// {
|
||||
// list = CodeGeneratorRepository.GetAllTables(dbName, tablename, pager);
|
||||
// }
|
||||
// else if (dbType == "0")
|
||||
// {
|
||||
// //list = mysqlExtractor.GetAllTables(this.dbName, tablename, fieldNameToSort, isDescending, info);
|
||||
// }
|
||||
// return list;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,10 +26,10 @@ export function cleanOperlog() {
|
||||
}
|
||||
|
||||
// 导出操作日志
|
||||
export function exportOperlog(query) {
|
||||
return request({
|
||||
url: '/monitor/operlog/export',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
// export function exportOperlog(query) {
|
||||
// return request({
|
||||
// url: '/monitor/operlog/export',
|
||||
// method: 'get',
|
||||
// params: query
|
||||
// })
|
||||
// }
|
||||
|
||||
@ -6,16 +6,13 @@
|
||||
<!-- 面包屑导航 -->
|
||||
<breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
|
||||
<!-- <top-nav id="topmenu-container" class="topmenu-container" v-if="!topNav"/> -->
|
||||
<!-- <el-menu class="el-menu">
|
||||
<el-menu-item index="4" text-color="#fff"><a href="/bigdata" target="_blank">大屏数据</a></el-menu-item>
|
||||
</el-menu> -->
|
||||
|
||||
<div class="right-menu">
|
||||
<template v-if="device!=='mobile'">
|
||||
<search id="header-search" class="right-menu-item" />
|
||||
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
||||
<!-- <el-tooltip content="布局大小" effect="dark" placement="bottom"> -->
|
||||
<size-select id="size-select" class="right-menu-item hover-effect" />
|
||||
<size-select id="size-select" class="right-menu-item hover-effect" />
|
||||
<!-- </el-tooltip> -->
|
||||
</template>
|
||||
|
||||
@ -85,9 +82,6 @@ export default {
|
||||
});
|
||||
});
|
||||
},
|
||||
to() {
|
||||
this.$router.replace("/bigdata");
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -1,218 +0,0 @@
|
||||
|
||||
<template>
|
||||
<div id="big-data-container" class="big-data-container">
|
||||
<div class="head">
|
||||
<h1>大屏数据统计分析显示</h1>
|
||||
</div>
|
||||
<div class="data-container">
|
||||
<div class="data-left">
|
||||
<div class="data-left-item">
|
||||
<div class="title">商品销量分类</div>
|
||||
<div id="chart-left-1" style="height: calc(100% - 30px);"></div>
|
||||
<div class="data-foot-line"></div>
|
||||
</div>
|
||||
<div class="data-left-item">
|
||||
<div class="title">本月商品销量</div>
|
||||
<div id="chart-left-3" style="height: calc(100% - 30px);"></div>
|
||||
|
||||
<div class="data-foot-line"></div>
|
||||
</div>
|
||||
<div class="data-left-item">
|
||||
<div class="title">7日订单销量</div>
|
||||
<div id="chart-left-2" style="height: calc(100% - 30px);"></div>
|
||||
<div class="data-foot-line"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-center">
|
||||
<!-- <div class="title">中间位置</div> -->
|
||||
<div class="center-top-num">
|
||||
<div class="item">
|
||||
<div class="text">累计销量</div>
|
||||
<div class="num">220,000</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="text">累计销售金额</div>
|
||||
<div class="num">58,000,000</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="text">购买用户人数</div>
|
||||
<div class="num">15,000</div>
|
||||
</div>
|
||||
<div class="data-foot-line"></div>
|
||||
</div>
|
||||
<div class="center-top">
|
||||
<div class="title">用户活跃信息-1</div>
|
||||
<iview-circle :size="200" style="padding: 8px 0;"></iview-circle>
|
||||
<div class="data-foot-line"></div>
|
||||
</div>
|
||||
<div class="title">订单销售统计</div>
|
||||
<div id="chart-center" class="chart-center"></div>
|
||||
</div>
|
||||
<div class="data-right">
|
||||
<div class="data-right-item">
|
||||
<div class="title">销售情况走势</div>
|
||||
<div id="chart-right-1" style="height: calc(100% - 30px);"></div>
|
||||
<div class="data-foot-line"></div>
|
||||
</div>
|
||||
<div class="data-right-item">
|
||||
<div class="title">用户活跃信息</div>
|
||||
<iview-circle></iview-circle>
|
||||
<div class="data-foot-line"></div>
|
||||
</div>
|
||||
<div class="data-right-item right-3">
|
||||
<div class="title">商品销售排行</div>
|
||||
<div id="chart-right-3" class="right-item">
|
||||
<div class="item">
|
||||
<div class="top">排名</div>
|
||||
<div class="pro-name">商品名称</div>
|
||||
<div class="num">销量</div>
|
||||
<div class="num">销售金额</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="top top-1">
|
||||
<span>1</span>
|
||||
</div>
|
||||
<div class="pro-name">卡帝乐鳄鱼</div>
|
||||
<div class="num">2,200</div>
|
||||
<div class="num">360,00</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="top top-2">
|
||||
<span>2</span>
|
||||
</div>
|
||||
<div class="pro-name">春夏男T恤</div>
|
||||
<div class="num">1,700</div>
|
||||
<div class="num">24,500</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="top top-3">
|
||||
<span>3</span>
|
||||
</div>
|
||||
<div class="pro-name">男女同款休闲鞋</div>
|
||||
<div class="num">1,120</div>
|
||||
<div class="num">12,700</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="boxfoot"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
var echarts = require("echarts");
|
||||
import {
|
||||
chartLeft1,
|
||||
chartLeft2,
|
||||
chartLeft3,
|
||||
chartRight1
|
||||
} from "./bigdata/chart-options";
|
||||
import IviewCircle from "./bigdata/IviewCircle";
|
||||
import "./bigdata/layout.less";
|
||||
export default {
|
||||
components: {
|
||||
"iview-circle": IviewCircle
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
mounted() {
|
||||
var $chartLeft1 = echarts.init(document.getElementById("chart-left-1"));
|
||||
$chartLeft1.setOption(chartLeft1);
|
||||
|
||||
var $chartLeft2 = echarts.init(document.getElementById("chart-left-2"));
|
||||
$chartLeft2.setOption(chartLeft2);
|
||||
|
||||
var $chartLeft3 = echarts.init(document.getElementById("chart-left-3"));
|
||||
$chartLeft3.setOption(chartLeft3);
|
||||
|
||||
var $chartCenter = echarts.init(document.getElementById("chart-center"));
|
||||
$chartCenter.setOption(chartRight1);
|
||||
|
||||
var $chartRight1 = echarts.init(document.getElementById("chart-right-1"));
|
||||
$chartRight1.setOption(chartRight1);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
/* .chart-center {
|
||||
display: flex;
|
||||
border: 1px solid #0000ff;
|
||||
height: 200px;
|
||||
flex-direction: column;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.chart-center .item {
|
||||
text-align: center;
|
||||
border: 1px solid #00c1b3;
|
||||
flex: 1;
|
||||
} */
|
||||
.right-3 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
/* margin-top: 20px; */
|
||||
}
|
||||
|
||||
.right-3 .right-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.right-3 .item {
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #549069;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
padding: 5px 10px;
|
||||
margin: 0 10px;
|
||||
font-size: 14px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.right-3 .item:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.right-3 .item > div {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.right-3 .top {
|
||||
width: 60px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.right-3 .top span {
|
||||
position: absolute;
|
||||
width: 20px;
|
||||
line-height: 20px;
|
||||
top: 5px;
|
||||
text-align: center;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.right-3 .top-1 span {
|
||||
background: #e80d0d;
|
||||
}
|
||||
|
||||
.right-3 .top-2 span {
|
||||
background: #00c935;
|
||||
}
|
||||
|
||||
.right-3 .top-3 span {
|
||||
background: #0083f4;
|
||||
}
|
||||
|
||||
.right-3 .num {
|
||||
width: 88px;
|
||||
}
|
||||
|
||||
.right-3 .pro-name {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
<template>
|
||||
<div class="demo-Circle">
|
||||
<div style>
|
||||
<i-circle :size="size" :trail-width="4" :stroke-width="5" :percent="75" stroke-linecap="square" stroke-color="#43a3fb">
|
||||
<div class="demo-Circle-custom">
|
||||
<h1>1500</h1>
|
||||
<p>昨日活跃用户数量</p>
|
||||
<span>
|
||||
占比
|
||||
<i>{{1500/20000}}%</i>
|
||||
</span>
|
||||
</div>
|
||||
</i-circle>
|
||||
</div>
|
||||
<div style>
|
||||
<i-circle :size="size" :trail-width="4" :stroke-width="5" :percent="75" stroke-linecap="square" stroke-color="#43a3fb">
|
||||
<div class="demo-Circle-custom">
|
||||
<h1>12000</h1>
|
||||
<p>上月活跃用户数量</p>
|
||||
<span>
|
||||
占比
|
||||
<i>{{12000/150000}}%</i>
|
||||
</span>
|
||||
</div>
|
||||
</i-circle>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
size: {
|
||||
type: Number,
|
||||
default: 150,
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.demo-Circle {
|
||||
display: flex;
|
||||
}
|
||||
.demo-Circle > div {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
.demo-Circle > div:first-child {
|
||||
padding-left: 10%;
|
||||
}
|
||||
|
||||
.demo-Circle > div:last-child {
|
||||
padding-right: 10%;
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped>
|
||||
.demo-Circle-custom {
|
||||
& h1 {
|
||||
color: #ffffff;
|
||||
font-size: 28px;
|
||||
font-weight: normal;
|
||||
}
|
||||
& p {
|
||||
color: #ece8e8;
|
||||
font-size: 14px;
|
||||
margin: 10px 0 15px;
|
||||
}
|
||||
& span {
|
||||
display: block;
|
||||
padding-top: 15px;
|
||||
color: wheat;
|
||||
font-size: 14px;
|
||||
&:before {
|
||||
content: "";
|
||||
display: block;
|
||||
width: 50px;
|
||||
height: 1px;
|
||||
margin: 0 auto;
|
||||
background: #e0e3e6;
|
||||
position: relative;
|
||||
top: -15px;
|
||||
}
|
||||
}
|
||||
& span i {
|
||||
font-style: normal;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -1,471 +0,0 @@
|
||||
var echarts = require("echarts");
|
||||
let chartLeft1 = {
|
||||
tooltip: {
|
||||
trigger: "axis",
|
||||
axisPointer: {
|
||||
type: "shadow"
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
left: "0%",
|
||||
top: "10px",
|
||||
right: "0%",
|
||||
bottom: "4%",
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: "category",
|
||||
data: [
|
||||
"商超门店",
|
||||
"教育培训",
|
||||
"房地产",
|
||||
"生活服务",
|
||||
"汽车销售",
|
||||
"旅游酒店",
|
||||
"五金建材"
|
||||
],
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1)",
|
||||
width: 1,
|
||||
type: "solid"
|
||||
}
|
||||
},
|
||||
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLabel: {
|
||||
interval: 0,
|
||||
show: true,
|
||||
splitNumber: 15,
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.6)",
|
||||
fontSize: "12"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: "value",
|
||||
axisLabel: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.6)",
|
||||
fontSize: "12"
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1 )",
|
||||
width: 1,
|
||||
type: "solid"
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1)"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: "bar",
|
||||
data: [200, 600, 300, 900, 1500, 1200, 600],
|
||||
barWidth: "35%",
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#2f89cf",
|
||||
opacity: 1,
|
||||
barBorderRadius: 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
let chartLeft2 = {
|
||||
tooltip: {
|
||||
trigger: "axis",
|
||||
axisPointer: {
|
||||
type: "shadow"
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
left: "0%",
|
||||
top: "10px",
|
||||
right: "0%",
|
||||
bottom: "4%",
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: "category",
|
||||
data: [
|
||||
"07.01",
|
||||
"07.02",
|
||||
"07.03",
|
||||
"07.04",
|
||||
"07.05",
|
||||
"07.06",
|
||||
],
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1)",
|
||||
width: 1,
|
||||
type: "solid"
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLabel: {
|
||||
interval: 0,
|
||||
// rotate:50,
|
||||
show: true,
|
||||
splitNumber: 15,
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.6)",
|
||||
fontSize: "12"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: "value",
|
||||
axisLabel: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.6)",
|
||||
fontSize: "12"
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1 )",
|
||||
width: 1,
|
||||
type: "solid"
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1)"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "value",
|
||||
axisLabel: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.6)",
|
||||
fontSize: "12"
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1 )",
|
||||
width: 1,
|
||||
type: "solid"
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1)"
|
||||
}
|
||||
}
|
||||
}
|
||||
], series: [
|
||||
{
|
||||
type: "bar",
|
||||
name: "销量",
|
||||
data: [1200, 800, 300, 500, 560, 220],
|
||||
barWidth: "25%",
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#2f89cf",
|
||||
opacity: 1,
|
||||
barBorderRadius: 5
|
||||
}
|
||||
}
|
||||
}, {
|
||||
type: "bar",
|
||||
name: "订单",
|
||||
data: [1000, 750, 380, 450, 450, 120],
|
||||
barWidth: "25%",
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#46d000",
|
||||
opacity: 1,
|
||||
barBorderRadius: 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
let chartLeft3 = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
left: "0%",
|
||||
top: "-5px",
|
||||
right: "3%",
|
||||
bottom: "4%",
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
axisLabel: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.6)",
|
||||
fontSize: "12"
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1 )",
|
||||
width: 1,
|
||||
type: "solid"
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1)"
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
axisLabel: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.6)",
|
||||
fontSize: "12"
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1 )",
|
||||
width: 1,
|
||||
type: "solid"
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1)"
|
||||
}
|
||||
},
|
||||
data: ['周一', '周二', '周三', '周四', '周五']
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '直接访问',
|
||||
type: 'bar',
|
||||
stack: '总量',
|
||||
label: {
|
||||
show: true,
|
||||
position: 'insideRight'
|
||||
},
|
||||
barWidth: "55%",
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#2f89cf",
|
||||
opacity: 1,
|
||||
barBorderRadius: 5
|
||||
}
|
||||
},
|
||||
data: [120, 302, 400, 200, 700]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
let chartRight1 = {
|
||||
title: {},
|
||||
tooltip: {
|
||||
trigger: "axis",
|
||||
axisPointer: {
|
||||
type: "cross",
|
||||
label: {
|
||||
backgroundColor: "#6a7985"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
color: ["#ffab6f", "#09b916", "#83cddc"], //图例颜色
|
||||
legend: {
|
||||
top: "0%",
|
||||
icon: "roundRect",
|
||||
data: ["销售订单", "退货订单", "折扣订单"],
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.5)",
|
||||
fontSize: "12"
|
||||
}
|
||||
},
|
||||
toolbox: {
|
||||
feature: {}
|
||||
},
|
||||
grid: {
|
||||
left: "10",
|
||||
top: "20",
|
||||
right: "10",
|
||||
bottom: "10",
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: "category",
|
||||
boundaryGap: false,
|
||||
axisLabel: {
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.6)",
|
||||
fontSize: 12
|
||||
}
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.2)"
|
||||
}
|
||||
},
|
||||
data: [
|
||||
"2020.06.15",
|
||||
"2020.06.16",
|
||||
"2020.06.17",
|
||||
"2020.06.18",
|
||||
"2020.06.19",
|
||||
"2020.06.20",
|
||||
"2020.06.21",
|
||||
"2020.06.22"
|
||||
]
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: "value",
|
||||
axisTick: { show: false },
|
||||
minInterval: 60,
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1)"
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
textStyle: {
|
||||
color: "rgba(255,255,255,.6)",
|
||||
fontSize: 12
|
||||
}
|
||||
},
|
||||
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: "rgba(255,255,255,.1)"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: "销售订单",
|
||||
type: "line",
|
||||
smooth: true,
|
||||
lineStyle: {
|
||||
color: "#45d4ba",
|
||||
width: 1
|
||||
}, //线条的样式
|
||||
areaStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{
|
||||
offset: 0,
|
||||
color: "#83cddc"
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: "#bfdffbb5"
|
||||
}
|
||||
])
|
||||
},
|
||||
data: [5, 22, 150, 54, 1, 230, 4, 1]
|
||||
},
|
||||
{
|
||||
name: "退货订单",
|
||||
type: "line",
|
||||
|
||||
smooth: true,
|
||||
lineStyle: {
|
||||
color: "#04a710",
|
||||
width: 1
|
||||
}, //
|
||||
areaStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{
|
||||
offset: 0,
|
||||
color: "#0cbf22"
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: "#b8f7d1b5"
|
||||
}
|
||||
])
|
||||
},
|
||||
data: [10, 150, 1, 250, 20, 100, 10, 150]
|
||||
},
|
||||
{
|
||||
name: "折扣订单",
|
||||
type: "line",
|
||||
|
||||
lineStyle: {
|
||||
color: "#0864c3",
|
||||
width: 1
|
||||
}, //线条的样式
|
||||
smooth: true,
|
||||
areaStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{
|
||||
offset: 0,
|
||||
color: "#29d7ff"
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: "#34ccef85"
|
||||
}
|
||||
])
|
||||
},
|
||||
data: [100, 2, 260, 1, 200, 30, 101, 40]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
export { chartLeft1, chartLeft2,chartLeft3, chartRight1 }
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.7 KiB |
@ -1,197 +0,0 @@
|
||||
|
||||
.big-data-container {
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-color: #1400a8;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25' viewBox='0 0 1200 800'%3E%3Cdefs%3E%3CradialGradient id='a' cx='0' cy='800' r='800' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%230e0077'/%3E%3Cstop offset='1' stop-color='%230e0077' stop-opacity='0'/%3E%3C/radialGradient%3E%3CradialGradient id='b' cx='1200' cy='800' r='800' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%2314057c'/%3E%3Cstop offset='1' stop-color='%2314057c' stop-opacity='0'/%3E%3C/radialGradient%3E%3CradialGradient id='c' cx='600' cy='0' r='600' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%230d0524'/%3E%3Cstop offset='1' stop-color='%230d0524' stop-opacity='0'/%3E%3C/radialGradient%3E%3CradialGradient id='d' cx='600' cy='800' r='600' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%231400a8'/%3E%3Cstop offset='1' stop-color='%231400a8' stop-opacity='0'/%3E%3C/radialGradient%3E%3CradialGradient id='e' cx='0' cy='0' r='800' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%23000000'/%3E%3Cstop offset='1' stop-color='%23000000' stop-opacity='0'/%3E%3C/radialGradient%3E%3CradialGradient id='f' cx='1200' cy='0' r='800' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%23130733'/%3E%3Cstop offset='1' stop-color='%23130733' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Crect fill='url(%23a)' width='1200' height='800'/%3E%3Crect fill='url(%23b)' width='1200' height='800'/%3E%3Crect fill='url(%23c)' width='1200' height='800'/%3E%3Crect fill='url(%23d)' width='1200' height='800'/%3E%3Crect fill='url(%23e)' width='1200' height='800'/%3E%3Crect fill='url(%23f)' width='1200' height='800'/%3E%3C/svg%3E");
|
||||
background-attachment: fixed;
|
||||
background-size: cover;
|
||||
.head {
|
||||
height: 75px;
|
||||
/* height: 1.05rem; */
|
||||
background: url(./head_bg.png) no-repeat center center;
|
||||
background-size: 100% 100%;
|
||||
position: relative;
|
||||
z-index: 100;
|
||||
}
|
||||
}
|
||||
|
||||
.head h1 {
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
/* font-size: .4rem; */
|
||||
/* line-height: .8rem; */
|
||||
line-height: 71px;
|
||||
}
|
||||
|
||||
.data-container {
|
||||
/* margin: 5px 15px;
|
||||
height:100%; */
|
||||
|
||||
margin: 0px 15px;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 76px;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.data-container > div {
|
||||
float: left;
|
||||
/* border: 1px solid white; */
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.data-center {
|
||||
padding: 0 0.9rem;
|
||||
width: 40%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
// .center-top{
|
||||
// height: 210px;
|
||||
// background: red;
|
||||
// }
|
||||
.chart-center{
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
.chart-center{
|
||||
width: 100%;
|
||||
display: flex;
|
||||
// background: white;
|
||||
}
|
||||
.data-left,
|
||||
.data-right {
|
||||
width: 30%;
|
||||
display: flex;
|
||||
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.data-left-item,
|
||||
.data-right-item,.center-top,.center-top-num,.chart-center {
|
||||
border: 1px solid rgba(25, 186, 139, 0.17);
|
||||
padding: 0 0.2rem 0.4rem 0.15rem;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
background-size: 100% auto;
|
||||
position: relative;
|
||||
margin-bottom: 0.15rem;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.data-foot-line {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.data-foot-line:before,
|
||||
.data-foot-line:after {
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height:10px;
|
||||
content: "";
|
||||
border-bottom: 2px solid #02a6b5;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.boxall:before,
|
||||
.data-foot-line:before {
|
||||
border-left: 2px solid #02a6b5;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.boxall:after,
|
||||
.data-foot-line:after {
|
||||
border-right: 2px solid #02a6b5;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.boxall:before,
|
||||
.boxall:after {
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
content: "";
|
||||
border-top: 2px solid #02a6b5;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.data-left-item:before,
|
||||
.data-right-item:before,
|
||||
.center-top-num:before,
|
||||
.center-top:before{
|
||||
border-left: 2px solid #02a6b5;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height:10px;
|
||||
content: "";
|
||||
border-top: 2px solid #02a6b5;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.data-left-item:after,
|
||||
.data-right-item:after,
|
||||
.center-top-num:after,
|
||||
.center-top:after {
|
||||
border-right: 2px solid #02a6b5;
|
||||
right: 0;
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
content: "";
|
||||
border-top: 2px solid #02a6b5;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.data-left,
|
||||
.data-right {
|
||||
/* display: flex; */
|
||||
}
|
||||
|
||||
.data-left > .data-left-item,
|
||||
.data-right > .data-right-item {
|
||||
flex: 1;
|
||||
margin-bottom: 0.9rem;
|
||||
}
|
||||
|
||||
.data-center .title,
|
||||
.data-left > .data-left-item .title,
|
||||
.data-right > .data-right-item .title {
|
||||
/* font-size: .2rem; */
|
||||
font-size: 1rem;
|
||||
padding: 7px 0;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
/* line-height: .5rem; */
|
||||
}
|
||||
|
||||
.data-center .chart-center{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.center-top-num{
|
||||
height: 80px;
|
||||
padding-top: 7px;
|
||||
margin-bottom: 0.8rem;
|
||||
display: flex;
|
||||
.item{
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
.text{
|
||||
color: #fcf0d8;
|
||||
font-size: 14px;
|
||||
}
|
||||
.num{
|
||||
font-size: 34px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
|
||||
font-weight: bold;
|
||||
color: #67caca;
|
||||
}
|
||||
}
|
||||
151
ZR.Vue/src/views/monitor/cache/index.vue
vendored
151
ZR.Vue/src/views/monitor/cache/index.vue
vendored
@ -1,151 +0,0 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-row>
|
||||
<el-col :span="24" class="card-box">
|
||||
<el-card>
|
||||
<div slot="header"><span>基本信息</span></div>
|
||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
||||
<table cellspacing="0" style="width: 100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><div class="cell">Redis版本</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.redis_version }}</div></td>
|
||||
<td><div class="cell">运行模式</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.redis_mode == "standalone" ? "单机" : "集群" }}</div></td>
|
||||
<td><div class="cell">端口</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.tcp_port }}</div></td>
|
||||
<td><div class="cell">客户端数</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.connected_clients }}</div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div class="cell">运行时间(天)</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.uptime_in_days }}</div></td>
|
||||
<td><div class="cell">使用内存</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.used_memory_human }}</div></td>
|
||||
<td><div class="cell">使用CPU</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ parseFloat(cache.info.used_cpu_user_children).toFixed(2) }}</div></td>
|
||||
<td><div class="cell">内存配置</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.maxmemory_human }}</div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div class="cell">AOF是否开启</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.aof_enabled == "0" ? "否" : "是" }}</div></td>
|
||||
<td><div class="cell">RDB是否成功</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.rdb_last_bgsave_status }}</div></td>
|
||||
<td><div class="cell">Key数量</div></td>
|
||||
<td><div class="cell" v-if="cache.dbSize">{{ cache.dbSize }} </div></td>
|
||||
<td><div class="cell">网络入口/出口</div></td>
|
||||
<td><div class="cell" v-if="cache.info">{{ cache.info.instantaneous_input_kbps }}kps/{{cache.info.instantaneous_output_kbps}}kps</div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="card-box">
|
||||
<el-card>
|
||||
<div slot="header"><span>命令统计</span></div>
|
||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
||||
<div ref="commandstats" style="height: 420px" />
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="card-box">
|
||||
<el-card>
|
||||
<div slot="header">
|
||||
<span>内存信息</span>
|
||||
</div>
|
||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
||||
<div ref="usedmemory" style="height: 420px" />
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCache } from "@/api/monitor/cache";
|
||||
// import echarts from "echarts";
|
||||
|
||||
export default {
|
||||
name: "Server",
|
||||
data() {
|
||||
return {
|
||||
// 加载层信息
|
||||
loading: [],
|
||||
// 统计命令信息
|
||||
commandstats: null,
|
||||
// 使用内存
|
||||
usedmemory: null,
|
||||
// cache信息
|
||||
cache: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.openLoading();
|
||||
},
|
||||
methods: {
|
||||
/** 查缓存询信息 */
|
||||
getList() {
|
||||
getCache().then((response) => {
|
||||
this.cache = response.data;
|
||||
this.loading.close();
|
||||
|
||||
this.commandstats = echarts.init(this.$refs.commandstats, "macarons");
|
||||
this.commandstats.setOption({
|
||||
tooltip: {
|
||||
trigger: "item",
|
||||
formatter: "{a} <br/>{b} : {c} ({d}%)",
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: "命令",
|
||||
type: "pie",
|
||||
roseType: "radius",
|
||||
radius: [15, 95],
|
||||
center: ["50%", "38%"],
|
||||
data: response.data.commandStats,
|
||||
animationEasing: "cubicInOut",
|
||||
animationDuration: 1000,
|
||||
},
|
||||
],
|
||||
});
|
||||
this.usedmemory = echarts.init(this.$refs.usedmemory, "macarons");
|
||||
this.usedmemory.setOption({
|
||||
tooltip: {
|
||||
formatter: "{b} <br/>{a} : {c}M",
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: "峰值",
|
||||
type: "gauge",
|
||||
detail: {
|
||||
formatter: "{value}M",
|
||||
},
|
||||
data: [
|
||||
{
|
||||
value: parseFloat(this.cache.info.used_memory_human),
|
||||
name: "内存消耗",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
},
|
||||
// 打开加载层
|
||||
openLoading() {
|
||||
this.loading = this.$loading({
|
||||
lock: true,
|
||||
text: "拼命读取中",
|
||||
spinner: "el-icon-loading",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@ -1,128 +0,0 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
|
||||
<el-form-item label="登录地址" prop="ipaddr">
|
||||
<el-input
|
||||
v-model="queryParams.ipaddr"
|
||||
placeholder="请输入登录地址"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户名称" prop="userName">
|
||||
<el-input
|
||||
v-model="queryParams.userName"
|
||||
placeholder="请输入用户名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list.slice((pageNum-1)*pageSize,pageNum*pageSize)"
|
||||
style="width: 100%;"
|
||||
>
|
||||
<el-table-column label="序号" type="index" align="center">
|
||||
<template slot-scope="scope">
|
||||
<span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="会话编号" align="center" prop="tokenId" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="登录名称" align="center" prop="userName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="部门名称" align="center" prop="deptName" />
|
||||
<el-table-column label="主机" align="center" prop="ipaddr" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="浏览器" align="center" prop="browser" />
|
||||
<el-table-column label="操作系统" align="center" prop="os" />
|
||||
<el-table-column label="登录时间" align="center" prop="loginTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.loginTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleForceLogout(scope.row)"
|
||||
v-hasPermi="['monitor:online:forceLogout']"
|
||||
>强退</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { list, forceLogout } from "@/api/monitor/online";
|
||||
|
||||
export default {
|
||||
name: "Online",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 表格数据
|
||||
list: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
ipaddr: undefined,
|
||||
userName: undefined
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询登录日志列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
list(this.queryParams).then(response => {
|
||||
this.list = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 强退按钮操作 */
|
||||
handleForceLogout(row) {
|
||||
this.$confirm('是否确认强退名称为"' + row.userName + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return forceLogout(row.tokenId);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("强退成功");
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="30" align="center" />
|
||||
<el-table-column type="selection" width="50" align="center" />
|
||||
<el-table-column label="日志编号" align="center" prop="operId" />
|
||||
<el-table-column label="系统模块" align="center" prop="title" :show-overflow-tooltip="true"/>
|
||||
<!-- <el-table-column label="操作类型" align="center" prop="businessType" :formatter="typeFormat" /> -->
|
||||
@ -121,11 +121,10 @@ import {
|
||||
cleanOperlog,
|
||||
exportOperlog,
|
||||
} from "@/api/monitor/operlog";
|
||||
import template from "../../../../document/template.vue";
|
||||
import DateRangePicker from '@/components/DateRangePicker'
|
||||
|
||||
export default {
|
||||
components: { template ,DateRangePicker},
|
||||
components: { DateRangePicker},
|
||||
name: "Operlog",
|
||||
data() {
|
||||
return {
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
</el-select>
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据库表名">
|
||||
<el-form-item label="表名">
|
||||
<el-input v-model="searchform.tableName" clearable placeholder="输入要查询的表名" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@ -56,15 +56,21 @@
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="iconfont icon-code" @click="handleGenerate()">生成代码</el-button>
|
||||
<!-- <el-button type="primary" icon="iconfont icon-code" @click="handleGenerate()">生成代码</el-button> -->
|
||||
<el-button type="default" icon="el-icon-refresh" size="small" @click="loadTableData()">刷新</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-table ref="gridtable" v-loading="tableloading" :data="tableData" border stripe highlight-current-row style="width: 100%" :default-sort="{prop: 'TableName', order: 'ascending'}" @select="handleSelectChange" @select-all="handleSelectAllChange" @sort-change="handleSortChange">
|
||||
<el-table-column type="selection" width="50" />
|
||||
<el-table-column prop="tableName" label="表名" sortable="custom" width="380" />
|
||||
<el-table ref="gridtable" v-loading="tableloading" :data="tableData" border stripe highlight-current-row style="width: 100%" @selection-change="handleSelectChange">
|
||||
<!-- <el-table-column type="selection" width="50" /> -->
|
||||
<el-table-column prop="name" label="表名" sortable="custom" width="380" />
|
||||
<el-table-column prop="description" label="表描述" />
|
||||
<el-table-column label="操作" align="center" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" icon="el-icon-view">预览</el-button>
|
||||
<el-button type="text" icon="el-icon-download" @click="handleGenerate(scope.row)">生成代码</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="pagination-container">
|
||||
<el-pagination background :current-page="pagination.pageNum" :page-sizes="[5,10,20,50,100, 200, 300, 400]" :page-size="pagination.pagesize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.pageTotal" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
||||
@ -84,7 +90,9 @@ import { downloadFile } from "@/utils/index";
|
||||
import { Loading } from "element-ui";
|
||||
|
||||
import defaultSettings from "@/settings";
|
||||
import template from "../../../document/template.vue";
|
||||
export default {
|
||||
components: { template },
|
||||
name: "CodeGenerator",
|
||||
data() {
|
||||
return {
|
||||
@ -163,8 +171,8 @@ export default {
|
||||
var seachdata = {
|
||||
pageNum: this.pagination.pageNum,
|
||||
PageSize: this.pagination.pagesize,
|
||||
Keywords: this.searchform.tableName,
|
||||
EnCode: this.searchform.DbName,
|
||||
tableName: this.searchform.tableName,
|
||||
dbName: this.searchform.DbName,
|
||||
// Order: this.sortableData.order,
|
||||
// Sort: this.sortableData.sort,
|
||||
};
|
||||
@ -206,75 +214,57 @@ export default {
|
||||
/**
|
||||
* 点击生成服务端代码
|
||||
*/
|
||||
handleGenerate: async function () {
|
||||
if (this.currentSelected.length === 0) {
|
||||
this.$alert("请先选择要生成代码的数据表", "提示");
|
||||
return false;
|
||||
} else {
|
||||
this.$refs["codeform"].validate((valid) => {
|
||||
if (valid) {
|
||||
var loadop = {
|
||||
lock: true,
|
||||
text: "正在生成代码...",
|
||||
spinner: "el-icon-loading",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
};
|
||||
const pageLoading = Loading.service(loadop);
|
||||
var currentTables = "";
|
||||
this.currentSelected.forEach((element) => {
|
||||
currentTables += element.TableName + ",";
|
||||
});
|
||||
var seachdata = {
|
||||
tables: currentTables,
|
||||
baseSpace: this.codeform.baseSpace,
|
||||
replaceTableNameStr: this.codeform.replaceTableNameStr,
|
||||
};
|
||||
codeGenerator(seachdata)
|
||||
.then((res) => {
|
||||
if (res.code == 100) {
|
||||
downloadFile(
|
||||
defaultSettings.fileUrl + res.ResData[0],
|
||||
res.ResData[1]
|
||||
);
|
||||
handleGenerate: async function (row) {
|
||||
console.log(JSON.stringify(row));
|
||||
// if (this.currentSelected.length === 0 || this.currentSelected.length > 3) {
|
||||
// this.msgError("请先选择要生成代码的数据表", "提示");
|
||||
// return false;
|
||||
// } else {
|
||||
this.$refs["codeform"].validate((valid) => {
|
||||
if (valid) {
|
||||
var loadop = {
|
||||
lock: true,
|
||||
text: "正在生成代码...",
|
||||
spinner: "el-icon-loading",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
};
|
||||
const pageLoading = Loading.service(loadop);
|
||||
|
||||
this.msgSuccess("恭喜你,代码生成完成!");
|
||||
} else {
|
||||
this.msgError(res.msg);
|
||||
}
|
||||
pageLoading.close();
|
||||
})
|
||||
.catch((erre) => {
|
||||
pageLoading.close();
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 当表格的排序条件发生变化的时候会触发该事件
|
||||
*/
|
||||
handleSortChange: function (column) {
|
||||
this.sortableData.sort = column.prop;
|
||||
if (column.order === "ascending") {
|
||||
this.sortableData.order = "asc";
|
||||
} else {
|
||||
this.sortableData.order = "desc";
|
||||
}
|
||||
this.loadTableData();
|
||||
var seachdata = {
|
||||
dbName: this.searchform.DbName,
|
||||
tables: row.name, // this.currentSelected.toString(),
|
||||
baseSpace: this.codeform.baseSpace,
|
||||
replaceTableNameStr: this.codeform.replaceTableNameStr,
|
||||
};
|
||||
codeGenerator(seachdata)
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
// downloadFile(
|
||||
// defaultSettings.fileUrl + res.ResData[0],
|
||||
// res.ResData[1]
|
||||
// );
|
||||
|
||||
this.msgSuccess("恭喜你,代码生成完成!");
|
||||
} else {
|
||||
this.msgError(res.msg);
|
||||
}
|
||||
pageLoading.close();
|
||||
})
|
||||
.catch((erre) => {
|
||||
pageLoading.close();
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
// }
|
||||
},
|
||||
/**
|
||||
* 当用户手动勾选checkbox数据行事件
|
||||
*/
|
||||
handleSelectChange: function (selection, row) {
|
||||
this.currentSelected = selection;
|
||||
},
|
||||
/**
|
||||
* 当用户手动勾选全选checkbox事件
|
||||
*/
|
||||
handleSelectAllChange: function (selection) {
|
||||
this.currentSelected = selection;
|
||||
console.log(JSON.stringify(selection));
|
||||
this.currentSelected = selection.map((item) => item.name);
|
||||
},
|
||||
/**
|
||||
* 选择每页显示数量
|
||||
|
||||
12
ZRAdmin.xml
12
ZRAdmin.xml
@ -42,15 +42,19 @@
|
||||
<summary>
|
||||
获取所有表根据数据名
|
||||
</summary>
|
||||
<param name="enCode">数据库名</param>
|
||||
<param name="keywords">表名</param>
|
||||
<param name="dbName">数据库名</param>
|
||||
<param name="tableName">表名</param>
|
||||
<param name="pager">分页信息</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.Generate">
|
||||
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.Generate(System.String,System.String,System.String,System.String)">
|
||||
<summary>
|
||||
生成代码
|
||||
代码生成器
|
||||
</summary>
|
||||
<param name="dbName"></param>
|
||||
<param name="tables">要生成代码的表</param>
|
||||
<param name="baseSpace">项目命名空间</param>
|
||||
<param name="replaceTableNameStr">要删除表名的字符串用英文逗号","隔开</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ZR.Admin.WebApi.Controllers.HomeController.Health">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user