starfish-form-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/README.md +2 -0
- package/auto-imports.d.ts +9 -0
- package/components.d.ts +68 -0
- package/dist/formAction-28d86b6a.mjs +446 -0
- package/dist/index-04830c0b.mjs +126 -0
- package/dist/index-eab8ef70.mjs +519 -0
- package/dist/index-f7ea052c.mjs +241 -0
- package/dist/main-96327b2e.mjs +5051 -0
- package/dist/starfish-form-a18a5409.mjs +328 -0
- package/dist/starfish-form.mjs +36 -0
- package/dist/style.css +377 -0
- package/dist/types/form/src/common/Loading.vue.d.ts +3 -0
- package/dist/types/form/src/env.d.ts +15 -0
- package/dist/types/form/src/main.d.ts +43 -0
- package/dist/types/form/src/starfish-form.vue.d.ts +40 -0
- package/dist/types/form/src/utils/customHooks.d.ts +2 -0
- package/dist/types/form/src/utils/fieldConfig.d.ts +78 -0
- package/dist/types/form/src/utils/fieldProps.d.ts +43 -0
- package/dist/types/starfish-form.d.ts +3 -0
- package/package.json +42 -0
- package/src/common/KeyValueConfig.vue +145 -0
- package/src/common/KeyValueConfigMult.vue +139 -0
- package/src/common/Loading.vue +14 -0
- package/src/common/action.vue +76 -0
- package/src/common/formAction.vue +298 -0
- package/src/common/listConfig.vue +45 -0
- package/src/common/panel.vue +61 -0
- package/src/common/radiogroup.vue +31 -0
- package/src/components/CheckBox/index.vue +42 -0
- package/src/components/ColorSelect/index.vue +49 -0
- package/src/components/Date/index.vue +39 -0
- package/src/components/DateTime/index.vue +39 -0
- package/src/components/InputNumber/index.vue +48 -0
- package/src/components/JsonEditor/index.vue +167 -0
- package/src/components/Radio/index.vue +42 -0
- package/src/components/RichText/index.vue +60 -0
- package/src/components/Rule/index.vue +365 -0
- package/src/components/Rule/ruleform.json +315 -0
- package/src/components/Rule/rules.js +91 -0
- package/src/components/Selected/index.vue +50 -0
- package/src/components/Selecteds/index.vue +50 -0
- package/src/components/ShowRule/index.vue +50 -0
- package/src/components/Slider/index.vue +38 -0
- package/src/components/Switch/index.vue +61 -0
- package/src/components/Text/index.vue +48 -0
- package/src/components/TextArea/index.vue +49 -0
- package/src/components/Time/index.vue +36 -0
- package/src/env.d.ts +15 -0
- package/src/layout/Divider.vue +30 -0
- package/src/layout/Info.vue +69 -0
- package/src/layout/Tabs.vue +75 -0
- package/src/layout/collapse.vue +78 -0
- package/src/layout/grid.vue +88 -0
- package/src/layout/table.vue +80 -0
- package/src/main.ts +62 -0
- package/src/starfish-form.vue +265 -0
- package/src/styles/action.scss +25 -0
- package/src/styles/collapse.scss +15 -0
- package/src/styles/custom-cpm.scss +5 -0
- package/src/styles/divider.scss +16 -0
- package/src/styles/form-action.scss +92 -0
- package/src/styles/formedit.scss +69 -0
- package/src/styles/grid.scss +12 -0
- package/src/styles/index.scss +12 -0
- package/src/styles/keyvalueConfig.scss +56 -0
- package/src/styles/rule.scss +17 -0
- package/src/styles/showrule.scss +5 -0
- package/src/styles/table.scss +19 -0
- package/src/styles/tabs.scss +5 -0
- package/src/utils/customHooks.ts +22 -0
- package/src/utils/fieldConfig.ts +961 -0
- package/src/utils/fieldProps.ts +50 -0
- package/stats.html +4949 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="starfish-formitem starfish-formitem-action" :class="{ formCover: drag, 'starfish-vertical': labelalign != 'top', [item.data.csslist?.join(' ')]: !!item.data.csslist }" >
|
|
3
|
+
<div class="label" :class="'label_' + labelalign" :style="{ width: labelWidth + 'px' }">
|
|
4
|
+
<label>{{ item.data.label }}{{ suffix }}</label>
|
|
5
|
+
<span v-if="item.data.required" class="item_require">*</span>
|
|
6
|
+
<el-tooltip v-if="item.data.tip" class="item" effect="dark" :content="item.data.tip" placement="top">
|
|
7
|
+
<span class="tip iconfontui icon-tishi"></span>
|
|
8
|
+
</el-tooltip>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="control" :style="{ marginLeft: labelalign != 'top' ? labelWidth + 'px' : '' }">
|
|
11
|
+
<div class="starfish-keyValueItem" v-for="(items, index) in data[item.data.fieldName].items" :key="index">
|
|
12
|
+
<div class="keyValueSelect">
|
|
13
|
+
<el-checkbox v-model="items.select" @change="getChangeSelect(items)"></el-checkbox>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="keyValueInput">
|
|
16
|
+
<div class="inputItem">
|
|
17
|
+
<span>文本:</span>
|
|
18
|
+
<div>
|
|
19
|
+
<el-input v-model="items.label" size="small" @input="getChangeValue(items)" />
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="inputItem">
|
|
23
|
+
<span>值:</span>
|
|
24
|
+
<div>
|
|
25
|
+
<el-input v-model="items.value" size="small" @input="getChangeValue(items)" />
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="keyValueControl">
|
|
30
|
+
<div class="add" @click="addItem(index)">
|
|
31
|
+
<i class="iconfontui icon-zengjia"></i>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="remove" @click="removeItem(index)">
|
|
34
|
+
<i class="iconfontui icon-shanchu"></i>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="top" @click="handleTop(index)">
|
|
37
|
+
<i class="iconfontui icon-shangyi"></i>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="bottom" @click="handleBottom(index)">
|
|
40
|
+
<i class="iconfontui icon-xiayi"></i>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
<script lang="ts">
|
|
48
|
+
import { defineComponent } from "vue";
|
|
49
|
+
import { getFormConfig } from "../utils/fieldConfig";
|
|
50
|
+
import fieldProps from "../utils/fieldProps";
|
|
51
|
+
export default defineComponent({
|
|
52
|
+
ControlType: "KeyValueConfig", // 必须与文件名匹配
|
|
53
|
+
nameCn: "键值对匹配",
|
|
54
|
+
icon: "icon-danxuankuang",
|
|
55
|
+
isHide: true,
|
|
56
|
+
formConfig: getFormConfig("KeyValueConfig"),
|
|
57
|
+
props: {
|
|
58
|
+
...fieldProps,
|
|
59
|
+
},
|
|
60
|
+
setup(props) {
|
|
61
|
+
function getMaxId() {
|
|
62
|
+
let maxId = 0;
|
|
63
|
+
const data: any = props.data;
|
|
64
|
+
const item: any = props.item;
|
|
65
|
+
const allItems = data[item.data.fieldName];
|
|
66
|
+
allItems.items.forEach((item: any) => {
|
|
67
|
+
maxId = Math.max(item.id, maxId);
|
|
68
|
+
});
|
|
69
|
+
return maxId + 1;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
getChangeValue(sitem: any) {
|
|
73
|
+
const data: any = props.data;
|
|
74
|
+
const item: any = props.item;
|
|
75
|
+
const allItems = data[item.data.fieldName];
|
|
76
|
+
allItems.value = sitem.value;
|
|
77
|
+
allItems.id = sitem.id;
|
|
78
|
+
},
|
|
79
|
+
getChangeSelect(sitem: any) {
|
|
80
|
+
const data: any = props.data;
|
|
81
|
+
const item: any = props.item;
|
|
82
|
+
const allItems = data[item.data.fieldName];
|
|
83
|
+
if (sitem.select) {
|
|
84
|
+
allItems.value = sitem.value;
|
|
85
|
+
allItems.id = sitem.id;
|
|
86
|
+
allItems.items.forEach((item: any) => {
|
|
87
|
+
if (item.id !== sitem.id) {
|
|
88
|
+
item.select = false;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
let isHave = false;
|
|
93
|
+
allItems.items.forEach((item: any) => {
|
|
94
|
+
if (item.select) {
|
|
95
|
+
isHave = true;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (!isHave) {
|
|
99
|
+
allItems.value = "";
|
|
100
|
+
allItems.id = "";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
removeItem(index: number) {
|
|
105
|
+
const data: any = props.data;
|
|
106
|
+
const item: any = props.item;
|
|
107
|
+
const allItems = data[item.data.fieldName];
|
|
108
|
+
if (allItems.items.length <= 1) return;
|
|
109
|
+
allItems.items.splice(index, 1);
|
|
110
|
+
},
|
|
111
|
+
handleTop(index: number) {
|
|
112
|
+
if (index > 0) {
|
|
113
|
+
const data: any = props.data;
|
|
114
|
+
const item: any = props.item;
|
|
115
|
+
const allItem = data[item.data.fieldName].items;
|
|
116
|
+
const newItem = allItem.splice(index, 1)[0];
|
|
117
|
+
allItem.splice(index - 1, 0, newItem);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
handleBottom(index: number) {
|
|
121
|
+
const data: any = props.data;
|
|
122
|
+
const item: any = props.item;
|
|
123
|
+
const allItem = data[item.data.fieldName].items;
|
|
124
|
+
if (index < allItem.length - 1) {
|
|
125
|
+
const newItem = allItem.splice(index, 1)[0];
|
|
126
|
+
allItem.splice(index + 1, 0, newItem);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
addItem(index: number) {
|
|
130
|
+
const maxId = getMaxId();
|
|
131
|
+
const data: any = props.data;
|
|
132
|
+
const item: any = props.item;
|
|
133
|
+
const allItems = data[item.data.fieldName];
|
|
134
|
+
allItems.items.splice(index + 1, 0, {
|
|
135
|
+
label: "选项" + maxId,
|
|
136
|
+
value: "选项" + maxId,
|
|
137
|
+
select: false,
|
|
138
|
+
id: maxId,
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
</script>
|
|
145
|
+
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="starfish-formitem" :class="{ formCover: drag, 'starfish-vertical': labelalign != 'top', [item.data.csslist?.join(' ')]: !!item.data.csslist }">
|
|
3
|
+
<div class="label" :class="'label_' + labelalign" :style="{ width: labelWidth + 'px' }">
|
|
4
|
+
<label>{{ item.data.label }}{{ suffix }}</label>
|
|
5
|
+
<span v-if="item.data.required" class="item_require">*</span>
|
|
6
|
+
<el-tooltip v-if="item.data.tip" class="item" effect="dark" :content="item.data.tip" placement="top">
|
|
7
|
+
<span class="tip iconfontui icon-tishi"></span>
|
|
8
|
+
</el-tooltip>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="control" :style="{ marginLeft: labelalign != 'top' ? labelWidth + 'px' : '' }">
|
|
11
|
+
<div class="starfish-keyValueItem" v-for="(items, index) in data[item.data.fieldName].items" :key="index">
|
|
12
|
+
<div class="keyValueSelect">
|
|
13
|
+
<el-checkbox v-model="items.select" @change="getChangeSelect(items)"></el-checkbox>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="keyValueInput">
|
|
16
|
+
<div class="inputItem">
|
|
17
|
+
<span>文本:</span>
|
|
18
|
+
<div>
|
|
19
|
+
<el-input v-model="items.label" size="small" @input="getChangeValue()" />
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="inputItem">
|
|
23
|
+
<span>值:</span>
|
|
24
|
+
<div>
|
|
25
|
+
<el-input v-model="items.value" size="small" @input="getChangeValue()" />
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="keyValueControl">
|
|
30
|
+
<div class="add" @click="addItem(index)">
|
|
31
|
+
<i class="iconfontui icon-zengjia"></i>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="remove" @click="removeItem(index)">
|
|
34
|
+
<i class="iconfontui icon-shanchu"></i>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="top" @click="handleTop(index)">
|
|
37
|
+
<i class="iconfontui icon-shangyi"></i>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="bottom" @click="handleBottom(index)">
|
|
40
|
+
<i class="iconfontui icon-xiayi"></i>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
<script lang="ts">
|
|
48
|
+
import { defineComponent } from "vue";
|
|
49
|
+
import { getFormConfig } from "../utils/fieldConfig";
|
|
50
|
+
import fieldProps from "../utils/fieldProps";
|
|
51
|
+
export default defineComponent({
|
|
52
|
+
ControlType: "KeyValueConfigMult", // 必须与文件名匹配
|
|
53
|
+
nameCn: "多选键值对匹配",
|
|
54
|
+
icon: "icon-danxuankuang",
|
|
55
|
+
isHide: true,
|
|
56
|
+
props: {
|
|
57
|
+
...fieldProps,
|
|
58
|
+
},
|
|
59
|
+
getFormConfig: getFormConfig("KeyValueConfigMult"),
|
|
60
|
+
setup(props) {
|
|
61
|
+
function getMaxId() {
|
|
62
|
+
let maxId = 0;
|
|
63
|
+
const data: any = props.data;
|
|
64
|
+
const item: any = props.item;
|
|
65
|
+
const allItems = data[item.data.fieldName];
|
|
66
|
+
allItems.items.forEach((item: any) => {
|
|
67
|
+
maxId = Math.max(item.id, maxId);
|
|
68
|
+
});
|
|
69
|
+
return maxId + 1;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
getChangeValue() {
|
|
73
|
+
const data: any = props.data;
|
|
74
|
+
const item: any = props.item;
|
|
75
|
+
const allItems = data[item.data.fieldName];
|
|
76
|
+
allItems.value = [];
|
|
77
|
+
allItems.items.forEach((item: any) => {
|
|
78
|
+
if (item.select) {
|
|
79
|
+
allItems.value.push(item.value);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
getChangeSelect(sitem: any) {
|
|
84
|
+
const data: any = props.data;
|
|
85
|
+
const item: any = props.item;
|
|
86
|
+
const allItems = data[item.data.fieldName];
|
|
87
|
+
if (sitem.select) {
|
|
88
|
+
allItems.value.push(sitem.value);
|
|
89
|
+
} else {
|
|
90
|
+
allItems.value = [];
|
|
91
|
+
allItems.items.forEach((item: any) => {
|
|
92
|
+
if (item.select) {
|
|
93
|
+
allItems.value.push(item.value);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
removeItem(index: number) {
|
|
100
|
+
const data: any = props.data;
|
|
101
|
+
const item: any = props.item;
|
|
102
|
+
const allItems = data[item.data.fieldName];
|
|
103
|
+
if (allItems.items.length <= 1) return;
|
|
104
|
+
allItems.items.splice(index, 1);
|
|
105
|
+
},
|
|
106
|
+
handleTop(index: number) {
|
|
107
|
+
if (index > 0) {
|
|
108
|
+
const data: any = props.data;
|
|
109
|
+
const item: any = props.item;
|
|
110
|
+
const allItem = data[item.data.fieldName].items;
|
|
111
|
+
const newItem = allItem.splice(index, 1)[0];
|
|
112
|
+
allItem.splice(index - 1, 0, newItem);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
handleBottom(index: number) {
|
|
116
|
+
const data: any = props.data;
|
|
117
|
+
const item: any = props.item;
|
|
118
|
+
const allItem = data[item.data.fieldName].items;
|
|
119
|
+
if (index < allItem.length - 1) {
|
|
120
|
+
const newItem = allItem.splice(index, 1)[0];
|
|
121
|
+
allItem.splice(index + 1, 0, newItem);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
addItem(index: number) {
|
|
125
|
+
const maxId = getMaxId();
|
|
126
|
+
const data: any = props.data;
|
|
127
|
+
const item: any = props.item;
|
|
128
|
+
const allItems = data[item.data.fieldName];
|
|
129
|
+
allItems.items.splice(index + 1, 0, {
|
|
130
|
+
label: "选项" + maxId,
|
|
131
|
+
value: "选项" + maxId,
|
|
132
|
+
select: false,
|
|
133
|
+
id: maxId,
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="loading" v-loading="true"></div>
|
|
3
|
+
</template>
|
|
4
|
+
<style lang="scss" scoped>
|
|
5
|
+
.loading {
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 100%;
|
|
8
|
+
min-height: 40px;
|
|
9
|
+
::v-deep .el-loading-spinner .circular {
|
|
10
|
+
width: 30px;
|
|
11
|
+
height: 30px;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="starfish-formitem starfish-formitem-action" :class="{ formCover: drag, 'starfish-vertical': labelalign != 'top', [item.data.csslist?.join(' ')]: !!item.data.csslist }">
|
|
3
|
+
<div class="label" :class="'label_' + labelalign" :style="{ width: labelWidth + 'px' }">
|
|
4
|
+
<label>{{ item.data.label }}{{ suffix }}</label>
|
|
5
|
+
<span v-if="item.data.required" class="item_require">*</span>
|
|
6
|
+
<el-tooltip v-if="item.data.tip" class="item" effect="dark" :content="item.data.tip" placement="top">
|
|
7
|
+
<span class="tip iconfontui icon-tishi"></span>
|
|
8
|
+
</el-tooltip>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="control" :style="{ marginLeft: labelalign != 'top' ? labelWidth + 'px' : '' }">
|
|
11
|
+
<el-collapse v-if="data[item.data.fieldName]">
|
|
12
|
+
<el-collapse-item :title="key" name="1" v-for="(configItem, key) in data[item.data.fieldName]" :key="key">
|
|
13
|
+
<el-row :gutter="10">
|
|
14
|
+
<el-col class="list-group-item" :span="16">
|
|
15
|
+
<el-select v-model="data[item.data.fieldName][key]" class="m-2" placeholder="Select" :size="size" style="width: 100%">
|
|
16
|
+
<el-option v-for="item in action" :key="item.type" :label="item.funcName" :value="JSON.stringify(item)" />
|
|
17
|
+
</el-select>
|
|
18
|
+
</el-col>
|
|
19
|
+
<el-col :span="6" style="white-space: nowrap">
|
|
20
|
+
<el-button type="primary" circle :size="size" @click="onEditAction(configItem, key)">
|
|
21
|
+
<el-icon><Edit /></el-icon>
|
|
22
|
+
</el-button>
|
|
23
|
+
<el-button type="danger" circle :size="size" @click="onRemoveAction(key)">
|
|
24
|
+
<el-icon><Delete /></el-icon>
|
|
25
|
+
</el-button>
|
|
26
|
+
</el-col>
|
|
27
|
+
</el-row>
|
|
28
|
+
</el-collapse-item>
|
|
29
|
+
</el-collapse>
|
|
30
|
+
<el-dropdown style="width: 100%">
|
|
31
|
+
<el-button style="width: 100%" :size="size"> 新建动作+ </el-button>
|
|
32
|
+
<template #dropdown>
|
|
33
|
+
<el-dropdown-menu>
|
|
34
|
+
<el-dropdown-item v-for="(actionItem, index) in item.data.formConfig.items" :key="index" @click="addAction(actionItem.value)" :disabled="data[item.data.fieldName] && data[item.data.fieldName][actionItem.value]">{{ actionItem.label }}</el-dropdown-item>
|
|
35
|
+
</el-dropdown-menu>
|
|
36
|
+
</template>
|
|
37
|
+
</el-dropdown>
|
|
38
|
+
</div>
|
|
39
|
+
<formAction :isForm="true" :item="item" :data="data" ref="formAction"> </formAction>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
<script lang="ts">
|
|
43
|
+
import { defineComponent, ref, inject, computed } from "vue";
|
|
44
|
+
import { Delete, Edit } from "@element-plus/icons-vue";
|
|
45
|
+
import fieldProps from "../utils/fieldProps";
|
|
46
|
+
export default defineComponent({
|
|
47
|
+
ControlType: "Action", // 必须与文件名匹配
|
|
48
|
+
isHide: true,
|
|
49
|
+
props: {
|
|
50
|
+
...fieldProps,
|
|
51
|
+
},
|
|
52
|
+
components: {
|
|
53
|
+
Delete,
|
|
54
|
+
Edit,
|
|
55
|
+
},
|
|
56
|
+
setup(props) {
|
|
57
|
+
const { actionContrl } = inject<any>("control") || {};
|
|
58
|
+
const action = computed(() => actionContrl?.get("action"));
|
|
59
|
+
const formAction = ref();
|
|
60
|
+
return {
|
|
61
|
+
action,
|
|
62
|
+
formAction,
|
|
63
|
+
addAction(type: string) {
|
|
64
|
+
formAction.value.onAction(type);
|
|
65
|
+
},
|
|
66
|
+
onEditAction(actionItem: string, key: any) {
|
|
67
|
+
const type = (JSON.parse(actionItem || "{}") || {}).type;
|
|
68
|
+
formAction.value.onEditAction(key, type);
|
|
69
|
+
},
|
|
70
|
+
onRemoveAction(key: any) {
|
|
71
|
+
delete props.data[props.item.data.fieldName][key];
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
</script>
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="starfish-formitem"
|
|
4
|
+
:class="{
|
|
5
|
+
formCover: drag,
|
|
6
|
+
'starfish-vertical': labelalign != 'top',
|
|
7
|
+
[item.data.csslist?.join(' ')]: !!item.data.csslist,
|
|
8
|
+
}"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
class="label"
|
|
12
|
+
:class="'label_' + labelalign"
|
|
13
|
+
:style="{ width: labelWidth + 'px' }"
|
|
14
|
+
v-if="!isForm"
|
|
15
|
+
>
|
|
16
|
+
<label>{{ item.data.label }}</label>
|
|
17
|
+
<span v-if="item.data.required" class="item_require">*</span>
|
|
18
|
+
<el-tooltip
|
|
19
|
+
v-if="item.data.tip"
|
|
20
|
+
class="item"
|
|
21
|
+
effect="dark"
|
|
22
|
+
:content="item.data.tip"
|
|
23
|
+
placement="top"
|
|
24
|
+
>
|
|
25
|
+
<span class="tip iconfontui icon-tishi"></span>
|
|
26
|
+
</el-tooltip>
|
|
27
|
+
</div>
|
|
28
|
+
<div
|
|
29
|
+
class="control"
|
|
30
|
+
:style="{ marginLeft: labelalign != 'top' ? labelWidth + 'px' : '' }"
|
|
31
|
+
>
|
|
32
|
+
<el-button style="width: 100%" @click="onAction" v-if="!isForm">
|
|
33
|
+
设置
|
|
34
|
+
</el-button>
|
|
35
|
+
<CustomDialog ref="actionRef">
|
|
36
|
+
<div class="common-layout">
|
|
37
|
+
<el-container
|
|
38
|
+
style="height: 100%; border: 1px solid rgb(238, 238, 238)"
|
|
39
|
+
>
|
|
40
|
+
<el-container>
|
|
41
|
+
<el-aside width="300px" class="event-script-aside">
|
|
42
|
+
<el-container class="is-vertical">
|
|
43
|
+
<header class="action-header">
|
|
44
|
+
<el-button type="text" :size="size" @click="addAction">
|
|
45
|
+
+添加动作</el-button
|
|
46
|
+
>
|
|
47
|
+
</header>
|
|
48
|
+
<el-main>
|
|
49
|
+
<el-scrollbar>
|
|
50
|
+
<div class="action-list">
|
|
51
|
+
<div
|
|
52
|
+
class="action"
|
|
53
|
+
v-for="(item, index) in action"
|
|
54
|
+
:key="index"
|
|
55
|
+
@click="handleAction(item)"
|
|
56
|
+
:class="
|
|
57
|
+
currentAction && item.type == currentAction.type
|
|
58
|
+
? 'selectAction'
|
|
59
|
+
: ''
|
|
60
|
+
"
|
|
61
|
+
>
|
|
62
|
+
<span class="event-script-menu-i">Function</span>
|
|
63
|
+
<div class="event-script-menu-label">
|
|
64
|
+
{{ item.funcName }}
|
|
65
|
+
</div>
|
|
66
|
+
<div
|
|
67
|
+
class="event-script-menu-action"
|
|
68
|
+
v-if="!item.disabled"
|
|
69
|
+
>
|
|
70
|
+
<i
|
|
71
|
+
title="复制"
|
|
72
|
+
class="iconfontui icon-fuzhi"
|
|
73
|
+
@click.stop="copyAction(item)"
|
|
74
|
+
></i>
|
|
75
|
+
<i
|
|
76
|
+
title="删除"
|
|
77
|
+
class="iconfontui icon-shanchu1"
|
|
78
|
+
@click.stop="deleteAction(item)"
|
|
79
|
+
></i>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</el-scrollbar>
|
|
84
|
+
</el-main>
|
|
85
|
+
</el-container>
|
|
86
|
+
</el-aside>
|
|
87
|
+
<el-main class="event-script-main">
|
|
88
|
+
<el-container class="is-vertical">
|
|
89
|
+
<header class="action-header event-script-main-header">
|
|
90
|
+
<el-button type="primary" @click="onConfirm" size="small"
|
|
91
|
+
>确定</el-button
|
|
92
|
+
>
|
|
93
|
+
<el-button type="primary" @click="onSave" size="small"
|
|
94
|
+
>保存</el-button
|
|
95
|
+
>
|
|
96
|
+
<el-button @click="onCancel" size="small">取消</el-button>
|
|
97
|
+
</header>
|
|
98
|
+
<el-main v-if="currentAction" class="func_main">
|
|
99
|
+
<el-scrollbar>
|
|
100
|
+
<el-form :model="currentAction" :rules="rules">
|
|
101
|
+
<el-form-item label="Function Name" prop="funcName">
|
|
102
|
+
<el-input
|
|
103
|
+
v-model="currentAction.funcName"
|
|
104
|
+
:disabled="currentAction.disabled"
|
|
105
|
+
/>
|
|
106
|
+
</el-form-item>
|
|
107
|
+
<el-form-item prop="funcStr">
|
|
108
|
+
<div class="coding">
|
|
109
|
+
<div class="header">
|
|
110
|
+
function {{ currentAction.funcName }}({{
|
|
111
|
+
getField(currentAction.methods)
|
|
112
|
+
}}){
|
|
113
|
+
</div>
|
|
114
|
+
<codemirror
|
|
115
|
+
v-model="currentAction.funcStr"
|
|
116
|
+
placeholder=""
|
|
117
|
+
:style="{ height: '400px' }"
|
|
118
|
+
mode="text/javascript"
|
|
119
|
+
:autofocus="true"
|
|
120
|
+
:indent-with-tab="true"
|
|
121
|
+
:tab-size="2"
|
|
122
|
+
/>
|
|
123
|
+
<div class="footer">}</div>
|
|
124
|
+
</div>
|
|
125
|
+
</el-form-item>
|
|
126
|
+
</el-form>
|
|
127
|
+
</el-scrollbar>
|
|
128
|
+
</el-main>
|
|
129
|
+
</el-container>
|
|
130
|
+
</el-main>
|
|
131
|
+
</el-container>
|
|
132
|
+
</el-container>
|
|
133
|
+
</div>
|
|
134
|
+
</CustomDialog>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</template>
|
|
138
|
+
<script lang="ts">
|
|
139
|
+
import {
|
|
140
|
+
defineComponent,
|
|
141
|
+
ref,
|
|
142
|
+
reactive,
|
|
143
|
+
onMounted,
|
|
144
|
+
inject,
|
|
145
|
+
getCurrentInstance,
|
|
146
|
+
} from "vue";
|
|
147
|
+
// import { javascript } from "@codemirror/lang-javascript";
|
|
148
|
+
import { Codemirror } from "vue-codemirror";
|
|
149
|
+
export default defineComponent({
|
|
150
|
+
ControlType: "FormAction",
|
|
151
|
+
isHide: true,
|
|
152
|
+
components: {
|
|
153
|
+
Codemirror,
|
|
154
|
+
},
|
|
155
|
+
props: {
|
|
156
|
+
item: {
|
|
157
|
+
type: Object,
|
|
158
|
+
default: () => ({}),
|
|
159
|
+
},
|
|
160
|
+
data: {
|
|
161
|
+
type: Object,
|
|
162
|
+
default: () => ({}),
|
|
163
|
+
},
|
|
164
|
+
drag: {
|
|
165
|
+
type: Boolean,
|
|
166
|
+
default: false,
|
|
167
|
+
},
|
|
168
|
+
labelalign: {
|
|
169
|
+
type: String,
|
|
170
|
+
default: "top",
|
|
171
|
+
},
|
|
172
|
+
labelWidth: {
|
|
173
|
+
type: Number,
|
|
174
|
+
},
|
|
175
|
+
size: {
|
|
176
|
+
type: String,
|
|
177
|
+
},
|
|
178
|
+
isForm: {
|
|
179
|
+
type: Boolean,
|
|
180
|
+
default: false,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
setup(props) {
|
|
184
|
+
const { actionContrl: actionStore } = inject<any>("control") || {};
|
|
185
|
+
const actionRef = ref();
|
|
186
|
+
const { proxy } = getCurrentInstance() as any;
|
|
187
|
+
const action = ref(window.VApp.$Flex.deepClone(actionStore?.get("action")));
|
|
188
|
+
const currentAction = ref(
|
|
189
|
+
window.VApp.$Flex.deepClone(actionStore?.get("currentAction"))
|
|
190
|
+
);
|
|
191
|
+
// const extensions = [javascript()];
|
|
192
|
+
let actionType = "";
|
|
193
|
+
const rules = reactive({
|
|
194
|
+
funcName: [
|
|
195
|
+
{
|
|
196
|
+
required: true,
|
|
197
|
+
message: "函数名称必填",
|
|
198
|
+
trigger: "change",
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
});
|
|
202
|
+
console.log(props);
|
|
203
|
+
onMounted(() => {
|
|
204
|
+
// props.data[props.item.data.fieldName] = action.value;
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
rules,
|
|
208
|
+
actionRef,
|
|
209
|
+
action,
|
|
210
|
+
currentAction,
|
|
211
|
+
getField(methods: string) {
|
|
212
|
+
return window.VApp.$Flex.getField(methods);
|
|
213
|
+
},
|
|
214
|
+
// extensions,
|
|
215
|
+
onAction(type?: string) {
|
|
216
|
+
action.value = window.VApp.$Flex.deepClone(actionStore?.get("action"));
|
|
217
|
+
actionRef.value.init("动作设置", "icon-icon-bianji");
|
|
218
|
+
actionRef.value.show();
|
|
219
|
+
if (type) {
|
|
220
|
+
actionType = type;
|
|
221
|
+
const item = action.value.find((item: any) => {
|
|
222
|
+
if (item.type == type) {
|
|
223
|
+
return item;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
if (item) {
|
|
227
|
+
currentAction.value = item;
|
|
228
|
+
} else {
|
|
229
|
+
proxy.addAction(type);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
onEditAction(key: any, type: string) {
|
|
234
|
+
actionType = key;
|
|
235
|
+
action.value = window.VApp.$Flex.deepClone(actionStore?.get("action"));
|
|
236
|
+
actionRef.value.init("动作设置", "icon-icon-bianji");
|
|
237
|
+
actionRef.value.show();
|
|
238
|
+
const item = action.value.find((item: any) => {
|
|
239
|
+
if (item.type == type) {
|
|
240
|
+
return item;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
if (item) {
|
|
244
|
+
currentAction.value = item;
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
handleAction(item: any) {
|
|
248
|
+
currentAction.value = item;
|
|
249
|
+
},
|
|
250
|
+
onSave() {
|
|
251
|
+
actionStore?.set("action", action.value);
|
|
252
|
+
actionRef.value.close();
|
|
253
|
+
},
|
|
254
|
+
onCancel() {
|
|
255
|
+
actionRef.value.close();
|
|
256
|
+
},
|
|
257
|
+
copyAction(item: any) {
|
|
258
|
+
const newAction = window.VApp.$Flex.deepClone(item);
|
|
259
|
+
newAction.funcName = newAction.funcName + "_copy";
|
|
260
|
+
newAction.type = window.VApp.$Flex.generateMixed(5);
|
|
261
|
+
action.value.push(newAction);
|
|
262
|
+
currentAction.value = newAction;
|
|
263
|
+
},
|
|
264
|
+
deleteAction(item: any) {
|
|
265
|
+
action.value = action.value.filter((actionItem: any) => {
|
|
266
|
+
if (actionItem.type !== item.type) {
|
|
267
|
+
return actionItem;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
if (currentAction.value && item.type == currentAction.value.type) {
|
|
271
|
+
currentAction.value = null;
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
addAction(type?: string) {
|
|
275
|
+
const addAction = {
|
|
276
|
+
funcName: (type || "func") + "_" + window.VApp.$Flex.generateMixed(5),
|
|
277
|
+
type: window.VApp.$Flex.generateMixed(5),
|
|
278
|
+
funcStr: "",
|
|
279
|
+
methods: type,
|
|
280
|
+
};
|
|
281
|
+
action.value.push(addAction);
|
|
282
|
+
if (type) {
|
|
283
|
+
currentAction.value = addAction;
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
onConfirm() {
|
|
287
|
+
if (!props.data[props.item.data.fieldName]) {
|
|
288
|
+
props.data[props.item.data.fieldName] = {};
|
|
289
|
+
}
|
|
290
|
+
props.data[props.item.data.fieldName][actionType] = JSON.stringify(
|
|
291
|
+
currentAction.value
|
|
292
|
+
);
|
|
293
|
+
proxy.onSave();
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
</script>
|