parent
77df957b7b
commit
6a920f9161
|
|
@ -1,4 +1,4 @@
|
||||||
import { Button, Col, Form, Row, Space, Spin } from "antd";
|
import { Button, Col, Form, Row, Space, Spin, message } from "antd";
|
||||||
import FormItemsRenderer from "./FormItemsRenderer";
|
import FormItemsRenderer from "./FormItemsRenderer";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -34,6 +34,9 @@ const FormBuilder = (props) => {
|
||||||
scrollToFirstError
|
scrollToFirstError
|
||||||
wrapperCol={{ span: 24 - labelCol.span }}
|
wrapperCol={{ span: 24 - labelCol.span }}
|
||||||
initialValues={values}
|
initialValues={values}
|
||||||
|
onFinishFailed={() => {
|
||||||
|
message.error("请补全必填项");
|
||||||
|
}}
|
||||||
style={{ width: `calc(100% - ${gutter * 2}px)`, margin: `0 auto` }}
|
style={{ width: `calc(100% - ${gutter * 2}px)`, margin: `0 auto` }}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,19 @@ import { useState } from "react";
|
||||||
function useDeleteFile(returnType = "object") {
|
function useDeleteFile(returnType = "object") {
|
||||||
// loading状态
|
// loading状态
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
// 用于跟踪进行中的请求数量(不暴露给外部)
|
||||||
|
let requestCount = 0;
|
||||||
|
|
||||||
// 删除文件
|
// 删除文件
|
||||||
const deleteFile = (options) => {
|
const deleteFile = (options) => {
|
||||||
if (!options)
|
if (!options)
|
||||||
throw new Error("请传入 options");
|
throw new Error("请传入 options");
|
||||||
|
|
||||||
setLoading(true);
|
// 增加请求数量并设置loading状态
|
||||||
|
requestCount++;
|
||||||
|
if (requestCount > 0) {
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const { files = [], single = true } = options;
|
const { files = [], single = true } = options;
|
||||||
|
|
@ -25,7 +31,10 @@ function useDeleteFile(returnType = "object") {
|
||||||
|
|
||||||
// 如果没有文件则直接返回
|
// 如果没有文件则直接返回
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
setLoading(false);
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +43,10 @@ function useDeleteFile(returnType = "object") {
|
||||||
if (single) {
|
if (single) {
|
||||||
const firstFile = files[0];
|
const firstFile = files[0];
|
||||||
if (!firstFile.filePath) {
|
if (!firstFile.filePath) {
|
||||||
setLoading(false);
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +55,10 @@ function useDeleteFile(returnType = "object") {
|
||||||
else {
|
else {
|
||||||
const validFiles = files.filter(f => f.id);
|
const validFiles = files.filter(f => f.id);
|
||||||
if (validFiles.length === 0) {
|
if (validFiles.length === 0) {
|
||||||
setLoading(false);
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +78,11 @@ function useDeleteFile(returnType = "object") {
|
||||||
reject(err);
|
reject(err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
// 减少请求数量并在没有进行中的请求时设置loading为false
|
||||||
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,19 @@ import { DICTIONARY_APP_KEY_ENUM } from "../../enum/dictionary";
|
||||||
function useDictionary(returnType = "object") {
|
function useDictionary(returnType = "object") {
|
||||||
// loading状态
|
// loading状态
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
// 用于跟踪进行中的请求数量(不暴露给外部)
|
||||||
|
let requestCount = 0;
|
||||||
|
|
||||||
// 获取数据字典
|
// 获取数据字典
|
||||||
const getDictionary = (options) => {
|
const getDictionary = (options) => {
|
||||||
if (!options)
|
if (!options)
|
||||||
throw new Error("请传入 options");
|
throw new Error("请传入 options");
|
||||||
|
|
||||||
setLoading(true);
|
// 增加请求数量并设置loading状态
|
||||||
|
requestCount++;
|
||||||
|
if (requestCount > 0) {
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const { appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT, dictValue } = options;
|
const { appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT, dictValue } = options;
|
||||||
|
|
@ -37,7 +43,11 @@ function useDictionary(returnType = "object") {
|
||||||
reject(err);
|
reject(err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
// 减少请求数量并在没有进行中的请求时设置loading为false
|
||||||
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,16 @@ import { useState } from "react";
|
||||||
export default function useDownloadBlob(returnType = "object") {
|
export default function useDownloadBlob(returnType = "object") {
|
||||||
// loading状态
|
// loading状态
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
// 用于跟踪进行中的请求数量(不暴露给外部)
|
||||||
|
let requestCount = 0;
|
||||||
|
|
||||||
// 下载Blob流文件
|
// 下载Blob流文件
|
||||||
const downloadBlob = (url, options) => {
|
const downloadBlob = (url, options) => {
|
||||||
setLoading(true);
|
// 增加请求数量并设置loading状态
|
||||||
|
requestCount++;
|
||||||
|
if (requestCount > 0) {
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!url)
|
if (!url)
|
||||||
|
|
@ -57,7 +63,11 @@ export default function useDownloadBlob(returnType = "object") {
|
||||||
reject(err);
|
reject(err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
// 减少请求数量并在没有进行中的请求时设置loading为false
|
||||||
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,16 @@ import { getFileName, getFileSuffix, getFileUrl } from "../../utils";
|
||||||
export default function useDownloadFile(returnType = "object") {
|
export default function useDownloadFile(returnType = "object") {
|
||||||
// loading状态
|
// loading状态
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
// 用于跟踪进行中的请求数量(不暴露给外部)
|
||||||
|
let requestCount = 0;
|
||||||
|
|
||||||
// 下载文件
|
// 下载文件
|
||||||
const downloadFile = (options) => {
|
const downloadFile = (options) => {
|
||||||
setLoading(true);
|
// 增加请求数量并设置loading状态
|
||||||
|
requestCount++;
|
||||||
|
if (requestCount > 0) {
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
|
|
||||||
const { url, name: fileName } = options;
|
const { url, name: fileName } = options;
|
||||||
if (!url)
|
if (!url)
|
||||||
|
|
@ -50,9 +56,20 @@ export default function useDownloadFile(returnType = "object") {
|
||||||
message.error("下载失败");
|
message.error("下载失败");
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
// 减少请求数量并在没有进行中的请求时设置loading为false
|
||||||
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
onCancel: () => {
|
||||||
|
// 减少请求数量并在没有进行中的请求时设置loading为false
|
||||||
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,19 @@ import { addingPrefixToFile } from "../../utils";
|
||||||
function useGetFile(returnType = "object") {
|
function useGetFile(returnType = "object") {
|
||||||
// loading状态
|
// loading状态
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
// 用于跟踪进行中的请求数量(不暴露给外部)
|
||||||
|
let requestCount = 0;
|
||||||
|
|
||||||
// 获取文件
|
// 获取文件
|
||||||
const getFile = (options) => {
|
const getFile = (options) => {
|
||||||
if (!options)
|
if (!options)
|
||||||
throw new Error("请传入 options");
|
throw new Error("请传入 options");
|
||||||
|
|
||||||
setLoading(true);
|
// 增加请求数量并设置loading状态
|
||||||
|
requestCount++;
|
||||||
|
if (requestCount > 0) {
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const { eqType, eqForeignKey } = options;
|
const { eqType, eqForeignKey } = options;
|
||||||
|
|
@ -43,7 +49,11 @@ function useGetFile(returnType = "object") {
|
||||||
reject(err);
|
reject(err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
// 减少请求数量并在没有进行中的请求时设置loading为false
|
||||||
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,16 @@ import { useState } from "react";
|
||||||
function useGetUserInfo(returnType = "object") {
|
function useGetUserInfo(returnType = "object") {
|
||||||
// loading状态
|
// loading状态
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
// 用于跟踪进行中的请求数量(不暴露给外部)
|
||||||
|
let requestCount = 0;
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
const getUserInfo = () => {
|
const getUserInfo = () => {
|
||||||
setLoading(true);
|
// 增加请求数量并设置loading状态
|
||||||
|
requestCount++;
|
||||||
|
if (requestCount > 0) {
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 发送请求
|
// 发送请求
|
||||||
|
|
@ -26,7 +32,11 @@ function useGetUserInfo(returnType = "object") {
|
||||||
reject(err);
|
reject(err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
// 减少请求数量并在没有进行中的请求时设置loading为false
|
||||||
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,16 @@ import { useState } from "react";
|
||||||
export default function useImportFile(returnType = "object") {
|
export default function useImportFile(returnType = "object") {
|
||||||
// loading状态
|
// loading状态
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
// 用于跟踪进行中的请求数量(不暴露给外部)
|
||||||
|
let requestCount = 0;
|
||||||
|
|
||||||
// 导入文件
|
// 导入文件
|
||||||
const importFile = (url, options) => {
|
const importFile = (url, options) => {
|
||||||
setLoading(true);
|
// 增加请求数量并设置loading状态
|
||||||
|
requestCount++;
|
||||||
|
if (requestCount > 0) {
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!url)
|
if (!url)
|
||||||
|
|
@ -38,7 +44,11 @@ export default function useImportFile(returnType = "object") {
|
||||||
reject(err);
|
reject(err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
// 减少请求数量并在没有进行中的请求时设置loading为false
|
||||||
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,19 @@ import { UPLOAD_FILE_PATH_ENUM, UPLOAD_FILE_TYPE_ENUM } from "../../enum/uploadF
|
||||||
function useUploadFile(returnType = "object") {
|
function useUploadFile(returnType = "object") {
|
||||||
// loading状态
|
// loading状态
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
// 用于跟踪进行中的请求数量(不暴露给外部)
|
||||||
|
let requestCount = 0;
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
const uploadFile = (options) => {
|
const uploadFile = (options) => {
|
||||||
if (!options)
|
if (!options)
|
||||||
throw new Error("请传入 options");
|
throw new Error("请传入 options");
|
||||||
|
|
||||||
setLoading(true);
|
// 增加请求数量并设置loading状态
|
||||||
|
requestCount++;
|
||||||
|
if (requestCount > 0) {
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const { files = [], single = true, params } = options;
|
const { files = [], single = true, params } = options;
|
||||||
|
|
@ -48,7 +54,10 @@ function useUploadFile(returnType = "object") {
|
||||||
|
|
||||||
// 如果没有文件则直接返回
|
// 如果没有文件则直接返回
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
setLoading(false);
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
resolve(
|
resolve(
|
||||||
single
|
single
|
||||||
? { filePath: "" }
|
? { filePath: "" }
|
||||||
|
|
@ -77,7 +86,10 @@ function useUploadFile(returnType = "object") {
|
||||||
|
|
||||||
// 如果没有文件则返回老文件
|
// 如果没有文件则返回老文件
|
||||||
if (filesLength === 0) {
|
if (filesLength === 0) {
|
||||||
setLoading(false);
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
resolve(
|
resolve(
|
||||||
single
|
single
|
||||||
? { filePath: files[0].filePath }
|
? { filePath: files[0].filePath }
|
||||||
|
|
@ -104,7 +116,11 @@ function useUploadFile(returnType = "object") {
|
||||||
reject(err);
|
reject(err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
// 减少请求数量并在没有进行中的请求时设置loading为false
|
||||||
|
requestCount--;
|
||||||
|
if (requestCount <= 0) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue