|
@@ -136,6 +136,27 @@ export function arrToObj(arr) {
|
|
|
return obj
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+export function convertFileName (oldFileName, type) {
|
|
|
+ const lastDotIndex = oldFileName.lastIndexOf('.')
|
|
|
+ if (lastDotIndex === -1) {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ const now = new Date();
|
|
|
+ const year = now.getFullYear();
|
|
|
+ const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
|
+ const day = String(now.getDate()).padStart(2, '0');
|
|
|
+ const hours = String(now.getHours()).padStart(2, '0');
|
|
|
+ const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
|
+ const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
|
+ const randomNum = Math.floor(Math.random() * 9000) + 1000;
|
|
|
+ if (type === 'onlyName') {
|
|
|
+ return `${year}${month}${day}${hours}${minutes}${seconds}-${randomNum}`
|
|
|
+ } else {
|
|
|
+ return `${year}${month}${day}${hours}${minutes}${seconds}-${randomNum}${oldFileName.substring(lastDotIndex)}`
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export function noEmpty(val) {
|
|
|
if (val === null || val === undefined || val === '') {
|
|
|
return false
|