Yansen 2 yıl önce
ebeveyn
işleme
8693545edb

+ 5
- 1
src/components/Page/index.jsx Dosyayı Görüntüle

29
     e.preventDefault();
29
     e.preventDefault();
30
     e.stopPropagation();
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
   return (
39
   return (

+ 18
- 0
src/components/TargetLink/index.jsx Dosyayı Görüntüle

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 Dosyayı Görüntüle

32
     }
32
     }
33
   }, [id]);
33
   }, [id]);
34
 
34
 
35
-  console.log('-----survey----->', survey);
36
   return (
35
   return (
37
     <Page back>
36
     <Page back>
38
       <CheckForm
37
       <CheckForm

+ 8
- 25
src/pages/check/components/LocForm.jsx Dosyayı Görüntüle

8
 const LocForm = (props) => {
8
 const LocForm = (props) => {
9
   const { checkItem, open, onOpenChange, onChange, itemId, checkId } = props;
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
   // const [listData, setListData] = React.useState();
13
   // const [listData, setListData] = React.useState();
14
 
14
 
15
   const [form] = Form.useForm();
15
   const [form] = Form.useForm();
34
     }
34
     }
35
   }, [checkItem]);
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
   // React.useEffect(() => {
37
   // React.useEffect(() => {
50
-  //   if (checkId) {
38
+  //   if (itemId) {
51
   //     startLoading();
39
   //     startLoading();
52
-  //     getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then(res => {
53
-  //       setListData(...res.records || []);
40
+  //     getTaCheckItemQu({ pageSize: 500, itemId }).then((res) => {
54
   //       stopLoading();
41
   //       stopLoading();
42
+  //       setList(...res.records);
55
   //     }).catch(() => {
43
   //     }).catch(() => {
56
   //       stopLoading();
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
   return (
49
   return (
67
     <ModalForm
50
     <ModalForm
68
       title={`${checkItem?.name} 维护`}
51
       title={`${checkItem?.name} 维护`}
72
       onFinish={onFinish}
55
       onFinish={onFinish}
73
       onOpenChange={onOpenChange}
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
       <ProFormDigit label="数量" name="num" min={1} fieldProps={{ precision: 0 }} />
59
       <ProFormDigit label="数量" name="num" min={1} fieldProps={{ precision: 0 }} />
77
       <ProFormDependency name={['fullScore', 'num']}>
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
       </ProFormDependency>
64
       </ProFormDependency>
82
     </ModalForm>
65
     </ModalForm>

+ 54
- 29
src/pages/check/components/LocTable.jsx Dosyayı Görüntüle

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
 
17
 
18
-  const onEdit = (row) => {
19
-    // console.log('________________________>', row);
20
-    setCurItem(row);
21
-    setOpen(true);
22
-  }
23
-
24
-
25
-
26
   const columns = [
18
   const columns = [
27
     {
19
     {
28
       title: '点位名称',
20
       title: '点位名称',
53
       title: '小计',
45
       title: '小计',
54
       dataIndex: 'fullScore',
46
       dataIndex: 'fullScore',
55
       key: 'fullScore',
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
       title: '测评得分',
51
       title: '测评得分',
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
     if (checkId) {
94
     if (checkId) {
91
       startLoading();
95
       startLoading();
92
       getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then(res => {
96
       getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then(res => {
98
     }
102
     }
99
   }, [checkId]);
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
   return (
130
   return (
104
     <Row gutter={24}>
131
     <Row gutter={24}>
107
           <Table
134
           <Table
108
             sticky
135
             sticky
109
             summary={() => (
136
             summary={() => (
110
-              <Table.Summary>
137
+              <Table.Summary fixed="top">
111
                 <Table.Summary.Row style={{ fontWeight: 'bolder' }}>
138
                 <Table.Summary.Row style={{ fontWeight: 'bolder' }}>
112
                   <Table.Summary.Cell index={0}>合计</Table.Summary.Cell>
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
                 </Table.Summary.Row>
144
                 </Table.Summary.Row>
120
               </Table.Summary>
145
               </Table.Summary>
121
             )}
146
             )}
140
         </Card>
165
         </Card>
141
       </Col>
166
       </Col>
142
       <Col span={12}>
167
       <Col span={12}>
143
-        <QuList itemId={curItem?.itemId} />
168
+        <QuList itemId={curItem?.itemId} onChange={onQuChange} />
144
       </Col>
169
       </Col>
145
     </Row>
170
     </Row>
146
   )
171
   )

+ 4
- 4
src/pages/check/components/QuForm.jsx Dosyayı Görüntüle

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

+ 10
- 13
src/pages/check/components/QuList.jsx Dosyayı Görüntüle

5
 import QuForm from './QuForm';
5
 import QuForm from './QuForm';
6
 
6
 
7
 export default (props) => {
7
 export default (props) => {
8
-  const { itemId, itemType = 'loc' } = props;
8
+  const { itemId, itemType = 'loc', onChange } = props;
9
 
9
 
10
   const [open, setOpen] = React.useState(false);
10
   const [open, setOpen] = React.useState(false);
11
   const [list, setList] = React.useState([]);
11
   const [list, setList] = React.useState([]);
12
   const [curItem, setCurItem] = React.useState();
12
   const [curItem, setCurItem] = React.useState();
13
   const [loading, startLoading, stopLoading] = useBool();
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
   const columns = [
19
   const columns = [
16
     {
20
     {
17
       title: '序号',
21
       title: '序号',
93
     }
97
     }
94
 
98
 
95
     setList(newList);
99
     setList(newList);
100
+
101
+    if (onChange) {
102
+      onChange();
103
+    }
96
   }
104
   }
97
 
105
 
98
   React.useEffect(() => {
106
   React.useEffect(() => {
109
 
117
 
110
   return (
118
   return (
111
     <Card
119
     <Card
112
-      title="试题列表"
120
+      title={`试题列表 (总分 ${totalScore})`}
113
       extra={
121
       extra={
114
         itemType == 'loc' ?
122
         itemType == 'loc' ?
115
           <Button type="link" disabled={!itemId} onClick={onAdd}>新增</Button> :
123
           <Button type="link" disabled={!itemId} onClick={onAdd}>新增</Button> :
117
       }
125
       }
118
     >
126
     >
119
       <Table
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
         bordered
128
         bordered
132
         rowKey="quId"
129
         rowKey="quId"
133
         loading={loading}
130
         loading={loading}

+ 2
- 1
src/pages/checkAnswer/loc/index.jsx Dosyayı Görüntüle

8
 import { getTdLocType } from '@/service/tdloctype';
8
 import { getTdLocType } from '@/service/tdloctype';
9
 import { getTaCheckAnswer, exportTaCheckAnswer } from '@/service/tacheckanswer';
9
 import { getTaCheckAnswer, exportTaCheckAnswer } from '@/service/tacheckanswer';
10
 import useBool from '@/utils/hooks/useBool';
10
 import useBool from '@/utils/hooks/useBool';
11
+import TargetLink from '@/components/TargetLink';
11
 
12
 
12
 const getCheck = queryDict(getTaCheck, { labelKey: 'title', valueKey: 'checkId' });
13
 const getCheck = queryDict(getTaCheck, { labelKey: 'title', valueKey: 'checkId' });
13
 const getLocType = queryDict(getTdLocType, { labelKey: 'name', valueKey: 'typeId' });
14
 const getLocType = queryDict(getTdLocType, { labelKey: 'name', valueKey: 'typeId' });
83
       key: 'options',
84
       key: 'options',
84
       render: (_, row) => {
85
       render: (_, row) => {
85
         return (
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 Dosyayı Görüntüle

7
 import { getTaCheck } from '@/service/tacheck';
7
 import { getTaCheck } from '@/service/tacheck';
8
 import { getTaCheckAnswer, exportTaCheckAnswer } from '@/service/tacheckanswer';
8
 import { getTaCheckAnswer, exportTaCheckAnswer } from '@/service/tacheckanswer';
9
 import useBool from '@/utils/hooks/useBool';
9
 import useBool from '@/utils/hooks/useBool';
10
+import TargetLink from '@/components/TargetLink';
10
 
11
 
11
 const getCheck = queryDict(getTaCheck, { labelKey: 'title', valueKey: 'checkId' });
12
 const getCheck = queryDict(getTaCheck, { labelKey: 'title', valueKey: 'checkId' });
12
 const getAnswer = queryTable(getTaCheckAnswer);
13
 const getAnswer = queryTable(getTaCheckAnswer);
84
       key: 'options',
85
       key: 'options',
85
       render: (_, row) => {
86
       render: (_, row) => {
86
         return (
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 Dosyayı Görüntüle

18
 import useBool from "@/utils/hooks/useBool";
18
 import useBool from "@/utils/hooks/useBool";
19
 import useOrgResponsible from "@/utils/hooks/useOrgResponsible";
19
 import useOrgResponsible from "@/utils/hooks/useOrgResponsible";
20
 import dayjs from "dayjs";
20
 import dayjs from "dayjs";
21
+import TargetLink from "@/components/TargetLink";
21
 
22
 
22
 const queryOrg = queryDict(getSysOrg, { labelKey: "name", valueKey: "orgId" });
23
 const queryOrg = queryDict(getSysOrg, { labelKey: "name", valueKey: "orgId" });
23
 const queryLocType = queryDict(getTdLocType, {
24
 const queryLocType = queryDict(getTdLocType, {
194
       params={params}
195
       params={params}
195
       beforeSearchSubmit={beforeSearchSubmit}
196
       beforeSearchSubmit={beforeSearchSubmit}
196
       optionRender={(_, row) => [
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
       toolBarRender={() => [
200
       toolBarRender={() => [
206
         <Button key="1" type="primary" loading={loading} onClick={onExport}>
201
         <Button key="1" type="primary" loading={loading} onClick={onExport}>