wjx 1 год назад
Родитель
Сommit
db19df0386
4 измененных файлов с 116 добавлено и 94 удалено
  1. 32 13
      src/pages/404.tsx
  2. 76 79
      src/pages/Download/index.tsx
  3. 4 1
      src/pages/MyTask/taskModal.tsx
  4. 4 1
      src/pages/Opus/opusRoll.tsx

+ 32 - 13
src/pages/404.tsx

@@ -1,18 +1,37 @@
-import { history } from '@umijs/max';
+import { history, useModel } from '@umijs/max';
 import { Button, Result } from 'antd';
 import React from 'react';
 
-const NoFoundPage: React.FC = () => (
-  <Result
-    status="404"
-    title="404"
-    subTitle="Sorry, the page you visited does not exist."
-    extra={
-      <Button type="primary" onClick={() => history.push('/')}>
-        Back Home
-      </Button>
-    }
-  />
-);
+const NoFoundPage: React.FC = () => {
+  const { initialState } = useModel('@@initialState');
+
+  return (
+    <Result
+      status="404"
+      title="404"
+      subTitle="Sorry, the page you visited does not exist."
+      extra={
+        <Button
+          type="primary"
+          onClick={() => {
+            // 判断不同角色登录成功跳到哪里
+            if (initialState?.currentUser?.role && localStorage.getItem('Admin-Token')) {
+              const urlParams = new URL(window.location.href).searchParams;
+              let defaultPath = '/task';
+              if (initialState.currentUser.role === 'USER_ROLE_MEMBER') {
+                defaultPath = '/myTask';
+              }
+              history.push(defaultPath);
+            } else {
+              history.push('/');
+            }
+          }}
+        >
+          Back Home
+        </Button>
+      }
+    />
+  );
+};
 
 export default NoFoundPage;

+ 76 - 79
src/pages/Download/index.tsx

@@ -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;

+ 4 - 1
src/pages/MyTask/taskModal.tsx

@@ -452,7 +452,10 @@ const TaskModal: React.FC<Props> = ({ initialValues, visible, onChange, onClose
             )}
             <Form.Item label={<strong>素材示例类型</strong>} name="materialExampleType">
               <Select
-                placeholder="请选择任务紧急度"
+                placeholder="请选择素材示例类型"
+                onChange={() => {
+                  form.setFieldsValue({ materialExamples: undefined });
+                }}
                 options={Object.keys(MaterialExampleEnum).map((key) => ({
                   label: (MaterialExampleEnum as any)[key],
                   value: key,

+ 4 - 1
src/pages/Opus/opusRoll.tsx

@@ -117,7 +117,10 @@ const OpusRoll: React.FC<Props> = ({
                     </Typography.Text>
                   </Flex>
                   <Flex justify="space-between">
-                    <Typography.Text>素材ID:{list.taskId}</Typography.Text>
+                    <Typography.Text>素材ID:{list.id}</Typography.Text>
+                    <Typography.Text>任务ID:{list.taskId}</Typography.Text>
+                  </Flex>
+                  <Flex justify="space-between">
                     {!list.cost && list.cost !== 0 ? null : (
                       <Typography.Text>消耗:{list.cost}</Typography.Text>
                     )}