|
|
@@ -1,7 +1,7 @@
|
|
|
import React, { useCallback, useEffect, useRef } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
import { GoodsType } from '../SonGoodsList/data'
|
|
|
-import { Cascader, DatePicker, Form, FormInstance, Input, InputNumber, Select } from 'antd'
|
|
|
+import { Button, Cascader, DatePicker, Form, FormInstance, Input, InputNumber, Select } from 'antd'
|
|
|
import { useDispatch, useSelector } from 'react-redux'
|
|
|
import { RootState } from '@/store'
|
|
|
import { E1_APIgetTree } from '@/store/action/Eculture/E1tag'
|
|
|
@@ -10,12 +10,36 @@ import { getTokenInfo } from '@/utils/storage'
|
|
|
import { getDictFu, selectObj } from '@/utils/dataChange'
|
|
|
import TextArea from 'antd/es/input/TextArea'
|
|
|
import Z3upFilesRef from '@/components/Z3upFilesRef'
|
|
|
+import GuShi from '../GuShi'
|
|
|
+import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
+import { API_getGoodsInfo } from '@/store/action/Cledger/C1ledger'
|
|
|
+
|
|
|
+// 级联的数据转换成字符串
|
|
|
+export const cascaderChArr = [
|
|
|
+ 'tagDictId',
|
|
|
+ 'typeDictId',
|
|
|
+ 'ageDictId',
|
|
|
+ 'pcsUnitDictId',
|
|
|
+ 'textureDictId',
|
|
|
+ 'qualityLevelDictId'
|
|
|
+]
|
|
|
+
|
|
|
+// 下拉框为空的时候转变成null
|
|
|
+export const addZiSelectChArr = [
|
|
|
+ 'level',
|
|
|
+ 'tornLevel',
|
|
|
+ 'keep',
|
|
|
+ 'qualityScope',
|
|
|
+ 'qualityUnitDictId',
|
|
|
+ 'inGoodYearScope',
|
|
|
+ 'source'
|
|
|
+]
|
|
|
|
|
|
type Props = {
|
|
|
info: GoodsType
|
|
|
closeFu: () => void
|
|
|
- isEdit: boolean //藏品编辑模块
|
|
|
- editSnap?: GoodsType //藏品模块属于新增还是编辑
|
|
|
+ isEdit: boolean //藏品编辑-模块
|
|
|
+ editSnap?: GoodsType //藏品编辑-属于新增还是编辑
|
|
|
succFu: (val: GoodsType, newFlag?: boolean) => void
|
|
|
moduleId: number
|
|
|
}
|
|
|
@@ -33,11 +57,93 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info }: Props)
|
|
|
// 设置表单ref
|
|
|
const FormBoxRef = useRef<FormInstance>(null)
|
|
|
|
|
|
+ // 故事模块的ref
|
|
|
+ const guShiRef = useRef<any>(null)
|
|
|
+
|
|
|
+ // 附件模块的ref
|
|
|
+ const fileRef = useRef<any>(null)
|
|
|
+
|
|
|
+ // 藏品编辑模块用来对比
|
|
|
+ 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)
|
|
|
+
|
|
|
+ // 设置附件
|
|
|
+ // fileRef.current?.sonSetListFu(fileList)
|
|
|
+
|
|
|
+ // 待完善sg-设置故事
|
|
|
+ // guShiRef.current?.setGuShiListBySon(list)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [editSnap]
|
|
|
+ )
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (info.id > 0) getInfo(info.id)
|
|
|
+ }, [getInfo, info.id])
|
|
|
+
|
|
|
// 没有通过校验
|
|
|
const onFinishFailed = useCallback(() => {}, [])
|
|
|
|
|
|
// 通过校验点击确定
|
|
|
- const onFinish = useCallback(async (values: any) => {}, [])
|
|
|
+ const onFinish = useCallback(
|
|
|
+ async (values: any) => {
|
|
|
+ // 获取附件
|
|
|
+ const { list: flieList, thumb, thumbPc } = fileRef.current?.sonResListFu()
|
|
|
+ // 待完善sg-设置故事
|
|
|
+ // const guShiList= guShiRef.current?.getGuShiListBySon()
|
|
|
+ // 2个日期的格式处理
|
|
|
+ let makeDate = ''
|
|
|
+ if (values.makeDate) makeDate = dayjs(values.makeDate).format('YYYY-MM-DD')
|
|
|
+ let inGoodYear = ''
|
|
|
+ if (values.inGoodYear) inGoodYear = dayjs(values.inGoodYear).format('YYYY-MM-DD')
|
|
|
+
|
|
|
+ const obj = {
|
|
|
+ ...values,
|
|
|
+ id: info.id > 0 ? info.id : null,
|
|
|
+ makeDate,
|
|
|
+ inGoodYear,
|
|
|
+ fileIds: flieList.join(','),
|
|
|
+ thumb,
|
|
|
+ thumbPc
|
|
|
+ }
|
|
|
+ for (const k in obj) {
|
|
|
+ if (obj[k] === null || obj[k] === undefined) obj[k] = ''
|
|
|
+ }
|
|
|
+
|
|
|
+ // 级联的数据转换成字符串
|
|
|
+ cascaderChArr.forEach(v => {
|
|
|
+ if (values[v]) obj[v] = values[v].join(',')
|
|
|
+ })
|
|
|
+ if (1 + 1 === 2) {
|
|
|
+ console.log(123, obj)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [info.id]
|
|
|
+ )
|
|
|
|
|
|
return (
|
|
|
<div className={styles.AddGoods}>
|
|
|
@@ -284,6 +390,7 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info }: Props)
|
|
|
<div className='AGfullll'>附件:</div>
|
|
|
<div className='AGfullrr'>
|
|
|
<Z3upFilesRef
|
|
|
+ ref={fileRef}
|
|
|
oneIsCover={true}
|
|
|
moduleId={moduleId}
|
|
|
dirCode='registerGoods'
|
|
|
@@ -291,8 +398,22 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info }: Props)
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ {/* 横线 */}
|
|
|
+ <div className='AGxian'></div>
|
|
|
+ <div className='AGfull'>
|
|
|
+ <div className='AGfullll'>故事:</div>
|
|
|
+ <div className='AGfullrr'>
|
|
|
+ <GuShi moduleId={moduleId} ref={guShiRef} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
|
|
|
- {/* 故事模块待完善sg */}
|
|
|
+ {/* 确定和取消按钮 */}
|
|
|
+ <Form.Item className='AGbtnok'>
|
|
|
+ <Button type='primary' htmlType='submit'>
|
|
|
+ 提交
|
|
|
+ </Button>
|
|
|
+ <MyPopconfirm txtK='取消' onConfirm={closeFu} />
|
|
|
+ </Form.Item>
|
|
|
</div>
|
|
|
</Form>
|
|
|
</div>
|