|
@@ -1,21 +1,34 @@
|
|
-import React, { useCallback, useMemo, useRef } from 'react'
|
|
|
|
|
|
+import React, { useCallback, useEffect, useMemo, useRef } from 'react'
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
import { useParams } from 'react-router-dom'
|
|
import { useParams } from 'react-router-dom'
|
|
-import B3aTop from '../B3add/B3aTop'
|
|
|
|
import { TypeB3PageSta } from '../type'
|
|
import { TypeB3PageSta } from '../type'
|
|
import { Button } from 'antd'
|
|
import { Button } from 'antd'
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
import history from '@/utils/history'
|
|
import history from '@/utils/history'
|
|
-import { B3TiaoObjUrl, B3TitObjKey } from '../B3add'
|
|
|
|
import B3goodsTable from '../../B3goodsTable'
|
|
import B3goodsTable from '../../B3goodsTable'
|
|
import B3flowTable from '../../B3flowTable'
|
|
import B3flowTable from '../../B3flowTable'
|
|
|
|
+import { B3TiaoObjUrl, B3TitObjKey } from './data'
|
|
|
|
+import B3aTop from './B3aTop'
|
|
|
|
+import { MessageFu } from '@/utils/message'
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
pageSta: TypeB3PageSta
|
|
pageSta: TypeB3PageSta
|
|
}
|
|
}
|
|
|
|
|
|
function B3editMain({ pageSta }: Props) {
|
|
function B3editMain({ pageSta }: Props) {
|
|
- const { key, id } = useParams<any>()
|
|
|
|
|
|
+ const { key, id, pageKey } = useParams<any>()
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ // key 1 2 3 4 新增 编辑 审批 查看
|
|
|
|
+ // pageKey 1 2 3 4 入馆 入藏 登记 删除
|
|
|
|
+ console.log('待完善', key, id)
|
|
|
|
+ }, [id, key])
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ // key改变的时候,滚动到顶部 并且更新数据
|
|
|
|
+ const dom = document.querySelector('#B3aTop') as HTMLDivElement
|
|
|
|
+ if (dom) dom.scrollTop = 0
|
|
|
|
+ }, [key])
|
|
|
|
|
|
// 点击按钮调用子组件的方法获取数据
|
|
// 点击按钮调用子组件的方法获取数据
|
|
const topRef = useRef<any>(null)
|
|
const topRef = useRef<any>(null)
|
|
@@ -23,6 +36,24 @@ function B3editMain({ pageSta }: Props) {
|
|
// 藏品清单子组件
|
|
// 藏品清单子组件
|
|
const goodsTableRef = useRef<any>(null)
|
|
const goodsTableRef = useRef<any>(null)
|
|
|
|
|
|
|
|
+ // 新增的按钮点击
|
|
|
|
+ const btnClickFu = useCallback(
|
|
|
|
+ (val: number) => {
|
|
|
|
+ // 从顶部组件中拿到数据
|
|
|
|
+ const resData = topRef.current?.resData()
|
|
|
|
+ console.log('从子组件获取数据', resData)
|
|
|
|
+
|
|
|
|
+ if (val === 2) {
|
|
|
|
+ // 存草稿 当前页保存 不跳转
|
|
|
|
+ MessageFu.success('草稿保存成功')
|
|
|
|
+ } else {
|
|
|
|
+ const url = Reflect.get(B3TiaoObjUrl, pageKey)
|
|
|
|
+ history.push(`${url}_edit/2/${99}/${pageKey}`)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ [pageKey]
|
|
|
|
+ )
|
|
|
|
+
|
|
// 点击保存
|
|
// 点击保存
|
|
const btnOk = useCallback(async () => {
|
|
const btnOk = useCallback(async () => {
|
|
console.log(pageSta, '编辑、审批逻辑判断')
|
|
console.log(pageSta, '编辑、审批逻辑判断')
|
|
@@ -37,9 +68,9 @@ function B3editMain({ pageSta }: Props) {
|
|
|
|
|
|
// 点击取消
|
|
// 点击取消
|
|
const btnX = useCallback(() => {
|
|
const btnX = useCallback(() => {
|
|
- let url = Reflect.get(B3TiaoObjUrl, key)
|
|
|
|
|
|
+ let url = Reflect.get(B3TiaoObjUrl, pageKey)
|
|
history.push(url)
|
|
history.push(url)
|
|
- }, [key])
|
|
|
|
|
|
+ }, [pageKey])
|
|
|
|
|
|
// const lookBtnFu = useCallback((val: string) => {
|
|
// const lookBtnFu = useCallback((val: string) => {
|
|
// const obj = {
|
|
// const obj = {
|
|
@@ -90,8 +121,7 @@ function B3editMain({ pageSta }: Props) {
|
|
<div className={styles.B3editMain}>
|
|
<div className={styles.B3editMain}>
|
|
<div className='pageTitle'>
|
|
<div className='pageTitle'>
|
|
{/* 待完善id */}
|
|
{/* 待完善id */}
|
|
- 藏品{Reflect.get(B3TitObjKey, key)}-{pageSta}
|
|
|
|
- {id}
|
|
|
|
|
|
+ 藏品{Reflect.get(B3TitObjKey, pageKey)}-{pageSta}
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<B3aTop
|
|
<B3aTop
|
|
@@ -101,7 +131,7 @@ function B3editMain({ pageSta }: Props) {
|
|
Dom={
|
|
Dom={
|
|
<>
|
|
<>
|
|
{/* 藏品清单 */}
|
|
{/* 藏品清单 */}
|
|
- <B3goodsTable ref={goodsTableRef} pageSta={pageSta} />
|
|
|
|
|
|
+ {pageSta === '新增' ? null : <B3goodsTable ref={goodsTableRef} pageSta={pageSta} />}
|
|
|
|
|
|
{/* 申请流程 */}
|
|
{/* 申请流程 */}
|
|
{['查看', '审批'].includes(pageSta) ? <B3flowTable /> : null}
|
|
{['查看', '审批'].includes(pageSta) ? <B3flowTable /> : null}
|
|
@@ -118,6 +148,21 @@ function B3editMain({ pageSta }: Props) {
|
|
</Button>
|
|
</Button>
|
|
) : null}
|
|
) : null}
|
|
|
|
|
|
|
|
+ {pageSta === '新增' ? (
|
|
|
|
+ <>
|
|
|
|
+ {' '}
|
|
|
|
+ <Button type='primary' onClick={() => btnClickFu(1)}>
|
|
|
|
+ 添加藏品
|
|
|
|
+ </Button>
|
|
|
|
+ <Button type='primary' onClick={() => btnClickFu(1)}>
|
|
|
|
+ 创建
|
|
|
|
+ </Button>
|
|
|
|
+ <Button type='primary' onClick={() => btnClickFu(2)}>
|
|
|
|
+ 存草稿
|
|
|
|
+ </Button>
|
|
|
|
+ </>
|
|
|
|
+ ) : null}
|
|
|
|
+
|
|
{pageSta === '查看' ? lookBtn : <MyPopconfirm txtK='取消' onConfirm={() => btnX()} />}
|
|
{pageSta === '查看' ? lookBtn : <MyPopconfirm txtK='取消' onConfirm={() => btnX()} />}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|