Yansen 2 gadus atpakaļ
vecāks
revīzija
8693545edb

+ 5
- 1
src/components/Page/index.jsx Parādīt failu

@@ -29,7 +29,11 @@ const Title = (props) => {
29 29
     e.preventDefault();
30 30
     e.stopPropagation();
31 31
 
32
-    navigate(-1);
32
+    if (history.length > 1) {
33
+      navigate(-1);
34
+    } else { 
35
+      window.close();
36
+    }
33 37
   }
34 38
 
35 39
   return (

+ 18
- 0
src/components/TargetLink/index.jsx Parādīt failu

@@ -0,0 +1,18 @@
1
+import React from 'react'
2
+
3
+export default (props) => {
4
+
5
+  const { to, route = 'hash' } = props;
6
+
7
+  const href = React.useMemo(() => {
8
+    if (route === 'hash') {
9
+      const prefix = window.location.href.replace(/#.*$/, '');
10
+      return `${prefix}#${to}`;
11
+    }
12
+    return to;
13
+  }, [route, to]);
14
+
15
+  return (
16
+    <a target="_blank" href={href}>{props.children}</a>
17
+  )
18
+}

+ 0
- 1
src/pages/check/Edit.jsx Parādīt failu

@@ -32,7 +32,6 @@ export default (props) => {
32 32
     }
33 33
   }, [id]);
34 34
 
35
-  console.log('-----survey----->', survey);
36 35
   return (
37 36
     <Page back>
38 37
       <CheckForm

+ 8
- 25
src/pages/check/components/LocForm.jsx Parādīt failu

@@ -8,8 +8,8 @@ import { getTaCheckItem, postTaCheckItem } from '@/service/tacheckitem';
8 8
 const LocForm = (props) => {
9 9
   const { checkItem, open, onOpenChange, onChange, itemId, checkId } = props;
10 10
 
11
-  const [loading, startLoading, stopLoading] = useBool();
12
-  const [list, setList] = React.useState();
11
+  // const [loading, startLoading, stopLoading] = useBool();
12
+  // const [list, setList] = React.useState();
13 13
   // const [listData, setListData] = React.useState();
14 14
 
15 15
   const [form] = Form.useForm();
@@ -34,35 +34,18 @@ const LocForm = (props) => {
34 34
     }
35 35
   }, [checkItem]);
36 36
 
37
-  React.useEffect(() => {
38
-    if (itemId) {
39
-      startLoading();
40
-      getTaCheckItemQu({ pageSize: 500, itemId }).then((res) => {
41
-        stopLoading();
42
-        setList(...res.records);
43
-      }).catch(() => {
44
-        stopLoading();
45
-      });
46
-    }
47
-  }, [itemId]);
48
-
49 37
   // React.useEffect(() => {
50
-  //   if (checkId) {
38
+  //   if (itemId) {
51 39
   //     startLoading();
52
-  //     getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then(res => {
53
-  //       setListData(...res.records || []);
40
+  //     getTaCheckItemQu({ pageSize: 500, itemId }).then((res) => {
54 41
   //       stopLoading();
42
+  //       setList(...res.records);
55 43
   //     }).catch(() => {
56 44
   //       stopLoading();
57 45
   //     });
58 46
   //   }
59
-  // }, [checkId]);
60
-
61
-
47
+  // }, [itemId]);
62 48
 
63
-  // console.log('list?.maxScore', list?.maxScore);
64
-  // console.log('checkItem?.answerNum', checkItem?.answerNum);
65
-  // console.log('list?.maxScore / checkItem?.answerNum', list?.maxScore / checkItem?.answerNum);
66 49
   return (
67 50
     <ModalForm
68 51
       title={`${checkItem?.name} 维护`}
@@ -72,11 +55,11 @@ const LocForm = (props) => {
72 55
       onFinish={onFinish}
73 56
       onOpenChange={onOpenChange}
74 57
     >
75
-      <ProFormDigit readonly label="分值" value={checkItem?.answerNum == 0 ? 0 : list?.maxScore / checkItem?.answerNum} />
58
+      <ProFormDigit readonly label="分值" name="fullScore" value={checkItem?.fullScore || 0} />
76 59
       <ProFormDigit label="数量" name="num" min={1} fieldProps={{ precision: 0 }} />
77 60
       <ProFormDependency name={['fullScore', 'num']}>
78 61
         {
79
-          ({ fullScore, num }) => <ProFormDigit readonly label="小计" value={fullScore / num} fieldProps={{ precision: 2 }} />
62
+          ({ fullScore, num }) => <ProFormDigit readonly label="小计" value={fullScore * num} fieldProps={{ precision: 2 }} />
80 63
         }
81 64
       </ProFormDependency>
82 65
     </ModalForm>

+ 54
- 29
src/pages/check/components/LocTable.jsx Parādīt failu

@@ -15,14 +15,6 @@ export default (props) => {
15 15
   const [loading, startLoading, stopLoading] = useBool();
16 16
   const [open, setOpen] = React.useState(false);
17 17
 
18
-  const onEdit = (row) => {
19
-    // console.log('________________________>', row);
20
-    setCurItem(row);
21
-    setOpen(true);
22
-  }
23
-
24
-
25
-
26 18
   const columns = [
27 19
     {
28 20
       title: '点位名称',
@@ -53,7 +45,7 @@ export default (props) => {
53 45
       title: '小计',
54 46
       dataIndex: 'fullScore',
55 47
       key: 'fullScore',
56
-      render: (_, row) => row.fullScore ? Number(row.fullScore * (row.num || 1)).toFixed(2) : '-',
48
+      render: (_, row) => row.fullScore ? Number(row.fullScore * (row.num || 0)).toFixed(2) : '-',
57 49
     },
58 50
     {
59 51
       title: '测评得分',
@@ -74,19 +66,31 @@ export default (props) => {
74 66
     },
75 67
   ]
76 68
 
77
-  const onChange = (item) => {
78
-    const newList = list.map(x => x.itemId === item.itemId ? item : x);
79
-    setList(newList);
80
-  }
69
+  const summary = React.useMemo(() => {
70
+    let fullScore = 0;
71
+    let answerNum = 0;
72
+    let num = 0;
73
+    let score = 0;
74
+    let subtotal = 0;
81 75
 
82
-  const getRowClassName = (row) => {
83
-    return [
84
-      styles['yz-table-row'],
85
-      (row.itemId == curItem?.itemId) ? styles.active : false,
86
-    ].filter(Boolean).join(' ');
87
-  }
76
+    list.forEach((x) => {
77
+      fullScore += (x.fullScore || 0);
78
+      answerNum += (x.answerNum || 0);
79
+      num += (x.num || 0);
80
+      score += (x.score || 0);
81
+      subtotal += (x.fullScore || 0) * (x.num || 0);
82
+    });
88 83
 
89
-  React.useEffect(() => {
84
+    return {
85
+      fullScore,
86
+      answerNum,
87
+      num,
88
+      score,
89
+      subtotal: Number(subtotal).toFixed(2),
90
+    }
91
+  }, [list]);
92
+
93
+  const queryList = React.useCallback(() => {
90 94
     if (checkId) {
91 95
       startLoading();
92 96
       getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then(res => {
@@ -98,7 +102,30 @@ export default (props) => {
98 102
     }
99 103
   }, [checkId]);
100 104
 
101
-  // console.log('---------------------------------------------------------->', list?.map((x) => Number(x.fullScore / (x.num || 1)).toFixed(2)))
105
+  const onEdit = (row) => {
106
+    setCurItem(row);
107
+    setOpen(true);
108
+  }
109
+
110
+  const onChange = (item) => {
111
+    const newList = list.map(x => x.itemId === item.itemId ? item : x);
112
+    setList(newList);
113
+  }
114
+
115
+  const onQuChange = () => {
116
+    queryList();
117
+  }
118
+
119
+  const getRowClassName = (row) => {
120
+    return [
121
+      styles['yz-table-row'],
122
+      (row.itemId == curItem?.itemId) ? styles.active : false,
123
+    ].filter(Boolean).join(' ');
124
+  }
125
+
126
+  React.useEffect(() => {
127
+    queryList();
128
+  }, [queryList]);
102 129
 
103 130
   return (
104 131
     <Row gutter={24}>
@@ -107,15 +134,13 @@ export default (props) => {
107 134
           <Table
108 135
             sticky
109 136
             summary={() => (
110
-              <Table.Summary>
137
+              <Table.Summary fixed="top">
111 138
                 <Table.Summary.Row style={{ fontWeight: 'bolder' }}>
112 139
                   <Table.Summary.Cell index={0}>合计</Table.Summary.Cell>
113
-                  <Table.Summary.Cell index={1}>{list?.map((x) => x.fullScore).reduce((total, num) => total + num, 0)}</Table.Summary.Cell>
114
-                  <Table.Summary.Cell index={2}>
115
-                    {list?.map((x) => x.answerNum).reduce((total, num) => total + num, 0)} / {list?.map((x) => x.num).reduce((total, num) => total + num, 0)}
116
-                  </Table.Summary.Cell>
117
-                  <Table.Summary.Cell index={3}>{list?.map((x) => Number(x.fullScore * (x.num || 1))).reduce((total, num) => total + num, 0).toFixed(2)}</Table.Summary.Cell>
118
-                  <Table.Summary.Cell index={4}>{list?.map((x) => x.score).reduce((total, num) => total + num, 0)}</Table.Summary.Cell>
140
+                  <Table.Summary.Cell index={1}>{summary.fullScore}</Table.Summary.Cell>
141
+                  <Table.Summary.Cell index={2}>{`${summary.answerNum} / ${summary.num}`}</Table.Summary.Cell>
142
+                  <Table.Summary.Cell index={3}>{summary.subtotal}</Table.Summary.Cell>
143
+                  <Table.Summary.Cell index={4}>{summary.score}</Table.Summary.Cell>
119 144
                 </Table.Summary.Row>
120 145
               </Table.Summary>
121 146
             )}
@@ -140,7 +165,7 @@ export default (props) => {
140 165
         </Card>
141 166
       </Col>
142 167
       <Col span={12}>
143
-        <QuList itemId={curItem?.itemId} />
168
+        <QuList itemId={curItem?.itemId} onChange={onQuChange} />
144 169
       </Col>
145 170
     </Row>
146 171
   )

+ 4
- 4
src/pages/check/components/QuForm.jsx Parādīt failu

@@ -47,12 +47,12 @@ export default (props) => {
47 47
   }
48 48
 
49 49
   React.useEffect(() => {
50
-    if (quInfo) {
51
-      form.setFieldsValue(quInfo);
52
-    } else {
50
+    if (!open || !quInfo) {
53 51
       form.resetFields();
52
+    } else {
53
+      form.setFieldsValue(quInfo);
54 54
     }
55
-  }, [quInfo]);
55
+  }, [quInfo, open]);
56 56
 
57 57
   // console.log('value', value);
58 58
   return (

+ 10
- 13
src/pages/check/components/QuList.jsx Parādīt failu

@@ -5,13 +5,17 @@ import { getTaCheckItemQu, deleteTaCheckItemQu } from '@/service/tacheckitemqu';
5 5
 import QuForm from './QuForm';
6 6
 
7 7
 export default (props) => {
8
-  const { itemId, itemType = 'loc' } = props;
8
+  const { itemId, itemType = 'loc', onChange } = props;
9 9
 
10 10
   const [open, setOpen] = React.useState(false);
11 11
   const [list, setList] = React.useState([]);
12 12
   const [curItem, setCurItem] = React.useState();
13 13
   const [loading, startLoading, stopLoading] = useBool();
14 14
 
15
+  const totalScore = React.useMemo(() => {
16
+    return list?.map((x) => x.maxScore).reduce((total, num) => total + num, 0);
17
+  }, [list]);
18
+
15 19
   const columns = [
16 20
     {
17 21
       title: '序号',
@@ -93,6 +97,10 @@ export default (props) => {
93 97
     }
94 98
 
95 99
     setList(newList);
100
+
101
+    if (onChange) {
102
+      onChange();
103
+    }
96 104
   }
97 105
 
98 106
   React.useEffect(() => {
@@ -109,7 +117,7 @@ export default (props) => {
109 117
 
110 118
   return (
111 119
     <Card
112
-      title="试题列表"
120
+      title={`试题列表 (总分 ${totalScore})`}
113 121
       extra={
114 122
         itemType == 'loc' ?
115 123
           <Button type="link" disabled={!itemId} onClick={onAdd}>新增</Button> :
@@ -117,17 +125,6 @@ export default (props) => {
117 125
       }
118 126
     >
119 127
       <Table
120
-        // sticky
121
-        // summary={() => (
122
-        //   <Table.Summary>
123
-        //     <Table.Summary.Row style={{ fontWeight: 'bolder' }}>
124
-        //       <Table.Summary.Cell index={0}>合计</Table.Summary.Cell>
125
-        //       <Table.Summary.Cell index={1}>1</Table.Summary.Cell>
126
-        //       <Table.Summary.Cell index={2}>{list?.map((x) => x.maxScore).reduce((total, num) => total + num, 0)}</Table.Summary.Cell>
127
-        //     </Table.Summary.Row>
128
-        //   </Table.Summary>
129
-        // )}
130
-        title={() => (<div style={{ fontWeight: 'bolder' }}>分值合计:{list?.map((x) => x.maxScore).reduce((total, num) => total + num, 0)}</div>)}
131 128
         bordered
132 129
         rowKey="quId"
133 130
         loading={loading}

+ 2
- 1
src/pages/checkAnswer/loc/index.jsx Parādīt failu

@@ -8,6 +8,7 @@ import { getTaCheck } from '@/service/tacheck';
8 8
 import { getTdLocType } from '@/service/tdloctype';
9 9
 import { getTaCheckAnswer, exportTaCheckAnswer } from '@/service/tacheckanswer';
10 10
 import useBool from '@/utils/hooks/useBool';
11
+import TargetLink from '@/components/TargetLink';
11 12
 
12 13
 const getCheck = queryDict(getTaCheck, { labelKey: 'title', valueKey: 'checkId' });
13 14
 const getLocType = queryDict(getTdLocType, { labelKey: 'name', valueKey: 'typeId' });
@@ -83,7 +84,7 @@ export default (props) => {
83 84
       key: 'options',
84 85
       render: (_, row) => {
85 86
         return (
86
-          <Button type="link" onClick={() => goToDetail(row)}>详情</Button>
87
+          <TargetLink to={`/checkAnswer/loc/detail?answerId=${row.answerId}&itemType=loc`}>详情</TargetLink>
87 88
         )
88 89
       }
89 90
     }

+ 2
- 1
src/pages/checkAnswer/survey/index.jsx Parādīt failu

@@ -7,6 +7,7 @@ import { Button, notification } from "antd";
7 7
 import { getTaCheck } from '@/service/tacheck';
8 8
 import { getTaCheckAnswer, exportTaCheckAnswer } from '@/service/tacheckanswer';
9 9
 import useBool from '@/utils/hooks/useBool';
10
+import TargetLink from '@/components/TargetLink';
10 11
 
11 12
 const getCheck = queryDict(getTaCheck, { labelKey: 'title', valueKey: 'checkId' });
12 13
 const getAnswer = queryTable(getTaCheckAnswer);
@@ -84,7 +85,7 @@ export default (props) => {
84 85
       key: 'options',
85 86
       render: (_, row) => {
86 87
         return (
87
-          <Button type="link" onClick={() => goToDetail(row)}>详情</Button>
88
+          <TargetLink to={`/checkAnswer/survey/detail?answerId=${row.answerId}&itemType=survey`}>详情</TargetLink>
88 89
         )
89 90
       }
90 91
     }

+ 2
- 7
src/pages/issue/index.jsx Parādīt failu

@@ -18,6 +18,7 @@ import { processEnum, processStatus } from "@/utils/biz";
18 18
 import useBool from "@/utils/hooks/useBool";
19 19
 import useOrgResponsible from "@/utils/hooks/useOrgResponsible";
20 20
 import dayjs from "dayjs";
21
+import TargetLink from "@/components/TargetLink";
21 22
 
22 23
 const queryOrg = queryDict(getSysOrg, { labelKey: "name", valueKey: "orgId" });
23 24
 const queryLocType = queryDict(getTdLocType, {
@@ -194,13 +195,7 @@ export default (props) => {
194 195
       params={params}
195 196
       beforeSearchSubmit={beforeSearchSubmit}
196 197
       optionRender={(_, row) => [
197
-        <Button
198
-          key="detail"
199
-          type="link"
200
-          onClick={() => navigate(`/issue/detail?id=${row.issueId}`)}
201
-        >
202
-          详情
203
-        </Button>,
198
+        <TargetLink key="detail" to={`/issue/detail?id=${row.issueId}`}>详情</TargetLink>,
204 199
       ]}
205 200
       toolBarRender={() => [
206 201
         <Button key="1" type="primary" loading={loading} onClick={onExport}>