mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-07 17:00:23 +08:00
optimize delfile in filelist & prepare for analyze
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { randomInt } from 'crypto'
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
import { resultError, resultSuccess, getRequestToken, requestParams } from '../_util'
|
||||
|
||||
@@ -16,7 +15,7 @@ function createFileList() {
|
||||
questions: 10,
|
||||
author: '课程组长',
|
||||
datetime: '2020-11-26 17:39',
|
||||
percent: randomInt(0, 100) + 1,
|
||||
percent: 0,
|
||||
})
|
||||
}
|
||||
return lst
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getFileListModel } from '/@/api/page/model/fileListModel'
|
||||
|
||||
const random = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1) + min)
|
||||
|
||||
function refreshFilePercent(arr: any[], i: number) {
|
||||
export function refreshFilePercent(arr: any[], i: number) {
|
||||
return async () => {
|
||||
const p = await getFilePercent(arr[i].id)
|
||||
arr[i].percent = p.percent
|
||||
@@ -47,6 +47,7 @@ async function refreshFileList() {
|
||||
author: lst[i].author,
|
||||
percent: lst[i].percent,
|
||||
hassettimeout: false,
|
||||
delloading: false,
|
||||
})
|
||||
__totalSize += lst[i].size
|
||||
__totalQuestions += lst[i].questions
|
||||
|
||||
@@ -55,7 +55,8 @@
|
||||
color="error"
|
||||
v-if="hasPermission([RoleEnum.SUPER])"
|
||||
:disabled="item.percent > 0 && item.percent < 100"
|
||||
@click="deleteFileBy(item.id)"
|
||||
:loading="item.delloading"
|
||||
@click="deleteFile(item)"
|
||||
>
|
||||
删除
|
||||
</a-button>
|
||||
@@ -102,16 +103,27 @@
|
||||
import { uploadApi } from '/@/api/sys/upload'
|
||||
import { useI18n } from '/@/hooks/web/useI18n'
|
||||
import { delFile } from '/@/api/page'
|
||||
import { DelFile } from '/@/api/page/model/fileListModel'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { createMessage } = useMessage()
|
||||
|
||||
function deleteFileBy(id: number) {
|
||||
delFile(id).then((value: DelFile) => {
|
||||
createMessage.info(value.msg)
|
||||
deleteFileByID(id)
|
||||
})
|
||||
async function deleteFile(item: any) {
|
||||
try {
|
||||
item.delloading = true
|
||||
const msg = await delFile(item.id)
|
||||
if (msg) {
|
||||
createMessage.success(msg.msg)
|
||||
setTimeout(() => {
|
||||
deleteFileByID(item.id)
|
||||
}, 1000)
|
||||
}
|
||||
} catch (error) {
|
||||
createMessage.error((error as unknown as Error).message)
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
item.delloading = false
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
@@ -139,7 +151,7 @@
|
||||
hasPermission,
|
||||
prefixCls: 'list-basic',
|
||||
getListOfPage,
|
||||
deleteFileBy,
|
||||
deleteFile,
|
||||
cardList,
|
||||
pagination,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user