소스 검색

东哥开始指点江山

shaogen1995 2 달 전
부모
커밋
5f7f59f2ab

+ 18 - 0
src/assets/styles/base.css

@@ -41,6 +41,24 @@ textarea {
 .noFindPage {
   opacity: 0;
   transition: opacity 0.5s;
+  background-color: #fff;
+  border-radius: 10px;
+  display: flex;
+  justify-content: center;
+  flex-direction: column;
+  align-items: center;
+  color: #666666;
+  font-size: 16px;
+  padding-bottom: 20px;
+}
+.noFindPage > p {
+  margin-bottom: 10px;
+}
+.noFindPage > div {
+  width: 80%;
+  margin-top: 8%;
+  display: flex;
+  justify-content: space-around;
 }
 /* 兼容360浏览器的下拉框 */
 .ant-select-selector {

+ 19 - 0
src/assets/styles/base.less

@@ -53,6 +53,25 @@ textarea {
 .noFindPage {
   opacity: 0;
   transition: opacity 0.5s;
+  background-color: #fff;
+  border-radius: 10px;
+  display: flex;
+  justify-content: center;
+  flex-direction: column;
+  align-items: center;
+  color: #666666;
+  font-size: 16px;
+  padding-bottom: 20px;
+
+  & > p {
+    margin-bottom: 10px;
+  }
+  & > div {
+    width: 80%;
+    margin-top: 8%;
+    display: flex;
+    justify-content: space-around;
+  }
 }
 
 /* 兼容360浏览器的下拉框 */

+ 27 - 0
src/components/MyTable/index.module.scss

@@ -27,5 +27,32 @@
       //   color: var(--themeColor);
       // }
     }
+    .ant-table-placeholder {
+      .ant-table-cell {
+        padding: 0 !important;
+        border-bottom: none !important;
+      }
+    }
+
+    .NODATA {
+      display: flex;
+      flex-direction: column;
+      justify-content: center;
+      align-items: center;
+      color: #666666;
+      font-size: 16px;
+      // img {
+      //   width: 150px;
+      // }
+      & > p {
+        margin-bottom: 10px;
+      }
+      div {
+        width: 80%;
+        margin-top: 8%;
+        display: flex;
+        justify-content: space-around;
+      }
+    }
   }
 }

+ 14 - 0
src/components/MyTable/index.tsx

@@ -11,6 +11,7 @@ import { DatePicker, Form, FormInstance, Input, Table, TableProps } from 'antd'
 import ImageLazy from '../ImageLazy'
 import classNames from 'classnames'
 import { resJiLianFu } from '@/utils/history'
+import { baseURL } from '@/utils/http'
 
 interface MyTableProps extends Omit<TableProps, 'onChange'> {
   yHeight?: number //设置表格的高度
@@ -280,6 +281,19 @@ const MyTable = forwardRef<MyTableMethods, MyTableProps>(
               : false
           }
           {...rest}
+          locale={{
+            emptyText: (
+              <div className='NODATA' style={{ height: yHeight ? yHeight : '' }}>
+                <img src={baseURL + `/baseData/staImg/build.png`} alt='' />
+                <p>暂无相关搜索结果,请更换关键字搜索</p>
+                <div>
+                  <p>应用归属单位:义乌市博物馆</p>
+                  <p>应用管理员:李亮</p>
+                  <p>联系方式:18767178372</p>
+                </div>
+              </div>
+            )
+          }}
         />
       </Form>
     )

+ 11 - 5
src/components/NoPower/index.module.scss

@@ -1,17 +1,23 @@
 .NoPower {
   background-color: #fff;
   border-radius: 10px;
-  padding-bottom: 5%;
   display: flex;
   flex-direction: column;
   justify-content: center;
   align-items: center;
-  width: 100%;
-  height: 100%;
+  color: #666666;
+  font-size: 16px;
+  padding-bottom: 20px;
+
   :global {
     p {
-      color: #666666;
-      margin-top: 24px;
+      margin-bottom: 10px;
+    }
+    div {
+      width: 80%;
+      margin-top: 8%;
+      display: flex;
+      justify-content: space-around;
     }
   }
 }

+ 67 - 4
src/components/NoPower/index.tsx

@@ -1,12 +1,75 @@
-import React from 'react'
+import React, { useEffect, useState } from 'react'
 import styles from './index.module.scss'
-import NoPowerImg from '@/assets/img/NoPower.png'
+import { baseURL } from '@/utils/http'
+
+const objData = {
+  // 404
+  1: {
+    txt1: '抱歉,系统错误,',
+    txt2: '您可以选择尝试清除缓存或联系管理员',
+    imgName: '404'
+  },
+
+  // 网络错误
+  2: {
+    txt1: '网络错误, ',
+    txt2: '请检查网络连接是否正常',
+    imgName: 'err'
+  },
+  // 建设中页面
+  3: {
+    txt1: '正在建设中,敬请期待',
+    txt2: '',
+    imgName: 'build'
+  },
+  // 查询为空
+  4: {
+    txt1: '暂无相关搜索结果,请更换关键字搜索',
+    txt2: '',
+    imgName: 'build'
+  },
+  // 详情页为空
+  5: {
+    txt1: '暂无相关内容,请退回上一页',
+    txt2: '',
+    imgName: 'null'
+  }
+}
 
 function NoPower() {
+  const [info, setInfo] = useState({
+    txt1: '',
+    txt2: '',
+    imgName: ''
+  })
+
+  useEffect(() => {
+    const urlAll = window.location.href
+    const arr = urlAll.split('?k=')
+    if (arr && arr.length > 1) {
+      const num = arr[1]
+
+      const obj = Reflect.get(objData, num)
+      if (obj.imgName) setInfo(obj)
+    } else {
+      setInfo({
+        txt1: '抱歉,您暂无当前页面的访问权限,',
+        txt2: '请联系管理员',
+        imgName: 'noPower'
+      })
+    }
+  }, [])
+
   return (
     <div className={styles.NoPower}>
-      <img src={NoPowerImg} alt='' />
-      <p>您没有本页面的权限,请联系管理员开通。</p>
+      <img src={baseURL + `/baseData/staImg/${info.imgName}.png`} alt='' />
+      <p>{info.txt1} </p>
+      <p>{info.txt2}</p>
+      <div>
+        <p>应用归属单位:义乌市博物馆</p>
+        <p>应用管理员:李亮</p>
+        <p>联系方式:18767178372</p>
+      </div>
     </div>
   )
 }

+ 19 - 16
src/components/NotFound/index.tsx

@@ -1,26 +1,29 @@
-import { Result } from "antd";
-import { useEffect, useRef } from "react";
+import { baseURL } from '@/utils/http'
+import { useEffect, useRef } from 'react'
 
 export default function NotFound() {
-  const timeRef = useRef(-1);
+  const timeRef = useRef(-1)
 
   useEffect(() => {
     timeRef.current = window.setTimeout(() => {
-      const dom: HTMLDivElement = document.querySelector(".noFindPage")!;
-      dom.style.opacity = "1";
-    }, 500);
+      const dom: HTMLDivElement = document.querySelector('.noFindPage')!
+      dom.style.opacity = '1'
+    }, 500)
     return () => {
-      clearTimeout(timeRef.current);
-    };
-  }, []);
+      clearTimeout(timeRef.current)
+    }
+  }, [])
 
   return (
-    <div className="noFindPage">
-      <Result
-        status="404"
-        title="404"
-        subTitle="找不到页面,或没有权限!"
-      />
+    <div className='noFindPage'>
+      <img src={baseURL + '/baseData/staImg/404.png'} alt='' />
+      <p>抱歉,系统错误, </p>
+      <p>您可以选择尝试清除缓存或联系管理员</p>
+      <div>
+        <p>应用归属单位:义乌市博物馆</p>
+        <p>应用管理员:李亮</p>
+        <p>联系方式:18767178372</p>
+      </div>
     </div>
-  );
+  )
 }

+ 48 - 15
src/pages/D_storeManage/D2storSet/D2edit.tsx

@@ -1,4 +1,4 @@
-import React, { useCallback, useEffect, useRef } from 'react'
+import React, { useCallback, useEffect, useRef, useState } from 'react'
 import styles from './index.module.scss'
 import { Button, Form, FormInstance, Input, Modal, Radio, Select } from 'antd'
 import TextArea from 'antd/es/input/TextArea'
@@ -8,6 +8,7 @@ import { getUserListAPI } from '@/store/action/Z6user'
 import { RootState } from '@/store'
 import { D2_APIedit, D2_APIgetInfo } from '@/store/action/D2storSet'
 import { MessageFu } from '@/utils/message'
+import { findMissingIds } from '@/pages/Z_system/Z3flowSet/Z3edit/data'
 
 type Props = {
   sId: number
@@ -19,13 +20,21 @@ type Props = {
 function D2edit({ sId, succToLookFu, closeFu, isLook }: Props) {
   // 获取用户列表
   const dispatch = useDispatch()
+
+  const [loding, setLoding] = useState(false)
+
   useEffect(() => {
     dispatch(
-      getUserListAPI({
-        pageNum: 1,
-        pageSize: 99999,
-        searchKey: ''
-      })
+      getUserListAPI(
+        {
+          pageNum: 1,
+          pageSize: 99999,
+          searchKey: ''
+        },
+        () => {
+          setLoding(true)
+        }
+      )
     )
   }, [dispatch])
 
@@ -34,15 +43,39 @@ function D2edit({ sId, succToLookFu, closeFu, isLook }: Props) {
   // 设置表单ref
   const FormBoxRef = useRef<FormInstance>(null)
 
-  const getInfoFu = useCallback(async (id: number) => {
-    const res = await D2_APIgetInfo(id)
-    const obj = res.data
+  const getInfoFu = useCallback(
+    async (id: number) => {
+      if (loding) {
+        const res = await D2_APIgetInfo(id)
 
-    if (obj.memberUserIds)
-      obj.memberUserIds = obj.memberUserIds.split(',').map((v: string) => Number(v))
-    else obj.memberUserIds = []
-    if (res.code === 0) FormBoxRef.current?.setFieldsValue(res.data)
-  }, [])
+        if (res.code === 0) {
+          const obj = res.data
+
+          if (obj.memberUserIds)
+            obj.memberUserIds = obj.memberUserIds.split(',').map((v: string) => Number(v))
+          else obj.memberUserIds = []
+
+          // console.log('---------', obj)
+
+          if (!userList.some(v => v.id === obj.managerUserId)) {
+            obj.managerUserId = null
+          }
+
+          if (obj.memberUserIds && obj.memberUserIds.length) {
+            const isDelIdArrRef = findMissingIds(userList, obj.memberUserIds)
+            if (isDelIdArrRef && isDelIdArrRef.length) {
+              const userIds = new Set(isDelIdArrRef.map(u => u))
+              const copyUserIds = obj.memberUserIds.filter((id: any) => !userIds.has(id))
+              obj.memberUserIds = copyUserIds
+            }
+          }
+
+          FormBoxRef.current?.setFieldsValue(res.data)
+        }
+      }
+    },
+    [loding, userList]
+  )
 
   useEffect(() => {
     if (sId > 0) getInfoFu(sId)
@@ -114,7 +147,7 @@ function D2edit({ sId, succToLookFu, closeFu, isLook }: Props) {
           >
             <Select
               disabled={isLook}
-              placeholder='请选择'
+              placeholder={isLook ? '(空)' : '请选择'}
               options={userList.map(v => ({ value: v.id, label: v.realName || v.userName }))}
             />
           </Form.Item>

+ 6 - 0
src/pages/Layout/data.ts

@@ -448,5 +448,11 @@ export const routerSon: RouterTypeRow[] = [
     name: '藏品移库-详情页',
     path: '/moveStor_edit/:key/:id',
     Com: React.lazy(() => import('../D_storeManage/D5moveStor/D5edit'))
+  },
+  {
+    id: 26,
+    name: '异常状态页面',
+    path: '/abnormal',
+    Com: React.lazy(() => import('@/components/NoPower'))
   }
 ]

+ 10 - 0
src/pages/Z_system/Z3flowSet/Z3edit/data.ts

@@ -0,0 +1,10 @@
+import { UserTableListType } from '@/types'
+
+// 已经被删除的用户id集合
+export function findMissingIds(users: UserTableListType[], idsToCheck: number[]): number[] {
+  // 创建用户ID集合便于快速查找
+  const userIds = new Set(users.map(user => user.id))
+  // 过滤出不存在于用户数据的ID
+
+  return idsToCheck.filter(id => !userIds.has(id))
+}

+ 36 - 15
src/pages/Z_system/Z3flowSet/Z3edit/index.tsx

@@ -7,6 +7,7 @@ import MyPopconfirm from '@/components/MyPopconfirm'
 import { MessageFu } from '@/utils/message'
 import { UserTableListType } from '@/types'
 import { Z3tableType } from '../type'
+import { findMissingIds } from './data'
 
 type Props = {
   sId: number
@@ -18,21 +19,41 @@ type Props = {
 function Z3edit({ sId, closeFu, succFu, userList }: Props) {
   const [info, setInfo] = useState({} as Z3tableType)
 
-  const getInfoFu = useCallback(async (id: number) => {
-    const res = await Z3_APIgetInfo(id)
-    if (res.code === 0) {
-      const data: Z3tableType = res.data
-
-      const copyUserIds = (
-        data.copyUserIds ? data.copyUserIds.split(',').map(v => Number(v)) : ''
-      ) as string
-
-      setInfo({
-        ...data,
-        copyUserIds
-      })
-    }
-  }, [])
+  const getInfoFu = useCallback(
+    async (id: number) => {
+      const res = await Z3_APIgetInfo(id)
+      if (res.code === 0) {
+        const data: Z3tableType = res.data
+
+        let copyUserIds = (
+          data.copyUserIds ? data.copyUserIds.split(',').map(v => Number(v)) : ''
+        ) as any
+
+        const isDelIdArrRef = findMissingIds(userList, copyUserIds)
+
+        if (isDelIdArrRef && isDelIdArrRef.length) {
+          const userIds = new Set(isDelIdArrRef.map(u => u))
+          copyUserIds = copyUserIds.filter((id: any) => !userIds.has(id))
+          const res2 = await Z3_APIsave({
+            ...data,
+            copyUserIds: copyUserIds ? copyUserIds.join(',') : ''
+          })
+          if (res2.code === 0) {
+            setInfo({
+              ...data,
+              copyUserIds
+            })
+          }
+        } else {
+          setInfo({
+            ...data,
+            copyUserIds
+          })
+        }
+      }
+    },
+    [userList]
+  )
 
   useEffect(() => {
     getInfoFu(sId)

+ 28 - 13
src/pages/Z_system/Z3flowSet/Z3linkSet/Z3addPro.tsx

@@ -10,6 +10,7 @@ import { RootState } from '@/store'
 import { D4_APIgetTree } from '@/store/action/Z4organization'
 import { MessageFu } from '@/utils/message'
 import { Z3proListType } from '../type'
+import { findMissingIds } from '../Z3edit/data'
 
 const baseFormData = {
   id: -1,
@@ -36,22 +37,36 @@ function Z3addPro({ sId, closeFu, succFu, userList, flowId }: Props) {
 
   const [form, setForm] = useState(baseFormData)
 
-  const getInfoFu = useCallback(async (id: number) => {
-    const res = await Z3_APIgetProInfo(id)
-    if (res.code === 0) {
-      const data: Z3proListType = res.data
+  const getInfoFu = useCallback(
+    async (id: number) => {
+      const res = await Z3_APIgetProInfo(id)
+      if (res.code === 0) {
+        const data: Z3proListType = res.data
 
-      let moduleIds: any = data.moduleIds.split(',')
+        let moduleIds: any = data.moduleIds.split(',')
 
-      data.type === 'user'
-        ? setIdsArr1(moduleIds.map((v: any) => Number(v)))
-        : data.type === 'role'
-        ? setIdsArr2(moduleIds.map((v: any) => Number(v)))
-        : setIdsArr3(moduleIds)
+        data.type === 'user'
+          ? setIdsArr1(moduleIds.map((v: any) => Number(v)))
+          : data.type === 'role'
+          ? setIdsArr2(moduleIds.map((v: any) => Number(v)))
+          : setIdsArr3(moduleIds)
 
-      setForm(data)
-    }
-  }, [])
+        if (data.type === 'user') {
+          const arr = moduleIds.map((v: any) => Number(v))
+          const isDelIdArrRef = findMissingIds(userList, arr)
+
+          if (isDelIdArrRef && isDelIdArrRef.length) {
+            const userIds = new Set(isDelIdArrRef.map(u => u))
+            const copyUserIds = arr.filter((id: any) => !userIds.has(id))
+            setIdsArr1(copyUserIds)
+          }
+        }
+
+        setForm(data)
+      }
+    },
+    [userList]
+  )
 
   useEffect(() => {
     dispatch(Z5_APIgetList({ pageNum: 1, pageSize: 99999 }))

+ 2 - 1
src/store/action/Z6user.ts

@@ -4,7 +4,7 @@ import { SaveUserType } from '@/types'
 /**
  * 获取用户管理表格列表
  */
-export const getUserListAPI = (data: any): any => {
+export const getUserListAPI = (data: any, back?: () => void): any => {
   return async (dispatch: AppDispatch) => {
     const url = 'sys/user/list?scope=' + (isDing ? 'DING' : 'SYS')
 
@@ -16,6 +16,7 @@ export const getUserListAPI = (data: any): any => {
       }
 
       dispatch({ type: 'Z6/getList', payload: obj })
+      back && back()
     }
   }
 }

+ 13 - 3
src/utils/http.ts

@@ -4,6 +4,7 @@ import store from '@/store'
 import { MessageFu } from './message'
 import { domShowFu } from './domShow'
 import { loginOutFu } from '@/components/DingLogin/data'
+import history from './history'
 
 // 是否是钉钉登录
 export const isDing = isDingTemp
@@ -73,6 +74,9 @@ http.interceptors.response.use(
       // MessageFu.success(response.data.msg);
     } else if (![3014, 3101].includes(response.data.code)) MessageFu.warning(response.data.msg)
 
+    if (response.data.code === -1 && response.data.msg === '对象不存在')
+      history.replace('/abnormal?k=5')
+
     return response.data
   },
   async function (err) {
@@ -83,7 +87,10 @@ http.interceptors.response.use(
       // 如果因为网络原因,response没有,给提示消息
       if (!err.response) {
         if (store.getState().A0Layout.closeUpFile.state) MessageFu.warning('取消上传!')
-        else MessageFu.error('网络繁忙,请稍后重试!')
+        else {
+          MessageFu.error('网络繁忙,请稍后重试!')
+          history.replace('/abnormal?k=2')
+        }
       } else {
         if (
           err.response &&
@@ -96,8 +103,11 @@ http.interceptors.response.use(
           if (err.response.data.code === 5003) {
             removeTokenInfo()
             loginOutFu()
-          }
-        } else MessageFu.error('响应错误,请联系管理员!')
+          } else history.replace('/abnormal?k=1')
+        } else {
+          MessageFu.error('响应错误,请联系管理员!')
+          history.replace('/abnormal?k=1')
+        }
       }
     }, 100)