This commit is contained in:
zpc 2025-11-16 11:02:08 +08:00
parent 70f3212840
commit 02168e0c24
7 changed files with 101 additions and 80 deletions

View File

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using ${options.DtosNamespace}.${options.SubNamespace}.Dto; using ${options.DtosNamespace}.${options.SubNamespace}.Dto;
using ${options.ModelsNamespace}.${options.SubNamespace}; using ${options.ModelsNamespace}.${options.SubNamespace};
using ${options.IServicsNamespace}.${options.SubNamespace}.I${options.SubNamespace}Service; using ${options.IServicsNamespace}.${options.SubNamespace}.I${options.SubNamespace}Service;
@ -96,7 +96,17 @@ $if(replaceDto.ShowBtnEdit)
[Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.UPDATE)] [Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.UPDATE)]
public IActionResult Update${replaceDto.ModelTypeName}([FromBody] ${replaceDto.ModelTypeName}Dto parm) public IActionResult Update${replaceDto.ModelTypeName}([FromBody] ${replaceDto.ModelTypeName}Dto parm)
{ {
var modal = parm.Adapt<${replaceDto.ModelTypeName}>().ToUpdate(HttpContext);
if (parm.Id == 0)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
}
var oldal = _${replaceDto.ModelTypeName}Service.GetById(parm.Id);
if (oldal == null)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "数据不存在");
}
var modal = parm.Adapt(oldal);
var response = _${replaceDto.ModelTypeName}Service.Update${replaceDto.ModelTypeName}(modal); var response = _${replaceDto.ModelTypeName}Service.Update${replaceDto.ModelTypeName}(modal);
return ToResponse(response); return ToResponse(response);

View File

@ -4,3 +4,4 @@ global using SqlSugar;
global using Newtonsoft.Json; global using Newtonsoft.Json;
global using MiniExcelLibs.Attributes; global using MiniExcelLibs.Attributes;
global using System.ComponentModel.DataAnnotations; global using System.ComponentModel.DataAnnotations;
global using ZR.Model;

View File

@ -28,11 +28,11 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
[ExcelColumn(Name = "等级图标")] [ExcelColumn(Name = "等级图标")]
[ExcelColumnName("等级图标")] [ExcelColumnName("等级图标")]
public string LevelIcon { get; set; } public string? LevelIcon { get; set; }
[ExcelColumn(Name = "显示颜色")] [ExcelColumn(Name = "显示颜色")]
[ExcelColumnName("显示颜色")] [ExcelColumnName("显示颜色")]
public string LevelColor { get; set; } public string? LevelColor { get; set; }
[ExcelColumn(Name = "最小经验值")] [ExcelColumn(Name = "最小经验值")]
[ExcelColumnName("最小经验值")] [ExcelColumnName("最小经验值")]
@ -44,7 +44,7 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
[ExcelColumn(Name = "特权配置")] [ExcelColumn(Name = "特权配置")]
[ExcelColumnName("特权配置")] [ExcelColumnName("特权配置")]
public string Privileges { get; set; } public string? Privileges { get; set; }
[Required(ErrorMessage = "状态不能为空")] [Required(ErrorMessage = "状态不能为空")]
[ExcelColumn(Name = "状态")] [ExcelColumn(Name = "状态")]
@ -59,9 +59,7 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
[ExcelColumnName("更新时间")] [ExcelColumnName("更新时间")]
public DateTime? UpdatedAt { get; set; } public DateTime? UpdatedAt { get; set; }
[ExcelColumn(Name = "状态")] [ExcelColumn(Name = "状态")]
public string IsActiveLabel { get; set; } public string? IsActiveLabel { get; set; }
} }
} }

View File

@ -1,4 +1,4 @@
using Infrastructure.Attribute; using Infrastructure.Attribute;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using ZR.LiveForum.Model.Liveforum.Dto; using ZR.LiveForum.Model.Liveforum.Dto;
using ZR.LiveForum.Model.Liveforum; using ZR.LiveForum.Model.Liveforum;
@ -80,7 +80,7 @@ namespace ZR.Service.Liveforum
.Where(predicate.ToExpression()) .Where(predicate.ToExpression())
.Select((it) => new T_UserLevelsDto() .Select((it) => new T_UserLevelsDto()
{ {
IsActiveLabel = it.IsActive.GetConfigValue<Model.System.SysDictData>("sys_common_status"), IsActiveLabel = it.IsActive.GetConfigValue<Model.System.SysDictData>("sys_common_status_bool"),
}, true) }, true)
.ToPage(parm); .ToPage(parm);

View File

@ -18,7 +18,7 @@ export function getData(dictCode) {
} }
// 根据字典类型查询字典数据信息 // 根据字典类型查询字典数据信息
export function getDicts(dictType) { export async function getDicts(dictType) {
if (typeof dictType === 'object') { if (typeof dictType === 'object') {
var data = dictType.map((x) => { var data = dictType.map((x) => {
if (typeof x === 'object') { if (typeof x === 'object') {
@ -27,11 +27,24 @@ export function getDicts(dictType) {
return x return x
} }
}) })
return request({ var res = await request({
url: '/system/dict/data/dicts', url: '/system/dict/data/dicts',
data: data, data: data,
method: 'post' method: 'post'
}) });
if (res.code == 200) {
res.data.forEach(element => {
if (element.dictType == "sys_common_status_bool") {
element.list.forEach(item => {
item.value = item.value == "true" ? true : false;
item.dictValue = item.dictValue == "true" ? true : false;
});
}
});
}
return res;
} else { } else {
return request({ return request({
url: '/system/dict/data/type/' + dictType, url: '/system/dict/data/type/' + dictType,

View File

@ -1,13 +1,8 @@
<template> <template>
<template v-for="(item, index) in dataList"> <template v-for="(item, index) in dataList">
<template v-if="values.includes(item.dictValue)"> <template v-if="values.includes(item.dictValue.toString())">
<el-tag <el-tag v-if="dictValues.includes(item.listClass)" size="small" :disable-transitions="true" :index="index"
v-if="dictValues.includes(item.listClass)" :type="item.listClass" :class="item.cssClass">
size="small"
:disable-transitions="true"
:index="index"
:type="item.listClass"
:class="item.cssClass">
<template v-if="item.langKey"> <template v-if="item.langKey">
{{ $t(item.langKey) }} {{ $t(item.langKey) }}
</template> </template>
@ -51,6 +46,7 @@ const props = defineProps({
} }
}) })
const dataList = computed(() => { const dataList = computed(() => {
// debugger
if (props.config) { if (props.config) {
let config = props.config let config = props.config
var newList = [] var newList = []
@ -63,6 +59,8 @@ const dataList = computed(() => {
} }
return newList return newList
} }
console.log("options", props.options);
return props.options return props.options
}) })
const values = computed(() => { const values = computed(() => {
@ -80,7 +78,7 @@ const dictValues = ref(['primary', 'danger', 'warning', 'info', 'success'])
</script> </script>
<style scoped> <style scoped>
.el-tag + .el-tag { .el-tag+.el-tag {
margin-left: 10px; margin-left: 10px;
} }
</style> </style>

View File

@ -29,44 +29,45 @@
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row> </el-row>
<el-table <el-table :data="dataList" v-loading="loading" ref="table" border header-cell-class-name="el-table-header-cell"
:data="dataList" highlight-current-row @sort-change="sortChange">
v-loading="loading" <el-table-column prop="id" label="id" align="center" v-if="columns.showColumn('id')" />
ref="table" <el-table-column prop="levelName" label="名称" align="center" :show-overflow-tooltip="true"
border v-if="columns.showColumn('levelName')" />
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')"> <el-table-column prop="levelIcon" label="等级图标" align="center" v-if="columns.showColumn('levelIcon')">
<template #default="scope"> <template #default="scope">
<ImagePreview :src="scope.row.levelIcon"></ImagePreview> <ImagePreview :src="scope.row.levelIcon"></ImagePreview>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="levelColor" label="显示颜色" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('levelColor')"/> <el-table-column prop="levelColor" label="显示颜色" align="center" :show-overflow-tooltip="true"
<el-table-column prop="minExperience" label="最小经验值" align="center" v-if="columns.showColumn('minExperience')"/> v-if="columns.showColumn('levelColor')" />
<el-table-column prop="maxExperience" label="最大经验值" align="center" v-if="columns.showColumn('maxExperience')"/> <el-table-column prop="minExperience" label="最小经验值" align="center" v-if="columns.showColumn('minExperience')" />
<el-table-column prop="privileges" label="特权配置" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('privileges')"/> <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')"> <el-table-column prop="isActive" label="状态" align="center" v-if="columns.showColumn('isActive')">
<template #default="scope"> <template #default="scope">
<dict-tag :options=" options.sys_common_status " :value="scope.row.isActive" /> {{ scope.row.isActive }}
<dict-tag :options="options.sys_common_status_bool" :value="scope.row.isActive" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="createdAt" label="创建时间" :show-overflow-tooltip="true" v-if="columns.showColumn('createdAt')"/> <el-table-column prop="createdAt" label="创建时间" :show-overflow-tooltip="true"
<el-table-column prop="updatedAt" label="更新时间" :show-overflow-tooltip="true" v-if="columns.showColumn('updatedAt')"/> 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"> <el-table-column label="操作" width="160">
<template #default="scope"> <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="success" size="small" icon="edit" title="编辑" v-hasPermi="['tuserlevels:edit']"
<el-button type="danger" size="small" icon="delete" title="删除" v-hasPermi="['tuserlevels:delete']" @click="handleDelete(scope.row)"></el-button> @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> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> <pagination :total="total" :page="queryParams.pageNum" :limit="queryParams.pageSize" @pagination="getList" />
<el-dialog :title="title" :lock-scroll="false" v-model="open" > <el-dialog :title="title" :lock-scroll="false" v-model="open">
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px"> <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
<el-row :gutter="20"> <el-row :gutter="20">
@ -110,8 +111,8 @@
<el-col :lg="12"> <el-col :lg="12">
<el-form-item label="状态" prop="isActive"> <el-form-item label="状态" prop="isActive">
<el-radio-group v-model="form.isActive"> <el-radio-group v-model="form.isActive">
<el-radio v-for="item in options.sys_common_status" :key="item.dictValue" :value="item.dictValue"> <el-radio v-for="item in options.sys_common_status_bool" :key="item.dictValue" :value="item.dictValue">
{{item.dictLabel}} {{ item.dictLabel }}
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
@ -129,11 +130,12 @@
</template> </template>
<script setup name="tuserlevels"> <script setup name="tuserlevels">
import { listtuserlevels, import {
listtuserlevels,
addtuserlevels, deltuserlevels, addtuserlevels, deltuserlevels,
updatetuserlevels,gettuserlevels, updatetuserlevels, gettuserlevels,
} }
from '@/api/liveforum/tuserlevels.js' from '@/api/liveforum/tuserlevels.js'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const ids = ref([]) const ids = ref([])
const loading = ref(false) const loading = ref(false)
@ -147,15 +149,15 @@ const queryParams = reactive({
}) })
const columns = ref([ const columns = ref([
{ visible: true, align: 'center', type: '', prop: 'id', label: 'id' }, { visible: true, align: 'center', type: '', prop: 'id', label: 'id' },
{ visible: true, align: 'center', type: '', prop: 'levelName', label: '名称' ,showOverflowTooltip: true }, { 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: 'img', prop: 'levelIcon', label: '等级图标', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'levelColor', 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: 'minExperience', label: '最小经验值' },
{ visible: true, align: 'center', type: '', prop: 'maxExperience', label: '最大经验值' }, { visible: true, align: 'center', type: '', prop: 'maxExperience', label: '最大经验值' },
{ visible: true, align: 'center', type: '', prop: 'privileges', label: '特权配置' ,showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'privileges', label: '特权配置', showOverflowTooltip: true },
{ visible: true, align: 'center', type: 'dict', prop: 'isActive', label: '状态' ,dictType: 'sys_common_status' }, { visible: true, align: 'center', type: 'dict', prop: 'isActive', label: '状态', dictType: 'sys_common_status_bool' },
{ visible: false, align: 'center', type: '', prop: 'createdAt', label: '创建时间' ,showOverflowTooltip: true }, { visible: false, align: 'center', type: '', prop: 'createdAt', label: '创建时间', showOverflowTooltip: true },
{ visible: false, align: 'center', type: '', prop: 'updatedAt', label: '更新时间' ,showOverflowTooltip: true }, { visible: false, align: 'center', type: '', prop: 'updatedAt', label: '更新时间', showOverflowTooltip: true },
//{ visible: false, prop: 'actions', label: '', type: 'slot', width: '160' } //{ visible: false, prop: 'actions', label: '', type: 'slot', width: '160' }
]) ])
const total = ref(0) const total = ref(0)
@ -165,7 +167,7 @@ const defaultTime = ref([new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23,
var dictParams = [ var dictParams = [
"sys_common_status", "sys_common_status_bool",
] ]
proxy.getDicts(dictParams).then((response) => { proxy.getDicts(dictParams).then((response) => {
@ -174,7 +176,7 @@ proxy.getDicts(dictParams).then((response) => {
}) })
}) })
function getList(){ function getList() {
loading.value = true loading.value = true
listtuserlevels(queryParams).then(res => { listtuserlevels(queryParams).then(res => {
const { code, data } = res const { code, data } = res
@ -193,7 +195,7 @@ function handleQuery() {
} }
// //
function resetQuery(){ function resetQuery() {
proxy.resetForm("queryRef") proxy.resetForm("queryRef")
handleQuery() handleQuery()
} }
@ -225,18 +227,17 @@ const state = reactive({
form: {}, form: {},
rules: { rules: {
levelName: [{ required: true, message: "名称不能为空", trigger: "blur" }], levelName: [{ required: true, message: "名称不能为空", trigger: "blur" }],
isActive: [{ required: true, message: "状态不能为空", trigger: "blur" }],
}, },
options: { options: {
// eg:{ dictLabel: '', dictValue: '0'} // eg:{ dictLabel: '', dictValue: '0'}
sys_common_status: [], sys_common_status_bool: [],
} }
}) })
const { form, rules, options, single, multiple } = toRefs(state) const { form, rules, options, single, multiple } = toRefs(state)
// dialog // dialog
function cancel(){ function cancel() {
open.value = false open.value = false
reset() reset()
} }