Yansen il y a 2 ans
Parent
révision
da7c561bf3

+ 2
- 2
src/components/Percent/index.jsx Voir le fichier

@@ -11,7 +11,7 @@ export default (props) => {
11 11
   const [percent, setPercent] = useState(0)
12 12
 
13 13
   useEffect(() => {
14
-    setPercent(epsilon2(value * 100))
14
+    setPercent(epsilon2((value || 0) * 100))
15 15
   }, [value])
16 16
 
17 17
   const handleChange = (val) => {
@@ -25,7 +25,7 @@ export default (props) => {
25 25
       value={percent}
26 26
       onChange={handleChange}
27 27
       precision={2}
28
-      formatter={value => `${value} %`}
28
+      formatter={value => `${value || 0} %`}
29 29
       parser={value => value.replace(/\s?%/g, '')}
30 30
     />
31 31
   )

+ 45
- 0
src/pages/check/components/CopyCheck.jsx Voir le fichier

@@ -0,0 +1,45 @@
1
+import React from 'react';
2
+import { ModalForm, ProFormText } from "@ant-design/pro-components";
3
+import { Form } from "antd";
4
+import { copyTaCheck } from '@/service/tacheck';
5
+
6
+export default (props) => {
7
+  const { check, open, onOpenChange, onFinish } = props;
8
+
9
+  const [formRef] = Form.useForm();
10
+
11
+  const onSubmit = async (values) => {
12
+    await copyTaCheck(values.checkId, values);
13
+    onOpenChange(false);
14
+    onFinish();
15
+    return;
16
+  }
17
+
18
+  React.useEffect(() => {
19
+    formRef.setFieldsValue({
20
+      checkId: check?.checkId,
21
+      title: `${check?.title}-复制`,
22
+    });
23
+  }, [check]);
24
+
25
+  return (
26
+    <ModalForm
27
+      title="复制"
28
+      width="560px"
29
+      open={open}
30
+      form={formRef}
31
+      onOpenChange={onOpenChange}
32
+      onFinish={onSubmit}
33
+    >
34
+      <ProFormText hidden name="checkId" />
35
+      <ProFormText
36
+        name="title"
37
+        label="测评名称"
38
+        placeholder="请输入测评名称"
39
+        rules={[
40
+          {required: true, message: '请输入测评名称'},
41
+        ]}
42
+      />
43
+    </ModalForm>
44
+  )
45
+}

+ 14
- 11
src/pages/check/index.jsx Voir le fichier

@@ -2,9 +2,10 @@ import React from 'react';
2 2
 import Page from '@/components/Page';
3 3
 import { useNavigate, Link } from 'react-router-dom';
4 4
 import { queryTable } from "@/utils/request";
5
-import { ProTable } from "@ant-design/pro-components";
6
-import { Button, message, Popconfirm, Input, Modal } from "antd";
5
+import { ProTable, ModalForm, ProFormText } from "@ant-design/pro-components";
6
+import { Button, message, Popconfirm, Form } from "antd";
7 7
 import { getTaCheck, deleteTaCheck, putTaCheck, calcScoreTaCheck } from '@/service/tacheck';
8
+import CopyCheck from './components/CopyCheck';
8 9
 
9 10
 const queryList = queryTable(getTaCheck);
10 11
 
@@ -14,7 +15,7 @@ export default (props) => {
14 15
   const actionRef = React.useRef();
15 16
   const [messageApi, contextHolder] = message.useMessage();
16 17
   const [open, setOpen] = React.useState(false);
17
-  const [check, setCheck] = React.useState({});
18
+  const [check, setCheck] = React.useState(false);
18 19
 
19 20
   const onDelete = (item) => {
20 21
     deleteTaCheck(item.checkId).then(() => {
@@ -44,7 +45,11 @@ export default (props) => {
44 45
 
45 46
   const onOpen = (record) => {
46 47
     setCheck(record);
47
-    setOpen(true)
48
+    setOpen(true);
49
+  }
50
+
51
+  const onCopyFinish = () => {
52
+    actionRef.current.reload();
48 53
   }
49 54
 
50 55
   const columns = [
@@ -159,14 +164,12 @@ export default (props) => {
159 164
   return (
160 165
     <Page>
161 166
       {contextHolder}
162
-      <Modal
163
-        title="复制"
167
+      <CopyCheck
164 168
         open={open}
165
-        onCancel={() => setOpen(false)}
166
-      >
167
-        测评名称:
168
-        <Input placeholder="请输入" value={check.title + '-复制'} />
169
-      </Modal>
169
+        check={check}
170
+        onOpenChange={setOpen}
171
+        onFinish={onCopyFinish}
172
+      />
170 173
       <ProTable
171 174
         actionRef={actionRef}
172 175
         rowKey="checkId"

+ 8
- 0
src/service/tacheck.js Voir le fichier

@@ -29,3 +29,11 @@ export const deleteTaCheck = (id) => request(`/api/taCheck/${id}`, { method: 'de
29 29
  * 计算分数
30 30
  */
31 31
 export const calcScoreTaCheck = (id) => request(`/api/taCheck/${id}/score`, { method: 'put' });
32
+
33
+/**
34
+ * 拷贝测评
35
+ * @param {*} id 
36
+ * @param {*} data 
37
+ * @returns 
38
+ */
39
+export const copyTaCheck = (id, data) => request(`/api/taCheck/${id}/copy`, { data, method: 'put' });

+ 0
- 2
src/utils/request.js Voir le fichier

@@ -19,8 +19,6 @@ instance.interceptors.request.use(function (config) {
19 19
     noTip = method.toLocaleLowerCase() === 'get' ? true : false;
20 20
   }
21 21
 
22
-  console.log('-----timeout---', download ? 600000 : 10000)
23
-
24 22
   // 在发送请求之前做些什么
25 23
   return {
26 24
     ...config,