|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useCallback, useEffect, useState } from 'react'
|
|
|
|
|
|
|
+import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
|
import { Button } from 'antd'
|
|
import { Button } from 'antd'
|
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
@@ -9,6 +9,7 @@ import { useInfo } from '../InfoContext'
|
|
|
import { MessageFu } from '@/utils/message'
|
|
import { MessageFu } from '@/utils/message'
|
|
|
import { fileIdsResFu } from '@/utils'
|
|
import { fileIdsResFu } from '@/utils'
|
|
|
import { API_objType } from '@/store/action/Dmanage/D1register'
|
|
import { API_objType } from '@/store/action/Dmanage/D1register'
|
|
|
|
|
+import { TypetableAuditList } from '../data'
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
path: string
|
|
path: string
|
|
@@ -17,7 +18,7 @@ type Props = {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
|
|
function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
|
|
|
- const { info, snaps, delSnapIdsRef, setTimeKeyFu } = useInfo()
|
|
|
|
|
|
|
+ const { info, snaps, delSnapIdsRef, setTimeKeyFu, auditInfo } = useInfo()
|
|
|
|
|
|
|
|
const [btnCan, setBtnCan] = useState({ status: 0, creatorId: 0 })
|
|
const [btnCan, setBtnCan] = useState({ status: 0, creatorId: 0 })
|
|
|
|
|
|
|
@@ -26,7 +27,11 @@ function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
|
|
|
}, [info.status, info.creatorId])
|
|
}, [info.status, info.creatorId])
|
|
|
|
|
|
|
|
// key:1 新增 2编辑 3审批 4查看
|
|
// key:1 新增 2编辑 3审批 4查看
|
|
|
- const { key, id } = useParams<any>()
|
|
|
|
|
|
|
+ const { key } = useParams<any>()
|
|
|
|
|
+
|
|
|
|
|
+ const isLook = useMemo(() => {
|
|
|
|
|
+ return ['3', '4'].includes(key)
|
|
|
|
|
+ }, [key])
|
|
|
|
|
|
|
|
const [btnPowArr, setBtnPowArr] = useState<string[]>([])
|
|
const [btnPowArr, setBtnPowArr] = useState<string[]>([])
|
|
|
|
|
|
|
@@ -42,12 +47,12 @@ function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
|
|
|
async (val: string, flag?: string) => {
|
|
async (val: string, flag?: string) => {
|
|
|
// console.log('点击按钮', val, flag)
|
|
// console.log('点击按钮', val, flag)
|
|
|
// 新增、编辑、审批、查看互相跳转
|
|
// 新增、编辑、审批、查看互相跳转
|
|
|
- if (flag) pageSkitFu(path, val, id, flag)
|
|
|
|
|
|
|
+ if (flag) pageSkitFu(path, val, info.id, flag)
|
|
|
else {
|
|
else {
|
|
|
const obj = {
|
|
const obj = {
|
|
|
...info,
|
|
...info,
|
|
|
fileIds: fileIdsResFu(info.files),
|
|
fileIds: fileIdsResFu(info.files),
|
|
|
- goodsIds: snaps.map(v => v.id).join(','),
|
|
|
|
|
|
|
+ goodIds: snaps.map(v => v.id).join(','),
|
|
|
delSnapIds: delSnapIdsRef.current.length ? delSnapIdsRef.current : '',
|
|
delSnapIds: delSnapIdsRef.current.length ? delSnapIdsRef.current : '',
|
|
|
snaps: snaps.map(v => ({
|
|
snaps: snaps.map(v => ({
|
|
|
goodsId: v.id,
|
|
goodsId: v.id,
|
|
@@ -56,14 +61,18 @@ function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
|
|
|
snap: JSON.stringify(v)
|
|
snap: JSON.stringify(v)
|
|
|
}))
|
|
}))
|
|
|
}
|
|
}
|
|
|
- console.log('xxxxxxxxx', obj)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // if (1 + 1 === 2) {
|
|
|
|
|
+ // console.log('xxxxxxxxx', obj)
|
|
|
|
|
+ // return
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
// 草稿、发起、审批、撤回、删除
|
|
// 草稿、发起、审批、撤回、删除
|
|
|
|
|
|
|
|
if (val === '草稿') {
|
|
if (val === '草稿') {
|
|
|
const res = await APIobj['草稿'](obj)
|
|
const res = await APIobj['草稿'](obj)
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
- pageSkitFu(path, '4', id, '详情', '保存草稿成功')
|
|
|
|
|
|
|
+ pageSkitFu(path, '4', info.id, '详情', '保存草稿成功')
|
|
|
}
|
|
}
|
|
|
} else if (val === '撤回') {
|
|
} else if (val === '撤回') {
|
|
|
const res = await APIobj['撤回'](obj.id)
|
|
const res = await APIobj['撤回'](obj.id)
|
|
@@ -85,77 +94,110 @@ function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
|
|
|
return MessageFu.warning('请输入申请编号')
|
|
return MessageFu.warning('请输入申请编号')
|
|
|
}
|
|
}
|
|
|
if (snaps.length === 0) {
|
|
if (snaps.length === 0) {
|
|
|
- editPageToTopFu()
|
|
|
|
|
|
|
+ // editPageToTopFu()
|
|
|
return MessageFu.warning(`请至少添加一个${checkListTxt}`)
|
|
return MessageFu.warning(`请至少添加一个${checkListTxt}`)
|
|
|
}
|
|
}
|
|
|
const res = await APIobj['发起'](obj)
|
|
const res = await APIobj['发起'](obj)
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
- MessageFu.success('操作成功')
|
|
|
|
|
|
|
+ if (['1', '2'].includes(key)) {
|
|
|
|
|
+ pageSkitFu(path, '4', info.id, '详情', '提交成功')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ MessageFu.success('发起成功')
|
|
|
|
|
+ // 重新调用获取详情接口-当前页刷新状态
|
|
|
|
|
+ setTimeKeyFu()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (val === '重新发起') {
|
|
|
|
|
+ const res = await APIobj['重新发起'](obj.id)
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ MessageFu.success('重新发起成功')
|
|
|
// 重新调用获取详情接口-当前页刷新状态
|
|
// 重新调用获取详情接口-当前页刷新状态
|
|
|
setTimeKeyFu()
|
|
setTimeKeyFu()
|
|
|
}
|
|
}
|
|
|
} else if (val === '审批') {
|
|
} else if (val === '审批') {
|
|
|
- // 待完善sg
|
|
|
|
|
|
|
+ if (!auditInfo.status) {
|
|
|
|
|
+ editPageToTopFu()
|
|
|
|
|
+ return MessageFu.warning('请选择审批结果')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const auditObj = {
|
|
|
|
|
+ ...auditInfo,
|
|
|
|
|
+ orderId: info.id
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await APIobj['审批'](auditObj)
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ pageSkitFu(path, '4', info.id, '详情', '审批成功')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- [APIobj, checkListTxt, delSnapIdsRef, id, info, path, setTimeKeyFu, snaps]
|
|
|
|
|
|
|
+ [APIobj, auditInfo, checkListTxt, delSnapIdsRef, info, key, path, setTimeKeyFu, snaps]
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ // 申请记录的显示
|
|
|
|
|
+ const [auditListShow, setAuditListShow] = useState<TypetableAuditList[]>([])
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.EditBtn}>
|
|
<div className={styles.EditBtn}>
|
|
|
- {['1', '2'].includes(key) ? (
|
|
|
|
|
- <>
|
|
|
|
|
- <Button type='primary' onClick={() => sonClick('草稿')}>
|
|
|
|
|
- 存草稿
|
|
|
|
|
- </Button>
|
|
|
|
|
- <Button type='primary' onClick={() => sonClick('发起')}>
|
|
|
|
|
- 提交
|
|
|
|
|
- </Button>
|
|
|
|
|
- <MyPopconfirm txtK='取消' onConfirm={() => backPageFu(path)} />
|
|
|
|
|
- </>
|
|
|
|
|
- ) : key === '3' ? (
|
|
|
|
|
- <>
|
|
|
|
|
- <Button type='primary' onClick={() => sonClick('审批')}>
|
|
|
|
|
- 审批
|
|
|
|
|
- </Button>
|
|
|
|
|
- <Button onClick={() => backPageFu(path)}>返回</Button>
|
|
|
|
|
- </>
|
|
|
|
|
- ) : key === '4' ? (
|
|
|
|
|
- <>
|
|
|
|
|
- {btnPowArr.includes('重新发起') ? (
|
|
|
|
|
- <Button type='primary' onClick={() => sonClick('发起')}>
|
|
|
|
|
- 重新发起
|
|
|
|
|
- </Button>
|
|
|
|
|
- ) : null}
|
|
|
|
|
- {btnPowArr.includes('撤回') ? (
|
|
|
|
|
- <MyPopconfirm
|
|
|
|
|
- txtK='撤回'
|
|
|
|
|
- onConfirm={() => sonClick('撤回')}
|
|
|
|
|
- Dom={<Button danger>撤回</Button>}
|
|
|
|
|
- />
|
|
|
|
|
- ) : null}
|
|
|
|
|
- {btnPowArr.includes('编辑') ? (
|
|
|
|
|
- <Button type='primary' onClick={() => sonClick('2', '编辑')}>
|
|
|
|
|
- 编辑
|
|
|
|
|
|
|
+ <div>
|
|
|
|
|
+ {['1', '2'].includes(key) ? (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Button type='primary' onClick={() => sonClick('草稿')}>
|
|
|
|
|
+ 存草稿
|
|
|
</Button>
|
|
</Button>
|
|
|
- ) : null}
|
|
|
|
|
- {btnPowArr.includes('发起') ? (
|
|
|
|
|
<Button type='primary' onClick={() => sonClick('发起')}>
|
|
<Button type='primary' onClick={() => sonClick('发起')}>
|
|
|
- 发起
|
|
|
|
|
|
|
+ 提交
|
|
|
</Button>
|
|
</Button>
|
|
|
- ) : null}
|
|
|
|
|
- {btnPowArr.includes('删除') ? (
|
|
|
|
|
- <MyPopconfirm
|
|
|
|
|
- txtK='删除2'
|
|
|
|
|
- onConfirm={() => sonClick('删除')}
|
|
|
|
|
- Dom={<Button danger>删除</Button>}
|
|
|
|
|
- />
|
|
|
|
|
- ) : null}
|
|
|
|
|
|
|
+ <MyPopconfirm txtK='取消' onConfirm={() => backPageFu(path)} />
|
|
|
|
|
+ </>
|
|
|
|
|
+ ) : key === '3' ? (
|
|
|
|
|
+ <Button type='primary' onClick={() => sonClick('审批')}>
|
|
|
|
|
+ 审批
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ ) : key === '4' ? (
|
|
|
|
|
+ <>
|
|
|
|
|
+ {btnPowArr.includes('重新发起') ? (
|
|
|
|
|
+ <Button type='primary' onClick={() => sonClick('重新发起')}>
|
|
|
|
|
+ 重新发起
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+ {btnPowArr.includes('撤回') ? (
|
|
|
|
|
+ <MyPopconfirm
|
|
|
|
|
+ txtK='撤回'
|
|
|
|
|
+ onConfirm={() => sonClick('撤回')}
|
|
|
|
|
+ Dom={<Button danger>撤回</Button>}
|
|
|
|
|
+ />
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+ {btnPowArr.includes('编辑') ? (
|
|
|
|
|
+ <Button type='primary' onClick={() => sonClick('2', '编辑')}>
|
|
|
|
|
+ 编辑
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+ {btnPowArr.includes('发起') ? (
|
|
|
|
|
+ <Button type='primary' onClick={() => sonClick('发起')}>
|
|
|
|
|
+ 发起
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+ {btnPowArr.includes('删除') ? (
|
|
|
|
|
+ <MyPopconfirm
|
|
|
|
|
+ txtK='删除2'
|
|
|
|
|
+ onConfirm={() => sonClick('删除')}
|
|
|
|
|
+ Dom={<Button danger>删除</Button>}
|
|
|
|
|
+ />
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+ </>
|
|
|
|
|
+ ) : null}
|
|
|
|
|
|
|
|
|
|
+ {isLook && info.audits && info.audits.length ? (
|
|
|
<Button onClick={() => backPageFu(path)}>返回</Button>
|
|
<Button onClick={() => backPageFu(path)}>返回</Button>
|
|
|
- </>
|
|
|
|
|
- ) : null}
|
|
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div>
|
|
|
|
|
+ {isLook ? <Button onClick={() => setAuditListShow(info.audits)}>申请记录</Button> : null}
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* {auditListShow.length ? <AuditList /> : null} */}
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|