@@ -8,7 +8,8 @@ import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
88import edit from ' @/assets/svg/icon_edit_outlined.svg'
99import { useI18n } from ' vue-i18n'
1010import ParamsForm from ' ./ParamsForm.vue'
11-
11+ import TableRelationship from ' @/views/ds/TableRelationship.vue'
12+ import icon_mindnote_outlined from ' @/assets/svg/icon_mindnote_outlined.svg'
1213interface Table {
1314 name: string
1415 host: string
@@ -54,6 +55,7 @@ const paramsFormRef = ref()
5455const tableList = ref ([] as any [])
5556const loading = ref (false )
5657const initLoading = ref (false )
58+ const activeRelationship = ref (false )
5759const keywords = ref (' ' )
5860const tableListWithSearch = computed (() => {
5961 if (! keywords .value ) return tableList .value
@@ -66,13 +68,29 @@ const showNum = ref(100)
6668const currentTable = ref <any >({})
6769const ds = ref <any >({})
6870const btnSelect = ref (' d' )
69-
71+ const isDrag = ref (false )
72+ const tableName = ref <any []>([])
7073const pageInfo = reactive ({
7174 currentPage: 1 ,
7275 pageSize: 10 ,
7376 total: 0 ,
7477})
78+ const handleRelationship = () => {
79+ activeRelationship .value = ! activeRelationship .value
80+ currentTable .value = {}
81+ }
82+ const singleDragStartD = (e : DragEvent , ele : any ) => {
83+ isDrag .value = true
84+ e .dataTransfer ! .setData (' table' , JSON .stringify (ele ))
85+ }
7586
87+ const getTableName = (val : any ) => {
88+ tableName .value = val
89+ }
90+
91+ const singleDragEnd = () => {
92+ isDrag .value = false
93+ }
7694const handleSizeChange = (val : number ) => {
7795 pageInfo .currentPage = 1
7896 pageInfo .pageSize = val
@@ -119,6 +137,7 @@ const handleSelectTableList = () => {
119137}
120138
121139const clickTable = (table : any ) => {
140+ if (activeRelationship .value ) return
122141 loading .value = true
123142 currentTable .value = table
124143 fieldList .value = []
@@ -290,8 +309,14 @@ const btnSelectClick = (val: any) => {
290309 <div
291310 v-for =" ele in tableListWithSearch"
292311 :key =" ele.table_name"
312+ :draggable =" activeRelationship && !tableName.includes(ele.id)"
293313 class =" model"
294- :class =" currentTable.table_name === ele.table_name && 'isActive'"
314+ @dragstart =" ($event: any) => singleDragStartD($event, ele)"
315+ @dragend =" singleDragEnd"
316+ :class =" [
317+ currentTable.table_name === ele.table_name && 'isActive',
318+ tableName.includes(ele.id) && activeRelationship && 'disabled-table',
319+ ]"
295320 :title =" ele.table_name"
296321 @click =" clickTable(ele)"
297322 >
@@ -318,9 +343,32 @@ const btnSelectClick = (val: any) => {
318343 </div >
319344 </div >
320345 </div >
346+ <div class =" table-relationship" >
347+ <div @click =" handleRelationship" :class =" activeRelationship && 'active'" class =" btn" >
348+ <el-icon size =" 16" >
349+ <icon _mindnote_outlined ></icon _mindnote_outlined >
350+ </el-icon >
351+ {{ t('training.table_relationship_management') }}
352+ </div >
353+ </div >
354+ </div >
355+
356+ <div v-if =" activeRelationship" class =" relationship-content" >
357+ <div class =" title" >{{ t('training.table_relationship_management') }}</div >
358+ <div class =" content" >
359+ <TableRelationship
360+ @getTableName =" getTableName"
361+ :dragging =" isDrag"
362+ :id =" info.id"
363+ ></TableRelationship >
364+ </div >
321365 </div >
322366
323- <div v-if =" currentTable.table_name" v-loading =" loading" class =" info-table" >
367+ <div
368+ v-if =" currentTable.table_name && !activeRelationship"
369+ v-loading =" loading"
370+ class =" info-table"
371+ >
324372 <div class =" table-name" >
325373 <div class =" name" >{{ currentTable.table_name }}</div >
326374 <div class =" notes" >
@@ -336,6 +384,7 @@ const btnSelectClick = (val: any) => {
336384 </el-tooltip >
337385 </div >
338386 </div >
387+
339388 <div class =" table-content" >
340389 <div class =" btn-select" >
341390 <el-button
@@ -532,6 +581,46 @@ const btnSelectClick = (val: any) => {
532581 padding : 8px 16px ;
533582 height : 100% ;
534583 border-right : 1px solid #1f232926 ;
584+ .table-relationship {
585+ height : 56px ;
586+ width : 100% ;
587+ display : flex ;
588+ align-items : center ;
589+ margin-top : 20px ;
590+ position : relative ;
591+
592+ & ::after {
593+ content : ' ' ;
594+ width : calc (100% + 32px );
595+ position : absolute ;
596+ left : -16px ;
597+ background-color : #1f232926 ;
598+ top : 0 ;
599+ height : 1px ;
600+ }
601+
602+ .btn {
603+ width : 248px ;
604+ height : 32px ;
605+ cursor : pointer ;
606+ border-radius : 6px ;
607+ display : flex ;
608+ align-items : center ;
609+ padding-left : 8px ;
610+ .ed-icon {
611+ color : #646a73 ;
612+ margin-right : 8px ;
613+ }
614+
615+ & .active {
616+ color : var (--ed-color-primary );
617+ .ed-icon {
618+ color : var (--ed-color-primary );
619+ }
620+ background-color : var (--ed-color-primary-1a );
621+ }
622+ }
623+ }
535624 .select-table_top {
536625 height : 40px ;
537626 display : flex ;
@@ -551,7 +640,7 @@ const btnSelectClick = (val: any) => {
551640 }
552641
553642 .list-content {
554- height : calc (100% - 100 px );
643+ height : calc (100% - 156 px );
555644 .no-result {
556645 margin-top : 72px ;
557646 font-weight : 400 ;
@@ -569,6 +658,12 @@ const btnSelectClick = (val: any) => {
569658 border-radius : 4px ;
570659 cursor : pointer ;
571660
661+ & .disabled-table {
662+ background : #dee0e3 !important ;
663+ color : #646a73 ;
664+ cursor : not-allowed ;
665+ }
666+
572667 .name {
573668 margin-left : 8px ;
574669 font-weight : 500 ;
@@ -604,6 +699,27 @@ const btnSelectClick = (val: any) => {
604699 }
605700 }
606701 }
702+ .relationship-content {
703+ position : absolute ;
704+ right : 0 ;
705+ top : 0 ;
706+ width : calc (100% - 280px );
707+ height : 100% ;
708+
709+ .content {
710+ height : calc (100% - 56px );
711+ width : 100% ;
712+ }
713+
714+ .title {
715+ height : 56px ;
716+ padding-left : 24px ;
717+ line-height : 56px ;
718+ font-weight : 500 ;
719+ font-size : 16px ;
720+ border-bottom : 1px solid #1f232926 ;
721+ }
722+ }
607723 .info-table {
608724 position : absolute ;
609725 right : 0 ;
0 commit comments