t20-common-lib 0.12.6 → 0.12.8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "t20-common-lib",
3
- "version": "0.12.6",
3
+ "version": "0.12.8",
4
4
  "description": "T20",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -129,12 +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 request from "../../../src/utils/request";
132
+ import request from "@/utils/request";
133
133
  import { getCommonConfig } from "../../../src/api/common";
134
134
  import treeSelectImg from "../../../src/common/selectTree/imgs/tree-select.png";
135
135
  import treeUnSelectImg from "../../../src/common/selectTree/imgs/tree-unselect.png";
136
136
  import listSelectImg from "../../../src/common/selectTree/imgs/list-select.png";
137
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
+
138
153
  export default {
139
154
  name: "SelectTreeUnit",
140
155
  components: { ElSelect, Tree, Filters },
@@ -454,7 +469,7 @@ export default {
454
469
  },
455
470
  async getCommonConfig(resolve) {
456
471
  let res = await getCommonConfig();
457
- res = res.data
472
+ res = unwrapRequestData(res)
458
473
  if (res && res.length > 0) {
459
474
  res.forEach((r) => {
460
475
  if (r.configGroupName.includes("单位树")) {
@@ -540,7 +555,7 @@ export default {
540
555
  }
541
556
  request({ url: this.url + str, method: "GET", cache:true, headers }).then((res) => {
542
557
  this.loading = false;
543
- res = res.data
558
+ res = unwrapRequestData(res)
544
559
  let data = res.fundTreeVoList;
545
560
  // if (code == 200) {
546
561
  if (data && data.length > 0) {
@@ -1098,7 +1113,7 @@ export default {
1098
1113
  data: params,
1099
1114
  headers, cache:true,
1100
1115
  }).then((res) => {
1101
- res = res.data
1116
+ res = unwrapRequestData(res)
1102
1117
  console.log(6666);
1103
1118
  this.loading = false;
1104
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 "../../../src/utils/request";
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.data
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.data
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.data
1036
+ res = unwrapRequestData(res)
1022
1037
  this.loading = false;
1023
1038
  if (res.records && res.records.length > 0) {
1024
1039
  res.records.forEach((r) => {
package/src/api/common.js CHANGED
@@ -1,4 +1,4 @@
1
- // import request from '@/utils/request'
1
+ import request from '@/utils/request'
2
2
 
3
3
  // 单位本位币
4
4
  export function getUnitCurrency(unitNo) {