4.1 同步发版内容到天梯

This commit is contained in:
jl-zhoujl2
2022-04-01 20:06:34 +08:00
parent a3b939d154
commit 7b3efe00dd
128 changed files with 929 additions and 5029 deletions

View File

@ -1,12 +1,10 @@
import React, { useEffect, useState } from 'react';
import { Upload, Button, message, Modal, Spin } from "antd";
import { UploadOutlined, CloseSquareOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import { createNewFileBid, removeFileByOid, getFileListByBid } from "./service"
import { getSessionRoleData, getSessionUserData,getUserToken } from '@/utils/session';
import { getSessionRoleData, getUserToken } from '@/utils/session';
import { UploadProps } from 'antd/lib/upload/interface';
import { downloadFile, getFileListByBid, uploadAttachmentPath } from '../DownloadUtils';
import { createNewFileBid, removeFileByOid } from '@/services/download_';
interface ExtendUploadProps {
bid?: string;
@ -57,7 +55,7 @@ const ExtendUpload: React.FC<ExtendUploadProps> = (props) => {
const fileBeforeUpload = (curFile: any, curFileList: any) => {
const promise = new Promise<File | void>((resolve, reject) => {
if (maxSize === 0) {
} else {
let curSize = curFile.size / 1024 / 1024;
if (maxSize <= curSize) {
@ -66,7 +64,7 @@ const ExtendUpload: React.FC<ExtendUploadProps> = (props) => {
}
}
if (maxCount === 0) {
} else {
let curCount = fileList.length;
if (maxCount <= curCount) {
@ -95,10 +93,10 @@ const ExtendUpload: React.FC<ExtendUploadProps> = (props) => {
const fileChange = async (info: any) => {
const { file, fileList } = info;
setSpin(true);
if (file.status === 'uploading' ||file.status === 'removed' || file.status === 'done' || file.status === 'error') {
if (file.status === 'uploading' || file.status === 'removed' || file.status === 'done' || file.status === 'error') {
if (file.status === 'uploading') {
setFileList(fileList);
}else {
} else {
if (file.status === 'removed') {
if (file?.uid !== "") {
await removeFileByOid(file.uid)
@ -112,7 +110,7 @@ const ExtendUpload: React.FC<ExtendUploadProps> = (props) => {
//重新获取文件列表并确认是否返回文件id
fileListById(returnValue)
}
}else{
} else {
fileListById(returnValue)
}
}
@ -135,56 +133,35 @@ const ExtendUpload: React.FC<ExtendUploadProps> = (props) => {
return promise;
}
const fileDownLoad = (file: any) => {
window.fetch(file.url, {
method: "GET",
headers: {
// JwtToken: getSessionUserData() == null ? null : getSessionUserData().userId,
Authorization:getUserToken(),
currentRoleCode: getSessionRoleData()?.roleCode,
},
credentials: 'include',
}).then((response) => {
// 这里才是下载附件逻辑处理的地方
response.blob().then(blob => {
const blobUrl = window.URL.createObjectURL(blob);
const aElement = document.createElement("a");
const filename = file.name; // 设置文件名称
aElement.href = blobUrl; // 设置a标签路径
aElement.download = filename;
aElement.click();
window.URL.revokeObjectURL(blobUrl);
});
});
}
return (
<>
<Spin spinning={spin}>
<Upload
{...uploadProps}
key={"file" + returnValue}
action="/api/core-service-ebtp-updownload/v1/attachment/upload/"
data={{ businessId: returnValue }}
headers={{
// JwtToken: getSessionUserData() == null ? null : getSessionUserData().userId,
Authorization:getUserToken(),
currentRoleCode: getSessionRoleData()?.roleCode,
}}
name="file"
beforeUpload={fileBeforeUpload}
onChange={fileChange}
onRemove={fileRemove}
showUploadList={{
removeIcon: <CloseSquareOutlined />,
}}
onPreview={fileDownLoad}
fileList={fileList}
>
{!uploadProps?.disabled ?
<Button disabled={uploadProps?.disabled} icon={<UploadOutlined />}>{btnName}</Button>
: null}
</Upload>
<Spin spinning={spin}>
<Upload
{...uploadProps}
key={"file" + returnValue}
action={uploadAttachmentPath}
data={{
appCode: 'ebtp-cloud-frontend',
objectId: returnValue,
}}
headers={{
Authorization: getUserToken(),
currentRoleCode: getSessionRoleData()?.roleCode,
}}
name="multipartFiles"
beforeUpload={fileBeforeUpload}
onChange={fileChange}
onRemove={fileRemove}
showUploadList={{
removeIcon: <CloseSquareOutlined />,
}}
onPreview={downloadFile}
fileList={fileList}
>
{!uploadProps?.disabled ?
<Button disabled={uploadProps?.disabled} icon={<UploadOutlined />}>{btnName}</Button>
: null}
</Upload>
</Spin>
</>
)

View File

@ -1,45 +0,0 @@
import request from '@/utils/request';
//获取项目所有公告信息
//params项目id项目类别id
//projectId
//roomType
export async function createNewFileBid() {
return request('/api/core-service-ebtp-updownload/v1/business/id',{
method:'get'
})
}
//按照oid删除文件
export async function removeFileByOid(oid?:string) {
return request('/api/core-service-ebtp-updownload/v1/attachment/item/'+oid,{
method:'delete',
})
}
//根据bid获取文件列表返回给ExtendUpload组件
export async function getFileListByBid(Bid: string) {
let result: { uid: any; name: any; status: string; url: string; }[] = [];
if(Bid==null||Bid==""||Bid==undefined){
return [];
}
return request('/api/core-service-ebtp-updownload/v1/attachment/find',{
method: 'post',
data: {
"bidList": [Bid]
}
}).then(res => {
if (res?.[Bid]?.length > 0){
for(let i=0;i<res[Bid].length;i++){
result.push({
uid: res[Bid][i].id,
name: res[Bid][i].filename,
status: 'done',
url: '/api/core-service-ebtp-updownload/v1/attachment/download/oid/' + res[Bid][i].id,
})
}
return result;
}
return [];
})
}