|
@@ -14,6 +14,7 @@ import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
import { API_getGoodsInfo } from '@/store/action/Cledger/C1ledger'
|
|
import { API_getGoodsInfo } from '@/store/action/Cledger/C1ledger'
|
|
|
import { MessageFu } from '@/utils/message'
|
|
import { MessageFu } from '@/utils/message'
|
|
|
import { API_getFileListByIds } from '@/store/action/Cledger/C4file'
|
|
import { API_getFileListByIds } from '@/store/action/Cledger/C4file'
|
|
|
|
|
+import { FileUpInfoType } from '../data'
|
|
|
|
|
|
|
|
// 级联的数据转换成字符串
|
|
// 级联的数据转换成字符串
|
|
|
export const cascaderChArr = [
|
|
export const cascaderChArr = [
|
|
@@ -40,13 +41,15 @@ type Props = {
|
|
|
info: GoodsType
|
|
info: GoodsType
|
|
|
closeFu: () => void
|
|
closeFu: () => void
|
|
|
isEdit: boolean //藏品编辑-模块
|
|
isEdit: boolean //藏品编辑-模块
|
|
|
- editSnap?: GoodsType //藏品编辑-属于新增还是编辑
|
|
|
|
|
succFu: (val: '新增' | '编辑', info: GoodsType) => void
|
|
succFu: (val: '新增' | '编辑', info: GoodsType) => void
|
|
|
moduleId: number
|
|
moduleId: number
|
|
|
|
|
+ // 上传附件的信息
|
|
|
|
|
+ fileUpInfo: FileUpInfoType
|
|
|
APIsave: any
|
|
APIsave: any
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info, APIsave }: Props) {
|
|
|
|
|
|
|
+function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo }: Props) {
|
|
|
|
|
+ // 获取标签 树结构
|
|
|
const E1tree = useSelector((state: RootState) => state.E1tag.treeData)
|
|
const E1tree = useSelector((state: RootState) => state.E1tag.treeData)
|
|
|
|
|
|
|
|
// 设置表单ref
|
|
// 设置表单ref
|
|
@@ -62,42 +65,39 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info, APIsave }
|
|
|
const objOld = useRef({} as GoodsType)
|
|
const objOld = useRef({} as GoodsType)
|
|
|
|
|
|
|
|
// 编辑进来获取详情
|
|
// 编辑进来获取详情
|
|
|
- const getInfo = useCallback(
|
|
|
|
|
- async (id: number) => {
|
|
|
|
|
- const res = await API_getGoodsInfo(id)
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- // 藏品编辑信息保存
|
|
|
|
|
- objOld.current = { ...res.data }
|
|
|
|
|
-
|
|
|
|
|
- const obj = editSnap && editSnap.id ? { ...editSnap } : { ...res.data }
|
|
|
|
|
- // 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(',')
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- addZiSelectChArr.forEach(v => {
|
|
|
|
|
- if (!obj[v]) obj[v] = null
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- FormBoxRef.current?.setFieldsValue(obj)
|
|
|
|
|
-
|
|
|
|
|
- // 设置附件
|
|
|
|
|
- if (obj.fileIds) {
|
|
|
|
|
- const fileRes = await API_getFileListByIds(obj.fileIds.split(','))
|
|
|
|
|
- if (fileRes.code === 0) {
|
|
|
|
|
- fileRef.current?.sonSetListFu(fileRes.data || [])
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const getInfo = useCallback(async (id: number) => {
|
|
|
|
|
+ const res = await API_getGoodsInfo(id)
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ // 藏品编辑信息保存
|
|
|
|
|
+ objOld.current = { ...res.data }
|
|
|
|
|
+
|
|
|
|
|
+ const obj = { ...res.data }
|
|
|
|
|
+ // 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(',')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ addZiSelectChArr.forEach(v => {
|
|
|
|
|
+ if (!obj[v]) obj[v] = null
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ FormBoxRef.current?.setFieldsValue(obj)
|
|
|
|
|
+
|
|
|
|
|
+ // 设置附件
|
|
|
|
|
+ if (obj.fileIds) {
|
|
|
|
|
+ const fileRes = await API_getFileListByIds(obj.fileIds.split(','))
|
|
|
|
|
+ if (fileRes.code === 0) {
|
|
|
|
|
+ fileRef.current?.sonSetListFu(fileRes.data || [])
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- [editSnap]
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (info.id > 0) getInfo(info.id)
|
|
if (info.id > 0) getInfo(info.id)
|
|
@@ -144,7 +144,7 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info, APIsave }
|
|
|
// }
|
|
// }
|
|
|
const res = await APIsave(obj)
|
|
const res = await APIsave(obj)
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
- MessageFu.warning(info.id > 0 ? '编辑成功' : '新增成功')
|
|
|
|
|
|
|
+ MessageFu.success(info.id > 0 ? '编辑成功' : '新增成功')
|
|
|
succFu(info.id > 0 ? '编辑' : '新增', res.data)
|
|
succFu(info.id > 0 ? '编辑' : '新增', res.data)
|
|
|
closeFu()
|
|
closeFu()
|
|
|
}
|
|
}
|
|
@@ -155,7 +155,7 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info, APIsave }
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.AddGoods}>
|
|
<div className={styles.AddGoods}>
|
|
|
<div className='AGbox'>
|
|
<div className='AGbox'>
|
|
|
- <div className='AG1'>{isEdit ? '藏品修改' : editSnap ? '藏品编辑' : '藏品新增'}</div>
|
|
|
|
|
|
|
+ <div className='AG1'>{isEdit ? '藏品修改' : info.id > 0 ? '藏品编辑' : '藏品新增'}</div>
|
|
|
|
|
|
|
|
<Form
|
|
<Form
|
|
|
scrollToFirstError={true}
|
|
scrollToFirstError={true}
|
|
@@ -177,7 +177,7 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info, APIsave }
|
|
|
rules={[{ required: true, message: '请输入' }]}
|
|
rules={[{ required: true, message: '请输入' }]}
|
|
|
getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
|
|
getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
|
|
|
>
|
|
>
|
|
|
- <Input placeholder='请输入' showCount maxLength={20} />
|
|
|
|
|
|
|
+ <Input placeholder='请输入' showCount maxLength={30} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
|
|
|
|
|
<Form.Item label='藏品标签' name='tagDictId'>
|
|
<Form.Item label='藏品标签' name='tagDictId'>
|
|
@@ -208,7 +208,7 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info, APIsave }
|
|
|
rules={[{ required: true, message: '请输入' }]}
|
|
rules={[{ required: true, message: '请输入' }]}
|
|
|
getValueFromEvent={e => e.target.value.trim()}
|
|
getValueFromEvent={e => e.target.value.trim()}
|
|
|
>
|
|
>
|
|
|
- <Input placeholder='请输入' showCount maxLength={20} />
|
|
|
|
|
|
|
+ <Input placeholder='请输入' showCount maxLength={30} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
|
|
|
|
|
{/* 横线 */}
|
|
{/* 横线 */}
|
|
@@ -220,11 +220,11 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info, APIsave }
|
|
|
rules={[{ required: true, message: '请输入' }]}
|
|
rules={[{ required: true, message: '请输入' }]}
|
|
|
getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
|
|
getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
|
|
|
>
|
|
>
|
|
|
- <Input placeholder='请输入' showCount maxLength={20} />
|
|
|
|
|
|
|
+ <Input placeholder='请输入' showCount maxLength={30} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
|
|
|
|
|
<Form.Item label='藏品原名' name='oldName'>
|
|
<Form.Item label='藏品原名' name='oldName'>
|
|
|
- <Input placeholder='请输入' showCount maxLength={20} />
|
|
|
|
|
|
|
+ <Input placeholder='请输入' showCount maxLength={30} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
|
|
|
|
|
<Form.Item label='藏品级别' name='level'>
|
|
<Form.Item label='藏品级别' name='level'>
|
|
@@ -396,13 +396,7 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info, APIsave }
|
|
|
<div className='AGfull'>
|
|
<div className='AGfull'>
|
|
|
<div className='AGfullll'>附件:</div>
|
|
<div className='AGfullll'>附件:</div>
|
|
|
<div className='AGfullrr'>
|
|
<div className='AGfullrr'>
|
|
|
- <Z3upFilesRef
|
|
|
|
|
- ref={fileRef}
|
|
|
|
|
- oneIsCover={true}
|
|
|
|
|
- moduleId={moduleId}
|
|
|
|
|
- dirCode='registerGoods'
|
|
|
|
|
- myUrl='cms/order/register/son/upload'
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <Z3upFilesRef ref={fileRef} oneIsCover={true} moduleId={moduleId} {...fileUpInfo} />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
{/* 横线 */}
|
|
{/* 横线 */}
|