tianheng-ui 0.1.82 → 0.1.84
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +72 -72
- package/lib/theme-chalk/fonts/formMaking-iconfont.svg +155 -155
- package/lib/theme-chalk/fonts/th-iconfont.css +2402 -2402
- package/lib/theme-chalk/js/axios.js +87 -87
- package/lib/tianheng-ui.js +4 -4
- package/package.json +87 -86
- package/packages/FormMaking/GenerateForm.vue +392 -392
- package/packages/FormMaking/Upload/index.vue +571 -571
- package/packages/FormMaking/WidgetForm.vue +145 -145
- package/packages/FormMaking/custom/register.js +43 -43
- package/packages/FormMaking/iconfont/demo.css +539 -539
- package/packages/FormMaking/iconfont/demo_index.html +1159 -1159
- package/packages/FormMaking/iconfont/formMaking-iconfont.css +189 -189
- package/packages/FormMaking/iconfont/formMaking-iconfont.svg +155 -155
- package/packages/FormMaking/index.js +33 -33
- package/packages/FormMaking/lang/en-US.js +187 -187
- package/packages/FormMaking/lang/zh-CN.js +187 -187
- package/packages/FormMaking/network/axios.js +88 -88
- package/packages/FormMaking/styles/index.scss +216 -216
- package/packages/FormMaking/util/index.js +98 -98
- package/packages/TableMaking/network/axios.js +88 -88
@@ -1,216 +1,216 @@
|
|
1
|
-
@import "../../../lib/theme-chalk/styles/variable.scss";
|
2
|
-
|
3
|
-
.th-formMaking {
|
4
|
-
// 组件拖拽区的操作样式
|
5
|
-
.widget-actions {
|
6
|
-
.actions {
|
7
|
-
position: absolute;
|
8
|
-
right: -2px;
|
9
|
-
bottom: -2px;
|
10
|
-
display: flex;
|
11
|
-
z-index: 9;
|
12
|
-
|
13
|
-
> div {
|
14
|
-
display: inline-block;
|
15
|
-
width: 20px;
|
16
|
-
height: 20px;
|
17
|
-
line-height: 20px;
|
18
|
-
text-align: center;
|
19
|
-
background: $color-parimary-active;
|
20
|
-
}
|
21
|
-
i {
|
22
|
-
font-size: 12px;
|
23
|
-
color: #fff;
|
24
|
-
cursor: pointer;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
.drag {
|
29
|
-
position: absolute;
|
30
|
-
left: -2px;
|
31
|
-
bottom: -2px;
|
32
|
-
width: 20px;
|
33
|
-
height: 20px;
|
34
|
-
line-height: 20px;
|
35
|
-
text-align: center;
|
36
|
-
background: $color-parimary-active;
|
37
|
-
z-index: 9;
|
38
|
-
|
39
|
-
i {
|
40
|
-
font-size: 14px;
|
41
|
-
color: #fff;
|
42
|
-
cursor: move;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
&.widget-actions-col {
|
47
|
-
.clone {
|
48
|
-
background: $color-warning-active !important;
|
49
|
-
}
|
50
|
-
.trash {
|
51
|
-
background: $color-warning-active !important;
|
52
|
-
}
|
53
|
-
.drag {
|
54
|
-
background: $color-warning-active !important;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
// draggable 拖拽时的占位样式
|
60
|
-
.draggable-ghost {
|
61
|
-
padding: 0px;
|
62
|
-
height: 52px;
|
63
|
-
font-size: 0;
|
64
|
-
background-color: $color-danger-hover;
|
65
|
-
box-sizing: border-box;
|
66
|
-
overflow: hidden;
|
67
|
-
content: "";
|
68
|
-
// 隐藏内容
|
69
|
-
i {
|
70
|
-
display: none;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
// draggable 拖拽列表样式
|
75
|
-
.draggable-list {
|
76
|
-
min-height: 52px;
|
77
|
-
background-color: #fff;
|
78
|
-
border: 1px dashed rgba(170, 170, 170, 0.7);
|
79
|
-
}
|
80
|
-
|
81
|
-
.widgetForm {
|
82
|
-
.isHideFormLabel {
|
83
|
-
.el-form-item__label {
|
84
|
-
display: none;
|
85
|
-
}
|
86
|
-
.el-form-item__content {
|
87
|
-
margin-left: 0 !important;
|
88
|
-
}
|
89
|
-
}
|
90
|
-
|
91
|
-
.widgetFormItem {
|
92
|
-
margin: 2px;
|
93
|
-
padding-bottom: 18px;
|
94
|
-
min-width: 120px;
|
95
|
-
position: relative;
|
96
|
-
background-color: rgba($color-parimary-lighter, 0.3);
|
97
|
-
border: 1px dashed rgba(170, 170, 170, 0.7);
|
98
|
-
|
99
|
-
// 解决复制、删除、移动按钮的位置问题
|
100
|
-
.el-form-item__content {
|
101
|
-
position: unset;
|
102
|
-
}
|
103
|
-
|
104
|
-
&.isActive {
|
105
|
-
outline: 2px solid $color-parimary-active;
|
106
|
-
border: 1px solid $color-parimary-active;
|
107
|
-
}
|
108
|
-
|
109
|
-
&.isLayout {
|
110
|
-
padding-bottom: 0;
|
111
|
-
padding: 5px;
|
112
|
-
margin-left: 2px !important;
|
113
|
-
margin-right: 2px !important;
|
114
|
-
background-color: rgba($color-warning-lighter, 0.3);
|
115
|
-
|
116
|
-
&.isActive {
|
117
|
-
outline: 2px solid $color-warning-active !important;
|
118
|
-
border: 1px solid $color-warning-active !important;
|
119
|
-
}
|
120
|
-
|
121
|
-
&:hover {
|
122
|
-
background-color: $color-warning-lighter;
|
123
|
-
outline: 1px solid $color-warning-active;
|
124
|
-
outline-offset: 0px;
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
&:hover {
|
129
|
-
background-color: $color-parimary-lighter;
|
130
|
-
outline: 1px solid $color-parimary-active;
|
131
|
-
outline-offset: 0px;
|
132
|
-
|
133
|
-
&.isActive {
|
134
|
-
outline: 2px solid $color-parimary-active;
|
135
|
-
border: 1px solid $color-parimary-active;
|
136
|
-
outline-offset: 0;
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
// 组件config配置视图样式
|
143
|
-
.component-config {
|
144
|
-
.config-header {
|
145
|
-
display: flex;
|
146
|
-
align-items: center;
|
147
|
-
justify-content: space-between;
|
148
|
-
|
149
|
-
.title {
|
150
|
-
}
|
151
|
-
|
152
|
-
.value {
|
153
|
-
color: $color-parimary;
|
154
|
-
cursor: pointer;
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
.eventsCollapse {
|
159
|
-
border: 1px solid #ebeef5;
|
160
|
-
border-bottom-color: #e1e1e1;
|
161
|
-
|
162
|
-
&-item {
|
163
|
-
display: flex;
|
164
|
-
align-items: center;
|
165
|
-
|
166
|
-
.el-select {
|
167
|
-
flex: 1;
|
168
|
-
margin-right: 5px;
|
169
|
-
}
|
170
|
-
|
171
|
-
> i {
|
172
|
-
padding: 5px;
|
173
|
-
cursor: pointer;
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
.el-collapse-item__header {
|
178
|
-
padding: 5px;
|
179
|
-
height: 30px;
|
180
|
-
line-height: 30px;
|
181
|
-
font-size: 12px;
|
182
|
-
background: #f5f7fa;
|
183
|
-
}
|
184
|
-
|
185
|
-
.el-collapse-item__content {
|
186
|
-
padding: 5px;
|
187
|
-
}
|
188
|
-
}
|
189
|
-
|
190
|
-
.el-form-item__label {
|
191
|
-
width: 100%;
|
192
|
-
}
|
193
|
-
|
194
|
-
.flexView {
|
195
|
-
display: flex;
|
196
|
-
margin-bottom: 5px;
|
197
|
-
}
|
198
|
-
}
|
199
|
-
}
|
200
|
-
|
201
|
-
// 组件内联样式
|
202
|
-
.component-table {
|
203
|
-
.el-form-item__label {
|
204
|
-
float: none !important;
|
205
|
-
}
|
206
|
-
.el-form-item__content {
|
207
|
-
margin-left: 0 !important;
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
// 组件头部标题统一样式
|
212
|
-
.component-header_title {
|
213
|
-
margin-bottom: 5px;
|
214
|
-
font-size: 16px;
|
215
|
-
font-weight: bold;
|
216
|
-
}
|
1
|
+
@import "../../../lib/theme-chalk/styles/variable.scss";
|
2
|
+
|
3
|
+
.th-formMaking {
|
4
|
+
// 组件拖拽区的操作样式
|
5
|
+
.widget-actions {
|
6
|
+
.actions {
|
7
|
+
position: absolute;
|
8
|
+
right: -2px;
|
9
|
+
bottom: -2px;
|
10
|
+
display: flex;
|
11
|
+
z-index: 9;
|
12
|
+
|
13
|
+
> div {
|
14
|
+
display: inline-block;
|
15
|
+
width: 20px;
|
16
|
+
height: 20px;
|
17
|
+
line-height: 20px;
|
18
|
+
text-align: center;
|
19
|
+
background: $color-parimary-active;
|
20
|
+
}
|
21
|
+
i {
|
22
|
+
font-size: 12px;
|
23
|
+
color: #fff;
|
24
|
+
cursor: pointer;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
.drag {
|
29
|
+
position: absolute;
|
30
|
+
left: -2px;
|
31
|
+
bottom: -2px;
|
32
|
+
width: 20px;
|
33
|
+
height: 20px;
|
34
|
+
line-height: 20px;
|
35
|
+
text-align: center;
|
36
|
+
background: $color-parimary-active;
|
37
|
+
z-index: 9;
|
38
|
+
|
39
|
+
i {
|
40
|
+
font-size: 14px;
|
41
|
+
color: #fff;
|
42
|
+
cursor: move;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
&.widget-actions-col {
|
47
|
+
.clone {
|
48
|
+
background: $color-warning-active !important;
|
49
|
+
}
|
50
|
+
.trash {
|
51
|
+
background: $color-warning-active !important;
|
52
|
+
}
|
53
|
+
.drag {
|
54
|
+
background: $color-warning-active !important;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
// draggable 拖拽时的占位样式
|
60
|
+
.draggable-ghost {
|
61
|
+
padding: 0px;
|
62
|
+
height: 52px;
|
63
|
+
font-size: 0;
|
64
|
+
background-color: $color-danger-hover;
|
65
|
+
box-sizing: border-box;
|
66
|
+
overflow: hidden;
|
67
|
+
content: "";
|
68
|
+
// 隐藏内容
|
69
|
+
i {
|
70
|
+
display: none;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
// draggable 拖拽列表样式
|
75
|
+
.draggable-list {
|
76
|
+
min-height: 52px;
|
77
|
+
background-color: #fff;
|
78
|
+
border: 1px dashed rgba(170, 170, 170, 0.7);
|
79
|
+
}
|
80
|
+
|
81
|
+
.widgetForm {
|
82
|
+
.isHideFormLabel {
|
83
|
+
.el-form-item__label {
|
84
|
+
display: none;
|
85
|
+
}
|
86
|
+
.el-form-item__content {
|
87
|
+
margin-left: 0 !important;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
.widgetFormItem {
|
92
|
+
margin: 2px;
|
93
|
+
padding-bottom: 18px;
|
94
|
+
min-width: 120px;
|
95
|
+
position: relative;
|
96
|
+
background-color: rgba($color-parimary-lighter, 0.3);
|
97
|
+
border: 1px dashed rgba(170, 170, 170, 0.7);
|
98
|
+
|
99
|
+
// 解决复制、删除、移动按钮的位置问题
|
100
|
+
.el-form-item__content {
|
101
|
+
position: unset;
|
102
|
+
}
|
103
|
+
|
104
|
+
&.isActive {
|
105
|
+
outline: 2px solid $color-parimary-active;
|
106
|
+
border: 1px solid $color-parimary-active;
|
107
|
+
}
|
108
|
+
|
109
|
+
&.isLayout {
|
110
|
+
padding-bottom: 0;
|
111
|
+
padding: 5px;
|
112
|
+
margin-left: 2px !important;
|
113
|
+
margin-right: 2px !important;
|
114
|
+
background-color: rgba($color-warning-lighter, 0.3);
|
115
|
+
|
116
|
+
&.isActive {
|
117
|
+
outline: 2px solid $color-warning-active !important;
|
118
|
+
border: 1px solid $color-warning-active !important;
|
119
|
+
}
|
120
|
+
|
121
|
+
&:hover {
|
122
|
+
background-color: $color-warning-lighter;
|
123
|
+
outline: 1px solid $color-warning-active;
|
124
|
+
outline-offset: 0px;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
&:hover {
|
129
|
+
background-color: $color-parimary-lighter;
|
130
|
+
outline: 1px solid $color-parimary-active;
|
131
|
+
outline-offset: 0px;
|
132
|
+
|
133
|
+
&.isActive {
|
134
|
+
outline: 2px solid $color-parimary-active;
|
135
|
+
border: 1px solid $color-parimary-active;
|
136
|
+
outline-offset: 0;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
// 组件config配置视图样式
|
143
|
+
.component-config {
|
144
|
+
.config-header {
|
145
|
+
display: flex;
|
146
|
+
align-items: center;
|
147
|
+
justify-content: space-between;
|
148
|
+
|
149
|
+
.title {
|
150
|
+
}
|
151
|
+
|
152
|
+
.value {
|
153
|
+
color: $color-parimary;
|
154
|
+
cursor: pointer;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
.eventsCollapse {
|
159
|
+
border: 1px solid #ebeef5;
|
160
|
+
border-bottom-color: #e1e1e1;
|
161
|
+
|
162
|
+
&-item {
|
163
|
+
display: flex;
|
164
|
+
align-items: center;
|
165
|
+
|
166
|
+
.el-select {
|
167
|
+
flex: 1;
|
168
|
+
margin-right: 5px;
|
169
|
+
}
|
170
|
+
|
171
|
+
> i {
|
172
|
+
padding: 5px;
|
173
|
+
cursor: pointer;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
.el-collapse-item__header {
|
178
|
+
padding: 5px;
|
179
|
+
height: 30px;
|
180
|
+
line-height: 30px;
|
181
|
+
font-size: 12px;
|
182
|
+
background: #f5f7fa;
|
183
|
+
}
|
184
|
+
|
185
|
+
.el-collapse-item__content {
|
186
|
+
padding: 5px;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
.el-form-item__label {
|
191
|
+
width: 100%;
|
192
|
+
}
|
193
|
+
|
194
|
+
.flexView {
|
195
|
+
display: flex;
|
196
|
+
margin-bottom: 5px;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
// 组件内联样式
|
202
|
+
.component-table {
|
203
|
+
.el-form-item__label {
|
204
|
+
float: none !important;
|
205
|
+
}
|
206
|
+
.el-form-item__content {
|
207
|
+
margin-left: 0 !important;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
// 组件头部标题统一样式
|
212
|
+
.component-header_title {
|
213
|
+
margin-bottom: 5px;
|
214
|
+
font-size: 16px;
|
215
|
+
font-weight: bold;
|
216
|
+
}
|
@@ -1,98 +1,98 @@
|
|
1
|
-
export const loadJs = url => {
|
2
|
-
return new Promise((resolve, reject) => {
|
3
|
-
const script = document.createElement("script");
|
4
|
-
script.src = url;
|
5
|
-
script.type = "text/javascript";
|
6
|
-
document.body.appendChild(script);
|
7
|
-
script.onload = () => {
|
8
|
-
resolve();
|
9
|
-
};
|
10
|
-
});
|
11
|
-
};
|
12
|
-
|
13
|
-
export const loadCss = url => {
|
14
|
-
return new Promise((resolve, reject) => {
|
15
|
-
const link = document.createElement("link");
|
16
|
-
link.rel = "stylesheet";
|
17
|
-
link.href = url;
|
18
|
-
document.head.appendChild(link);
|
19
|
-
link.onload = () => {
|
20
|
-
resolve();
|
21
|
-
};
|
22
|
-
});
|
23
|
-
};
|
24
|
-
|
25
|
-
export const generateUUID = () => {
|
26
|
-
var d = new Date().getTime();
|
27
|
-
var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
28
|
-
c
|
29
|
-
) {
|
30
|
-
var r = (d + Math.random() * 16) % 16 | 0;
|
31
|
-
d = Math.floor(d / 16);
|
32
|
-
return (c == "x" ? r : (r & 0x7) | 0x8).toString(16);
|
33
|
-
});
|
34
|
-
return uuid;
|
35
|
-
};
|
36
|
-
|
37
|
-
export const inputTypeDict = val => {
|
38
|
-
const dict = {
|
39
|
-
email: "email",
|
40
|
-
url: "url"
|
41
|
-
};
|
42
|
-
return dict[val] || "text";
|
43
|
-
};
|
44
|
-
|
45
|
-
export const deepClone = (obj, clone) => {
|
46
|
-
//判断拷贝的要进行深拷贝的是数组还是对象,是数组的话进行数组拷贝,对象的话进行对象拷贝
|
47
|
-
const toString = Object.prototype.toString;
|
48
|
-
toString.call(obj) === "[object Array]"
|
49
|
-
? (clone = clone || [])
|
50
|
-
: (clone = clone || {});
|
51
|
-
for (const i in obj) {
|
52
|
-
if (typeof obj[i] === "object" && obj[i] !== null) {
|
53
|
-
// 要考虑深复制问题了
|
54
|
-
if (Array.isArray(obj[i])) {
|
55
|
-
// 这是数组
|
56
|
-
clone[i] = [];
|
57
|
-
} else {
|
58
|
-
// 这是对象
|
59
|
-
clone[i] = {};
|
60
|
-
}
|
61
|
-
deepClone(obj[i], clone[i]);
|
62
|
-
} else {
|
63
|
-
clone[i] = obj[i];
|
64
|
-
}
|
65
|
-
}
|
66
|
-
return clone;
|
67
|
-
};
|
68
|
-
|
69
|
-
// 链式读取对象属性
|
70
|
-
export const getProperty = (obj = {}, str = "") => {
|
71
|
-
let dic = deepClone(obj);
|
72
|
-
const props = str.replace(/\[(\w+)\]/g, ".$1"); // 处理数组下标
|
73
|
-
const keys = props.split(".");
|
74
|
-
for (const key of keys) {
|
75
|
-
dic = dic[key] || "";
|
76
|
-
}
|
77
|
-
return dic;
|
78
|
-
};
|
79
|
-
|
80
|
-
// 链式设置对象属性
|
81
|
-
export const setProperty = (obj = {}, str = "", value = "", isClone) => {
|
82
|
-
let dic = isClone ? deepClone(obj) : obj;
|
83
|
-
let propValue = "";
|
84
|
-
const props = str.replace(/\[(\w+)\]/g, ".$1"); // 处理数组下标
|
85
|
-
const keys = props.split(".");
|
86
|
-
for (let i = 0; i < keys.length; i++) {
|
87
|
-
const key = keys[i];
|
88
|
-
if (keys.length === 1) {
|
89
|
-
dic[key] = value;
|
90
|
-
} else if (i === keys.length - 1) {
|
91
|
-
propValue[key] = value;
|
92
|
-
} else {
|
93
|
-
if (!dic[key]) dic[key] = {};
|
94
|
-
propValue = dic[key];
|
95
|
-
}
|
96
|
-
}
|
97
|
-
return dic;
|
98
|
-
};
|
1
|
+
export const loadJs = url => {
|
2
|
+
return new Promise((resolve, reject) => {
|
3
|
+
const script = document.createElement("script");
|
4
|
+
script.src = url;
|
5
|
+
script.type = "text/javascript";
|
6
|
+
document.body.appendChild(script);
|
7
|
+
script.onload = () => {
|
8
|
+
resolve();
|
9
|
+
};
|
10
|
+
});
|
11
|
+
};
|
12
|
+
|
13
|
+
export const loadCss = url => {
|
14
|
+
return new Promise((resolve, reject) => {
|
15
|
+
const link = document.createElement("link");
|
16
|
+
link.rel = "stylesheet";
|
17
|
+
link.href = url;
|
18
|
+
document.head.appendChild(link);
|
19
|
+
link.onload = () => {
|
20
|
+
resolve();
|
21
|
+
};
|
22
|
+
});
|
23
|
+
};
|
24
|
+
|
25
|
+
export const generateUUID = () => {
|
26
|
+
var d = new Date().getTime();
|
27
|
+
var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
28
|
+
c
|
29
|
+
) {
|
30
|
+
var r = (d + Math.random() * 16) % 16 | 0;
|
31
|
+
d = Math.floor(d / 16);
|
32
|
+
return (c == "x" ? r : (r & 0x7) | 0x8).toString(16);
|
33
|
+
});
|
34
|
+
return uuid;
|
35
|
+
};
|
36
|
+
|
37
|
+
export const inputTypeDict = val => {
|
38
|
+
const dict = {
|
39
|
+
email: "email",
|
40
|
+
url: "url"
|
41
|
+
};
|
42
|
+
return dict[val] || "text";
|
43
|
+
};
|
44
|
+
|
45
|
+
export const deepClone = (obj, clone) => {
|
46
|
+
//判断拷贝的要进行深拷贝的是数组还是对象,是数组的话进行数组拷贝,对象的话进行对象拷贝
|
47
|
+
const toString = Object.prototype.toString;
|
48
|
+
toString.call(obj) === "[object Array]"
|
49
|
+
? (clone = clone || [])
|
50
|
+
: (clone = clone || {});
|
51
|
+
for (const i in obj) {
|
52
|
+
if (typeof obj[i] === "object" && obj[i] !== null) {
|
53
|
+
// 要考虑深复制问题了
|
54
|
+
if (Array.isArray(obj[i])) {
|
55
|
+
// 这是数组
|
56
|
+
clone[i] = [];
|
57
|
+
} else {
|
58
|
+
// 这是对象
|
59
|
+
clone[i] = {};
|
60
|
+
}
|
61
|
+
deepClone(obj[i], clone[i]);
|
62
|
+
} else {
|
63
|
+
clone[i] = obj[i];
|
64
|
+
}
|
65
|
+
}
|
66
|
+
return clone;
|
67
|
+
};
|
68
|
+
|
69
|
+
// 链式读取对象属性
|
70
|
+
export const getProperty = (obj = {}, str = "") => {
|
71
|
+
let dic = deepClone(obj);
|
72
|
+
const props = str.replace(/\[(\w+)\]/g, ".$1"); // 处理数组下标
|
73
|
+
const keys = props.split(".");
|
74
|
+
for (const key of keys) {
|
75
|
+
dic = dic[key] || "";
|
76
|
+
}
|
77
|
+
return dic;
|
78
|
+
};
|
79
|
+
|
80
|
+
// 链式设置对象属性
|
81
|
+
export const setProperty = (obj = {}, str = "", value = "", isClone) => {
|
82
|
+
let dic = isClone ? deepClone(obj) : obj;
|
83
|
+
let propValue = "";
|
84
|
+
const props = str.replace(/\[(\w+)\]/g, ".$1"); // 处理数组下标
|
85
|
+
const keys = props.split(".");
|
86
|
+
for (let i = 0; i < keys.length; i++) {
|
87
|
+
const key = keys[i];
|
88
|
+
if (keys.length === 1) {
|
89
|
+
dic[key] = value;
|
90
|
+
} else if (i === keys.length - 1) {
|
91
|
+
propValue[key] = value;
|
92
|
+
} else {
|
93
|
+
if (!dic[key]) dic[key] = {};
|
94
|
+
propValue = dic[key];
|
95
|
+
}
|
96
|
+
}
|
97
|
+
return dic;
|
98
|
+
};
|