forked from opentiny/tiny-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetaForm.vue
More file actions
82 lines (75 loc) · 1.71 KB
/
Copy pathMetaForm.vue
File metadata and controls
82 lines (75 loc) · 1.71 KB
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
75
76
77
78
79
80
81
82
<template>
<div class="demo-form">
<tiny-form label-position="left" label-width="53px">
<template v-for="label in labelList" :key="label">
<tiny-form-item v-if="labelTranslations[label]" :label="labelTranslations[label] || label">
<tiny-input v-model="formData[label]"></tiny-input>
</tiny-form-item>
</template>
<tiny-form-item :class="{ footerbtnHide: footerbtnHide }">
<tiny-button @click="cancel">取消</tiny-button>
<tiny-button @click="confirm">确定</tiny-button>
</tiny-form-item>
</tiny-form>
</div>
</template>
<script>
import { reactive } from 'vue'
import { Form, FormItem, Input, Button } from '@opentiny/vue'
export default {
components: {
TinyForm: Form,
TinyFormItem: FormItem,
TinyInput: Input,
TinyButton: Button
},
props: {
option: {
type: Object,
default: () => ({})
},
footerbtnHide: {
type: Boolean,
default: false
}
},
setup(props, { emit }) {
const labelList = Object.keys(props.option)
const formData = reactive({ ...props.option })
const labelTranslations = {
label: '显示值',
text: '展示值',
zh_CN: '中文',
en_US: '英文',
field: 'field',
title: 'title',
description: '描述',
defaultValue: '缺省值'
}
const cancel = () => {
emit('cancel')
}
const confirm = () => {
emit('confirm', formData)
}
return {
labelList,
formData,
labelTranslations,
cancel,
confirm
}
}
}
</script>
<style lang="less" scoped>
.demo-form {
.tiny-button {
min-width: 50px;
padding: 0 8px;
}
.footerbtnHide {
display: none;
}
}
</style>