Ver código fonte

Merge branch 'dev1.0' of http://git.ycjcjy.com/civilized_city/pc-admin into dev1.0

张涛 2 anos atrás
pai
commit
ea384c467f

+ 12
- 2
src/pages/check/components/LocTable.jsx Ver arquivo

2
 import { Link } from 'react-router-dom';
2
 import { Link } from 'react-router-dom';
3
 import useBool from '@/utils/hooks/useBool';
3
 import useBool from '@/utils/hooks/useBool';
4
 import { Table, Space, Button, Row, Col, Card } from 'antd';
4
 import { Table, Space, Button, Row, Col, Card } from 'antd';
5
-import { getTaCheckItem } from '@/service/tacheckitem';
5
+import { getTaCheckItem, exportTaCheckItem } from '@/service/tacheckitem';
6
 import QuList from './QuList';
6
 import QuList from './QuList';
7
 import LocForm from './LocForm';
7
 import LocForm from './LocForm';
8
 import styles from './style.module.less';
8
 import styles from './style.module.less';
14
   const [curItem, setCurItem] = React.useState();
14
   const [curItem, setCurItem] = React.useState();
15
   const [loading, startLoading, stopLoading] = useBool();
15
   const [loading, startLoading, stopLoading] = useBool();
16
   const [open, setOpen] = React.useState(false);
16
   const [open, setOpen] = React.useState(false);
17
+  const [expLoading, startExpLoading, stopExpLoading] = useBool();
17
 
18
 
18
   const columns = [
19
   const columns = [
19
     {
20
     {
107
     setOpen(true);
108
     setOpen(true);
108
   }
109
   }
109
 
110
 
111
+  const onExport = () => {
112
+    startExpLoading();
113
+    exportTaCheckItem(checkId).then(() => {
114
+      stopExpLoading();
115
+    }).catch(() => {
116
+      stopExpLoading();
117
+    });
118
+  }
119
+
110
   const onChange = (item) => {
120
   const onChange = (item) => {
111
     const newList = list.map(x => x.itemId === item.itemId ? item : x);
121
     const newList = list.map(x => x.itemId === item.itemId ? item : x);
112
     setList(newList);
122
     setList(newList);
130
   return (
140
   return (
131
     <Row gutter={24}>
141
     <Row gutter={24}>
132
       <Col span={12}>
142
       <Col span={12}>
133
-        <Card>
143
+        <Card extra={<Button loading={expLoading} type="primary" onClick={onExport}>导出</Button>}>
134
           <Table
144
           <Table
135
             sticky
145
             sticky
136
             summary={() => (
146
             summary={() => (

+ 5
- 2
src/pages/check/index.jsx Ver arquivo

94
       dataIndex: "surveyScore",
94
       dataIndex: "surveyScore",
95
       hideInSearch: true,
95
       hideInSearch: true,
96
       render: (_, row) => {
96
       render: (_, row) => {
97
+        const num = row.surveyNum || 0;
98
+        if (num === 0) return '-';
99
+
97
         const origin = row.surveyScore || 0;
100
         const origin = row.surveyScore || 0;
98
         const percent = row.surveyScorePercent || 0;
101
         const percent = row.surveyScorePercent || 0;
99
-        const score = Number(origin * percent).toFixed(2);
102
+        const score = Number(origin / num * percent).toFixed(2);
100
 
103
 
101
-        return `${origin} * ${percent * 100}% = ${score}`;
104
+        return `${origin} / ${num} * ${percent * 100}% = ${score}`;
102
       },
105
       },
103
     },
106
     },
104
     {
107
     {

+ 4
- 1
src/service/tacheckitem.js Ver arquivo

32
  * @param {*} typeId 
32
  * @param {*} typeId 
33
  * @returns 
33
  * @returns 
34
  */
34
  */
35
-export const getByCheckId = (checkId, typeId) => request(`/api/taCheck/${checkId}/item/${typeId}`)
35
+export const getByCheckId = (checkId, typeId) => request(`/api/taCheck/${checkId}/item/${typeId}`)
36
+
37
+
38
+export const exportTaCheckItem = (checkId) => request(`/api/taCheck/${checkId}/loc/export`, { method: 'post', download: true });

+ 1
- 1
src/utils/request.js Ver arquivo

52
 
52
 
53
     const { data, config } = response;
53
     const { data, config } = response;
54
 
54
 
55
-    if (config.download && !data.code) {
55
+    if (config.download && !data?.code) {
56
       return downloadBlob(response, "下载文件");
56
       return downloadBlob(response, "下载文件");
57
     }
57
     }
58
 
58