未验证 提交 cc8b09a8 编写于 作者: Mr.奇淼('s avatar Mr.奇淼( 提交者: GitHub

字典优化,tabs优化,自动化代码优化 (#1128)

* server/service/system/sys_dictionary.go: fix 获取字典单条数据时status失效的bug

* 增加关闭状态下折叠内容所在menu的高亮提示

* 修复字典变更无法打开的bug

* 增加详情页签区分功能

* 增加字典详情区分

* 修复字典功能
Co-authored-by: Nyancunju <yancunju@autouc.com>
上级 aa802413
...@@ -80,9 +80,9 @@ func (s *DictionaryApi) UpdateSysDictionary(c *gin.Context) { ...@@ -80,9 +80,9 @@ func (s *DictionaryApi) UpdateSysDictionary(c *gin.Context) {
func (s *DictionaryApi) FindSysDictionary(c *gin.Context) { func (s *DictionaryApi) FindSysDictionary(c *gin.Context) {
var dictionary system.SysDictionary var dictionary system.SysDictionary
_ = c.ShouldBindQuery(&dictionary) _ = c.ShouldBindQuery(&dictionary)
if sysDictionary, err := dictionaryService.GetSysDictionary(dictionary.Type, dictionary.ID); err != nil { if sysDictionary, err := dictionaryService.GetSysDictionary(dictionary.Type, dictionary.ID, dictionary.Status); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Error(err)) global.GVA_LOG.Error("字典未创建或未开启!", zap.Error(err))
response.FailWithMessage("查询失败", c) response.FailWithMessage("字典未创建或未开启", c)
} else { } else {
response.OkWithDetailed(gin.H{"resysDictionary": sysDictionary}, "查询成功", c) response.OkWithDetailed(gin.H{"resysDictionary": sysDictionary}, "查询成功", c)
} }
......
...@@ -80,8 +80,14 @@ func (dictionaryService *DictionaryService) UpdateSysDictionary(sysDictionary *s ...@@ -80,8 +80,14 @@ func (dictionaryService *DictionaryService) UpdateSysDictionary(sysDictionary *s
//@param: Type string, Id uint //@param: Type string, Id uint
//@return: err error, sysDictionary model.SysDictionary //@return: err error, sysDictionary model.SysDictionary
func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uint) (sysDictionary system.SysDictionary, err error) { func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uint, status *bool) (sysDictionary system.SysDictionary, err error) {
err = global.GVA_DB.Where("type = ? OR id = ? and status = ?", Type, Id, true).Preload("SysDictionaryDetails", "status = ?", true).First(&sysDictionary).Error var flag = false
if status == nil {
flag = true
} else {
flag = *status
}
err = global.GVA_DB.Where("(type = ? OR id = ?) and status = ?", Type, Id, flag).Preload("SysDictionaryDetails", "status = ?", true).First(&sysDictionary).Error
return return
} }
......
...@@ -68,13 +68,13 @@ func (i *initMenu) InitializeData(ctx context.Context) (next context.Context, er ...@@ -68,13 +68,13 @@ func (i *initMenu) InitializeData(ctx context.Context) (next context.Context, er
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "formCreate", Name: "formCreate", Component: "view/systemTools/formCreate/index.vue", Sort: 2, Meta: Meta{Title: "表单生成器", Icon: "magic-stick", KeepAlive: true}}, {MenuLevel: 0, Hidden: false, ParentId: "14", Path: "formCreate", Name: "formCreate", Component: "view/systemTools/formCreate/index.vue", Sort: 2, Meta: Meta{Title: "表单生成器", Icon: "magic-stick", KeepAlive: true}},
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "system", Name: "system", Component: "view/systemTools/system/system.vue", Sort: 3, Meta: Meta{Title: "系统配置", Icon: "operation"}}, {MenuLevel: 0, Hidden: false, ParentId: "14", Path: "system", Name: "system", Component: "view/systemTools/system/system.vue", Sort: 3, Meta: Meta{Title: "系统配置", Icon: "operation"}},
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "dictionary", Name: "dictionary", Component: "view/superAdmin/dictionary/sysDictionary.vue", Sort: 5, Meta: Meta{Title: "字典管理", Icon: "notebook"}}, {MenuLevel: 0, Hidden: false, ParentId: "3", Path: "dictionary", Name: "dictionary", Component: "view/superAdmin/dictionary/sysDictionary.vue", Sort: 5, Meta: Meta{Title: "字典管理", Icon: "notebook"}},
{MenuLevel: 0, Hidden: true, ParentId: "3", Path: "dictionaryDetail/:id", Name: "dictionaryDetail", Component: "view/superAdmin/dictionary/sysDictionaryDetail.vue", Sort: 1, Meta: Meta{Title: "字典详情", Icon: "order"}}, {MenuLevel: 0, Hidden: true, ParentId: "3", Path: "dictionaryDetail/:id", Name: "dictionaryDetail", Component: "view/superAdmin/dictionary/sysDictionaryDetail.vue", Sort: 1, Meta: Meta{Title: "字典详情-${id}", Icon: "order"}},
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "operation", Name: "operation", Component: "view/superAdmin/operation/sysOperationRecord.vue", Sort: 6, Meta: Meta{Title: "操作历史", Icon: "pie-chart"}}, {MenuLevel: 0, Hidden: false, ParentId: "3", Path: "operation", Name: "operation", Component: "view/superAdmin/operation/sysOperationRecord.vue", Sort: 6, Meta: Meta{Title: "操作历史", Icon: "pie-chart"}},
{MenuLevel: 0, Hidden: false, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "view/example/simpleUploader/simpleUploader", Sort: 6, Meta: Meta{Title: "断点续传(插件版)", Icon: "upload"}}, {MenuLevel: 0, Hidden: false, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "view/example/simpleUploader/simpleUploader", Sort: 6, Meta: Meta{Title: "断点续传(插件版)", Icon: "upload"}},
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "https://www.gin-vue-admin.com", Name: "https://www.gin-vue-admin.com", Component: "/", Sort: 0, Meta: Meta{Title: "官方网站", Icon: "home-filled"}}, {MenuLevel: 0, Hidden: false, ParentId: "0", Path: "https://www.gin-vue-admin.com", Name: "https://www.gin-vue-admin.com", Component: "/", Sort: 0, Meta: Meta{Title: "官方网站", Icon: "home-filled"}},
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "state", Name: "state", Component: "view/system/state.vue", Sort: 6, Meta: Meta{Title: "服务器状态", Icon: "cloudy"}}, {MenuLevel: 0, Hidden: false, ParentId: "0", Path: "state", Name: "state", Component: "view/system/state.vue", Sort: 6, Meta: Meta{Title: "服务器状态", Icon: "cloudy"}},
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoCodeAdmin", Name: "autoCodeAdmin", Component: "view/systemTools/autoCodeAdmin/index.vue", Sort: 1, Meta: Meta{Title: "自动化代码管理", Icon: "magic-stick"}}, {MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoCodeAdmin", Name: "autoCodeAdmin", Component: "view/systemTools/autoCodeAdmin/index.vue", Sort: 1, Meta: Meta{Title: "自动化代码管理", Icon: "magic-stick"}},
{MenuLevel: 0, Hidden: true, ParentId: "14", Path: "autoCodeEdit/:id", Name: "autoCodeEdit", Component: "view/systemTools/autoCode/index.vue", Sort: 0, Meta: Meta{Title: "自动化代码(复用)", Icon: "magic-stick"}}, {MenuLevel: 0, Hidden: true, ParentId: "14", Path: "autoCodeEdit/:id", Name: "autoCodeEdit", Component: "view/systemTools/autoCode/index.vue", Sort: 0, Meta: Meta{Title: "自动化代码-${id}", Icon: "magic-stick"}},
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoPkg", Name: "autoPkg", Component: "view/systemTools/autoPkg/autoPkg.vue", Sort: 0, Meta: Meta{Title: "自动化package", Icon: "folder"}}, {MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoPkg", Name: "autoPkg", Component: "view/systemTools/autoPkg/autoPkg.vue", Sort: 0, Meta: Meta{Title: "自动化package", Icon: "folder"}},
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoPlug", Name: "autoPlug", Component: "view/systemTools/autoPlug/autoPlug.vue", Sort: 4, Meta: Meta{Title: "自动化插件模板", Icon: "folder"}}, {MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoPlug", Name: "autoPlug", Component: "view/systemTools/autoPlug/autoPlug.vue", Sort: 4, Meta: Meta{Title: "自动化插件模板", Icon: "folder"}},
} }
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
:root { :root {
--el-color-primary: #4D70FF; --el-color-primary: #4D70FF;
--el-menu-item-height:56px ;
} }
.gva-search-box { .gva-search-box {
......
export const fmtTitle = (title, now) => {
const reg = /\$\{(.+?)\}/
const reg_g = /\$\{(.+?)\}/g
const result = title.match(reg_g)
if (result) {
result.forEach((item) => {
const key = item.match(reg)[1]
const value = now.params[key] || now.query[key]
title = title.replace(item, value)
})
}
return title
}
<template> <template>
<el-sub-menu ref="subMenu" :index="routerInfo.name"> <el-sub-menu ref="subMenu" :index="routerInfo.name">
<template #title> <template #title>
<el-icon v-if="routerInfo.meta.icon"> <div v-if="!isCollapse" class="gva-subMenu">
<component :is="routerInfo.meta.icon" /> <el-icon v-if="routerInfo.meta.icon">
</el-icon> <component :is="routerInfo.meta.icon" />
<span>{{ routerInfo.meta.title }}</span> </el-icon>
<span>{{ routerInfo.meta.title }}</span>
</div>
<template v-else>
<el-icon v-if="routerInfo.meta.icon">
<component :is="routerInfo.meta.icon" />
</el-icon>
<span>{{ routerInfo.meta.title }}</span>
</template>
</template> </template>
<slot /> <slot />
</el-sub-menu> </el-sub-menu>
...@@ -39,15 +48,15 @@ const props = defineProps({ ...@@ -39,15 +48,15 @@ const props = defineProps({
} }
}) })
// const activeBackground = ref(props.theme.activeBackground) const activeBackground = ref(props.theme.activeBackground)
// const activeText = ref(props.theme.activeText) const activeText = ref(props.theme.activeText)
const normalText = ref(props.theme.normalText) const normalText = ref(props.theme.normalText)
// const hoverBackground = ref(props.theme.hoverBackground) // const hoverBackground = ref(props.theme.hoverBackground)
// const hoverText = ref(props.theme.hoverText) // const hoverText = ref(props.theme.hoverText)
watch(() => props.theme, () => { watch(() => props.theme, () => {
// activeBackground.value = props.theme.activeBackground activeBackground.value = props.theme.activeBackground
// activeText.value = props.theme.activeText activeText.value = props.theme.activeText
normalText.value = props.theme.normalText normalText.value = props.theme.normalText
// hoverBackground.value = props.theme.hoverBackground // hoverBackground.value = props.theme.hoverBackground
// hoverText.value = props.theme.hoverText // hoverText.value = props.theme.hoverText
...@@ -58,8 +67,26 @@ watch(() => props.theme, () => { ...@@ -58,8 +67,26 @@ watch(() => props.theme, () => {
<style lang="scss" scoped> <style lang="scss" scoped>
.el-sub-menu{ .el-sub-menu{
::v-deep(.el-sub-menu__title){ ::v-deep(.el-sub-menu__title){
padding: 6px;
color: v-bind(normalText); color: v-bind(normalText);
} }
} }
.is-active:not(.is-opened){
::v-deep(.el-sub-menu__title) .gva-subMenu{
flex:1;
height: 100%;
line-height: 44px;
background: v-bind(activeBackground) !important;
border-radius: 4px;
box-shadow: 0 0 2px 1px v-bind(activeBackground) !important;
i{
color: v-bind(activeText);
}
span{
color: v-bind(activeText);
}
}
}
</style> </style>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
activeValue === name(item) ? userStore.activeColor : '#ddd', activeValue === name(item) ? userStore.activeColor : '#ddd',
}" }"
/> />
{{ item.meta.title }}</span> {{ fmtTitle(item.meta.title,item) }}</span>
</template> </template>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
...@@ -59,6 +59,7 @@ import { emitter } from '@/utils/bus.js' ...@@ -59,6 +59,7 @@ import { emitter } from '@/utils/bus.js'
import { computed, onUnmounted, ref, watch } from 'vue' import { computed, onUnmounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { useUserStore } from '@/pinia/modules/user' import { useUserStore } from '@/pinia/modules/user'
import { fmtTitle } from '@/utils/fmtRouterTitle'
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
...@@ -208,11 +209,11 @@ const setTab = (route) => { ...@@ -208,11 +209,11 @@ const setTab = (route) => {
const historyMap = ref({}) const historyMap = ref({})
watch(()=>historys.value,()=>{ watch(() => historys.value, () => {
historyMap.value={} historyMap.value = {}
historys.value.forEach((item)=>{ historys.value.forEach((item) => {
historyMap.value[getFmtString(item)] = item historyMap.value[getFmtString(item)] = item
}) })
}) })
const changeTab = (name) => { const changeTab = (name) => {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<el-breadcrumb-item <el-breadcrumb-item
v-for="item in matched.slice(1,matched.length)" v-for="item in matched.slice(1,matched.length)"
:key="item.path" :key="item.path"
>{{ route.params.title || item.meta.title }}</el-breadcrumb-item> >{{ fmtTitle(item.meta.title,route) }}</el-breadcrumb-item>
</el-breadcrumb> </el-breadcrumb>
</el-col> </el-col>
<el-col :xs="12" :lg="9" :md="9" :sm="14" :xl="9"> <el-col :xs="12" :lg="9" :md="9" :sm="14" :xl="9">
...@@ -114,6 +114,7 @@ import { computed, ref, onMounted, nextTick } from 'vue' ...@@ -114,6 +114,7 @@ import { computed, ref, onMounted, nextTick } from 'vue'
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import { useUserStore } from '@/pinia/modules/user' import { useUserStore } from '@/pinia/modules/user'
import { useRouterStore } from '@/pinia/modules/router' import { useRouterStore } from '@/pinia/modules/router'
import { fmtTitle } from '@/utils/fmtRouterTitle'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
......
...@@ -85,13 +85,15 @@ ...@@ -85,13 +85,15 @@
<el-button <el-button
size="small" size="small"
icon="document" icon="document"
type="primary" link type="primary"
link
@click="toDetile(scope.row)" @click="toDetile(scope.row)"
>详情</el-button> >详情</el-button>
<el-button <el-button
size="small" size="small"
icon="edit" icon="edit"
type="primary" link type="primary"
link
@click="updateSysDictionaryFunc(scope.row)" @click="updateSysDictionaryFunc(scope.row)"
>变更</el-button> >变更</el-button>
<el-popover <el-popover
...@@ -103,7 +105,8 @@ ...@@ -103,7 +105,8 @@
<div style="text-align: right; margin-top: 8px"> <div style="text-align: right; margin-top: 8px">
<el-button <el-button
size="small" size="small"
type="primary" link type="primary"
link
@click="scope.row.visible = false" @click="scope.row.visible = false"
>取消</el-button> >取消</el-button>
<el-button <el-button
...@@ -114,7 +117,8 @@ ...@@ -114,7 +117,8 @@
</div> </div>
<template #reference> <template #reference>
<el-button <el-button
type="primary" link type="primary"
link
icon="delete" icon="delete"
size="small" size="small"
style="margin-left: 10px" style="margin-left: 10px"
...@@ -308,7 +312,7 @@ const toDetile = (row) => { ...@@ -308,7 +312,7 @@ const toDetile = (row) => {
const dialogFormVisible = ref(false) const dialogFormVisible = ref(false)
const type = ref('') const type = ref('')
const updateSysDictionaryFunc = async(row) => { const updateSysDictionaryFunc = async(row) => {
const res = await findSysDictionary({ ID: row.ID }) const res = await findSysDictionary({ ID: row.ID, status: row.status })
type.value = 'update' type.value = 'update'
if (res.code === 0) { if (res.code === 0) {
formData.value = res.data.resysDictionary formData.value = res.data.resysDictionary
...@@ -356,6 +360,7 @@ const enterDialog = async() => { ...@@ -356,6 +360,7 @@ const enterDialog = async() => {
break break
} }
if (res.code === 0) { if (res.code === 0) {
ElMessage.success('操作成功')
closeDialog() closeDialog()
getTableData() getTableData()
} }
......
...@@ -221,7 +221,7 @@ const updateSysDictionaryDetailFunc = async(row) => { ...@@ -221,7 +221,7 @@ const updateSysDictionaryDetailFunc = async(row) => {
const res = await findSysDictionaryDetail({ ID: row.ID }) const res = await findSysDictionaryDetail({ ID: row.ID })
type.value = 'update' type.value = 'update'
if (res.code === 0) { if (res.code === 0) {
formData.value = res.data.resysDictionaryDetail formData.value = res.data.reSysDictionaryDetail
dialogFormVisible.value = true dialogFormVisible.value = true
} }
} }
......
...@@ -480,7 +480,9 @@ const init = () => { ...@@ -480,7 +480,9 @@ const init = () => {
init() init()
watch(() => route.params.id, (id) => { watch(() => route.params.id, (id) => {
init() if (route.name === 'autoCodeEdit') {
init()
}
}) })
</script> </script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册