tianheng-ui 0.1.10 → 0.1.11
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/lib/theme-chalk/styles/reset.scss +0 -2
- package/lib/tianheng-ui.js +14 -14
- package/package.json +1 -1
- package/packages/FormMaking/GenerateForm.vue +10 -10
- package/packages/FormMaking/GenerateFormItem.vue +66 -578
- package/packages/FormMaking/GenerateFormItemH5.vue +5 -5
- package/packages/FormMaking/Upload/index.vue +0 -1
- package/packages/FormMaking/WidgetConfig.vue +66 -30
- package/packages/FormMaking/WidgetForm.vue +7 -48
- package/packages/FormMaking/WidgetFormItem.vue +41 -65
- package/packages/FormMaking/WidgetSelect.vue +160 -0
- package/packages/FormMaking/custom/config.js +98 -63
- package/packages/FormMaking/custom/configs/grid.vue +4 -4
- package/packages/FormMaking/custom/configs/input.vue +135 -28
- package/packages/FormMaking/custom/configs/number.vue +2 -2
- package/packages/FormMaking/custom/configs/table.vue +2 -2
- package/packages/FormMaking/custom/configs/{table_h5.vue → tableH5.vue} +2 -2
- package/packages/FormMaking/custom/configs/tabs.vue +6 -6
- package/packages/FormMaking/custom/configs/textarea.vue +121 -19
- package/packages/FormMaking/custom/index.js +2 -4
- package/packages/FormMaking/custom/items/alliance.vue +30 -29
- package/packages/FormMaking/custom/items/blank_pro.vue +14 -0
- package/packages/FormMaking/custom/items/button.vue +1 -0
- package/packages/FormMaking/custom/items/cascader.vue +6 -2
- package/packages/FormMaking/custom/items/cell.vue +0 -2
- package/packages/FormMaking/custom/items/checkbox.vue +17 -7
- package/packages/FormMaking/custom/items/color.vue +1 -1
- package/packages/FormMaking/custom/items/date.vue +1 -1
- package/packages/FormMaking/custom/items/editor.vue +1 -1
- package/packages/FormMaking/custom/items/{grid.vue → grid_dev.vue} +16 -47
- package/packages/FormMaking/custom/items/grid_pro.vue +45 -0
- package/packages/FormMaking/custom/items/image.vue +0 -28
- package/packages/FormMaking/custom/items/input.vue +15 -9
- package/packages/FormMaking/custom/items/number.vue +4 -4
- package/packages/FormMaking/custom/items/radio.vue +17 -7
- package/packages/FormMaking/custom/items/rate.vue +1 -1
- package/packages/FormMaking/custom/items/select.vue +12 -6
- package/packages/FormMaking/custom/items/slider.vue +1 -1
- package/packages/FormMaking/custom/items/switch.vue +1 -1
- package/packages/FormMaking/custom/items/{table_h5.vue → tableH5_dev.vue} +44 -49
- package/packages/FormMaking/custom/items/tableH5_pro.vue +113 -0
- package/packages/FormMaking/custom/items/{table.vue → table_dev.vue} +21 -41
- package/packages/FormMaking/custom/items/table_pro.vue +114 -0
- package/packages/FormMaking/custom/items/tabs_dev.vue +101 -0
- package/packages/FormMaking/custom/items/tabs_pro.vue +50 -0
- package/packages/FormMaking/custom/items/text.vue +1 -1
- package/packages/FormMaking/custom/items/textarea.vue +4 -13
- package/packages/FormMaking/custom/items/time.vue +3 -3
- package/packages/FormMaking/custom/items/upload.vue +15 -14
- package/packages/FormMaking/custom/mixins/index.js +23 -1
- package/packages/FormMaking/custom/register.js +22 -11
- package/packages/FormMaking/index.vue +11 -7
- package/packages/FormMaking/styles/index.scss +235 -221
- package/packages/FormMaking/util/generateCode.js +3 -3
- package/packages/FormMaking/util/index.js +33 -23
- package/packages/FormMaking/custom/items/tabs.vue +0 -145
- /package/packages/FormMaking/custom/items/{blank.vue → blank_dev.vue} +0 -0
@@ -502,7 +502,7 @@
|
|
502
502
|
</el-table>
|
503
503
|
</template>
|
504
504
|
|
505
|
-
<template v-if="widget.type == '
|
505
|
+
<template v-if="widget.type == 'tableH5'">
|
506
506
|
<div class="tableH5">
|
507
507
|
<div
|
508
508
|
class="tableH5-item"
|
@@ -567,7 +567,7 @@
|
|
567
567
|
:align="widget.options.align"
|
568
568
|
>
|
569
569
|
<el-col
|
570
|
-
v-for="(column, columnIndex) in widget.columns"
|
570
|
+
v-for="(column, columnIndex) in widget.options.columns"
|
571
571
|
:key="columnIndex"
|
572
572
|
:span="column.span"
|
573
573
|
>
|
@@ -593,7 +593,7 @@
|
|
593
593
|
<template v-if="widget.type == 'tabs'">
|
594
594
|
<el-tabs v-model="widget.options.defaultValue">
|
595
595
|
<el-tab-pane
|
596
|
-
v-for="(column, columnIndex) in widget.
|
596
|
+
v-for="(column, columnIndex) in widget.options.columns"
|
597
597
|
:key="`tabs_${columnIndex}`"
|
598
598
|
:label="column.label"
|
599
599
|
:name="column.value"
|
@@ -750,8 +750,8 @@ export default {
|
|
750
750
|
let dic = {};
|
751
751
|
this.widget.list.forEach(item => {
|
752
752
|
if (item.type === "grid") {
|
753
|
-
for (let i = 0; i < item.columns.length; i++) {
|
754
|
-
const element = item.columns[i];
|
753
|
+
for (let i = 0; i < item.options.columns.length; i++) {
|
754
|
+
const element = item.options.columns[i];
|
755
755
|
for (let j = 0; j < element.list.length; j++) {
|
756
756
|
const element2 = element.list[j];
|
757
757
|
dic[element2.model] = element2.options.defaultValue;
|
@@ -1,5 +1,33 @@
|
|
1
1
|
<template>
|
2
2
|
<div class="widgetConfig" v-if="show">
|
3
|
+
<div style="line-height: 30px;"></div>
|
4
|
+
<div class="flexView">
|
5
|
+
<div style="width:100px">类型切换</div>
|
6
|
+
<el-select
|
7
|
+
:value="data.type"
|
8
|
+
style="width:100%;"
|
9
|
+
size="small"
|
10
|
+
placeholder="请选择类型"
|
11
|
+
@change="handleTypeChange"
|
12
|
+
>
|
13
|
+
<el-option
|
14
|
+
v-for="item in Object.values(compsData)"
|
15
|
+
:key="item.type"
|
16
|
+
:label="item.name"
|
17
|
+
:value="item.type"
|
18
|
+
>
|
19
|
+
</el-option>
|
20
|
+
</el-select>
|
21
|
+
<el-tooltip
|
22
|
+
style="padding-left:10px;color:#F56C6C;"
|
23
|
+
effect="dark"
|
24
|
+
content="切换类型会导致该组件配置信息重置,请谨慎使用!"
|
25
|
+
placement="top"
|
26
|
+
>
|
27
|
+
<i class="el-icon-warning"></i>
|
28
|
+
</el-tooltip>
|
29
|
+
</div>
|
30
|
+
|
3
31
|
<component
|
4
32
|
:widget="data"
|
5
33
|
:config="config"
|
@@ -108,10 +136,7 @@
|
|
108
136
|
|
109
137
|
<script>
|
110
138
|
import compsData from "./custom/register";
|
111
|
-
import ThDialog from "ui/Dialog/index.vue";
|
112
|
-
import ThCodeEditor from "ui/CodeEditor/index.vue";
|
113
139
|
export default {
|
114
|
-
components: { ThDialog, ThCodeEditor },
|
115
140
|
props: {
|
116
141
|
data: {
|
117
142
|
type: Object,
|
@@ -175,6 +200,34 @@ export default {
|
|
175
200
|
]
|
176
201
|
};
|
177
202
|
},
|
203
|
+
// watch: {
|
204
|
+
// "data.options.isRange": function(val) {
|
205
|
+
// if (typeof val !== "undefined") {
|
206
|
+
// if (val) {
|
207
|
+
// this.data.options.defaultValue = null;
|
208
|
+
// } else {
|
209
|
+
// if (Object.keys(this.data.options).indexOf("defaultValue") >= 0)
|
210
|
+
// this.data.options.defaultValue = "";
|
211
|
+
// }
|
212
|
+
// }
|
213
|
+
// },
|
214
|
+
// "data.options.required": function(val) {
|
215
|
+
// this.validateRequired(val);
|
216
|
+
// },
|
217
|
+
// "data.options.dataType": function(val) {
|
218
|
+
// this.validateDataType(val);
|
219
|
+
// },
|
220
|
+
// "data.options.pattern": function(val) {
|
221
|
+
// this.valiatePattern(val);
|
222
|
+
// },
|
223
|
+
// "data.name": function(val) {
|
224
|
+
// if (this.data.options) {
|
225
|
+
// this.validateRequired(this.data.options.required);
|
226
|
+
// this.validateDataType(this.data.options.dataType);
|
227
|
+
// this.valiatePattern(this.data.options.pattern);
|
228
|
+
// }
|
229
|
+
// }
|
230
|
+
// },
|
178
231
|
computed: {
|
179
232
|
show() {
|
180
233
|
if (this.data && Object.keys(this.data).length > 0) {
|
@@ -310,34 +363,10 @@ export default {
|
|
310
363
|
break;
|
311
364
|
}
|
312
365
|
}
|
313
|
-
}
|
314
|
-
},
|
315
|
-
watch: {
|
316
|
-
"data.options.isRange": function(val) {
|
317
|
-
if (typeof val !== "undefined") {
|
318
|
-
if (val) {
|
319
|
-
this.data.options.defaultValue = null;
|
320
|
-
} else {
|
321
|
-
if (Object.keys(this.data.options).indexOf("defaultValue") >= 0)
|
322
|
-
this.data.options.defaultValue = "";
|
323
|
-
}
|
324
|
-
}
|
325
366
|
},
|
326
|
-
|
327
|
-
this.
|
328
|
-
|
329
|
-
"data.options.dataType": function(val) {
|
330
|
-
this.validateDataType(val);
|
331
|
-
},
|
332
|
-
"data.options.pattern": function(val) {
|
333
|
-
this.valiatePattern(val);
|
334
|
-
},
|
335
|
-
"data.name": function(val) {
|
336
|
-
if (this.data.options) {
|
337
|
-
this.validateRequired(this.data.options.required);
|
338
|
-
this.validateDataType(this.data.options.dataType);
|
339
|
-
this.valiatePattern(this.data.options.pattern);
|
340
|
-
}
|
367
|
+
handleTypeChange(val) {
|
368
|
+
const config = JSON.parse(JSON.stringify(this.compsData[val].config));
|
369
|
+
this.$emit("update", config);
|
341
370
|
}
|
342
371
|
}
|
343
372
|
};
|
@@ -464,5 +493,12 @@ export default {
|
|
464
493
|
margin: 0 5px;
|
465
494
|
}
|
466
495
|
}
|
496
|
+
.flexView {
|
497
|
+
display: flex;
|
498
|
+
align-items: center;
|
499
|
+
padding-bottom: 10px;
|
500
|
+
margin-bottom: 10px;
|
501
|
+
border-bottom: 1px solid #e1e1e1;
|
502
|
+
}
|
467
503
|
}
|
468
504
|
</style>
|
@@ -1,8 +1,5 @@
|
|
1
1
|
<template>
|
2
2
|
<div class="widget-form-container" ref="formContainer">
|
3
|
-
<!-- <div v-if="data.list.length == 0" class="form-empty">
|
4
|
-
从左侧拖拽来添加字段
|
5
|
-
</div> -->
|
6
3
|
<th-empty
|
7
4
|
class="form-empty"
|
8
5
|
v-if="data.list.length == 0"
|
@@ -10,7 +7,7 @@
|
|
10
7
|
description="从左侧拖拽来添加字段"
|
11
8
|
></th-empty>
|
12
9
|
<el-form
|
13
|
-
:class="{
|
10
|
+
:class="{ isHideFormLabel: data.config.hideLabel }"
|
14
11
|
style="margin: 0 auto;padding:5px;height:100%;"
|
15
12
|
:style="{ width: formWidth }"
|
16
13
|
:size="data.config.size"
|
@@ -20,7 +17,7 @@
|
|
20
17
|
:disabled="data.config.disabled"
|
21
18
|
>
|
22
19
|
<draggable
|
23
|
-
|
20
|
+
class="draggable"
|
24
21
|
v-model="data.list"
|
25
22
|
v-bind="{
|
26
23
|
group: 'people',
|
@@ -28,16 +25,15 @@
|
|
28
25
|
animation: 200,
|
29
26
|
handle: '.drag-widget'
|
30
27
|
}"
|
31
|
-
@end="handleMoveEnd"
|
32
28
|
@add="handleWidgetAdd"
|
33
29
|
>
|
34
|
-
<transition-group name="fade" tag="div" class="
|
30
|
+
<transition-group name="fade" tag="div" class="draggable-list">
|
35
31
|
<widget-form-item
|
36
32
|
v-for="(element, elementIndex) in widgetList"
|
37
33
|
:key="element.key"
|
38
34
|
:widget="element"
|
35
|
+
:widgetArray="data.list"
|
39
36
|
:widgetIndex="elementIndex"
|
40
|
-
:widgetArray="data"
|
41
37
|
:config="data.config"
|
42
38
|
:select.sync="selectWidget"
|
43
39
|
></widget-form-item>
|
@@ -49,11 +45,10 @@
|
|
49
45
|
|
50
46
|
<script>
|
51
47
|
import Draggable from "vuedraggable";
|
52
|
-
import WidgetFormItem from "./WidgetFormItem";
|
53
|
-
import ThEmpty from "ui/Empty/index.vue";
|
48
|
+
import WidgetFormItem from "./WidgetFormItem.vue";
|
54
49
|
|
55
50
|
export default {
|
56
|
-
components: { Draggable, WidgetFormItem
|
51
|
+
components: { Draggable, WidgetFormItem },
|
57
52
|
props: ["data", "select", "client"],
|
58
53
|
data() {
|
59
54
|
return {
|
@@ -99,7 +94,6 @@ export default {
|
|
99
94
|
};
|
100
95
|
},
|
101
96
|
methods: {
|
102
|
-
handleMoveEnd({ newIndex, oldIndex }) {},
|
103
97
|
handleSelectWidget(index) {
|
104
98
|
this.selectWidget = this.data.list[index];
|
105
99
|
},
|
@@ -113,45 +107,10 @@ export default {
|
|
113
107
|
let dic = JSON.parse(JSON.stringify(this.data.list[newIndex]));
|
114
108
|
dic.key = key;
|
115
109
|
dic.model = dic.type + "_" + key;
|
116
|
-
dic.rules = [];
|
110
|
+
// dic.rules = [{ id: new Date().getTime(), patternStr: "", pattern: "" }];
|
117
111
|
|
118
112
|
this.$set(this.data.list, newIndex, dic);
|
119
113
|
|
120
|
-
// if (
|
121
|
-
// this.data.list[newIndex].type === "radio" ||
|
122
|
-
// this.data.list[newIndex].type === "checkbox" ||
|
123
|
-
// this.data.list[newIndex].type === "select"
|
124
|
-
// ) {
|
125
|
-
// this.$set(this.data.list, newIndex, {
|
126
|
-
// ...this.data.list[newIndex],
|
127
|
-
// options: {
|
128
|
-
// ...this.data.list[newIndex].options,
|
129
|
-
// options: this.data.list[newIndex].options.options.map(item => ({
|
130
|
-
// ...item
|
131
|
-
// }))
|
132
|
-
// }
|
133
|
-
// });
|
134
|
-
// }
|
135
|
-
|
136
|
-
// if (this.data.list[newIndex].type === "grid") {
|
137
|
-
// this.$set(
|
138
|
-
// this.data.list,
|
139
|
-
// newIndex,
|
140
|
-
// JSON.parse(JSON.stringify(this.data.list[newIndex]))
|
141
|
-
// );
|
142
|
-
// }
|
143
|
-
|
144
|
-
// if (this.data.list[newIndex].type === "tabs") {
|
145
|
-
// this.$set(this.data.list, newIndex, JSON.parse(JSON.stringify(this.data.list[newIndex])));
|
146
|
-
// }
|
147
|
-
|
148
|
-
// if (this.data.list[newIndex].type === "table") {
|
149
|
-
// this.$set(this.data.list, newIndex, {
|
150
|
-
// ...this.data.list[newIndex],
|
151
|
-
// list: this.data.list[newIndex].list.map(item => ({ ...item }))
|
152
|
-
// });
|
153
|
-
// }
|
154
|
-
|
155
114
|
this.selectWidget = this.data.list[newIndex];
|
156
115
|
}
|
157
116
|
}
|
@@ -1,11 +1,10 @@
|
|
1
1
|
<template>
|
2
2
|
<el-form-item
|
3
|
-
class="
|
3
|
+
class="widgetFormItem"
|
4
4
|
:class="{
|
5
5
|
active: selectWidget.model == widget.model,
|
6
|
-
|
7
|
-
|
8
|
-
'widget-col': ['grid', 'tabs', 'table', 'table_h5', 'alliance'].includes(
|
6
|
+
isRequired: widget.options.required,
|
7
|
+
isLayout: ['grid', 'tabs', 'table', 'tableH5', 'alliance'].includes(
|
9
8
|
widget.type
|
10
9
|
),
|
11
10
|
[`widget-form-list-${widget.type}`]: true,
|
@@ -14,10 +13,11 @@
|
|
14
13
|
:label="widget.options.hideLabel ? '' : widget.name"
|
15
14
|
:label-width="labelWidth"
|
16
15
|
:ref="widget.model"
|
17
|
-
@click.native.stop="
|
16
|
+
@click.native.stop="selectWidget = widget"
|
18
17
|
>
|
19
18
|
<component
|
20
19
|
:is="compsData[widget.type].content"
|
20
|
+
:value.sync="widget.options.defaultValue"
|
21
21
|
:widget="widget"
|
22
22
|
:config="config"
|
23
23
|
:select.sync="selectWidget"
|
@@ -32,20 +32,14 @@
|
|
32
32
|
'grid',
|
33
33
|
'tabs',
|
34
34
|
'table',
|
35
|
-
'
|
35
|
+
'tableH5',
|
36
36
|
'alliance'
|
37
37
|
].includes(widget.type)
|
38
38
|
}"
|
39
39
|
>
|
40
40
|
<div class="actions">
|
41
|
-
<i
|
42
|
-
|
43
|
-
@click.stop="handleWidgetClone(widgetIndex)"
|
44
|
-
></i>
|
45
|
-
<i
|
46
|
-
class="iconfont icon-trash"
|
47
|
-
@click.stop="handleWidgetDelete(widgetIndex)"
|
48
|
-
></i>
|
41
|
+
<i class="iconfont icon-icon_clone" @click.stop="handleWidgetClone"></i>
|
42
|
+
<i class="iconfont icon-trash" @click.stop="handleWidgetDelete"></i>
|
49
43
|
</div>
|
50
44
|
|
51
45
|
<div class="drag">
|
@@ -90,59 +84,69 @@ export default {
|
|
90
84
|
}
|
91
85
|
},
|
92
86
|
created() {
|
87
|
+
const devComponentsPath = {
|
88
|
+
grid: "grid_dev",
|
89
|
+
table: "table_dev",
|
90
|
+
tableH5: "tableH5_dev",
|
91
|
+
tabs: "tabs_dev",
|
92
|
+
blank: "blank_dev"
|
93
|
+
};
|
93
94
|
const keys = Object.keys(this.compsData);
|
94
95
|
for (const key of keys) {
|
95
|
-
|
96
|
+
if (devComponentsPath[key])
|
97
|
+
this.compsData[
|
98
|
+
key
|
99
|
+
].content = require(`./custom/items/${devComponentsPath[key]}`).default;
|
100
|
+
else
|
101
|
+
this.compsData[key].content = require(`./custom/items/${key}`).default;
|
96
102
|
}
|
97
103
|
},
|
98
104
|
mounted() {},
|
99
105
|
methods: {
|
100
|
-
|
101
|
-
this.
|
102
|
-
|
103
|
-
handleWidgetDelete(index) {
|
104
|
-
if (this.widgetArray.list.length - 1 === index) {
|
105
|
-
if (index === 0) {
|
106
|
+
handleWidgetDelete() {
|
107
|
+
if (this.widgetArray.length - 1 === this.widgetIndex) {
|
108
|
+
if (this.widgetIndex === 0) {
|
106
109
|
this.selectWidget = {};
|
107
110
|
} else {
|
108
|
-
this.selectWidget = this.widgetArray.
|
111
|
+
this.selectWidget = this.widgetArray[this.widgetIndex - 1];
|
109
112
|
}
|
110
113
|
} else {
|
111
|
-
this.selectWidget = this.widgetArray.
|
114
|
+
this.selectWidget = this.widgetArray[this.widgetIndex + 1];
|
112
115
|
}
|
113
116
|
|
114
117
|
this.$nextTick(() => {
|
115
|
-
this.widgetArray.
|
118
|
+
this.widgetArray.splice(this.widgetIndex, 1);
|
116
119
|
});
|
117
120
|
},
|
118
121
|
|
119
|
-
handleWidgetClone(
|
120
|
-
const data = JSON.parse(
|
122
|
+
handleWidgetClone() {
|
123
|
+
const data = JSON.parse(
|
124
|
+
JSON.stringify(this.widgetArray[this.widgetIndex])
|
125
|
+
);
|
121
126
|
|
122
127
|
const initKey = item => {
|
123
|
-
const key =
|
124
|
-
|
125
|
-
|
126
|
-
Math.ceil(Math.random() * 99999);
|
128
|
+
const key = `${Date.parse(new Date().toString())}_${Math.ceil(
|
129
|
+
Math.random() * 99999
|
130
|
+
)}`;
|
127
131
|
|
128
|
-
item.options.remoteFunc = `func__${key}`;
|
129
132
|
item.key = key;
|
130
|
-
item.
|
133
|
+
item.options.remoteFunc = `func__${key}`;
|
134
|
+
item.model = `${item.type}_${key}`;
|
131
135
|
|
132
|
-
if (["table", "
|
136
|
+
if (["table", "tableH5"].includes(item.type)) {
|
133
137
|
item.list.forEach(element => {
|
134
138
|
initKey(element);
|
135
139
|
});
|
136
140
|
}
|
137
141
|
if (["tabs"].includes(item.type)) {
|
138
|
-
item.
|
142
|
+
item.options.columns.forEach(tab => {
|
139
143
|
tab.forEach(element => {
|
140
144
|
initKey(element);
|
141
145
|
});
|
142
146
|
});
|
143
147
|
}
|
144
148
|
if (["grid"].includes(item.type)) {
|
145
|
-
item.columns.forEach(column => {
|
149
|
+
item.options.columns.forEach(column => {
|
146
150
|
column.list.forEach(element => {
|
147
151
|
initKey(element);
|
148
152
|
});
|
@@ -151,36 +155,8 @@ export default {
|
|
151
155
|
};
|
152
156
|
initKey(data);
|
153
157
|
|
154
|
-
|
155
|
-
|
156
|
-
// options: {
|
157
|
-
// ...this.widgetArray.list[index].options,
|
158
|
-
// remoteFunc: "func_" + key
|
159
|
-
// },
|
160
|
-
// key,
|
161
|
-
// model: this.widgetArray.list[index].type + "_" + key,
|
162
|
-
// rules: this.widgetArray.list[index].rules || []
|
163
|
-
// };
|
164
|
-
|
165
|
-
// if (
|
166
|
-
// this.widgetArray.list[index].type === "radio" ||
|
167
|
-
// this.widgetArray.list[index].type === "checkbox" ||
|
168
|
-
// this.widgetArray.list[index].type === "select"
|
169
|
-
// ) {
|
170
|
-
// cloneData = {
|
171
|
-
// ...cloneData,
|
172
|
-
// options: {
|
173
|
-
// ...cloneData.options,
|
174
|
-
// options: cloneData.options.options.map(item => ({ ...item }))
|
175
|
-
// }
|
176
|
-
// };
|
177
|
-
// }
|
178
|
-
|
179
|
-
this.widgetArray.list.splice(index, 0, data);
|
180
|
-
|
181
|
-
this.$nextTick(() => {
|
182
|
-
this.selectWidget = this.widgetArray.list[index + 1];
|
183
|
-
});
|
158
|
+
this.widgetArray.splice(this.widgetIndex, 0, data);
|
159
|
+
this.selectWidget = data;
|
184
160
|
}
|
185
161
|
}
|
186
162
|
};
|
@@ -0,0 +1,160 @@
|
|
1
|
+
<template>
|
2
|
+
<div
|
3
|
+
v-if="selectWidget.model == widget.model"
|
4
|
+
class="widget-actions"
|
5
|
+
:class="{
|
6
|
+
'widget-actions_layout': [
|
7
|
+
'grid',
|
8
|
+
'tabs',
|
9
|
+
'table',
|
10
|
+
'tableH5',
|
11
|
+
'alliance'
|
12
|
+
].includes(widget.type)
|
13
|
+
}"
|
14
|
+
>
|
15
|
+
<div class="actions">
|
16
|
+
<i class="iconfont icon-icon_clone" @click.stop="handleWidgetClone"></i>
|
17
|
+
<i class="iconfont icon-trash" @click.stop="handleWidgetDelete"></i>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<div class="drag">
|
21
|
+
<i class="iconfont icon-drag drag-widget"></i>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</template>
|
25
|
+
|
26
|
+
<script>
|
27
|
+
export default {
|
28
|
+
props: ["widgetArray", "widgetIndex", "widget", "select"],
|
29
|
+
data() {
|
30
|
+
return {
|
31
|
+
selectWidget: this.select
|
32
|
+
};
|
33
|
+
},
|
34
|
+
watch: {
|
35
|
+
select(val) {
|
36
|
+
this.selectWidget = val;
|
37
|
+
},
|
38
|
+
selectWidget: {
|
39
|
+
handler(val) {
|
40
|
+
this.$emit("update:select", val);
|
41
|
+
},
|
42
|
+
deep: true
|
43
|
+
}
|
44
|
+
},
|
45
|
+
created() {},
|
46
|
+
mounted() {},
|
47
|
+
methods: {
|
48
|
+
handleWidgetDelete() {
|
49
|
+
if (this.widgetArray.length - 1 === this.widgetIndex) {
|
50
|
+
if (this.widgetIndex === 0) {
|
51
|
+
this.selectWidget = {};
|
52
|
+
} else {
|
53
|
+
this.selectWidget = this.widgetArray[this.widgetIndex - 1];
|
54
|
+
}
|
55
|
+
} else {
|
56
|
+
this.selectWidget = this.widgetArray[this.widgetIndex + 1];
|
57
|
+
}
|
58
|
+
|
59
|
+
this.$nextTick(() => {
|
60
|
+
this.widgetArray.splice(this.widgetIndex, 1);
|
61
|
+
});
|
62
|
+
},
|
63
|
+
|
64
|
+
handleWidgetClone() {
|
65
|
+
const data = JSON.parse(
|
66
|
+
JSON.stringify(this.widgetArray[this.widgetIndex])
|
67
|
+
);
|
68
|
+
|
69
|
+
const initKey = item => {
|
70
|
+
const key = `${Date.parse(new Date().toString())}_${Math.ceil(
|
71
|
+
Math.random() * 99999
|
72
|
+
)}`;
|
73
|
+
|
74
|
+
item.key = key;
|
75
|
+
item.options.remoteFunc = `func__${key}`;
|
76
|
+
item.model = `${item.type}_${key}`;
|
77
|
+
|
78
|
+
if (["table", "tableH5"].includes(item.type)) {
|
79
|
+
item.list.forEach(element => {
|
80
|
+
initKey(element);
|
81
|
+
});
|
82
|
+
}
|
83
|
+
if (["tabs"].includes(item.type)) {
|
84
|
+
item.options.columns.forEach(tab => {
|
85
|
+
tab.forEach(element => {
|
86
|
+
initKey(element);
|
87
|
+
});
|
88
|
+
});
|
89
|
+
}
|
90
|
+
if (["grid"].includes(item.type)) {
|
91
|
+
item.options.columns.forEach(column => {
|
92
|
+
column.list.forEach(element => {
|
93
|
+
initKey(element);
|
94
|
+
});
|
95
|
+
});
|
96
|
+
}
|
97
|
+
};
|
98
|
+
initKey(data);
|
99
|
+
|
100
|
+
this.widgetArray.splice(this.widgetIndex, 0, data);
|
101
|
+
this.selectWidget = data;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
};
|
105
|
+
</script>
|
106
|
+
|
107
|
+
<style lang="scss" scoped>
|
108
|
+
$primary-color: #409eff;
|
109
|
+
$primary-background-color: #ecf5ff;
|
110
|
+
.widget-actions {
|
111
|
+
position: absolute;
|
112
|
+
left: 0;
|
113
|
+
top: 0;
|
114
|
+
width: 100%;
|
115
|
+
height: 100%;
|
116
|
+
.actions {
|
117
|
+
position: absolute;
|
118
|
+
right: 0;
|
119
|
+
bottom: 0;
|
120
|
+
height: 28px;
|
121
|
+
line-height: 28px;
|
122
|
+
background: $primary-color;
|
123
|
+
z-index: 9;
|
124
|
+
|
125
|
+
i {
|
126
|
+
font-size: 14px;
|
127
|
+
color: #fff;
|
128
|
+
margin: 0 5px;
|
129
|
+
cursor: pointer;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
.drag {
|
134
|
+
position: absolute;
|
135
|
+
left: -2px;
|
136
|
+
bottom: -2px;
|
137
|
+
height: 28px;
|
138
|
+
line-height: 28px;
|
139
|
+
background: $primary-color;
|
140
|
+
z-index: 9;
|
141
|
+
|
142
|
+
i {
|
143
|
+
font-size: 14px;
|
144
|
+
color: #fff;
|
145
|
+
margin: 0 5px;
|
146
|
+
cursor: move;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
.widget-actions_layout {
|
152
|
+
.actions {
|
153
|
+
background: #e6a23c;
|
154
|
+
}
|
155
|
+
|
156
|
+
.drag {
|
157
|
+
background: #e6a23c;
|
158
|
+
}
|
159
|
+
}
|
160
|
+
</style>
|