代码生成测试
This commit is contained in:
parent
2924004bbf
commit
73eb608139
118
ZR.Admin.WebApi/Controllers/Liveforum/T_UserLevelsController.cs
Normal file
118
ZR.Admin.WebApi/Controllers/Liveforum/T_UserLevelsController.cs
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.LiveForum.Model.Liveforum.Dto;
|
||||
using ZR.LiveForum.Model.Liveforum;
|
||||
using ZR.Service.Liveforum.ILiveforumService;
|
||||
|
||||
//创建时间:2025-11-15
|
||||
namespace ZR.Admin.WebApi.Controllers.Liveforum
|
||||
{
|
||||
/// <summary>
|
||||
/// 等级配置
|
||||
/// </summary>
|
||||
[Route("liveforum/tuserlevels")]
|
||||
public class T_UserLevelsController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 等级配置接口
|
||||
/// </summary>
|
||||
private readonly IT_UserLevelsService _T_UserLevelsService;
|
||||
|
||||
public T_UserLevelsController(IT_UserLevelsService T_UserLevelsService)
|
||||
{
|
||||
_T_UserLevelsService = T_UserLevelsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询等级配置列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
[ActionPermissionFilter(Permission = "tuserlevels:list")]
|
||||
public IActionResult QueryT_UserLevels([FromQuery] T_UserLevelsQueryDto parm)
|
||||
{
|
||||
var response = _T_UserLevelsService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询等级配置详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{Id}")]
|
||||
[ActionPermissionFilter(Permission = "tuserlevels:query")]
|
||||
public IActionResult GetT_UserLevels(int Id)
|
||||
{
|
||||
var response = _T_UserLevelsService.GetInfo(Id);
|
||||
|
||||
var info = response.Adapt<T_UserLevelsDto>();
|
||||
return SUCCESS(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加等级配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ActionPermissionFilter(Permission = "tuserlevels:add")]
|
||||
[Log(Title = "等级配置", BusinessType = BusinessType.INSERT)]
|
||||
public IActionResult AddT_UserLevels([FromBody] T_UserLevelsDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<T_UserLevels>().ToCreate(HttpContext);
|
||||
|
||||
var response = _T_UserLevelsService.AddT_UserLevels(modal);
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新等级配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[ActionPermissionFilter(Permission = "tuserlevels:edit")]
|
||||
[Log(Title = "等级配置", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult UpdateT_UserLevels([FromBody] T_UserLevelsDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<T_UserLevels>().ToUpdate(HttpContext);
|
||||
var response = _T_UserLevelsService.UpdateT_UserLevels(modal);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除等级配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("delete/{ids}")]
|
||||
[ActionPermissionFilter(Permission = "tuserlevels:delete")]
|
||||
[Log(Title = "等级配置", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult DeleteT_UserLevels([FromRoute]string ids)
|
||||
{
|
||||
var idArr = Tools.SplitAndConvert<int>(ids);
|
||||
|
||||
return ToResponse(_T_UserLevelsService.Delete(idArr));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出等级配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Log(Title = "等级配置", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||||
[HttpGet("export")]
|
||||
[ActionPermissionFilter(Permission = "tuserlevels:export")]
|
||||
public IActionResult Export([FromQuery] T_UserLevelsQueryDto parm)
|
||||
{
|
||||
var list = _T_UserLevelsService.ExportList(parm).Result;
|
||||
if (list == null || list.Count <= 0)
|
||||
{
|
||||
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
||||
}
|
||||
var result = ExportExcelMini(list, "等级配置", "等级配置");
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
<ProjectReference Include="..\ZR.Mall\ZR.Mall.csproj" />
|
||||
<ProjectReference Include="..\ZR.Service\ZR.Service.csproj" />
|
||||
<ProjectReference Include="..\ZR.Tasks\ZR.Tasks.csproj" />
|
||||
<ProjectReference Include="..\ZR.LiveForum.Model\ZR.LiveForum.Model.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Lazy.Captcha.Core" Version="2.0.9" />
|
||||
|
|
|
|||
7
ZR.LiveForum.Model/Class1.cs
Normal file
7
ZR.LiveForum.Model/Class1.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace ZR.LiveForum.Model
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
6
ZR.LiveForum.Model/GlobalUsing.cs
Normal file
6
ZR.LiveForum.Model/GlobalUsing.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
global using System.Collections.Generic;
|
||||
global using System;
|
||||
global using SqlSugar;
|
||||
global using Newtonsoft.Json;
|
||||
global using MiniExcelLibs.Attributes;
|
||||
global using System.ComponentModel.DataAnnotations;
|
||||
67
ZR.LiveForum.Model/Liveforum/Dto/T_UserLevelsDto.cs
Normal file
67
ZR.LiveForum.Model/Liveforum/Dto/T_UserLevelsDto.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
using ZR.Model;
|
||||
|
||||
namespace ZR.LiveForum.Model.Liveforum.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 等级配置查询对象
|
||||
/// </summary>
|
||||
public class T_UserLevelsQueryDto : PagerInfo
|
||||
{
|
||||
public string? LevelName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等级配置输入输出对象
|
||||
/// </summary>
|
||||
public class T_UserLevelsDto
|
||||
{
|
||||
[Required(ErrorMessage = "id不能为空")]
|
||||
[ExcelColumn(Name = "id")]
|
||||
[ExcelColumnName("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "名称不能为空")]
|
||||
[ExcelColumn(Name = "名称")]
|
||||
[ExcelColumnName("名称")]
|
||||
public string LevelName { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "等级图标")]
|
||||
[ExcelColumnName("等级图标")]
|
||||
public string LevelIcon { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "显示颜色")]
|
||||
[ExcelColumnName("显示颜色")]
|
||||
public string LevelColor { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "最小经验值")]
|
||||
[ExcelColumnName("最小经验值")]
|
||||
public int? MinExperience { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "最大经验值")]
|
||||
[ExcelColumnName("最大经验值")]
|
||||
public int? MaxExperience { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "特权配置")]
|
||||
[ExcelColumnName("特权配置")]
|
||||
public string Privileges { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "状态不能为空")]
|
||||
[ExcelColumn(Name = "状态")]
|
||||
[ExcelColumnName("状态")]
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "创建时间", Format = "yyyy-MM-dd HH:mm:ss", Width = 20)]
|
||||
[ExcelColumnName("创建时间")]
|
||||
public DateTime? CreatedAt { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "更新时间", Format = "yyyy-MM-dd HH:mm:ss", Width = 20)]
|
||||
[ExcelColumnName("更新时间")]
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
|
||||
|
||||
|
||||
[ExcelColumn(Name = "状态")]
|
||||
public string IsActiveLabel { get; set; }
|
||||
}
|
||||
}
|
||||
63
ZR.LiveForum.Model/Liveforum/T_UserLevels.cs
Normal file
63
ZR.LiveForum.Model/Liveforum/T_UserLevels.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
namespace ZR.LiveForum.Model.Liveforum
|
||||
{
|
||||
/// <summary>
|
||||
/// 等级配置
|
||||
/// </summary>
|
||||
[SugarTable("T_UserLevels")]
|
||||
[Tenant("2")]
|
||||
public class T_UserLevels
|
||||
{
|
||||
/// <summary>
|
||||
/// id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string LevelName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 等级图标
|
||||
/// </summary>
|
||||
public string LevelIcon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示颜色
|
||||
/// </summary>
|
||||
public string LevelColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小经验值
|
||||
/// </summary>
|
||||
public int? MinExperience { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大经验值
|
||||
/// </summary>
|
||||
public int? MaxExperience { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 特权配置
|
||||
/// </summary>
|
||||
public string Privileges { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
17
ZR.LiveForum.Model/ZR.LiveForum.Model.csproj
Normal file
17
ZR.LiveForum.Model/ZR.LiveForum.Model.csproj
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MiniExcel" Version="1.41.4" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.4.207" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -9,9 +9,4 @@
|
|||
<ProjectReference Include="..\Infrastructure\ZR.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\ZR.ServiceCore\ZR.ServiceCore.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Model\" />
|
||||
<Folder Include="Service\IService\" />
|
||||
<Folder Include="Enum\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure\ZR.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\ZR.LiveForum.Model\ZR.LiveForum.Model.csproj" />
|
||||
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
using ZR.LiveForum.Model.Liveforum.Dto;
|
||||
using ZR.LiveForum.Model.Liveforum;
|
||||
|
||||
namespace ZR.Service.Liveforum.ILiveforumService
|
||||
{
|
||||
/// <summary>
|
||||
/// 等级配置service接口
|
||||
/// </summary>
|
||||
public interface IT_UserLevelsService : IBaseService<T_UserLevels>
|
||||
{
|
||||
PagedInfo<T_UserLevelsDto> GetList(T_UserLevelsQueryDto parm);
|
||||
|
||||
T_UserLevels GetInfo(int Id);
|
||||
|
||||
|
||||
T_UserLevels AddT_UserLevels(T_UserLevels parm);
|
||||
int UpdateT_UserLevels(T_UserLevels parm);
|
||||
|
||||
|
||||
PagedInfo<T_UserLevelsDto> ExportList(T_UserLevelsQueryDto parm);
|
||||
}
|
||||
}
|
||||
103
ZR.Service/Liveforum/T_UserLevelsService.cs
Normal file
103
ZR.Service/Liveforum/T_UserLevelsService.cs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using ZR.LiveForum.Model.Liveforum.Dto;
|
||||
using ZR.LiveForum.Model.Liveforum;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.Liveforum.ILiveforumService;
|
||||
|
||||
namespace ZR.Service.Liveforum
|
||||
{
|
||||
/// <summary>
|
||||
/// 等级配置Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IT_UserLevelsService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class T_UserLevelsService : BaseService<T_UserLevels>, IT_UserLevelsService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询等级配置列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<T_UserLevelsDto> GetList(T_UserLevelsQueryDto parm)
|
||||
{
|
||||
var predicate = QueryExp(parm);
|
||||
|
||||
var response = Queryable()
|
||||
//.OrderBy("Id asc")
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<T_UserLevels, T_UserLevelsDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public T_UserLevels GetInfo(int Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加等级配置
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public T_UserLevels AddT_UserLevels(T_UserLevels model)
|
||||
{
|
||||
return Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改等级配置
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateT_UserLevels(T_UserLevels model)
|
||||
{
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出等级配置
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<T_UserLevelsDto> ExportList(T_UserLevelsQueryDto parm)
|
||||
{
|
||||
parm.PageNum = 1;
|
||||
parm.PageSize = 100000;
|
||||
var predicate = QueryExp(parm);
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.Select((it) => new T_UserLevelsDto()
|
||||
{
|
||||
IsActiveLabel = it.IsActive.GetConfigValue<Model.System.SysDictData>("sys_common_status"),
|
||||
}, true)
|
||||
.ToPage(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询导出表达式
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
private static Expressionable<T_UserLevels> QueryExp(T_UserLevelsQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<T_UserLevels>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LevelName), it => it.LevelName.Contains(parm.LevelName));
|
||||
return predicate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZR.Common\ZR.Common.csproj" />
|
||||
<ProjectReference Include="..\ZR.Repository\ZR.Repository.csproj" />
|
||||
<ProjectReference Include="..\ZR.LiveForum.Model\ZR.LiveForum.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
|
||||
<ProjectReference Include="..\ZR.Service\ZR.Service.csproj" />
|
||||
<ProjectReference Include="..\ZR.LiveForum.Model\ZR.LiveForum.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
62
ZR.Vue/src/api/liveforum/tuserlevels.js
Normal file
62
ZR.Vue/src/api/liveforum/tuserlevels.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import request from '@/utils/request'
|
||||
import { downFile } from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 等级配置分页查询
|
||||
* @param {查询条件} data
|
||||
*/
|
||||
export function listtuserlevels(query) {
|
||||
return request({
|
||||
url: 'liveforum/tuserlevels/list',
|
||||
method: 'get',
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增等级配置
|
||||
* @param data
|
||||
*/
|
||||
export function addtuserlevels(data) {
|
||||
return request({
|
||||
url: 'liveforum/tuserlevels',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 修改等级配置
|
||||
* @param data
|
||||
*/
|
||||
export function updatetuserlevels(data) {
|
||||
return request({
|
||||
url: 'liveforum/tuserlevels',
|
||||
method: 'PUT',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获取等级配置详情
|
||||
* @param {Id}
|
||||
*/
|
||||
export function gettuserlevels(id) {
|
||||
return request({
|
||||
url: 'liveforum/tuserlevels/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除等级配置
|
||||
* @param {主键} pid
|
||||
*/
|
||||
export function deltuserlevels(pid) {
|
||||
return request({
|
||||
url: 'liveforum/tuserlevels/delete/' + pid,
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
// 导出等级配置
|
||||
export async function exporttuserlevels(query) {
|
||||
await downFile('liveforum/tuserlevels/export', { ...query })
|
||||
}
|
||||
354
ZR.Vue/src/views/liveforum/tuserlevels.vue
Normal file
354
ZR.Vue/src/views/liveforum/tuserlevels.vue
Normal file
|
|
@ -0,0 +1,354 @@
|
|||
<!--
|
||||
* @Descripttion: (等级配置/T_UserLevels)
|
||||
* @Author: (admin)
|
||||
* @Date: (2025-11-15)
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch" @submit.prevent>
|
||||
<el-form-item label="名称" prop="levelName">
|
||||
<el-input v-model="queryParams.levelName" placeholder="请输入名称" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
|
||||
<el-button icon="refresh" @click="resetQuery">{{ $t('btn.reset') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 工具区域 -->
|
||||
<el-row :gutter="15" class="mb10">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" v-hasPermi="['tuserlevels:add']" plain icon="plus" @click="handleAdd">
|
||||
{{ $t('btn.add') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="download" @click="handleExport" v-hasPermi="['tuserlevels:export']">
|
||||
{{ $t('btn.export') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
:data="dataList"
|
||||
v-loading="loading"
|
||||
ref="table"
|
||||
border
|
||||
header-cell-class-name="el-table-header-cell"
|
||||
highlight-current-row
|
||||
@sort-change="sortChange"
|
||||
>
|
||||
<el-table-column prop="id" label="id" align="center" v-if="columns.showColumn('id')"/>
|
||||
<el-table-column prop="levelName" label="名称" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('levelName')"/>
|
||||
<el-table-column prop="levelIcon" label="等级图标" align="center" v-if="columns.showColumn('levelIcon')">
|
||||
<template #default="scope">
|
||||
<ImagePreview :src="scope.row.levelIcon"></ImagePreview>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="levelColor" label="显示颜色" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('levelColor')"/>
|
||||
<el-table-column prop="minExperience" label="最小经验值" align="center" v-if="columns.showColumn('minExperience')"/>
|
||||
<el-table-column prop="maxExperience" label="最大经验值" align="center" v-if="columns.showColumn('maxExperience')"/>
|
||||
<el-table-column prop="privileges" label="特权配置" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('privileges')"/>
|
||||
<el-table-column prop="isActive" label="状态" align="center" v-if="columns.showColumn('isActive')">
|
||||
<template #default="scope">
|
||||
<dict-tag :options=" options.sys_common_status " :value="scope.row.isActive" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdAt" label="创建时间" :show-overflow-tooltip="true" v-if="columns.showColumn('createdAt')"/>
|
||||
<el-table-column prop="updatedAt" label="更新时间" :show-overflow-tooltip="true" v-if="columns.showColumn('updatedAt')"/>
|
||||
<el-table-column label="操作" width="160">
|
||||
<template #default="scope">
|
||||
<el-button type="success" size="small" icon="edit" title="编辑" v-hasPermi="['tuserlevels:edit']" @click="handleUpdate(scope.row)"></el-button>
|
||||
<el-button type="danger" size="small" icon="delete" title="删除" v-hasPermi="['tuserlevels:delete']" @click="handleDelete(scope.row)"></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
|
||||
<el-dialog :title="title" :lock-scroll="false" v-model="open" >
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row :gutter="20">
|
||||
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="名称" prop="levelName">
|
||||
<el-input v-model="form.levelName" placeholder="请输入名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="等级图标" prop="levelIcon">
|
||||
<UploadImage v-model="form.levelIcon" :data="{ uploadType: 1 }" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="显示颜色" prop="levelColor">
|
||||
<el-color-picker v-model="form.levelColor" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="最小经验值" prop="minExperience">
|
||||
<el-input v-model.number="form.minExperience" placeholder="请输入最小经验值" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="最大经验值" prop="maxExperience">
|
||||
<el-input v-model.number="form.maxExperience" placeholder="请输入最大经验值" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="特权配置" prop="privileges">
|
||||
<el-input v-model="form.privileges" placeholder="请输入特权配置" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="状态" prop="isActive">
|
||||
<el-radio-group v-model="form.isActive">
|
||||
<el-radio v-for="item in options.sys_common_status" :key="item.dictValue" :value="item.dictValue">
|
||||
{{item.dictLabel}}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer v-if="opertype != 3">
|
||||
<el-button text @click="cancel">{{ $t('btn.cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="state.submitLoading" @click="submitForm">{{ $t('btn.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="tuserlevels">
|
||||
import { listtuserlevels,
|
||||
addtuserlevels, deltuserlevels,
|
||||
updatetuserlevels,gettuserlevels,
|
||||
}
|
||||
from '@/api/liveforum/tuserlevels.js'
|
||||
const { proxy } = getCurrentInstance()
|
||||
const ids = ref([])
|
||||
const loading = ref(false)
|
||||
const showSearch = ref(true)
|
||||
const queryParams = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
sort: 'Id',
|
||||
sortType: 'asc',
|
||||
levelName: undefined,
|
||||
})
|
||||
const columns = ref([
|
||||
{ visible: true, align: 'center', type: '', prop: 'id', label: 'id' },
|
||||
{ visible: true, align: 'center', type: '', prop: 'levelName', label: '名称' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: 'img', prop: 'levelIcon', label: '等级图标' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: '', prop: 'levelColor', label: '显示颜色' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: '', prop: 'minExperience', label: '最小经验值' },
|
||||
{ visible: true, align: 'center', type: '', prop: 'maxExperience', label: '最大经验值' },
|
||||
{ visible: true, align: 'center', type: '', prop: 'privileges', label: '特权配置' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: 'dict', prop: 'isActive', label: '状态' ,dictType: 'sys_common_status' },
|
||||
{ visible: false, align: 'center', type: '', prop: 'createdAt', label: '创建时间' ,showOverflowTooltip: true },
|
||||
{ visible: false, align: 'center', type: '', prop: 'updatedAt', label: '更新时间' ,showOverflowTooltip: true },
|
||||
//{ visible: false, prop: 'actions', label: '操作', type: 'slot', width: '160' }
|
||||
])
|
||||
const total = ref(0)
|
||||
const dataList = ref([])
|
||||
const queryRef = ref()
|
||||
const defaultTime = ref([new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)])
|
||||
|
||||
|
||||
var dictParams = [
|
||||
"sys_common_status",
|
||||
]
|
||||
|
||||
proxy.getDicts(dictParams).then((response) => {
|
||||
response.data.forEach((element) => {
|
||||
state.options[element.dictType] = element.list
|
||||
})
|
||||
})
|
||||
|
||||
function getList(){
|
||||
loading.value = true
|
||||
listtuserlevels(queryParams).then(res => {
|
||||
const { code, data } = res
|
||||
if (code == 200) {
|
||||
dataList.value = data.result
|
||||
total.value = data.totalNum
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 查询
|
||||
function handleQuery() {
|
||||
queryParams.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
// 重置查询操作
|
||||
function resetQuery(){
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
// 自定义排序
|
||||
function sortChange(column) {
|
||||
var sort = undefined
|
||||
var sortType = undefined
|
||||
|
||||
if (column.prop != null && column.order != null) {
|
||||
sort = column.prop
|
||||
sortType = column.order
|
||||
|
||||
}
|
||||
queryParams.sort = sort
|
||||
queryParams.sortType = sortType
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/*************** form操作 ***************/
|
||||
const formRef = ref()
|
||||
const title = ref('')
|
||||
// 操作类型 1、add 2、edit 3、view
|
||||
const opertype = ref(0)
|
||||
const open = ref(false)
|
||||
const state = reactive({
|
||||
single: true,
|
||||
multiple: true,
|
||||
submitLoading: false,
|
||||
form: {},
|
||||
rules: {
|
||||
levelName: [{ required: true, message: "名称不能为空", trigger: "blur" }],
|
||||
isActive: [{ required: true, message: "状态不能为空", trigger: "blur" }],
|
||||
},
|
||||
options: {
|
||||
// 状态 选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
|
||||
sys_common_status: [],
|
||||
}
|
||||
})
|
||||
|
||||
const { form, rules, options, single, multiple } = toRefs(state)
|
||||
|
||||
// 关闭dialog
|
||||
function cancel(){
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 重置表单
|
||||
function reset() {
|
||||
form.value = {
|
||||
id: null,
|
||||
levelName: null,
|
||||
levelIcon: null,
|
||||
levelColor: null,
|
||||
minExperience: null,
|
||||
maxExperience: null,
|
||||
privileges: null,
|
||||
isActive: null,
|
||||
createdAt: null,
|
||||
updatedAt: null,
|
||||
};
|
||||
proxy.resetForm("formRef")
|
||||
}
|
||||
|
||||
|
||||
// 添加按钮操作
|
||||
function handleAdd() {
|
||||
reset();
|
||||
open.value = true
|
||||
state.submitLoading = false
|
||||
title.value = '添加等级配置'
|
||||
opertype.value = 1
|
||||
}
|
||||
// 修改按钮操作
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const id = row.id || ids.value
|
||||
gettuserlevels(id).then((res) => {
|
||||
const { code, data } = res
|
||||
if (code == 200) {
|
||||
open.value = true
|
||||
title.value = '修改等级配置'
|
||||
opertype.value = 2
|
||||
|
||||
form.value = {
|
||||
...data,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 添加&修改 表单提交
|
||||
function submitForm() {
|
||||
proxy.$refs["formRef"].validate((valid) => {
|
||||
if (valid) {
|
||||
state.submitLoading = true
|
||||
|
||||
if (form.value.id != undefined && opertype.value === 2) {
|
||||
updatetuserlevels(form.value).then((res) => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
.finally(() => {
|
||||
state.submitLoading = false
|
||||
})
|
||||
} else {
|
||||
addtuserlevels(form.value).then((res) => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
state.submitLoading = false
|
||||
}, 800)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 删除按钮操作
|
||||
function handleDelete(row) {
|
||||
const Ids = row.id || ids.value
|
||||
|
||||
proxy
|
||||
.$confirm('是否确认删除参数编号为"' + Ids + '"的数据项?', "警告", {
|
||||
confirmButtonText: proxy.$t('common.ok'),
|
||||
cancelButtonText: proxy.$t('common.cancel'),
|
||||
type: "warning",
|
||||
})
|
||||
.then(function () {
|
||||
return deltuserlevels(Ids)
|
||||
})
|
||||
.then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 导出按钮操作
|
||||
function handleExport() {
|
||||
proxy
|
||||
.$confirm("是否确认导出等级配置数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(async () => {
|
||||
await proxy.downFile('/liveforum/tuserlevels/export', { ...queryParams })
|
||||
})
|
||||
}
|
||||
|
||||
handleQuery()
|
||||
</script>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 18
|
||||
VisualStudioVersion = 18.3.11206.111 d18.3
|
||||
VisualStudioVersion = 18.3.11206.111
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.Admin.WebApi", "ZR.Admin.WebApi\ZR.Admin.WebApi.csproj", "{E5497BB4-B0C1-4794-9FAE-163F626EC399}"
|
||||
EndProject
|
||||
|
|
@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZR.Mall", "ZR.Mall\ZR.Mall.
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZR.LiveForum", "ZR.LiveForum\ZR.LiveForum.csproj", "{B466E6BC-BB8E-4149-A7DD-3D11C5038007}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZR.LiveForum.Model", "ZR.LiveForum.Model\ZR.LiveForum.Model.csproj", "{ED637CF7-FCCB-4996-B660-C78A00BAA8F4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -75,6 +77,10 @@ Global
|
|||
{B466E6BC-BB8E-4149-A7DD-3D11C5038007}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B466E6BC-BB8E-4149-A7DD-3D11C5038007}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B466E6BC-BB8E-4149-A7DD-3D11C5038007}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ED637CF7-FCCB-4996-B660-C78A00BAA8F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ED637CF7-FCCB-4996-B660-C78A00BAA8F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ED637CF7-FCCB-4996-B660-C78A00BAA8F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED637CF7-FCCB-4996-B660-C78A00BAA8F4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user