Quellcode durchsuchen

准备写藏品删除

shaogen1995 vor 1 Monat
Ursprung
Commit
e9edbd782b

+ 56 - 6
后台管理/src/pages/A0addGoods/index.tsx

@@ -14,12 +14,13 @@ import TextArea from 'antd/es/input/TextArea'
 import ZupOne from '@/components/ZupOne'
 import Z3upFiles from '@/components/Z3upFiles'
 import dayjs from 'dayjs'
-import { API_addGoods, API_getGoodsInfo } from '@/store/action/B1ledger'
+import { API_addGoods, API_getFileListByIds, API_getGoodsInfo } from '@/store/action/B1ledger'
 import { MessageFu } from '@/utils/message'
 import history from '@/utils/history'
 import { B2_APIresubmit } from '@/store/action/B2register'
-import { B3_APIcreate, B3_APIresubmit } from '@/store/action/B3edit'
+import { B3_APIcreate, B3_APIgetInfo, B3_APIresubmit } from '@/store/action/B3edit'
 import { B1listType } from '../B1ledger/data'
+import { timeChange } from '@/utils/deriveFu'
 
 type Props = {
   sId: number
@@ -52,8 +53,14 @@ function A0addGoods({ sId, closeFu, isEdit, orderId, isEditresubmit }: Props) {
           if (!info[v]) info[v] = null
         })
 
-        // 把旧的数据存起来
-        if (isEdit || isEditresubmit) oldObjRef.current = { ...res.data, file: res.data.file || [] }
+        // 把旧的数据存起来(2个日期得单独处理一下)
+        if (isEdit || isEditresubmit)
+          oldObjRef.current = {
+            ...res.data,
+            inHouseTime: timeChange(res.data.inHouseTime),
+            registerTime: timeChange(res.data.registerTime),
+            file: res.data.file || []
+          }
 
         // 设置封面图
         ZupThumbRef.current?.setFileComFileFu({
@@ -67,10 +74,53 @@ function A0addGoods({ sId, closeFu, isEdit, orderId, isEditresubmit }: Props) {
         if (info.inHouseTime) info.inHouseTime = dayjs(info.inHouseTime)
         if (info.registerTime) info.registerTime = dayjs(info.registerTime)
 
-        FormBoxRef.current?.setFieldsValue(info)
+        // 从藏品修改的 重新提交进入,应该把需改之后的信息带入表单
+        if (isEditresubmit && orderId) {
+          const resR = await B3_APIgetInfo(orderId)
+
+          if (resR.code === 0) {
+            // 拿到快照新数据
+            const goodsArr = resR.data.snaps
+            if (goodsArr && goodsArr[0] && goodsArr[0].snap) {
+              const objStr = goodsArr[0].snap
+              try {
+                const obj: any = JSON.parse(objStr)
+                ;['level', 'torn', 'qualityUnit', 'isNote', 'sizeUnit'].forEach(v => {
+                  if (!obj[v]) obj[v] = null
+                })
+                // inHouseTime registerTime 2个日期需要格式处理一下
+                if (obj.inHouseTime) obj.inHouseTime = dayjs(obj.inHouseTime)
+                if (obj.registerTime) obj.registerTime = dayjs(obj.registerTime)
+
+                FormBoxRef.current?.setFieldsValue(obj)
+
+                // 设置封面图
+                ZupThumbRef.current?.setFileComFileFu({
+                  fileName: '',
+                  filePath: obj.thumbPc,
+                  thumb: obj.thumb
+                })
+
+                if (obj.fileIds) {
+                  const fileArr = obj.fileIds.split(',').map((v: any) => Number(v))
+
+                  const resFlie = await API_getFileListByIds(fileArr)
+
+                  if (resFlie.code === 0) {
+                    filesRef.current?.showList(resFlie.data || [])
+                  }
+                }
+
+                console.log(1234564, obj)
+              } catch (error) {
+                MessageFu.warning('JSON数据错误')
+              }
+            }
+          }
+        } else FormBoxRef.current?.setFieldsValue(info)
       }
     },
-    [isEdit, isEditresubmit]
+    [isEdit, isEditresubmit, orderId]
   )
 
   useEffect(() => {

+ 3 - 0
后台管理/src/pages/A0goodsInfo/Tab1info/index.module.scss

@@ -41,6 +41,9 @@
         width: 150px;
         display: flex;
         align-items: center;
+        & > span {
+          font-weight: 700;
+        }
       }
     }
     .T1_2 {

+ 5 - 0
后台管理/src/pages/A0goodsInfo/Tab1info/index.tsx

@@ -5,6 +5,7 @@ import ImageLazy from '@/components/ImageLazy'
 import { pageShowArr1, pageShowArr2 } from './data'
 import classNames from 'classnames'
 import Z3upFiles from '@/components/Z3upFiles'
+import { goodsSelect } from '@/utils/select'
 
 type Props = {
   info: B1listType
@@ -32,6 +33,10 @@ function Tab1info({ info, auto }: Props) {
                 </div>
               ))}
             </div>
+            <div className='T1_1rr'>
+              <span>藏品状态:</span>
+              <p>{goodsSelect.find(v => v.value === info.status)?.label}</p>
+            </div>
           </div>
 
           <div className='T1_1 T1_2'>

+ 3 - 0
后台管理/src/pages/A0goodsInfo/Tab2log/index.module.scss

@@ -1,4 +1,7 @@
 .Tab2log {
   :global {
+    .ant-table-cell {
+      padding: 8px !important;
+    }
   }
 }

+ 80 - 3
后台管理/src/pages/A0goodsInfo/Tab2log/index.tsx

@@ -1,9 +1,86 @@
-import React from 'react'
+import React, { useCallback, useEffect, useMemo, useState } from 'react'
 import styles from './index.module.scss'
-function Tab2log() {
+import { API_getGoodsLog } from '@/store/action/B1ledger'
+import MyTable from '@/components/MyTable'
+import { B1listType } from '@/pages/B1ledger/data'
+import { goodsLogTableC } from '@/utils/tableData'
+import { Button } from 'antd'
+import tabLeftArr from '@/pages/Layout/data'
+import { openLink } from '@/utils/history'
+
+type Props = {
+  sId: number
+}
+
+function Tab2log({ sId }: Props) {
+  const [list, setList] = useState<B1listType[]>([])
+
+  const getListFu = useCallback(async () => {
+    const res = await API_getGoodsLog(sId)
+    if (res.code === 0) {
+      setList(res.data)
+    }
+  }, [sId])
+
+  useEffect(() => {
+    getListFu()
+  }, [getListFu])
+
+  const dataChange = useCallback((item: B1listType) => {
+    const arr = tabLeftArr[1].son
+    const obj = arr.find(v => v.pageType === item.type)
+    return obj
+  }, [])
+
+  const staBtn = useMemo(() => {
+    return [
+      {
+        title: '订单编号',
+        render: (item: B1listType) => item.num
+      },
+      {
+        title: '申请类型',
+        render: (item: B1listType) => {
+          const obj = dataChange(item)
+
+          return obj ? obj.name : '(空)'
+        }
+      }
+    ]
+  }, [dataChange])
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: '操作',
+        render: (item: B1listType) => {
+          return (
+            <Button
+              size='small'
+              type='text'
+              onClick={() => {
+                const obj = dataChange(item)
+                if (obj) openLink(`${obj.path}_look/1/${item.id}`)
+              }}
+            >
+              查看
+            </Button>
+          )
+        }
+      }
+    ]
+  }, [dataChange])
+
   return (
     <div className={styles.Tab2log}>
-      <h1>Tab2log 待完善</h1>
+      <MyTable
+        yHeight={690}
+        list={list}
+        columnsTemp={goodsLogTableC}
+        staBtn={staBtn}
+        lastBtn={tableLastBtn}
+        pagingInfo={false}
+      />
     </div>
   )
 }

+ 7 - 5
后台管理/src/pages/A0goodsInfo/index.tsx

@@ -126,11 +126,13 @@ function A0goodsInfo() {
         </div>
       </div>
 
-      <div className='AImain'>
-        {btnAc === '藏品信息' ? <Tab1info info={goodsInfo} /> : null}
-        {btnAc === '编辑记录' ? <Tab2log /> : null}
-        {btnAc === '库存状态' ? <Tab3stock /> : null}
-      </div>
+      {goodsInfo.id ? (
+        <div className='AImain'>
+          {btnAc === '藏品信息' ? <Tab1info info={goodsInfo} /> : null}
+          {btnAc === '编辑记录' ? <Tab2log sId={goodsInfo.id} /> : null}
+          {btnAc === '库存状态' ? <Tab3stock /> : null}
+        </div>
+      ) : null}
 
       {/* 点击藏品修改 */}
       {isEdit && goodsInfo.id ? (

+ 2 - 0
后台管理/src/pages/B1ledger/data.ts

@@ -77,6 +77,8 @@ export type B1listType = {
   currentAuditUserIds?: string
 
   oldGoods: string
+
+  type: string
 }
 
 export type GoodsAduitsType = {

+ 6 - 3
后台管理/src/pages/Layout/data.ts

@@ -35,19 +35,22 @@ const tabLeftArr: RouterType = [
         id: 400,
         name: '藏品登记',
         path: '/register',
-        Com: React.lazy(() => import('../B2register'))
+        Com: React.lazy(() => import('../B2register')),
+        pageType: 'DJ'
       },
       {
         id: 500,
         name: '藏品修改',
         path: '/edit',
-        Com: React.lazy(() => import('../B3edit'))
+        Com: React.lazy(() => import('../B3edit')),
+        pageType: 'XG'
       },
       {
         id: 600,
         name: '藏品删除',
         path: '/delete',
-        Com: React.lazy(() => import('../B4delete'))
+        Com: React.lazy(() => import('../B4delete')),
+        pageType: 'SC'
       }
     ]
   },

+ 7 - 0
后台管理/src/store/action/B1ledger.ts

@@ -35,6 +35,13 @@ export const API_getGoodsInfo = (id: number) => {
 }
 
 /**
+ * 藏品详情-编辑记录
+ */
+export const API_getGoodsLog = (goodsId: number) => {
+  return http.get(`cms/goods/order/edit/${goodsId}`)
+}
+
+/**
  * 附件-根据附件ids查询
  */
 export const API_getFileListByIds = (data: number[]) => {

+ 1 - 0
后台管理/src/types/api/layot.d.ts

@@ -10,6 +10,7 @@ export type RouterTypeRow = {
   path: string
   pathLast?: string
   Com: React.LazyExoticComponent<React.MemoExoticComponent<() => JSX.Element>>
+  pageType?: 'DJ' | 'XG' | 'SC'
 }[]
 
 export type RouterType = {

+ 1 - 1
后台管理/src/utils/deriveFu.ts

@@ -36,7 +36,7 @@ const devDownFu = (
 
 // 日期处理
 export const timeChange = (val?: string) => {
-  return val ? dayjs(val).format('YYYY-MM-DD') : '(空)'
+  return val && val !== '(空)' ? dayjs(val).format('YYYY-MM-DD') : '(空)'
 }
 
 // 下拉框处理

+ 4 - 2
后台管理/src/utils/history.ts

@@ -27,11 +27,11 @@ export const backPageFu = (path: string) => {
   else history.push(path)
 }
 
-const userInfo = (getTokenInfo() || {}).user
-
 // 列表按钮的权限-审批
 // 订单状态为待审批,且当前用户为当前节点审批人时
 export const aduitBtnRoleFu = (item: B1listType) => {
+  const userInfo = getTokenInfo().user
+
   let flag = false
 
   if (item.status === 1 && userInfo) {
@@ -50,6 +50,8 @@ export const aduitBtnRoleFu = (item: B1listType) => {
 // 列表按钮的权限-重新提交
 // 申请状态为未通过,且当前用户为订单创建人时
 export const resubmitBtnRoleFu = (item: B1listType) => {
+  const userInfo = getTokenInfo().user
+
   let flag = false
 
   if (item.status === 2 && userInfo) {

+ 7 - 0
后台管理/src/utils/select.ts

@@ -53,3 +53,10 @@ export const statusSelect = [
   { value: 2, label: '审批不通过' },
   { value: 3, label: '已完成' }
 ]
+
+// 藏品状态
+export const goodsSelect = [
+  { value: 1, label: '已登记' },
+  { value: 2, label: '修改中' },
+  { value: 3, label: '删除中' }
+]

+ 9 - 2
后台管理/src/utils/tableData.ts

@@ -14,7 +14,7 @@
 //     ["text", "创建日期",'description', 50,A],
 //   ];
 
-import { dictSelect, statusSelect } from './select'
+import { dictSelect, goodsSelect, statusSelect } from './select'
 
 export const auditTableC = [
   ['txt', '节点名称', 'nodeName'],
@@ -24,6 +24,12 @@ export const auditTableC = [
   ['text', '审批意见', 'rtfOpinion', 100]
 ]
 
+export const goodsLogTableC = [
+  ['txt', '发起人', 'creatorName'],
+  ['time', '发起日期', 'createTime'],
+  ['select', '申请状态', 'status', statusSelect]
+]
+
 export const B1tableC = [
   ['txt', '藏品编号', 'num'],
   ['txt', '藏品标题', 'name'],
@@ -36,7 +42,8 @@ export const B1tableC = [
   ['select', '材质', 'textureDictId', dictSelect('藏品材质')],
   ['txt', '当前位置', '待完善'],
   ['ping', '数量', 'pcs', 'pcsUnitDictId', dictSelect('数量单位')],
-  ['txt', '有无说明牌', 'isNote']
+  ['txt', '有无说明牌', 'isNote'],
+  ['select', '状态', 'status', goodsSelect]
 ]
 
 export const B2tableC = [