Skip to content

Commit 1564a1e

Browse files
committed
Use dialog-input-components
1 parent 0f55024 commit 1564a1e

File tree

7 files changed

+72
-34
lines changed

7 files changed

+72
-34
lines changed

src/components/Dialog.vue

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
<div class="mp-dialog-body">
1212
<div class="mp-dialog-form">
1313
<div class="mp-dialog-field" v-for="field in request.body">
14-
<label>{{ field.title }}</label>
15-
<input class="mp-dialog-input" v-if="field.type === 'input'" v-model="responseData[field.name]">
16-
<textarea class="mp-dialog-input" v-if="field.type === 'textarea'" v-model="responseData[field.name]"></textarea>
17-
<br>
14+
<component :is="field.type" :requestField="field" :param="field.param" @change="handleUpdate"></component>
1815
</div>
1916
</div>
2017

@@ -73,31 +70,10 @@
7370
}
7471
7572
.mp-dialog-field {
76-
margin-bottom: 8px;
73+
margin: 10px 8px;
7774
overflow:auto;
7875
}
79-
.dialog-field label {
80-
padding-top: 5px;
81-
display: inline-block;
82-
vertical-align: top;
83-
width: 75px;
84-
font-size: 14px;
85-
color: #666;
86-
}
8776
88-
.dialog-field textarea {
89-
resize: none;
90-
height: 250px;
91-
overflow: auto;
92-
}
93-
94-
.mp-dialog-input {
95-
display: inline-block;
96-
width: 220px;
97-
color: #999;
98-
padding: 8px;
99-
border: 1px solid #ddd;
100-
}
10177
.mp-dialog-footer {
10278
overflow:auto;
10379
}
@@ -137,6 +113,7 @@
137113

138114
<script>
139115
import 'font-awesome/css/font-awesome.css'
116+
import DialogComponents from './dialog-input-components/components'
140117
141118
export default {
142119
name: 'editor-dialog',
@@ -172,7 +149,11 @@ export default {
172149
},
173150
finish () {
174151
this.$emit('finish', this.response)
152+
},
153+
handleUpdate(request) {
154+
this.responseData[request.name] = request.value
175155
}
176-
}
156+
},
157+
components: DialogComponents
177158
}
178159
</script>

src/components/Toolbar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import 'font-awesome/css/font-awesome.css'
8282
* reqeust: {
8383
* title: "",
8484
* body: [
85-
* {name,title,default}
85+
* {name, title, type, param, default}
8686
* ],
8787
* callback(){} //return the code that needed to be inserted
8888
* }
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<div id="mp-dialog-input">
3+
<label>{{ request.title }}</label>
4+
<input v-model="value">
5+
</div>
6+
</template>
7+
8+
<style>
9+
#mp-dialog-input {
10+
overflow: auto;
11+
}
12+
13+
#mp-dialog-input label {
14+
float: left;
15+
padding-top: 5px;
16+
vertical-align: top;
17+
width: 20%;
18+
font-size: 14px;
19+
color: #666;
20+
}
21+
22+
#mp-dialog-input input {
23+
float: left;
24+
width: 73%;
25+
color: #999;
26+
padding: 8px;
27+
border: 1px solid #ddd;
28+
}
29+
</style>
30+
31+
<script>
32+
export default {
33+
name: 'dialog-input',
34+
props: {
35+
requestField: {
36+
type: Object
37+
}
38+
},
39+
data() {
40+
return {
41+
request: this.requestField,
42+
value :this.requestField.default ? this.requestField.default : ''
43+
}
44+
},
45+
watch: {
46+
value(newValue) {
47+
this.request.value = newValue
48+
this.$emit('change', this.request)
49+
}
50+
}
51+
}
52+
</script>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Input from './input.vue'
2+
3+
export default {
4+
'dialog-input': Input
5+
}

src/components/toolbar-button/btn-img.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ export default {
99
{
1010
name: 'address',
1111
title: '图片地址',
12-
type: 'input',
12+
type: 'dialog-input',
1313
default: ''
1414
},
1515
{
1616
name: 'description',
1717
title: '图片描述',
18-
type: 'input',
18+
type: 'dialog-input',
1919
default: ''
2020
}
2121
],

src/components/toolbar-button/btn-link.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ export default {
99
{
1010
name: 'url',
1111
title: '链接地址',
12-
type: 'input',
12+
type: 'dialog-input',
1313
default: ''
1414
},
1515
{
1616
name: 'description',
1717
title: '链接标题',
18-
type: 'input',
18+
type: 'dialog-input',
1919
default: ''
2020
}
2121
],

src/components/toolbar-button/btn-table.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ export default {
99
{
1010
name: 'row',
1111
title: '行数',
12-
type: 'input',
12+
type: 'dialog-input',
1313
default: '3'
1414
},
1515
{
1616
name: 'col',
1717
title: '列数',
18-
type: 'input',
18+
type: 'dialog-input',
1919
default: '2'
2020
}
2121
],

0 commit comments

Comments
 (0)