Procházet zdrojové kódy

完善藏品详情页右侧按钮校验

shaogen1995 před 5 dny
rodič
revize
16d4f333c8

+ 3 - 1
src/pages/ZgoodsInfo/index.module.scss

@@ -33,8 +33,10 @@
           padding: 0 10px;
           margin: 0 5px;
           position: relative;
+          font-weight: 700;
         }
         .GItab1Ac {
+          color: var(--txtColor);
           &::before {
             content: '';
             position: absolute;
@@ -42,7 +44,7 @@
             left: 0;
             width: 100%;
             height: 6px;
-            background-color: var(--themeColor);
+            background-color: var(--txtColor);
           }
         }
         .ant-btn {

+ 46 - 15
src/pages/ZgoodsInfo/index.tsx

@@ -3,7 +3,7 @@ import styles from './index.module.scss'
 import { GoodsType } from '../Zother/SonGoodsList/data'
 import { API_getGoodsInfo } from '@/store/action/Cledger/C1ledger'
 import { useParams } from 'react-router-dom'
-import { resTagFu } from '@/utils/dataChange'
+import { resTagFu, selectObj } from '@/utils/dataChange'
 import { Button, Dropdown, Tag } from 'antd'
 import { useSelector } from 'react-redux'
 import { RootState } from '@/store'
@@ -16,6 +16,7 @@ import GItab2 from './GItab2'
 import GItab3 from './GItab3'
 import GItab4 from './GItab4'
 import GItab5 from './GItab5'
+import { MessageFu } from '@/utils/message'
 
 type tabArr1Type = {
   id: number
@@ -50,7 +51,7 @@ function ZgoodsInfo() {
     ]
   }, [info])
 
-  // 待完善sg 点击的时候校验前置状态,待确定
+  // 点击的时候校验前置状态和页面权限
   const tabArr2Temp = useMemo(() => {
     return [
       {
@@ -62,14 +63,22 @@ function ZgoodsInfo() {
           {
             key: '1',
             label: '修改',
-            onClick: () =>
+            onClick: () => {
+              if (info.isEdit === 1) return MessageFu.warning(`当前藏品为 修改中 状态,不可 修改`)
               authorityFu(420, '藏品修改', () => history.push(`/edit_edit/1/null?gId=${id}`))
+            }
           },
           {
             key: '2',
             label: '注销',
-            onClick: () =>
-              authorityFu(430, '藏品注销', () => history.push(`/writeOff_edit/1/null?gId=${id}`))
+            onClick: () => {
+              if ([3, 6].includes(info.status)) {
+                authorityFu(430, '藏品注销', () => history.push(`/writeOff_edit/1/null?gId=${id}`))
+              } else {
+                const txt = Reflect.get(selectObj['藏品入藏状态'], info.status) || '草稿'
+                MessageFu.warning(`当前藏品为 ${txt} 状态,不可 注销`)
+              }
+            }
           }
         ]
       },
@@ -82,22 +91,44 @@ function ZgoodsInfo() {
           {
             key: '1',
             label: '入库',
-            onClick: () =>
-              authorityFu(1010, '藏品入库', () => history.push(`/inStorage_edit/1/null?gId=${id}`))
+            onClick: () => {
+              if (!info.siteStatus || info.siteStatus === 1) {
+                authorityFu(1010, '藏品入库', () =>
+                  history.push(`/inStorage_edit/1/null?gId=${id}`)
+                )
+              } else {
+                const txt = Reflect.get(selectObj['藏品库存状态'], info.siteStatus) || '草稿'
+                MessageFu.warning(`当前藏品为 ${txt} 状态,不可 入库`)
+              }
+            }
           },
           {
             key: '2',
             label: '移库',
-            onClick: () =>
-              authorityFu(1020, '藏品移库', () =>
-                history.push(`/moveStorage_edit/1/null?gId=${id}`)
-              )
+            onClick: () => {
+              if (info.siteStatus === 3) {
+                authorityFu(1020, '藏品移库', () =>
+                  history.push(`/moveStorage_edit/1/null?gId=${id}`)
+                )
+              } else {
+                const txt = Reflect.get(selectObj['藏品库存状态'], info.siteStatus) || '草稿'
+                MessageFu.warning(`当前藏品为 ${txt} 状态,不可 移库`)
+              }
+            }
           },
           {
             key: '3',
             label: '出库',
-            onClick: () =>
-              authorityFu(1030, '藏品出库', () => history.push(`/outStorage_edit/1/null?gId=${id}`))
+            onClick: () => {
+              if (info.siteStatus === 3) {
+                authorityFu(1030, '藏品出库', () =>
+                  history.push(`/outStorage_edit/1/null?gId=${id}`)
+                )
+              } else {
+                const txt = Reflect.get(selectObj['藏品库存状态'], info.siteStatus) || '草稿'
+                MessageFu.warning(`当前藏品为 ${txt} 状态,不可 出库`)
+              }
+            }
           }
         ]
       },
@@ -134,7 +165,7 @@ function ZgoodsInfo() {
         ]
       }
     ]
-  }, [id])
+  }, [id, info])
 
   const [tabArr1, setTabArr1] = useState<tabArr1Type[]>([])
   const [loding, setLoding] = useState(false)
@@ -211,7 +242,7 @@ function ZgoodsInfo() {
           ))}
         </div>
         {/* 已删除状态隐藏右侧抽屉按钮 */}
-        {info.status === 8 ? (
+        {!info.status || [8, 0].includes(info.status) ? (
           <div></div>
         ) : (
           <div>

+ 1 - 1
src/pages/Zother/EditBtn/index.tsx

@@ -132,7 +132,7 @@ function EditBtn({
           })
         })
 
-        // 没有选择关联藏品的时候,只存下面的字段 待完善sg--等后端确定
+        // 没有选择关联藏品的时候,只存下面的字段
         if (snaps.length === 0) {
           let snapSon: any = {}
           snapSon = {

+ 6 - 4
src/pages/Zother/EditTop/index.tsx

@@ -104,10 +104,13 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
 
         const snapsTemp = data.snaps || []
         snapsTemp.forEach(async (v: any, i: number) => {
+          // console.log('ssssss', v)
+
           const obj = JSON.parse(v.snap || '{}')
 
           const flag = v.pageType === 'clue' && !v.clueId
-          if (obj.id === null || obj.isNew || flag) obj.id = Date.now() + i
+          if (obj.id === null || obj.isNew || flag)
+            obj.id = pageTxt === '藏品登记' ? v.goodId : Date.now() + i
 
           obj.idTemp = obj.id
 
@@ -139,11 +142,10 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
         })
 
         // console.log('-------', arrTemp)
-
-        setSnapsFu(arrTemp)
+        setSnapsFu(arrTemp.filter((v: any) => v.idTemp))
       }
     },
-    [APIobj, moreDom, setInfoFu, setSnapsFu]
+    [APIobj, moreDom, pageTxt, setInfoFu, setSnapsFu]
   )
 
   useEffect(() => {

+ 1 - 1
src/utils/authority.ts

@@ -9,7 +9,7 @@ export const authorityFu = (id: number, txt: string, fu: () => void, txt2?: stri
   const authorityIds = store.getState().A0Layout.authorityIds
 
   if (authorityIds.includes(id)) fu()
-  else MessageFu.warning(txt2 ? txt2 : `您没有${txt}权限!`)
+  else MessageFu.warning(txt2 ? txt2 : `您没有${txt}页面权限!`)
 }
 
 // 列表页面的审批按钮是否显示,true为显示

+ 3 - 0
src/utils/dataChange.tsx

@@ -64,6 +64,7 @@ export const selectObj = {
     { value: 6, label: '待提交' }
   ],
   藏品入藏状态: [
+    // status
     { value: 1, label: '入馆中' },
     { value: 2, label: '待入馆' },
     { value: 3, label: '已入馆' },
@@ -75,6 +76,7 @@ export const selectObj = {
     { value: 9, label: '待登记' }
   ],
   藏品库存状态: [
+    // siteStatus
     { value: 1, label: '待入库' },
     { value: 2, label: '入库中' },
     { value: 3, label: '已入库' },
@@ -84,6 +86,7 @@ export const selectObj = {
     { value: 7, label: '盘点中' }
   ],
   藏品属性状态: [
+    // isEdit
     { value: 0, label: '可编辑' },
     { value: 1, label: '修改中' }
   ],