This commit is contained in:
chenbo 2024-01-17 18:22:51 +08:00
parent 7643305054
commit 16121d7260
1 changed files with 13 additions and 7 deletions

View File

@ -240,17 +240,23 @@ const handleSubmit = async () => {
popupRef.value?.close()
emit('success')
}
const generateUuid = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r = (Math.random() * 16) | 0
const v = c == 'x' ? r : (r & 0x3) | 0x8
return v.toString(16)
})
const generateUuid = (length: number) => {
let result1='',result2='';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
const characters1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
result1 = characters.charAt(Math.floor(Math.random() * characters.length))
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters1.length);
result2 += characters1.charAt(randomIndex);
}
return result1+result2;
}
//
const open = (type = 'add') => {
mode.value = type
formData.code = generateUuid()
formData.code = generateUuid(3)
popupRef.value?.open()
}