@bchr/bchr-front-lib 0.4.5 → 0.5.2
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/base/layout/ActionButton.js +705 -0
- package/lib/base/utils/Arrays.js +37 -0
- package/lib/base/utils/CNKits.js +227 -0
- package/lib/base/utils/CharReplaceUtils.js +111 -0
- package/lib/base/utils/DES24JS.js +58 -0
- package/lib/base/utils/DateTimes.js +163 -0
- package/lib/base/utils/FormDatas.js +109 -0
- package/lib/base/utils/LangTypes.js +173 -0
- package/lib/base/utils/Objects.js +60 -0
- package/lib/base/utils/Randoms.js +146 -0
- package/lib/base/utils/Strings.js +152 -0
- package/lib/base/utils/TreeDataUtils.js +165 -0
- package/lib/base/utils/Values.js +181 -0
- package/lib/base/utils/index.js +45 -0
- package/lib/services/http.js +486 -0
- package/lib/style/ExtCustomKendo.less +1063 -935
- package/package.json +5 -2
- package/src/base/layout/ActionButton.js +628 -0
- package/src/base/utils/Arrays.js +29 -0
- package/src/base/utils/CNKits.js +236 -0
- package/src/base/utils/CharReplaceUtils.js +99 -0
- package/src/base/utils/DES24JS.js +54 -0
- package/src/base/utils/DateTimes.js +136 -0
- package/src/base/utils/FormDatas.js +103 -0
- package/src/base/utils/LangTypes.js +202 -0
- package/src/base/utils/Objects.js +48 -0
- package/src/base/utils/Randoms.js +142 -0
- package/src/base/utils/Strings.js +146 -0
- package/src/base/utils/TreeDataUtils.js +128 -0
- package/src/base/utils/Values.js +196 -0
- package/src/base/utils/index.js +15 -0
- package/src/services/http.js +460 -0
- package/src/style/ExtCustomKendo.less +1063 -935
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
import lodash from "lodash";
|
|
3
|
+
import moment from "moment";
|
|
4
|
+
import Strings from "./Strings"
|
|
5
|
+
|
|
6
|
+
const Values = {
|
|
7
|
+
|
|
8
|
+
ifNull(rawValue, defaultValue) {
|
|
9
|
+
if (rawValue === null || rawValue === void 0) {
|
|
10
|
+
return defaultValue;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return rawValue;
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
ifEmpty(rawValue, defaultValue){
|
|
17
|
+
if (this.isEmpty(rawValue)) {
|
|
18
|
+
return defaultValue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return rawValue;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
isUndefined(value) {
|
|
25
|
+
return value === void 0;
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
isNull(value) {
|
|
29
|
+
return value === null || value === void 0;
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
isNotNull(value) {
|
|
33
|
+
return !(this.isNull(value));
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
isEmptyArray(value) {
|
|
37
|
+
return value === void 0 || value === null || (Array.isArray(value) && value.length === 0);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
isNotEmptyArray(value) {
|
|
41
|
+
return Array.isArray(value) && value.length > 0;
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
isEmpty(rawValue) {
|
|
45
|
+
if (rawValue === null || rawValue === void 0) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (lodash.isString(rawValue)) {
|
|
50
|
+
return this.isBlankString(rawValue);
|
|
51
|
+
}
|
|
52
|
+
else if (this.isEmptyArray(rawValue)) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
else if (lodash.isSet(rawValue)) {
|
|
56
|
+
return (rawValue.size === 0);
|
|
57
|
+
}
|
|
58
|
+
else if (lodash.isMap(rawValue)) {
|
|
59
|
+
return (rawValue.size === 0);
|
|
60
|
+
}
|
|
61
|
+
else if (lodash.isPlainObject(rawValue)) {
|
|
62
|
+
return (lodash.isEmpty(rawValue));
|
|
63
|
+
}
|
|
64
|
+
else if (lodash.isArrayLike(rawValue)) {
|
|
65
|
+
return rawValue.length === 0;
|
|
66
|
+
}
|
|
67
|
+
else if (lodash.isArrayBuffer(rawValue)) {
|
|
68
|
+
return rawValue.byteLength === 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return false;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
isNotEmpty(rawValue) {
|
|
75
|
+
return !this.isEmpty(rawValue);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
isBlankString(value) {
|
|
79
|
+
return Strings.isBlankString(value);
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
isNotBlankString(value) {
|
|
83
|
+
return Strings.isNotBlankString(value);
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
isPK(value) {
|
|
87
|
+
if (value === null || value === void 0) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (lodash.isString(value)) {
|
|
92
|
+
return this.isNotBlankString(value);
|
|
93
|
+
}
|
|
94
|
+
else if (lodash.isNumber(value)) {
|
|
95
|
+
return lodash.isInteger(value) && value > 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return false;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
isDateValue(value) {
|
|
102
|
+
if (value === null || value === void 0) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (lodash.isString(value)) {
|
|
107
|
+
let day = moment(value)
|
|
108
|
+
return day.isValid();
|
|
109
|
+
}
|
|
110
|
+
else if (lodash.isDate(value)) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
else if (lodash.isFunction(value.toDate) && lodash.isFunction(value.isValid)) {
|
|
114
|
+
return value.isValid();
|
|
115
|
+
}
|
|
116
|
+
else if (lodash.isPlainObject(value) && Object.prototype.hasOwnProperty.call(value, "value")) {
|
|
117
|
+
return this.isDateValue(value.value);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return false;
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
isInteger(value) {
|
|
124
|
+
if (value === null || value === void 0) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (lodash.isInteger(value)) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (lodash.isString(value)) {
|
|
133
|
+
let _value = value.replaceAll(",", "").replaceAll(' ', '');
|
|
134
|
+
try {
|
|
135
|
+
let decimalValue = new Decimal(_value);
|
|
136
|
+
return decimalValue.isInteger();
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return false;
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
isInteger2(value) {
|
|
147
|
+
if (value === null || value === void 0) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (lodash.isInteger(value)) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (lodash.isString(value)) {
|
|
156
|
+
try {
|
|
157
|
+
let decimalValue = new Decimal(value);
|
|
158
|
+
return decimalValue.isInteger();
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return false;
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
isNumber(value) {
|
|
169
|
+
if (value === null || value === void 0) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (isNaN(value)) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (lodash.isNumber(value)) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (lodash.isString(value)) {
|
|
182
|
+
let _value = value.replaceAll(",", "").replaceAll(' ', '');
|
|
183
|
+
try {
|
|
184
|
+
new Decimal(_value);
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
catch (e) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export default Values;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertFormValues2VOUsingVOFormat,
|
|
3
|
+
convertVO2FormValuesUsingFormValueFormat
|
|
4
|
+
}
|
|
5
|
+
from './FormDatas';
|
|
6
|
+
|
|
7
|
+
import Strings from "./Strings";
|
|
8
|
+
import Values from "./Values";
|
|
9
|
+
import DateTimes from "./DateTimes";
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
Strings, Values, DateTimes,
|
|
13
|
+
convertFormValues2VOUsingVOFormat,
|
|
14
|
+
convertVO2FormValuesUsingFormValueFormat,
|
|
15
|
+
}
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import lodash from "lodash";
|
|
2
|
+
import queryString from "query-string";
|
|
3
|
+
import { Values } from '../base/utils';
|
|
4
|
+
import { message } from 'antd';
|
|
5
|
+
|
|
6
|
+
const http = {
|
|
7
|
+
|
|
8
|
+
isUseDefaultExceptionHandler: function() {
|
|
9
|
+
return false;
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
getRequestContextPath: function(options) {
|
|
13
|
+
if (lodash.isString(options)) {
|
|
14
|
+
let requestURL = options;
|
|
15
|
+
if (requestURL.toLowerCase().startsWith("http")) {
|
|
16
|
+
return requestURL;
|
|
17
|
+
}
|
|
18
|
+
else if (requestURL.startsWith(AppConfig.BackServiceRpcPrefix)) {
|
|
19
|
+
// like "/d/module_code/function_let_code/method1
|
|
20
|
+
let requestContextPathParts = requestURL.split("/")
|
|
21
|
+
if (requestContextPathParts.length >= 4) {
|
|
22
|
+
return requestContextPathParts.slice(0, 4).join("/");
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return requestURL;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else if (requestURL.startsWith("/")) {
|
|
29
|
+
return requestURL;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let SERVICE_HOST_NAME = AppConfig.BackServiceHostAddress;
|
|
34
|
+
let SERVICE_CONTEXT_PATH = AppConfig.BackServiceContextPath;
|
|
35
|
+
let BACK_SERVICE_RPC_PREFIX = AppConfig.BackServiceRpcPrefix;
|
|
36
|
+
let ajaxBasePath = null;
|
|
37
|
+
if (lodash.isPlainObject(options)) {
|
|
38
|
+
ajaxBasePath = options.ajaxBasePath;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (Values.isBlankString(ajaxBasePath)) {
|
|
42
|
+
ajaxBasePath = this.requestContextPath;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (Values.isBlankString(ajaxBasePath)) {
|
|
46
|
+
let locationHash = window.location.hash;
|
|
47
|
+
if (!locationHash || locationHash === "#") {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
locationHash = locationHash.substring(1);
|
|
52
|
+
if (!locationHash) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let requestContextPathParts = locationHash.split('/')
|
|
57
|
+
if (requestContextPathParts.length >= 3) {
|
|
58
|
+
ajaxBasePath = requestContextPathParts.slice(0, 3).join("/");
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
ajaxBasePath = locationHash;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let requestContextPath = SERVICE_HOST_NAME + SERVICE_CONTEXT_PATH + BACK_SERVICE_RPC_PREFIX + ajaxBasePath;
|
|
66
|
+
|
|
67
|
+
if (!requestContextPath.endsWith("/")) {
|
|
68
|
+
requestContextPath = requestContextPath + "/"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return requestContextPath;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
getRequestPath: function(options) {
|
|
75
|
+
let rpcMethodName = null;
|
|
76
|
+
let ajaxOptions = {};
|
|
77
|
+
if (lodash.isPlainObject(options)) {
|
|
78
|
+
rpcMethodName = options.rpcMethodName;
|
|
79
|
+
ajaxOptions = {...options};
|
|
80
|
+
}
|
|
81
|
+
else if (lodash.isString(options)) {
|
|
82
|
+
let requestURL = options;
|
|
83
|
+
if (requestURL.toLowerCase().startsWith("http")) {
|
|
84
|
+
return requestURL;
|
|
85
|
+
}
|
|
86
|
+
else if (requestURL.toLowerCase().startsWith("/")) {
|
|
87
|
+
return requestURL;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
rpcMethodName = options;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw new Error("Invalid arguments value [" + options + "] for http#getRequestPath");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!rpcMethodName) {
|
|
98
|
+
rpcMethodName = "";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (ajaxOptions.url) {
|
|
102
|
+
return ajaxOptions.url
|
|
103
|
+
} else {
|
|
104
|
+
let requestContextPath = this.getRequestContextPath(options);
|
|
105
|
+
return requestContextPath + rpcMethodName;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
getFunctionLetUIPathFromLocationString: function(locationString) {
|
|
110
|
+
if (locationString == null || locationString === "") {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let index1 = locationString.indexOf("#");
|
|
115
|
+
if (index1 === -1) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let locationHash = locationString.substring(index1);
|
|
120
|
+
let index2 = locationHash.indexOf("?");
|
|
121
|
+
if (index2 === -1) {
|
|
122
|
+
return locationHash;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return locationHash.substring(0, index2);
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
getFunctionLetUIContextPathFromLocationString: function(locationString) {
|
|
129
|
+
let functionLetUIPath = this.getFunctionLetUIPathFromLocationString(locationString);
|
|
130
|
+
if (functionLetUIPath == null) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (functionLetUIPath.endsWith("/")) {
|
|
135
|
+
return functionLetUIPath;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let index1 = functionLetUIPath.lastIndexOf("/");
|
|
139
|
+
if (index1 == -1) {
|
|
140
|
+
return functionLetUIPath;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return functionLetUIPath.substring(0, index1 + 1);
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
getViewNameFromLocationHash: function() {
|
|
147
|
+
let currentHash = window.location.hash;
|
|
148
|
+
if (!currentHash) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let pureHashLocation = currentHash;
|
|
153
|
+
let p1 = pureHashLocation.indexOf("?");
|
|
154
|
+
if (p1 > 0) {
|
|
155
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (pureHashLocation.endsWith("/")) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let p2 = pureHashLocation.lastIndexOf("/");
|
|
163
|
+
if (p2 > 0) {
|
|
164
|
+
return pureHashLocation.substring(p2 + 1);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
return pureHashLocation.substring(1);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
getParameterValue: function (paramName) {
|
|
172
|
+
if (!paramName) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let hash = window.location.hash;
|
|
177
|
+
if (!hash) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let index = hash.indexOf("?");
|
|
182
|
+
if (index < 0) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
let search = hash.substring(index + 1);
|
|
187
|
+
|
|
188
|
+
let paramObject = queryString.parse(search);
|
|
189
|
+
|
|
190
|
+
if (!paramObject) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return paramObject[paramName];
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
getParameterObject: function (...paramNames) {
|
|
198
|
+
let hash = window.location.hash;
|
|
199
|
+
if (!hash) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
let index = hash.indexOf("?");
|
|
204
|
+
if (index < 0) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let search = hash.substring(index + 1);
|
|
209
|
+
|
|
210
|
+
let paramObject = queryString.parse(search);
|
|
211
|
+
|
|
212
|
+
if (!Array.isArray(paramNames)){
|
|
213
|
+
return paramObject;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let _paramObject = {};
|
|
217
|
+
for (let i = 0, len = paramNames.length; i < len; i++) {
|
|
218
|
+
let param = paramNames[i];
|
|
219
|
+
_paramObject[param] = paramObject[param];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return _paramObject;
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
encodeObject2ParameterString2: function(object) {
|
|
226
|
+
if (!lodash.isPlainObject(object)) {
|
|
227
|
+
return "";
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return "?" + queryString.stringify(object);
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
encodeObject2ParameterString: function (object) {
|
|
234
|
+
if (!lodash.isPlainObject(object)) {
|
|
235
|
+
return "";
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return queryString.stringify(object);
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
redirectToFunctionLet(functionLetRouterPath, parameterObject) {
|
|
242
|
+
this.redirectTo("#" + functionLetRouterPath, parameterObject)
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
redirectTo: function(targetLocation, parameterObject) {
|
|
246
|
+
if (targetLocation === null || targetLocation === void 0) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (Values.isBlankString(targetLocation)) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let location = targetLocation;
|
|
255
|
+
if (lodash.isPlainObject(parameterObject)) {
|
|
256
|
+
location = location + this.encodeObject2ParameterString2(parameterObject)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
let lowerCaseLocation = location.toLowerCase();
|
|
260
|
+
if (lowerCaseLocation.startsWith("http://") || lowerCaseLocation.startsWith("https://") || lowerCaseLocation.startsWith("/")) {
|
|
261
|
+
window.location = location;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (location.startsWith("#")) {
|
|
265
|
+
window.location.hash = location
|
|
266
|
+
}
|
|
267
|
+
else if (location.startsWith("./")) {
|
|
268
|
+
let currentHash = window.location.hash;
|
|
269
|
+
if (!currentHash) {
|
|
270
|
+
window.location = location;
|
|
271
|
+
}
|
|
272
|
+
else if (currentHash === "#/") {
|
|
273
|
+
window.location.hash = "#" + location.substring(1);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
let pureHashLocation = currentHash;
|
|
277
|
+
let p1 = pureHashLocation.indexOf("?");
|
|
278
|
+
if (p1 > 0) {
|
|
279
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
let p2 = pureHashLocation.lastIndexOf("/");
|
|
283
|
+
if (p2 > 0) {
|
|
284
|
+
window.location.hash = pureHashLocation.substring(0, p2 + 1) + location.substring(2);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
window.location.hash = "#" + location.substring(1);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else if (location.indexOf("../") >= 0) {
|
|
292
|
+
let currentHash = window.location.hash;
|
|
293
|
+
if (!currentHash) {
|
|
294
|
+
window.location = location;
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
message.error("Not support the location pattern:" + location);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
let currentHash = window.location.hash;
|
|
302
|
+
if (!currentHash) {
|
|
303
|
+
window.location = location;
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
let pureHashLocation = currentHash;
|
|
307
|
+
let p1 = pureHashLocation.indexOf("?");
|
|
308
|
+
if (p1 > 0) {
|
|
309
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
let p2 = pureHashLocation.lastIndexOf("/");
|
|
313
|
+
if (p2 > 0) {
|
|
314
|
+
window.location.hash = pureHashLocation.substring(0, p2 + 1) + location;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
window.location.hash = "#/" + location;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
goBack: function() {
|
|
324
|
+
let currentHash = window.location.hash;
|
|
325
|
+
if (currentHash == null || currentHash.length == 0 || currentHash == "#/" || currentHash == "#") {
|
|
326
|
+
window.history.go(-1);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
let pureHashLocation = currentHash;
|
|
331
|
+
let p1 = pureHashLocation.indexOf("?");
|
|
332
|
+
if (p1 > 0) {
|
|
333
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
let p2 = pureHashLocation.lastIndexOf("/");
|
|
337
|
+
let hash = "";
|
|
338
|
+
if (p2 > 0) {
|
|
339
|
+
window.location.hash = pureHashLocation.substring(0, p2 + 1);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
window.history.go(-1);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
|
|
348
|
+
getFullURL: function(targetLocation, parameterObject) {
|
|
349
|
+
if (targetLocation === null || targetLocation === void 0) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (Values.isBlankString(targetLocation)) {
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
let location = targetLocation;
|
|
358
|
+
if (lodash.isPlainObject(parameterObject)) {
|
|
359
|
+
location = location + this.encodeObject2ParameterString2(parameterObject)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
let lowerCaseLocation = location.toLowerCase();
|
|
363
|
+
if (lowerCaseLocation.startsWith("http://") || lowerCaseLocation.startsWith("https://") || lowerCaseLocation.startsWith("/")) {
|
|
364
|
+
return location;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (location.startsWith("#")) {
|
|
368
|
+
return window.location.origin + window.location.pathname + location;
|
|
369
|
+
}
|
|
370
|
+
else if (location.startsWith("./")) {
|
|
371
|
+
let currentHash = window.location.hash;
|
|
372
|
+
if (Values.isBlankString(currentHash)) {
|
|
373
|
+
let currentPathname = window.location.pathname;
|
|
374
|
+
let idx = currentHash.lastIndexOf("/")
|
|
375
|
+
if (idx >= 0) {
|
|
376
|
+
return window.location.origin + currentPathname.substring(0, idx + 1) + location.substring(2);
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
return window.location.origin + location.substring(1);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
else if (currentHash === "#/") {
|
|
383
|
+
return window.location.origin + window.location.pathname + "#" + location.substring(1);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
let pureHashLocation = currentHash;
|
|
387
|
+
let p1 = pureHashLocation.indexOf("?");
|
|
388
|
+
if (p1 > 0) {
|
|
389
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
let p2 = pureHashLocation.lastIndexOf("/");
|
|
393
|
+
let hash = "";
|
|
394
|
+
if (p2 > 0) {
|
|
395
|
+
hash = pureHashLocation.substring(0, p2 + 1) + location.substring(2);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
hash = "#" + location.substring(1);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
return window.location.origin + window.location.pathname + hash;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
let currentHash = window.location.hash;
|
|
406
|
+
if (Values.isBlankString(currentHash)) {
|
|
407
|
+
let currentPathname = window.location.pathname;
|
|
408
|
+
let idx = currentHash.lastIndexOf("/")
|
|
409
|
+
if (idx >= 0) {
|
|
410
|
+
return window.location.origin + currentPathname.substring(0, idx + 1) + location;
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
return window.location.origin + "/" + location;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
let pureHashLocation = currentHash;
|
|
418
|
+
let p1 = pureHashLocation.indexOf("?");
|
|
419
|
+
if (p1 > 0) {
|
|
420
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
let p2 = pureHashLocation.lastIndexOf("/");
|
|
424
|
+
let hash = "";
|
|
425
|
+
if (p2 > 0) {
|
|
426
|
+
hash = pureHashLocation.substring(0, p2 + 1) + location;
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
hash = "#/" + location;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return window.location.origin + window.location.pathname + hash;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
isInView: function(viewName) {
|
|
438
|
+
if (!lodash.isString(viewName)) {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
let currentView = this.getViewNameFromLocationHash();
|
|
443
|
+
if (!currentView) {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return viewName.toLowerCase() === currentView.toLowerCase();
|
|
448
|
+
},
|
|
449
|
+
|
|
450
|
+
switchMainView: (parameterObject) => {
|
|
451
|
+
if (this.isInView("main_view")) {
|
|
452
|
+
this.redirectTo("main_view2", parameterObject)
|
|
453
|
+
}
|
|
454
|
+
else if (this.isInView("main_view2")) {
|
|
455
|
+
this.redirectTo("main_view", parameterObject)
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export default http;
|