22import { ref , computed } from ' vue'
33import AuthTree from ' ./AuthTree.vue'
44import { useI18n } from ' vue-i18n'
5+ import { variablesApi } from ' @/api/variables'
56
67const { t } = useI18n ()
78const errorMessage = ref (' ' )
@@ -26,9 +27,10 @@ const svgDashinePath = computed(() => {
2627 return path
2728})
2829
29- const init = (expressionTree : any ) => {
30+ const init = async (expressionTree : any ) => {
3031 const { logic : lg = ' or' , items = [] } = expressionTree
3132 logic .value = lg
33+ await getVariables ()
3234 relationList .value = dfsInit (items )
3335}
3436const submit = () => {
@@ -65,6 +67,17 @@ const errorDetected = ({ filter_type, field_id, term, value, value_type, variabl
6567 }
6668 }
6769}
70+ const variables = ref <any []>([])
71+ const getVariables = () => {
72+ return variablesApi .listAll ().then ((res : any ) => {
73+ variables .value = res || []
74+ })
75+ }
76+
77+ const canPush = (value_type : any , variable_id : any ) => {
78+ if (value_type === ' normal' ) return true
79+ return variables .value .some ((ele ) => ele .id === variable_id )
80+ }
6881const dfsInit = (arr : any []) => {
6982 const elementList: any [] = []
7083 arr .forEach ((ele : any ) => {
@@ -85,16 +98,18 @@ const dfsInit = (arr: any[]) => {
8598 variable_id = ' ' ,
8699 } = ele
87100 const { name } = field || {}
88- elementList .push ({
89- enum_value: enum_value .join (' ,' ),
90- field_id ,
91- filter_type ,
92- term ,
93- value ,
94- name ,
95- value_type ,
96- variable_id ,
97- })
101+ if (canPush (value_type , variable_id )) {
102+ elementList .push ({
103+ enum_value: enum_value .join (' ,' ),
104+ field_id ,
105+ filter_type ,
106+ term ,
107+ value ,
108+ name ,
109+ value_type ,
110+ variable_id ,
111+ })
112+ }
98113 }
99114 })
100115 return elementList
0 commit comments