Browse Source

upp-项目管理-新增字段-创建人

shaogen1995 1 year ago
parent
commit
5a01131d81

+ 14 - 3
src/components/Z3upFiles/index.tsx

@@ -33,7 +33,18 @@ type Props = {
 };
 
 function Z3upFiles(
-  { max, isLook, type="doc", fileCheck, dirCode, myUrl, fromData, lookData, accept=".zip", tips="此处的附件为对外的项目成果文件,仅支持zip格式,最多10个" }: Props,
+  {
+    max,
+    isLook,
+    type = "doc",
+    fileCheck,
+    dirCode,
+    myUrl,
+    fromData,
+    lookData,
+    accept = ".zip",
+    tips = "此处的附件为对外的项目成果文件,仅支持zip格式,最多10个",
+  }: Props,
   ref: any
 ) {
   const [fileList, setFileList] = useState<FileImgListType[]>([]);
@@ -52,7 +63,7 @@ function Z3upFiles(
         const filesInfo = e.target.files[0];
 
         // 校验格式
-        if (!filesInfo.name.includes(".zip") && accept !== '*') {
+        if (!filesInfo.name.includes(".zip") && accept !== "*") {
           e.target.value = "";
           return MessageFu.warning(`只支持zip格式!`);
         }
@@ -84,7 +95,7 @@ function Z3upFiles(
         }
       }
     },
-    [dirCode, fileList, fromData, myUrl]
+    [accept, dirCode, fileList, fromData, myUrl, type]
   );
 
   // 列表删除某一个文件

+ 18 - 6
src/pages/A1Project/A1Add/index.module.scss

@@ -14,20 +14,19 @@
       width: 100%;
       height: calc(100% - 60px);
       overflow-y: auto;
+      overflow-x: hidden;
       padding: 20px 20px 20px 0px;
+      position: relative;
 
       .ant-form-item-label {
         width: 120px !important;
       }
 
       .A1AddBtn {
-        margin-top: 30px;
-        width: 740px;
-        text-align: center;
         position: absolute;
-        bottom: 10px;
-        left: 0;
-        z-index: 20;
+        left: 800px;
+        top: 50%;
+        transform: translateY(-50%);
       }
 
       .e_row {
@@ -84,6 +83,19 @@
         }
 
       }
+
+      .A1AtitTxt {
+        position: relative;
+        bottom:30px;
+        left: 120px;
+        opacity: 0;
+        transition: all .3s;
+        pointer-events: none;
+      }
+      .A1AtitTxtShow{
+        opacity: 1;
+        bottom: 24px;
+      }
     }
 
     // 查看的情况

+ 65 - 13
src/pages/A1Project/A1Add/index.tsx

@@ -1,4 +1,10 @@
-import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import React, {
+  useCallback,
+  useEffect,
+  useMemo,
+  useRef,
+  useState,
+} from "react";
 import styles from "./index.module.scss";
 import {
   Button,
@@ -47,6 +53,9 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
       const info = res.data.entity;
       setLookInfo(info);
 
+      // 创建人编辑的 提示 回显
+      setCreatorIdValue(info.creatorId);
+
       const province = info.province ? info.province.split("-") : "";
 
       const dateScope = info.dateScope ? info.dateScope.split(" 至 ") : "";
@@ -122,7 +131,26 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
     [addFu, closeFu, editFu, pageType.id, pageType.txt]
   );
 
-  
+  // 从仓库中获取 用户列表数据(全部)
+  const userListTemp = useSelector(
+    (state: RootState) => state.A3User.tableInfo.list
+  );
+
+  const userList = useMemo(() => {
+    return userListTemp.map((v: any) => ({
+      value: v.id,
+      label: `${v.userName} - ${v.roleName}${
+        v.realName ? " - " + v.realName : ""
+      }`,
+    }));
+  }, [userListTemp]);
+
+  // 创建人 的 值
+  const [creatorIdValue, setCreatorIdValue] = useState(userInfo.id);
+
+  useEffect(() => {
+    console.log("---------", creatorIdValue);
+  }, [creatorIdValue]);
 
   return (
     <div className={styles.A1Add}>
@@ -140,7 +168,8 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
           onFinishFailed={onFinishFailed}
           autoComplete="off"
           initialValues={{
-            snapPmUser: userInfo.realName
+            snapPmUser: userInfo.realName,
+            creatorId: userInfo.id,
           }}
         >
           <Form.Item
@@ -214,10 +243,7 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
             />
           </Form.Item>
 
-          <Form.Item
-            label="项目经理"
-            name="snapPmUser"
-          >
+          <Form.Item label="项目经理" name="snapPmUser">
             <Input
               style={{ width: 600 }}
               maxLength={30}
@@ -228,10 +254,7 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
             />
           </Form.Item>
 
-          <Form.Item
-            label="商务经理"
-            name="snapBmUser"
-          >
+          <Form.Item label="商务经理" name="snapBmUser">
             <Input
               style={{ width: 600 }}
               maxLength={30}
@@ -299,9 +322,37 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
             </Form.Item>
           )}
 
+          {/* 新加的项目 创建人 */}
+          <Form.Item
+            label="创建人"
+            name="creatorId"
+            rules={[{ required: true, message: "请选择创建人!" }]}
+          >
+            <Select
+              value={creatorIdValue}
+              onChange={(e) => setCreatorIdValue(e)}
+              placeholder={
+                isOk ? (pageType.txt === "look" ? "(空)" : "请选择") : ""
+              }
+              style={{ width: 300 }}
+              options={userList}
+            />
+          </Form.Item>
+
+          {pageType.txt === "look" ? null : (
+            <div
+              className={classNames(
+                "A1AtitTxt",
+                creatorIdValue !== userInfo.id ? "A1AtitTxtShow" : ""
+              )}
+            >
+              创建人与当前用户不一致,请谨慎选择
+            </div>
+          )}
+
           {/* 确定和取消按钮 */}
           <div className="A1AddBtn">
-            {pageType.txt === "look" ? null : ( // <Button onClick={closeFu}>关 闭</Button>
+            {pageType.txt === "look" ? null : (
               <>
                 <Popconfirm
                   title="放弃编辑后,信息将不会保存!"
@@ -312,7 +363,8 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
                 >
                   <Button>取消</Button>
                 </Popconfirm>{" "}
-                &emsp;&emsp;
+                <br />
+                <br />
                 <Button type="primary" htmlType="submit">
                   保存
                 </Button>

+ 5 - 1
src/pages/Layout/index.tsx

@@ -27,6 +27,7 @@ import tabLeftArr from "./data";
 import { RootState } from "@/store";
 import { RouterType } from "@/types";
 import { A1_APIOgetHardCoded } from "@/store/action/A1Project";
+import { getUserListAPI } from "@/store/action/A3User";
 
 function Layout() {
   const dispatch = useDispatch();
@@ -40,6 +41,9 @@ function Layout() {
 
     // 获取 项目管理-项目文件-左侧一级写死目录
     dispatch(A1_APIOgetHardCoded());
+
+    // 获取用户列表-用于给项目 新增/编辑 里面的 创建人 字段
+    dispatch(getUserListAPI({ pageNum: 1, pageSize: 99999 }));
   }, [dispatch]);
 
   // 左侧菜单 和 路由 信息
@@ -211,7 +215,7 @@ function Layout() {
             label="旧密码"
             name="oldPassword"
             rules={[{ required: true, message: "不能为空!" }]}
-            getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")} 
+            getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
           >
             <Input.Password maxLength={20} />
           </Form.Item>