Browse Source

up-项目经理/商务经理。从用户列表中选择=》手动输入

shaogen1995 1 year ago
parent
commit
d35a92df73

+ 15 - 18
src/pages/A1Project/A1User/A1UserAdd.tsx

@@ -1,5 +1,13 @@
 import { A1UtableType } from "@/types";
-import { Button, Form, FormInstance, Modal, Popconfirm, Select } from "antd";
+import {
+  Button,
+  Form,
+  FormInstance,
+  Input,
+  Modal,
+  Popconfirm,
+  Select,
+} from "antd";
 import React, { useCallback, useEffect, useRef } from "react";
 import styles from "./index.module.scss";
 import { useSelector } from "react-redux";
@@ -19,7 +27,7 @@ function A1UserAdd({ info, closeFu, editFu, addFu }: Props) {
     if (info.id > 0) {
       FormBoxRef.current?.setFieldsValue({
         dictJobId: info.dictJobId,
-        userId: info.userId,
+        name: info.name,
       });
     }
   }, [info]);
@@ -30,9 +38,6 @@ function A1UserAdd({ info, closeFu, editFu, addFu }: Props) {
   // 从仓库拿 项目职能 下拉框
   const arr1 = useSelector((state: RootState) => state.A2Dict.A2Tab1_1Obj.job);
 
-  // 从仓库拿 用户姓名 下拉框
-  const arr2 = useSelector((state: RootState) => state.A3User.tableInfo.list);
-
   // 没有通过校验
   const onFinishFailed = useCallback(() => {}, []);
 
@@ -41,7 +46,7 @@ function A1UserAdd({ info, closeFu, editFu, addFu }: Props) {
     async (value: any) => {
       const res = await A1_APIUsave({
         dictJobId: value.dictJobId,
-        userId: value.userId,
+        name: value.name,
         id: info.id > 0 ? info.id : null,
         projectId: info.projectId,
       });
@@ -92,19 +97,11 @@ function A1UserAdd({ info, closeFu, editFu, addFu }: Props) {
           </Form.Item>
 
           <Form.Item
-            label="用户"
-            name="userId"
-            rules={[{ required: true, message: "请选择用户!" }]}
+            label="姓名"
+            name="name"
+            rules={[{ required: true, message: "请输入姓名!" }]}
           >
-            <Select
-              placeholder="请选择"
-              options={arr2
-                .filter((v) => v.userName !== "admin")
-                .map((v) => ({
-                  label: v.userName + " - " + v.realName,
-                  value: v.id,
-                }))}
-            />
+            <Input maxLength={10} showCount placeholder="请输入姓名" />
           </Form.Item>
 
           <div className="A1UAbtn">

+ 2 - 16
src/pages/A1Project/A1User/index.tsx

@@ -12,7 +12,6 @@ import { A1UtableType } from "@/types";
 import A1UserAdd from "./A1UserAdd";
 import { useSelector } from "react-redux";
 import { RootState } from "@/store";
-import lastIdresArrFu from "@/pages/A3User/UserAdd/dataRes";
 import { MessageFu } from "@/utils/message";
 import AuthCom from "@/components/AuthCom";
 
@@ -67,9 +66,6 @@ function A1User({ projectId }: Props) {
     [getListFu, searchKey]
   );
 
-  // 从仓库获取部门 级联 信息
-  const deptList = useSelector((state: RootState) => state.A5Section.tableList);
-
   // 权限
   const authArr = useSelector((state: RootState) => state.A4Role.A4RoleAll);
 
@@ -80,18 +76,8 @@ function A1User({ projectId }: Props) {
         dataIndex: "jobName",
       },
       {
-        title: "部门",
-        render: (item: A1UtableType) =>
-          lastIdresArrFu(item.deptId + "", deptList, true),
-        // dataIndex: "deptId",
-      },
-      {
-        title: "角色",
-        dataIndex: "roleName",
-      },
-      {
         title: "姓名",
-        dataIndex: "userName",
+        dataIndex: "name",
       },
     ];
 
@@ -123,7 +109,7 @@ function A1User({ projectId }: Props) {
       });
 
     return arr;
-  }, [authArr, delById, deptList]);
+  }, [authArr, delById]);
 
   // 编辑 新增 的数据
   const [addInfo, setAddInfo] = useState({} as A1UtableType);

+ 1 - 1
src/pages/A1Project/index.module.scss

@@ -23,7 +23,7 @@
 
         .A1SearchBtn {
           position: absolute;
-          right: 0px;
+          right: 8px;
         }
       }
     }

+ 18 - 72
src/pages/A1Project/index.tsx

@@ -14,7 +14,6 @@ import A1Add from "./A1Add";
 import A1Down from "./A1Down";
 import A1Look from "./A1Look";
 import { A1_APIgetList, A1_APIdelProject } from "@/store/action/A1Project";
-import { getUserListAPI } from "@/store/action/A3User";
 import { A2_APIgetList1 } from "@/store/action/A2Dict";
 import { hasAuditStatusArr } from "./data";
 import { MessageFu } from "@/utils/message";
@@ -24,26 +23,10 @@ function A1Project() {
   const dispatch = useDispatch();
 
   useEffect(() => {
-    // 获取用户列表(项目管理下拉筛选使用)
-    dispatch(getUserListAPI({ pageNum: 1, pageSize: 99999 }));
     // 获取 字典 的 职能(项目详情的项目成员用)  和 状态(这个页面用)
     dispatch(A2_APIgetList1());
   }, [dispatch]);
 
-  // 从仓库获取用户列表--项目经理下拉框 和 商务经理下拉框使用
-  const A3UserList = useSelector(
-    (state: RootState) => state.A3User.tableInfo.list
-  );
-
-  const pmUserIdArr = useMemo(() => {
-    const arr1 = A3UserList.filter((v) => v.userName !== "admin");
-    const arr2: { value: number; label: string }[] = arr1.map((v) => ({
-      value: v.id,
-      label: v.userName + " - " + v.realName,
-    }));
-    return arr2;
-  }, [A3UserList]);
-
   // 从仓库 获取 项目状态的下拉框 数据
   const statusArr = useSelector(
     (state: RootState) => state.A2Dict.A2Tab1_1Obj.status
@@ -55,8 +38,8 @@ function A1Project() {
   // 表单数据
   const [fromData, setFromData] = useState({
     searchKey: "",
-    pmUserId: "",
-    bmUserId: "",
+    pmName: "",
+    bmName: "",
     statusId: "",
     hasAuditStatus: "",
     projectRole: "",
@@ -77,12 +60,15 @@ function A1Project() {
   // 项目编号/项目名称/建设单位 的 输入
   const searchKeyTime = useRef(-1);
   const searchKeyChange = useCallback(
-    (e: React.ChangeEvent<HTMLInputElement>) => {
+    (
+      e: React.ChangeEvent<HTMLInputElement>,
+      key: "searchKey" | "pmName" | "bmName"
+    ) => {
       clearTimeout(searchKeyTime.current);
       searchKeyTime.current = window.setTimeout(() => {
         setFromData({
           ...fromData,
-          searchKey: e.target.value,
+          [key]: e.target.value,
           pageNum: 1,
         });
       }, 500);
@@ -90,32 +76,6 @@ function A1Project() {
     [fromData]
   );
 
-  // 项目经理 下拉 搜索 的 改变
-  const pmUserIdChange = useCallback(
-    (value: string) => {
-      const val = value ? value : "";
-      setFromData({
-        ...fromData,
-        pmUserId: val,
-        pageNum: 1,
-      });
-    },
-    [fromData]
-  );
-
-  // 商务经理 下拉 搜索 的 改变
-  const bmUserIdChange = useCallback(
-    (value: string) => {
-      const val = value ? value : "";
-      setFromData({
-        ...fromData,
-        bmUserId: val,
-        pageNum: 1,
-      });
-    },
-    [fromData]
-  );
-
   // 点击重置
   const [inputKey, setInputKey] = useState(1);
   const resetSelectFu = useCallback(() => {
@@ -123,8 +83,8 @@ function A1Project() {
     setInputKey(Date.now());
     setFromData({
       searchKey: "",
-      pmUserId: "",
-      bmUserId: "",
+      pmName: "",
+      bmName: "",
       statusId: "",
       hasAuditStatus: "",
       projectRole: "",
@@ -395,45 +355,31 @@ function A1Project() {
               style={{ width: 200 }}
               placeholder="请输入内容,最多20字"
               allowClear
-              onChange={(e) => searchKeyChange(e)}
+              onChange={(e) => searchKeyChange(e, "searchKey")}
             />
           </div>
 
           <div className="A1SearchRow">
             <span>项目经理:</span>
-            <Select
+            <Input
               key={inputKey}
+              maxLength={10}
               style={{ width: 200 }}
-              showSearch
+              placeholder="请输入内容,最多10字"
               allowClear
-              placeholder="请选择或输入内容搜索"
-              optionFilterProp="children"
-              onChange={pmUserIdChange}
-              filterOption={(input, option) =>
-                (option?.label ?? "")
-                  .toLowerCase()
-                  .includes(input.toLowerCase())
-              }
-              options={pmUserIdArr}
+              onChange={(e) => searchKeyChange(e, "pmName")}
             />
           </div>
 
           <div className="A1SearchRow">
             <span>商务经理:</span>
-            <Select
+            <Input
               key={inputKey}
+              maxLength={10}
               style={{ width: 200 }}
-              showSearch
+              placeholder="请输入内容,最多10字"
               allowClear
-              placeholder="请选择或输入内容搜索"
-              optionFilterProp="children"
-              onChange={bmUserIdChange}
-              filterOption={(input, option) =>
-                (option?.label ?? "")
-                  .toLowerCase()
-                  .includes(input.toLowerCase())
-              }
-              options={pmUserIdArr}
+              onChange={(e) => searchKeyChange(e, "bmName")}
             />
           </div>
         </div>

+ 2 - 1
src/types/api/A1Project.d.ts

@@ -46,7 +46,8 @@ export type A1UtableType = {
   realName: string;
   roleName: string;
   updateTime: string;
-  userId: number;
+  // userId: number;
+  name:string
 };
 
 export type A1ItableType = {