-
Notifications
You must be signed in to change notification settings - Fork 1
/
EditName.vue
51 lines (51 loc) · 1.06 KB
/
EditName.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<template>
<div>
<el-dialog :title="item.title" :visible.sync="item.show">
<el-form @submit.native.prevent>
<el-form-item label="标题" required>
<el-input ref="input" v-model="item.name" @keyup.enter.native.stop="wayEdit"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="wayEdit">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
props: {
item: {
type: Object,
default: () => {
return {
show: false,
name: '',
title: '编辑'
}
}
}
},
watch: {
'item.show': {
handler: function (val) {
if (val) {
this.$nextTick(() => {
this.$refs.input.focus()
})
}
}
}
},
methods: {
wayEdit() {
if (this.item.name === '') {
this.$message.warning('名称不能为空')
return false
}
this.$emit('wayEdit')
this.item.show = false
}
}
}
</script>