cloud-web-corejs 1.0.200 → 1.0.201
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/package.json +1 -1
- package/src/resources/js/base/common.js +109 -109
package/package.json
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
/**version-1.0*/
|
|
2
|
-
(function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
1
|
+
/**version-1.0*/
|
|
2
|
+
(function(w) {
|
|
3
|
+
w.commonDataUtil = {
|
|
4
|
+
toHump: function(name) {
|
|
5
|
+
return name.replace(/\_(\w)/g, function(all, letter) {
|
|
6
|
+
return letter.toUpperCase();
|
|
7
|
+
});
|
|
8
|
+
},
|
|
9
|
+
toLine: function(name) {
|
|
10
|
+
return name.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
11
|
+
},
|
|
12
|
+
toHumpKey: function(data) {
|
|
13
|
+
if (!data) return data;
|
|
14
|
+
var nMap = {};
|
|
15
|
+
for (const key in data) {
|
|
16
|
+
const value = data[key];
|
|
17
|
+
const nKey = commonDataUtil.toHump(key);
|
|
18
|
+
nMap[nKey] = value;
|
|
19
|
+
}
|
|
20
|
+
return nMap;
|
|
21
|
+
},
|
|
22
|
+
handleForm: function(data, option) {
|
|
23
|
+
let ignore_fields = ["_X_ROW_CHILD", "_X_ROW_KEY"];
|
|
24
|
+
let ignore_key = "_$ignore_field_";
|
|
25
|
+
let toDo = function(data) {
|
|
26
|
+
if (!Array.isArray(data) && Object.prototype.toString.call(data) !==
|
|
27
|
+
'[object Object]') {
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
let formData = JSON.parse(JSON.stringify(data || {}));
|
|
31
|
+
let newFormData = {};
|
|
32
|
+
let keys = Object.keys(formData);
|
|
33
|
+
for (let i = 0; i < keys.length; i++) {
|
|
34
|
+
let key = keys[i];
|
|
35
|
+
let value = formData[key];
|
|
36
|
+
if (ignore_fields.includes(key) || key.indexOf(ignore_key) == 0) {
|
|
37
|
+
delete formData[key];
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (option && option.ignore_fields && option.ignore_fields.includes(key)) {
|
|
41
|
+
delete formData[key];
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (value != null) {
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
value.forEach(function(item, index) {
|
|
47
|
+
if (Array.isArray(item) || Object.prototype.toString.call(
|
|
48
|
+
item) ===
|
|
49
|
+
'[object Object]') {
|
|
50
|
+
value[index] = toDo(item);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
formData[key] = value;
|
|
54
|
+
} else if (Object.prototype.toString.call(value) === '[object Object]') {
|
|
55
|
+
formData[key] = toDo(value);
|
|
56
|
+
} else {
|
|
57
|
+
if (key == 'id' && value.toString().indexOf('row_') == 0) {
|
|
58
|
+
formData[key] = '';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return formData;
|
|
64
|
+
}
|
|
65
|
+
return toDo(data);
|
|
66
|
+
},
|
|
67
|
+
handleForm2: function(data, field) {
|
|
68
|
+
const formData = {};
|
|
69
|
+
var tKey = field ? field + '.' : '';
|
|
70
|
+
for (const key in data) {
|
|
71
|
+
const rKey = tKey + commonDataUtil.toHump(key);
|
|
72
|
+
let value = data[key];
|
|
73
|
+
if (value != null) {
|
|
74
|
+
if (Array.isArray(value)) {
|
|
75
|
+
value.forEach(function(item, index) {
|
|
76
|
+
const mKey = rKey + '[' + index + ']';
|
|
77
|
+
Object.assign(formData, commonDataUtil.handleForm2(item, mKey));
|
|
78
|
+
});
|
|
79
|
+
} else if (Object.prototype.toString.call(value) === '[object Object]') {
|
|
80
|
+
Object.assign(formData, commonDataUtil.handleForm2(value, rKey));
|
|
81
|
+
} else {
|
|
82
|
+
if (key == 'id' && value.toString().indexOf('row_') == 0) {
|
|
83
|
+
value = '';
|
|
84
|
+
} else {
|
|
85
|
+
formData[rKey] = value;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return formData;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
w.$getVueByUid = function(uid) {
|
|
95
|
+
let loop = function(parent) {
|
|
96
|
+
if (parent._uid == uid) {
|
|
97
|
+
return parent;
|
|
98
|
+
} else {
|
|
99
|
+
let $children = parent.$children;
|
|
100
|
+
for (let i = 0; i < $children.length; i++) {
|
|
101
|
+
let tTarget = loop($children[i]);
|
|
102
|
+
if (tTarget) {
|
|
103
|
+
return tTarget;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return loop($vueRoot);
|
|
109
|
+
};
|
|
110
110
|
})(window);
|