173173 }]"
174174 v-model =" formModel[field.name]"
175175 :placeholder =" field.description"
176- :autoFocus =" fieldIndex === 0 "
176+ :autoFocus =" fieldIndex === firstIndex "
177177 />
178178 </span >
179179 <span v-else-if =" currentAction.mapping && field.name in currentAction.mapping && currentAction.mapping[field.name].options" >
183183 rules: [{ required: field.required, message: `${$t('message.error.select')}` }]
184184 }]"
185185 :placeholder =" field.description"
186+ :autoFocus =" fieldIndex === firstIndex"
186187 >
187188 <a-select-option key =" " >{{ }}</a-select-option >
188189 <a-select-option v-for =" (opt, optIndex) in currentAction.mapping[field.name].options" :key =" optIndex" >
204205 :filterOption =" (input, option) => {
205206 return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
206207 }"
208+ :autoFocus =" fieldIndex === firstIndex"
207209 >
208210 <a-select-option key =" " >{{ }}</a-select-option >
209211 <a-select-option v-for =" (opt, optIndex) in field.opts" :key =" optIndex" >
224226 :filterOption =" (input, option) => {
225227 return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
226228 }"
229+ :autoFocus =" fieldIndex === firstIndex"
227230 >
228231 <a-select-option key =" " >{{ }}</a-select-option >
229232 <a-select-option v-for =" opt in field.opts" :key =" opt.id" >
239242 rules: [{ required: field.required, message: `${$t('message.error.select')}` }]
240243 }]"
241244 :placeholder =" field.description"
245+ :autoFocus =" fieldIndex === firstIndex"
242246 >
243247 <a-select-option v-for =" (opt, optIndex) in field.opts" :key =" optIndex" >
244248 {{ opt.name && opt.type ? opt.name + ' (' + opt.type + ')' : opt.name || opt.description }}
247251 </span >
248252 <span v-else-if =" field.type==='long'" >
249253 <a-input-number
250- :autoFocus =" fieldIndex === 0 "
254+ :autoFocus =" fieldIndex === firstIndex "
251255 style =" width : 100% ;"
252256 v-decorator =" [field.name, {
253257 rules: [{ required: field.required, message: `${$t('message.validate.number')}` }]
270274 }]"
271275 :placeholder =" field.description"
272276 @blur =" ($event) => handleConfirmBlur($event, field.name)"
277+ :autoFocus =" fieldIndex === firstIndex"
273278 />
274279 </span >
275280 <span v-else-if =" field.name==='certificate' || field.name==='privatekey' || field.name==='certchain'" >
279284 rules: [{ required: field.required, message: `${$t('message.error.required.input')}` }]
280285 }]"
281286 :placeholder =" field.description"
287+ :autoFocus =" fieldIndex === firstIndex"
282288 />
283289 </span >
284290 <span v-else >
285291 <a-input
286- :autoFocus =" fieldIndex === 0 "
292+ :autoFocus =" fieldIndex === firstIndex "
287293 v-decorator =" [field.name, {
288294 rules: [{ required: field.required, message: `${$t('message.error.required.input')}` }]
289295 }]"
@@ -394,7 +400,8 @@ export default {
394400 searchParams: {},
395401 actions: [],
396402 formModel: {},
397- confirmDirty: false
403+ confirmDirty: false ,
404+ firstIndex: 0
398405 }
399406 },
400407 beforeCreate () {
@@ -756,6 +763,7 @@ export default {
756763 })
757764 }
758765 }
766+ this .getFirstIndexFocus ()
759767
760768 this .showAction = true
761769 for (const param of this .currentAction .paramFields ) {
@@ -771,6 +779,16 @@ export default {
771779 this .fillEditFormFieldValues ()
772780 }
773781 },
782+ getFirstIndexFocus () {
783+ this .firstIndex = 0
784+ for (let fieldIndex = 0 ; fieldIndex < this .currentAction .paramFields .length ; fieldIndex++ ) {
785+ const field = this .currentAction .paramFields [fieldIndex]
786+ if (! (this .currentAction .mapping && field .name in this .currentAction .mapping && this .currentAction .mapping [field .name ].value )) {
787+ this .firstIndex = fieldIndex
788+ break
789+ }
790+ }
791+ },
774792 listUuidOpts (param ) {
775793 if (this .currentAction .mapping && param .name in this .currentAction .mapping && ! this .currentAction .mapping [param .name ].api ) {
776794 return
0 commit comments