|
125 | 125 | </div> |
126 | 126 | <el-select |
127 | 127 | :teleported="false" |
128 | | - v-if=" |
129 | | - modelValue['api_input_field_list'][f.field] && |
130 | | - trigger.trigger_type === 'EVENT' && |
131 | | - trigger.trigger_setting.body.length |
132 | | - " |
| 128 | + v-if="modelValue['api_input_field_list'][f.field] && showSource" |
133 | 129 | v-model="modelValue['api_input_field_list'][f.field].source" |
134 | 130 | size="small" |
135 | 131 | style="width: 85px" |
|
158 | 154 | </el-form> |
159 | 155 | </template> |
160 | 156 | <script setup lang="ts"> |
161 | | -import { computed, ref } from 'vue' |
| 157 | +import { computed, ref, watch } from 'vue' |
162 | 158 | import { type FormInstance } from 'element-plus' |
163 | 159 | import { t } from '@/locales' |
164 | 160 | const applicationParameterFormRef = ref<FormInstance>() |
165 | 161 | const props = defineProps<{ application?: any; modelValue: any; trigger: any }>() |
166 | 162 | const emit = defineEmits(['update:modelValue']) |
167 | | -
|
| 163 | +const showSource = computed(() => { |
| 164 | + return props.trigger.trigger_type === 'EVENT' && props.trigger.trigger_setting.body.length > 0 |
| 165 | +}) |
| 166 | +watch( |
| 167 | + () => showSource.value, |
| 168 | + () => { |
| 169 | + if (!showSource.value) { |
| 170 | + const parameter: any = { ...props.modelValue } |
| 171 | + base_field_list.value.forEach((f) => { |
| 172 | + if (!parameter[f.field]) { |
| 173 | + parameter[f.field] = { source: 'custom', value: f.default_value } |
| 174 | + } else { |
| 175 | + parameter[f.field] = { ...parameter[f.field], source: 'custom' } |
| 176 | + } |
| 177 | + }) |
| 178 | + api_input_field_list.value.forEach((f) => { |
| 179 | + if (!parameter.api_input_field_list) { |
| 180 | + parameter['api_input_field_list'] = {} |
| 181 | + } |
| 182 | + if (!parameter['api_input_field_list'][f.field]) { |
| 183 | + parameter['api_input_field_list'][f.field] = { |
| 184 | + source: 'custom', |
| 185 | + value: f.default_value ? f.default_value : '', |
| 186 | + } |
| 187 | + } else { |
| 188 | + parameter['api_input_field_list'][f.field] = { |
| 189 | + ...parameter['api_input_field_list'][f.field], |
| 190 | + source: 'custom', |
| 191 | + } |
| 192 | + } |
| 193 | + }) |
| 194 | + user_input_field_list.value.forEach((f) => { |
| 195 | + if (!parameter['user_input_field_list']) { |
| 196 | + parameter['user_input_field_list'] = {} |
| 197 | + } |
| 198 | + if (!parameter['user_input_field_list'][f.field]) { |
| 199 | + parameter['user_input_field_list'][f.field] = { |
| 200 | + source: 'custom', |
| 201 | + value: f.default_value ? f.default_value : '', |
| 202 | + } |
| 203 | + } else { |
| 204 | + parameter['user_input_field_list'][f.field] = { |
| 205 | + ...parameter['user_input_field_list'][f.field], |
| 206 | + source: 'custom', |
| 207 | + } |
| 208 | + } |
| 209 | + }) |
| 210 | + emit('update:modelValue', { ...parameter }) |
| 211 | + } |
| 212 | + }, |
| 213 | +) |
168 | 214 | const options = computed(() => { |
169 | 215 | if (props.trigger.trigger_type === 'EVENT') { |
170 | 216 | const body = props.trigger.trigger_setting.body |
|
0 commit comments