rb-document-form-constructor 0.9.16 → 0.9.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rb-document-form-constructor.esm.js +25 -11
- package/dist/rb-document-form-constructor.min.js +2 -2
- package/dist/rb-document-form-constructor.ssr.js +31 -17
- package/dist/scss/_global.scss +3 -3
- package/dist/scss/_variables.scss +17 -17
- package/dist/scss/components/_doc-form.scss +36 -36
- package/dist/scss/components/_doc-template-constructor.scss +112 -112
- package/dist/scss/components/_doc-template-facet-list.scss +46 -46
- package/dist/scss/components/_doc-template-field-sidebar.scss +52 -52
- package/dist/scss/components/_field-rule-form-modal.scss +27 -27
- package/dist/scss/components.scss +7 -7
- package/package.json +61 -61
- package/src/components/DocForm.vue +308 -301
- package/src/components/DocTemplateConstructor.vue +262 -262
- package/src/components/DocTemplateFacetList.vue +127 -127
- package/src/components/DocTemplateFieldSidebar.vue +293 -293
- package/src/components/DocTemplateSectionModal.vue +63 -63
- package/src/components/FieldRuleFormModal.vue +287 -287
|
@@ -1,262 +1,262 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="rb-doc-template-constructor d-flex">
|
|
3
|
-
<doc-template-facet-list @fieldMoveEnd="onFieldMoveEnd" :facets="facets">
|
|
4
|
-
<template #action>
|
|
5
|
-
<slot name="action"></slot>
|
|
6
|
-
</template>
|
|
7
|
-
<template #actionField="{field}">
|
|
8
|
-
<slot :field="field" name="actionField"></slot>
|
|
9
|
-
</template>
|
|
10
|
-
</doc-template-facet-list>
|
|
11
|
-
|
|
12
|
-
<div class="rb-form-constructor flex-fill">
|
|
13
|
-
<div class="rb-constructor-toolbar d-flex flex-row">
|
|
14
|
-
<h4>Добавить секцию: </h4>
|
|
15
|
-
<div class="rb-layout-buttons">
|
|
16
|
-
<b-button pill variant="outline-gray" @click="addSection(1)">
|
|
17
|
-
<rb-text>Секция с 1 колонкой</rb-text>
|
|
18
|
-
<rb-icon :icon="iconAdd"></rb-icon>
|
|
19
|
-
</b-button>
|
|
20
|
-
<b-button pill variant="outline-gray" @click="addSection(2)">
|
|
21
|
-
<rb-text>Секция с 2 колонками</rb-text>
|
|
22
|
-
<rb-icon :icon="iconAdd"></rb-icon>
|
|
23
|
-
</b-button>
|
|
24
|
-
<b-button pill variant="outline-gray" @click="addSection(3)">
|
|
25
|
-
<rb-text>Секция с 3 колонками</rb-text>
|
|
26
|
-
<rb-icon :icon="iconAdd"></rb-icon>
|
|
27
|
-
</b-button>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
<div class="rb-constructor-body">
|
|
32
|
-
<draggable v-model="formConfig.sections"
|
|
33
|
-
:animation="200"
|
|
34
|
-
group="section"
|
|
35
|
-
ghost-class="rb-form-card-moving"
|
|
36
|
-
handle=".rb-row-drag-handle">
|
|
37
|
-
<b-card v-for="(section, index) in formConfig.sections" :key="section.labelRu"
|
|
38
|
-
class="rb-form-card" :data-hash="hash">
|
|
39
|
-
<template #header>
|
|
40
|
-
<rb-icon
|
|
41
|
-
:icon="iconDrag"
|
|
42
|
-
class="cursor-pointer rb-row-drag-handle"></rb-icon>
|
|
43
|
-
<rb-text class="flex-fill" @click="editSection(section)">
|
|
44
|
-
{{ section.labelRu }}
|
|
45
|
-
</rb-text>
|
|
46
|
-
<span class="rb-actions">
|
|
47
|
-
<rb-icon :icon="iconEdit" class="cursor-pointer"
|
|
48
|
-
@click="editSection(section)"></rb-icon>
|
|
49
|
-
<rb-icon :icon="iconDelete" class="cursor-pointer"
|
|
50
|
-
@click="removeSection(section, index)"></rb-icon>
|
|
51
|
-
</span>
|
|
52
|
-
</template>
|
|
53
|
-
|
|
54
|
-
<div class="d-flex flex-row">
|
|
55
|
-
<draggable tag="b-form"
|
|
56
|
-
class="rb-form-column"
|
|
57
|
-
v-for="column in section.columns"
|
|
58
|
-
:key="column.index"
|
|
59
|
-
:class="{'rb-single-column': section.columnCount === 1}"
|
|
60
|
-
v-model="column.fields"
|
|
61
|
-
@add="onFieldAddedToColumn($event, column, section)"
|
|
62
|
-
:animation="200"
|
|
63
|
-
group="fields"
|
|
64
|
-
ghost-class="rb-moving-item"
|
|
65
|
-
handle=".rb-field-drag-handle">
|
|
66
|
-
<b-form-row v-for="field in column.fields" :key="field.name"
|
|
67
|
-
class="cursor-pointer" @click="showProperties(field, $event)">
|
|
68
|
-
<b-col lg="12">
|
|
69
|
-
<b-form-group :label="field.labelRu">
|
|
70
|
-
<template #label>
|
|
71
|
-
<rb-icon :icon="iconDrag" class="rb-field-drag-handle"></rb-icon>
|
|
72
|
-
<rb-text>{{ field.labelRu }}</rb-text>
|
|
73
|
-
<rb-icon :icon="iconDelete" class="rb-remove-field"
|
|
74
|
-
@click.prevent="onRemoveField($event, field, column)">
|
|
75
|
-
</rb-icon>
|
|
76
|
-
</template>
|
|
77
|
-
<component v-bind:is="field.input.type"
|
|
78
|
-
:id="field.name"
|
|
79
|
-
v-if="field.input"
|
|
80
|
-
v-bind="getFieldExtendedPropsData(field)"
|
|
81
|
-
disabled
|
|
82
|
-
class="cursor-pointer">
|
|
83
|
-
</component>
|
|
84
|
-
</b-form-group>
|
|
85
|
-
</b-col>
|
|
86
|
-
</b-form-row>
|
|
87
|
-
</draggable>
|
|
88
|
-
</div>
|
|
89
|
-
</b-card>
|
|
90
|
-
</draggable>
|
|
91
|
-
</div>
|
|
92
|
-
|
|
93
|
-
<doc-template-field-sidebar v-model="sidebarField"
|
|
94
|
-
:visible="sidebarVisible"
|
|
95
|
-
:form-config="formConfig"
|
|
96
|
-
@hide="sidebarVisible=false">
|
|
97
|
-
</doc-template-field-sidebar>
|
|
98
|
-
|
|
99
|
-
<doc-template-section-modal :mode="sectionModalCfg.mode"
|
|
100
|
-
:section="sectionModalCfg.section"
|
|
101
|
-
:on-after-ok="sectionModalCfg.onAfterOk">
|
|
102
|
-
</doc-template-section-modal>
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
|
-
</template>
|
|
106
|
-
|
|
107
|
-
<script>
|
|
108
|
-
import DocTemplateFacetList from "@/components/DocTemplateFacetList";
|
|
109
|
-
import DocTemplateFieldSidebar from "@/components/DocTemplateFieldSidebar";
|
|
110
|
-
import DocTemplateSectionModal from "@/components/DocTemplateSectionModal";
|
|
111
|
-
import draggable from 'vuedraggable';
|
|
112
|
-
import {UtFormConfig} from "../utils/UtFormConfig";
|
|
113
|
-
import {UtFormConstructor} from "../utils/UtFormConstructor";
|
|
114
|
-
|
|
115
|
-
export default {
|
|
116
|
-
name: 'DocTemplateConstructor',
|
|
117
|
-
components: {DocTemplateFacetList, DocTemplateFieldSidebar, DocTemplateSectionModal, draggable},
|
|
118
|
-
props: {
|
|
119
|
-
formConfig: {
|
|
120
|
-
type: Object, default: () => {
|
|
121
|
-
return {sections: []}
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
facets: {type: Array, default: () => []}
|
|
125
|
-
},
|
|
126
|
-
data() {
|
|
127
|
-
return {
|
|
128
|
-
sidebarVisible: false,
|
|
129
|
-
sidebarField: null,
|
|
130
|
-
columnTo: false,
|
|
131
|
-
hash: '',
|
|
132
|
-
sectionModalCfg: {
|
|
133
|
-
id: 'rb-doc-template-section-modal',
|
|
134
|
-
mode: 'ins',
|
|
135
|
-
section: null,
|
|
136
|
-
onAfterOk() {
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
computed: {
|
|
142
|
-
iconAdd() {
|
|
143
|
-
return UtFormConstructor.config.icons.iconAdd;
|
|
144
|
-
},
|
|
145
|
-
iconEdit() {
|
|
146
|
-
return UtFormConstructor.config.icons.iconEdit;
|
|
147
|
-
},
|
|
148
|
-
iconDelete() {
|
|
149
|
-
return UtFormConstructor.config.icons.iconDelete;
|
|
150
|
-
},
|
|
151
|
-
iconDrag() {
|
|
152
|
-
return UtFormConstructor.config.icons.iconDrag;
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
methods: {
|
|
156
|
-
showProperties(field, event) {
|
|
157
|
-
if (event.target.classList
|
|
158
|
-
&& event.target.classList.contains('rb-remove-field')) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
this.sidebarVisible = true;
|
|
163
|
-
this.sidebarField = field;
|
|
164
|
-
},
|
|
165
|
-
addSection(columnCount) {
|
|
166
|
-
let section = {labelRu: null, columnCount: columnCount};
|
|
167
|
-
this.sectionModalCfg.mode = 'ins';
|
|
168
|
-
this.sectionModalCfg.section = section;
|
|
169
|
-
this.sectionModalCfg.onAfterOk = () => {
|
|
170
|
-
section.columns = [];
|
|
171
|
-
for (let i = 0; i < columnCount; i++) {
|
|
172
|
-
section.columns.push({
|
|
173
|
-
index: i,
|
|
174
|
-
fields: []
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
this.formConfig.sections.push(section)
|
|
179
|
-
}
|
|
180
|
-
this.$bvModal.show(this.sectionModalCfg.id);
|
|
181
|
-
},
|
|
182
|
-
editSection(section) {
|
|
183
|
-
this.sectionModalCfg.mode = 'update';
|
|
184
|
-
this.sectionModalCfg.section = section;
|
|
185
|
-
this.sectionModalCfg.onAfterOk = () => {
|
|
186
|
-
}
|
|
187
|
-
this.$bvModal.show(this.sectionModalCfg.id);
|
|
188
|
-
},
|
|
189
|
-
removeSection(section, index) {
|
|
190
|
-
this.formConfig.sections.splice(index, 1);
|
|
191
|
-
/*UtModal.showYesNoDialog('Вы действительно хотите удалить секцию?', {
|
|
192
|
-
onOk: (event, modal) => {
|
|
193
|
-
this.formConfig.sections.splice(index, 1);
|
|
194
|
-
UtModal.closeModal(modal);
|
|
195
|
-
}
|
|
196
|
-
});*/
|
|
197
|
-
},
|
|
198
|
-
multipleFieldAreOnFormConfig(field) {
|
|
199
|
-
let count = 0;
|
|
200
|
-
this.formConfig.sections.forEach(s => {
|
|
201
|
-
s.columns.forEach(c => {
|
|
202
|
-
c.fields.forEach(f => {
|
|
203
|
-
if (f.name === field.name) {
|
|
204
|
-
count++;
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
})
|
|
208
|
-
});
|
|
209
|
-
return count > 1;
|
|
210
|
-
},
|
|
211
|
-
removeFieldFromColumn(field, column, newIndex) {
|
|
212
|
-
let index = newIndex != null ? newIndex : -1;
|
|
213
|
-
|
|
214
|
-
if (index < 0) {
|
|
215
|
-
index = column.fields.findIndex(f => field.name === f.name);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (index >= 0) {
|
|
219
|
-
column.fields.splice(index, 1);
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
onRemoveField(event, field, column) {
|
|
223
|
-
event.preventDefault();
|
|
224
|
-
this.removeFieldFromColumn(field, column)
|
|
225
|
-
},
|
|
226
|
-
onFieldAddedToColumn(event, column, section) {
|
|
227
|
-
this.columnTo = column;
|
|
228
|
-
},
|
|
229
|
-
onFieldMoveEnd(event) {
|
|
230
|
-
const {newIndex} = event;
|
|
231
|
-
let field = event.item._underlying_vm_;
|
|
232
|
-
|
|
233
|
-
if (!field.hasOwnProperty('defaultValue')) {
|
|
234
|
-
this.$set(field, 'defaultValue', undefined);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
let found = this.multipleFieldAreOnFormConfig(field);
|
|
238
|
-
if (found) {
|
|
239
|
-
this.removeFieldFromColumn(field, this.columnTo, newIndex);
|
|
240
|
-
this.resetDragVariables();
|
|
241
|
-
this.$bvModal.msgBoxOk('На форме уже есть это поле', {
|
|
242
|
-
title: 'Ошибка',
|
|
243
|
-
headerClass: 'rb-error-msg-box__header',
|
|
244
|
-
bodyClass: 'rb-error-msg-box__body',
|
|
245
|
-
footerClass: 'rb-error-msg-box__footer',
|
|
246
|
-
centered: true,
|
|
247
|
-
noCloseOnBackdrop: true,
|
|
248
|
-
noCloseOnEsc: true
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
this.resetDragVariables();
|
|
252
|
-
this.hash = (Math.random() + 1).toString(36).substring(7);
|
|
253
|
-
},
|
|
254
|
-
getFieldExtendedPropsData(field) {
|
|
255
|
-
return {...field.input.propsData, placeholder: field.tag, disabled: true};
|
|
256
|
-
},
|
|
257
|
-
resetDragVariables() {
|
|
258
|
-
this.columnTo = null;
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
}
|
|
262
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="rb-doc-template-constructor d-flex">
|
|
3
|
+
<doc-template-facet-list @fieldMoveEnd="onFieldMoveEnd" :facets="facets">
|
|
4
|
+
<template #action>
|
|
5
|
+
<slot name="action"></slot>
|
|
6
|
+
</template>
|
|
7
|
+
<template #actionField="{field}">
|
|
8
|
+
<slot :field="field" name="actionField"></slot>
|
|
9
|
+
</template>
|
|
10
|
+
</doc-template-facet-list>
|
|
11
|
+
|
|
12
|
+
<div class="rb-form-constructor flex-fill">
|
|
13
|
+
<div class="rb-constructor-toolbar d-flex flex-row">
|
|
14
|
+
<h4>Добавить секцию: </h4>
|
|
15
|
+
<div class="rb-layout-buttons">
|
|
16
|
+
<b-button pill variant="outline-gray" @click="addSection(1)">
|
|
17
|
+
<rb-text>Секция с 1 колонкой</rb-text>
|
|
18
|
+
<rb-icon :icon="iconAdd"></rb-icon>
|
|
19
|
+
</b-button>
|
|
20
|
+
<b-button pill variant="outline-gray" @click="addSection(2)">
|
|
21
|
+
<rb-text>Секция с 2 колонками</rb-text>
|
|
22
|
+
<rb-icon :icon="iconAdd"></rb-icon>
|
|
23
|
+
</b-button>
|
|
24
|
+
<b-button pill variant="outline-gray" @click="addSection(3)">
|
|
25
|
+
<rb-text>Секция с 3 колонками</rb-text>
|
|
26
|
+
<rb-icon :icon="iconAdd"></rb-icon>
|
|
27
|
+
</b-button>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div class="rb-constructor-body">
|
|
32
|
+
<draggable v-model="formConfig.sections"
|
|
33
|
+
:animation="200"
|
|
34
|
+
group="section"
|
|
35
|
+
ghost-class="rb-form-card-moving"
|
|
36
|
+
handle=".rb-row-drag-handle">
|
|
37
|
+
<b-card v-for="(section, index) in formConfig.sections" :key="section.labelRu"
|
|
38
|
+
class="rb-form-card" :data-hash="hash">
|
|
39
|
+
<template #header>
|
|
40
|
+
<rb-icon
|
|
41
|
+
:icon="iconDrag"
|
|
42
|
+
class="cursor-pointer rb-row-drag-handle"></rb-icon>
|
|
43
|
+
<rb-text class="flex-fill" @click="editSection(section)">
|
|
44
|
+
{{ section.labelRu }}
|
|
45
|
+
</rb-text>
|
|
46
|
+
<span class="rb-actions">
|
|
47
|
+
<rb-icon :icon="iconEdit" class="cursor-pointer"
|
|
48
|
+
@click="editSection(section)"></rb-icon>
|
|
49
|
+
<rb-icon :icon="iconDelete" class="cursor-pointer"
|
|
50
|
+
@click="removeSection(section, index)"></rb-icon>
|
|
51
|
+
</span>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<div class="d-flex flex-row">
|
|
55
|
+
<draggable tag="b-form"
|
|
56
|
+
class="rb-form-column"
|
|
57
|
+
v-for="column in section.columns"
|
|
58
|
+
:key="column.index"
|
|
59
|
+
:class="{'rb-single-column': section.columnCount === 1}"
|
|
60
|
+
v-model="column.fields"
|
|
61
|
+
@add="onFieldAddedToColumn($event, column, section)"
|
|
62
|
+
:animation="200"
|
|
63
|
+
group="fields"
|
|
64
|
+
ghost-class="rb-moving-item"
|
|
65
|
+
handle=".rb-field-drag-handle">
|
|
66
|
+
<b-form-row v-for="field in column.fields" :key="field.name"
|
|
67
|
+
class="cursor-pointer" @click="showProperties(field, $event)">
|
|
68
|
+
<b-col lg="12">
|
|
69
|
+
<b-form-group :label="field.labelRu">
|
|
70
|
+
<template #label>
|
|
71
|
+
<rb-icon :icon="iconDrag" class="rb-field-drag-handle"></rb-icon>
|
|
72
|
+
<rb-text>{{ field.labelRu }}</rb-text>
|
|
73
|
+
<rb-icon :icon="iconDelete" class="rb-remove-field"
|
|
74
|
+
@click.prevent="onRemoveField($event, field, column)">
|
|
75
|
+
</rb-icon>
|
|
76
|
+
</template>
|
|
77
|
+
<component v-bind:is="field.input.type"
|
|
78
|
+
:id="field.name"
|
|
79
|
+
v-if="field.input"
|
|
80
|
+
v-bind="getFieldExtendedPropsData(field)"
|
|
81
|
+
disabled
|
|
82
|
+
class="cursor-pointer">
|
|
83
|
+
</component>
|
|
84
|
+
</b-form-group>
|
|
85
|
+
</b-col>
|
|
86
|
+
</b-form-row>
|
|
87
|
+
</draggable>
|
|
88
|
+
</div>
|
|
89
|
+
</b-card>
|
|
90
|
+
</draggable>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<doc-template-field-sidebar v-model="sidebarField"
|
|
94
|
+
:visible="sidebarVisible"
|
|
95
|
+
:form-config="formConfig"
|
|
96
|
+
@hide="sidebarVisible=false">
|
|
97
|
+
</doc-template-field-sidebar>
|
|
98
|
+
|
|
99
|
+
<doc-template-section-modal :mode="sectionModalCfg.mode"
|
|
100
|
+
:section="sectionModalCfg.section"
|
|
101
|
+
:on-after-ok="sectionModalCfg.onAfterOk">
|
|
102
|
+
</doc-template-section-modal>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</template>
|
|
106
|
+
|
|
107
|
+
<script>
|
|
108
|
+
import DocTemplateFacetList from "@/components/DocTemplateFacetList";
|
|
109
|
+
import DocTemplateFieldSidebar from "@/components/DocTemplateFieldSidebar";
|
|
110
|
+
import DocTemplateSectionModal from "@/components/DocTemplateSectionModal";
|
|
111
|
+
import draggable from 'vuedraggable';
|
|
112
|
+
import {UtFormConfig} from "../utils/UtFormConfig";
|
|
113
|
+
import {UtFormConstructor} from "../utils/UtFormConstructor";
|
|
114
|
+
|
|
115
|
+
export default {
|
|
116
|
+
name: 'DocTemplateConstructor',
|
|
117
|
+
components: {DocTemplateFacetList, DocTemplateFieldSidebar, DocTemplateSectionModal, draggable},
|
|
118
|
+
props: {
|
|
119
|
+
formConfig: {
|
|
120
|
+
type: Object, default: () => {
|
|
121
|
+
return {sections: []}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
facets: {type: Array, default: () => []}
|
|
125
|
+
},
|
|
126
|
+
data() {
|
|
127
|
+
return {
|
|
128
|
+
sidebarVisible: false,
|
|
129
|
+
sidebarField: null,
|
|
130
|
+
columnTo: false,
|
|
131
|
+
hash: '',
|
|
132
|
+
sectionModalCfg: {
|
|
133
|
+
id: 'rb-doc-template-section-modal',
|
|
134
|
+
mode: 'ins',
|
|
135
|
+
section: null,
|
|
136
|
+
onAfterOk() {
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
computed: {
|
|
142
|
+
iconAdd() {
|
|
143
|
+
return UtFormConstructor.config.icons.iconAdd;
|
|
144
|
+
},
|
|
145
|
+
iconEdit() {
|
|
146
|
+
return UtFormConstructor.config.icons.iconEdit;
|
|
147
|
+
},
|
|
148
|
+
iconDelete() {
|
|
149
|
+
return UtFormConstructor.config.icons.iconDelete;
|
|
150
|
+
},
|
|
151
|
+
iconDrag() {
|
|
152
|
+
return UtFormConstructor.config.icons.iconDrag;
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
methods: {
|
|
156
|
+
showProperties(field, event) {
|
|
157
|
+
if (event.target.classList
|
|
158
|
+
&& event.target.classList.contains('rb-remove-field')) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
this.sidebarVisible = true;
|
|
163
|
+
this.sidebarField = field;
|
|
164
|
+
},
|
|
165
|
+
addSection(columnCount) {
|
|
166
|
+
let section = {labelRu: null, columnCount: columnCount};
|
|
167
|
+
this.sectionModalCfg.mode = 'ins';
|
|
168
|
+
this.sectionModalCfg.section = section;
|
|
169
|
+
this.sectionModalCfg.onAfterOk = () => {
|
|
170
|
+
section.columns = [];
|
|
171
|
+
for (let i = 0; i < columnCount; i++) {
|
|
172
|
+
section.columns.push({
|
|
173
|
+
index: i,
|
|
174
|
+
fields: []
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this.formConfig.sections.push(section)
|
|
179
|
+
}
|
|
180
|
+
this.$bvModal.show(this.sectionModalCfg.id);
|
|
181
|
+
},
|
|
182
|
+
editSection(section) {
|
|
183
|
+
this.sectionModalCfg.mode = 'update';
|
|
184
|
+
this.sectionModalCfg.section = section;
|
|
185
|
+
this.sectionModalCfg.onAfterOk = () => {
|
|
186
|
+
}
|
|
187
|
+
this.$bvModal.show(this.sectionModalCfg.id);
|
|
188
|
+
},
|
|
189
|
+
removeSection(section, index) {
|
|
190
|
+
this.formConfig.sections.splice(index, 1);
|
|
191
|
+
/*UtModal.showYesNoDialog('Вы действительно хотите удалить секцию?', {
|
|
192
|
+
onOk: (event, modal) => {
|
|
193
|
+
this.formConfig.sections.splice(index, 1);
|
|
194
|
+
UtModal.closeModal(modal);
|
|
195
|
+
}
|
|
196
|
+
});*/
|
|
197
|
+
},
|
|
198
|
+
multipleFieldAreOnFormConfig(field) {
|
|
199
|
+
let count = 0;
|
|
200
|
+
this.formConfig.sections.forEach(s => {
|
|
201
|
+
s.columns.forEach(c => {
|
|
202
|
+
c.fields.forEach(f => {
|
|
203
|
+
if (f.name === field.name) {
|
|
204
|
+
count++;
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
return count > 1;
|
|
210
|
+
},
|
|
211
|
+
removeFieldFromColumn(field, column, newIndex) {
|
|
212
|
+
let index = newIndex != null ? newIndex : -1;
|
|
213
|
+
|
|
214
|
+
if (index < 0) {
|
|
215
|
+
index = column.fields.findIndex(f => field.name === f.name);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (index >= 0) {
|
|
219
|
+
column.fields.splice(index, 1);
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
onRemoveField(event, field, column) {
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
this.removeFieldFromColumn(field, column)
|
|
225
|
+
},
|
|
226
|
+
onFieldAddedToColumn(event, column, section) {
|
|
227
|
+
this.columnTo = column;
|
|
228
|
+
},
|
|
229
|
+
onFieldMoveEnd(event) {
|
|
230
|
+
const {newIndex} = event;
|
|
231
|
+
let field = event.item._underlying_vm_;
|
|
232
|
+
|
|
233
|
+
if (!field.hasOwnProperty('defaultValue')) {
|
|
234
|
+
this.$set(field, 'defaultValue', undefined);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
let found = this.multipleFieldAreOnFormConfig(field);
|
|
238
|
+
if (found) {
|
|
239
|
+
this.removeFieldFromColumn(field, this.columnTo, newIndex);
|
|
240
|
+
this.resetDragVariables();
|
|
241
|
+
this.$bvModal.msgBoxOk('На форме уже есть это поле', {
|
|
242
|
+
title: 'Ошибка',
|
|
243
|
+
headerClass: 'rb-error-msg-box__header',
|
|
244
|
+
bodyClass: 'rb-error-msg-box__body',
|
|
245
|
+
footerClass: 'rb-error-msg-box__footer',
|
|
246
|
+
centered: true,
|
|
247
|
+
noCloseOnBackdrop: true,
|
|
248
|
+
noCloseOnEsc: true
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
this.resetDragVariables();
|
|
252
|
+
this.hash = (Math.random() + 1).toString(36).substring(7);
|
|
253
|
+
},
|
|
254
|
+
getFieldExtendedPropsData(field) {
|
|
255
|
+
return {...field.input.propsData, placeholder: field.tag, disabled: true};
|
|
256
|
+
},
|
|
257
|
+
resetDragVariables() {
|
|
258
|
+
this.columnTo = null;
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
}
|
|
262
|
+
</script>
|