Commit 09460346 authored by 涂伟's avatar 涂伟

fix: '视频配置导入导出功能添加'

parent f643013b
Pipeline #73235 passed with stages
...@@ -14,6 +14,9 @@ import { ...@@ -14,6 +14,9 @@ import {
Tooltip, Tooltip,
Popconfirm, Popconfirm,
notification, notification,
Upload,
Modal,
message,
} from 'antd'; } from 'antd';
import { import {
SyncOutlined, SyncOutlined,
...@@ -25,10 +28,17 @@ import { ...@@ -25,10 +28,17 @@ import {
ZoomInOutlined, ZoomInOutlined,
CaretUpFilled, CaretUpFilled,
CaretDownFilled, CaretDownFilled,
ExportOutlined,
ImportOutlined,
DownloadOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import voca from 'voca'; import voca from 'voca';
import styles from './index.less'; import styles from './index.less';
import { GetVideoConfigList, deleteInsertVideoConfig } from '@/services/videoManger/videoManger'; import {
GetVideoConfigList,
deleteInsertVideoConfig,
ImportVideoConfig,
} from '@/services/videoManger/videoManger';
import AddModal from './AddModal'; import AddModal from './AddModal';
import CheckModal from './CheckModal'; import CheckModal from './CheckModal';
import VideoModal from './VideoModal'; import VideoModal from './VideoModal';
...@@ -36,6 +46,8 @@ import DHModal from './DHModal'; ...@@ -36,6 +46,8 @@ import DHModal from './DHModal';
import HKModal from './HKModal'; import HKModal from './HKModal';
import AddAllModal from './AddAllModal'; import AddAllModal from './AddAllModal';
const path = require('path');
const videoManager = () => { const videoManager = () => {
const [configurationType, setConfigurationType] = useState('1'); const [configurationType, setConfigurationType] = useState('1');
const [loading, setLoading] = useState(false); // 加载 const [loading, setLoading] = useState(false); // 加载
...@@ -414,6 +426,40 @@ const videoManager = () => { ...@@ -414,6 +426,40 @@ const videoManager = () => {
setAddVisible(false); setAddVisible(false);
setFlag(flag + 1); setFlag(flag + 1);
}; };
// 导入
const beforeUpload = val => {
const formData = new FormData();
formData.append('file', val);
console.log(formData, val, 'OK');
ImportVideoConfig(formData).then(response => {
if (response.code === 0) {
setFlag(flag + 1);
message.success('导入成功');
} else {
message.error(response.msg);
}
});
return false;
};
const downLoadObj = {
'1': '萤石云-视频导入模板',
'2': '海康-视频导入模板',
'3': '海康1-2-视频导入模板',
'4': '海康NVR-视频导入模板',
'5': '大华-视频导入模板',
'6': '海康ISC-视频导入模板',
};
// 下载模板
const downloadFile = () => {
let downloadLink = document.createElement('a');
downloadLink.href = path.join(__dirname, `/civmanage/${downLoadObj[configurationType]}.xlsx`);
downloadLink.download = downLoadObj[configurationType];
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
};
return ( return (
<div className={styles.videoManagerContainer}> <div className={styles.videoManagerContainer}>
<Row className={styles.head}> <Row className={styles.head}>
...@@ -463,6 +509,16 @@ const videoManager = () => { ...@@ -463,6 +509,16 @@ const videoManager = () => {
> >
新增 新增
</Button> */} </Button> */}
<div style={{ float: 'right' }}>
<Upload showUploadList={false} accept=".xlsx" beforeUpload={beforeUpload}>
<Button style={{ marginLeft: '10px' }} type="primary" ghost>
<div style={{ display: 'flex', alignItems: 'center' }}>
<ImportOutlined style={{ marginRight: '5px' }} />
<div>导入</div>
</div>
</Button>
</Upload>
</div>
<Button <Button
icon={<PlusOutlined className={styles.icon} />} icon={<PlusOutlined className={styles.icon} />}
onClick={addAll} onClick={addAll}
...@@ -474,6 +530,17 @@ const videoManager = () => { ...@@ -474,6 +530,17 @@ const videoManager = () => {
> >
新增 新增
</Button> </Button>
<Button
icon={<DownloadOutlined className={styles.icon} />}
onClick={downloadFile}
style={{
float: 'right',
verticalAlign: 'middle',
marginRight: '10px',
}}
>
下载模板
</Button>
</Col> </Col>
</Row> </Row>
......
...@@ -15,3 +15,7 @@ export const editInsertVideoConfig = data => ...@@ -15,3 +15,7 @@ export const editInsertVideoConfig = data =>
// 删除配置 // 删除配置
export const deleteInsertVideoConfig = data => export const deleteInsertVideoConfig = data =>
post(`${PUBLISH_SERVICE}/VideoManager/InsertVideoConfig?type=delete`, data); post(`${PUBLISH_SERVICE}/VideoManager/InsertVideoConfig?type=delete`, data);
// 导入配置
export const ImportVideoConfig = data =>
post(`${PUBLISH_SERVICE}/VideoManager/ImportVideoConfig`, data);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment