提交 9bfdfdcc 作者: ZhangLingKun

功能:招标快讯文件回显

上级 a528149d
......@@ -10,6 +10,7 @@ VITE_REQUEST_BASE_URL='/api'
#VITE_REQUEST_BASE_URL='http://192.168.3.22:10001'
#VITE_REQUEST_BASE_URL='http://192.168.3.17:8099'
#VITE_REQUEST_BASE_URL='http://192.168.3.23:35150'
#VITE_REQUEST_BASE_URL='http://192.168.3.111:10001'
#版本
NODE_ENV='development'
VERSION='2.2.4.230217.Release'
......@@ -31,6 +31,7 @@ export type releaseTenderNews = InterListFunction<
port: number;
tenderName: string;
using: number;
url: string;
}
>;
// 新增招标快讯
......
......@@ -5,6 +5,7 @@ import { releaseTenderNewsUpdate, releaseTenderNews } from '~/api/interface/reso
import { ResourceManageAPI } from '~/api';
import { Uploader } from '~/components/uploader';
import { UploadOutlined } from '@ant-design/icons';
import { uploadFile } from '~/utils/uploadFile';
// 列表的类型
type TableType = InterListType<releaseTenderNews>;
......@@ -48,11 +49,23 @@ const AddEditModal: React.FC<propType> = (props) => {
};
// 提交事件
const handleSubmit = async (values: ReqType & { file: any[] }) => {
// 上传文件
const filePath = await uploadFile(values?.file?.at(-1));
// 新建formData
const formData = new FormData();
formData.append('file', values?.file?.at(-1));
const blob = new Blob([JSON.stringify({ ...values, id: data?.id ? data?.id : null })], {
const blob = new Blob(
[
JSON.stringify({
...values,
id: data?.id ? data?.id : null,
url: filePath ? filePath : null,
}),
],
{
type: 'application/json',
});
},
);
formData.append('tenderNewsVO', blob);
const res = await ResourceManageAPI[
data?.id ? 'releaseTenderNewsUpdate' : 'releaseTenderNewsAdd'
......@@ -115,6 +128,7 @@ const AddEditModal: React.FC<propType> = (props) => {
onChange={(e) => {
form.setFieldValue('file', e);
}}
defaultFileList={data?.url ? [{ url: data?.url }] : []}
>
<Button icon={<UploadOutlined />} type={'primary'}>
上传
......
import { CommonAPI } from '~/api';
import { message } from 'antd';
// 上传文件
export const uploadFile = (file: any): Promise<string> =>
new Promise((resolve, reject) => {
// 上传到服务器
const formData = new FormData();
formData.append('uploadFile', file);
CommonAPI.uploadOssBP(formData).then((res) => {
if (res && res.code === '200') {
resolve(res.result);
return;
} else {
reject(res);
message.error('文件上传失败').then();
return;
}
});
});
......@@ -13,6 +13,8 @@ export default defineConfig({
'/api': {
// target: 'http://192.168.3.111:8099', // 后端女pms
// target: 'http://192.168.3.111:8077', // 后端女oms
// target: 'http://192.168.3.111:10001', // 后端女release
// target: 'http://192.168.3.111:35150', // 后端女user
// target: 'http://192.168.3.17:8099', // 狗旺
target: 'https://test.iuav.shop',
changeOrigin: true,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论