张涛 2 年前
父节点
当前提交
de88f5ab61
共有 3 个文件被更改,包括 164 次插入104 次删除
  1. 10
    10
      src/App.jsx
  2. 48
    7
      src/pages/issue/index.jsx
  3. 106
    87
      src/utils/request.js

+ 10
- 10
src/App.jsx 查看文件

@@ -1,14 +1,14 @@
1
-import React from 'react';
2
-import 'dayjs/locale/zh-cn';
3
-import locale from 'antd/locale/zh_CN';
4
-import { ConfigProvider, App as Antd } from 'antd';
5
-import Router from './routes/Router'
6
-import { useModel } from './store';
1
+import React from "react";
2
+import "dayjs/locale/zh-cn";
3
+import locale from "antd/es/locale/zh_CN";
4
+import { ConfigProvider, App as Antd } from "antd";
7 5
 
8
-function App() {
6
+import Router from "./routes/Router";
7
+import { useModel } from "./store";
9 8
 
10
-  const { antThemeData } = useModel('system');
11
-  const theme = React.useMemo(() => ({token: antThemeData}), [antThemeData]);
9
+function App() {
10
+  const { antThemeData } = useModel("system");
11
+  const theme = React.useMemo(() => ({ token: antThemeData }), [antThemeData]);
12 12
 
13 13
   return (
14 14
     <ConfigProvider locale={locale} theme={theme}>
@@ -19,4 +19,4 @@ function App() {
19 19
   );
20 20
 }
21 21
 
22
-export default App
22
+export default App;

+ 48
- 7
src/pages/issue/index.jsx 查看文件

@@ -8,6 +8,8 @@ import {
8 8
   exportTaIssue,
9 9
   exportTaOrgIssue,
10 10
 } from "@/service/taissue";
11
+import { getTdIssueType } from "@/service/tdissuetype";
12
+
11 13
 import { getTdLocType } from "@/service/tdloctype";
12 14
 import { getSysOrg } from "@/service/sysorg";
13 15
 import { queryDict } from "@/utils/request";
@@ -21,10 +23,15 @@ const queryLocType = queryDict(getTdLocType, {
21 23
   labelKey: "name",
22 24
   valueKey: "typeId",
23 25
 });
26
+const getTdList = queryDict(getTdIssueType, {
27
+  labelKey: "name",
28
+  valueKey: "typeId",
29
+});
24 30
 
25 31
 const yestoday = dayjs().subtract(1, "day").format("YYYY-MM-DD");
26 32
 export default (props) => {
27 33
   const [loading, startLoading, stopLoading] = useBool();
34
+  const [loading1, startLoading1, stopLoading1] = useBool();
28 35
   const navigate = useNavigate();
29 36
   const paramsRef = React.useRef();
30 37
 
@@ -42,6 +49,15 @@ export default (props) => {
42 49
       title: "问题单号",
43 50
       dataIndex: "issueId",
44 51
     },
52
+    {
53
+      title: "问题类别",
54
+      dataIndex: "typeId",
55
+      valueType: "select",
56
+      request: getTdList,
57
+      render: (_, row) => {
58
+        return <span>{row.typeName}</span>;
59
+      },
60
+    },
45 61
     {
46 62
       title: "创建时间",
47 63
       dataIndex: "createdAt",
@@ -58,7 +74,7 @@ export default (props) => {
58 74
     },
59 75
     {
60 76
       title: "办结时间",
61
-      dataIndex: "createdAts",
77
+      dataIndex: "endDateEnd",
62 78
       valueType: "dateRange",
63 79
       hideInTable: true,
64 80
       search: {
@@ -108,7 +124,7 @@ export default (props) => {
108 124
       render: (_, row) => {
109 125
         if (row.processNode != "03" && yestoday > row.expireDate) {
110 126
           return <Badge status="error" text="已逾期" />;
111
-        } else if(row.processNode=="03"&& yestoday > row.expireDate){
127
+        } else if (row.processNode == "03" && yestoday > row.expireDate) {
112 128
           return <Badge status="warning" text="延期办结" />;
113 129
         } else {
114 130
           const st = processStatus.filter((x) => x.value == row.processNode)[0];
@@ -124,12 +140,23 @@ export default (props) => {
124 140
     {
125 141
       title: "上报人",
126 142
       dataIndex: "userName",
127
-      hideInSearch: true,
143
+      // hideInSearch: true,
144
+    },
145
+    {
146
+      title: "办结时间",
147
+      dataIndex: "endDate",
148
+      valueType: "date",
149
+      search: false,
150
+      ellipsis: true,
151
+      render: (_, row) => {
152
+        if (row.endDate) return row.endDate.replace("T", "-");
153
+        return row.endDate;
154
+      },
128 155
     },
129 156
   ];
130
-
157
+  // 带图导出
131 158
   const onExport = () => {
132
-    console.log(paramsRef)
159
+    paramsRef.current.withImage = true;
133 160
     startLoading();
134 161
     exportFn(paramsRef.current)
135 162
       .then(() => {
@@ -139,7 +166,18 @@ export default (props) => {
139 166
         stopLoading();
140 167
       });
141 168
   };
142
-
169
+  // 不带图导出
170
+  const onExportImg = () => {
171
+    paramsRef.current.withImage = false;
172
+    startLoading1();
173
+    exportFn(paramsRef.current)
174
+      .then(() => {
175
+        stopLoading1();
176
+      })
177
+      .catch(() => {
178
+        stopLoading1();
179
+      });
180
+  };
143 181
   const beforeSearchSubmit = (params) => {
144 182
     paramsRef.current = {
145 183
       ...(params || {}),
@@ -166,7 +204,10 @@ export default (props) => {
166 204
       ]}
167 205
       toolBarRender={() => [
168 206
         <Button key="1" type="primary" loading={loading} onClick={onExport}>
169
-          导出
207
+          带图导出
208
+        </Button>,
209
+        <Button key="2" type="primary" loading={loading1} onClick={onExportImg}>
210
+          不带图导出
170 211
         </Button>,
171 212
       ]}
172 213
     />

+ 106
- 87
src/utils/request.js 查看文件

@@ -1,88 +1,99 @@
1 1
 import axios from "axios";
2
-import React from 'react';
3
-import { message } from 'antd';
2
+import React from "react";
3
+import { message } from "antd";
4 4
 
5 5
 const instance = axios.create({
6
-  baseURL: import.meta.env.VITE_SERVER_BASE || '',
6
+  baseURL: import.meta.env.VITE_SERVER_BASE || "",
7 7
   timeout: 10000,
8 8
   withCredentials: false, // 跨域
9 9
 });
10 10
 
11
-
12 11
 // 添加请求拦截器
13
-instance.interceptors.request.use(function (config) {
14
-  const { headers = {}, method = 'get', responseType = 'json', download = false, silent } = config;
15
-  const token = localStorage.getItem('token') || '';
12
+instance.interceptors.request.use(
13
+  function (config) {
14
+    const {
15
+      headers = {},
16
+      method = "get",
17
+      responseType = "json",
18
+      download = false,
19
+      silent,
20
+    } = config;
21
+    const token = localStorage.getItem("token") || "";
22
+
23
+    let noTip = silent;
24
+    if (noTip === undefined) {
25
+      noTip = method.toLocaleLowerCase() === "get" ? true : false;
26
+    }
16 27
 
17
-  let noTip = silent;
18
-  if (noTip === undefined) {
19
-    noTip = method.toLocaleLowerCase() === 'get' ? true : false;
28
+    // 在发送请求之前做些什么
29
+    return {
30
+      ...config,
31
+      silent: noTip,
32
+      timeout: download ? 600000 : 10000,
33
+      headers: {
34
+        "Content-Type": "application/json;charset=utf-8", // charset 防止乱码
35
+        ...headers,
36
+        Authorization: token,
37
+      },
38
+      responseType: download ? "blob" : responseType,
39
+    };
40
+  },
41
+  function (error) {
42
+    // 对请求错误做些什么
43
+    return Promise.reject(error);
20 44
   }
21
-
22
-  // 在发送请求之前做些什么
23
-  return {
24
-    ...config,
25
-    silent: noTip,
26
-    timeout: download ? 600000 : 10000,
27
-    headers: {
28
-      'Content-Type': 'application/json;charset=utf-8', // charset 防止乱码
29
-      ...headers,
30
-      Authorization: token,
31
-    },
32
-    responseType: download ? 'blob' : responseType,
33
-  };
34
-}, function (error) {
35
-  // 对请求错误做些什么
36
-  return Promise.reject(error);
37
-});
45
+);
38 46
 
39 47
 // 添加响应拦截器
40
-instance.interceptors.response.use(function (response) {
41
-  // 2xx 范围内的状态码都会触发该函数。
42
-  // 对响应数据做点什么
43
-
44
-  const { data, config } = response;
48
+instance.interceptors.response.use(
49
+  function (response) {
50
+    // 2xx 范围内的状态码都会触发该函数。
51
+    // 对响应数据做点什么
45 52
 
46
-  if (config.download && !data.code) {
47
-    return downloadBlob(response, '下载文件');
48
-  }
53
+    const { data, config } = response;
49 54
 
50
-  if (data.code === 1000) {
51
-    if (data.data?.token) {
52
-      localStorage.setItem('token', data.data.token);
55
+    if (config.download && !data.code) {
56
+      return downloadBlob(response, "下载文件");
53 57
     }
54 58
 
55
-    if (!config.silent) {
56
-      message.success('操作成功');
59
+    if (data.code === 1000) {
60
+      if (data.data?.token) {
61
+        localStorage.setItem("token", data.data.token);
62
+      }
63
+
64
+      if (!config.silent) {
65
+        message.success("操作成功");
66
+      }
67
+
68
+      return data.data;
69
+    } else if (data.code === 1001) {
70
+      if (!config.silent) {
71
+        message.error("未登录或者超时, 请重新登录");
72
+      }
73
+    } else {
74
+      console.log(config);
75
+      if (!config.silent) {
76
+        const errMsg = data.message || "系统错误";
77
+        message.error(errMsg.indexOf("exception") > -1 ? "服务异常" : errMsg);
78
+      }
57 79
     }
58 80
 
59
-    return data.data;
60
-  } else if (data.code === 1001) {
61
-    if (!config.silent) {
62
-      message.error('未登录或者超时, 请重新登录');
63
-    }
64
-  } else {
65
-    console.log(config)
66
-    if (!config.silent) {
67
-      const errMsg = data.message || '系统错误';
68
-      message.error(errMsg.indexOf('exception') > -1 ? '服务异常' : errMsg);
69
-    }
70
-  }
81
+    return Promise.reject(response);
82
+  },
83
+  function (error) {
84
+    // 超出 2xx 范围的状态码都会触发该函数。
85
+    // 对响应错误做点什么
71 86
 
72
-  return Promise.reject(response);
73
-}, function (error) {
74
-  // 超出 2xx 范围的状态码都会触发该函数。
75
-  // 对响应错误做点什么
87
+    console.error(error);
76 88
 
77
-  console.error(error);
78
-
79
-  message.error('网络超时或异常...')
80
-  return Promise.reject("网络异常, 请重试...");
81
-});
89
+    message.error("网络超时或异常...");
90
+    return Promise.reject("网络异常, 请重试...");
91
+  }
92
+);
82 93
 
83 94
 export default instance;
84 95
 
85
-export function queryTable (apiRequest) {
96
+export function queryTable(apiRequest) {
86 97
   return function (params) {
87 98
     const { pageSize } = params;
88 99
     return apiRequest({
@@ -105,7 +116,10 @@ export function queryTable (apiRequest) {
105 116
   };
106 117
 }
107 118
 
108
-export function queryDict (apiRequest, {labelKey = 'name', valueKey = 'id'} = {}) {
119
+export function queryDict(
120
+  apiRequest,
121
+  { labelKey = "name", valueKey = "id" } = {}
122
+) {
109 123
   return function (params) {
110 124
     const { current, pageSize, ...leftParams } = params || {};
111 125
     return apiRequest({
@@ -128,48 +142,53 @@ export function queryDict (apiRequest, {labelKey = 'name', valueKey = 'id'} = {}
128 142
   };
129 143
 }
130 144
 
131
-export function restful (url) {
132
-  const list = params => instance.get(url, { params });
133
-  const get = id => instance.get(`${url}/${id}`);
134
-  const add = data => instance.post(url, data);
145
+export function restful(url) {
146
+  const list = (params) => instance.get(url, { params });
147
+  const get = (id) => instance.get(`${url}/${id}`);
148
+  const add = (data) => instance.post(url, data);
135 149
   const update = (id, data) => instance.put(`${url}/${id}`, data);
136
-  const del = id => instance.delete(`${url}/${id}`);
150
+  const del = (id) => instance.delete(`${url}/${id}`);
137 151
 
138 152
   return [list, get, add, update, del];
139 153
 }
140 154
 
141
-export function useRequest (fn) {
155
+export function useRequest(fn) {
142 156
   const [loading, setLoading] = React.useState(false);
143 157
 
144
-  const p = (...args) => new Promise((resolve, reject) => {
145
-    setLoading(true);
146
-    fn(...args).then(res => {
147
-      setLoading(false);
148
-      resolve(res);
149
-    }).catch(e => {
150
-      setLoading(false);
151
-      reject(e);
158
+  const p = (...args) =>
159
+    new Promise((resolve, reject) => {
160
+      setLoading(true);
161
+      fn(...args)
162
+        .then((res) => {
163
+          setLoading(false);
164
+          resolve(res);
165
+        })
166
+        .catch((e) => {
167
+          setLoading(false);
168
+          reject(e);
169
+        });
152 170
     });
153
-  });
154 171
 
155
-  return [loading, p]
172
+  return [loading, p];
156 173
 }
157 174
 
158
-function downloadBlob (response) {
159
-  let fileName = '未知文件';
160
-  const contentType = response.headers['content-type'];
161
-  const contentDisposition = response.headers['content-disposition'];
175
+function downloadBlob(response) {
176
+  let fileName = "未知文件";
177
+  const contentType = response.headers["content-type"];
178
+  const contentDisposition = response.headers["content-disposition"];
162 179
   if (contentDisposition) {
163
-    const parts = contentDisposition.split(';filename=');
180
+    const parts = contentDisposition.split(";filename=");
164 181
     if (parts[1]) {
165 182
       fileName = decodeURIComponent(parts[1]);
166 183
     }
167 184
   }
168 185
 
169
-  const url = window.URL.createObjectURL(new Blob([response.data], { type: contentType }));
170
-  const link = document.createElement('a');
186
+  const url = window.URL.createObjectURL(
187
+    new Blob([response.data], { type: contentType })
188
+  );
189
+  const link = document.createElement("a");
171 190
   link.href = url;
172
-  link.setAttribute('download', fileName);
191
+  link.setAttribute("download", fileName);
173 192
   link.click();
174 193
   window.URL.revokeObjectURL(url);
175 194
 }