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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
| <template>
| <b-modal
| :title="title"
| ref="myModalRef"
| ok-title="保存"
| @ok="handleOk"
| @cancel="clearName"
| cancel-title="取消"
| >
| <div>
| <b-form-group
| horizontal
| label="角色名称:"
| :label-cols="2"
| label-class="text-sm-right"
| label-for="input_username"
| >
| <b-form-input
| autocomplete="off"
| required
| id="input_username"
| v-model="name"
| placeholder="请输入角色名称"
| />
| </b-form-group>
| </div>
| </b-modal>
| </template>
|
| <script>
| export default {
| props: {
| title: String,
| item: Object
| },
| data: () => ({
| name: ''
| }),
| methods: {
| // * 打开modal
| showModel() {
| this.$refs.myModalRef.show()
| this.$nextTick(() => {
| this.reView(this.item)
| })
| },
| hideModel () {
| this.$refs.myModalRef.hide()
| },
| // 回显
| reView(item) {
| if (item) {
| this.name = item.name
| } else {
| this.name = ''
| }
| },
| // * 提交表单
| handleOk(e) {
| e.preventDefault()
| if (!this.name) {
| this.$toast({
| type: 'warning',
| message: '请输入角色名称'
| })
| return
| }
| this.$emit('submit', this.name, this.item ? this.item.id : '')
| },
| // * 取消
| clearName() {}
| }
| }
| </script>
|
|