|
@@ -1,79 +1,76 @@
|
|
|
-import { PageContainer } from "@ant-design/pro-components"
|
|
|
-import { Card, Table, Tag } from "antd"
|
|
|
-import Columns from "./tableConfig"
|
|
|
-import { useRequest } from "ahooks"
|
|
|
-import { downloadEscalationApi, getDownloadListApi } from "@/services/task-api/download"
|
|
|
-import { useEffect, useState } from "react"
|
|
|
-import { request } from "@umijs/max"
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * 下载任务
|
|
|
- * @returns
|
|
|
- */
|
|
|
-const Download: React.FC = () => {
|
|
|
-
|
|
|
- /********************************/
|
|
|
- const [queryForm, setQueryForm] = useState<TASKAPI.DownloadList>({ pageNum: 1, pageSize: 20 })
|
|
|
- const getDownloadList = useRequest(getDownloadListApi, { manual: true })
|
|
|
- const downloadEscalation = useRequest(downloadEscalationApi, { manual: true })
|
|
|
- /********************************/
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- getDownloadList.runAsync(queryForm)
|
|
|
- }, [queryForm])
|
|
|
-
|
|
|
- const download = (url: string, userMaterialId: number) => {
|
|
|
- downloadEscalation.runAsync({ userMaterialId }).then(res => {
|
|
|
- const fileName = 'downloaded.mp4'; // 可以自定义下载的文件名
|
|
|
- let link = url
|
|
|
- let x = new XMLHttpRequest()
|
|
|
- x.open('GET', link, true)
|
|
|
- x.responseType = 'blob'
|
|
|
- x.onload = (e) => {
|
|
|
- let url = window.URL.createObjectURL(x.response)
|
|
|
- let a = document.createElement('a')
|
|
|
- a.href = url
|
|
|
- a.download = fileName
|
|
|
- a.click()
|
|
|
- }
|
|
|
- x.send()
|
|
|
- getDownloadList.refresh()
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- return <PageContainer
|
|
|
- extra={<a onClick={() => getDownloadList.refresh()}>刷新</a>}
|
|
|
- >
|
|
|
- <Card
|
|
|
- style={{
|
|
|
- borderRadius: 8,
|
|
|
- }}
|
|
|
- >
|
|
|
- <Table
|
|
|
- columns={Columns(download)}
|
|
|
- dataSource={getDownloadList?.data?.data?.records}
|
|
|
- scroll={{ x: 1000 }}
|
|
|
- rowKey={(s) => {
|
|
|
- return s.id
|
|
|
- }}
|
|
|
- size='small'
|
|
|
- pagination={{
|
|
|
- total: 0,
|
|
|
- showTotal: (total) => <Tag color="cyan">总共{total}数据</Tag>,
|
|
|
- showSizeChanger: true,
|
|
|
- showLessItems: true,
|
|
|
- defaultCurrent: 1,
|
|
|
- defaultPageSize: 20,//默认初始的每页条数
|
|
|
- current: getDownloadList?.data?.data?.current || 1,
|
|
|
- pageSize: getDownloadList?.data?.data?.size || 20,
|
|
|
- onChange: (page, pageSize) => {
|
|
|
- setQueryForm({ ...queryForm, pageNum: page, pageSize })
|
|
|
- }
|
|
|
- }}
|
|
|
- />
|
|
|
- </Card>
|
|
|
- </PageContainer>
|
|
|
-}
|
|
|
-
|
|
|
-export default Download
|
|
|
+import { downloadEscalationApi, getDownloadListApi } from '@/services/task-api/download';
|
|
|
+import { PageContainer } from '@ant-design/pro-components';
|
|
|
+import { useRequest } from 'ahooks';
|
|
|
+import { Card, Table, Tag } from 'antd';
|
|
|
+import { useEffect, useState } from 'react';
|
|
|
+import Columns from './tableConfig';
|
|
|
+
|
|
|
+/**
|
|
|
+ * 下载任务
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+const Download: React.FC = () => {
|
|
|
+ /********************************/
|
|
|
+ const [queryForm, setQueryForm] = useState<TASKAPI.DownloadList>({ pageNum: 1, pageSize: 20 });
|
|
|
+ const getDownloadList = useRequest(getDownloadListApi, { manual: true });
|
|
|
+ const downloadEscalation = useRequest(downloadEscalationApi, { manual: true });
|
|
|
+ /********************************/
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ getDownloadList.runAsync(queryForm);
|
|
|
+ }, [queryForm]);
|
|
|
+
|
|
|
+ const download = (url: string, userMaterialId: number) => {
|
|
|
+ downloadEscalation.runAsync({ userMaterialId }).then((res) => {
|
|
|
+ const fileName = 'downloaded.mp4'; // 可以自定义下载的文件名
|
|
|
+ let link = url;
|
|
|
+ let x = new XMLHttpRequest();
|
|
|
+ x.open('GET', link, true);
|
|
|
+ x.responseType = 'blob';
|
|
|
+ x.onload = (e) => {
|
|
|
+ let url = window.URL.createObjectURL(x.response);
|
|
|
+ let a = document.createElement('a');
|
|
|
+ a.href = url;
|
|
|
+ a.download = fileName;
|
|
|
+ a.click();
|
|
|
+ };
|
|
|
+ x.send();
|
|
|
+ getDownloadList.refresh();
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ return (
|
|
|
+ <PageContainer extra={<a onClick={() => getDownloadList.refresh()}>刷新</a>}>
|
|
|
+ <Card
|
|
|
+ style={{
|
|
|
+ borderRadius: 8,
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Table
|
|
|
+ columns={Columns(download)}
|
|
|
+ dataSource={getDownloadList?.data?.data?.records}
|
|
|
+ scroll={{ x: 1000 }}
|
|
|
+ rowKey={(s) => {
|
|
|
+ return s.id;
|
|
|
+ }}
|
|
|
+ size="small"
|
|
|
+ pagination={{
|
|
|
+ total: getDownloadList?.data?.data?.total,
|
|
|
+ showTotal: (total) => <Tag color="cyan">总共{total}数据</Tag>,
|
|
|
+ showSizeChanger: true,
|
|
|
+ showLessItems: true,
|
|
|
+ defaultCurrent: 1,
|
|
|
+ defaultPageSize: 20, //默认初始的每页条数
|
|
|
+ current: getDownloadList?.data?.data?.current || 1,
|
|
|
+ pageSize: getDownloadList?.data?.data?.size || 20,
|
|
|
+ onChange: (page, pageSize) => {
|
|
|
+ setQueryForm({ ...queryForm, pageNum: page, pageSize });
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Card>
|
|
|
+ </PageContainer>
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export default Download;
|