11<script lang="tsx">
2- import { discoveryApi , ldpApi , metadataDefinitionsApi } from ' @tap/api'
2+ import {
3+ discoveryApi ,
4+ fetchMetadataInstances ,
5+ ldpApi ,
6+ metadataDefinitionsApi ,
7+ } from ' @tap/api'
38import { makeDragNodeImage , TASK_SETTINGS } from ' @tap/business/src/shared'
49import { IconButton } from ' @tap/component/src/icon-button'
5-
10+ import { FieldSelect , mapFieldsData } from ' @tap/form '
611import i18n from ' @tap/i18n'
712import { generateId , uuid } from ' @tap/shared'
813import { debounce } from ' lodash-es'
@@ -11,7 +16,7 @@ import commonMix from './mixins/common'
1116
1217export default {
1318 name: ' MDM' ,
14- components: { IconButton },
19+ components: { IconButton , FieldSelect },
1520 mixins: [commonMix ],
1621 props: {
1722 directory: Object ,
@@ -43,6 +48,8 @@ export default {
4348 crontabExpression: ' ' ,
4449 crontabExpressionType: ' once' ,
4550 },
51+ fields: [],
52+ updateConditionFields: [],
4653 },
4754 expandedKeys: [],
4855 dialogConfig: {
@@ -256,10 +263,8 @@ export default {
256263
257264 handleDragLeave(ev ) {
258265 ev .preventDefault ()
259- console .log (' handleDragLeave' ) // eslint-disable-line
260266 if (! this .allowDrop ) return
261267 if (! ev .currentTarget .contains (ev .relatedTarget )) {
262- console .log (' handleDragLeave✌️' , ev ) // eslint-disable-line
263268 this .removeDropEffect (ev , ' tree-wrap' , ' is-drop' )
264269 }
265270 },
@@ -315,9 +320,11 @@ export default {
315320 } else {
316321 this .taskDialogConfig .notSupportedCDC = false
317322 }
323+
324+ this .loadFields ()
318325 },
319326
320- async taskDialogSubmit(start , confirmTable ) {
327+ taskDialogSubmit(start , confirmTable ) {
321328 this .$refs .form .validate (async (valid ) => {
322329 if (! valid ) return
323330 const {
@@ -354,7 +361,6 @@ export default {
354361 this .setNodeExpand (tagId )
355362 }, 1000 )
356363 } catch (error ) {
357- console .log (error ) // eslint-disable-line
358364 const code = error ?.data ?.code
359365 const data = error ?.data ?.data
360366 if (code === ' Ldp.MdmTargetNoPrimaryKey' && data ) {
@@ -407,6 +413,9 @@ export default {
407413 makeTask(from , tableName , newTableName ) {
408414 const source = this .getTableNode (from , tableName )
409415 const target = this .getTableNode (this .mdmConnection , newTableName )
416+
417+ target .updateConditionFields = this .taskDialogConfig .updateConditionFields
418+
410419 return {
411420 ... TASK_SETTINGS ,
412421 syncType: ' sync' ,
@@ -533,7 +542,6 @@ export default {
533542 this .removeDropEffect (ev , ' tree-wrap' , ' is-drop' )
534543
535544 this .showTaskDialog (! data .isObject ? data .id : undefined )
536- console .log (' handleTreeDrop' ) // eslint-disable-line
537545 },
538546
539547 handleSelfDrop(draggingNode , dropNode , dropType , ev ) {
@@ -620,6 +628,52 @@ export default {
620628 hideDialog() {
621629 this .dialogConfig .visible = false
622630 },
631+ async loadFields() {
632+ this .taskDialogConfig .loading = true
633+ this .taskDialogConfig .fields = []
634+ this .taskDialogConfig .updateConditionFields = []
635+
636+ const {
637+ items : [schema = {}],
638+ } = await fetchMetadataInstances ({
639+ page: 1 ,
640+ size: 1 ,
641+ where: {
642+ ' source.id' : this .taskDialogConfig .from .id ,
643+ meta_type: { in: [' collection' , ' table' , ' view' ] },
644+ is_deleted: false ,
645+ sourceType: ' SOURCE' ,
646+ original_name: this .taskDialogConfig .tableName ,
647+ },
648+ fields: {
649+ original_name: true ,
650+ fields: true ,
651+ qualified_name: true ,
652+ name: true ,
653+ indices: true ,
654+ constraints: true ,
655+ },
656+ }).finally (() => {
657+ this .taskDialogConfig .loading = false
658+ })
659+
660+ const { fields } = mapFieldsData (schema )
661+ this .taskDialogConfig .fields = fields
662+
663+ let defaultList = fields .filter ((item ) => item .isPrimaryKey )
664+
665+ if (! defaultList .length ) {
666+ defaultList = fields .filter ((item ) => item .indicesUnique )
667+ }
668+
669+ if (! defaultList .length ) {
670+ defaultList = fields .filter ((item ) => item .source === ' virtual_hash' )
671+ }
672+
673+ this .taskDialogConfig .updateConditionFields = defaultList .map (
674+ (item ) => item .value ,
675+ )
676+ },
623677 async dialogSubmit() {
624678 const config = this .dialogConfig
625679 const value = config .label
@@ -968,10 +1022,10 @@ export default {
9681022 <ElFormItem
9691023 :label =" $t (' packages_dag_task_setting_crontabExpressionFlag' )"
9701024 prop="task.crontabExpressionType "
1025+ class="flex-1"
9711026 >
9721027 <ElSelect
9731028 v-model =" taskDialogConfig .task .crontabExpressionType "
974- class="flex-1"
9751029 @change =" handleChangeCronType "
9761030 >
9771031 <ElOption v-for =" (opt , i ) in cronOptions " v-bind =" opt " :key =" i " />
@@ -980,11 +1034,24 @@ export default {
9801034 <ElFormItem
9811035 v-if =" taskDialogConfig .task .crontabExpressionType === ' custom' "
9821036 prop="task.crontabExpression "
983- label-width="0"
1037+ class="flex-1"
1038+ label-width="auto"
1039+ :label =" $t (' public_crontabExpression' )"
9841040 >
9851041 <ElInput v-model =" taskDialogConfig .task .crontabExpression " />
9861042 </ElFormItem >
9871043 </div >
1044+ <ElFormItem
1045+ :label =" $t (' packages_dag_nodes_table_gengxintiaojianzi' )"
1046+ prop="updateConditionFields"
1047+ >
1048+ <FieldSelect
1049+ v-model =" taskDialogConfig .updateConditionFields "
1050+ :options =" taskDialogConfig .fields "
1051+ multiple
1052+ :loading =" taskDialogConfig .loading "
1053+ />
1054+ </ElFormItem >
9881055 </ElForm >
9891056 <template #footer >
9901057 <span class =" dialog-footer" >
0 commit comments