Ver código fonte

藏品修改模块开发

shaogen1995 2 dias atrás
pai
commit
0476b56a51

+ 1 - 1
src/components/MyTable/index.module.scss

@@ -15,4 +15,4 @@
       }
     }
   }
-}
+}

+ 26 - 18
src/pages/Cledger/C1ledger/index.tsx

@@ -263,6 +263,7 @@ function C1ledger() {
     setIsModalOpen(false)
   }
 
+  const authorityIds = useSelector((state: RootState) => state.A0Layout.authorityIds)
   // 故事管理/藏品总账定制右侧内容
   const storyTableListToprr = ({
     clickSearch,
@@ -273,24 +274,31 @@ function C1ledger() {
   }) => {
     return (
       <>
-        <Dropdown menu={{ items: rightBtnOptions['dangan'] }} trigger={['click']}>
-          <Button type='primary'>
-            档案管理
-            <CaretDownOutlined />
-          </Button>
-        </Dropdown>
-        <Dropdown menu={{ items: rightBtnOptions['kufang'] }} trigger={['click']}>
-          <Button type='primary'>
-            库房管理
-            <CaretDownOutlined />
-          </Button>
-        </Dropdown>
-        <Dropdown menu={{ items: rightBtnOptions['weihu'] }} trigger={['click']}>
-          <Button type='primary'>
-            藏品维护
-            <CaretDownOutlined />
-          </Button>
-        </Dropdown>
+        {authorityIds.includes(311) ? (
+          <Dropdown menu={{ items: rightBtnOptions['dangan'] }} trigger={['click']}>
+            <Button type='primary'>
+              档案管理
+              <CaretDownOutlined />
+            </Button>
+          </Dropdown>
+        ) : null}
+        {authorityIds.includes(312) ? (
+          <Dropdown menu={{ items: rightBtnOptions['kufang'] }} trigger={['click']}>
+            <Button type='primary'>
+              库房管理
+              <CaretDownOutlined />
+            </Button>
+          </Dropdown>
+        ) : null}
+        {authorityIds.includes(313) ? (
+          <Dropdown menu={{ items: rightBtnOptions['weihu'] }} trigger={['click']}>
+            <Button type='primary'>
+              藏品维护
+              <CaretDownOutlined />
+            </Button>
+          </Dropdown>
+        ) : null}
+
         <Button type='primary' onClick={() => console.log(123)}>
           数据导入
         </Button>

+ 4 - 0
src/pages/Dmanage/D2edit/D2editSon/index.module.scss

@@ -0,0 +1,4 @@
+// .D2editSon {
+//   :global {
+//   }
+// }

+ 42 - 0
src/pages/Dmanage/D2edit/D2editSon/index.tsx

@@ -0,0 +1,42 @@
+import React from 'react'
+import styles from './index.module.scss'
+import { rowArrTemp } from '@/pages/Zother/data'
+import { InfoProvider } from '@/pages/Zother/InfoContext'
+import EditTop from '@/pages/Zother/EditTop'
+import { D2API_obj } from '@/store/action/Dmanage/D2edit'
+import FileArchive from '@/pages/Zother/FileArchive'
+import EditBtn from '@/pages/Zother/EditBtn'
+import D2info from '../D2info'
+
+const rowArr = rowArrTemp('修改')
+
+function D2editSon() {
+  return (
+    <InfoProvider>
+      <div className={styles.D2edit} id='editBox'>
+        <div className='editMain'>
+          {/* 顶部 */}
+          <EditTop
+            pageTxt='藏品修改'
+            rowArr={rowArr}
+            APIobj={D2API_obj}
+            fileUpInfo={{ myUrl: 'cms/order/edit/upload', dirCode: 'goodEdit' }}
+          />
+
+          {/* 详情 */}
+          <D2info />
+
+          {/* 附件归档 */}
+          <FileArchive />
+
+          {/* 底部按钮 */}
+          <EditBtn path='/edit' APIobj={D2API_obj} checkListTxt='请选择关联藏品' isEdit={true} />
+        </div>
+      </div>
+    </InfoProvider>
+  )
+}
+
+const MemoD2editSon = React.memo(D2editSon)
+
+export default MemoD2editSon

+ 89 - 0
src/pages/Dmanage/D2edit/D2info/index.module.scss

@@ -0,0 +1,89 @@
+.D2info {
+  :global {
+    .EdTit {
+      padding: 15px;
+      font-weight: 700;
+      font-size: 18px;
+      display: flex;
+      justify-content: space-between;
+      .ant-btn {
+        margin-left: 15px;
+      }
+      .EdTitBtn {
+        pointer-events: none;
+      }
+    }
+
+    .Edtop1 {
+      border-top: 1px solid #ccc;
+      padding-top: 15px;
+      display: flex;
+      justify-content: space-between;
+      flex-wrap: wrap;
+      .Edtop1row {
+        display: flex;
+        width: 48%;
+        margin-bottom: 15px;
+        min-height: 32px;
+        line-height: 32px;
+        .Edtop1ll {
+          font-weight: 700;
+          width: 100px;
+          text-align: right;
+
+          span {
+            color: #ff4d4f;
+          }
+        }
+        .Edtop1rr {
+          width: calc(100% - 100px);
+          & > div {
+            width: 100%;
+          }
+          .ant-btn {
+            margin-right: 15px;
+          }
+        }
+
+        .Edtop1rr2 {
+          border-radius: 6px;
+          overflow: hidden;
+          width: calc(48% - 100px);
+          border: 1px solid #ccc;
+          height: 60px;
+          display: flex;
+          padding-right: 10px;
+          justify-content: space-between;
+          & > div {
+            height: 100%;
+            line-height: 60px;
+          }
+          .Edtop1rr2Txt {
+            width: calc(100% - 180px);
+            color: var(--txtColor);
+            text-align: center;
+
+            overflow: hidden;
+            text-overflow: ellipsis;
+            white-space: nowrap;
+          }
+        }
+      }
+      .Edtop1rowFull {
+        width: 100%;
+      }
+    }
+
+    .tableTxtAc {
+      color: var(--txtColor);
+    }
+    #tableTxtAc2 {
+      color: var(--myAntdColor) !important;
+      margin: 0 10px;
+      border-bottom: 1px solid var(--myAntdColor);
+    }
+    .ant-table-cell {
+      padding: 8px !important;
+    }
+  }
+}

+ 230 - 0
src/pages/Dmanage/D2edit/D2info/index.tsx

@@ -0,0 +1,230 @@
+import React, { useCallback, useEffect, useMemo, useState } from 'react'
+import styles from './index.module.scss'
+import { useInfo } from '@/pages/Zother/InfoContext'
+import ImageLazy from '@/components/ImageLazy'
+import { Button } from 'antd'
+import { openLink } from '@/utils/history'
+import { useParams } from 'react-router-dom'
+import { GIrowArr } from '@/pages/ZgoodsInfo/data'
+import { API_getFileListByIds } from '@/store/action/Cledger/C4file'
+import MyTable from '@/components/MyTable'
+import { baseURL } from '@/utils/http'
+import { GoodsType } from '@/pages/Zother/SonGoodsList/data'
+import { resTagFu } from '@/utils/dataChange'
+import AddGoods from '@/pages/Zother/AddGoods'
+import { MessageFu } from '@/utils/message'
+import { arrFiltersFu } from '@/utils'
+
+function D2info() {
+  const { snaps, editObj, setEditObjFu } = useInfo()
+  const { key } = useParams<any>()
+  // key:1 新增 2编辑 3审批 4查看
+  const isLook = useMemo(() => {
+    return ['3', '4'].includes(key)
+  }, [key])
+
+  const [tableList, setTableList] = useState<any[]>([])
+
+  const getList = useCallback(async (changeObj: any) => {
+    // console.log('-------', changeObj)
+
+    let resArr: any[] = []
+    if (changeObj.keyArr) {
+      const arr = [
+        ...GIrowArr,
+        { key: 'name', name: '藏品名称' },
+        {
+          key: 'tagDictId',
+          name: '藏品标签',
+          resFu: (info: GoodsType) => {
+            let resTxt = info.tagDictId
+            if (resTxt) return resTagFu(resTxt) || '(空)'
+            return resTxt || '(空)'
+          }
+        }
+      ]
+
+      const oldInfo: any = changeObj.old
+      const newInfo: any = changeObj.new
+      const keyArr = changeObj.keyArr
+      arr.forEach(v1 => {
+        keyArr.forEach((v2: any) => {
+          const type = typeof v1.key
+          let flag = false
+          flag = type === 'string' ? v1.key === v2 : v1.key.includes(v2)
+
+          if (flag) {
+            resArr.push({
+              id: v2,
+              label: v1.name,
+              old: v1.resFu ? v1.resFu(oldInfo) : oldInfo[v2],
+              new: v1.resFu ? v1.resFu(newInfo) : newInfo[v2]
+            })
+          }
+        })
+      })
+
+      if (keyArr.includes('thumb')) {
+        resArr.push({
+          id: 'thumb',
+          label: '封面图',
+          old: { thumb: oldInfo.thumb, thumbPc: oldInfo.thumbPc },
+          new: { thumb: newInfo.thumb, thumbPc: newInfo.thumbPc }
+        })
+      }
+
+      if (keyArr.includes('fileIds')) {
+        // 有藏品附件
+        let ids: any = new Set([...oldInfo['fileIds'].split(','), ...newInfo['fileIds'].split(',')])
+
+        const res = await API_getFileListByIds([...ids].filter(v => v))
+        if (res.code === 0) {
+          const fileList: any[] = res.data || []
+
+          resArr.push({
+            id: 'fileIds',
+            label: '附件',
+            old: fileList.filter(v => oldInfo['fileIds'].includes(v.id + '')),
+            new: fileList.filter(v => newInfo['fileIds'].includes(v.id + ''))
+          })
+          setTableList(arrFiltersFu(resArr, 'label'))
+        }
+      } else setTableList(arrFiltersFu(resArr, 'label'))
+    }
+  }, [])
+
+  useEffect(() => {
+    getList(editObj)
+  }, [editObj, getList])
+
+  const tableLastBtn2Fu = useCallback((item: any, key: 'new' | 'old') => {
+    if (item.label === '附件') {
+      let arr = item[key] as any[]
+
+      return arr.length
+        ? arr.map((v: any) => (
+            <a
+              id='tableTxtAc2'
+              key={v.id}
+              href={baseURL + v.filePath}
+              download
+              target='_blank'
+              rel='noreferrer'
+            >
+              {v.fileName}
+            </a>
+          ))
+        : '-'
+    } else if (item.label === '封面图') {
+      const info: any = item[key]
+
+      return (
+        <div className='tableImgAuto'>
+          <ImageLazy
+            width={60}
+            height={60}
+            srcBig={info.thumbPc || info.thumb}
+            src={info.thumb || info.thumbPc}
+          />
+        </div>
+      )
+    } else return item[key] || '(空)'
+  }, [])
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        width: 300,
+        title: '编辑项',
+        render: (item: any) =>
+          ['封面图', '附件'].includes(item.label) ? (
+            <span className='tableTxtAc'>{item.label}</span>
+          ) : (
+            item.label
+          )
+      },
+      {
+        title: '编辑前',
+        render: (item: any) => tableLastBtn2Fu(item, 'old')
+      },
+      {
+        title: '编辑后',
+        render: (item: any) => tableLastBtn2Fu(item, 'new')
+      }
+    ]
+  }, [tableLastBtn2Fu])
+
+  // 点击重新编辑
+  const [goodInfo, setGoodInfo] = useState({} as GoodsType)
+
+  return (
+    <div className={styles.D2info}>
+      <div className='EdTit'>
+        <div>修改详情</div>
+      </div>
+      <div className='Edtop1'>
+        <div className='Edtop1row Edtop1rowFull'>
+          <div className='Edtop1ll'>
+            <span>* </span>
+            关联藏品:
+          </div>
+          {snaps.length > 0 ? (
+            <div className='Edtop1rr2'>
+              <ImageLazy
+                width={60}
+                height={58}
+                src={snaps[0].thumb || snaps[0].thumbPc}
+                srcBig={snaps[0].thumbPc || snaps[0].thumb}
+              />
+              <div className='Edtop1rr2Txt' title={snaps[0].num + ' - ' + snaps[0].name}>
+                {snaps[0].num + ' - ' + snaps[0].name}
+              </div>
+              <div>
+                <Button
+                  type='text'
+                  size='small'
+                  onClick={() => openLink(`/goodsLook/${snaps[0].id}`)}
+                >
+                  查看
+                </Button>
+                {isLook ? null : (
+                  <Button type='text' size='small' onClick={() => setGoodInfo(editObj.new)}>
+                    重新编辑
+                  </Button>
+                )}
+              </div>
+            </div>
+          ) : isLook ? (
+            '(空)'
+          ) : null}
+        </div>
+      </div>
+
+      <MyTable list={tableList} columnsTemp={[]} lastBtn={tableLastBtn} pagingInfo={false} />
+
+      {/* 藏品编辑弹窗 */}
+      {goodInfo.id ? (
+        <AddGoods
+          info={goodInfo}
+          editSnap={goodInfo}
+          closeFu={() => setGoodInfo({} as GoodsType)}
+          isEdit={true}
+          succFu={async (val, newObj, oldObj, keyArr) => {
+            const newCanObj = { new: newObj, old: oldObj, keyArr }
+            getList(newCanObj)
+            setEditObjFu(newCanObj)
+            MessageFu.success('重新编辑成功')
+            setGoodInfo({} as GoodsType)
+          }}
+          moduleId={0}
+          fileUpInfo={{ myUrl: 'cms/order/edit/son/upload', dirCode: 'goodEditSon' }}
+          APIsave={null}
+        />
+      ) : null}
+    </div>
+  )
+}
+
+const MemoD2info = React.memo(D2info)
+
+export default MemoD2info

+ 94 - 1
src/pages/Dmanage/D2edit/index.tsx

@@ -1,9 +1,102 @@
-import React from 'react'
+import React, { useState } from 'react'
 import styles from './index.module.scss'
+import { baseFormData, topSearch } from '@/pages/Zother/data'
+import { useSelector } from 'react-redux'
+import { RootState } from '@/store'
+import TableList from '@/pages/Zother/TableList'
+import { D2_APIgetClueList, D2_APIgetList, D2API_obj } from '@/store/action/Dmanage/D2edit'
+import { baseTableC, goodsSonTableC } from '@/utils/tableData'
+import SelectGoods from '@/pages/Zother/SelectGoods'
+import { GoodsType, sgBaseFormDataGood, sgTopSelectDomGood } from '@/pages/Zother/SonGoodsList/data'
+import AddGoods from '@/pages/Zother/AddGoods'
+import { MessageFu } from '@/utils/message'
+import history from '@/utils/history'
+
+const search = topSearch('修改')
+
+const baseFormDataRes = baseFormData()
+
 function D2edit() {
+  // 从仓库拿数据
+  const tableInfo = useSelector((state: RootState) => state.D2edit.tableInfo)
+
+  const [editShow, setEditShow] = useState(false)
+
+  const [goodInfo, setGoodInfo] = useState({} as GoodsType)
+
   return (
     <div className={styles.D2edit}>
       <div className='pageTitle'>藏品修改</div>
+
+      <TableList
+        baseFormData={baseFormDataRes}
+        getListAPI={D2_APIgetList}
+        pageKey='edit'
+        tableInfo={tableInfo}
+        columnsTemp={baseTableC('修改')}
+        yHeight={585}
+        searchDom={search}
+        // 藏品修改特有的字段
+        isEdit={() => setEditShow(true)}
+      />
+
+      {/* 打开选择藏品的弹窗-单选 */}
+      {editShow ? (
+        <SelectGoods
+          myType='藏品'
+          API_getList={D2_APIgetClueList}
+          closeFu={() => setEditShow(false)}
+          baseFormData={sgBaseFormDataGood}
+          topSelectDom={sgTopSelectDomGood}
+          columnsTemp={goodsSonTableC(true)}
+          oldCheckArr={[]}
+          isOne={true}
+          dataResFu={res => {
+            if (res && res[0] && res[0].id) {
+              setGoodInfo(res[0])
+            }
+          }}
+        />
+      ) : null}
+
+      {/* 藏品编辑弹窗 */}
+      {goodInfo.id ? (
+        <AddGoods
+          info={goodInfo}
+          closeFu={() => setGoodInfo({} as GoodsType)}
+          isEdit={true}
+          succFu={async (val, newObj, oldObj, keyArr) => {
+            const res = await D2API_obj['创建订单']()
+            if (res.code === 0) {
+              const dingDanObj = res.data
+              const obj = {
+                ...dingDanObj,
+                goodIds: newObj.id + '',
+                snaps: [
+                  {
+                    id: null,
+                    goodId: newObj.id,
+                    orderId: dingDanObj.id,
+                    snap: JSON.stringify({
+                      new: newObj,
+                      old: oldObj,
+                      keyArr
+                    })
+                  }
+                ]
+              }
+              const res2 = await D2API_obj['草稿'](obj)
+              if (res2.code === 0) {
+                MessageFu.success('藏品修改-' + val + '订单成功')
+                history.push(`/edit_edit/2/${dingDanObj.id}`)
+              }
+            }
+          }}
+          moduleId={0}
+          fileUpInfo={{ myUrl: 'cms/order/edit/son/upload', dirCode: 'goodEditSon' }}
+          APIsave={null}
+        />
+      ) : null}
     </div>
   )
 }

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

@@ -364,6 +364,12 @@ export const routerSon: RouterTypeRow[] = [
     Com: React.lazy(() => import('../Dmanage/D1register/D1edit'))
   },
   {
+    id: 420,
+    name: '藏品修改-详情页',
+    path: '/edit_edit/:key/:id',
+    Com: React.lazy(() => import('../Dmanage/D2edit/D2editSon'))
+  },
+  {
     id: 430,
     name: '藏品注销-详情页',
     path: '/writeOff_edit/:key/:id',

+ 2 - 2
src/pages/ZgoodsInfo/GItab1/index.tsx

@@ -25,8 +25,8 @@ function GItab1({ info, fileList }: Props) {
   return (
     <div className={styles.GItab1}>
       <div className='GI1left' style={{ width: imgList.length === 0 ? '100%' : '' }}>
-        {GIrowArr.map(item => (
-          <div key={item.key} className={classNames('GI1Lrow', item.full ? 'GI1LrowFull' : '')}>
+        {GIrowArr.map((item, index) => (
+          <div key={index} className={classNames('GI1Lrow', item.full ? 'GI1LrowFull' : '')}>
             <div>{item.name}</div>
             <p>{item.resFu ? item.resFu(info) : info[item.key as 'num'] || '(空)'}</p>
           </div>

+ 36 - 10
src/pages/ZgoodsInfo/GItab5/index.tsx

@@ -1,12 +1,14 @@
-import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import React, { useCallback, useEffect, useMemo, useState } from 'react'
 import styles from './index.module.scss'
-import { Button, Input, Select } from 'antd'
-import { Typetable } from '@/pages/Zother/data'
+import { Button, Select } from 'antd'
 import { API_GIlog } from '@/store/action/Cledger/C1ledger'
 import history from '@/utils/history'
 import MyTable from '@/components/MyTable'
 import { GI5tableC } from '@/utils/tableData'
 import tabLeftArr from '@/pages/Layout/data'
+import { GI5tableType } from '../data'
+import { MessageFu } from '@/utils/message'
+import { authorityFu } from '@/utils/authority'
 
 type Props = {
   goodId: number
@@ -15,7 +17,7 @@ type Props = {
 function GItab5({ goodId }: Props) {
   const [type, setType] = useState(null)
 
-  const [tableList, setTableList] = useState<any[]>([])
+  const [tableList, setTableList] = useState<GI5tableType[]>([])
 
   // 封装发送请求的函数
   const getListFu = useCallback(async () => {
@@ -38,16 +40,26 @@ function GItab5({ goodId }: Props) {
     getListFu()
   }, [getListFu])
 
+  const [list, setList] = useState<any[]>([])
+
   const tableLastBtn = useMemo(() => {
     return [
       {
         title: '操作',
-        render: (item: Typetable) => (
+        render: (item: GI5tableType) => (
           <>
             <Button
               size='small'
               type='text'
-              onClick={() => history.push(`/story_edit/4/${item.id}`)}
+              onClick={() => {
+                console.log(item)
+                const obj = list.find(v => v.value === item.type)
+                if (obj) {
+                  authorityFu(obj.id, obj.label, () =>
+                    history.push(`${obj.path}_edit/4/${item.id}`)
+                  )
+                } else MessageFu.warning('申请类型错误')
+              }}
             >
               查看
             </Button>
@@ -55,19 +67,33 @@ function GItab5({ goodId }: Props) {
         )
       }
     ]
-  }, [])
+  }, [list])
 
-  const [list, setList] = useState<any[]>([])
   useEffect(() => {
     const arr: any[] = []
     tabLeftArr.forEach(v1 => {
       v1.son.forEach(v2 => {
-        if (v2.pageType) arr.push({ path: v2.path, value: v2.pageType, label: v2.name })
+        if (v2.pageType) arr.push({ path: v2.path, value: v2.pageType, label: v2.name, id: v2.id })
       })
     })
+
     setList(arr)
   }, [])
 
+  const staBtn = useMemo(() => {
+    return [
+      {
+        title: '申请类型',
+        render: (item: GI5tableType) => {
+          let txt = '(空)'
+          const obj = list.find(v => v.value === item.type)
+          if (obj) txt = obj.label
+          return txt
+        }
+      }
+    ]
+  }, [list])
+
   return (
     <div className={styles.GItab5}>
       <div className='GI5top'>
@@ -85,9 +111,9 @@ function GItab5({ goodId }: Props) {
         classKey='GItab5'
         yHeight={560}
         list={tableList}
-        // 待完善sg ---等后端
         columnsTemp={GI5tableC}
         lastBtn={tableLastBtn}
+        staBtn={staBtn}
         pagingInfo={false}
         widthSet={{ remark: 800 }}
       />

+ 42 - 6
src/pages/ZgoodsInfo/data.ts

@@ -18,7 +18,7 @@ export const GIrowArr = [
   { key: 'ageDictId', name: '藏品年代', resFu: (info: GoodsType) => resJiLianFu(info.ageDictId) },
   { key: 'ageInfo', name: '具体年代' },
   {
-    key: 'pcs',
+    key: ['pcs', 'pcsUnitDictId'],
     name: '实际数量',
     resFu: (info: GoodsType) => {
       let jlTxt = resJiLianFu(info.pcsUnitDictId)
@@ -35,16 +35,18 @@ export const GIrowArr = [
   { key: 'tornInfo', name: '完残状况' },
   { key: 'keep', name: '保存状态', full: true },
   { key: 'keepInfo', name: '保护修复情况', full: true },
-  { key: 'sizeL', name: '尺寸(cm)', resFu: (info: GoodsType) => myTableTransferSize(info) },
+  {
+    key: ['sizeL', 'sizeW', 'sizeH'],
+    name: '尺寸(cm)',
+    resFu: (info: GoodsType) => myTableTransferSize(info)
+  },
   { key: 'sizeInfo', name: '具体尺寸' },
   { key: 'qualityScope', name: '质量范围' },
   {
-    key: 'quality',
+    key: ['quality', 'qualityUnitDictId'],
     name: '具体质量',
     resFu: (info: GoodsType) => {
-      let jlTxt = resJiLianFu(info.qualityUnitDictId)
-      jlTxt = jlTxt === isNull ? '' : jlTxt
-      return info.quality && jlTxt ? info.quality + jlTxt : isNull
+      return `${info.quality || isNull}${info.qualityUnitDictId || ''}`
     }
   },
   {
@@ -67,3 +69,37 @@ export const GIrowArr = [
   { key: 'intro', name: '藏品简介', full: true },
   { key: 'remark', name: '备注', full: true }
 ]
+
+export type GI5tableType = {
+  auditUserIds: string
+  audits: any[]
+  createTime: string
+  creatorId: number
+  creatorName: string
+  currentAuditUserIds: string
+  currentProcessId: number
+  date: string
+  dateEnd?: any
+  dateStart?: any
+  deptName: string
+  dictIdApply?: any
+  fileIds: string
+  files: any[]
+  goodIds: string
+  id: number
+  nodeProcessId: number
+  num: string
+  reason?: any
+  remark?: any
+  showId?: any
+  showName?: any
+  snapName: string
+  snapNum: string
+  snapType?: any
+  snaps: any[]
+  status: number
+  storageId?: any
+  storageName?: any
+  type: string
+  updateTime: string
+}

+ 52 - 5
src/pages/ZgoodsInfo/index.tsx

@@ -20,6 +20,8 @@ import { MessageFu } from '@/utils/message'
 import { FileListType } from '@/components/Z3upFiles/data'
 import { API_getFileListByIds } from '@/store/action/Cledger/C4file'
 import { infoPageIDGet, infoPageIDSet } from '@/utils/storage'
+import AddGoods from '../Zother/AddGoods'
+import { D2API_obj } from '@/store/action/Dmanage/D2edit'
 
 type tabArr1Type = {
   id: number
@@ -76,6 +78,9 @@ function ZgoodsInfo() {
     ]
   }, [fileList, info])
 
+  // 藏品修改模块特有的
+  const [goodInfo, setGoodInfo] = useState({} as GoodsType)
+
   // 点击的时候校验前置状态和页面权限
   const tabArr2Temp = useMemo(() => {
     return [
@@ -90,7 +95,7 @@ function ZgoodsInfo() {
             label: '修改',
             onClick: () => {
               if (info.isEdit === 1) return MessageFu.warning(`当前藏品为 修改中 状态,不可 修改`)
-              authorityFu(420, '藏品修改', () => history.push(`/edit_edit/1/null?gId=${id}`))
+              authorityFu(420, '藏品修改', () => setGoodInfo(info))
             }
           },
           {
@@ -221,13 +226,17 @@ function ZgoodsInfo() {
   // 获取标签
   const tagDom = useMemo(() => {
     let dom: any = ''
+
     if (info.tagDictId) {
       dom = []
       const txt: string = resTagFu(info.tagDictId)
-      const arr = txt.split(';')
-      arr.forEach((v, i) => {
-        dom.push(<Tag key={i}>{v}</Tag>)
-      })
+
+      if (txt) {
+        const arr = txt.split(';')
+        arr.forEach((v, i) => {
+          dom.push(<Tag key={i}>{v}</Tag>)
+        })
+      }
     }
     return dom
   }, [info.tagDictId])
@@ -316,6 +325,44 @@ function ZgoodsInfo() {
           找不到相关藏品信息
         </div>
       )}
+      {/* 藏品编辑弹窗 */}
+      {goodInfo.id ? (
+        <AddGoods
+          info={goodInfo}
+          closeFu={() => setGoodInfo({} as GoodsType)}
+          isEdit={true}
+          succFu={async (val, newObj, oldObj, keyArr) => {
+            const res = await D2API_obj['创建订单']()
+            if (res.code === 0) {
+              const dingDanObj = res.data
+              const obj = {
+                ...dingDanObj,
+                goodIds: newObj.id + '',
+                snaps: [
+                  {
+                    id: null,
+                    goodId: newObj.id,
+                    orderId: dingDanObj.id,
+                    snap: JSON.stringify({
+                      new: newObj,
+                      old: oldObj,
+                      keyArr
+                    })
+                  }
+                ]
+              }
+              const res2 = await D2API_obj['草稿'](obj)
+              if (res2.code === 0) {
+                MessageFu.success('藏品修改-' + val + '订单成功')
+                history.push(`/edit_edit/2/${dingDanObj.id}`)
+              }
+            }
+          }}
+          moduleId={0}
+          fileUpInfo={{ myUrl: 'cms/order/edit/son/upload', dirCode: 'goodEditSon' }}
+          APIsave={null}
+        />
+      ) : null}
     </div>
   )
 }

+ 112 - 53
src/pages/Zother/AddGoods/index.tsx

@@ -40,14 +40,24 @@ type Props = {
   info: GoodsType
   closeFu: () => void
   isEdit: boolean //藏品编辑-模块
-  succFu: (val: '新增' | '编辑', info: GoodsType) => void
+  editSnap?: GoodsType //藏品模块属于新增还是编辑
+  succFu: (val: '新增' | '编辑', info: GoodsType, oldInfo?: GoodsType, keyArr?: string[]) => void
   moduleId: number
   // 上传附件的信息
   fileUpInfo: FileUpInfoType
   APIsave: any
 }
 
-function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo }: Props) {
+function AddGoods({
+  closeFu,
+  succFu,
+  isEdit,
+  moduleId,
+  info,
+  APIsave,
+  fileUpInfo,
+  editSnap
+}: Props) {
   // 获取标签 树结构
   const E1tree = useSelector((state: RootState) => state.E1tag.treeData)
 
@@ -61,44 +71,47 @@ function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo
   const fileRef = useRef<any>(null)
 
   // 藏品编辑模块用来对比
-  const objOld = useRef({} as GoodsType)
+  const objOld = useRef<any>({})
 
-  const resInfoFu = useCallback(async (infoRes: GoodsType) => {
-    // 藏品编辑信息保存
-    objOld.current = { ...infoRes }
+  const resInfoFu = useCallback(
+    async (infoRes: GoodsType) => {
+      // 藏品编辑信息保存
+      objOld.current = { ...infoRes }
 
-    const obj: any = { ...infoRes }
-    // makeDate inGoodYear 2个日期需要格式处理一下
-    if (obj.makeDate) obj.makeDate = dayjs(obj.makeDate)
-    if (obj.inGoodYear) obj.inGoodYear = dayjs(obj.inGoodYear)
+      const obj: any = editSnap && editSnap.id ? { ...editSnap } : { ...infoRes }
+      // makeDate inGoodYear 2个日期需要格式处理一下
+      if (obj.makeDate) obj.makeDate = dayjs(obj.makeDate)
+      if (obj.inGoodYear) obj.inGoodYear = dayjs(obj.inGoodYear)
 
-    cascaderChArr.forEach(v => {
-      if (obj[v] === '0') obj[v] = null
-      else if (obj[v]) {
-        obj[v] = obj[v].split(',')
-      }
-    })
+      cascaderChArr.forEach(v => {
+        if (obj[v] === '0') obj[v] = null
+        else if (obj[v]) {
+          obj[v] = obj[v].split(',')
+        }
+      })
 
-    addZiSelectChArr.forEach(v => {
-      if (!obj[v]) obj[v] = null
-    })
+      addZiSelectChArr.forEach(v => {
+        if (!obj[v]) obj[v] = null
+      })
 
-    // 处理藏品标签
-    if (obj.tagDictId) {
-      const tagDictId = obj.tagDictId.split(';').map((item: string) => item.split(','))
-      obj.tagDictId = tagDictId
-    }
+      // 处理藏品标签
+      if (obj.tagDictId) {
+        const tagDictId = obj.tagDictId.split(';').map((item: string) => item.split(','))
+        obj.tagDictId = tagDictId
+      }
 
-    FormBoxRef.current?.setFieldsValue(obj)
+      FormBoxRef.current?.setFieldsValue(obj)
 
-    // 设置附件
-    if (obj.fileIds) {
-      const fileRes = await API_getFileListByIds(obj.fileIds.split(','))
-      if (fileRes.code === 0) {
-        fileRef.current?.sonSetListFu(fileRes.data || [])
+      // 设置附件
+      if (obj.fileIds) {
+        const fileRes = await API_getFileListByIds(obj.fileIds.split(','))
+        if (fileRes.code === 0) {
+          fileRef.current?.sonSetListFu(fileRes.data || [])
+        }
       }
-    }
-  }, [])
+    },
+    [editSnap]
+  )
 
   // 编辑进来获取详情
   const getInfo = useCallback(
@@ -127,12 +140,18 @@ function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo
       // 获取附件
       const { list: flieList, thumb, thumbPc } = fileRef.current?.sonResListFu()
       // 获取故事
-      const { guShiList, delIds } = guShiRef.current?.getGuShiListBySon()
+      let guShiList: any[] = []
+      let delIds: any[] = []
+      if (guShiRef.current) {
+        const gushiInfo = guShiRef.current?.getGuShiListBySon()
+        guShiList = gushiInfo.guShiList
+        delIds = gushiInfo.delIds
+      }
       // 2个日期的格式处理
       let makeDate = ''
       if (values.makeDate) makeDate = dayjs(values.makeDate).format('YYYY-MM-DD')
       let inGoodYear = ''
-      if (values.inGoodYear) inGoodYear = dayjs(values.inGoodYear).format('YYYY-MM-DD')
+      if (values.inGoodYear) inGoodYear = dayjs(values.inGoodYear).format('YYYY')
 
       const obj = {
         ...values,
@@ -170,30 +189,66 @@ function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo
       //   return
       // }
 
-      const res = await APIsave(obj)
-      if (res.code === 0) {
-        MessageFu.success(info.id > 0 ? '编辑成功' : '新增成功')
+      if (isEdit) {
+        // 藏品编辑模块
+        let flag = true
+        const oldInfoObj = { ...objOld.current }
+        if (oldInfoObj.makeDate)
+          oldInfoObj.makeDate = dayjs(oldInfoObj.makeDate).format('YYYY-MM-DD')
+        if (oldInfoObj.inGoodYear)
+          oldInfoObj.inGoodYear = dayjs(oldInfoObj.inGoodYear).format('YYYY')
+
+        const keyArr: string[] = []
+
+        for (const k in obj) {
+          if (!['delStoryIds', 'storyIds'].includes(k)) {
+            if ((oldInfoObj[k] || obj[k]) && oldInfoObj[k] !== obj[k]) {
+              keyArr.push(k)
+              flag = false
+            }
+          }
+        }
+
         // if (1 + 1 === 2) {
-        //   console.log('----------------', info)
+        //   console.log('---------', keyArr, oldInfoObj, obj)
         //   return
         // }
 
-        const resObj = { ...res.data }
-        if (info.pageType === 'clue') {
-          resObj.clueId = info.id
-        }
+        if (flag) return MessageFu.warning('未修改藏品信息')
 
-        succFu(info.id > 0 ? '编辑' : '新增', resObj)
-        closeFu()
+        succFu(editSnap ? '编辑' : '新增', obj, oldInfoObj, keyArr)
+      } else {
+        const res = await APIsave(obj)
+        if (res.code === 0) {
+          MessageFu.success(info.id > 0 ? '编辑成功' : '新增成功')
+          // if (1 + 1 === 2) {
+          //   console.log('----------------', info)
+          //   return
+          // }
+
+          const resObj = { ...res.data }
+          if (info.pageType === 'clue') {
+            resObj.clueId = info.id
+          }
+
+          succFu(info.id > 0 ? '编辑' : '新增', resObj)
+          closeFu()
+        }
       }
     },
-    [APIsave, closeFu, info, succFu]
+    [APIsave, closeFu, editSnap, info.id, info.pageType, isEdit, succFu]
   )
 
   return (
     <div className={styles.AddGoods}>
       <div className='AGbox'>
-        <div className='AG1'>{isEdit ? '藏品修改' : info.id > 0 ? '藏品编辑' : '藏品新增'}</div>
+        <div className='AG1'>
+          {isEdit
+            ? `藏品修改${editSnap ? '- 编辑' : '- 新增'}`
+            : info.id > 0
+              ? '藏品编辑'
+              : '藏品新增'}
+        </div>
 
         <Form
           scrollToFirstError={true}
@@ -440,13 +495,17 @@ function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo
               </div>
             </div>
             {/* 横线 */}
-            <div className='AGxian'></div>
-            <div className='AGfull'>
-              <div className='AGfullll'>故事:</div>
-              <div className='AGfullrr'>
-                <GuShi moduleId={moduleId} ref={guShiRef} goodsId={info.id} />
-              </div>
-            </div>
+            {isEdit ? null : (
+              <>
+                <div className='AGxian'></div>
+                <div className='AGfull'>
+                  <div className='AGfullll'>故事:</div>
+                  <div className='AGfullrr'>
+                    <GuShi moduleId={moduleId} ref={guShiRef} goodsId={info.id} />
+                  </div>
+                </div>
+              </>
+            )}
 
             {/* 确定和取消按钮 */}
             <Form.Item className='AGbtnok'>

+ 16 - 3
src/pages/Zother/EditBtn/index.tsx

@@ -26,6 +26,8 @@ type Props = {
   getExtraData?: (info: Typetable, snaps: GoodsType[]) => { storageId?: number; snaps?: any[] }
   // 第二个模块
   isTow?: boolean
+  // 藏品修改模块
+  isEdit?: boolean
 }
 
 function EditBtn({
@@ -35,9 +37,10 @@ function EditBtn({
   verifyArr = [{ key: 'num', txt: '请输入申请编号' }],
   verifyBackFu,
   getExtraData,
-  isTow
+  isTow,
+  isEdit
 }: Props) {
-  const { info, info2, snaps, setTimeKeyFu, auditInfo } = useInfo()
+  const { info, info2, snaps, setTimeKeyFu, auditInfo, editObj } = useInfo()
 
   const [btnCan, setBtnCan] = useState({ status: 0, creatorId: 0 })
 
@@ -123,6 +126,12 @@ function EditBtn({
               snapSon.fileIds2 = info.files2.map(v => v.id).join(',')
             }
           }
+
+          // 藏品修改模块----------
+          if (isEdit && i === 0) {
+            snapSon = editObj
+          }
+
           // console.log('xxxxxxxx', snapSon)
 
           snapsArr.push({
@@ -163,7 +172,9 @@ function EditBtn({
         }
 
         // if (1 + 1 === 2) {
-        //   console.log('xxxxxxxxx', obj.snaps)
+        //   // console.log('--------', obj)
+
+        //   console.log('xxxxxxxxx', JSON.parse(obj.snaps[0].snap))
         //   return
         // }
 
@@ -281,9 +292,11 @@ function EditBtn({
       APIobj,
       auditInfo,
       checkListTxt,
+      editObj,
       getExtraData,
       info,
       info2,
+      isEdit,
       isLook,
       isTow,
       key,

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

@@ -52,7 +52,8 @@ type Props = {
 }
 
 function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
-  const { info, setInfoFu, snaps, setSnapsFu, timeKey, auditInfo, setAuditInfoFu } = useInfo()
+  const { info, setInfoFu, snaps, setSnapsFu, timeKey, auditInfo, setAuditInfoFu, setEditObjFu } =
+    useInfo()
 
   // 从藏品详情进来的-获取藏品详情
   const getGoodsInfoFu = useCallback(
@@ -115,7 +116,7 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
 
         // 设置有关藏品的信息
         // 藏品清单快照信息id对比
-        const arrTemp: any = []
+        let arrTemp: any = []
 
         const snapsTemp = data.snaps || []
         snapsTemp.forEach(async (v: any, i: number) => {
@@ -156,10 +157,16 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
         })
 
         // console.log('-------', arrTemp)
-        setSnapsFu(arrTemp.filter((v: any) => v.idTemp))
+        if (pageTxt === '藏品修改') {
+          if (arrTemp[0] && arrTemp[0].old) {
+            const editObj = arrTemp[0].old
+            setSnapsFu([{ ...editObj, idTemp: editObj.id }])
+            setEditObjFu(arrTemp[0])
+          }
+        } else setSnapsFu(arrTemp.filter((v: any) => v.idTemp))
       }
     },
-    [APIobj, moreDom, pageTxt, setInfoFu, setSnapsFu]
+    [APIobj, moreDom, pageTxt, setEditObjFu, setInfoFu, setSnapsFu]
   )
 
   useEffect(() => {

+ 25 - 2
src/pages/Zother/InfoContext.tsx

@@ -12,6 +12,8 @@ type InfoContextValue = {
   setTimeKeyFu: () => void
   auditInfo: { status: number; rtfOpinion: string }
   setAuditInfoFu: (key: 'status' | 'rtfOpinion', val: string | number) => void
+  editObj: { new: GoodsType; old: GoodsType; keyArr: string[] }
+  setEditObjFu: (val: any) => void
 }
 
 type Props = {
@@ -70,6 +72,13 @@ export function InfoProvider({ children }: Props) {
     setSnaps(snaps)
   }, [])
 
+  // 藏品修改信息
+  const [editObj, setEditObj] = useState({} as any)
+
+  const setEditObjFu = useCallback((val: any) => {
+    setEditObj(val)
+  }, [])
+
   const value = useMemo(
     () => ({
       info,
@@ -80,9 +89,23 @@ export function InfoProvider({ children }: Props) {
       timeKey,
       setTimeKeyFu,
       auditInfo,
-      setAuditInfoFu
+      setAuditInfoFu,
+      editObj,
+      setEditObjFu
     }),
-    [auditInfo, info, info2, setAuditInfoFu, setInfoFu, setSnapsFu, setTimeKeyFu, snaps, timeKey]
+    [
+      auditInfo,
+      editObj,
+      info,
+      info2,
+      setAuditInfoFu,
+      setEditObjFu,
+      setInfoFu,
+      setSnapsFu,
+      setTimeKeyFu,
+      snaps,
+      timeKey
+    ]
   )
 
   return <InfoContext.Provider value={value}>{children}</InfoContext.Provider>

+ 11 - 2
src/pages/Zother/TableList/index.tsx

@@ -37,6 +37,8 @@ type Props = {
   // antd Table rowSelection 配置(例如跨页多选)
   rowSelection?: any
   staBtn?: any
+  // 藏品修改特有的字段
+  isEdit?: () => void
 }
 
 const TableList = forwardRef<any, Props>(function TableList(props, ref) {
@@ -54,7 +56,8 @@ const TableList = forwardRef<any, Props>(function TableList(props, ref) {
     storyTableListToprr,
     extraParams,
     rowSelection,
-    staBtn
+    staBtn,
+    isEdit
   } = props
   const dispatch = useDispatch()
   const _searchDom = useRef(searchDom)
@@ -225,7 +228,13 @@ const TableList = forwardRef<any, Props>(function TableList(props, ref) {
             storyTableListToprr({ clickSearch, resetSelectFu })
           ) : (
             <>
-              <Button type='primary' onClick={() => history.push(`/${pageKey}_edit/1/null`)}>
+              <Button
+                type='primary'
+                onClick={() => {
+                  if (isEdit) isEdit()
+                  else history.push(`/${pageKey}_edit/1/null`)
+                }}
+              >
                 发起申请
               </Button>
               <Button type='primary' onClick={clickSearch}>

+ 38 - 0
src/store/action/Dmanage/D2edit.ts

@@ -0,0 +1,38 @@
+import { AppDispatch } from '@/store'
+import http from '@/utils/http'
+import { APIbase } from '../layout'
+
+/**
+ * 藏品修改 -获取分页列表
+ */
+export const D2_APIgetList = (data: any): any => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post('cms/order/edit/page', data)
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total
+      }
+
+      dispatch({ type: 'D2/getList', payload: obj })
+    }
+  }
+}
+
+/**
+ * 藏品修改-选择藏品
+ */
+export const D2_APIgetClueList = (data: any) => {
+  return http.post('cms/order/edit/good/page', data)
+}
+
+export const D2API_obj = {
+  创建订单: () => APIbase('get', 'cms/order/edit/create'),
+  获取详情: (id: number) => APIbase('get', `cms/order/edit/detail/${id}`),
+  草稿: (data: any) => APIbase('post', `cms/order/edit/saveDraft`, data),
+  发起: (data: any) => APIbase('post', `cms/order/edit/saveApply`, data),
+  重新发起: (id: number) => APIbase('get', `cms/order/edit/reissue/${id}`),
+  审批: (data: any) => APIbase('post', `cms/order/edit/audit`, data),
+  撤回: (id: number) => APIbase('get', `cms/order/edit/revocation/${id}`),
+  删除: (id: number) => APIbase('get', `cms/order/edit/remove/${id}`)
+}

+ 28 - 0
src/store/reducer/Dmanage/D2edit.ts

@@ -0,0 +1,28 @@
+import { Typetable } from '@/pages/Zother/data'
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  tableInfo: {
+    list: [] as Typetable[],
+    total: 0
+  }
+}
+
+// 定义 action 类型
+type Props = {
+  type: 'D2/getList'
+  payload: { list: Typetable[]; total: number }
+}
+
+// reducer
+export default function Reducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case 'D2/getList':
+      return { ...state, tableInfo: action.payload }
+
+    default:
+      return state
+  }
+}

+ 2 - 0
src/store/reducer/index.ts

@@ -10,6 +10,7 @@ import B4enterCang from './Benter/B4enterCang'
 import C1ledger from './Cledger/C1ledger'
 import C4file from './Cledger/C4file'
 import D1register from './Dmanage/D1register'
+import D2edit from './Dmanage/D2edit'
 import D3writeOff from './Dmanage/D3writeOff'
 import E1tag from './Eculture/E1tag'
 import E2story from './Eculture/E2story'
@@ -36,6 +37,7 @@ const rootReducer = combineReducers({
   C1ledger,
   C4file,
   D1register,
+  D2edit,
   D3writeOff,
   E1tag,
   E2story,

+ 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为显示

+ 15 - 0
src/utils/index.ts

@@ -73,3 +73,18 @@ export const downloadFileByUrl = async (fileUrl: string, fileName?: string, back
   document.body.removeChild(a)
   if (back) back()
 }
+
+// 过滤数组重复的`label`字段
+export function arrFiltersFu(data: any[], label: string) {
+  const seenLabels = new Set<string>()
+  const result: any[] = []
+
+  for (const item of data) {
+    if (!seenLabels.has(item[label])) {
+      seenLabels.add(item[label])
+      result.push(item)
+    }
+  }
+
+  return result
+}

+ 1 - 2
src/utils/tableData.ts

@@ -193,8 +193,7 @@ export const GI4tableC = [
 
 // 藏品详情----藏品日志
 export const GI5tableC = [
-  ['txt', '申请类型', 'xxx'],
-  ['txt', '业务发生日期', 'xxx'],
+  ['dateRes', '业务发生日期', 'date'],
   ['txt', '申请编号', 'num'],
   ['txt', '发起部门', 'deptName'],
   ['txt', '发起人', 'creatorName'],