index.vue
2.06 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
<template>
<el-dialog v-bind="$attrs" :close-on-click-modal="false" :modal-append-to-body="false"
append-to-body v-on="$listeners" @open="onOpen" @close="onClose"
class="NCC-dialog NCC-dialog_center" title="预览" :width="formConf.generalWidth">
<parser :form-conf="formConf" @submit="sumbitForm" :key="key" ref="dynamicForm"
:setFormData="setFormData" :setShowOrHide="setShowOrHide" :setRequired="setRequired"
:setDisabled="setDisabled" :setFieldOptions="setFieldOptions" />
<div slot="footer">
<el-button @click="close">{{formConf.cancelButtonText||'取 消'}}</el-button>
<el-button type="primary" @click="handelConfirm">{{formConf.confirmButtonText||'确 定'}}
</el-button>
</div>
</el-dialog>
</template>
<script>
import Parser from '@/components/Generator/parser/Parser'
import ParserMixin from '@/components/Generator/parser/mixin'
export default {
components: { Parser },
mixins: [ParserMixin],
props: ['formData'],
data() {
return {
}
},
computed: {},
watch: {},
created() { },
mounted() { },
methods: {
onOpen() {
this.key = +new Date()
this.formConf = this.formData
},
onClose() {
},
close(e) {
this.$emit('update:visible', false)
},
handelConfirm() {
this.$refs.dynamicForm && this.$refs.dynamicForm.submitForm()
},
fillFormData(form, data) {
const loop = list => {
for (let i = 0; i < list.length; i++) {
let item = list[i]
if (item.__vModel__) {
const val = data[item.__vModel__]
if (val !== undefined) item.__config__.defaultValue = val
}
if (item.__config__ && item.__config__.nccKey !== 'table' && item.__config__.children && Array.isArray(item.__config__.children)) {
loop(item.__config__.children)
}
}
}
loop(form.fields)
},
sumbitForm(data, callback) {
console.log('sumbitForm提交数据:', data)
if (callback && typeof callback === "function") {
callback()
}
},
}
}
</script>