diff --git a/src/directive/focus/focus.js b/src/directive/focus/focus.js index 7c3b68b65..512c0d1df 100644 --- a/src/directive/focus/focus.js +++ b/src/directive/focus/focus.js @@ -1,18 +1,21 @@ export default { - // 当被绑定的元素插入到 DOM 中时 - inserted: function (el, obj) { - // 这是需要页面刚加载就能进行聚焦操作使用的钩子函数,可以省略的,视具体需求而定 - // 对值进行判断 - if (obj.value) { - // 聚焦元素 - el.focus(); - } - }, - // 当指令所在组件的 VNode 及其子 VNode 全部更新后调用 - // 这是每当绑定的值发生改变时触发的钩子函数 - componentUpdated: function (el, obj) { - if (obj.value) { - el.focus(); - } - } + // 当被绑定的元素插入到 DOM 中时 + inserted: function (el, obj) { + // 这是需要页面刚加载就能进行聚焦操作使用的钩子函数,可以省略的,视具体需求而定 + // 对值进行判断 + const dom = el.querySelector('input') || el.querySelector('textarea'); + dom.focus(); + // el.focus(); + // if (obj.value) { + // // 聚焦元素 + // el.focus(); + // } + }, + // 当指令所在组件的 VNode 及其子 VNode 全部更新后调用 + // 这是每当绑定的值发生改变时触发的钩子函数 + componentUpdated: function (el, obj) { + if (obj.value) { + el.focus(); + } + } }; diff --git a/src/views/competitionManage/practiceList/create.vue b/src/views/competitionManage/practiceList/create.vue index 498c4d1a6..e612b68b7 100644 --- a/src/views/competitionManage/practiceList/create.vue +++ b/src/views/competitionManage/practiceList/create.vue @@ -19,13 +19,18 @@ export default { default() { return ''; } + }, + raceList:{ + type: Array, + default() { + return ''; + } } }, data() { return { dialogVisible: false, - mapList: [], - taskStatusList: [], + isEdit:false, formModel: { name: '', mapId: '', @@ -34,11 +39,19 @@ export default { }; }, computed: { + raceInfoList() { + const racelist = []; + this.raceList.forEach(each=>{ + racelist.push({label:each.name, value:each.id}); + }); + return racelist; + }, form() { const form = { labelWidth: '120px', items: [ { prop: 'name', label: '实操名称', type: 'text' }, + { prop:'raceId', label:'竞赛名称', type:'select', options:this.raceInfoList, disabled:this.isEdit}, { prop: 'description', label: '实操描述', type: 'textarea' } ] }; @@ -53,6 +66,9 @@ export default { description: [ { validator: this.validateDescription, trigger: 'blur' }, { validator: this.validateDescription, trigger: 'change' } + ], + raceId:[ + { required: true, message: '请选择竞赛', trigger: 'change' } ] }; return crules; @@ -82,12 +98,13 @@ export default { this.formModel = data; this.formModel.id = questid; this.dialogVisible = true; + this.isEdit = true; }); } else { this.formModel.mapId = this.$route.params.mapId; this.dialogVisible = true; + this.isEdit = false; } - }, doCreate() { const self = this; diff --git a/src/views/competitionManage/practiceList/index.vue b/src/views/competitionManage/practiceList/index.vue index 95512d719..401a0b737 100644 --- a/src/views/competitionManage/practiceList/index.vue +++ b/src/views/competitionManage/practiceList/index.vue @@ -1,8 +1,8 @@