|
|
@@ -80,10 +80,17 @@ export function controlResultInfo(fn: Promise<any>, msgInfo: [string, string] =
|
|
|
*/
|
|
|
export function controlResultErrInfo(fn: Promise<any>) {
|
|
|
return fn.then(res => {
|
|
|
- // 列表数据需要一个key,要不然会报错,统一处理
|
|
|
- const result = res.map((e: any, i: number) => {
|
|
|
- return { ...e, key: String(i) };
|
|
|
- })
|
|
|
+ let result = res
|
|
|
+ if (Array.isArray(res)) {
|
|
|
+ // 列表数据需要一个key,要不然会报错,统一处理
|
|
|
+ result = res.map((e: any, i: number) => {
|
|
|
+ if (e.hasOwnProperty('key')) {
|
|
|
+ return e
|
|
|
+ } else {
|
|
|
+ return { ...e, key: String(i) };
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
console.log('查询数据成功:', result)
|
|
|
return result
|
|
|
}).catch(err => {
|
|
|
@@ -113,4 +120,5 @@ export function requestResultLoadingAndInfo(fn: Function, param: any, loading: R
|
|
|
*/
|
|
|
export function queryResultLoadingAndInfo(fn: Function, loading: Ref<boolean>, param?: any) {
|
|
|
return controlResultErrInfo(controlLoading(fn, loading, param))
|
|
|
-}
|
|
|
+}
|
|
|
+
|