Yansen пре 2 година
родитељ
комит
65ddfb42ba

+ 54
- 0
src/components/SearchSelect/index.jsx Прегледај датотеку

@@ -0,0 +1,54 @@
1
+import React from 'react';
2
+import { Select } from 'antd';
3
+
4
+/**
5
+ * 转换普通查询函数
6
+ * @param {*} fn 
7
+ * @param {*} params
8
+ * @returns 
9
+ */
10
+export function transformQuery(fn, { searchKey = 'name', labelKey = 'name', valueKey = 'id' }) {
11
+  return s => {
12
+    const pageSize = !s ? 10 : 100;
13
+    return fn({ pageSize, [searchKey]: s }).then(res => {
14
+      return (res.records || []).map(x => ({label: x[labelKey], value: x[valueKey]}));
15
+    })
16
+  }
17
+}
18
+
19
+/**
20
+ * 远程搜索下拉框
21
+ */
22
+export default (props) => {
23
+  const { request, onChange, ...leftProps } = props;
24
+
25
+  // [{label, value}]
26
+  const [list, setList] = React.useState([]);
27
+
28
+  const onSearch = (searchValue) => {
29
+    request(searchValue).then(setList);
30
+  }
31
+
32
+  const handleChange = (val) => {
33
+    const obj = list.filter(x => x.value === val)[0];
34
+    onChange(val, obj);
35
+  }
36
+
37
+  React.useEffect(() => {
38
+    onSearch();
39
+  }, []);
40
+
41
+  return (
42
+    <Select
43
+      showSearch
44
+      defaultActiveFirstOption={false}
45
+      showArrow={false}
46
+      filterOption={false}
47
+      onSearch={onSearch}
48
+      onChange={handleChange}
49
+      notFoundContent={null}
50
+      options={list}
51
+      {...leftProps}
52
+    />
53
+  )
54
+}

+ 14
- 1
src/pages/check/components/QuForm.jsx Прегледај датотеку

@@ -8,10 +8,12 @@ import {
8 8
 } from '@ant-design/pro-components';
9 9
 import { Form, Row, Col } from 'antd';
10 10
 import WangEditor from '@/components/Wangeditor';
11
+import SearchSelect, { transformQuery } from '@/components/SearchSelect';
11 12
 import { postTaCheckItemQu } from '@/service/tdlocquestion';
12 13
 
14
+
13 15
 export default (props) => {
14
-  const {open, onOpenChange, quInfo, itemId, onChange} = props;
16
+  const {open, onOpenChange, quInfo, itemId, itemType, onChange} = props;
15 17
   const [form] = Form.useForm();
16 18
   
17 19
   const onFinish = async (values) => {
@@ -44,6 +46,17 @@ export default (props) => {
44 46
       destroyOnClose
45 47
       onFinish={onFinish}
46 48
       onOpenChange={onOpenChange}
49
+      drawerProps={{
50
+        extra: (
51
+          <>
52
+          {
53
+            itemType == 'survey' && (
54
+              <div></div>
55
+            )
56
+          }
57
+          </>
58
+        )
59
+      }}
47 60
     >
48 61
       <Row gutter={24}>
49 62
         <Col span={6}>

+ 1
- 0
src/pages/check/components/QuList.jsx Прегледај датотеку

@@ -128,6 +128,7 @@ export default (props) => {
128 128
         open={open}
129 129
         itemId={itemId}
130 130
         quInfo={curItem}
131
+        itemType={itemType}
131 132
         onOpenChange={setOpen}
132 133
         onChange={onFinish}
133 134
       />