11<script lang="ts" setup>
22import icon_deleteTrash_outlined from ' @/assets/svg/icon_delete.svg'
3- import { ref , inject , computed , onBeforeMount , toRefs , type Ref } from ' vue'
3+ import { ref , inject , computed , onBeforeMount , toRefs , type Ref , shallowRef } from ' vue'
4+ import { variablesApi } from ' @/api/variables'
45import { useI18n } from ' vue-i18n'
56import { allOptions } from ' ../options'
67export interface Item {
@@ -10,6 +11,8 @@ export interface Item {
1011 enum_value: string
1112 name: string
1213 value: any
14+ value_type: any
15+ variable_id: any
1316}
1417
1518export interface sysVariable {
@@ -32,6 +35,8 @@ const props = withDefaults(defineProps<Props>(), {
3235 enum_value: ' ' ,
3336 name: ' ' ,
3437 value: null ,
38+ value_type: ' normal' ,
39+ variable_id: undefined ,
3540 }),
3641})
3742
@@ -41,15 +46,25 @@ const keywords = ref('')
4146const activeName = ref ()
4247const checklist = ref <string []>([])
4348const filterList = ref <any []>([])
44-
49+ const variables = shallowRef <any []>([])
50+ const valueTypeList = [
51+ {
52+ value: ' normal' ,
53+ label: t (' variables.normal_value' ),
54+ },
55+ {
56+ value: ' variable' ,
57+ label: t (' variables.system_variables' ),
58+ },
59+ ]
4560const { item } = toRefs (props )
4661
4762const filedList = inject (' filedList' ) as Ref <any []>
4863
4964const computedWidth = computed (() => {
5065 const { field_id } = item .value
5166 return {
52- width: ! field_id ? ' 270px' : ' 670px ' ,
67+ width: ! field_id ? ' 270px' : ' 770px ' ,
5368 }
5469})
5570
@@ -69,8 +84,15 @@ const dimensions = computed(() => {
6984onBeforeMount (() => {
7085 initNameEnumName ()
7186 filterListInit ()
87+ getVariables ()
7288})
7389
90+ const getVariables = () => {
91+ variablesApi .listAll ().then ((res : any ) => {
92+ variables .value = res || []
93+ })
94+ }
95+
7496const initNameEnumName = () => {
7597 const { name, enum_value, field_id } = item .value
7698 dimensions .value .forEach ((ele ) => {
@@ -103,6 +125,8 @@ const selectItem = ({ field_name, id }: any) => {
103125 filter_type: ' logic' ,
104126 value: ' ' ,
105127 term: ' ' ,
128+ variable_id: undefined ,
129+ value_type: ' normal' ,
106130 })
107131 filterListInit ()
108132 checklist .value = []
@@ -152,6 +176,20 @@ const emits = defineEmits(['update:item', 'del'])
152176 >
153177 </el-option >
154178 </el-select >
179+ <el-select
180+ v-model =" item.value_type"
181+ style =" width : 102px ; margin-left : 8px "
182+ :placeholder =" $t('permission.conditional_filtering')"
183+ @change =" filterTypeChange"
184+ >
185+ <el-option
186+ v-for =" ele in valueTypeList"
187+ :key =" ele.value"
188+ :label =" ele.label"
189+ :value =" ele.value"
190+ >
191+ </el-option >
192+ </el-select >
155193 <el-select
156194 v-if =" ['null', 'not_null', 'empty', 'not_empty'].includes(item.term)"
157195 v-model =" item.term"
@@ -167,7 +205,7 @@ const emits = defineEmits(['update:item', 'del'])
167205 </el-option >
168206 </el-select >
169207 <el-input
170- v-else
208+ v-else-if = " item.value_type === 'normal' "
171209 v-model =" item.value"
172210 style =" max-width : 280px ; margin-left : 8px "
173211 :placeholder =" $t('datasource.please_enter')"
@@ -190,6 +228,29 @@ const emits = defineEmits(['update:item', 'del'])
190228 </el-select >
191229 </template >
192230 </el-input >
231+ <template v-else >
232+ <el-select
233+ v-model =" item.term"
234+ style =" width : 75px ; margin-left : 8px "
235+ :placeholder =" t('datasource.Please_select')"
236+ >
237+ <el-option
238+ v-for =" ele in operators"
239+ :key =" ele.value"
240+ :label =" t(ele.label)"
241+ :value =" ele.value"
242+ >
243+ </el-option >
244+ </el-select >
245+ <el-select
246+ v-model =" item.variable_id"
247+ style =" max-width : 197px ; margin-left : 8px "
248+ :placeholder =" t('datasource.Please_select')"
249+ >
250+ <el-option v-for =" ele in variables" :key =" ele.id" :label =" ele.name" :value =" ele.id" >
251+ </el-option >
252+ </el-select >
253+ </template >
193254 </template >
194255 <el-icon v-if =" showDel" class =" font16" @click =" emits('del')" >
195256 <icon _deleteTrash_outlined />
0 commit comments