Explorar el Código

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

张涛 hace 2 años
padre
commit
ea384c467f

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

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

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

@@ -94,11 +94,14 @@ export default (props) => {
94 94
       dataIndex: "surveyScore",
95 95
       hideInSearch: true,
96 96
       render: (_, row) => {
97
+        const num = row.surveyNum || 0;
98
+        if (num === 0) return '-';
99
+
97 100
         const origin = row.surveyScore || 0;
98 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 fichero

@@ -32,4 +32,7 @@ export const deleteTaCheckItem = (id) => request(`/api/taCheckItem/${id}`, { met
32 32
  * @param {*} typeId 
33 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 fichero

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