Skip to content

Commit cc4662f

Browse files
committed
feat: terminology management
1 parent 8c64a99 commit cc4662f

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

backend/apps/terminology/curd/terminology.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import List, Optional
33

44
from sqlalchemy import and_, or_, select, func, delete, update
5-
from sqlalchemy.dialects.postgresql import JSONB
65
from sqlalchemy.orm import aliased
76

87
from apps.terminology.models.terminology_model import Terminology, TerminologyInfo
@@ -25,7 +24,7 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
2524
# 步骤1:先找到所有匹配的节点ID(无论是父节点还是子节点)
2625
matched_ids_subquery = (
2726
select(Terminology.id)
28-
.where(Terminology.name.like(keyword_pattern)) # LIKE查询条件
27+
.where(Terminology.word.like(keyword_pattern)) # LIKE查询条件
2928
.subquery()
3029
)
3130

@@ -60,7 +59,7 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
6059
children_subquery = (
6160
select(
6261
child.pid,
63-
func.jsonb_agg(child.name).order_by(child.create_time.desc()).label('children_names')
62+
func.jsonb_agg(child.word).filter(child.word.isnot(None)).label('other_words')
6463
)
6564
.where(child.pid.isnot(None))
6665
.group_by(child.pid)
@@ -74,10 +73,7 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
7473
Terminology.word,
7574
Terminology.create_time,
7675
Terminology.description,
77-
func.coalesce(
78-
children_subquery.c.children_names,
79-
func.cast('[]', JSONB)
80-
).label('other_words')
76+
children_subquery.c.other_words
8177
)
8278
.outerjoin(
8379
children_subquery,
@@ -110,10 +106,7 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
110106
Terminology.word,
111107
Terminology.create_time,
112108
Terminology.description,
113-
func.coalesce(
114-
func.jsonb_agg(child.word),
115-
func.cast('[]', JSONB)
116-
).label('other_words')
109+
func.jsonb_agg(child.word).filter(child.word.isnot(None)).label('other_words')
117110
)
118111
.outerjoin(child, and_(Terminology.id == child.pid))
119112
.where(Terminology.id.in_(paginated_parent_ids))
@@ -130,7 +123,7 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
130123
word=row.word,
131124
create_time=row.create_time,
132125
description=row.description,
133-
other_words=row.other_words,
126+
other_words=row.other_words if row.other_words else [],
134127
))
135128

136129
return current_page, page_size, total_count, total_pages, _list
@@ -153,7 +146,7 @@ def create_terminology(session: SessionDep, info: TerminologyInfo):
153146
if info.other_words:
154147
for other_word in info.other_words:
155148
_list.append(
156-
Terminology(pid=result.id, word=other_word, create_time=create_time, description=info.description))
149+
Terminology(pid=result.id, word=other_word, create_time=create_time))
157150
session.bulk_save_objects(_list)
158151
session.flush()
159152
session.commit()
@@ -180,7 +173,7 @@ def update_terminology(session: SessionDep, info: TerminologyInfo):
180173
if info.other_words:
181174
for other_word in info.other_words:
182175
_list.append(
183-
Terminology(pid=info.id, word=other_word, create_time=create_time, description=info.description))
176+
Terminology(pid=info.id, word=other_word, create_time=create_time))
184177
session.bulk_save_objects(_list)
185178
session.flush()
186179
session.commit()

frontend/src/views/system/professional/index.vue

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts" setup>
2-
import { ref, onMounted, reactive, unref, nextTick } from 'vue'
2+
import { nextTick, onMounted, reactive, ref, unref } from 'vue'
33
import icon_export_outlined from '@/assets/svg/icon_export_outlined.svg'
44
import { professionalApi } from '@/api/professional'
55
import { formatTimestamp } from '@/utils/date'
@@ -72,7 +72,7 @@ const exportBatchUser = () => {
7272
cancelButtonText: t('common.cancel'),
7373
customClass: 'confirm-no_icon',
7474
autofocus: false,
75-
}
75+
},
7676
).then(() => {
7777
professionalApi.deleteEmbedded(multipleSelectionAll.value.map((ele) => ele.id)).then(() => {
7878
ElMessage({
@@ -112,7 +112,7 @@ const deleteBatchUser = () => {
112112
cancelButtonText: t('common.cancel'),
113113
customClass: 'confirm-no_icon',
114114
autofocus: false,
115-
}
115+
},
116116
).then(() => {
117117
professionalApi.deleteEmbedded(multipleSelectionAll.value.map((ele) => ele.id)).then(() => {
118118
ElMessage({
@@ -297,19 +297,20 @@ const deleteHandlerItem = (idx: number) => {
297297
</el-icon>
298298
</template>
299299
</el-input>
300-
<el-button secondary @click="exportAllUser">
301-
<template #icon>
302-
<icon_export_outlined />
303-
</template>
304-
{{ $t('professional.export_all') }}
305-
</el-button>
306-
<el-button secondary @click="editHandler(null)">
307-
<template #icon>
308-
<ccmUpload></ccmUpload>
309-
</template>
310-
{{ $t('user.batch_import') }}
311-
</el-button>
312-
300+
<template v-if="false">
301+
<el-button secondary @click="exportAllUser">
302+
<template #icon>
303+
<icon_export_outlined />
304+
</template>
305+
{{ $t('professional.export_all') }}
306+
</el-button>
307+
<el-button secondary @click="editHandler(null)">
308+
<template #icon>
309+
<ccmUpload></ccmUpload>
310+
</template>
311+
{{ $t('user.batch_import') }}
312+
</el-button>
313+
</template>
313314
<el-button type="primary" @click="editHandler(null)">
314315
<template #icon>
315316
<icon_add_outlined></icon_add_outlined>
@@ -434,8 +435,8 @@ const deleteHandlerItem = (idx: number) => {
434435
<button class="danger-button" @click="deleteBatchUser">{{ $t('dashboard.delete') }}</button>
435436

436437
<span class="selected">{{
437-
$t('user.selected_2_items', { msg: multipleSelectionAll.length })
438-
}}</span>
438+
$t('user.selected_2_items', { msg: multipleSelectionAll.length })
439+
}}</span>
439440

440441
<el-button text @click="cancelDelete">
441442
{{ $t('common.cancel') }}
@@ -577,23 +578,27 @@ const deleteHandlerItem = (idx: number) => {
577578
height: auto;
578579
padding-top: 200px;
579580
}
581+
580582
.tool-left {
581583
display: flex;
582584
align-items: center;
583585
justify-content: space-between;
584586
margin-bottom: 16px;
587+
585588
.page-title {
586589
font-weight: 500;
587590
font-size: 20px;
588591
line-height: 28px;
589592
}
590593
}
594+
591595
.pagination-container {
592596
display: flex;
593597
justify-content: end;
594598
align-items: center;
595599
margin-top: 16px;
596600
}
601+
597602
.table-content {
598603
max-height: calc(100% - 104px);
599604
overflow-y: auto;
@@ -606,6 +611,7 @@ const deleteHandlerItem = (idx: number) => {
606611
.ed-icon {
607612
color: #646a73;
608613
}
614+
609615
.user-status-container {
610616
display: flex;
611617
align-items: center;
@@ -618,8 +624,10 @@ const deleteHandlerItem = (idx: number) => {
618624
margin-left: 8px;
619625
}
620626
}
627+
621628
.field-comment {
622629
height: 24px;
630+
623631
.ed-icon {
624632
position: relative;
625633
cursor: pointer;
@@ -716,9 +724,11 @@ const deleteHandlerItem = (idx: number) => {
716724
.ed-form-item--label-top .ed-form-item__label {
717725
margin-bottom: 4px;
718726
}
727+
719728
.ed-form-item__label {
720729
color: #646a73;
721730
}
731+
722732
.content {
723733
width: 100%;
724734
line-height: 22px;
@@ -761,6 +771,7 @@ const deleteHandlerItem = (idx: number) => {
761771
border-radius: 6px;
762772
margin-right: -4px;
763773
cursor: pointer;
774+
764775
&:hover {
765776
background-color: #1f23291a;
766777
}

0 commit comments

Comments
 (0)