优化代码生成
This commit is contained in:
parent
e3d9b8103b
commit
59b44b3928
@ -16,7 +16,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
public static string TIME_FORMAT_FULL = "yyyy-MM-dd HH:mm:ss";
|
public static string TIME_FORMAT_FULL = "yyyy-MM-dd HH:mm:ss";
|
||||||
public static string TIME_FORMAT_FULL_2 = "MM-dd HH:mm:ss";
|
public static string TIME_FORMAT_FULL_2 = "MM-dd HH:mm:ss";
|
||||||
|
|
||||||
protected IActionResult SUCCESS(object data, string timeFormatStr = "MM-dd HH:mm:ss")
|
protected IActionResult SUCCESS(object data, string timeFormatStr = "yyyy-MM-dd HH:mm:ss")
|
||||||
{
|
{
|
||||||
string jsonStr = GetJsonStr(GetApiResult(data != null ? ResultCode.SUCCESS : ResultCode.FAIL, data), timeFormatStr);
|
string jsonStr = GetJsonStr(GetApiResult(data != null ? ResultCode.SUCCESS : ResultCode.FAIL, data), timeFormatStr);
|
||||||
return Content(jsonStr, "application/json");
|
return Content(jsonStr, "application/json");
|
||||||
@ -34,13 +34,13 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
/// <param name="apiResult"></param>
|
/// <param name="apiResult"></param>
|
||||||
/// <param name="timeFormatStr"></param>
|
/// <param name="timeFormatStr"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected IActionResult OutputJson(ApiResult apiResult, string timeFormatStr = "MM-dd HH:mm:ss")
|
protected IActionResult OutputJson(ApiResult apiResult, string timeFormatStr = "yyyy-MM-dd HH:mm:ss")
|
||||||
{
|
{
|
||||||
string jsonStr = GetJsonStr(apiResult, timeFormatStr);
|
string jsonStr = GetJsonStr(apiResult, timeFormatStr);
|
||||||
|
|
||||||
return Content(jsonStr, "application/json");
|
return Content(jsonStr, "application/json");
|
||||||
}
|
}
|
||||||
protected IActionResult OutputJson(long rows, string timeFormatStr = "MM-dd HH:mm:ss")
|
protected IActionResult OutputJson(long rows, string timeFormatStr = "yyyy-MM-dd HH:mm:ss")
|
||||||
{
|
{
|
||||||
string jsonStr = GetJsonStr(ToJson(rows), timeFormatStr);
|
string jsonStr = GetJsonStr(ToJson(rows), timeFormatStr);
|
||||||
|
|
||||||
|
|||||||
138
ZR.Admin.WebApi/Controllers/business/GendemoController.cs
Normal file
138
ZR.Admin.WebApi/Controllers/business/GendemoController.cs
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ZR.Admin.WebApi.Filters;
|
||||||
|
using ZR.Admin.WebApi.Controllers;
|
||||||
|
using ZR.Service.Business;
|
||||||
|
using SqlSugar;
|
||||||
|
using Infrastructure;
|
||||||
|
using Infrastructure.Attribute;
|
||||||
|
using Infrastructure.Enums;
|
||||||
|
using Infrastructure.Model;
|
||||||
|
using Mapster;
|
||||||
|
using ZR.Admin.WebApi.Extensions;
|
||||||
|
using ZR.Model.Dto;
|
||||||
|
using ZR.Model.Models;
|
||||||
|
|
||||||
|
namespace ZRAdmin.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 代码自动生成
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
//[Verify]
|
||||||
|
[Route("bus/gendemo")]
|
||||||
|
public class GendemoController : BaseController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接口
|
||||||
|
/// </summary>
|
||||||
|
private readonly IGendemoService _GendemoService;
|
||||||
|
|
||||||
|
public GendemoController(IGendemoService GendemoService)
|
||||||
|
{
|
||||||
|
_GendemoService = GendemoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("list")]
|
||||||
|
[ActionPermissionFilter(Permission = "gendemo:list")]
|
||||||
|
public IActionResult Query([FromQuery] GendemoQueryDto parm)
|
||||||
|
{
|
||||||
|
//开始拼装查询条件
|
||||||
|
var predicate = Expressionable.Create<Gendemo>();
|
||||||
|
|
||||||
|
//TODO 搜索条件
|
||||||
|
//predicate = predicate.And(m => m.Name.Contains(parm.Name));
|
||||||
|
|
||||||
|
var response = _GendemoService.GetPages(predicate.ToExpression(), parm);
|
||||||
|
|
||||||
|
return SUCCESS(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询详情
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{Id}")]
|
||||||
|
[ActionPermissionFilter(Permission = "gendemo:query")]
|
||||||
|
public IActionResult Get(int Id)
|
||||||
|
{
|
||||||
|
var response = _GendemoService.GetId(Id);
|
||||||
|
|
||||||
|
return SUCCESS(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[ActionPermissionFilter(Permission = "gendemo:add")]
|
||||||
|
[Log(Title = "添加", BusinessType = BusinessType.INSERT)]
|
||||||
|
public IActionResult Create([FromBody] GendemoDto parm)
|
||||||
|
{
|
||||||
|
if (parm == null)
|
||||||
|
{
|
||||||
|
throw new CustomException("请求参数错误");
|
||||||
|
}
|
||||||
|
//从 Dto 映射到 实体
|
||||||
|
var addModel = parm.Adapt<Gendemo>().ToCreate();
|
||||||
|
//addModel.CreateID = User.Identity.Name;
|
||||||
|
|
||||||
|
return SUCCESS(_GendemoService.Add(addModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut]
|
||||||
|
[ActionPermissionFilter(Permission = "gendemo:update")]
|
||||||
|
[Log(Title = "修改", BusinessType = BusinessType.UPDATE)]
|
||||||
|
public IActionResult Update([FromBody] GendemoDto parm)
|
||||||
|
{
|
||||||
|
if (parm == null)
|
||||||
|
{
|
||||||
|
throw new CustomException("请求实体不能为空");
|
||||||
|
}
|
||||||
|
//从 Dto 映射到 实体
|
||||||
|
var updateModel = parm.Adapt<Gendemo>().ToCreate();
|
||||||
|
//updateModel.CreateID = User.Identity.Name;
|
||||||
|
|
||||||
|
var response = _GendemoService.Update(w => w.Id == updateModel.Id, it => new Gendemo()
|
||||||
|
{
|
||||||
|
//TODO 字段映射
|
||||||
|
Name = parm.Name,
|
||||||
|
Icon = parm.Icon,
|
||||||
|
ShowStatus = parm.ShowStatus,
|
||||||
|
AddTime = parm.AddTime,
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return SUCCESS(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("{Id}")]
|
||||||
|
[ActionPermissionFilter(Permission = "gendemo:delete")]
|
||||||
|
[Log(Title = "删除", BusinessType = BusinessType.DELETE)]
|
||||||
|
public IActionResult Delete(int Id = 0)
|
||||||
|
{
|
||||||
|
if (Id <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
var response = _GendemoService.Delete(Id);
|
||||||
|
|
||||||
|
return SUCCESS(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<el-button type="primary" v-hasPermi="['{Permission}:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
|
<el-button type="primary" v-hasPermi="['{Permission}:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="success" v-hasPermi="['{Permission}:update']" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
|
<el-button type="success" :disabled="single" v-hasPermi="['{Permission}:update']" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="danger" v-hasPermi="['{Permission}:delete']" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
|
<el-button type="danger" v-hasPermi="['{Permission}:delete']" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
|
||||||
@ -53,7 +53,7 @@
|
|||||||
</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]" @size-change="handleSizeChange" @current-change="getList" />
|
<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" />
|
||||||
|
|
||||||
<!-- 添加或修改菜单对话框 -->
|
<!-- 添加或修改菜单对话框 -->
|
||||||
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open" >
|
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open" >
|
||||||
@ -232,14 +232,4 @@ export default {
|
|||||||
.table-td-thumb {
|
.table-td-thumb {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
}
|
}
|
||||||
.icon {
|
|
||||||
width: 100px;
|
|
||||||
}
|
|
||||||
.uploader-icon {
|
|
||||||
width: 50px;
|
|
||||||
height: 50px;
|
|
||||||
line-height: 50px;
|
|
||||||
border: 1px dashed #ccc;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
26
ZR.Model/Dto/GendemoDto.cs
Normal file
26
ZR.Model/Dto/GendemoDto.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using ZR.Model.Dto;
|
||||||
|
using ZR.Model.Models;
|
||||||
|
|
||||||
|
namespace ZR.Model.Dto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 输入对象模型
|
||||||
|
/// </summary>
|
||||||
|
public class GendemoDto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Icon { get; set; }
|
||||||
|
public int? ShowStatus { get; set; }
|
||||||
|
public DateTime? AddTime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GendemoQueryDto: PagerInfo
|
||||||
|
{
|
||||||
|
public DateTime? BeginTime { get; set; }
|
||||||
|
public DateTime? EndTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
45
ZR.Model/Models/Gendemo.cs
Normal file
45
ZR.Model/Models/Gendemo.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ZR.Model.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ,数据实体对象
|
||||||
|
/// </summary>
|
||||||
|
[SqlSugar.SugarTable("gen_demo")]
|
||||||
|
public class Gendemo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :自增id
|
||||||
|
/// 空值 :False
|
||||||
|
/// 默认 :
|
||||||
|
/// </summary>
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int? Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :名称
|
||||||
|
/// 空值 :False
|
||||||
|
/// 默认 :
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :图片
|
||||||
|
/// 空值 :True
|
||||||
|
/// 默认 :
|
||||||
|
/// </summary>
|
||||||
|
public string Icon { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :显示状态
|
||||||
|
/// 空值 :False
|
||||||
|
/// 默认 :
|
||||||
|
/// </summary>
|
||||||
|
public int? ShowStatus { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :添加时间
|
||||||
|
/// 空值 :True
|
||||||
|
/// 默认 :
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? AddTime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
24
ZR.Repository/Repositories/GendemoRepository.cs
Normal file
24
ZR.Repository/Repositories/GendemoRepository.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using Infrastructure.Attribute;
|
||||||
|
using ZR.Repository.System;
|
||||||
|
using ZR.Model.Models;
|
||||||
|
|
||||||
|
namespace ZR.Repository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 仓储接口的实现
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class GendemoRepository : BaseRepository
|
||||||
|
{
|
||||||
|
public GendemoRepository()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 业务逻辑代码
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
28
ZR.Service/Business/GendemoService.cs
Normal file
28
ZR.Service/Business/GendemoService.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using Infrastructure;
|
||||||
|
using Infrastructure.Attribute;
|
||||||
|
using Infrastructure.Extensions;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using ZR.Common;
|
||||||
|
using ZR.Model.Models;
|
||||||
|
using ZR.Repository;
|
||||||
|
using ZR.Service.IService;
|
||||||
|
|
||||||
|
namespace ZR.Service.Business
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 服务接口实现
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceType = typeof(IGendemoService), ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class GendemoService: BaseService<Gendemo>, IGendemoService
|
||||||
|
{
|
||||||
|
private readonly GendemoRepository _repository;
|
||||||
|
public GendemoService(GendemoRepository repository)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
ZR.Service/Business/IBusService/IGendemoService.cs
Normal file
12
ZR.Service/Business/IBusService/IGendemoService.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using ZR.Model.Models;
|
||||||
|
|
||||||
|
namespace ZR.Service.Business
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 定义服务接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IGendemoService: IBaseService<Gendemo>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,7 +21,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@riophae/vue-treeselect": "0.4.0",
|
"@riophae/vue-treeselect": "0.4.0",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.4",
|
||||||
"clipboard": "2.0.4",
|
"clipboard": "2.0.4",
|
||||||
"core-js": "3.6.5",
|
"core-js": "3.6.5",
|
||||||
"echarts": "^5.1.1",
|
"echarts": "^5.1.1",
|
||||||
|
|||||||
59
ZR.Vue/src/api/gendemo.js
Normal file
59
ZR.Vue/src/api/gendemo.js
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param {查询条件} data
|
||||||
|
*/
|
||||||
|
export function listGendemo(data) {
|
||||||
|
return request({
|
||||||
|
url: '/bus/Gendemo/list',
|
||||||
|
method: 'get',
|
||||||
|
params: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export function addGendemo(data) {
|
||||||
|
return request({
|
||||||
|
url: '/bus/Gendemo',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export function updateGendemo(data) {
|
||||||
|
return request({
|
||||||
|
url: '/bus/Gendemo',
|
||||||
|
method: 'PUT',
|
||||||
|
data: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取详情
|
||||||
|
* @param {Id} Id
|
||||||
|
*/
|
||||||
|
export function getGendemo(id) {
|
||||||
|
return request({
|
||||||
|
url: '/bus/Gendemo/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @param {主键} pid
|
||||||
|
*/
|
||||||
|
export function delGendemo(pid) {
|
||||||
|
return request({
|
||||||
|
url: '/bus/Gendemo/' + pid,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -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
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
279
ZR.Vue/src/views/gendemo/index.vue
Normal file
279
ZR.Vue/src/views/gendemo/index.vue
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<!-- :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-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-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 工具区域 -->
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" v-hasPermi="['gendemo:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="success" :disabled="single" v-hasPermi="['gendemo:update']" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" v-hasPermi="['gendemo:delete']" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 数据区域 -->
|
||||||
|
<el-table :data="dataList" ref="table" border @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="50" />
|
||||||
|
<el-table-column prop="id" label="自增id" align="center" width="100" />
|
||||||
|
<el-table-column prop="name" label="名称" align="center" width="100" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column prop="icon" label="图片">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-image class="table-td-thumb" :src="scope.row.icon" :preview-src-list="[scope.row.icon]"></el-image>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="showStatus" label="显示状态" align="center" width="100" />
|
||||||
|
<el-table-column prop="addTime" label="添加时间" align="center" width="100" />
|
||||||
|
|
||||||
|
<el-table-column label="操作" align="center" width="200">
|
||||||
|
<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-popconfirm title="确定删除吗?" @onConfirm="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-popconfirm>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</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"
|
||||||
|
@current-change="getList" />
|
||||||
|
|
||||||
|
<!-- 添加或修改菜单对话框 -->
|
||||||
|
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open">
|
||||||
|
<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-input v-model="form.name" placeholder="请输入名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<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">
|
||||||
|
<img v-if="form.icon" :src="form.icon" class="icon">
|
||||||
|
<i v-else class="el-icon-plus uploader-icon"></i>
|
||||||
|
</el-upload>
|
||||||
|
<el-input v-model="form.icon" placeholder="请上传文件或手动输入文件地址"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="显示状态" :label-width="labelWidth" prop="showStatus">
|
||||||
|
<el-input v-model="form.showStatus" placeholder="请输入显示状态" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="添加时间" :label-width="labelWidth" prop="addTime">
|
||||||
|
<el-date-picker v-model="form.addTime" type="datetime" placeholder="选择日期时间" default-time="12:00:00"> </el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer" v-if="btnSubmitVisible">
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
listGendemo,
|
||||||
|
addGendemo,
|
||||||
|
delGendemo,
|
||||||
|
updateGendemo,
|
||||||
|
getGendemo,
|
||||||
|
} from "@/api/gendemo.js";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Gendemo",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
labelWidth: "100px",
|
||||||
|
formLabelWidth: "100px",
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {},
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 时间范围数组
|
||||||
|
timeRange: [],
|
||||||
|
// xxx下拉框
|
||||||
|
statusOptions: [],
|
||||||
|
// 数据列表
|
||||||
|
dataList: [],
|
||||||
|
// 总记录数
|
||||||
|
total: 0,
|
||||||
|
// 提交按钮是否显示
|
||||||
|
btnSubmitVisible: true,
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
||||||
|
showStatus: [
|
||||||
|
{ required: true, message: "请输入显示状态", trigger: "blur" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// 列表数据查询
|
||||||
|
this.getList();
|
||||||
|
// 下拉框绑定
|
||||||
|
// this.getDicts("sys_normal_disable").then((response) => {
|
||||||
|
// this.statusOptions = response.data;
|
||||||
|
// });
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 查询数据
|
||||||
|
getList() {
|
||||||
|
console.log(JSON.stringify(this.queryParams));
|
||||||
|
listGendemo(this.addDateRange(this.queryParams, this.timeRange)).then(
|
||||||
|
(res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.dataList = res.data.result;
|
||||||
|
this.total = res.data.totalCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 重置数据表单
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
name: undefined,
|
||||||
|
icon: undefined,
|
||||||
|
showStatus: undefined,
|
||||||
|
addTime: undefined,
|
||||||
|
|
||||||
|
//需个性化处理内容
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 重置查询操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.timeRange = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.queryParams = {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
//TODO 重置字段
|
||||||
|
};
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map((item) => item.id);
|
||||||
|
this.single = selection.length != 1;
|
||||||
|
this.multiple = !selection.length;
|
||||||
|
},
|
||||||
|
/** 选择每页显示数量*/
|
||||||
|
handleSizeChange(val) {
|
||||||
|
this.queryParams.pageSize = val;
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加";
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
delGendemo(row.id).then((res) => {
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
this.handleQuery();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id || this.ids;
|
||||||
|
getGendemo(id).then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.form = res.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改数据";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeFileUpload(file) {},
|
||||||
|
//文件上传成功方法
|
||||||
|
handleUploadiconSuccess(res, file) {
|
||||||
|
this.form.icon = URL.createObjectURL(file.raw);
|
||||||
|
// this.$refs.upload.clearFiles();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm: function () {
|
||||||
|
this.$refs["form"].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
console.log(JSON.stringify(this.form));
|
||||||
|
|
||||||
|
if (this.form.id != undefined || this.title === "修改数据") {
|
||||||
|
updateGendemo(this.form).then((res) => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addGendemo(this.form).then((res) => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.table-td-thumb {
|
||||||
|
width: 80px;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
16
ZRAdmin.xml
16
ZRAdmin.xml
@ -920,42 +920,42 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<param name="services"></param>
|
<param name="services"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:ZRAdmin.Controllers.UserInfoController">
|
<member name="T:ZRAdmin.Controllers.GendemoController">
|
||||||
<summary>
|
<summary>
|
||||||
代码自动生成
|
代码自动生成
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="F:ZRAdmin.Controllers.UserInfoController._UserInfoService">
|
<member name="F:ZRAdmin.Controllers.GendemoController._GendemoService">
|
||||||
<summary>
|
<summary>
|
||||||
接口
|
接口
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZRAdmin.Controllers.UserInfoController.Query(ZR.Model.Dto.UserInfoQueryDto)">
|
<member name="M:ZRAdmin.Controllers.GendemoController.Query(ZR.Model.Dto.GendemoQueryDto)">
|
||||||
<summary>
|
<summary>
|
||||||
查询列表
|
查询列表
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZRAdmin.Controllers.UserInfoController.Get(System.Int32)">
|
<member name="M:ZRAdmin.Controllers.GendemoController.Get(System.Int32)">
|
||||||
<summary>
|
<summary>
|
||||||
查询详情
|
查询详情
|
||||||
</summary>
|
</summary>
|
||||||
<param name="Luid"></param>
|
<param name="Id"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZRAdmin.Controllers.UserInfoController.Create(ZR.Model.Dto.UserInfoDto)">
|
<member name="M:ZRAdmin.Controllers.GendemoController.Create(ZR.Model.Dto.GendemoDto)">
|
||||||
<summary>
|
<summary>
|
||||||
添加
|
添加
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZRAdmin.Controllers.UserInfoController.Update(ZR.Model.Dto.UserInfoDto)">
|
<member name="M:ZRAdmin.Controllers.GendemoController.Update(ZR.Model.Dto.GendemoDto)">
|
||||||
<summary>
|
<summary>
|
||||||
更新
|
更新
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZRAdmin.Controllers.UserInfoController.Delete(System.Int32)">
|
<member name="M:ZRAdmin.Controllers.GendemoController.Delete(System.Int32)">
|
||||||
<summary>
|
<summary>
|
||||||
删除
|
删除
|
||||||
</summary>
|
</summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user