starfish-editor-custom 1.0.0
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/auto-imports.d.ts +10 -0
- package/babel.config.js +8 -0
- package/components.d.ts +46 -0
- package/dist/ConditionModule.js +892 -0
- package/dist/ConditionSelect.js +483 -0
- package/dist/CustomDialog.js +105 -0
- package/dist/formStyle.js +245 -0
- package/dist/globalFormList.js +59 -0
- package/dist/jsonCode.js +74 -0
- package/dist/jsonEditor.js +71 -0
- package/dist/main.js +3319 -0
- package/dist/starfish-editor.es.js +30 -0
- package/dist/style.css +1 -0
- package/dist/types/editor/src/common/ConditionSelect/ConditionGroup.vue.d.ts +61 -0
- package/dist/types/editor/src/common/ConditionSelect/ConditionModule.vue.d.ts +43 -0
- package/dist/types/editor/src/common/ConditionSelect/ConditionTanc.vue.d.ts +48 -0
- package/dist/types/editor/src/common/ConditionSelect.vue.d.ts +72 -0
- package/dist/types/editor/src/common/CustomDialog.vue.d.ts +25 -0
- package/dist/types/editor/src/common/Loading.vue.d.ts +3 -0
- package/dist/types/editor/src/common/formJson.d.ts +80 -0
- package/dist/types/editor/src/common/jsonCode.vue.d.ts +110 -0
- package/dist/types/editor/src/components/ComponentList.vue.d.ts +32 -0
- package/dist/types/editor/src/components/FormPreview.vue.d.ts +25 -0
- package/dist/types/editor/src/components/Nav.vue.d.ts +9 -0
- package/dist/types/editor/src/components/PropsPanel.vue.d.ts +53 -0
- package/dist/types/editor/src/components/Shape.vue.d.ts +40 -0
- package/dist/types/editor/src/components/Workspace.vue.d.ts +22 -0
- package/dist/types/editor/src/components/globalFormList.vue.d.ts +6 -0
- package/dist/types/editor/src/components/jsonEditor.vue.d.ts +6 -0
- package/dist/types/editor/src/controller/action.d.ts +18 -0
- package/dist/types/editor/src/controller/form.d.ts +24 -0
- package/dist/types/editor/src/controller/history.d.ts +12 -0
- package/dist/types/editor/src/controller/shortcut.d.ts +20 -0
- package/dist/types/editor/src/controller/ui.d.ts +10 -0
- package/dist/types/editor/src/layouts/ControlEditSize.vue.d.ts +17 -0
- package/dist/types/editor/src/layouts/Framework.vue.d.ts +33 -0
- package/dist/types/editor/src/layouts/Resizer.vue.d.ts +13 -0
- package/dist/types/editor/src/layouts/ShortcutKey.vue.d.ts +8 -0
- package/dist/types/editor/src/main.d.ts +5 -0
- package/dist/types/editor/src/shims-vue.d.ts +23 -0
- package/dist/types/editor/src/starfish-editor.vue.d.ts +109 -0
- package/dist/types/editor/src/type.d.ts +224 -0
- package/dist/types/editor/src/utils/_.d.ts +33 -0
- package/dist/types/editor/src/utils/formKeycon.d.ts +18 -0
- package/dist/types/editor/src/utils/shortcutKey.d.ts +3 -0
- package/dist/types/editor/src/utils/vm.d.ts +3 -0
- package/dist/types/starfish-editor.d.ts +3 -0
- package/package.json +55 -0
- package/src/common/ConditionSelect/ConditionGroup.vue +167 -0
- package/src/common/ConditionSelect/ConditionModule.vue +118 -0
- package/src/common/ConditionSelect/ConditionTanc.vue +319 -0
- package/src/common/ConditionSelect.vue +268 -0
- package/src/common/CustomDialog.vue +77 -0
- package/src/common/Loading.vue +10 -0
- package/src/common/formJson.ts +143 -0
- package/src/common/formStyle.vue +170 -0
- package/src/common/jsonCode.vue +45 -0
- package/src/components/ComponentList.vue +156 -0
- package/src/components/FormPreview.vue +197 -0
- package/src/components/Nav.vue +128 -0
- package/src/components/NavList.vue +560 -0
- package/src/components/PropsPanel.vue +376 -0
- package/src/components/Shape.vue +178 -0
- package/src/components/Workspace.vue +258 -0
- package/src/components/globalFormList.vue +30 -0
- package/src/components/jsonEditor.vue +41 -0
- package/src/controller/action.ts +37 -0
- package/src/controller/form.ts +207 -0
- package/src/controller/history.ts +57 -0
- package/src/controller/shortcut.ts +81 -0
- package/src/controller/ui.ts +91 -0
- package/src/layouts/ControlEditSize.vue +52 -0
- package/src/layouts/Framework.vue +76 -0
- package/src/layouts/Resizer.vue +54 -0
- package/src/layouts/ShortcutKey.vue +61 -0
- package/src/main.ts +56 -0
- package/src/shims-vue.d.ts +23 -0
- package/src/starfish-editor.vue +176 -0
- package/src/styles/common/normalize.css +455 -0
- package/src/styles/component-list.scss +64 -0
- package/src/styles/condition-select.scss +176 -0
- package/src/styles/control_edit_size.scss +36 -0
- package/src/styles/custom-dialog.scss +110 -0
- package/src/styles/form-preview.scss +47 -0
- package/src/styles/framework.scss +150 -0
- package/src/styles/iconfont/iconfont.css +247 -0
- package/src/styles/iconfont/iconfont.js +1 -0
- package/src/styles/iconfont/iconfont.json +415 -0
- package/src/styles/iconfont/iconfont.ttf +0 -0
- package/src/styles/iconfont/iconfont.woff +0 -0
- package/src/styles/iconfont/iconfont.woff2 +0 -0
- package/src/styles/index.scss +18 -0
- package/src/styles/nav-list.scss +59 -0
- package/src/styles/nav.scss +46 -0
- package/src/styles/props-panel.scss +115 -0
- package/src/styles/resizer.scss +15 -0
- package/src/styles/shape.scss +101 -0
- package/src/styles/shortcutkey.scss +44 -0
- package/src/styles/variables.scss +36 -0
- package/src/styles/work-space.scss +126 -0
- package/src/type.ts +240 -0
- package/src/utils/_.ts +349 -0
- package/src/utils/formKeycon.ts +42 -0
- package/src/utils/shortcutKey.ts +46 -0
- package/src/utils/vm.ts +3 -0
- package/stats.html +4949 -0
- package/tsconfig.json +19 -0
- package/vite.config.ts +111 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<teleport to="body">
|
|
3
|
+
<CustomDialog ref="maxJsonDialog" dialogclass="maxJsonDialog">
|
|
4
|
+
<el-main style="padding: 0">
|
|
5
|
+
<el-container style="height: 100%">
|
|
6
|
+
<el-main class="my-pageMain">
|
|
7
|
+
<el-table :data="table" style="width: 100%" border>
|
|
8
|
+
<el-table-column prop="field" label="字段">
|
|
9
|
+
<template #default="scope">
|
|
10
|
+
<el-select v-model="scope.row.field" placeholder="请选择">
|
|
11
|
+
<el-option :label="'未选择'" :value="''"></el-option>
|
|
12
|
+
<el-option
|
|
13
|
+
v-for="(item, index) in fieldList"
|
|
14
|
+
:key="index"
|
|
15
|
+
:label="item.label"
|
|
16
|
+
:value="item.value"
|
|
17
|
+
>
|
|
18
|
+
</el-option>
|
|
19
|
+
</el-select>
|
|
20
|
+
</template>
|
|
21
|
+
</el-table-column>
|
|
22
|
+
<el-table-column prop="logic" label="逻辑">
|
|
23
|
+
<template #default="scope">
|
|
24
|
+
<el-select v-model="scope.row.logic" placeholder="请选择">
|
|
25
|
+
<el-option
|
|
26
|
+
v-for="item in getLogic()"
|
|
27
|
+
:key="item.value"
|
|
28
|
+
:label="item.label"
|
|
29
|
+
:value="item.value"
|
|
30
|
+
>
|
|
31
|
+
</el-option>
|
|
32
|
+
</el-select>
|
|
33
|
+
</template>
|
|
34
|
+
</el-table-column>
|
|
35
|
+
<el-table-column prop="type" label="值类型">
|
|
36
|
+
<template #default="scope">
|
|
37
|
+
<el-select
|
|
38
|
+
v-model="scope.row.type"
|
|
39
|
+
placeholder="请选择"
|
|
40
|
+
@change="handleType"
|
|
41
|
+
>
|
|
42
|
+
<el-option
|
|
43
|
+
v-for="item in newtypeList"
|
|
44
|
+
:key="item.value"
|
|
45
|
+
:label="item.label"
|
|
46
|
+
:value="item.value"
|
|
47
|
+
>
|
|
48
|
+
</el-option>
|
|
49
|
+
</el-select>
|
|
50
|
+
</template>
|
|
51
|
+
</el-table-column>
|
|
52
|
+
<el-table-column prop="value" label="值">
|
|
53
|
+
<template #default="scope">
|
|
54
|
+
<el-form
|
|
55
|
+
:model="scope.row"
|
|
56
|
+
:rules="getRules(scope.row.type)"
|
|
57
|
+
v-if="getTypeIsChange(scope.$index, index)"
|
|
58
|
+
ref="formList"
|
|
59
|
+
>
|
|
60
|
+
<el-form-item prop="value">
|
|
61
|
+
<el-input text v-model="scope.row.value" />
|
|
62
|
+
</el-form-item>
|
|
63
|
+
</el-form>
|
|
64
|
+
<el-select
|
|
65
|
+
v-model="scope.row.value"
|
|
66
|
+
filterable
|
|
67
|
+
placeholder="请选择"
|
|
68
|
+
v-if="scope.row.type == '选项'"
|
|
69
|
+
:multiple="getMultiple()"
|
|
70
|
+
>
|
|
71
|
+
<el-option :label="'未选择'" :value="''"></el-option>
|
|
72
|
+
<el-option
|
|
73
|
+
v-for="(item, index) in getFiled()"
|
|
74
|
+
:key="index"
|
|
75
|
+
:label="item.label"
|
|
76
|
+
:value="item.value"
|
|
77
|
+
>
|
|
78
|
+
</el-option>
|
|
79
|
+
</el-select>
|
|
80
|
+
<el-switch
|
|
81
|
+
v-model="scope.row.value"
|
|
82
|
+
:active-icon="Check"
|
|
83
|
+
:inactive-icon="Close"
|
|
84
|
+
v-if="scope.row.type == '布尔'"
|
|
85
|
+
/>
|
|
86
|
+
</template>
|
|
87
|
+
</el-table-column>
|
|
88
|
+
<el-table-column fixed="right" label="操作" width="200">
|
|
89
|
+
<template #default="scope">
|
|
90
|
+
<el-button
|
|
91
|
+
size="small"
|
|
92
|
+
type="danger"
|
|
93
|
+
@click.prevent="deleteRow(scope.$index, index)"
|
|
94
|
+
>
|
|
95
|
+
删除
|
|
96
|
+
</el-button>
|
|
97
|
+
</template>
|
|
98
|
+
</el-table-column>
|
|
99
|
+
</el-table>
|
|
100
|
+
<el-button
|
|
101
|
+
class="mt-4"
|
|
102
|
+
text
|
|
103
|
+
@click="onAddItem"
|
|
104
|
+
v-if="table.length == 0"
|
|
105
|
+
style="width: 100%"
|
|
106
|
+
>+条件</el-button
|
|
107
|
+
>
|
|
108
|
+
</el-main>
|
|
109
|
+
<el-footer class="my-Footer" style="height: 60px; padding-top: 10px">
|
|
110
|
+
<el-button type="primary" @click="saveJson">保存</el-button>
|
|
111
|
+
<el-button @click="closeDialog">关闭</el-button>
|
|
112
|
+
</el-footer>
|
|
113
|
+
</el-container>
|
|
114
|
+
</el-main>
|
|
115
|
+
</CustomDialog>
|
|
116
|
+
</teleport>
|
|
117
|
+
</template>
|
|
118
|
+
<script >
|
|
119
|
+
export default {
|
|
120
|
+
props: {
|
|
121
|
+
fieldList: {
|
|
122
|
+
type: Object,
|
|
123
|
+
default() {
|
|
124
|
+
return {};
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
data: {
|
|
128
|
+
type: Object,
|
|
129
|
+
default() {
|
|
130
|
+
return {};
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
data() {
|
|
135
|
+
return {
|
|
136
|
+
table: [],
|
|
137
|
+
groupSelect: [
|
|
138
|
+
{
|
|
139
|
+
value: "andgroup",
|
|
140
|
+
label: "+并组",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
value: "orgroup",
|
|
144
|
+
label: "+或组",
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
value: "data",
|
|
148
|
+
label: "条件",
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
logicList: [
|
|
152
|
+
{ value: "=", label: "等于" },
|
|
153
|
+
{ value: "!=", label: "不等于" },
|
|
154
|
+
],
|
|
155
|
+
typeList: [
|
|
156
|
+
{
|
|
157
|
+
rule: [],
|
|
158
|
+
value: "常量",
|
|
159
|
+
label: "常量",
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
computed: {
|
|
165
|
+
newtypeList() {
|
|
166
|
+
const item = this.fieldList.find((item) => {
|
|
167
|
+
if (this.table && this.table.length > 0) {
|
|
168
|
+
if (item.value == this.table[0].field) {
|
|
169
|
+
return item;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
if (item && item.options) {
|
|
174
|
+
return [
|
|
175
|
+
{
|
|
176
|
+
rule: [],
|
|
177
|
+
value: "选项",
|
|
178
|
+
label: "选项",
|
|
179
|
+
},
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
if (item && item.switch) {
|
|
183
|
+
return [
|
|
184
|
+
{
|
|
185
|
+
value: "布尔",
|
|
186
|
+
label: "布尔",
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
return this.typeList;
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
methods: {
|
|
194
|
+
handleType(type) {
|
|
195
|
+
if (type == "布尔") {
|
|
196
|
+
this.table[0].value = true;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
getFiled() {
|
|
200
|
+
if (!this.table[0] || !this.table[0].field) return [];
|
|
201
|
+
const item = this.fieldList.find((item) => {
|
|
202
|
+
if (this.table && this.table.length > 0) {
|
|
203
|
+
if (item.value == this.table[0].field) {
|
|
204
|
+
return item;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return item.options || [];
|
|
209
|
+
},
|
|
210
|
+
getMultiple() {
|
|
211
|
+
const item = this.fieldList.find((item) => {
|
|
212
|
+
if (this.table && this.table.length > 0) {
|
|
213
|
+
if (item.value == this.table[0].field) {
|
|
214
|
+
return item;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
return !!item.multiple;
|
|
219
|
+
},
|
|
220
|
+
getLogic() {
|
|
221
|
+
const item = this.fieldList.find((item) => {
|
|
222
|
+
if (this.table && this.table.length > 0) {
|
|
223
|
+
if (item.value == this.table[0].field) {
|
|
224
|
+
return item;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
if (item && item.options && item.multiple) {
|
|
229
|
+
return [
|
|
230
|
+
{ value: "in", label: "包含" },
|
|
231
|
+
{ value: "not in", label: "不包含" },
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
if (item && item.switch) {
|
|
235
|
+
return [
|
|
236
|
+
{
|
|
237
|
+
value: "=",
|
|
238
|
+
label: "等于",
|
|
239
|
+
},
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
return this.logicList;
|
|
243
|
+
},
|
|
244
|
+
show(data) {
|
|
245
|
+
this.$refs.maxJsonDialog.init("可用条件", "icon-icon-bianji");
|
|
246
|
+
this.$refs.maxJsonDialog.show();
|
|
247
|
+
if (Object.keys(data).length > 0) {
|
|
248
|
+
this.table = [data];
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
onAddItem() {
|
|
252
|
+
this.table.push({
|
|
253
|
+
field: "",
|
|
254
|
+
logic: "",
|
|
255
|
+
type: "",
|
|
256
|
+
value: "",
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
getTypeIsChange(index) {
|
|
260
|
+
const nowRow = this.table[index];
|
|
261
|
+
return !!nowRow.type && nowRow.type == "常量";
|
|
262
|
+
},
|
|
263
|
+
getRules(value) {
|
|
264
|
+
return {
|
|
265
|
+
value: this.typeList.find((item) => {
|
|
266
|
+
return item.value == value;
|
|
267
|
+
})?.rule,
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
closeDialog() {
|
|
271
|
+
this.$refs.maxJsonDialog.close();
|
|
272
|
+
},
|
|
273
|
+
deleteRow() {
|
|
274
|
+
this.table = [];
|
|
275
|
+
},
|
|
276
|
+
async saveJson() {
|
|
277
|
+
if (this.table.length > 0) {
|
|
278
|
+
const data = this.table[0];
|
|
279
|
+
if (!data.field) {
|
|
280
|
+
ElMessage({
|
|
281
|
+
type: "error",
|
|
282
|
+
message: "字段不能为空!",
|
|
283
|
+
});
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (!data.type) {
|
|
287
|
+
ElMessage({
|
|
288
|
+
type: "error",
|
|
289
|
+
message: "请选择值类型!!",
|
|
290
|
+
});
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (data.type && data.type == "选项" && !data.value) {
|
|
294
|
+
ElMessage({
|
|
295
|
+
type: "error",
|
|
296
|
+
message: "值类型为字段时值不能为空!",
|
|
297
|
+
});
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
for (const key in this.table[0]) {
|
|
301
|
+
this.data[key] = this.table[0][key];
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
for (const key in this.data) {
|
|
305
|
+
delete this.data[key];
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
ElMessage({
|
|
309
|
+
message: "保存成功",
|
|
310
|
+
type: "success",
|
|
311
|
+
});
|
|
312
|
+
this.closeDialog();
|
|
313
|
+
this.$emit("end");
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
</script>
|
|
318
|
+
<style scoped lang="scss">
|
|
319
|
+
</style>
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<teleport to="body">
|
|
3
|
+
<CustomDialog ref="maxJsonDialog" dialogclass="conditionSelectNormal">
|
|
4
|
+
<el-main style="padding: 0">
|
|
5
|
+
<el-container style="height: 100%">
|
|
6
|
+
<el-main class="my-pageMain">
|
|
7
|
+
<div class="tipContent">满足以下所有条件时,此组件可用</div>
|
|
8
|
+
<div class="tableContainer" v-for="(table, index) in andData" :key="index">
|
|
9
|
+
<el-table :data="table" style="width: 100%" border>
|
|
10
|
+
<el-table-column prop="field" label="字段">
|
|
11
|
+
<template #default="scope">
|
|
12
|
+
<el-select v-model="scope.row.field" placeholder="请选择">
|
|
13
|
+
<el-option v-for="item in fieldList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
|
14
|
+
</el-select>
|
|
15
|
+
</template>
|
|
16
|
+
</el-table-column>
|
|
17
|
+
<el-table-column prop="logic" label="逻辑">
|
|
18
|
+
<template #default="scope">
|
|
19
|
+
<el-select v-model="scope.row.logic" placeholder="请选择">
|
|
20
|
+
<el-option v-for="item in getLogic(scope.$index, index)" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
|
21
|
+
</el-select>
|
|
22
|
+
</template>
|
|
23
|
+
</el-table-column>
|
|
24
|
+
<el-table-column prop="type" label="值类型">
|
|
25
|
+
<template #default="scope">
|
|
26
|
+
<el-select v-model="scope.row.type" placeholder="请选择" @change="handleType(scope.$index, index, scope.row.type)">
|
|
27
|
+
<el-option v-for="item in getNewTypeList(scope.$index, index)" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
|
28
|
+
</el-select>
|
|
29
|
+
</template>
|
|
30
|
+
</el-table-column>
|
|
31
|
+
<el-table-column prop="value" label="值">
|
|
32
|
+
<template #default="scope">
|
|
33
|
+
<el-form :model="scope.row" :rules="getRules(scope.row.type)" v-if="getTypeIsChange(scope.$index, index) && scope.row.type == '常量'" ref="formList">
|
|
34
|
+
<el-form-item prop="value">
|
|
35
|
+
<el-input text v-model="scope.row.value" />
|
|
36
|
+
</el-form-item>
|
|
37
|
+
</el-form>
|
|
38
|
+
<el-select v-model="scope.row.value" filterable placeholder="请选择" v-if="scope.row.type == '选项'" :multiple="getMultiple(scope.$index, index)">
|
|
39
|
+
<el-option :label="'未选择'" :value="''"></el-option>
|
|
40
|
+
<el-option v-for="(item, rightIndex) in getFiled(scope.$index, index)" :key="rightIndex" :label="item.label" :value="item.value"> </el-option>
|
|
41
|
+
</el-select>
|
|
42
|
+
<el-switch v-model="scope.row.value" v-if="scope.row.type == '布尔'" />
|
|
43
|
+
</template>
|
|
44
|
+
</el-table-column>
|
|
45
|
+
<el-table-column fixed="right" label="操作" width="100">
|
|
46
|
+
<template #default="scope">
|
|
47
|
+
<el-button size="small" type="danger" @click.prevent="deleteRow(scope.$index, index)"> 删除 </el-button>
|
|
48
|
+
</template>
|
|
49
|
+
</el-table-column>
|
|
50
|
+
</el-table>
|
|
51
|
+
<el-button class="mt-4" style="width: 100%" text @click="onAddItem(index)">+并条件</el-button>
|
|
52
|
+
</div>
|
|
53
|
+
<el-button class="mt-4" text @click="onOrItem">+或条件</el-button>
|
|
54
|
+
</el-main>
|
|
55
|
+
|
|
56
|
+
<el-footer class="my-Footer" style="height: 60px; padding-top: 10px; text-align: right">
|
|
57
|
+
<el-button type="primary" @click="saveJson">保存</el-button>
|
|
58
|
+
<el-button @click="closeDialog">关闭</el-button>
|
|
59
|
+
</el-footer>
|
|
60
|
+
</el-container>
|
|
61
|
+
</el-main>
|
|
62
|
+
</CustomDialog>
|
|
63
|
+
</teleport>
|
|
64
|
+
</template>
|
|
65
|
+
<script lang="ts">
|
|
66
|
+
import { defineComponent, reactive, toRefs, ref, toRaw } from "vue";
|
|
67
|
+
import formStore from "@/controller/form";
|
|
68
|
+
export default defineComponent({
|
|
69
|
+
props: {
|
|
70
|
+
data: {
|
|
71
|
+
type: Object,
|
|
72
|
+
default() {
|
|
73
|
+
return {};
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
item: {
|
|
77
|
+
type: Object,
|
|
78
|
+
default() {
|
|
79
|
+
return {};
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
emits: ["change"],
|
|
84
|
+
setup(props, { emit }) {
|
|
85
|
+
const maxJsonDialog = ref();
|
|
86
|
+
const formList = ref();
|
|
87
|
+
const fieldList: any = ref();
|
|
88
|
+
function initFieldList() {
|
|
89
|
+
const allFormList = formStore?.get("allFormList");
|
|
90
|
+
const fieldResult: any[] = [];
|
|
91
|
+
toRaw(allFormList)?.forEach((item: any) => {
|
|
92
|
+
window.VueContext.$Flex.getFormDataList(item, fieldResult, props.data.fieldName);
|
|
93
|
+
});
|
|
94
|
+
fieldList.value = fieldResult;
|
|
95
|
+
}
|
|
96
|
+
interface logicItem {
|
|
97
|
+
value: string;
|
|
98
|
+
label: string;
|
|
99
|
+
rule?: any[];
|
|
100
|
+
}
|
|
101
|
+
interface ConditionSelect {
|
|
102
|
+
andData: Array<Array<any>>;
|
|
103
|
+
logicList: Array<logicItem>;
|
|
104
|
+
typeList: Array<logicItem>;
|
|
105
|
+
}
|
|
106
|
+
const data = reactive<ConditionSelect>({
|
|
107
|
+
andData: [[]],
|
|
108
|
+
logicList: [
|
|
109
|
+
{ value: "=", label: "等于" },
|
|
110
|
+
{ value: "!=", label: "不等于" },
|
|
111
|
+
],
|
|
112
|
+
typeList: [
|
|
113
|
+
{
|
|
114
|
+
value: "常量",
|
|
115
|
+
label: "常量",
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
...toRefs(data),
|
|
121
|
+
fieldList,
|
|
122
|
+
maxJsonDialog,
|
|
123
|
+
formList,
|
|
124
|
+
handleType(index: number, tableIndex: number, type: string) {
|
|
125
|
+
if (type == "布尔") {
|
|
126
|
+
data.andData[tableIndex][index].value = true;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
getLogic(index: number, tableIndex: number) {
|
|
130
|
+
const item = fieldList.value.find((item: any) => {
|
|
131
|
+
if (data.andData[tableIndex][index]) {
|
|
132
|
+
if (item.value == data.andData[tableIndex][index].field) {
|
|
133
|
+
return item;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
if (item && item.options && item.multiple) {
|
|
138
|
+
return [
|
|
139
|
+
{ value: "in", label: "包含" },
|
|
140
|
+
{ value: "not in", label: "不包含" },
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
if (item && item.switch) {
|
|
144
|
+
return [
|
|
145
|
+
{
|
|
146
|
+
value: "=",
|
|
147
|
+
label: "等于",
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
return data.logicList;
|
|
152
|
+
},
|
|
153
|
+
getFiled(index: number, tableIndex: number) {
|
|
154
|
+
if (!data.andData[tableIndex][index] || !(data.andData[tableIndex][index] as any).field) return [];
|
|
155
|
+
const item = fieldList.value.find((item: any) => {
|
|
156
|
+
if (data.andData[tableIndex][index]) {
|
|
157
|
+
if (item.value == data.andData[tableIndex][index].field) {
|
|
158
|
+
return item;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return item.options || [];
|
|
163
|
+
},
|
|
164
|
+
show() {
|
|
165
|
+
maxJsonDialog.value.init("可用条件", "icon-icon-bianji");
|
|
166
|
+
maxJsonDialog.value.show();
|
|
167
|
+
console.log(props.data);
|
|
168
|
+
if (typeof props.data.showRule != "string" && Array.isArray(props.data.showRule)) {
|
|
169
|
+
data.andData = props.data.showRule;
|
|
170
|
+
} else {
|
|
171
|
+
data.andData = [[]];
|
|
172
|
+
}
|
|
173
|
+
initFieldList();
|
|
174
|
+
},
|
|
175
|
+
getMultiple(index: number, tableIndex: number) {
|
|
176
|
+
const item = fieldList.value.find((item: any) => {
|
|
177
|
+
if (data.andData[tableIndex][index]) {
|
|
178
|
+
if (item.value == data.andData[tableIndex][index].field) {
|
|
179
|
+
return item;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return !!item.multiple;
|
|
184
|
+
},
|
|
185
|
+
getNewTypeList(index: number, tableIndex: number) {
|
|
186
|
+
const item = fieldList.value.find((item: any) => {
|
|
187
|
+
if (data.andData[tableIndex][index]) {
|
|
188
|
+
if (item.value == data.andData[tableIndex][index].field) {
|
|
189
|
+
return item;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
if (item && item.options) {
|
|
194
|
+
return [
|
|
195
|
+
{
|
|
196
|
+
rule: [],
|
|
197
|
+
value: "选项",
|
|
198
|
+
label: "选项",
|
|
199
|
+
},
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
if (item && item.switch) {
|
|
203
|
+
return [
|
|
204
|
+
{
|
|
205
|
+
value: "布尔",
|
|
206
|
+
label: "布尔",
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
return data.typeList;
|
|
211
|
+
},
|
|
212
|
+
deleteRow(index: number, tableIndex: number) {
|
|
213
|
+
data.andData[tableIndex].splice(index, 1);
|
|
214
|
+
},
|
|
215
|
+
getTypeIsChange(index: number, tableIndex: number) {
|
|
216
|
+
const nowRow = data.andData[tableIndex][index];
|
|
217
|
+
return !!nowRow.type;
|
|
218
|
+
},
|
|
219
|
+
getRules(value: any) {
|
|
220
|
+
return {
|
|
221
|
+
value: data.typeList.find((item) => {
|
|
222
|
+
return item.value == value;
|
|
223
|
+
})?.rule,
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
async onAddItem(index: number) {
|
|
227
|
+
data.andData[index].push({
|
|
228
|
+
field: "",
|
|
229
|
+
logic: "",
|
|
230
|
+
type: "",
|
|
231
|
+
value: "",
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
onOrItem() {
|
|
235
|
+
data.andData.push([]);
|
|
236
|
+
},
|
|
237
|
+
closeDialog() {
|
|
238
|
+
maxJsonDialog.value.close();
|
|
239
|
+
},
|
|
240
|
+
saveJson() {
|
|
241
|
+
const andData = toRaw(data.andData)
|
|
242
|
+
.filter((item) => {
|
|
243
|
+
if (item.length > 0) {
|
|
244
|
+
return item;
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
.map((tabData) => {
|
|
248
|
+
const newTabData = tabData.filter((item) => {
|
|
249
|
+
if (item.field) {
|
|
250
|
+
return item;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
if (newTabData.length > 0) {
|
|
254
|
+
return newTabData;
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
.filter((item) => {
|
|
258
|
+
return !!item;
|
|
259
|
+
});
|
|
260
|
+
// props.data[props.item.data.fieldName] = andData;
|
|
261
|
+
emit("change", andData);
|
|
262
|
+
maxJsonDialog.value.close();
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
</script>
|
|
268
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-dialog
|
|
3
|
+
v-model="isshow"
|
|
4
|
+
:custom-class="['MyDialogBody', dialogclass, { fullscreen: isFullScreen }]"
|
|
5
|
+
:width="newWidth"
|
|
6
|
+
:append-to-body="true"
|
|
7
|
+
:close-on-click-modal="false"
|
|
8
|
+
:destroy-on-close="true"
|
|
9
|
+
@close="close"
|
|
10
|
+
>
|
|
11
|
+
<template #title>
|
|
12
|
+
<div class="my-pageHeader">
|
|
13
|
+
<div class="my-icon">
|
|
14
|
+
<em class="iconfontui" :class="icon"></em>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="my-title">{{ title }}</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
<slot></slot>
|
|
20
|
+
</el-dialog>
|
|
21
|
+
</template>
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { defineComponent, ref, computed } from "vue";
|
|
24
|
+
|
|
25
|
+
export default defineComponent({
|
|
26
|
+
props: {
|
|
27
|
+
dialogclass: String,
|
|
28
|
+
showDialog: Boolean,
|
|
29
|
+
width: Number,
|
|
30
|
+
},
|
|
31
|
+
emits: ["open", "close"],
|
|
32
|
+
setup(props, { emit }) {
|
|
33
|
+
const isshow = ref<boolean>(false);
|
|
34
|
+
const title = ref<string>("");
|
|
35
|
+
const icon = ref<string>("");
|
|
36
|
+
const isFullScreen = ref<boolean>(false);
|
|
37
|
+
const newWidth = computed(() => {
|
|
38
|
+
if (typeof props.width == "number") {
|
|
39
|
+
return props.width + "px";
|
|
40
|
+
} else {
|
|
41
|
+
return props.width || "50%";
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
isshow,
|
|
46
|
+
title,
|
|
47
|
+
icon,
|
|
48
|
+
isFullScreen,
|
|
49
|
+
newWidth,
|
|
50
|
+
init(titles: string, icons: string) {
|
|
51
|
+
title.value = titles;
|
|
52
|
+
icon.value = icons;
|
|
53
|
+
},
|
|
54
|
+
show() {
|
|
55
|
+
isshow.value = true;
|
|
56
|
+
emit("open");
|
|
57
|
+
},
|
|
58
|
+
close() {
|
|
59
|
+
isshow.value = false;
|
|
60
|
+
emit("close");
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<style scoped>
|
|
68
|
+
.MyDialogBody {
|
|
69
|
+
position: relative;
|
|
70
|
+
}
|
|
71
|
+
.fullscreen {
|
|
72
|
+
width: 100% !important;
|
|
73
|
+
height: 100% !important;
|
|
74
|
+
margin: 0;
|
|
75
|
+
padding: 0;
|
|
76
|
+
}
|
|
77
|
+
</style>
|