t20-common-lib 0.12.5 → 0.12.7
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
CHANGED
|
@@ -129,14 +129,27 @@
|
|
|
129
129
|
import Tree from "../../../src/common/selectTree/Tree/index.vue";
|
|
130
130
|
import ElSelect from "../../../src/common/selectTree/Extends/ElSelect.vue";
|
|
131
131
|
import Filters from "../../../src/common/selectTree/Filters/index.vue"
|
|
132
|
-
import
|
|
133
|
-
import request from "../../../src/utils/request";
|
|
134
|
-
import { getToken } from "../../../src/utils/auth";
|
|
132
|
+
import request from "@/utils/request";
|
|
135
133
|
import { getCommonConfig } from "../../../src/api/common";
|
|
136
134
|
import treeSelectImg from "../../../src/common/selectTree/imgs/tree-select.png";
|
|
137
135
|
import treeUnSelectImg from "../../../src/common/selectTree/imgs/tree-unselect.png";
|
|
138
136
|
import listSelectImg from "../../../src/common/selectTree/imgs/list-select.png";
|
|
139
137
|
import listUnSelectImg from "../../../src/common/selectTree/imgs/list-unselect.png";
|
|
138
|
+
|
|
139
|
+
/** 兼容接口返回体在 res 顶层或 res.data */
|
|
140
|
+
function unwrapRequestData(res) {
|
|
141
|
+
if (res == null || typeof res !== "object") return res;
|
|
142
|
+
if (Array.isArray(res)) return res;
|
|
143
|
+
const hasPayloadKeys =
|
|
144
|
+
Object.prototype.hasOwnProperty.call(res, "fundTreeVoList") ||
|
|
145
|
+
Object.prototype.hasOwnProperty.call(res, "records") ||
|
|
146
|
+
Object.prototype.hasOwnProperty.call(res, "onlyUnit") ||
|
|
147
|
+
Object.prototype.hasOwnProperty.call(res, "firstAuthUnit");
|
|
148
|
+
if (hasPayloadKeys) return res;
|
|
149
|
+
if (res.data != null && typeof res.data === "object") return res.data;
|
|
150
|
+
return res;
|
|
151
|
+
}
|
|
152
|
+
|
|
140
153
|
export default {
|
|
141
154
|
name: "SelectTreeUnit",
|
|
142
155
|
components: { ElSelect, Tree, Filters },
|
|
@@ -456,7 +469,7 @@ export default {
|
|
|
456
469
|
},
|
|
457
470
|
async getCommonConfig(resolve) {
|
|
458
471
|
let res = await getCommonConfig();
|
|
459
|
-
res = res
|
|
472
|
+
res = unwrapRequestData(res)
|
|
460
473
|
if (res && res.length > 0) {
|
|
461
474
|
res.forEach((r) => {
|
|
462
475
|
if (r.configGroupName.includes("单位树")) {
|
|
@@ -542,7 +555,7 @@ export default {
|
|
|
542
555
|
}
|
|
543
556
|
request({ url: this.url + str, method: "GET", cache:true, headers }).then((res) => {
|
|
544
557
|
this.loading = false;
|
|
545
|
-
res = res
|
|
558
|
+
res = unwrapRequestData(res)
|
|
546
559
|
let data = res.fundTreeVoList;
|
|
547
560
|
// if (code == 200) {
|
|
548
561
|
if (data && data.length > 0) {
|
|
@@ -1100,7 +1113,7 @@ export default {
|
|
|
1100
1113
|
data: params,
|
|
1101
1114
|
headers, cache:true,
|
|
1102
1115
|
}).then((res) => {
|
|
1103
|
-
res = res
|
|
1116
|
+
res = unwrapRequestData(res)
|
|
1104
1117
|
console.log(6666);
|
|
1105
1118
|
this.loading = false;
|
|
1106
1119
|
if (res.records && res.records.length > 0) {
|
|
@@ -110,12 +110,27 @@ import emitter from "element-ui/src/mixins/emitter";
|
|
|
110
110
|
import Tree from "../../../src/common/selectTree/Tree/index.vue";
|
|
111
111
|
import ElSelect from "../../../src/common/selectTree/Extends/ElSelect.vue";
|
|
112
112
|
import Filters from "../../../src/common/selectTree/Filters/index.vue"
|
|
113
|
-
import request from "
|
|
113
|
+
import request from "@/utils/request";
|
|
114
114
|
import { getCommonConfig } from "../../../src/api/common";
|
|
115
115
|
import treeSelectImg from "../../../src/common/selectTree/imgs/tree-select.png";
|
|
116
116
|
import treeUnSelectImg from "../../../src/common/selectTree/imgs/tree-unselect.png";
|
|
117
117
|
import listSelectImg from "../../../src/common/selectTree/imgs/list-select.png";
|
|
118
118
|
import listUnSelectImg from "../../../src/common/selectTree/imgs/list-unselect.png";
|
|
119
|
+
|
|
120
|
+
/** 兼容接口返回体在 res 顶层或 res.data */
|
|
121
|
+
function unwrapRequestData(res) {
|
|
122
|
+
if (res == null || typeof res !== "object") return res;
|
|
123
|
+
if (Array.isArray(res)) return res;
|
|
124
|
+
const hasPayloadKeys =
|
|
125
|
+
Object.prototype.hasOwnProperty.call(res, "fundTreeVoList") ||
|
|
126
|
+
Object.prototype.hasOwnProperty.call(res, "records") ||
|
|
127
|
+
Object.prototype.hasOwnProperty.call(res, "onlyUnit") ||
|
|
128
|
+
Object.prototype.hasOwnProperty.call(res, "firstAuthUnit");
|
|
129
|
+
if (hasPayloadKeys) return res;
|
|
130
|
+
if (res.data != null && typeof res.data === "object") return res.data;
|
|
131
|
+
return res;
|
|
132
|
+
}
|
|
133
|
+
|
|
119
134
|
export default {
|
|
120
135
|
name: "SelectTreeUnitForm",
|
|
121
136
|
components: { Tree, ElSelect, Filters },
|
|
@@ -361,7 +376,7 @@ export default {
|
|
|
361
376
|
},
|
|
362
377
|
async getCommonConfig(resolve) {
|
|
363
378
|
let res = await getCommonConfig();
|
|
364
|
-
res = res
|
|
379
|
+
res = unwrapRequestData(res)
|
|
365
380
|
if (res && res.length > 0) {
|
|
366
381
|
res.forEach((r) => {
|
|
367
382
|
if (r.configGroupName.includes("单位树")) {
|
|
@@ -498,7 +513,7 @@ export default {
|
|
|
498
513
|
cache: true,
|
|
499
514
|
headers,
|
|
500
515
|
}).then((res) => {
|
|
501
|
-
res = res
|
|
516
|
+
res = unwrapRequestData(res)
|
|
502
517
|
let data = res.fundTreeVoList;
|
|
503
518
|
this.loading = false;
|
|
504
519
|
if (data && data.length > 0) {
|
|
@@ -1018,7 +1033,7 @@ export default {
|
|
|
1018
1033
|
headers,
|
|
1019
1034
|
cache: true,
|
|
1020
1035
|
});
|
|
1021
|
-
res = res
|
|
1036
|
+
res = unwrapRequestData(res)
|
|
1022
1037
|
this.loading = false;
|
|
1023
1038
|
if (res.records && res.records.length > 0) {
|
|
1024
1039
|
res.records.forEach((r) => {
|