@@ -47,11 +47,14 @@ const props = withDefaults(
4747const emit = defineEmits <{
4848 ' update-rules' : [data : any []]
4949 ' open-update-rules' : []
50- ' update-fields ' : [updater : (fields : any []) => void ]
50+ updateFields : [updater : (fields : any []) => void , tableName ? : string ]
5151}>()
5252
5353const dataflowStore = useDataflowStore ()
54- const activeNode = computed (() => dataflowStore .selectedNode )
54+ const activeNode = computed <any >(() => dataflowStore .selectedNode )
55+ const isDatabaseNode = computed <boolean >(
56+ () => activeNode .value .type === ' database' ,
57+ )
5558
5659const tableRef = useTemplateRef <InstanceType <typeof VTable >>(' table' )
5760
@@ -258,7 +261,7 @@ function handleUpdate(data?: any[]) {
258261}
259262
260263function submitEdit() {
261- const { qualified_name, nodeId } = props .data
264+ const { nodeId, ancestorsName } = props .data
262265 const {
263266 changeRuleId,
264267 fieldName,
@@ -315,7 +318,7 @@ function submitEdit() {
315318 const _originType = originType .value
316319 const _coefficient = coefficient
317320 const _ruleId = ruleId
318- emit ( ' update-fields ' , (fields : any []) => {
321+ const updater = (fields : any []) => {
319322 fields .forEach ((t : any ) => {
320323 const fieldOriginType = t .data_type ?.split (' (' )[0 ]
321324 if (fieldOriginType === _originType && t .dataTypeTemp ) {
@@ -328,7 +331,10 @@ function submitEdit() {
328331 t .changeRuleId = _ruleId
329332 }
330333 })
331- })
334+ }
335+ isDatabaseNode .value
336+ ? emit (' updateFields' , updater )
337+ : updater (props .data .fields )
332338 handleUpdate ()
333339 ElMessage .success (i18n .t (' public_message_operation_success' ))
334340 editDataTypeVisible .value = false
@@ -376,7 +382,9 @@ function submitEdit() {
376382 const op = {
377383 id: uuid (),
378384 scope: useToAll ? ' Node' : ' Field' ,
379- namespace: useToAll ? [nodeId ] : [nodeId , qualified_name , fieldName ],
385+ namespace: useToAll
386+ ? [nodeId ]
387+ : [nodeId , isDatabaseNode .value ? ancestorsName : null , fieldName ],
380388 type: ' DataType' ,
381389 accept: dataTypeTemp ,
382390 result: { dataType: newDataType , tapType , selectDataType },
@@ -391,19 +399,32 @@ function submitEdit() {
391399 const _fieldName = fieldName
392400 const _newDataType = newDataType
393401 const _ruleId = ruleId
394- emit ( ' update-fields ' , (fields : any [], qualifiedName : string ) => {
402+ const updater = (fields : any [], tableName ? : string ) => {
395403 fields .forEach ((t : any ) => {
396404 if (
397405 (_useToAll &&
398406 t .data_type === t .dataTypeTemp &&
399407 t .dataTypeTemp === _dataTypeTemp ) ||
400- (t .field_name === _fieldName && qualifiedName === qualified_name )
408+ (t .field_name === _fieldName && tableName === ancestorsName )
401409 ) {
402410 t .data_type = _newDataType
403411 t .changeRuleId = _ruleId
404412 }
405413 })
406- })
414+ }
415+ isDatabaseNode .value
416+ ? emit (' updateFields' , updater )
417+ : props .data .fields .forEach ((t : any ) => {
418+ if (
419+ (_useToAll &&
420+ t .data_type === t .dataTypeTemp &&
421+ t .dataTypeTemp === _dataTypeTemp ) ||
422+ t .field_name === _fieldName
423+ ) {
424+ t .data_type = _newDataType
425+ t .changeRuleId = _ruleId
426+ }
427+ })
407428 handleUpdate ()
408429 editBtnLoading .value = false
409430 ElMessage .success (i18n .t (' public_message_operation_success' ))
@@ -463,6 +484,13 @@ function getRevokeDisabled(row: any) {
463484}
464485
465486function getFieldScope(row : any = {}) {
487+ console .log (' getFieldScope' )
488+ console .log (
489+ row .changeRuleId ,
490+ props .fieldChangeRules ,
491+ props .fieldChangeRules .find ((t ) => t .id === row .changeRuleId )?.scope ,
492+ )
493+
466494 return props .fieldChangeRules .find ((t ) => t .id === row .changeRuleId )?.scope
467495}
468496
0 commit comments