mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-08 17:40:23 +08:00
finish getFileList getFilePercent and part of analyzeFile
This commit is contained in:
@@ -35,8 +35,11 @@ export const delFile = (id: number) => {
|
||||
/**
|
||||
* @description: Analyze file
|
||||
*/
|
||||
export const analyzeFile = (id: number) => {
|
||||
return defHttp.get<AnalyzeFile>({ url: Api.AnalyzeFile, params: { id: id } })
|
||||
export const analyzeFile = (id: number, permanent: boolean) => {
|
||||
return defHttp.get<AnalyzeFile>(
|
||||
{ url: Api.AnalyzeFile, params: { id: id, permanent: permanent } },
|
||||
{ errorMessageMode: 'none' },
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface UploadApiResult {
|
||||
message: string
|
||||
code: number
|
||||
url: string
|
||||
result: number
|
||||
}
|
||||
|
||||
@@ -11,12 +11,6 @@
|
||||
{{ fileList.length }}
|
||||
</template>
|
||||
</template>
|
||||
<a-button @click="openPreviewModal">
|
||||
<Icon icon="bi:eye" />
|
||||
<template v-if="fileList.length && showPreviewNumber">
|
||||
{{ fileList.length }}
|
||||
</template>
|
||||
</a-button>
|
||||
</Tooltip>
|
||||
</Space>
|
||||
<UploadModal
|
||||
@@ -26,18 +20,10 @@
|
||||
@change="handleChange"
|
||||
@delete="handleDelete"
|
||||
/>
|
||||
|
||||
<UploadPreviewModal
|
||||
:value="fileList"
|
||||
@register="registerPreviewModal"
|
||||
@list-change="handlePreviewChange"
|
||||
@delete="handlePreviewDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, watch, unref, computed } from 'vue'
|
||||
import { Icon } from '/@/components/Icon'
|
||||
import { Tooltip, Space } from 'ant-design-vue'
|
||||
import { useModal } from '/@/components/Modal'
|
||||
import { uploadContainerProps } from './props'
|
||||
@@ -45,10 +31,9 @@
|
||||
import { useI18n } from '/@/hooks/web/useI18n'
|
||||
import { isArray } from '/@/utils/is'
|
||||
import UploadModal from './UploadModal.vue'
|
||||
import UploadPreviewModal from './UploadPreviewModal.vue'
|
||||
export default defineComponent({
|
||||
name: 'BasicUpload',
|
||||
components: { UploadModal, Space, UploadPreviewModal, Icon, Tooltip },
|
||||
components: { UploadModal, Space, Tooltip },
|
||||
props: uploadContainerProps,
|
||||
emits: ['change', 'delete', 'preview-delete', 'update:value'],
|
||||
setup(props, { emit, attrs }) {
|
||||
@@ -80,12 +65,6 @@
|
||||
emit('update:value', fileList.value)
|
||||
emit('change', fileList.value)
|
||||
}
|
||||
// 预览modal保存操作
|
||||
function handlePreviewChange(urls: string[]) {
|
||||
fileList.value = [...(urls || [])]
|
||||
emit('update:value', fileList.value)
|
||||
emit('change', fileList.value)
|
||||
}
|
||||
function handleDelete(record: Recordable) {
|
||||
emit('delete', record)
|
||||
}
|
||||
@@ -96,7 +75,6 @@
|
||||
registerUploadModal,
|
||||
openUploadModal,
|
||||
handleChange,
|
||||
handlePreviewChange,
|
||||
registerPreviewModal,
|
||||
openPreviewModal,
|
||||
fileList,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<BasicModal
|
||||
width="800px"
|
||||
:title="t('component.upload.upload')"
|
||||
:okText="t('component.upload.save')"
|
||||
:okText="t('component.upload.complete')"
|
||||
v-bind="$attrs"
|
||||
@register="register"
|
||||
@ok="handleOk"
|
||||
@@ -236,11 +236,11 @@
|
||||
if (isUploadingRef.value) {
|
||||
return createMessage.warning(t('component.upload.saveWarn'))
|
||||
}
|
||||
const fileList: string[] = []
|
||||
const fileList: number[] = []
|
||||
for (const item of fileListRef.value) {
|
||||
const { status, responseData } = item
|
||||
if (status === UploadResultStatus.SUCCESS && responseData) {
|
||||
fileList.push(responseData.url)
|
||||
fileList.push(responseData.result)
|
||||
}
|
||||
}
|
||||
// 存在一个上传成功的即可保存
|
||||
|
||||
@@ -91,6 +91,7 @@ export default {
|
||||
},
|
||||
upload: {
|
||||
save: '保存',
|
||||
complete: '完成',
|
||||
upload: '上传',
|
||||
imgUpload: '图片上传',
|
||||
uploaded: '已上传',
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
<BasicUpload
|
||||
name="paper"
|
||||
v-if="hasPermission([RoleEnum.SUPER, RoleEnum.FILE_MANAGER])"
|
||||
:maxSize="20"
|
||||
:maxNumber="10"
|
||||
@change="handleChange"
|
||||
:maxSize="64"
|
||||
:maxNumber="16"
|
||||
:api="uploadApi"
|
||||
@change="onChange"
|
||||
:accept="['application/vnd.openxmlformats-officedocument.wordprocessingml.document']"
|
||||
/>
|
||||
</template>
|
||||
@@ -19,7 +19,7 @@
|
||||
</a-col>
|
||||
<a-col :span="8" :class="`${prefixCls}__top-col`">
|
||||
<div>占用空间</div>
|
||||
<p> {{ cardList._totalSize }}MB </p>
|
||||
<p> {{ cardList._totalSize.toFixed(2) }}MB </p>
|
||||
</a-col>
|
||||
<a-col :span="8" :class="`${prefixCls}__top-col`">
|
||||
<div>总题目数</div>
|
||||
@@ -75,7 +75,7 @@
|
||||
{{ item.description }}
|
||||
</div>
|
||||
<div class="info">
|
||||
<div><span>文件大小</span>{{ item.size }}MB</div>
|
||||
<div><span>文件大小</span>{{ item.size.toFixed(2) }}MB</div>
|
||||
<div><span>上传用户</span>{{ item.author }}</div>
|
||||
<div><span>上传时间</span>{{ item.datetime }}</div>
|
||||
</div>
|
||||
@@ -109,6 +109,7 @@
|
||||
pagination,
|
||||
refreshFilePercent,
|
||||
random,
|
||||
refreshCardList,
|
||||
} from './data'
|
||||
import { PageWrapper } from '/@/components/Page'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
@@ -119,6 +120,7 @@
|
||||
import { useI18n } from '/@/hooks/web/useI18n'
|
||||
import { delFile, analyzeFile } from '/@/api/page'
|
||||
import { useGo } from '/@/hooks/web/usePage'
|
||||
import { useTabs } from '/@/hooks/web/useTabs'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { createMessage } = useMessage()
|
||||
@@ -144,7 +146,7 @@
|
||||
|
||||
async function analFile(item: any) {
|
||||
try {
|
||||
const msg = await analyzeFile(item.id)
|
||||
const msg = await analyzeFile(item.id, true)
|
||||
if (msg) {
|
||||
createMessage.success(msg.msg)
|
||||
if (!item.hassettimeout && item.percent == 0) {
|
||||
@@ -171,18 +173,21 @@
|
||||
},
|
||||
setup() {
|
||||
const { hasPermission } = usePermission()
|
||||
const { refreshPage } = useTabs()
|
||||
const go = useGo()
|
||||
|
||||
function openFile(id: number) {
|
||||
go({ name: 'FilePage', params: { id } })
|
||||
}
|
||||
|
||||
async function onChange(_: number[]) {
|
||||
refreshCardList()
|
||||
refreshPage()
|
||||
}
|
||||
|
||||
return {
|
||||
t,
|
||||
RoleEnum,
|
||||
handleChange: (list: string[]) => {
|
||||
createMessage.info(`已上传文件${JSON.stringify(list)}`)
|
||||
},
|
||||
uploadApi,
|
||||
hasPermission,
|
||||
prefixCls: 'list-basic',
|
||||
@@ -192,6 +197,7 @@
|
||||
analyzeFile: analFile,
|
||||
cardList,
|
||||
pagination,
|
||||
onChange,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user