Skip to content

Commit cc8b09a

Browse files
奇淼(piexlmaxyancunju
andauthored
字典优化,tabs优化,自动化代码优化 (flipped-aurora#1128)
* server/service/system/sys_dictionary.go: fix 获取字典单条数据时status失效的bug * 增加关闭状态下折叠内容所在menu的高亮提示 * 修复字典变更无法打开的bug * 增加详情页签区分功能 * 增加字典详情区分 * 修复字典功能 Co-authored-by: yancunju <yancunju@autouc.com>
1 parent aa80241 commit cc8b09a

File tree

11 files changed

+84
-28
lines changed

11 files changed

+84
-28
lines changed

server/api/v1/system/sys_dictionary.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ func (s *DictionaryApi) UpdateSysDictionary(c *gin.Context) {
8080
func (s *DictionaryApi) FindSysDictionary(c *gin.Context) {
8181
var dictionary system.SysDictionary
8282
_ = c.ShouldBindQuery(&dictionary)
83-
if sysDictionary, err := dictionaryService.GetSysDictionary(dictionary.Type, dictionary.ID); err != nil {
84-
global.GVA_LOG.Error("查询失败!", zap.Error(err))
85-
response.FailWithMessage("查询失败", c)
83+
if sysDictionary, err := dictionaryService.GetSysDictionary(dictionary.Type, dictionary.ID, dictionary.Status); err != nil {
84+
global.GVA_LOG.Error("字典未创建或未开启!", zap.Error(err))
85+
response.FailWithMessage("字典未创建或未开启", c)
8686
} else {
8787
response.OkWithDetailed(gin.H{"resysDictionary": sysDictionary}, "查询成功", c)
8888
}

server/service/system/sys_dictionary.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,14 @@ func (dictionaryService *DictionaryService) UpdateSysDictionary(sysDictionary *s
8080
//@param: Type string, Id uint
8181
//@return: err error, sysDictionary model.SysDictionary
8282

83-
func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uint) (sysDictionary system.SysDictionary, err error) {
84-
err = global.GVA_DB.Where("type = ? OR id = ? and status = ?", Type, Id, true).Preload("SysDictionaryDetails", "status = ?", true).First(&sysDictionary).Error
83+
func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uint, status *bool) (sysDictionary system.SysDictionary, err error) {
84+
var flag = false
85+
if status == nil {
86+
flag = true
87+
} else {
88+
flag = *status
89+
}
90+
err = global.GVA_DB.Where("(type = ? OR id = ?) and status = ?", Type, Id, flag).Preload("SysDictionaryDetails", "status = ?", true).First(&sysDictionary).Error
8591
return
8692
}
8793

server/source/system/menu.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ func (i *initMenu) InitializeData(ctx context.Context) (next context.Context, er
6868
{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}},
6969
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "system", Name: "system", Component: "view/systemTools/system/system.vue", Sort: 3, Meta: Meta{Title: "系统配置", Icon: "operation"}},
7070
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "dictionary", Name: "dictionary", Component: "view/superAdmin/dictionary/sysDictionary.vue", Sort: 5, Meta: Meta{Title: "字典管理", Icon: "notebook"}},
71-
{MenuLevel: 0, Hidden: true, ParentId: "3", Path: "dictionaryDetail/:id", Name: "dictionaryDetail", Component: "view/superAdmin/dictionary/sysDictionaryDetail.vue", Sort: 1, Meta: Meta{Title: "字典详情", Icon: "order"}},
71+
{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"}},
7272
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "operation", Name: "operation", Component: "view/superAdmin/operation/sysOperationRecord.vue", Sort: 6, Meta: Meta{Title: "操作历史", Icon: "pie-chart"}},
7373
{MenuLevel: 0, Hidden: false, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "view/example/simpleUploader/simpleUploader", Sort: 6, Meta: Meta{Title: "断点续传(插件版)", Icon: "upload"}},
7474
{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"}},
7575
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "state", Name: "state", Component: "view/system/state.vue", Sort: 6, Meta: Meta{Title: "服务器状态", Icon: "cloudy"}},
7676
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoCodeAdmin", Name: "autoCodeAdmin", Component: "view/systemTools/autoCodeAdmin/index.vue", Sort: 1, Meta: Meta{Title: "自动化代码管理", Icon: "magic-stick"}},
77-
{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"}},
77+
{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"}},
7878
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoPkg", Name: "autoPkg", Component: "view/systemTools/autoPkg/autoPkg.vue", Sort: 0, Meta: Meta{Title: "自动化package", Icon: "folder"}},
7979
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoPlug", Name: "autoPlug", Component: "view/systemTools/autoPlug/autoPlug.vue", Sort: 4, Meta: Meta{Title: "自动化插件模板", Icon: "folder"}},
8080
}

web/src/style/element_visiable.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
:root {
5555
--el-color-primary: #4D70FF;
56+
--el-menu-item-height:56px ;
5657
}
5758

5859
.gva-search-box {

web/src/utils/fmtRouterTitle.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export const fmtTitle = (title, now) => {
2+
const reg = /\$\{(.+?)\}/
3+
const reg_g = /\$\{(.+?)\}/g
4+
const result = title.match(reg_g)
5+
if (result) {
6+
result.forEach((item) => {
7+
const key = item.match(reg)[1]
8+
const value = now.params[key] || now.query[key]
9+
title = title.replace(item, value)
10+
})
11+
}
12+
return title
13+
}

web/src/view/layout/aside/asideComponent/asyncSubmenu.vue

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
<template>
22
<el-sub-menu ref="subMenu" :index="routerInfo.name">
3+
34
<template #title>
4-
<el-icon v-if="routerInfo.meta.icon">
5-
<component :is="routerInfo.meta.icon" />
6-
</el-icon>
7-
<span>{{ routerInfo.meta.title }}</span>
5+
<div v-if="!isCollapse" class="gva-subMenu">
6+
<el-icon v-if="routerInfo.meta.icon">
7+
<component :is="routerInfo.meta.icon" />
8+
</el-icon>
9+
<span>{{ routerInfo.meta.title }}</span>
10+
</div>
11+
<template v-else>
12+
<el-icon v-if="routerInfo.meta.icon">
13+
<component :is="routerInfo.meta.icon" />
14+
</el-icon>
15+
<span>{{ routerInfo.meta.title }}</span>
16+
</template>
817
</template>
918
<slot />
1019
</el-sub-menu>
@@ -39,15 +48,15 @@ const props = defineProps({
3948
}
4049
})
4150
42-
// const activeBackground = ref(props.theme.activeBackground)
43-
// const activeText = ref(props.theme.activeText)
51+
const activeBackground = ref(props.theme.activeBackground)
52+
const activeText = ref(props.theme.activeText)
4453
const normalText = ref(props.theme.normalText)
4554
// const hoverBackground = ref(props.theme.hoverBackground)
4655
// const hoverText = ref(props.theme.hoverText)
4756
4857
watch(() => props.theme, () => {
49-
// activeBackground.value = props.theme.activeBackground
50-
// activeText.value = props.theme.activeText
58+
activeBackground.value = props.theme.activeBackground
59+
activeText.value = props.theme.activeText
5160
normalText.value = props.theme.normalText
5261
// hoverBackground.value = props.theme.hoverBackground
5362
// hoverText.value = props.theme.hoverText
@@ -58,8 +67,26 @@ watch(() => props.theme, () => {
5867
<style lang="scss" scoped>
5968
.el-sub-menu{
6069
::v-deep(.el-sub-menu__title){
70+
padding: 6px;
6171
color: v-bind(normalText);
6272
}
6373
}
6474
75+
.is-active:not(.is-opened){
76+
::v-deep(.el-sub-menu__title) .gva-subMenu{
77+
flex:1;
78+
height: 100%;
79+
line-height: 44px;
80+
background: v-bind(activeBackground) !important;
81+
border-radius: 4px;
82+
box-shadow: 0 0 2px 1px v-bind(activeBackground) !important;
83+
i{
84+
color: v-bind(activeText);
85+
}
86+
span{
87+
color: v-bind(activeText);
88+
}
89+
}
90+
}
91+
6592
</style>

web/src/view/layout/aside/historyComponent/history.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
activeValue === name(item) ? userStore.activeColor : '#ddd',
3030
}"
3131
/>
32-
{{ item.meta.title }}</span>
32+
{{ fmtTitle(item.meta.title,item) }}</span>
3333
</template>
3434
</el-tab-pane>
3535
</el-tabs>
@@ -59,6 +59,7 @@ import { emitter } from '@/utils/bus.js'
5959
import { computed, onUnmounted, ref, watch } from 'vue'
6060
import { useRoute, useRouter } from 'vue-router'
6161
import { useUserStore } from '@/pinia/modules/user'
62+
import { fmtTitle } from '@/utils/fmtRouterTitle'
6263
6364
const route = useRoute()
6465
const router = useRouter()
@@ -208,11 +209,11 @@ const setTab = (route) => {
208209
209210
const historyMap = ref({})
210211
211-
watch(()=>historys.value,()=>{
212-
historyMap.value={}
213-
historys.value.forEach((item)=>{
212+
watch(() => historys.value, () => {
213+
historyMap.value = {}
214+
historys.value.forEach((item) => {
214215
historyMap.value[getFmtString(item)] = item
215-
})
216+
})
216217
})
217218
218219
const changeTab = (name) => {

web/src/view/layout/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<el-breadcrumb-item
3232
v-for="item in matched.slice(1,matched.length)"
3333
:key="item.path"
34-
>{{ route.params.title || item.meta.title }}</el-breadcrumb-item>
34+
>{{ fmtTitle(item.meta.title,route) }}</el-breadcrumb-item>
3535
</el-breadcrumb>
3636
</el-col>
3737
<el-col :xs="12" :lg="9" :md="9" :sm="14" :xl="9">
@@ -114,6 +114,7 @@ import { computed, ref, onMounted, nextTick } from 'vue'
114114
import { useRouter, useRoute } from 'vue-router'
115115
import { useUserStore } from '@/pinia/modules/user'
116116
import { useRouterStore } from '@/pinia/modules/router'
117+
import { fmtTitle } from '@/utils/fmtRouterTitle'
117118
118119
const router = useRouter()
119120
const route = useRoute()

web/src/view/superAdmin/dictionary/sysDictionary.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@
8585
<el-button
8686
size="small"
8787
icon="document"
88-
type="primary" link
88+
type="primary"
89+
link
8990
@click="toDetile(scope.row)"
9091
>详情</el-button>
9192
<el-button
9293
size="small"
9394
icon="edit"
94-
type="primary" link
95+
type="primary"
96+
link
9597
@click="updateSysDictionaryFunc(scope.row)"
9698
>变更</el-button>
9799
<el-popover
@@ -103,7 +105,8 @@
103105
<div style="text-align: right; margin-top: 8px">
104106
<el-button
105107
size="small"
106-
type="primary" link
108+
type="primary"
109+
link
107110
@click="scope.row.visible = false"
108111
>取消</el-button>
109112
<el-button
@@ -114,7 +117,8 @@
114117
</div>
115118
<template #reference>
116119
<el-button
117-
type="primary" link
120+
type="primary"
121+
link
118122
icon="delete"
119123
size="small"
120124
style="margin-left: 10px"
@@ -308,7 +312,7 @@ const toDetile = (row) => {
308312
const dialogFormVisible = ref(false)
309313
const type = ref('')
310314
const updateSysDictionaryFunc = async(row) => {
311-
const res = await findSysDictionary({ ID: row.ID })
315+
const res = await findSysDictionary({ ID: row.ID, status: row.status })
312316
type.value = 'update'
313317
if (res.code === 0) {
314318
formData.value = res.data.resysDictionary
@@ -356,6 +360,7 @@ const enterDialog = async() => {
356360
break
357361
}
358362
if (res.code === 0) {
363+
ElMessage.success('操作成功')
359364
closeDialog()
360365
getTableData()
361366
}

web/src/view/superAdmin/dictionary/sysDictionaryDetail.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ const updateSysDictionaryDetailFunc = async(row) => {
221221
const res = await findSysDictionaryDetail({ ID: row.ID })
222222
type.value = 'update'
223223
if (res.code === 0) {
224-
formData.value = res.data.resysDictionaryDetail
224+
formData.value = res.data.reSysDictionaryDetail
225225
dialogFormVisible.value = true
226226
}
227227
}

web/src/view/systemTools/autoCode/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ const init = () => {
480480
init()
481481
482482
watch(() => route.params.id, (id) => {
483-
init()
483+
if (route.name === 'autoCodeEdit') {
484+
init()
485+
}
484486
})
485487
486488
</script>

0 commit comments

Comments
 (0)