services.js
1.23 KB
1
2
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
import request from "../utils/request";
export function getService(token, url) {
try {
const options = {
method: "GET",
headers: {
"Content-Type": "application/json",
authorization: token
}
};
return request(url, options);
} catch (e) {
console.log(e.message);
return {};
}
}
export function postValueService(token, valueOld, url) {
let value = valueOld;
// 如果入参是个{}并且入参有sSqlCondition
if (
typeof valueOld === "object" &&
!Array.isArray(valueOld) &&
valueOld.sSqlCondition &&
typeof valueOld.sSqlCondition === "object"
) {
const { sSqlCondition } = valueOld;
const sSqlConditionNew = {};
Object.keys(sSqlCondition).forEach(item => {
if (sSqlCondition[item] === undefined) {
sSqlConditionNew[item] = "";
} else {
sSqlConditionNew[item] = sSqlCondition[item];
}
});
value.sSqlCondition = sSqlConditionNew;
}
try {
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
authorization: token
},
body: JSON.stringify(value)
};
return request(url, options);
} catch (e) {
console.log(e.message);
return {};
}
}