适配
This commit is contained in:
parent
70f3212840
commit
02168e0c24
|
|
@ -1,4 +1,4 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ${options.DtosNamespace}.${options.SubNamespace}.Dto;
|
||||
using ${options.ModelsNamespace}.${options.SubNamespace};
|
||||
using ${options.IServicsNamespace}.${options.SubNamespace}.I${options.SubNamespace}Service;
|
||||
|
|
@ -96,7 +96,17 @@ $if(replaceDto.ShowBtnEdit)
|
|||
[Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.UPDATE)]
|
||||
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);
|
||||
|
||||
return ToResponse(response);
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@ global using System;
|
|||
global using SqlSugar;
|
||||
global using Newtonsoft.Json;
|
||||
global using MiniExcelLibs.Attributes;
|
||||
global using System.ComponentModel.DataAnnotations;
|
||||
global using System.ComponentModel.DataAnnotations;
|
||||
global using ZR.Model;
|
||||
|
|
@ -28,11 +28,11 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
|
|||
|
||||
[ExcelColumn(Name = "等级图标")]
|
||||
[ExcelColumnName("等级图标")]
|
||||
public string LevelIcon { get; set; }
|
||||
public string? LevelIcon { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "显示颜色")]
|
||||
[ExcelColumnName("显示颜色")]
|
||||
public string LevelColor { get; set; }
|
||||
public string? LevelColor { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "最小经验值")]
|
||||
[ExcelColumnName("最小经验值")]
|
||||
|
|
@ -44,7 +44,7 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
|
|||
|
||||
[ExcelColumn(Name = "特权配置")]
|
||||
[ExcelColumnName("特权配置")]
|
||||
public string Privileges { get; set; }
|
||||
public string? Privileges { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "状态不能为空")]
|
||||
[ExcelColumn(Name = "状态")]
|
||||
|
|
@ -59,9 +59,7 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
|
|||
[ExcelColumnName("更新时间")]
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
|
||||
|
||||
|
||||
[ExcelColumn(Name = "状态")]
|
||||
public string IsActiveLabel { get; set; }
|
||||
public string? IsActiveLabel { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using ZR.LiveForum.Model.Liveforum.Dto;
|
||||
using ZR.LiveForum.Model.Liveforum;
|
||||
|
|
@ -80,7 +80,7 @@ namespace ZR.Service.Liveforum
|
|||
.Where(predicate.ToExpression())
|
||||
.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)
|
||||
.ToPage(parm);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export function getData(dictCode) {
|
|||
}
|
||||
|
||||
// 根据字典类型查询字典数据信息
|
||||
export function getDicts(dictType) {
|
||||
export async function getDicts(dictType) {
|
||||
if (typeof dictType === 'object') {
|
||||
var data = dictType.map((x) => {
|
||||
if (typeof x === 'object') {
|
||||
|
|
@ -27,11 +27,24 @@ export function getDicts(dictType) {
|
|||
return x
|
||||
}
|
||||
})
|
||||
return request({
|
||||
var res = await request({
|
||||
url: '/system/dict/data/dicts',
|
||||
data: data,
|
||||
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 {
|
||||
return request({
|
||||
url: '/system/dict/data/type/' + dictType,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
<template>
|
||||
<template v-for="(item, index) in dataList">
|
||||
<template v-if="values.includes(item.dictValue)">
|
||||
<el-tag
|
||||
v-if="dictValues.includes(item.listClass)"
|
||||
size="small"
|
||||
:disable-transitions="true"
|
||||
:index="index"
|
||||
:type="item.listClass"
|
||||
:class="item.cssClass">
|
||||
<template v-if="values.includes(item.dictValue.toString())">
|
||||
<el-tag v-if="dictValues.includes(item.listClass)" size="small" :disable-transitions="true" :index="index"
|
||||
:type="item.listClass" :class="item.cssClass">
|
||||
<template v-if="item.langKey">
|
||||
{{ $t(item.langKey) }}
|
||||
</template>
|
||||
|
|
@ -51,6 +46,7 @@ const props = defineProps({
|
|||
}
|
||||
})
|
||||
const dataList = computed(() => {
|
||||
// debugger
|
||||
if (props.config) {
|
||||
let config = props.config
|
||||
var newList = []
|
||||
|
|
@ -63,6 +59,8 @@ const dataList = computed(() => {
|
|||
}
|
||||
return newList
|
||||
}
|
||||
console.log("options", props.options);
|
||||
|
||||
return props.options
|
||||
})
|
||||
const values = computed(() => {
|
||||
|
|
@ -80,7 +78,7 @@ const dictValues = ref(['primary', 'danger', 'warning', 'info', 'success'])
|
|||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-tag + .el-tag {
|
||||
.el-tag+.el-tag {
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -29,47 +29,48 @@
|
|||
<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 :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="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" />
|
||||
{{ scope.row.isActive }}
|
||||
<dict-tag :options="options.sys_common_status_bool" :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 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>
|
||||
<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" />
|
||||
<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-row :gutter="20">
|
||||
|
||||
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="名称" prop="levelName">
|
||||
|
|
@ -88,13 +89,13 @@
|
|||
<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="请输入最大经验值" />
|
||||
|
|
@ -110,8 +111,8 @@
|
|||
<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 v-for="item in options.sys_common_status_bool" :key="item.dictValue" :value="item.dictValue">
|
||||
{{ item.dictLabel }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
|
@ -129,11 +130,12 @@
|
|||
</template>
|
||||
|
||||
<script setup name="tuserlevels">
|
||||
import { listtuserlevels,
|
||||
addtuserlevels, deltuserlevels,
|
||||
updatetuserlevels,gettuserlevels,
|
||||
}
|
||||
from '@/api/liveforum/tuserlevels.js'
|
||||
import {
|
||||
listtuserlevels,
|
||||
addtuserlevels, deltuserlevels,
|
||||
updatetuserlevels, gettuserlevels,
|
||||
}
|
||||
from '@/api/liveforum/tuserlevels.js'
|
||||
const { proxy } = getCurrentInstance()
|
||||
const ids = ref([])
|
||||
const loading = ref(false)
|
||||
|
|
@ -146,16 +148,16 @@ const queryParams = reactive({
|
|||
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: 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_bool' },
|
||||
{ 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)
|
||||
|
|
@ -165,7 +167,7 @@ const defaultTime = ref([new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23,
|
|||
|
||||
|
||||
var dictParams = [
|
||||
"sys_common_status",
|
||||
"sys_common_status_bool",
|
||||
]
|
||||
|
||||
proxy.getDicts(dictParams).then((response) => {
|
||||
|
|
@ -174,7 +176,7 @@ proxy.getDicts(dictParams).then((response) => {
|
|||
})
|
||||
})
|
||||
|
||||
function getList(){
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listtuserlevels(queryParams).then(res => {
|
||||
const { code, data } = res
|
||||
|
|
@ -193,7 +195,7 @@ function handleQuery() {
|
|||
}
|
||||
|
||||
// 重置查询操作
|
||||
function resetQuery(){
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
|
|
@ -224,19 +226,18 @@ const state = reactive({
|
|||
submitLoading: false,
|
||||
form: {},
|
||||
rules: {
|
||||
levelName: [{ required: true, message: "名称不能为空", trigger: "blur" }],
|
||||
isActive: [{ required: true, message: "状态不能为空", trigger: "blur" }],
|
||||
levelName: [{ required: true, message: "名称不能为空", trigger: "blur" }],
|
||||
},
|
||||
options: {
|
||||
// 状态 选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
|
||||
sys_common_status: [],
|
||||
sys_common_status_bool: [],
|
||||
}
|
||||
})
|
||||
|
||||
const { form, rules, options, single, multiple } = toRefs(state)
|
||||
|
||||
// 关闭dialog
|
||||
function cancel(){
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
|
@ -297,15 +298,15 @@ function submitForm() {
|
|||
open.value = false
|
||||
getList()
|
||||
})
|
||||
.finally(() => {
|
||||
state.submitLoading = false
|
||||
})
|
||||
.finally(() => {
|
||||
state.submitLoading = false
|
||||
})
|
||||
} else {
|
||||
addtuserlevels(form.value).then((res) => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
state.submitLoading = false
|
||||
|
|
@ -351,4 +352,4 @@ function handleExport() {
|
|||
}
|
||||
|
||||
handleQuery()
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user