代码生成增加打包压缩下载功能、其他功能优化
This commit is contained in:
parent
95e1427f3d
commit
f44393b4b9
@ -8,11 +8,9 @@ using Microsoft.Extensions.Hosting;
|
|||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using ZR.Admin.WebApi.Extensions;
|
using ZR.Admin.WebApi.Extensions;
|
||||||
using ZR.Admin.WebApi.Filters;
|
using ZR.Admin.WebApi.Filters;
|
||||||
using ZR.CodeGenerator;
|
using ZR.CodeGenerator;
|
||||||
using ZR.CodeGenerator.CodeGenerator;
|
|
||||||
using ZR.CodeGenerator.Model;
|
using ZR.CodeGenerator.Model;
|
||||||
using ZR.CodeGenerator.Service;
|
using ZR.CodeGenerator.Service;
|
||||||
using ZR.Common;
|
using ZR.Common;
|
||||||
@ -85,31 +83,31 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
{
|
{
|
||||||
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
|
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
|
||||||
}
|
}
|
||||||
|
dto.ZipPath = WebHostEnvironment.WebRootPath + "\\Generatecode\\";
|
||||||
|
dto.GenCodePath = dto.ZipPath + DateTime.Now.ToString("yyyyMMdd") + "\\";
|
||||||
|
|
||||||
var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
|
var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
|
||||||
var getTableColumn = GenTableColumnService.GenTableColumns(dto.TableId);
|
var getTableColumn = GenTableColumnService.GenTableColumns(dto.TableId);
|
||||||
genTableInfo.Columns = getTableColumn;
|
genTableInfo.Columns = getTableColumn;
|
||||||
|
|
||||||
dto.ParentPath = WebHostEnvironment.WebRootPath + "\\Generatecode\\" + DateTime.Now.ToString("yyyyMMdd") + "\\";
|
//生成代码
|
||||||
|
|
||||||
CodeGeneratorTool.Generate(genTableInfo, dto);
|
CodeGeneratorTool.Generate(genTableInfo, dto);
|
||||||
string zipPath = CodeGeneratorTool.ZipGenCode(dto);
|
//下载文件
|
||||||
|
CodeGeneratorTool.ZipGenCode(dto);
|
||||||
|
|
||||||
return SUCCESS(new { zipPath });
|
//HttpContext.Response.Headers.Add("Content-disposition", $"attachment; filename={zipFileName}");
|
||||||
|
return SUCCESS(new { zipPath = "/Generatecode/" + dto.ZipFileName, fileName = dto.ZipFileName });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取表详细信息
|
/// 获取代码生成表列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tableName"></param>
|
/// <param name="tableName">表名</param>
|
||||||
/// <param name="pagerInfo">分页信息</param>
|
/// <param name="pagerInfo">分页信息</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("getGenTable")]
|
[HttpGet("listGenTable")]
|
||||||
public IActionResult GetGenTable(string tableName, PagerInfo pagerInfo)
|
public IActionResult GetGenTable(string tableName, PagerInfo pagerInfo)
|
||||||
{
|
{
|
||||||
//if (string.IsNullOrEmpty(tableName))
|
|
||||||
//{
|
|
||||||
// throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
|
|
||||||
//}
|
|
||||||
//查询原表数据,部分字段映射到代码生成表字段
|
//查询原表数据,部分字段映射到代码生成表字段
|
||||||
var rows = GenTableService.GetGenTables(new GenTable() { TableName = tableName }, pagerInfo);
|
var rows = GenTableService.GetGenTables(new GenTable() { TableName = tableName }, pagerInfo);
|
||||||
|
|
||||||
@ -119,7 +117,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询表字段列表
|
/// 查询表字段列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tableId"></param>
|
/// <param name="tableId">genTable表id</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("column/{tableId}")]
|
[HttpGet("column/{tableId}")]
|
||||||
public IActionResult GetColumnList(long tableId)
|
public IActionResult GetColumnList(long tableId)
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
<!--${basedir}表示当前应用程序域所在的根目录-->
|
<!--${basedir}表示当前应用程序域所在的根目录-->
|
||||||
<target name="allfile" xsi:type="File"
|
<target name="allfile" xsi:type="File"
|
||||||
fileName="${basedir}/adminlogs/nlog-all-${shortdate}.log"
|
fileName="${basedir}/adminlogs/nlog-all-${shortdate}.log"
|
||||||
|
archiveFileName="${basedir}/adminlogs/all/all.{###}.txt"
|
||||||
archiveAboveSize="20000000"
|
archiveAboveSize="20000000"
|
||||||
maxArchiveFiles="30"
|
maxArchiveFiles="30"
|
||||||
keepFileOpen="false"
|
keepFileOpen="false"
|
||||||
|
|||||||
@ -9,14 +9,15 @@
|
|||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"conn_zrAdmin": "server=127.0.0.1;user=zr;pwd=abc;database=admin"
|
"conn_zrAdmin": "server=127.0.0.1;user=zr;pwd=abc;database=admin"
|
||||||
},
|
},
|
||||||
|
"conn_zrAdmin_Type": 0, //MySql = 0, SqlServer = 1
|
||||||
"urls": "http://localhost:8888", //项目启动url
|
"urls": "http://localhost:8888", //项目启动url
|
||||||
"sysConfig": {
|
"sysConfig": {
|
||||||
"DBCommandTimeout": 10,
|
"DBCommandTimeout": 10,
|
||||||
|
"tokenExpire": 1440,//Jwt token超时时间(分)
|
||||||
"cors": "http://localhost:8887" //跨域地址,多个用","隔开
|
"cors": "http://localhost:8887" //跨域地址,多个用","隔开
|
||||||
},
|
},
|
||||||
"DemoMode": false, //是否演示模式
|
"DemoMode": false, //是否演示模式
|
||||||
"DbKey": "", //数据库加密key
|
"DbKey": "", //数据库加密key
|
||||||
"DbType": 0, //MySql = 0, SqlServer = 1
|
|
||||||
"Upload": {
|
"Upload": {
|
||||||
"UploadDirectory": "/",
|
"UploadDirectory": "/",
|
||||||
"UploadUrl": "http://localhost:8888"
|
"UploadUrl": "http://localhost:8888"
|
||||||
|
|||||||
@ -30,14 +30,14 @@
|
|||||||
{VueViewListContent}
|
{VueViewListContent}
|
||||||
<el-table-column label="操作" align="center" width="200">
|
<el-table-column label="操作" align="center" width="200">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini" v-hasPermi="['{Permission}:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
|
<el-button v-hasPermi="['{Permission}:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
|
||||||
<el-popconfirm title="确定删除吗?" @confirm="handleDelete(scope.row)" style="margin-left:10px">
|
<el-popconfirm title="确定删除吗?" @confirm="handleDelete(scope.row)" style="margin-left:10px">
|
||||||
<el-button slot="reference" v-hasPermi="['{Permission}:delete']" size="mini" type="text" icon="el-icon-delete">删除</el-button>
|
<el-button slot="reference" v-hasPermi="['{Permission}:delete']" type="text" icon="el-icon-delete">删除</el-button>
|
||||||
</el-popconfirm>
|
</el-popconfirm>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<el-pagination class="mt10" background :total="total" :current-page.sync="queryParams.pageNum" :page-size="queryParams.pageSize" :page-sizes="[20, 30, 50, 100]" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange" @current-change="getList" />
|
<pagination class="mt10" background :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||||
|
|
||||||
<!-- 添加或修改菜单对话框 -->
|
<!-- 添加或修改菜单对话框 -->
|
||||||
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open" >
|
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open" >
|
||||||
@ -67,7 +67,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
labelWidth: "100px",
|
labelWidth: "100px",
|
||||||
formLabelWidth:"100px",
|
formLabelWidth:"100px",
|
||||||
// 选中数组
|
// 选中{primaryKey}数组
|
||||||
ids: [],
|
ids: [],
|
||||||
// 非单个禁用
|
// 非单个禁用
|
||||||
single: true,
|
single: true,
|
||||||
@ -129,7 +129,7 @@ export default {
|
|||||||
reset() {
|
reset() {
|
||||||
this.form = {
|
this.form = {
|
||||||
{VueViewEditFormContent}
|
{VueViewEditFormContent}
|
||||||
//需个性化处理内容
|
//TODO 根据实际内容调整
|
||||||
};
|
};
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
@ -142,6 +142,7 @@ export default {
|
|||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
//TODO 重置字段
|
//TODO 重置字段
|
||||||
};
|
};
|
||||||
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
|
|||||||
@ -72,7 +72,7 @@ namespace ZR.CodeGenerator
|
|||||||
public static string[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "delFlag" };
|
public static string[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "delFlag" };
|
||||||
|
|
||||||
/** 页面不需要显示的列表字段 */
|
/** 页面不需要显示的列表字段 */
|
||||||
public static string[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "delFlag", "update_by",
|
public static string[] COLUMNNAME_NOT_LIST = { "create_by", "create_time", "delFlag", "update_by",
|
||||||
"update_time" , "password"};
|
"update_time" , "password"};
|
||||||
|
|
||||||
/** 页面不需要查询字段 */
|
/** 页面不需要查询字段 */
|
||||||
|
|||||||
@ -9,7 +9,7 @@ namespace ZR.CodeGenerator.Model
|
|||||||
public class GenerateDto
|
public class GenerateDto
|
||||||
{
|
{
|
||||||
public long TableId { get; set; }
|
public long TableId { get; set; }
|
||||||
public string[] queryColumn { get; set; }
|
public string[] QueryColumn { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -17,7 +17,7 @@ namespace ZR.CodeGenerator.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 项目命名空间
|
/// 项目命名空间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string baseSpace { get; set; }
|
//public string baseSpace { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 要生成代码的表
|
/// 要生成代码的表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -43,7 +43,19 @@ namespace ZR.CodeGenerator.Model
|
|||||||
//public string VuePath { get; set; }
|
//public string VuePath { get; set; }
|
||||||
//public string VueApiPath { get; set; }
|
//public string VueApiPath { get; set; }
|
||||||
|
|
||||||
public string ParentPath { get; set; } = "..";
|
//public string ParentPath { get; set; } = "..";
|
||||||
|
/// <summary>
|
||||||
|
/// 代码生成路径
|
||||||
|
/// </summary>
|
||||||
|
public string GenCodePath { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 代码生成压缩包路径
|
||||||
|
/// </summary>
|
||||||
|
public string ZipPath { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 代码生成压缩包名称
|
||||||
|
/// </summary>
|
||||||
|
public string ZipFileName { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ export function queryColumnInfo(tableId) {
|
|||||||
// 查询表详细信息
|
// 查询表详细信息
|
||||||
export function getGenTable(params) {
|
export function getGenTable(params) {
|
||||||
return request({
|
return request({
|
||||||
url: 'tool/gen/getGenTable',
|
url: 'tool/gen/listGenTable',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: params
|
params: params
|
||||||
})
|
})
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export const constantRoutes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/demo',
|
path: '/demo',
|
||||||
component: (resolve) => require(['@/views/userInfo/index'], resolve),
|
component: (resolve) => require(['@/views/gendemo/index'], resolve),
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import request from '@/utils/request'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
|
|
||||||
const mimeMap = {
|
const mimeMap = {
|
||||||
@ -9,9 +10,9 @@ const mimeMap = {
|
|||||||
const baseUrl = process.env.VUE_APP_BASE_API
|
const baseUrl = process.env.VUE_APP_BASE_API
|
||||||
export function downLoadZip(str, filename) {
|
export function downLoadZip(str, filename) {
|
||||||
var url = baseUrl + str
|
var url = baseUrl + str
|
||||||
axios({
|
request({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: url,
|
url: str,
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
headers: { 'Token': getToken() }
|
headers: { 'Token': getToken() }
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@ -40,7 +41,7 @@ export function resolveBlob(res, mimeType) {
|
|||||||
|
|
||||||
// //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
|
// //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
|
||||||
var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
|
var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
|
||||||
var contentDisposition = decodeURI(res.headers['content-disposition'])
|
var contentDisposition = decodeURI(res.headers['Content-disposition'])
|
||||||
var result = patt.exec(contentDisposition)
|
var result = patt.exec(contentDisposition)
|
||||||
var fileName = result[1]
|
var fileName = result[1]
|
||||||
fileName = fileName.replace(/\"/g, '')
|
fileName = fileName.replace(/\"/g, '')
|
||||||
@ -68,3 +69,23 @@ export function resolveExcel(res, fileName) {
|
|||||||
// 5.释放这个临时的对象url
|
// 5.释放这个临时的对象url
|
||||||
// window.URL.revokeObjectURL(aLink.href);
|
// window.URL.revokeObjectURL(aLink.href);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载文件调用
|
||||||
|
* @param 接口返回数据 文件名
|
||||||
|
*/
|
||||||
|
export function downloadFile(resUrl, fileName) {
|
||||||
|
if (!resUrl) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 创建下载链接
|
||||||
|
const url = resUrl
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.style.display = 'none'
|
||||||
|
link.href = url
|
||||||
|
link.setAttribute('download', fileName)// 文件名
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
document.body.removeChild(link) // 下载完成移除元素
|
||||||
|
window.URL.revokeObjectURL(url) // 释放掉blob对象
|
||||||
|
}
|
||||||
|
|||||||
@ -2,23 +2,6 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
|
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
|
||||||
<el-form :model="queryParams" label-position="left" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
|
<el-form :model="queryParams" label-position="left" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
|
||||||
<el-form-item label="文本文字">
|
|
||||||
<el-input v-model="queryParams.xxx" placeholder="" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="数字">
|
|
||||||
<el-input v-model.number="queryParams.xxx" placeholder="" />
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="下拉框">
|
|
||||||
<el-select v-model="queryParams.xxx" placeholder="">
|
|
||||||
<el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="时间范围">
|
|
||||||
<el-date-picker size="small" style="width: 240px" v-model="timeRange" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期">
|
|
||||||
</el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-row class="mb8" style="text-align:center">
|
<el-row class="mb8" style="text-align:center">
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
@ -43,49 +26,55 @@
|
|||||||
<!-- 数据区域 -->
|
<!-- 数据区域 -->
|
||||||
<el-table :data="dataList" ref="table" border @selection-change="handleSelectionChange">
|
<el-table :data="dataList" ref="table" border @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="50" />
|
<el-table-column type="selection" width="50" />
|
||||||
<el-table-column prop="id" label="自增id" align="center" width="100" />
|
<el-table-column prop="id" label="自增id" align="center" />
|
||||||
<el-table-column prop="name" label="名称" align="center" width="100" :show-overflow-tooltip="true" />
|
<el-table-column prop="name" label="名称" align="center" :show-overflow-tooltip="true" />
|
||||||
<el-table-column prop="icon" label="图片">
|
<el-table-column prop="icon" label="图片">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-image class="table-td-thumb" :src="scope.row.icon" :preview-src-list="[scope.row.icon]"></el-image>
|
<el-image class="table-td-thumb" :src="scope.row.icon" :preview-src-list="[scope.row.icon]"></el-image>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="showStatus" label="显示状态" align="center" width="100" />
|
<el-table-column prop="showStatus" label="显示状态" align="center" />
|
||||||
<el-table-column prop="addTime" label="添加时间" align="center" width="100" />
|
<el-table-column prop="addTime" label="添加时间" align="center" />
|
||||||
|
<el-table-column prop="sex" label="用户性别" align="center" :formatter="sexFormat" />
|
||||||
|
<el-table-column prop="sort" label="排序" align="center" />
|
||||||
|
|
||||||
<el-table-column label="操作" align="center" width="200">
|
<el-table-column label="操作" align="center" width="200">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini" v-hasPermi="['gendemo:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
|
<el-button v-hasPermi="['gendemo:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
|
||||||
<el-popconfirm title="确定删除吗?" @onConfirm="handleDelete(scope.row)" style="margin-left:10px">
|
<el-popconfirm title="确定删除吗?" @confirm="handleDelete(scope.row)" style="margin-left:10px">
|
||||||
<el-button slot="reference" v-hasPermi="['gendemo:delete']" size="mini" type="text" icon="el-icon-delete">删除</el-button>
|
<el-button slot="reference" v-hasPermi="['gendemo:delete']" type="text" icon="el-icon-delete">删除</el-button>
|
||||||
</el-popconfirm>
|
</el-popconfirm>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<el-pagination class="mt10" background :total="total" :current-page.sync="queryParams.pageNum" layout="total, sizes, prev, pager, next, jumper" :page-size="queryParams.pageSize" :page-sizes="[20, 30, 50, 100]" @size-change="handleSizeChange"
|
<pagination class="mt10" background :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||||
@current-change="getList" />
|
|
||||||
|
|
||||||
<!-- 添加或修改菜单对话框 -->
|
<!-- 添加或修改菜单对话框 -->
|
||||||
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open">
|
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open">
|
||||||
<el-form ref="form" :model="form" :rules="rules" :label-width="formLabelWidth">
|
<el-form ref="form" :model="form" :rules="rules" :label-width="formLabelWidth">
|
||||||
<el-form-item label="自增id" :label-width="labelWidth" prop="id">
|
|
||||||
<el-input v-model="form.id" placeholder="" :disabled="true" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="名称" :label-width="labelWidth" prop="name">
|
<el-form-item label="名称" :label-width="labelWidth" prop="name">
|
||||||
<el-input v-model="form.name" placeholder="请输入名称" />
|
<el-input v-model="form.name" placeholder="请输入名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="图片" :label-width="labelWidth" prop="icon">
|
<el-form-item label="图片" :label-width="labelWidth" prop="icon">
|
||||||
<el-upload class="avatar-uploader" name="file" action="/api/upload/saveFile/" :show-file-list="false" :on-success="handleUploadiconSuccess" :before-upload="beforeFileUpload">
|
<el-upload class="avatar-uploader" name="file" action="/api/upload/saveFile/" :show-file-list="false" :on-success="handleUploadIconSuccess" :before-upload="beforeFileUpload">
|
||||||
<img v-if="form.icon" :src="form.icon" class="icon">
|
<img v-if="form.icon" :src="form.icon" class="icon">
|
||||||
<i v-else class="el-icon-plus uploader-icon"></i>
|
<i v-else class="el-icon-plus uploader-icon"></i>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<el-input v-model="form.icon" placeholder="请上传文件或手动输入文件地址"></el-input>
|
<el-input v-model="form.icon" placeholder="请上传文件或手动输入文件地址"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="显示状态" :label-width="labelWidth" prop="showStatus">
|
<el-form-item label="显示状态" :label-width="labelWidth" prop="showStatus">
|
||||||
<el-input v-model="form.showStatus" placeholder="请输入显示状态" />
|
<el-radio-group v-model="form.showStatus">
|
||||||
|
<el-radio :key="1" :label="1">是</el-radio>
|
||||||
|
<el-radio :key="0" :label="0">否</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="添加时间" :label-width="labelWidth" prop="addTime">
|
<el-form-item label="用户性别" :label-width="labelWidth" prop="sex">
|
||||||
<el-date-picker v-model="form.addTime" type="datetime" placeholder="选择日期时间" default-time="12:00:00"> </el-date-picker>
|
<el-select v-model="form.sex">
|
||||||
|
<el-option v-for="item in sexOptions" :key="item.dictValue" :label="item.dictLabel" :value="parseInt(item.dictValue)"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序" :label-width="labelWidth" prop="sort">
|
||||||
|
<el-input v-model.number="form.sort" placeholder="请输入排序" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -112,7 +101,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
labelWidth: "100px",
|
labelWidth: "100px",
|
||||||
formLabelWidth: "100px",
|
formLabelWidth: "100px",
|
||||||
// 选中数组
|
// 选中id数组
|
||||||
ids: [],
|
ids: [],
|
||||||
// 非单个禁用
|
// 非单个禁用
|
||||||
single: true,
|
single: true,
|
||||||
@ -132,8 +121,8 @@ export default {
|
|||||||
form: {},
|
form: {},
|
||||||
// 时间范围数组
|
// 时间范围数组
|
||||||
timeRange: [],
|
timeRange: [],
|
||||||
// xxx下拉框
|
// 用户性别选项列表
|
||||||
statusOptions: [],
|
sexOptions: [],
|
||||||
// 数据列表
|
// 数据列表
|
||||||
dataList: [],
|
dataList: [],
|
||||||
// 总记录数
|
// 总记录数
|
||||||
@ -142,6 +131,7 @@ export default {
|
|||||||
btnSubmitVisible: true,
|
btnSubmitVisible: true,
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
|
id: [{ type: "number", message: "id必须为数字值", trigger: "blur" }],
|
||||||
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
||||||
showStatus: [
|
showStatus: [
|
||||||
{ required: true, message: "请输入显示状态", trigger: "blur" },
|
{ required: true, message: "请输入显示状态", trigger: "blur" },
|
||||||
@ -156,6 +146,9 @@ export default {
|
|||||||
// this.getDicts("sys_normal_disable").then((response) => {
|
// this.getDicts("sys_normal_disable").then((response) => {
|
||||||
// this.statusOptions = response.data;
|
// this.statusOptions = response.data;
|
||||||
// });
|
// });
|
||||||
|
this.getDicts("sys_user_sex").then((response) => {
|
||||||
|
this.sexOptions = response.data;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 查询数据
|
// 查询数据
|
||||||
@ -178,13 +171,14 @@ export default {
|
|||||||
// 重置数据表单
|
// 重置数据表单
|
||||||
reset() {
|
reset() {
|
||||||
this.form = {
|
this.form = {
|
||||||
id: undefined,
|
|
||||||
name: undefined,
|
name: undefined,
|
||||||
icon: undefined,
|
icon: undefined,
|
||||||
showStatus: undefined,
|
showStatus: undefined,
|
||||||
addTime: undefined,
|
addTime: undefined,
|
||||||
|
sex: undefined,
|
||||||
|
sort: undefined,
|
||||||
|
|
||||||
//需个性化处理内容
|
//TODO 根据实际内容调整
|
||||||
};
|
};
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
@ -197,6 +191,7 @@ export default {
|
|||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
//TODO 重置字段
|
//TODO 重置字段
|
||||||
};
|
};
|
||||||
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
@ -222,7 +217,8 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
delGendemo(row.id).then((res) => {
|
const ids = row.id || this.ids;
|
||||||
|
delGendemo(ids.toString()).then((res) => {
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess("删除成功");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
});
|
});
|
||||||
@ -241,10 +237,14 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeFileUpload(file) {},
|
beforeFileUpload(file) {},
|
||||||
//文件上传成功方法
|
//文件上传成功方法
|
||||||
handleUploadiconSuccess(res, file) {
|
handleUploadIconSuccess(res, file) {
|
||||||
this.form.icon = URL.createObjectURL(file.raw);
|
this.form.icon = URL.createObjectURL(file.raw);
|
||||||
// this.$refs.upload.clearFiles();
|
// this.$refs.upload.clearFiles();
|
||||||
},
|
},
|
||||||
|
// 用户性别字典翻译
|
||||||
|
sexFormat(row, column) {
|
||||||
|
return this.selectDictLabel(this.sexOptions, row.sex);
|
||||||
|
},
|
||||||
|
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm: function () {
|
submitForm: function () {
|
||||||
@ -274,6 +274,5 @@ export default {
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.table-td-thumb {
|
.table-td-thumb {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
height: 100%;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -35,11 +35,7 @@
|
|||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button type="text" icon="el-icon-view" @click="handlePreview()">预览</el-button>
|
<el-button type="text" icon="el-icon-view" @click="handlePreview()">预览</el-button>
|
||||||
<el-button type="text" icon="el-icon-edit" @click="handleEditTable(scope.row)">编辑</el-button>
|
<el-button type="text" icon="el-icon-edit" @click="handleEditTable(scope.row)">编辑</el-button>
|
||||||
|
<el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['tool:gen:delete']">删除</el-button>
|
||||||
<el-popconfirm title="确定删除吗?" @confirm="handleDelete(scope.row)" style="margin-left:10px">
|
|
||||||
<el-button slot="reference" v-hasPermi="['tool:gen:delete']" size="mini" type="text" icon="el-icon-delete">删除</el-button>
|
|
||||||
</el-popconfirm>
|
|
||||||
|
|
||||||
<el-button type="text" icon="el-icon-download" @click="handleShowDialog(scope.row)" v-hasPermi="['tool:gen:code']">生成代码</el-button>
|
<el-button type="text" icon="el-icon-download" @click="handleShowDialog(scope.row)" v-hasPermi="['tool:gen:code']">生成代码</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -77,7 +73,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { codeGenerator, getGenTable, delTable } from "@/api/tool/gen";
|
import { codeGenerator, getGenTable, delTable } from "@/api/tool/gen";
|
||||||
import { downLoadZip } from "@/utils/zipdownload.js";
|
import { downLoadZip, downloadFile } from "@/utils/zipdownload.js";
|
||||||
|
|
||||||
import importTable from "./importTable";
|
import importTable from "./importTable";
|
||||||
import { Loading } from "element-ui";
|
import { Loading } from "element-ui";
|
||||||
@ -192,7 +188,11 @@ export default {
|
|||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
this.showGenerate = false;
|
this.showGenerate = false;
|
||||||
this.msgSuccess("恭喜你,代码生成完成!");
|
this.msgSuccess("恭喜你,代码生成完成!");
|
||||||
downLoadZip(data.zipPath, '');
|
// downLoadZip(data.zipPath, '');
|
||||||
|
downloadFile(
|
||||||
|
process.env.VUE_APP_BASE_API + data.zipPath,
|
||||||
|
data.fileName
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.msgError(res.msg);
|
this.msgError(res.msg);
|
||||||
}
|
}
|
||||||
@ -206,21 +206,6 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* 选择每页显示数量
|
|
||||||
*/
|
|
||||||
// handleSizeChange(val) {
|
|
||||||
// this.pagination.pagesize = val;
|
|
||||||
// this.pagination.pageNum = 1;
|
|
||||||
// this.loadTableData();
|
|
||||||
// },
|
|
||||||
/**
|
|
||||||
* 选择当页面
|
|
||||||
*/
|
|
||||||
// handleCurrentChange(val) {
|
|
||||||
// this.pagination.pageNum = val;
|
|
||||||
// this.loadTableData();
|
|
||||||
// },
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.showGenerate = false;
|
this.showGenerate = false;
|
||||||
this.currentSelected = {};
|
this.currentSelected = {};
|
||||||
@ -231,6 +216,12 @@ export default {
|
|||||||
},
|
},
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const tableIds = row.tableId || this.tableIds;
|
const tableIds = row.tableId || this.tableIds;
|
||||||
|
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning",
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
delTable(tableIds.toString()).then((res) => {
|
delTable(tableIds.toString()).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess("删除成功");
|
||||||
@ -238,6 +229,13 @@ export default {
|
|||||||
this.handleSearch();
|
this.handleSearch();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
type: "info",
|
||||||
|
message: "已取消删除",
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
handleSelectionChange(section) {
|
handleSelectionChange(section) {
|
||||||
this.tableIds = section.map((item) => item.tableId);
|
this.tableIds = section.map((item) => item.tableId);
|
||||||
|
|||||||
@ -97,9 +97,9 @@
|
|||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.GetGenTable(System.String,ZR.Model.PagerInfo)">
|
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.GetGenTable(System.String,ZR.Model.PagerInfo)">
|
||||||
<summary>
|
<summary>
|
||||||
获取表详细信息
|
获取代码生成表列表
|
||||||
</summary>
|
</summary>
|
||||||
<param name="tableName"></param>
|
<param name="tableName">表名</param>
|
||||||
<param name="pagerInfo">分页信息</param>
|
<param name="pagerInfo">分页信息</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
@ -107,7 +107,7 @@
|
|||||||
<summary>
|
<summary>
|
||||||
查询表字段列表
|
查询表字段列表
|
||||||
</summary>
|
</summary>
|
||||||
<param name="tableId"></param>
|
<param name="tableId">genTable表id</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.Remove(System.String)">
|
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.Remove(System.String)">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user