|
|
@@ -5,12 +5,19 @@ import MyTable from '@/components/MyTable'
|
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
import AddGoods from '../AddGoods'
|
|
|
import { useInfo } from '../InfoContext'
|
|
|
-import { GoodsType, sgBaseFormData, sgTopSelectDom } from './data'
|
|
|
+import {
|
|
|
+ GoodsType,
|
|
|
+ sgBaseFormData,
|
|
|
+ sgBaseFormDataGood,
|
|
|
+ sgTopSelectDom,
|
|
|
+ sgTopSelectDomGood
|
|
|
+} from './data'
|
|
|
import { goodsSelectCuleC, goodsSonTableC } from '@/utils/tableData'
|
|
|
import { useParams } from 'react-router-dom'
|
|
|
import { openLink } from '@/utils/history'
|
|
|
import { FileUpInfoType } from '../data'
|
|
|
import SelectGoods from '../SelectGoods'
|
|
|
+import AddClues from '../AddClues'
|
|
|
|
|
|
type Props = {
|
|
|
// 上传附件的信息
|
|
|
@@ -21,9 +28,20 @@ type Props = {
|
|
|
addGoodsApi: any
|
|
|
// 需要从征集里面选择数据(现在是藏品登记/藏品入馆 需要 藏品入藏不需要)
|
|
|
isClueSelect: boolean
|
|
|
+ // 选择藏品的按钮字符串
|
|
|
+ btnTxt?: string
|
|
|
+ // 是否有新增和编辑可以操作藏品,默认true
|
|
|
+ addShow?: boolean
|
|
|
}
|
|
|
|
|
|
-function SonGoodsList({ fileUpInfo, selectApi, addGoodsApi, isClueSelect }: Props) {
|
|
|
+function SonGoodsList({
|
|
|
+ fileUpInfo,
|
|
|
+ selectApi,
|
|
|
+ addGoodsApi,
|
|
|
+ isClueSelect,
|
|
|
+ btnTxt,
|
|
|
+ addShow = true
|
|
|
+}: Props) {
|
|
|
const { info, snaps, setSnapsFu, delSnapIdsRef, snapsID2ref } = useInfo()
|
|
|
|
|
|
const { key } = useParams<any>()
|
|
|
@@ -35,37 +53,45 @@ function SonGoodsList({ fileUpInfo, selectApi, addGoodsApi, isClueSelect }: Prop
|
|
|
|
|
|
const [openInfo, setOpenInfo] = useState({} as GoodsType)
|
|
|
|
|
|
+ // 打开线索弹窗-查看详情
|
|
|
+ const [clueInfo, setClueInfo] = useState({} as GoodsType)
|
|
|
+
|
|
|
const tableLastBtn = useMemo(() => {
|
|
|
return [
|
|
|
{
|
|
|
title: '操作',
|
|
|
- render: (item: GoodsType) => (
|
|
|
- <>
|
|
|
- {isLook ? (
|
|
|
- <Button size='small' type='text' onClick={() => openLink(`/goodsLook/${item.id}`)}>
|
|
|
- 查看
|
|
|
- </Button>
|
|
|
- ) : (
|
|
|
- <>
|
|
|
- <Button size='small' type='text' onClick={() => setOpenInfo(item)}>
|
|
|
- 编辑
|
|
|
+ render: (item: GoodsType) => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {isLook ? (
|
|
|
+ <Button size='small' type='text' onClick={() => openLink(`/goodsLook/${item.id}`)}>
|
|
|
+ 查看
|
|
|
</Button>
|
|
|
- <MyPopconfirm
|
|
|
- txtK='删除'
|
|
|
- onConfirm={() => {
|
|
|
- if (item.id2 && !delSnapIdsRef.current.includes(item.id2)) {
|
|
|
- delSnapIdsRef.current.push(item.id2)
|
|
|
- }
|
|
|
- setSnapsFu(snaps.filter(v => v.id !== item.id))
|
|
|
- }}
|
|
|
- />
|
|
|
- </>
|
|
|
- )}
|
|
|
- </>
|
|
|
- )
|
|
|
+ ) : (
|
|
|
+ <>
|
|
|
+ {addShow ? (
|
|
|
+ <Button size='small' type='text' onClick={() => setOpenInfo(item)}>
|
|
|
+ 编辑
|
|
|
+ </Button>
|
|
|
+ ) : null}
|
|
|
+
|
|
|
+ <MyPopconfirm
|
|
|
+ txtK='删除'
|
|
|
+ onConfirm={() => {
|
|
|
+ if (item.id2 && !delSnapIdsRef.current.includes(item.id2)) {
|
|
|
+ delSnapIdsRef.current.push(item.id2)
|
|
|
+ }
|
|
|
+ setSnapsFu(snaps.filter(v => v.id !== item.id))
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
]
|
|
|
- }, [delSnapIdsRef, isLook, setSnapsFu, snaps])
|
|
|
+ }, [addShow, delSnapIdsRef, isLook, setSnapsFu, snaps])
|
|
|
|
|
|
// 从征集线索中添加
|
|
|
const [clueShow, setClueShow] = useState(false)
|
|
|
@@ -79,11 +105,13 @@ function SonGoodsList({ fileUpInfo, selectApi, addGoodsApi, isClueSelect }: Prop
|
|
|
) : (
|
|
|
<div>
|
|
|
<Button type='primary' onClick={() => setClueShow(true)}>
|
|
|
- 从征集线索中添加
|
|
|
- </Button>
|
|
|
- <Button type='primary' onClick={() => setOpenInfo({ id: -1 } as GoodsType)}>
|
|
|
- 新增
|
|
|
+ {btnTxt ? btnTxt : '从征集线索中添加'}
|
|
|
</Button>
|
|
|
+ {addShow ? (
|
|
|
+ <Button type='primary' onClick={() => setOpenInfo({ id: -1 } as GoodsType)}>
|
|
|
+ 新增
|
|
|
+ </Button>
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
)}
|
|
|
</div>
|
|
|
@@ -91,7 +119,7 @@ function SonGoodsList({ fileUpInfo, selectApi, addGoodsApi, isClueSelect }: Prop
|
|
|
<MyTable
|
|
|
classKey='SonGoodsList'
|
|
|
list={snaps}
|
|
|
- columnsTemp={goodsSonTableC}
|
|
|
+ columnsTemp={goodsSonTableC()}
|
|
|
lastBtn={tableLastBtn}
|
|
|
pagingInfo={false}
|
|
|
/>
|
|
|
@@ -106,7 +134,7 @@ function SonGoodsList({ fileUpInfo, selectApi, addGoodsApi, isClueSelect }: Prop
|
|
|
moduleId={info.id}
|
|
|
succFu={(val: '新增' | '编辑', info: GoodsType) => {
|
|
|
let objTemp = { ...info }
|
|
|
- const id2Obj = snapsID2ref.current.find(c => c.goodsId === objTemp.id)
|
|
|
+ const id2Obj = snapsID2ref.current.find(c => c.goodId === objTemp.id)
|
|
|
if (id2Obj) objTemp.id2 = id2Obj.id
|
|
|
if (val === '新增') {
|
|
|
// 是新增
|
|
|
@@ -126,10 +154,11 @@ function SonGoodsList({ fileUpInfo, selectApi, addGoodsApi, isClueSelect }: Prop
|
|
|
{/* 从藏品征集中添加 */}
|
|
|
{clueShow ? (
|
|
|
<SelectGoods
|
|
|
+ myType={isClueSelect ? '线索' : '藏品'}
|
|
|
API_getList={selectApi}
|
|
|
- baseFormData={sgBaseFormData}
|
|
|
- topSelectDom={sgTopSelectDom}
|
|
|
- columnsTemp={goodsSelectCuleC}
|
|
|
+ baseFormData={isClueSelect ? sgBaseFormData : sgBaseFormDataGood}
|
|
|
+ topSelectDom={isClueSelect ? sgTopSelectDom : sgTopSelectDomGood}
|
|
|
+ columnsTemp={isClueSelect ? goodsSelectCuleC : goodsSonTableC(true)}
|
|
|
closeFu={() => setClueShow(false)}
|
|
|
oldCheckArr={snaps}
|
|
|
dataResFu={data => {
|
|
|
@@ -146,8 +175,8 @@ function SonGoodsList({ fileUpInfo, selectApi, addGoodsApi, isClueSelect }: Prop
|
|
|
v.pageType = 'clue'
|
|
|
}
|
|
|
|
|
|
- // id2表示的是自己这条数据的id id才是goodsId
|
|
|
- const obj = snapsID2ref.current.find(c => c.goodsId === v.id)
|
|
|
+ // id2表示的是自己这条数据的id id才是goodId
|
|
|
+ const obj = snapsID2ref.current.find(c => c.goodId === v.id)
|
|
|
|
|
|
if (obj) v.id2 = obj.id
|
|
|
})
|
|
|
@@ -156,6 +185,18 @@ function SonGoodsList({ fileUpInfo, selectApi, addGoodsApi, isClueSelect }: Prop
|
|
|
}}
|
|
|
/>
|
|
|
) : null}
|
|
|
+
|
|
|
+ {/* 线索查看详情 */}
|
|
|
+ {clueInfo.id ? (
|
|
|
+ <AddClues
|
|
|
+ info={clueInfo}
|
|
|
+ closeFu={() => setClueInfo({} as GoodsType)}
|
|
|
+ succFu={() => {}}
|
|
|
+ moduleId={0}
|
|
|
+ fileUpInfo={{} as FileUpInfoType}
|
|
|
+ isLook={true}
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
)
|
|
|
}
|