|
4 | 4 | [$style.active]: editorItem.isEdit,
|
5 | 5 | js_viewComponentWrap: true
|
6 | 6 | }"
|
7 |
| - @click="handelClickView" |
| 7 | + @click="handleClickView" |
8 | 8 | >
|
9 | 9 | <span :class="$style.formProperty"> {{ attrs.curNodePath }}</span>
|
10 | 10 | <div v-if="editorItem.isEdit" :class="$style.editBar">
|
|
45 | 45 |
|
46 | 46 | <script>
|
47 | 47 | import { SchemaField } from '@lljj/vue-json-schema-form';
|
| 48 | + import { editorItem2SchemaFieldProps } from '../common/editorData'; |
48 | 49 |
|
49 | 50 | export default {
|
50 | 51 | name: 'ViewComponentWrap',
|
|
63 | 64 | },
|
64 | 65 | computed: {
|
65 | 66 | attrs() {
|
66 |
| - const baseValue = this.editorItem.componentValue.baseValue; |
67 |
| - const { default: defaultValue, uiOptions } = Object.keys(this.editorItem.componentValue.baseValue).reduce((preVal, curVal) => { |
68 |
| - if (curVal === 'default') { |
69 |
| - preVal.default = baseValue[curVal]; |
70 |
| - } else if (baseValue[curVal]) { |
71 |
| - preVal.uiOptions = preVal.uiOptions || {}; |
72 |
| - preVal.uiOptions[curVal] = baseValue[curVal]; |
73 |
| - } |
74 |
| -
|
75 |
| - return preVal; |
76 |
| - }, {}); |
77 |
| -
|
78 |
| - const schema = { |
79 |
| - ...this.editorItem.componentPack.viewSchema, |
80 |
| - default: defaultValue, |
81 |
| - }; |
82 |
| -
|
83 |
| - return { |
84 |
| - rootSchema: schema, |
85 |
| - schema, |
86 |
| - rootFormData: this.formData, |
87 |
| - curNodePath: this.editorItem.componentValue.property || '', |
88 |
| - uiSchema: { |
89 |
| - 'ui:options': uiOptions, |
90 |
| - } |
91 |
| - }; |
| 67 | + return editorItem2SchemaFieldProps(this.editorItem, this.formData); |
92 | 68 | }
|
93 | 69 | },
|
94 | 70 | beforeDestroy() {
|
95 | 71 | this.hideEditForm();
|
96 | 72 | },
|
97 | 73 | methods: {
|
98 | 74 | // 点击只能打开,并且打开状态下只能执行一次
|
99 |
| - handelClickView(e) { |
| 75 | + handleClickView(e) { |
100 | 76 | // 阻止浏览器默认事件
|
101 | 77 | e.preventDefault();
|
102 | 78 | if (!this.editorItem.isEdit) this.showEditForm();
|
|
0 commit comments