@@ -3,6 +3,7 @@ import { nextTick, onMounted, reactive, ref, unref } from 'vue'
33import icon_export_outlined from ' @/assets/svg/icon_export_outlined.svg'
44import { professionalApi } from ' @/api/professional'
55import { formatTimestamp } from ' @/utils/date'
6+ import { datasourceApi } from ' @/api/datasource'
67import ccmUpload from ' @/assets/svg/icon_ccm-upload_outlined.svg'
78import icon_add_outlined from ' @/assets/svg/icon_add_outlined.svg'
89import IconOpeEdit from ' @/assets/svg/icon_edit_outlined.svg'
@@ -16,11 +17,15 @@ interface Form {
1617 id? : string | null
1718 word: string | null
1819 other_words: string []
20+ specific_ds: boolean
21+ datasource_ids: number []
22+ datasource_names: string []
1923 description: string | null
2024}
2125
2226const { t } = useI18n ()
2327const multipleSelectionAll = ref <any []>([])
28+ const allDsList = ref <any []>([])
2429const keywords = ref (' ' )
2530const oldKeywords = ref (' ' )
2631const searchLoading = ref (false )
@@ -48,7 +53,10 @@ const defaultForm = {
4853 id: null ,
4954 word: null ,
5055 description: null ,
56+ specific_ds: false ,
57+ datasource_ids: [],
5158 other_words: [' ' ],
59+ datasource_names: [],
5260}
5361const pageForm = ref <Form >(cloneDeep (defaultForm ))
5462
@@ -197,6 +205,14 @@ const search = () => {
197205
198206const termFormRef = ref ()
199207
208+ const validatePass = (_ : any , value : any , callback : any ) => {
209+ if (pageForm .value .specific_ds && ! value .length ) {
210+ callback (new Error (t (' datasource.Please_select' ) + t (' common.empty' ) + t (' ds.title' )))
211+ } else {
212+ callback ()
213+ }
214+ }
215+
200216const rules = {
201217 word: [
202218 {
@@ -211,6 +227,16 @@ const rules = {
211227 t (' datasource.please_enter' ) + t (' common.empty' ) + t (' professional.term_description' ),
212228 },
213229 ],
230+ datasource_ids: [
231+ {
232+ validator: validatePass ,
233+ trigger: ' blur' ,
234+ },
235+ ],
236+ }
237+
238+ const handleChange = () => {
239+ termFormRef .value .validateField (' datasource_ids' )
214240}
215241
216242const saveHandler = () => {
@@ -241,7 +267,11 @@ const saveHandler = () => {
241267 }
242268 })
243269}
244-
270+ const list = () => {
271+ datasourceApi .list ().then ((res ) => {
272+ allDsList .value = res
273+ })
274+ }
245275const editHandler = (row : any ) => {
246276 pageForm .value .id = null
247277 if (row ) {
@@ -254,6 +284,7 @@ const editHandler = (row: any) => {
254284 ? t (' professional.editing_terminology' )
255285 : t (' professional.create_new_term' )
256286 dialogFormVisible .value = true
287+ list ()
257288}
258289
259290const onFormClose = () => {
@@ -353,10 +384,7 @@ const deleteHandlerItem = (idx: number) => {
353384 }}
354385 </template >
355386 </el-table-column >
356- <el-table-column
357- prop =" description"
358- :label =" $t('professional.term_description')"
359- min-width =" 240"
387+ <el-table-column :label =" $t('professional.term_description')" min-width =" 240"
360388 ><template #default =" scope " >
361389 <div class =" field-comment_d" >
362390 <span :title =" scope.row.description" class =" notes-in_table" >{{
@@ -365,6 +393,16 @@ const deleteHandlerItem = (idx: number) => {
365393 </div >
366394 </template >
367395 </el-table-column >
396+ <el-table-column :label =" $t('training.effective_data_sources')" min-width =" 240"
397+ ><template #default =" scope " >
398+ <div v-if =" scope.row.specific_ds" class =" field-comment_d" >
399+ <span :title =" scope.row.datasource_names" class =" notes-in_table" >{{
400+ scope.row.datasource_names.join(',')
401+ }}</span >
402+ </div >
403+ <div v-else >{{ t('training.all_data_sources') }}</div >
404+ </template >
405+ </el-table-column >
368406 <el-table-column
369407 prop =" create_time"
370408 sortable
@@ -490,6 +528,28 @@ const deleteHandlerItem = (idx: number) => {
490528 type =" textarea"
491529 />
492530 </el-form-item >
531+ <el-form-item
532+ class =" is-required"
533+ :class =" !pageForm.specific_ds && 'no-error'"
534+ prop =" datasource_ids"
535+ :label =" t('training.effective_data_sources')"
536+ >
537+ <el-radio-group v-model =" pageForm.specific_ds" >
538+ <el-radio :value =" false" >{{ $t('training.all_data_sources') }}</el-radio >
539+ <el-radio :value =" true" >{{ $t('training.partial_data_sources') }}</el-radio >
540+ </el-radio-group >
541+ <el-select
542+ v-model =" pageForm.datasource_ids"
543+ multiple
544+ v-if =" pageForm.specific_ds"
545+ filterable
546+ @change =" handleChange"
547+ :placeholder =" $t('datasource.Please_select') + $t('common.empty') + $t('ds.title')"
548+ style =" width : 100% ; margin-top : 8px "
549+ >
550+ <el-option v-for =" item in allDsList" :key =" item.id" :label =" item.name" :value =" item.id" />
551+ </el-select >
552+ </el-form-item >
493553
494554 <el-form-item >
495555 <template #label >
@@ -563,6 +623,15 @@ const deleteHandlerItem = (idx: number) => {
563623 {{ pageForm.other_words.join(',') }}
564624 </div >
565625 </el-form-item >
626+ <el-form-item :label =" t('training.effective_data_sources')" >
627+ <div class =" content" >
628+ {{
629+ pageForm.specific_ds
630+ ? pageForm.datasource_names.join(',')
631+ : t('training.all_data_sources')
632+ }}
633+ </div >
634+ </el-form-item >
566635 <el-form-item :label =" t('professional.term_description')" >
567636 <div class =" content" >
568637 {{ pageForm.description }}
@@ -762,6 +831,12 @@ const deleteHandlerItem = (idx: number) => {
762831}
763832
764833.professional-add_drawer {
834+ .no-error.no-error {
835+ .ed-form-item__error {
836+ display : none ;
837+ }
838+ margin-bottom : 16px ;
839+ }
765840 .ed-textarea__inner {
766841 line-height : 22px ;
767842 }
0 commit comments