11<script setup lang="ts">
2- import {
3- connectionsApi ,
4- metadataInstancesApi ,
5- taskApi ,
6- workerApi ,
7- } from ' @tap/api'
8- import { RightBoldOutlined , VEmpty } from ' @tap/component'
9- import VIcon from ' @tap/component/src/base/VIcon'
2+ import { metadataInstancesApi , taskApi } from ' @tap/api'
3+ import { RightBoldOutlined , VEmpty , VIcon } from ' @tap/component'
104import OverflowTooltip from ' @tap/component/src/overflow-tooltip'
5+ import { useI18n } from ' @tap/i18n'
116import { computed , ref , watch } from ' vue'
127import { RecycleScroller } from ' vue-virtual-scroller'
138import { useStore } from ' vuex'
@@ -17,6 +12,7 @@ import { getPrimaryKeyTablesByType } from '../../../util'
1712import ' vue-virtual-scroller/dist/vue-virtual-scroller.css'
1813
1914const store = useStore ()
15+ const { t } = useI18n ()
2016
2117// Props
2218const props = defineProps ({
@@ -25,7 +21,7 @@ const props = defineProps({
2521 required: true ,
2622 },
2723 value: {
28- type: Array as PropType < string []> ,
24+ type: Array ,
2925 default : () => [],
3026 },
3127 disabled: Boolean ,
@@ -232,17 +228,48 @@ const changeSeletedMode = () => {
232228 }
233229}
234230
231+ const getErrorTables = (tables : string []) => {
232+ const errors = {}
233+ const allTables = table .value .tables
234+
235+ if (! loading .value ) {
236+ tables .forEach ((table ) => {
237+ if (! allTables .includes (table )) {
238+ errors [table ] = t (
239+ ' packages_form_component_table_selector_error_not_exit' ,
240+ )
241+ }
242+ })
243+ }
244+
245+ errorTables .value = errors
246+ return errors
247+ }
248+
235249const submitClipboard = () => {
236- selected .value .tables = clipboardTables .value
250+ const errorTables = getErrorTables (clipboardTables .value )
251+
252+ if (Object .keys (errorTables ).length ) return
253+
254+ selected .value .tables = Array .from (
255+ new Set (selected .value .tables .concat (clipboardTables .value )),
256+ )
237257 isOpenClipMode .value = false
238258 emit (' change' , selected .value .tables )
239259}
240260
241261const autofix = () => {
242- selected .value .tables = selected .value .tables .filter (
243- (t ) => ! errorTables .value [t ],
244- )
245- emit (' change' , selected .value .tables )
262+ if (isOpenClipMode .value ) {
263+ clipboardValue .value = clipboardTables .value
264+ .filter ((t ) => ! errorTables .value [t ])
265+ .join (' , ' )
266+ errorTables .value = {}
267+ } else {
268+ selected .value .tables = selected .value .tables .filter (
269+ (t ) => ! errorTables .value [t ],
270+ )
271+ emit (' change' , selected .value .tables )
272+ }
246273}
247274
248275const getTableInfo = (table : string ) => {
@@ -252,7 +279,7 @@ const getTableInfo = (table: string) => {
252279// Watch
253280watch (
254281 () => props .value ,
255- (val ) => {
282+ (val : string [] ) => {
256283 selected .value .tables = val || []
257284 },
258285 { immediate: true },
@@ -641,15 +668,14 @@ getTables()
641668 <span class =" color-danger"
642669 >*{{ $t('packages_form_component_table_selector_error') }}</span
643670 >
644- <ElLink class =" ml-2 " type =" primary" @click =" autofix" >{{
671+ <el-button text class =" ml-1 " type =" primary" @click =" autofix" >{{
645672 $t('packages_form_component_table_selector_autofix')
646- }}</ElLink >
673+ }}</el-button >
647674 </div >
648675 <div v-if =" isOpenClipMode" class =" px-4 pb-4 text-end" >
649- <!-- <ElButton @click="changeSeletedMode()">{{ $t('public_button_cancel') }}</ElButton>-->
650- <ElButton type =" primary" @click =" submitClipboard" >{{
676+ <el-button type =" primary" @click =" submitClipboard" >{{
651677 $t('public_button_confirm')
652- }}</ElButton >
678+ }}</el-button >
653679 </div >
654680 </div >
655681 </div >
0 commit comments