|
@@ -8,9 +8,10 @@ import { MessageFu } from '@/utils/message'
|
|
|
import ZupOne from '@/components/ZupOne'
|
|
|
import TextArea from 'antd/es/input/TextArea'
|
|
|
import dayjs from 'dayjs'
|
|
|
-import { A2tableType, A2TreeType } from '@/types'
|
|
|
+import { A1tableType, A2tableType, A2TreeType } from '@/types'
|
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
import { A5_APIgetInfo } from '@/store/action/A5bookAudit'
|
|
|
+import { treeResIdFu } from '@/pages/A2classify/data'
|
|
|
|
|
|
type Props = {
|
|
|
editInfo: A1EditInfoType
|
|
@@ -20,6 +21,8 @@ type Props = {
|
|
|
storageArr: A2TreeType[]
|
|
|
exhibitTypeArr: A2tableType[]
|
|
|
isAudit?: boolean //从图书审核页面进来
|
|
|
+ isImportFu?: (info: A1tableType) => void // 从批量导入里面进来
|
|
|
+ ISBNArr?: string[] //ISBN编号集合,用来判断当前填写的ISBN是否已经存在了(外层表格中)
|
|
|
}
|
|
|
|
|
|
function A1add({
|
|
@@ -29,7 +32,9 @@ function A1add({
|
|
|
editTableFu,
|
|
|
storageArr,
|
|
|
exhibitTypeArr,
|
|
|
- isAudit
|
|
|
+ isAudit,
|
|
|
+ isImportFu,
|
|
|
+ ISBNArr
|
|
|
}: Props) {
|
|
|
// 表单的ref
|
|
|
const FormBoxRef = useRef<FormInstance>(null)
|
|
@@ -40,40 +45,47 @@ function A1add({
|
|
|
// txt的ref
|
|
|
const ZupTxtRef = useRef<any>(null)
|
|
|
|
|
|
+ // 回显数据的方法调用
|
|
|
+ const dataShow = useCallback((info: A1tableType) => {
|
|
|
+ let storageIds: any[] = []
|
|
|
+ if (info.ancestor) storageIds = info.ancestor.split(',').map((v: string) => Number(v))
|
|
|
+
|
|
|
+ if (info.storageId) storageIds.push(Number(info.storageId))
|
|
|
+
|
|
|
+ const obj = {
|
|
|
+ ...info,
|
|
|
+ storageIds,
|
|
|
+ exhibitTypeId: info.exhibitTypeId ? Number(info.exhibitTypeId) : null,
|
|
|
+ year: info.year ? info.year : null
|
|
|
+ }
|
|
|
+
|
|
|
+ FormBoxRef.current?.setFieldsValue(obj)
|
|
|
+
|
|
|
+ // 设置封面图
|
|
|
+ ZupThumbRef.current?.setFileComFileFu({
|
|
|
+ fileName: '',
|
|
|
+ filePath: info.thumb
|
|
|
+ })
|
|
|
+
|
|
|
+ // 设置附件
|
|
|
+ ZupTxtRef.current?.setFileComFileFu({
|
|
|
+ fileName: info.fileName,
|
|
|
+ filePath: info.filePath
|
|
|
+ })
|
|
|
+ }, [])
|
|
|
+
|
|
|
// 编辑/查看 进入页面 获取信息
|
|
|
const getInfoFu = useCallback(
|
|
|
async (id: number) => {
|
|
|
- const res = isAudit ? await A5_APIgetInfo(id) : await A1_APIgetInfo(id)
|
|
|
- if (res.code === 0) {
|
|
|
- const data = res.data
|
|
|
-
|
|
|
- let storageIds = []
|
|
|
- if (data.ancestor) storageIds = data.ancestor.split(',').map((v: string) => Number(v))
|
|
|
- storageIds.push(Number(data.storageId))
|
|
|
-
|
|
|
- const obj = {
|
|
|
- ...data,
|
|
|
- storageIds,
|
|
|
- exhibitTypeId: Number(data.exhibitTypeId),
|
|
|
- year: data.year ? data.year : null
|
|
|
+ if (isImportFu && editInfo.info) dataShow(editInfo.info)
|
|
|
+ else {
|
|
|
+ const res = isAudit ? await A5_APIgetInfo(id) : await A1_APIgetInfo(id)
|
|
|
+ if (res.code === 0) {
|
|
|
+ dataShow(res.data)
|
|
|
}
|
|
|
-
|
|
|
- FormBoxRef.current?.setFieldsValue(obj)
|
|
|
-
|
|
|
- // 设置封面图
|
|
|
- ZupThumbRef.current?.setFileComFileFu({
|
|
|
- fileName: '',
|
|
|
- filePath: data.thumb
|
|
|
- })
|
|
|
-
|
|
|
- // 设置附件
|
|
|
- ZupTxtRef.current?.setFileComFileFu({
|
|
|
- fileName: data.fileName,
|
|
|
- filePath: data.filePath
|
|
|
- })
|
|
|
}
|
|
|
},
|
|
|
- [isAudit]
|
|
|
+ [dataShow, editInfo.info, isAudit, isImportFu]
|
|
|
)
|
|
|
|
|
|
// 附件 是否 已经点击过确定
|
|
@@ -112,6 +124,9 @@ function A1add({
|
|
|
filePath = ZupTxtRefObj.filePath
|
|
|
if (!filePath) return MessageFu.warning('请上传epub附件!')
|
|
|
|
|
|
+ if (ISBNArr && ISBNArr.includes(values.num) && values.num !== '')
|
|
|
+ return MessageFu.warning(`ISBN编号 ${values.num} 重复!`)
|
|
|
+
|
|
|
let storageId: null | number = null
|
|
|
|
|
|
if (values.storageIds && values.storageIds.length) {
|
|
@@ -132,15 +147,59 @@ function A1add({
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
- const res = await A1_APIsave(obj)
|
|
|
+ if (isImportFu && editInfo.info) {
|
|
|
+ const info = editInfo.info
|
|
|
+
|
|
|
+ // 多级筛选的 映射字段回显
|
|
|
+ let ancestor = ''
|
|
|
+ let storageName = ''
|
|
|
+
|
|
|
+ const storageArrAc = treeResIdFu(storageArr, storageId!)
|
|
|
+ if (storageArrAc) {
|
|
|
+ ancestor = storageArrAc.ancestor
|
|
|
+ storageName = storageArrAc.name
|
|
|
+ }
|
|
|
+
|
|
|
+ // 下拉框 映射字段回显
|
|
|
+ let exhibitTypeName = ''
|
|
|
|
|
|
- if (res.code === 0) {
|
|
|
- MessageFu.success(isAudit ? '创建成功!' : `${editInfo.txt}成功!`)
|
|
|
- editInfo.id > 0 ? editTableFu() : addTableFu()
|
|
|
+ const exhibitTypeArrAc = exhibitTypeArr.find(v => v.id === values.exhibitTypeId)
|
|
|
+
|
|
|
+ if (exhibitTypeArrAc) exhibitTypeName = exhibitTypeArrAc.name
|
|
|
+ const ImpObj = {
|
|
|
+ ...obj,
|
|
|
+ id: info.id,
|
|
|
+ ancestor,
|
|
|
+ storageName,
|
|
|
+ exhibitTypeName
|
|
|
+ }
|
|
|
+
|
|
|
+ isImportFu(ImpObj)
|
|
|
+ MessageFu.success('编辑成功!')
|
|
|
closeFu()
|
|
|
+ } else {
|
|
|
+ const res = await A1_APIsave(obj)
|
|
|
+
|
|
|
+ if (res.code === 0) {
|
|
|
+ MessageFu.success(isAudit ? '创建成功!' : `${editInfo.txt}成功!`)
|
|
|
+ editInfo.id > 0 ? editTableFu() : addTableFu()
|
|
|
+ closeFu()
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
- [addTableFu, closeFu, editInfo.id, editInfo.txt, editTableFu, isAudit]
|
|
|
+ [
|
|
|
+ ISBNArr,
|
|
|
+ addTableFu,
|
|
|
+ closeFu,
|
|
|
+ editInfo.id,
|
|
|
+ editInfo.info,
|
|
|
+ editInfo.txt,
|
|
|
+ editTableFu,
|
|
|
+ exhibitTypeArr,
|
|
|
+ isAudit,
|
|
|
+ isImportFu,
|
|
|
+ storageArr
|
|
|
+ ]
|
|
|
)
|
|
|
|
|
|
// 年份
|