更新版本库
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Button, Form, Input, Modal, Upload, Select } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Button, Form, Input, Modal, Upload, Select, message } from 'antd';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import { getSecondBusinessId } from '../service';
|
||||
|
||||
interface CreateDocumentProps {
|
||||
//新增文档标题参数
|
||||
@ -9,6 +10,12 @@ interface CreateDocumentProps {
|
||||
modalVisible: boolean;
|
||||
//返回参数
|
||||
onCancel: () => void;
|
||||
//成功回参
|
||||
onOk: (value: any) => any;
|
||||
//存档目录数据传入
|
||||
archiveData?: any;
|
||||
//修改行数据传入
|
||||
values: any
|
||||
}
|
||||
|
||||
const layout = {
|
||||
@ -21,14 +28,122 @@ const validateMessages = {
|
||||
};
|
||||
|
||||
const CreateDocument: React.FC<CreateDocumentProps> = (props) => {
|
||||
const { modalVisible, onCancel, title } = props;
|
||||
|
||||
const { modalVisible, onCancel, title,archiveData ,onOk , values} = props;
|
||||
//上传文件id存储
|
||||
const [uploadId, setUploadId] = useState<any>();
|
||||
//上传文件列表
|
||||
const [fileListData, setFileListData] = useState<any[]>([]);
|
||||
const { Option } = Select;
|
||||
const { TextArea } = Input;
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const onFinish = (values: any) => {
|
||||
console.log(values);
|
||||
useEffect(() => {
|
||||
if(values == null || values == undefined) {
|
||||
setFileListData([])
|
||||
form.setFieldsValue({
|
||||
archiveFileType:'',
|
||||
archiveId:null,
|
||||
archiveExplain:'',
|
||||
archiveRoundsId:'',
|
||||
id:''
|
||||
})
|
||||
} else {
|
||||
if(values.ossFileList == null) {
|
||||
setFileListData([])
|
||||
} else {
|
||||
let value: { name: string; businessId: string; url: string; uid: string; }[] = []
|
||||
let data = values.ossFileList
|
||||
data.forEach((ele: any) => {
|
||||
let obj = {
|
||||
name: "",
|
||||
businessId: "",
|
||||
url:"",
|
||||
uid:""
|
||||
}
|
||||
obj.name = ele.filename
|
||||
obj.businessId = ele.bid
|
||||
obj.url = `http://125.32.114.204:8760/api/core-service-ebtp-updownload/v1/attachment/download/oid/${ele.id}`
|
||||
obj.uid = ele.id
|
||||
value.push(obj)
|
||||
});
|
||||
setFileListData([...value])
|
||||
}
|
||||
|
||||
form.setFieldsValue({
|
||||
archiveFileType:values.archiveFileType,
|
||||
archiveId:values.archiveId,
|
||||
archiveExplain:values.archiveExplain,
|
||||
archiveRoundsId:values.archiveRoundsId,
|
||||
id:values.id
|
||||
})
|
||||
}
|
||||
}, [values,modalVisible])
|
||||
|
||||
const onFinish = async (values: any) => {
|
||||
let data = values
|
||||
data.businessFileId = fileListData[0].businessId
|
||||
const success = await onOk(data)
|
||||
if(success) {
|
||||
setFileListData([])
|
||||
}
|
||||
|
||||
};
|
||||
const onSubmit = () => {
|
||||
if(fileListData.length == 0) {
|
||||
message.info("请选择文档")
|
||||
} else {
|
||||
form.submit()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//上传文件业务id获取
|
||||
const getUploadBusinessId = async () => {
|
||||
await getSecondBusinessId().then((res) => {
|
||||
setUploadId(res.id);
|
||||
});
|
||||
};
|
||||
|
||||
//上传文件数量控制
|
||||
const handleChange = (info: { fileList: any }) => {
|
||||
let fileList = [...info.fileList];
|
||||
let count = 0
|
||||
// 1. 限制上传文件的数量
|
||||
// 只显示最近上传的一个文件,旧的会被新的替换
|
||||
fileList = fileList.slice(-1);
|
||||
// 2.从response中读取并显示文件链接
|
||||
fileList = fileList.map((file) => {
|
||||
if (file.response) {
|
||||
// 组件将显示文件和url链接
|
||||
message.success("上传成功")
|
||||
count = 1
|
||||
file.url = `http://125.32.114.204:8760/api/core-service-ebtp-updownload/v1/attachment/download/oid/${file.response.oid}`;
|
||||
file.oid = file.response.oid;
|
||||
file.businessId = uploadId
|
||||
}
|
||||
return file;
|
||||
});
|
||||
if(count == 1) {
|
||||
setFileListData(fileList);
|
||||
}
|
||||
};
|
||||
//上传文件大小控制
|
||||
const beforeUpload = (file: any) => {
|
||||
//文件大小字节数自己算的
|
||||
if(file.size > 52428800) {
|
||||
message.info("上传文件大于50M,请重新上传")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
//上传文件参数配置
|
||||
const uploadProps = {
|
||||
action: '/api/core-service-ebtp-updownload/v1/attachment/upload',
|
||||
onChange: handleChange,
|
||||
beforeUpload: beforeUpload,
|
||||
data: {
|
||||
businessId: uploadId,
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
@ -36,7 +151,11 @@ const CreateDocument: React.FC<CreateDocumentProps> = (props) => {
|
||||
destroyOnClose
|
||||
title={title}
|
||||
visible={modalVisible}
|
||||
onCancel={() => onCancel()}
|
||||
onCancel={() => {
|
||||
setFileListData([])
|
||||
onCancel()
|
||||
}}
|
||||
onOk={() => onSubmit()}
|
||||
okText="保存"
|
||||
cancelText="取消"
|
||||
width={800}
|
||||
@ -47,6 +166,7 @@ const CreateDocument: React.FC<CreateDocumentProps> = (props) => {
|
||||
name="nest-messages"
|
||||
onFinish={onFinish}
|
||||
validateMessages={validateMessages}
|
||||
preserve={false}
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
@ -60,29 +180,31 @@ const CreateDocument: React.FC<CreateDocumentProps> = (props) => {
|
||||
>
|
||||
最多上传一个文件,每个最大50MB
|
||||
</span>
|
||||
<Form.Item label="选择文档" rules={[{ required: true }]}>
|
||||
<Upload>
|
||||
<Button type="primary">
|
||||
<Form.Item label="选择文档">
|
||||
<Upload {...uploadProps} fileList={fileListData}>
|
||||
<Button type="primary" onClick={() => getUploadBusinessId()}>
|
||||
<UploadOutlined />
|
||||
上传
|
||||
</Button>
|
||||
</Upload>
|
||||
</Form.Item>
|
||||
<Form.Item label="文档类型" rules={[{ required: true }]}>
|
||||
<Form.Item name="archiveFileType" label="文档类型" rules={[{ required: true }]}>
|
||||
<Input placeholder="请填写文档类型" />
|
||||
</Form.Item>
|
||||
<Form.Item label="存档目录" rules={[{ required: true }]}>
|
||||
<Form.Item name="archiveId" label="存档目录" rules={[{ required: true }]}>
|
||||
<Select style={{ width: 200 }} placeholder="请选择" optionFilterProp="children">
|
||||
<Option value="jack">项目建档</Option>
|
||||
<Option value="lucy">谈判邀请</Option>
|
||||
<Option value="tom">谈判准备</Option>
|
||||
<Option value="tom1">项目谈判</Option>
|
||||
<Option value="tom2">谈判结果</Option>
|
||||
{archiveData.map((ele: any) => (<Option value={ele.archiveLinkId} key={ele.archiveLinkId}>{ele.archiveLinkName}</Option>))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label="文档说明" rules={[{ required: true }]}>
|
||||
<Form.Item name="archiveExplain" label="文档说明" rules={[{ required: true }]}>
|
||||
<TextArea rows={6} maxLength={2000} placeholder="请填写文档说明" />
|
||||
</Form.Item>
|
||||
<Form.Item name="archiveRoundsId" label="archiveRoundsId" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="id" label="id" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
97
src/pages/Archive/ProjectArchive/components/Details.tsx
Normal file
97
src/pages/Archive/ProjectArchive/components/Details.tsx
Normal file
@ -0,0 +1,97 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Form, Input, Modal, Select } from 'antd';
|
||||
interface CreateDocumentProps {
|
||||
//新增文档标题参数
|
||||
title: string;
|
||||
//控制弹出参数
|
||||
modalVisible: boolean;
|
||||
//返回参数
|
||||
onCancel: () => void;
|
||||
//存档目录数据传入
|
||||
archiveData?: any;
|
||||
//修改行数据传入
|
||||
values: any;
|
||||
}
|
||||
|
||||
const layout = {
|
||||
labelCol: { span: 7 },
|
||||
wrapperCol: { span: 12 },
|
||||
};
|
||||
|
||||
const validateMessages = {
|
||||
required: '请填写${label}',
|
||||
};
|
||||
|
||||
const Details: React.FC<CreateDocumentProps> = (props) => {
|
||||
const { modalVisible, onCancel, title, archiveData, values } = props;
|
||||
//上传文件列表
|
||||
const [fileListData, setFileListData] = useState<any[]>([]);
|
||||
const { Option } = Select;
|
||||
const { TextArea } = Input;
|
||||
const [form] = Form.useForm();
|
||||
|
||||
useEffect(() => {
|
||||
if (values == null || values == undefined) {
|
||||
} else {
|
||||
if (values.ossFileList == null) {
|
||||
setFileListData([]);
|
||||
} else {
|
||||
setFileListData([...values.ossFileList]);
|
||||
}
|
||||
form.setFieldsValue({
|
||||
archiveFileType: values.archiveFileType,
|
||||
archiveId: values.archiveId,
|
||||
archiveExplain: values.archiveExplain,
|
||||
});
|
||||
}
|
||||
}, [values, modalVisible]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
destroyOnClose
|
||||
title={title}
|
||||
visible={modalVisible}
|
||||
onCancel={() => {
|
||||
onCancel()
|
||||
setFileListData([])
|
||||
}}
|
||||
footer={false}
|
||||
width={800}
|
||||
>
|
||||
<Form
|
||||
{...layout}
|
||||
form={form}
|
||||
name="nest-messages"
|
||||
validateMessages={validateMessages}
|
||||
preserve={false}
|
||||
>
|
||||
<Form.Item label="选择文档">
|
||||
{fileListData.map((e) => (
|
||||
<a
|
||||
href={`http://125.32.114.204:8760/api/core-service-ebtp-updownload/v1/attachment/download/oid/${e.id}`}
|
||||
>
|
||||
{e.filename}
|
||||
</a>
|
||||
))}
|
||||
</Form.Item>
|
||||
<Form.Item name="archiveFileType" label="文档类型">
|
||||
<Input placeholder="请填写文档类型" readOnly/>
|
||||
</Form.Item>
|
||||
<Form.Item name="archiveId" label="存档目录">
|
||||
<Select style={{ width: 200 }} placeholder="请选择" optionFilterProp="children" disabled>
|
||||
{archiveData.map((ele: any) => (
|
||||
<Option value={ele.archiveLinkId} key={ele.archiveLinkId}>
|
||||
{ele.archiveLinkName}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="archiveExplain" label="文档说明">
|
||||
<TextArea rows={6} maxLength={2000} placeholder="请填写文档说明" readOnly/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@ -1,147 +1,373 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Divider, Switch, Tag } from 'antd';
|
||||
import ProTable, { ProColumns } from '@ant-design/pro-table';
|
||||
import { EditOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { Card, message, Modal, Popconfirm, Switch, Tag } from 'antd';
|
||||
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
|
||||
import { EditOutlined, ExclamationCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import CreateDocument from './components/CreateDocument';
|
||||
|
||||
export interface Status {
|
||||
color: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
const statusMap = {
|
||||
0: {
|
||||
color: '',
|
||||
text: '未归档',
|
||||
},
|
||||
1: {
|
||||
color: 'green',
|
||||
text: '已归档',
|
||||
},
|
||||
};
|
||||
|
||||
export interface TableListItem {
|
||||
key: number;
|
||||
name: string;
|
||||
containers: number;
|
||||
creator: string;
|
||||
status: Status;
|
||||
createdAt: number;
|
||||
}
|
||||
const tableListDataSource: TableListItem[] = [];
|
||||
|
||||
const creators = ['付小小', '曲丽丽', '林东东', '陈帅帅', '兼某某'];
|
||||
|
||||
for (let i = 0; i < 5; i += 1) {
|
||||
tableListDataSource.push({
|
||||
key: i,
|
||||
name: 'AppName',
|
||||
containers: Math.floor(Math.random() * 20),
|
||||
creator: creators[Math.floor(Math.random() * creators.length)],
|
||||
status: statusMap[Math.floor(Math.random() * 10) % 5],
|
||||
createdAt: Date.now() - Math.floor(Math.random() * 100000),
|
||||
});
|
||||
}
|
||||
|
||||
const onChange = (value: any) => {
|
||||
console.log(value)
|
||||
}
|
||||
|
||||
const expandedRowRender = () => {
|
||||
const data = [];
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
data.push({
|
||||
key: i,
|
||||
id: i+1,
|
||||
to: "项目建档",
|
||||
upgradeNum: 'Upgraded: 56',
|
||||
name: 'This is production name',
|
||||
is: "有",
|
||||
ispaper: 1,
|
||||
state:statusMap[ i == 0 || i == 1 ? 0 : 1 ]
|
||||
});
|
||||
}
|
||||
return (
|
||||
<ProTable
|
||||
columns={[
|
||||
{ title: '序号', dataIndex: 'id', key: 'id' },
|
||||
{ title: '归档目录', dataIndex: 'to', key: 'to' },
|
||||
|
||||
{ title: '文档类型', dataIndex: 'upgradeNum', key: 'upgradeNum' },
|
||||
{ title: '文档名称', dataIndex: 'name', key: 'name' },
|
||||
{ title: '有无电子档', dataIndex: 'is', key: 'is' },
|
||||
{ title: '有无纸质', dataIndex: 'ispaper', key: 'ispaper',render:(_,record) => <Switch checkedChildren="有" unCheckedChildren="无" onChange={onChange}/> },
|
||||
{ title: '状态', dataIndex: 'state', key: 'state', render: (_, record) => <Tag color={record.state.color}>{record.state.text}</Tag>,},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'operation',
|
||||
key: 'operation',
|
||||
valueType: 'option',
|
||||
render: () => [<a key="Pause">移除</a>, <a key="Stop">编辑</a>, <a key="total">详情</a>],
|
||||
},
|
||||
]}
|
||||
headerTitle={false}
|
||||
search={false}
|
||||
options={false}
|
||||
dataSource={data}
|
||||
// pagination={false}
|
||||
/>
|
||||
);
|
||||
};
|
||||
import {
|
||||
getFirstSectionList,
|
||||
getSecondArchiveDirectory,
|
||||
getSecondFileList,
|
||||
proArchive,
|
||||
updateSecondFile,
|
||||
} from './service';
|
||||
import { handleAdd, handleDelete, handleUpdate } from './utils';
|
||||
import Details from './components/Details';
|
||||
import { getProId } from '@/utils/session';
|
||||
|
||||
const ProjectArchive: React.FC<{}> = () => {
|
||||
//新增档案文件弹出参数
|
||||
const [addDocument, setAddDocument] = useState<boolean>(false)
|
||||
//新增档案文件弹出参数
|
||||
const [addDocument, setAddDocument] = useState<boolean>(false);
|
||||
//查看档案文件弹出参数
|
||||
const [viewVisible, setViewVisible] = useState<boolean>(false);
|
||||
//一级标段目录总数据
|
||||
const [totalFirstData, setTotalFirstData] = useState<any[]>([]);
|
||||
//一级标段目录id数据(id)
|
||||
const [totalFirstIds, setTotalFirstIds] = useState<any[]>([]);
|
||||
//一级标段目录行数据
|
||||
const [firstDataRecord, setFirstDataRecord] = useState<any>();
|
||||
//二级附件目录行数据
|
||||
const [secondDataRecord, setSecondDataRecord] = useState<any>();
|
||||
//二级附件目录归档目录
|
||||
const [secondArchiveData, setSecondArchiveData] = useState<any[]>([]);
|
||||
//当前展开的一级表格key = id
|
||||
const [openRowKeys, setOpenRowKeys] = useState<any[]>([]);
|
||||
//控制一级表单作用
|
||||
const firstActionRef = useRef<ActionType>();
|
||||
//控制二级表单作用
|
||||
const secondActionRef = useRef<ActionType>();
|
||||
//存储新增修改详情title
|
||||
const [modalTitle, setModalTitle] = useState<any>();
|
||||
|
||||
const columns: ProColumns<TableListItem>[] = [
|
||||
const { confirm } = Modal;
|
||||
//初始化二级附件目录及二级附件目录刷新配置
|
||||
useEffect(() => {
|
||||
//获取新增二级附件归档目录数据
|
||||
const defId = 1;
|
||||
getSecondArchiveDirectory(defId).then((res) => {
|
||||
if (res.code == 200) {
|
||||
setSecondArchiveData(res.data);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
//二级附件目录配置
|
||||
const expandedRowRender = () => {
|
||||
const columns: ProColumns<any>[] = [
|
||||
{
|
||||
title: '业务编号',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 120,
|
||||
render: (_) => <a>{_}</a>,
|
||||
title: '序号',
|
||||
dataIndex: 'key',
|
||||
key: 'key',
|
||||
},
|
||||
{ title: '归档目录', dataIndex: 'archiveLinkName', key: 'archiveLinkName' },
|
||||
{ title: '文档类型', dataIndex: 'archiveFileType', key: 'archiveFileType' },
|
||||
{
|
||||
title: '文档名称',
|
||||
render: (_, record) => {
|
||||
if (record.isFile == 0) {
|
||||
}
|
||||
if (record.ossFileList == null) {
|
||||
return '-';
|
||||
}
|
||||
return record.ossFileList.map((e: any) => (
|
||||
<a
|
||||
href={`http://125.32.114.204:8760/api/core-service-ebtp-updownload/v1/attachment/download/oid/${e.id}`}
|
||||
>
|
||||
{e.filename}
|
||||
</a>
|
||||
));
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '标段名称',
|
||||
dataIndex: 'containers',
|
||||
key: 'containers',
|
||||
width: 120,
|
||||
title: '有无电子档',
|
||||
dataIndex: 'isElectronicFile',
|
||||
key: 'isElectronicFile',
|
||||
render: (_, record) => (record.isElectronicFile == 1 ? '有' : '无'),
|
||||
},
|
||||
{
|
||||
title: '有无纸质',
|
||||
render: (_, record) => (
|
||||
<Switch
|
||||
checkedChildren="有"
|
||||
unCheckedChildren="无"
|
||||
onChange={(checked) => onChange(checked, record)}
|
||||
disabled={record.status == 2}
|
||||
defaultChecked={record.isPaperFile == 1}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'option',
|
||||
dataIndex: 'operation',
|
||||
key: 'operation',
|
||||
valueType: 'option',
|
||||
width: 164,
|
||||
render: (_,record) => [
|
||||
<a key="1" onClick={() => setAddDocument(true)}><PlusOutlined />新增</a>,
|
||||
<a key="2"><EditOutlined />归档</a>
|
||||
]
|
||||
render: (_: any, record: any) =>
|
||||
record.status == 0
|
||||
? [
|
||||
<Popconfirm
|
||||
title="确定要移除吗?"
|
||||
onConfirm={() => deleteSecondFile(record)}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
>
|
||||
<a key="1">移除</a>
|
||||
</Popconfirm>,
|
||||
<a key="2" onClick={() => editSecondFile(record)}>
|
||||
编辑
|
||||
</a>,
|
||||
<a key="3" onClick={() => viewSecondFile(record)}>
|
||||
详情
|
||||
</a>,
|
||||
]
|
||||
: [
|
||||
<a key="1" onClick={() => viewSecondFile(record)}>
|
||||
详情
|
||||
</a>,
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<ProTable<TableListItem>
|
||||
columns={columns}
|
||||
request={(params, sorter, filter) => {
|
||||
// 表单搜索项会从 params 传入,传递给后端接口。
|
||||
console.log(params, sorter, filter);
|
||||
<ProTable
|
||||
columns={columns}
|
||||
actionRef={secondActionRef}
|
||||
headerTitle={false}
|
||||
search={false}
|
||||
options={false}
|
||||
// dataSource={data}
|
||||
params={{
|
||||
archiveRoundsId: openRowKeys[0],
|
||||
}}
|
||||
request={async (params) =>
|
||||
await getSecondFileList(params).then((res) => {
|
||||
if (res.code == 200) {
|
||||
let data = res.data;
|
||||
data.records.forEach((element: any, index: any) => {
|
||||
element.key = data.size * (data.current - 1) + index + 1;
|
||||
});
|
||||
return Promise.resolve({
|
||||
data: data.records,
|
||||
success: res.success,
|
||||
total: res.data.total,
|
||||
current: res.data.current,
|
||||
});
|
||||
}
|
||||
return Promise.resolve({
|
||||
data: tableListDataSource,
|
||||
success: true,
|
||||
data: [],
|
||||
success: false,
|
||||
total: 0,
|
||||
current: 1,
|
||||
});
|
||||
}}
|
||||
rowKey="key"
|
||||
pagination={{
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
expandable={{ expandedRowRender }}
|
||||
search={false}
|
||||
dateFormatter="string"
|
||||
options={false}
|
||||
/>
|
||||
<CreateDocument title="新增档案文件" onCancel={() => setAddDocument(false)} modalVisible={addDocument} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
export default ProjectArchive
|
||||
})
|
||||
}
|
||||
pagination={{ defaultPageSize: 10 }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
//一级目录columns配置
|
||||
const columns: ProColumns<any>[] = [
|
||||
{
|
||||
title: '业务编号',
|
||||
dataIndex: 'bidSectBizNum',
|
||||
key: 'bidSectBizNum',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '标段名称',
|
||||
dataIndex: 'sectionName',
|
||||
key: 'sectionName',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 120,
|
||||
render: (_, record) => (
|
||||
<Tag color={record.status == 1 ? 'green' : ''}>
|
||||
{record.status == 1 ? '已归档' : '未归档'}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'option',
|
||||
valueType: 'option',
|
||||
width: 164,
|
||||
render: (_, record) =>
|
||||
record.status == 0
|
||||
? [
|
||||
<a key="1" onClick={(e) => addArchive(e, record)}>
|
||||
<PlusOutlined />
|
||||
新增
|
||||
</a>,
|
||||
<a key="2" onClick={(e) => showPromiseConfirm(e, record)}>
|
||||
<EditOutlined />
|
||||
归档
|
||||
</a>,
|
||||
]
|
||||
: null,
|
||||
},
|
||||
];
|
||||
//新增档案文件
|
||||
const addArchive = (e: any, param: any) => {
|
||||
e.stopPropagation();
|
||||
setModalTitle('新增档案文件');
|
||||
setFirstDataRecord(param);
|
||||
setAddDocument(true);
|
||||
};
|
||||
|
||||
//归档操作
|
||||
const showPromiseConfirm = (e: any, data: any) => {
|
||||
e.stopPropagation();
|
||||
confirm({
|
||||
title: '您想要进行归档操作吗?',
|
||||
icon: <ExclamationCircleOutlined />,
|
||||
content: '注意:归档后将不能进行新增操作',
|
||||
async onOk() {
|
||||
await proArchive(data.id).then((res) => {
|
||||
if (res.code == 200) {
|
||||
message.success('归档完成');
|
||||
firstActionRef.current?.reloadAndRest?.();
|
||||
secondActionRef.current?.reloadAndRest?.();
|
||||
}
|
||||
});
|
||||
},
|
||||
onCancel() {},
|
||||
});
|
||||
};
|
||||
//删除档案文件
|
||||
const deleteSecondFile = async (param: any) => {
|
||||
const success = await handleDelete(param.id);
|
||||
if (success) {
|
||||
if (secondActionRef.current) {
|
||||
secondActionRef.current.reloadAndRest?.();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//编辑档案文件
|
||||
const editSecondFile = (param: any) => {
|
||||
setSecondDataRecord(param);
|
||||
setModalTitle('编辑档案文件');
|
||||
setAddDocument(true);
|
||||
};
|
||||
|
||||
//查看档案文件
|
||||
const viewSecondFile = (param: any) => {
|
||||
setSecondDataRecord(param);
|
||||
setModalTitle('查看档案文件');
|
||||
setViewVisible(true);
|
||||
};
|
||||
|
||||
const onChange = async (value: any, data: any) => {
|
||||
const param = {
|
||||
id: data.id,
|
||||
isPaperFile: value ? '1' : '0',
|
||||
};
|
||||
await updateSecondFile(param).then((res) => {
|
||||
if (res.code == 200) {
|
||||
if (secondActionRef.current) {
|
||||
secondActionRef.current.reloadAndRest?.();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//展开行控制(每次只可展开一行)
|
||||
const onOpenChange = (keys: any) => {
|
||||
const latestOpenKey = keys.find((key: any) => openRowKeys.indexOf(key) === -1);
|
||||
if (totalFirstIds.indexOf(latestOpenKey) === -1) {
|
||||
setOpenRowKeys(keys);
|
||||
} else {
|
||||
setOpenRowKeys(latestOpenKey ? [latestOpenKey] : []);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<ProTable<any>
|
||||
columns={columns}
|
||||
params={{ projectId: getProId() }}
|
||||
request={async (params) =>
|
||||
await getFirstSectionList(params).then((res) => {
|
||||
// 表单搜索项会从 params 传入,传递给后端接口。
|
||||
if (res.code == 200) {
|
||||
let data = res.data.records;
|
||||
setTotalFirstData(data);
|
||||
setTotalFirstIds(data.map((e: { id: any }) => e.id));
|
||||
data.forEach((element: any) => {
|
||||
element.key = element.id;
|
||||
});
|
||||
return Promise.resolve({
|
||||
data: data,
|
||||
success: res.success,
|
||||
total: res.data.total,
|
||||
current: res.data.current,
|
||||
});
|
||||
}
|
||||
return Promise.resolve({
|
||||
data: [],
|
||||
success: false,
|
||||
total: 0,
|
||||
current: 1,
|
||||
});
|
||||
})
|
||||
}
|
||||
rowKey="key"
|
||||
pagination={{
|
||||
showQuickJumper: true,
|
||||
defaultPageSize: 10,
|
||||
}}
|
||||
expandable={{
|
||||
expandRowByClick: true, //点击行展开子表
|
||||
onExpandedRowsChange: (expandedRows) => onOpenChange(expandedRows), //子表展开触发的change
|
||||
expandedRowRender: () => expandedRowRender(), //子表内容
|
||||
expandedRowKeys: openRowKeys, //当前展开的一级
|
||||
}}
|
||||
actionRef={firstActionRef}
|
||||
search={false}
|
||||
dateFormatter="string"
|
||||
options={false}
|
||||
/>
|
||||
<CreateDocument
|
||||
title={modalTitle}
|
||||
onCancel={() => {
|
||||
setSecondDataRecord(undefined);
|
||||
setAddDocument(false);
|
||||
}}
|
||||
onOk={async (value) => {
|
||||
|
||||
let e = value;
|
||||
let success = false;
|
||||
if (e.archiveRoundsId == null || e.archiveRoundsId == '') {
|
||||
e.archiveRoundsId = firstDataRecord.id;
|
||||
success = await handleAdd(e);
|
||||
} else {
|
||||
success = await handleUpdate(e);
|
||||
}
|
||||
if (success == true) {
|
||||
setAddDocument(false);
|
||||
setSecondDataRecord(undefined);
|
||||
if (secondActionRef.current) {
|
||||
secondActionRef.current.reloadAndRest?.();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}}
|
||||
modalVisible={addDocument}
|
||||
archiveData={secondArchiveData}
|
||||
values={secondDataRecord}
|
||||
/>
|
||||
<Details
|
||||
title="查看档案文件"
|
||||
onCancel={() => {
|
||||
setSecondDataRecord(undefined);
|
||||
setViewVisible(false);
|
||||
}}
|
||||
modalVisible={viewVisible}
|
||||
archiveData={secondArchiveData}
|
||||
values={secondDataRecord}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
export default ProjectArchive;
|
||||
|
96
src/pages/Archive/ProjectArchive/service.ts
Normal file
96
src/pages/Archive/ProjectArchive/service.ts
Normal file
@ -0,0 +1,96 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
/**
|
||||
* 归档列表-获取一级列表标段信息列表
|
||||
* @param param
|
||||
*/
|
||||
export async function getFirstSectionList(param: any) {
|
||||
return request('/api/biz-service-ebtp-archive/v1/archiveRounds/getPage', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...param,
|
||||
basePageRequest: {
|
||||
pageNo: param.current,
|
||||
pageSize: param.pageSize,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档列表-获取二级列表附件信息列表
|
||||
* @param param
|
||||
*/
|
||||
export async function getSecondFileList(param: any) {
|
||||
return request('/api/biz-service-ebtp-archive/v1/archiveFile/getPage', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...param,
|
||||
basePageRequest: {
|
||||
pageNo: param.current,
|
||||
pageSize: param.pageSize,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档列表-二级附件列表增加
|
||||
* @param param
|
||||
*/
|
||||
export async function addSecondFile(param: any) {
|
||||
return request('/api/biz-service-ebtp-archive/v1/archiveFile', {
|
||||
method: 'POST',
|
||||
data: param
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档列表-二级附件列表修改
|
||||
* @param param
|
||||
*/
|
||||
export async function updateSecondFile(param: any) {
|
||||
return request('/api/biz-service-ebtp-archive/v1/archiveFile', {
|
||||
method: 'PUT',
|
||||
data: param
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档列表-二级附件列表删除
|
||||
* @param param
|
||||
*/
|
||||
export async function deleteSecondFile(param: any) {
|
||||
return request('/api/biz-service-ebtp-archive/v1/archiveFile/' + param, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档列表-新增二级上传文件-获取业务id
|
||||
*/
|
||||
export async function getSecondBusinessId() {
|
||||
return request('/api/core-service-ebtp-updownload/v1/business/id', {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档列表-新增二级查询归档目录
|
||||
* @param param
|
||||
*/
|
||||
export async function getSecondArchiveDirectory(param: any) {
|
||||
return request(`/api/biz-service-ebtp-archive/v1/archiveLink/getListByDefId/` + param, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档列表-项目归档
|
||||
* @param param
|
||||
*/
|
||||
export async function proArchive(param: any) {
|
||||
return request(`/api/biz-service-ebtp-archive/v1/archiveRounds/archive/` + param, {
|
||||
method: 'PUT',
|
||||
});
|
||||
}
|
50
src/pages/Archive/ProjectArchive/utils.ts
Normal file
50
src/pages/Archive/ProjectArchive/utils.ts
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 新增档案文件
|
||||
* @param fields
|
||||
*/
|
||||
|
||||
import { message } from "antd";
|
||||
import { addSecondFile, deleteSecondFile, updateSecondFile } from "./service";
|
||||
|
||||
export const handleAdd = async (fields: any) => {
|
||||
try {
|
||||
await addSecondFile({...fields});
|
||||
message.success('添加成功');
|
||||
return true;
|
||||
} catch (error) {
|
||||
message.error('添加失败');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改档案文件
|
||||
* @param fields
|
||||
*/
|
||||
|
||||
export const handleUpdate = async (fields: any) => {
|
||||
try {
|
||||
await updateSecondFile({...fields});
|
||||
message.success('修改成功');
|
||||
return true;
|
||||
} catch (error) {
|
||||
message.error('修改失败');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除档案文件
|
||||
* @param fields
|
||||
*/
|
||||
|
||||
export const handleDelete = async (fields: any) => {
|
||||
try {
|
||||
await deleteSecondFile(fields);
|
||||
message.success('删除成功');
|
||||
return true;
|
||||
} catch (error) {
|
||||
message.error('删除失败');
|
||||
return false;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user