tianheng-ui 0.1.9 → 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/TableMaking/generateTable.vue +2 -2
- package/packages/FormMaking/custom/items/tabs.vue +0 -145
- /package/packages/FormMaking/custom/items/{blank.vue → blank_dev.vue} +0 -0
@@ -1,32 +1,38 @@
|
|
1
1
|
<template>
|
2
2
|
<el-input
|
3
|
-
v-model="
|
3
|
+
v-model="dataModel"
|
4
|
+
:type="inputTypeDict(widget.options.dataType)"
|
4
5
|
:style="{ width: widget.options.width }"
|
5
6
|
:placeholder="widget.options.placeholder"
|
6
7
|
:disabled="widget.options.disabled"
|
8
|
+
:readonly="widget.options.readonly"
|
9
|
+
:clearable="widget.options.clearable"
|
7
10
|
:maxlength="widget.options.maxlength"
|
8
11
|
:show-word-limit="widget.options.showWordLimit"
|
9
12
|
:show-password="widget.options.showPassword"
|
10
|
-
:clearable="widget.options.clearable"
|
11
13
|
:suffix-icon="widget.options.suffixIcon"
|
12
14
|
:prefix-icon="widget.options.prefixIcon"
|
13
15
|
@input="handleEventAction(widget.events.onChange)"
|
14
16
|
@focus="handleEventAction(widget.events.onFocus)"
|
15
17
|
@blur="handleEventAction(widget.events.onBlur)"
|
16
18
|
>
|
17
|
-
<template v-if="widget.options.prepend" slot="prepend">
|
18
|
-
|
19
|
-
</template>
|
20
|
-
<template v-if="widget.options.append" slot="append">
|
21
|
-
|
22
|
-
</template>
|
19
|
+
<template v-if="widget.options.prepend" slot="prepend">{{
|
20
|
+
widget.options.prepend
|
21
|
+
}}</template>
|
22
|
+
<template v-if="widget.options.append" slot="append">{{
|
23
|
+
widget.options.append
|
24
|
+
}}</template>
|
23
25
|
</el-input>
|
24
26
|
</template>
|
25
27
|
|
26
28
|
<script>
|
29
|
+
import { inputTypeDict } from "../../util/index";
|
27
30
|
import { itemsComponent } from "../mixins/index";
|
28
31
|
export default {
|
29
|
-
mixins: [itemsComponent]
|
32
|
+
mixins: [itemsComponent],
|
33
|
+
methods: {
|
34
|
+
inputTypeDict
|
35
|
+
}
|
30
36
|
};
|
31
37
|
</script>
|
32
38
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<template>
|
2
2
|
<el-input-number
|
3
|
-
v-model="
|
4
|
-
:disabled="widget.options.disabled"
|
5
|
-
:controls-position="widget.options.controlsPosition ? 'right' : ''"
|
3
|
+
v-model="dataModel"
|
6
4
|
:style="{ width: widget.options.width }"
|
5
|
+
:step="widget.options.step"
|
6
|
+
:controls-position="widget.options.controlsPosition ? 'right' : ''"
|
7
|
+
:disabled="widget.options.disabled"
|
7
8
|
:min="widget.options.min"
|
8
9
|
:max="widget.options.max"
|
9
|
-
:step="widget.options.step"
|
10
10
|
:precision="widget.options.precision"
|
11
11
|
@change="handleEventAction(widget.events.onChange)"
|
12
12
|
@focus="handleEventAction(widget.events.onFocus)"
|
@@ -1,21 +1,26 @@
|
|
1
1
|
<template>
|
2
2
|
<el-radio-group
|
3
|
-
v-model="
|
3
|
+
v-model="dataModel"
|
4
4
|
:style="{ width: widget.options.width }"
|
5
5
|
:disabled="widget.options.disabled"
|
6
6
|
@change="handleEventAction(widget.events.onChange)"
|
7
7
|
>
|
8
8
|
<template v-if="widget.options.buttonType">
|
9
9
|
<el-radio-button
|
10
|
-
v-for="(item, index) in widget.options.options"
|
11
|
-
:key="`radio_${index}_${item.value}`"
|
12
10
|
:style="{
|
13
11
|
display: widget.options.inline ? 'inline-block' : 'block'
|
14
12
|
}"
|
13
|
+
v-for="(item, index) in widget.options.remote
|
14
|
+
? widget.options.remoteOptions
|
15
|
+
: widget.options.options"
|
16
|
+
:key="index"
|
15
17
|
:label="item.value"
|
16
18
|
:border="widget.options.border"
|
17
19
|
>
|
18
|
-
|
20
|
+
<template v-if="widget.options.remote">{{ item.label }}</template>
|
21
|
+
<template v-else>{{
|
22
|
+
widget.options.showLabel ? item.label : item.value
|
23
|
+
}}</template>
|
19
24
|
</el-radio-button>
|
20
25
|
</template>
|
21
26
|
<template v-else>
|
@@ -25,10 +30,15 @@
|
|
25
30
|
}"
|
26
31
|
:label="item.value"
|
27
32
|
:border="widget.options.border"
|
28
|
-
v-for="(item, index) in widget.options.
|
29
|
-
|
33
|
+
v-for="(item, index) in widget.options.remote
|
34
|
+
? widget.options.remoteOptions
|
35
|
+
: widget.options.options"
|
36
|
+
:key="index"
|
30
37
|
>
|
31
|
-
|
38
|
+
<template v-if="widget.options.remote">{{ item.label }}</template>
|
39
|
+
<template v-else>{{
|
40
|
+
widget.options.showLabel ? item.label : item.value
|
41
|
+
}}</template>
|
32
42
|
</el-radio>
|
33
43
|
</template>
|
34
44
|
</el-radio-group>
|
@@ -1,23 +1,29 @@
|
|
1
1
|
<template>
|
2
2
|
<el-select
|
3
|
-
v-model="
|
3
|
+
v-model="dataModel"
|
4
4
|
:style="{ width: widget.options.width }"
|
5
5
|
:disabled="widget.options.disabled"
|
6
6
|
:multiple="widget.options.multiple"
|
7
|
-
:collapseTags="widget.options.collapseTags"
|
8
|
-
:allowCreate="widget.options.allowCreate"
|
9
7
|
:clearable="widget.options.clearable"
|
10
8
|
:placeholder="widget.options.placeholder"
|
9
|
+
:collapseTags="widget.options.collapseTags"
|
10
|
+
:allowCreate="widget.options.allowCreate"
|
11
11
|
:filterable="widget.options.allowCreate ? true : widget.options.filterable"
|
12
12
|
@change="handleEventAction(widget.events.onChange)"
|
13
13
|
@focus="handleEventAction(widget.events.onFocus)"
|
14
14
|
@blur="handleEventAction(widget.events.onBlur)"
|
15
15
|
>
|
16
16
|
<el-option
|
17
|
-
v-for="
|
18
|
-
|
17
|
+
v-for="item in widget.options.remote
|
18
|
+
? widget.options.remoteOptions
|
19
|
+
: widget.options.options"
|
20
|
+
:key="item.value"
|
19
21
|
:value="item.value"
|
20
|
-
:label="
|
22
|
+
:label="
|
23
|
+
widget.options.showLabel || widget.options.remote
|
24
|
+
? item.label
|
25
|
+
: item.value
|
26
|
+
"
|
21
27
|
></el-option>
|
22
28
|
</el-select>
|
23
29
|
</template>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<template>
|
2
|
-
<div>
|
2
|
+
<div class="tableH5">
|
3
3
|
<draggable
|
4
|
-
v-model="widget.
|
4
|
+
v-model="widget.options.columns"
|
5
5
|
:no-transition-on-drag="true"
|
6
6
|
v-bind="{
|
7
7
|
group: 'people',
|
@@ -9,29 +9,24 @@
|
|
9
9
|
animation: 200,
|
10
10
|
handle: '.drag-widget'
|
11
11
|
}"
|
12
|
-
@add="
|
12
|
+
@add="handleWidgetAdd($event)"
|
13
13
|
>
|
14
|
-
<transition-group name="fade" tag="div" class="tableH5">
|
14
|
+
<transition-group name="fade" tag="div" class="tableH5-list">
|
15
15
|
<div
|
16
|
-
|
17
|
-
|
18
|
-
return item.key;
|
19
|
-
})"
|
16
|
+
v-for="(element, elementIndex) in widget.options.columns"
|
17
|
+
class="tableH5-list-item"
|
20
18
|
:key="element.key"
|
19
|
+
@click.stop="selectWidget = element"
|
21
20
|
>
|
22
21
|
<widget-form-item
|
23
|
-
class="tableH5-item-widget"
|
24
22
|
:widget="element"
|
23
|
+
:widgetArray="widget.options.columns"
|
25
24
|
:widgetIndex="elementIndex"
|
26
|
-
:widgetArray="widget"
|
27
25
|
:select.sync="selectWidget"
|
28
26
|
:config="config"
|
29
27
|
>
|
30
28
|
</widget-form-item>
|
31
|
-
<div
|
32
|
-
v-if="widget.options.isDelete && elementIndex === 0"
|
33
|
-
class="actions"
|
34
|
-
>
|
29
|
+
<div v-if="widget.options.isDelete && elementIndex === 0">
|
35
30
|
<el-button type="danger">{{
|
36
31
|
widget.options.deleteButtonText
|
37
32
|
}}</el-button>
|
@@ -39,7 +34,7 @@
|
|
39
34
|
</div>
|
40
35
|
</transition-group>
|
41
36
|
</draggable>
|
42
|
-
<div v-if="widget.options.isAdd"
|
37
|
+
<div v-if="widget.options.isAdd" class="footer">
|
43
38
|
<el-button type="text" :disabled="widget.options.disabled">{{
|
44
39
|
widget.options.addButtonText
|
45
40
|
}}</el-button>
|
@@ -71,56 +66,56 @@ export default {
|
|
71
66
|
}
|
72
67
|
},
|
73
68
|
methods: {
|
74
|
-
|
69
|
+
handleWidgetAdd($event) {
|
75
70
|
const newIndex = $event.newIndex;
|
76
71
|
const oldIndex = $event.oldIndex;
|
72
|
+
const newComponent = JSON.parse(
|
73
|
+
JSON.stringify(this.widget.options.columns[newIndex])
|
74
|
+
);
|
77
75
|
const item = $event.item;
|
78
76
|
// 防止布局元素的嵌套拖拽
|
79
77
|
if (item.className.indexOf("no-put") >= 0) {
|
80
78
|
// 如果是列表中拖拽的元素需要还原到原来位置
|
81
79
|
item.tagName === "DIV" &&
|
82
|
-
this.widgetArray.
|
83
|
-
|
84
|
-
row.list.splice(newIndex, 1);
|
80
|
+
this.widgetArray.splice(oldIndex, 0, newComponent);
|
85
81
|
|
82
|
+
this.widget.options.columns.splice(newIndex, 1);
|
86
83
|
return false;
|
87
84
|
}
|
88
85
|
|
89
86
|
const key =
|
90
87
|
Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
options: {
|
95
|
-
...row.list[newIndex].options
|
96
|
-
// remoteFunc: "func_" + key
|
97
|
-
},
|
98
|
-
key,
|
99
|
-
// 绑定键值
|
100
|
-
model: row.list[newIndex].type + "_" + key,
|
101
|
-
rules: []
|
102
|
-
});
|
103
|
-
|
104
|
-
if (
|
105
|
-
row.list[newIndex].type === "radio" ||
|
106
|
-
row.list[newIndex].type === "checkbox" ||
|
107
|
-
row.list[newIndex].type === "select"
|
108
|
-
) {
|
109
|
-
this.$set(row.list, newIndex, {
|
110
|
-
...row.list[newIndex],
|
111
|
-
options: {
|
112
|
-
...row.list[newIndex].options,
|
113
|
-
options: row.list[newIndex].options.options.map(item => ({
|
114
|
-
...item
|
115
|
-
}))
|
116
|
-
}
|
117
|
-
});
|
88
|
+
if (!newComponent.model) {
|
89
|
+
newComponent.key = key;
|
90
|
+
newComponent.model = `${newComponent.type}_${key}`;
|
118
91
|
}
|
119
|
-
|
120
|
-
this.selectWidget =
|
92
|
+
this.$set(this.widget.options.columns, newIndex, newComponent);
|
93
|
+
this.selectWidget = newComponent;
|
121
94
|
}
|
122
95
|
}
|
123
96
|
};
|
124
97
|
</script>
|
125
98
|
|
126
|
-
<style
|
99
|
+
<style lang="scss" scoped>
|
100
|
+
.tableH5 {
|
101
|
+
background: #fff;
|
102
|
+
|
103
|
+
.tableH5-list {
|
104
|
+
min-height: 50px;
|
105
|
+
border: 1px dashed #ccc;
|
106
|
+
.tableH5-list-item {
|
107
|
+
width: 100%;
|
108
|
+
}
|
109
|
+
.tableH5-list-item:nth-child(1) {
|
110
|
+
display: flex;
|
111
|
+
> div:first-child {
|
112
|
+
flex: 1;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
.footer {
|
118
|
+
text-align: center;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
</style>
|
@@ -0,0 +1,113 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="tableH5">
|
3
|
+
<div
|
4
|
+
v-for="(column, columnIndex) in dataModel"
|
5
|
+
class="tableH5-list"
|
6
|
+
:key="`tableH5_${columnIndex}`"
|
7
|
+
>
|
8
|
+
<div
|
9
|
+
v-for="(element, elementIndex) in widget.options.columns"
|
10
|
+
class="tableH5-list-item"
|
11
|
+
:key="`tableH5_${columnIndex}_${element.key}`"
|
12
|
+
>
|
13
|
+
<generate-form-item
|
14
|
+
style="flex:1;"
|
15
|
+
:models.sync="column"
|
16
|
+
:widget="element"
|
17
|
+
:remote="remote"
|
18
|
+
:config="config"
|
19
|
+
:prop="
|
20
|
+
element.type === 'grid'
|
21
|
+
? `${prop}.${columnIndex}`
|
22
|
+
: `${prop}.${columnIndex}.${element.model}`
|
23
|
+
"
|
24
|
+
:slotKeys="slotKeys"
|
25
|
+
:componentsData="componentsData"
|
26
|
+
>
|
27
|
+
<template v-for="name in slotKeys" :slot="name">
|
28
|
+
<slot :name="name" />
|
29
|
+
</template>
|
30
|
+
</generate-form-item>
|
31
|
+
<div
|
32
|
+
v-if="
|
33
|
+
widget.options.isDelete &&
|
34
|
+
elementIndex === 0 &&
|
35
|
+
columnIndex >= widget.options.deleteIndex
|
36
|
+
"
|
37
|
+
class="actions"
|
38
|
+
>
|
39
|
+
<el-button
|
40
|
+
type="danger"
|
41
|
+
@click.native.prevent="dataModel.splice(columnIndex, 1)"
|
42
|
+
>{{ widget.options.deleteButtonText }}</el-button
|
43
|
+
>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<div v-if="widget.options.isAdd" style="text-align: center;">
|
49
|
+
<el-button
|
50
|
+
type="text"
|
51
|
+
:disabled="widget.options.disabled"
|
52
|
+
@click="handleTableAdd"
|
53
|
+
>{{ widget.options.addButtonText }}</el-button
|
54
|
+
>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
</template>
|
58
|
+
|
59
|
+
<script>
|
60
|
+
import { itemsComponent } from "../mixins/index";
|
61
|
+
import GenerateFormItem from "../../GenerateFormItem.vue";
|
62
|
+
export default {
|
63
|
+
components: { GenerateFormItem },
|
64
|
+
mixins: [itemsComponent],
|
65
|
+
props: ["models", "remote", "prop", "slotKeys", "componentsData"],
|
66
|
+
data() {
|
67
|
+
return {};
|
68
|
+
},
|
69
|
+
|
70
|
+
methods: {
|
71
|
+
handleTableAdd() {
|
72
|
+
let dic = {};
|
73
|
+
this.widget.options.columns.forEach(item => {
|
74
|
+
if (item.type === "grid") {
|
75
|
+
for (let i = 0; i < item.options.columns.length; i++) {
|
76
|
+
const element = item.options.columns[i];
|
77
|
+
for (let j = 0; j < element.options.columns.length; j++) {
|
78
|
+
const element2 = element.options.columns[j];
|
79
|
+
dic[element2.model] = element2.options.defaultValue;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
} else {
|
83
|
+
dic[item.model] = item.options.defaultValue;
|
84
|
+
}
|
85
|
+
});
|
86
|
+
this.dataModel.push(dic);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
};
|
90
|
+
</script>
|
91
|
+
|
92
|
+
<style lang="scss" scoped>
|
93
|
+
.tableH5 {
|
94
|
+
background: #fff;
|
95
|
+
|
96
|
+
.tableH5-list {
|
97
|
+
.tableH5-list-item {
|
98
|
+
width: 100%;
|
99
|
+
}
|
100
|
+
.tableH5-list-item:nth-child(1) {
|
101
|
+
display: flex;
|
102
|
+
> div:first-child {
|
103
|
+
flex: 1;
|
104
|
+
margin-right: 10px;
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
.footer {
|
110
|
+
text-align: center;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
</style>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<template>
|
2
2
|
<draggable
|
3
|
-
v-model="widget.
|
3
|
+
v-model="widget.options.columns"
|
4
4
|
:no-transition-on-drag="true"
|
5
5
|
v-bind="{
|
6
6
|
group: 'people',
|
@@ -8,17 +8,19 @@
|
|
8
8
|
animation: 200,
|
9
9
|
handle: '.drag-widget'
|
10
10
|
}"
|
11
|
-
@add="
|
11
|
+
@add="handleWidgetAdd($event, widget)"
|
12
12
|
>
|
13
13
|
<transition-group name="fade" tag="div" class="widget-table-list">
|
14
14
|
<widget-form-item
|
15
|
-
v-for="(element, elementIndex) in widget.
|
16
|
-
|
17
|
-
|
15
|
+
v-for="(element, elementIndex) in widget.options.columns.filter(
|
16
|
+
item => {
|
17
|
+
return item.key;
|
18
|
+
}
|
19
|
+
)"
|
18
20
|
:key="element.key"
|
19
21
|
:widget="element"
|
20
22
|
:widgetIndex="elementIndex"
|
21
|
-
:widgetArray="widget"
|
23
|
+
:widgetArray="widget.options.columns"
|
22
24
|
:select.sync="selectWidget"
|
23
25
|
:config="config"
|
24
26
|
>
|
@@ -50,55 +52,33 @@ export default {
|
|
50
52
|
deep: true
|
51
53
|
}
|
52
54
|
},
|
53
|
-
methods:{
|
54
|
-
|
55
|
+
methods: {
|
56
|
+
handleWidgetAdd($event) {
|
55
57
|
const newIndex = $event.newIndex;
|
56
58
|
const oldIndex = $event.oldIndex;
|
59
|
+
const newComponent = JSON.parse(
|
60
|
+
JSON.stringify(this.widget.options.columns[newIndex])
|
61
|
+
);
|
57
62
|
const item = $event.item;
|
58
63
|
// 防止布局元素的嵌套拖拽
|
59
64
|
if (item.className.indexOf("no-put") >= 0) {
|
60
65
|
// 如果是列表中拖拽的元素需要还原到原来位置
|
61
66
|
item.tagName === "DIV" &&
|
62
|
-
this.widgetArray.
|
63
|
-
|
64
|
-
row.list.splice(newIndex, 1);
|
67
|
+
this.widgetArray.splice(oldIndex, 0, newComponent);
|
65
68
|
|
69
|
+
this.widget.options.columns.splice(newIndex, 1);
|
66
70
|
return false;
|
67
71
|
}
|
68
72
|
|
69
73
|
const key =
|
70
74
|
Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
options: {
|
75
|
-
...row.list[newIndex].options
|
76
|
-
// remoteFunc: "func_" + key
|
77
|
-
},
|
78
|
-
key,
|
79
|
-
// 绑定键值
|
80
|
-
model: row.list[newIndex].type + "_" + key,
|
81
|
-
rules: []
|
82
|
-
});
|
83
|
-
|
84
|
-
if (
|
85
|
-
row.list[newIndex].type === "radio" ||
|
86
|
-
row.list[newIndex].type === "checkbox" ||
|
87
|
-
row.list[newIndex].type === "select"
|
88
|
-
) {
|
89
|
-
this.$set(row.list, newIndex, {
|
90
|
-
...row.list[newIndex],
|
91
|
-
options: {
|
92
|
-
...row.list[newIndex].options,
|
93
|
-
options: row.list[newIndex].options.options.map(item => ({
|
94
|
-
...item
|
95
|
-
}))
|
96
|
-
}
|
97
|
-
});
|
75
|
+
if (!newComponent.model) {
|
76
|
+
newComponent.key = key;
|
77
|
+
newComponent.model = `${newComponent.type}_${key}`;
|
98
78
|
}
|
99
|
-
|
100
|
-
this.selectWidget =
|
101
|
-
}
|
79
|
+
this.$set(this.widget.options.columns, newIndex, newComponent);
|
80
|
+
this.selectWidget = newComponent;
|
81
|
+
}
|
102
82
|
}
|
103
83
|
};
|
104
84
|
</script>
|
@@ -0,0 +1,114 @@
|
|
1
|
+
<template>
|
2
|
+
<el-table
|
3
|
+
style="width:100%"
|
4
|
+
:data="dataModel"
|
5
|
+
:stripe="widget.options.stripe"
|
6
|
+
:show-header="widget.options.showHeader"
|
7
|
+
:highlight-current-row="widget.options.highlightCurrentRow"
|
8
|
+
:border="widget.options.border"
|
9
|
+
>
|
10
|
+
<el-table-column
|
11
|
+
v-if="widget.options.isSerial"
|
12
|
+
label="序号"
|
13
|
+
type="index"
|
14
|
+
width="50"
|
15
|
+
align="center"
|
16
|
+
>
|
17
|
+
</el-table-column>
|
18
|
+
<el-table-column
|
19
|
+
v-for="element in widget.options.columns"
|
20
|
+
:key="`table_${element.key}`"
|
21
|
+
:label="element.name"
|
22
|
+
:prop="element.model"
|
23
|
+
:width="element.options.width"
|
24
|
+
>
|
25
|
+
<template slot-scope="scope">
|
26
|
+
<generate-form-item
|
27
|
+
:models.sync="dataModel[scope.$index]"
|
28
|
+
:widget="element"
|
29
|
+
:remote="remote"
|
30
|
+
:config="config"
|
31
|
+
:prop="`${prop}.${scope.$index}.${element.model}`"
|
32
|
+
:slotKeys="slotKeys"
|
33
|
+
:componentsData="componentsData"
|
34
|
+
>
|
35
|
+
<template v-for="name in slotKeys" :slot="name">
|
36
|
+
<slot :name="name" />
|
37
|
+
</template>
|
38
|
+
</generate-form-item>
|
39
|
+
</template>
|
40
|
+
</el-table-column>
|
41
|
+
<el-table-column
|
42
|
+
v-if="widget.options.isDelete"
|
43
|
+
fixed="right"
|
44
|
+
label="操作"
|
45
|
+
width="60"
|
46
|
+
align="center"
|
47
|
+
>
|
48
|
+
<template slot-scope="scope">
|
49
|
+
<el-button
|
50
|
+
style="color:#F56C6C"
|
51
|
+
type="text"
|
52
|
+
@click.native.prevent="handleTableDelete(scope.$index)"
|
53
|
+
>
|
54
|
+
移除
|
55
|
+
</el-button>
|
56
|
+
</template>
|
57
|
+
</el-table-column>
|
58
|
+
<template v-if="widget.options.isAdd" slot="append">
|
59
|
+
<div
|
60
|
+
style="text-align: center;"
|
61
|
+
:style="{
|
62
|
+
borderTop:
|
63
|
+
dataModel && dataModel.length != 0 ? '' : '1px solid #EBEEF5'
|
64
|
+
}"
|
65
|
+
>
|
66
|
+
<el-button
|
67
|
+
type="text"
|
68
|
+
:disabled="widget.options.disabled"
|
69
|
+
@click="handleTableAdd"
|
70
|
+
>新增</el-button
|
71
|
+
>
|
72
|
+
</div>
|
73
|
+
</template>
|
74
|
+
</el-table>
|
75
|
+
</template>
|
76
|
+
|
77
|
+
<script>
|
78
|
+
import { itemsComponent } from "../mixins/index";
|
79
|
+
import GenerateFormItem from "../../GenerateFormItem.vue";
|
80
|
+
export default {
|
81
|
+
components: { GenerateFormItem },
|
82
|
+
mixins: [itemsComponent],
|
83
|
+
props: ["models", "remote", "prop", "slotKeys", "componentsData"],
|
84
|
+
data() {
|
85
|
+
return {};
|
86
|
+
},
|
87
|
+
|
88
|
+
methods: {
|
89
|
+
handleTableAdd() {
|
90
|
+
let dic = {};
|
91
|
+
this.widget.options.columns.forEach(item => {
|
92
|
+
if (item.type === "grid") {
|
93
|
+
for (let i = 0; i < item.options.columns.length; i++) {
|
94
|
+
const element = item.options.columns[i];
|
95
|
+
for (let j = 0; j < element.options.columns.length; j++) {
|
96
|
+
const element2 = element.options.columns[j];
|
97
|
+
dic[element2.model] = element2.options.defaultValue;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
} else {
|
101
|
+
dic[item.model] = item.options.defaultValue;
|
102
|
+
}
|
103
|
+
});
|
104
|
+
|
105
|
+
this.dataModel.push(dic);
|
106
|
+
},
|
107
|
+
handleTableDelete(index) {
|
108
|
+
this.dataModel.splice(index, 1);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
};
|
112
|
+
</script>
|
113
|
+
|
114
|
+
<style></style>
|