Bladeren bron

chore(core): 新增功能

wjx 1 jaar geleden
bovenliggende
commit
657bbe7540
3 gewijzigde bestanden met toevoegingen van 57 en 3 verwijderingen
  1. 38 1
      src/pages/Opus/index.tsx
  2. 2 2
      src/pages/Opus/opusRoll.tsx
  3. 17 0
      src/services/task-api/opus.ts

+ 38 - 1
src/pages/Opus/index.tsx

@@ -1,4 +1,4 @@
-import { getOpusListApi } from '@/services/task-api/opus';
+import { getOpusListApi, getUserNameListApi } from '@/services/task-api/opus';
 import { MaterialTypeEnum } from '@/utils/constEnum';
 import { SearchOutlined } from '@ant-design/icons';
 import { PageContainer } from '@ant-design/pro-components';
@@ -16,7 +16,9 @@ const Opus: React.FC = () => {
   const [form] = Form.useForm<TASKAPI.OpusList>();
   const [queryForm, setQueryForm] = useState<TASKAPI.OpusList>({ pageNum: 1, pageSize: 10 });
   const getOpusList = useRequest(getOpusListApi, { manual: true });
+  const getUserNameList = useRequest(getUserNameListApi, { manual: true, debounceWait: 300 });
   const [data, setData] = useState<any[]>([]);
+  const [userList, setUserList] = useState<{ label: string; value: any }[]>([]);
   /**************************************/
 
   useEffect(() => {
@@ -57,6 +59,23 @@ const Opus: React.FC = () => {
     setQueryForm({ ...queryForm, pageNum: queryForm.pageNum + 1 });
   };
 
+  const handleSearch = (newValue: string) => {
+    getUserNameList.runAsync({ userName: newValue }).then((res) => {
+      console.log('getUserNameList-->', res?.data);
+      if (res?.data && Object.keys(res?.data)?.length > 0) {
+        setUserList(
+          Object.keys(res?.data as any).map((key) => ({
+            label: res?.data[key],
+            value: key,
+          })),
+        );
+      } else {
+        setUserList([]);
+      }
+    });
+  };
+  console.log('--->', userList);
+
   return (
     <PageContainer>
       <Card style={{ borderRadius: 8 }} bodyStyle={{ padding: 0 }}>
@@ -78,6 +97,24 @@ const Opus: React.FC = () => {
                 onFinish={onFinish}
               >
                 <Row gutter={[0, 6]}>
+                  <Col>
+                    <Form.Item name="userId">
+                      <Select
+                        showSearch
+                        allowClear
+                        style={{ width: 150 }}
+                        loading={getUserNameList.loading}
+                        onSearch={handleSearch}
+                        placeholder="请输入名称查找"
+                        defaultActiveFirstOption={false}
+                        suffixIcon={null}
+                        filterOption={false}
+                        notFoundContent={null}
+                        options={userList}
+                      />
+                    </Form.Item>
+                  </Col>
+
                   <Col>
                     <Form.Item name="materialType">
                       <Select

+ 2 - 2
src/pages/Opus/opusRoll.tsx

@@ -102,8 +102,8 @@ const OpusRoll: React.FC<Props> = ({
                       <Typography.Title style={{ margin: 0, fontSize: 15 }} level={5} ellipsis>
                         {list.taskName}
                       </Typography.Title>
-                      <Typography.Text type="secondary" style={{ fontSize: 13 }}>
-                        {list.createTime}
+                      <Typography.Text type="secondary" style={{ fontSize: 13 }} ellipsis>
+                        <span style={{ color: '#646464' }}>{list.userName}</span> {list.createTime}
                       </Typography.Text>
                     </Space>
                   }

+ 17 - 0
src/services/task-api/opus.ts

@@ -14,3 +14,20 @@ export async function getOpusListApi(data: TASKAPI.OpusList, options?: { [key: s
     ...(options || {}),
   });
 }
+
+/**
+ * 根据昵称模糊匹配用户
+ * @param params
+ * @param options
+ * @returns
+ */
+export async function getUserNameListApi(
+  params: { userName: string },
+  options?: { [key: string]: any },
+) {
+  return request<API.Result>(config.API_BASE_URL + '/api/login/user/like/name', {
+    method: 'GET',
+    params,
+    ...(options || {}),
+  });
+}