import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import styles from './index.module.scss' import { useParams } from 'react-router-dom' import { Button, Cascader, DatePicker, Input, Select } from 'antd' import { B3aForm1 } from '@/pages/B_enterTibet/B3_4page/B3edit/data' import dayjs from 'dayjs' import Z3upFiles from '@/components/Z3upFiles' import ZRichTexts from '@/components/ZRichTexts' import MyPopconfirm from '@/components/MyPopconfirm' import history, { openGoodsInfoFu } from '@/utils/history' import { MessageFu } from '@/utils/message' import MyTable from '@/components/MyTable' import classNames from 'classnames' import Y1cathet from '@/pages/Y_goodsDetails/Y1cathet' import { D4goodsTableC, statusObj } from '@/utils/tableData' import B3GaddNow from '@/pages/B_enterTibet/B3goodsTable/B3GaddNow' import X1setStoreLocS from '@/pages/X_stock/X1setStoreLocS' import X3auditInfo from '@/pages/X_stock/X3auditInfo' import B3flowTable from '@/pages/B_enterTibet/B3flowTable' import { D4_APIcreate, D4_APIgetInfo } from '@/store/action/D4impStor' import { FourTableType } from '@/pages/B_enterTibet/B3_4page/type' export const pageTitTxtObj = { 1: '新增', 2: '编辑', 3: '审批', 4: '查看' } function D4edit() { const { key, id } = useParams() // key:1 新增 2编辑 3审批 4查看 // 滚到顶部 const sollrDom = useRef(null) // 顶部数据 const [topInfo, setTopInfo] = useState({} as FourTableType) // 创建订单 const creatFu = useCallback(async () => { const res = await D4_APIcreate() if (res.code === 0) { setTopInfo(res.data) } }, []) // 获取详情 const getInfoFu = useCallback(async (id: number) => { const res = await D4_APIgetInfo(id) if (res.code === 0) { setTopInfo(res.data) // 设置藏品清单数据 // goodsTableRef.current?.setData(res.data.goods || []) } }, []) useEffect(() => { if (key === '1') creatFu() else getInfoFu(id) if (sollrDom.current) sollrDom.current.scrollTop = 0 }, [creatFu, getInfoFu, id, key]) // 上传附件的ref const filesRef = useRef(null) // const filesRes = filesRef.current.filesIdRes(); // 富文本的ref const ZRichTextRef = useRef(null) // 审批意见的ref const ZAuditRef = useRef(null) // 设置富文本 // ZRichTextRef.current?.ritxtShowFu(JSON.parse(data.rtf)) const pageTitTxt = useMemo(() => { return Reflect.get(pageTitTxtObj, key) }, [key]) const timeChange = useCallback((e: any) => { console.log(123, e) }, []) // 新增的底部按钮点击 const btnClickFu = useCallback((val: number) => { const rtf1 = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true } console.log('申请信息富文本', JSON.stringify(rtf1.val || '')) const rtf2 = ZAuditRef.current?.resData() console.log('审批信息富文本', rtf2) // if (1 + 1 === 2) return if (val === 2) { // 存草稿 当前页保存 不跳转 MessageFu.success('草稿保存成功') } else { // 跳到详情页 history.push(`/impStor_edit/4/999`) } }, []) // 打开侧边栏 const [cathet, setCathet] = useState(0) // 点击删除 const delTableFu = useCallback(async (id: number) => {}, []) const startBtn = useMemo(() => { return [ { title: '藏品编号', render: (item: any) => { return ( setCathet(item.id)} className={classNames('D1GtNum', item.id === cathet ? 'D1GtNumAc' : '')} > {item.num} ) } } ] }, [cathet]) const tableLastBtn = useMemo(() => { return [ { title: '存放位置', render: (item: any) => ( ) }, { title: '操作', render: (item: any) => { return ( <> {['3', '4'].includes(key) ? null : ( delTableFu(item.id)} /> )} ) } } ] }, [delTableFu, key]) // 点击新增 const [nowSta, setNowSta] = useState({ key: '', id: '' }) // 点击批量设置存放位置 const [setLoc, setSetLoc] = useState(false) // 审批的sta const [auditSta, setAuDitSta] = useState('') // 查看模式下的按钮 待完善 const lookBtn = useMemo(() => { return ( <> {}} Dom={ } /> {}} Dom={ } /> ) }, []) return (
入库-{pageTitTxt}
{['3'].includes(key) ? ( setAuDitSta(val)} ref={ZAuditRef} /> ) : null} {/* 表单字段、附件等 */}
申请信息 {key === '1' ? null : ( )}
* 申请名称:
setTopInfo({ ...topInfo, name: e.target.value.trim() })} readOnly={['3', '4'].includes(key)} placeholder='请输入内容' maxLength={30} showCount />
* 业务类型: {/* 待完善业务类型字段 */}
{B3aForm1.map(v => (
{v.name}:
这是一段文本 {['3', '4'].includes(key) && v.name === '发起人' ? ' - 查看和审批后面显示创建时间' : ''}
))}
相关出库单:
备注:
库房信息
* 入库库房:
{/* 待完善 从库房设置列表里面选择 --默认第一个*/}