123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 |
- 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<any>()
- // key:1 新增 2编辑 3审批 4查看
- // 滚到顶部
- const sollrDom = useRef<HTMLDivElement>(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<any>(null)
- // const filesRes = filesRef.current.filesIdRes();
- // 富文本的ref
- const ZRichTextRef = useRef<any>(null)
- // 审批意见的ref
- const ZAuditRef = useRef<any>(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 (
- <span
- onClick={() => setCathet(item.id)}
- className={classNames('D1GtNum', item.id === cathet ? 'D1GtNumAc' : '')}
- >
- {item.num}
- </span>
- )
- }
- }
- ]
- }, [cathet])
- const tableLastBtn = useMemo(() => {
- return [
- {
- title: '存放位置',
- render: (item: any) => (
- <Cascader
- disabled={['3', '4'].includes(key)}
- options={[
- { value: '年代1', label: '年代11', children: [{ value: 1, label: 'xxx' }] },
- { value: '其他', label: '其他' }
- ]}
- placeholder='请选择'
- // fieldNames={{ label: 'name', value: 'id', children: 'children' }}
- allowClear={false}
- />
- )
- },
- {
- title: '操作',
- render: (item: any) => {
- return (
- <>
- <Button size='small' type='text' onClick={() => openGoodsInfoFu(item.id)}>
- 查看
- </Button>
- {['3', '4'].includes(key) ? null : (
- <MyPopconfirm txtK='删除' onConfirm={() => 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 (
- <>
- <Button type='primary'>创建</Button>
- <Button type='primary'>提交</Button>
- <MyPopconfirm
- txtK='撤回'
- onConfirm={() => {}}
- Dom={
- <Button type='primary' danger>
- 撤回
- </Button>
- }
- />
- <Button type='primary'>审批</Button>
- <Button type='primary'>编辑</Button>
- <Button type='primary'>重新提交</Button>
- <Button type='primary'>导出</Button>
- <MyPopconfirm
- txtK='删除'
- onConfirm={() => {}}
- Dom={
- <Button type='primary' danger>
- 删除
- </Button>
- }
- />
- <Button onClick={() => history.push('/impStor')}>返回</Button>
- </>
- )
- }, [])
- return (
- <div className={styles.D4edit}>
- <div className='pageTitle'>入库-{pageTitTxt}</div>
- <div className='D4main' ref={sollrDom}>
- {['3'].includes(key) ? (
- <X3auditInfo
- dirCode='D4impStor'
- myUrl='cms/orderIn/upload'
- auditSta={auditSta}
- auditStaFu={val => setAuDitSta(val)}
- ref={ZAuditRef}
- />
- ) : null}
- {/* 表单字段、附件等 */}
- <div className='D4Tit'>
- 申请信息
- {key === '1' ? null : (
- <Button type='dashed'>{Reflect.get(statusObj, topInfo.status)}</Button>
- )}
- </div>
- <div className='D4rowAll'>
- <div className='D4row'>
- <div className='D4rowll'>
- <span> * </span>申请名称:
- </div>
- <div className='D4rowrr'>
- <Input
- value={topInfo.name}
- onChange={e => setTopInfo({ ...topInfo, name: e.target.value.trim() })}
- readOnly={['3', '4'].includes(key)}
- placeholder='请输入内容'
- maxLength={30}
- showCount
- />
- </div>
- </div>
- <div className='D4row'>
- <div className='D4rowll'>
- <span> * </span>业务类型:
- {/* 待完善业务类型字段 */}
- </div>
- <div className='D4rowrr'>
- <Cascader
- disabled={['3', '4'].includes(key)}
- options={[
- { value: '年代1', label: '年代11', children: [{ value: 1, label: 'xxx' }] },
- { value: '其他', label: '其他' }
- ]}
- changeOnSelect
- placeholder='请选择'
- // fieldNames={{ label: 'name', value: 'id', children: 'children' }}
- allowClear={false}
- />
- </div>
- </div>
- {B3aForm1.map(v => (
- <div className='D4row' key={v.name}>
- <div className='D4rowll'>{v.name}:</div>
- <div className='D4rowrr'>
- 这是一段文本
- {['3', '4'].includes(key) && v.name === '发起人'
- ? ' - 查看和审批后面显示创建时间'
- : ''}
- </div>
- </div>
- ))}
- <div className='D4row'>
- <div className='D4rowll'>相关出库单:</div>
- <div className='D4rowrr'>
- <Select disabled={['3', '4'].includes(key)} placeholder='请搜索出库单编码' />
- </div>
- </div>
- <div className='D4row'>
- <div className='D4rowll'>
- <span> * </span>业务日期:
- </div>
- <div className='D4rowrr'>
- <DatePicker
- disabled={['3', '4'].includes(key)}
- allowClear={false}
- value={dayjs()}
- onChange={timeChange}
- />
- </div>
- </div>
- <div className='D4row D4row2'>
- <div className='D4rowll'>附件:</div>
- <div className='D4rowrr'>
- <Z3upFiles
- max={10}
- isLook={['3', '4'].includes(key)}
- ref={filesRef}
- fileCheck={false}
- dirCode={'xxxxxxx'}
- myUrl='xxxxxxxxxxxx'
- lookData={[]}
- size={500}
- />
- </div>
- </div>
- <div className='D4row'>
- <div className='D4rowll'>原因事由:</div>
- <div className='D4rowrr'>
- <Input
- readOnly={['3', '4'].includes(key)}
- placeholder='请输入内容'
- maxLength={30}
- showCount
- />
- </div>
- </div>
- <div className='D4row D4rowFull'>
- <div className='D4rowll'>备注:</div>
- <div className='D4rowrr'>
- <ZRichTexts
- check={false}
- dirCode={'xxxxxxxx'}
- isLook={['3', '4'].includes(key)}
- ref={ZRichTextRef}
- myUrl='xxxxxxxxxx'
- isOne={true}
- upAudioBtnNone={true}
- />
- </div>
- </div>
- </div>
- <div className='D4Tit'>库房信息</div>
- <div className='D4rowAll'>
- <div className='D4row'>
- <div className='D4rowll'>
- <span> * </span>入库库房:
- </div>
- <div className='D4rowrr'>
- {/* 待完善 从库房设置列表里面选择 --默认第一个*/}
- <Select disabled={['3', '4'].includes(key)} placeholder='请选择' />
- </div>
- </div>
- <div className='D4row D4row3'>
- <div className='D4rowll'>库房负责人:</div>
- <div className='D4rowrr'>这是一段文本</div>
- </div>
- </div>
- {/* 藏品清单 */}
- <div className='D4googsBox'>
- <div className='D4Tit2'>
- <div className='D4Tit2ll'>藏品清单</div>
- <div className='D4Tit2rr'>
- {['3', '4'].includes(key) ? null : (
- <>
- <Button type='primary' onClick={() => setNowSta({ key: '5', id })}>
- 新增
- </Button>
- <Button type='primary' onClick={() => setSetLoc(true)}>
- 批量设置存放位置
- </Button>
- <Button type='primary'>自动分配空置库位</Button>
- </>
- )}
- </div>
- </div>
- {/* 表格 */}
- <MyTable
- list={[{ id: 99, thumb: '', num: '一段编号_可点击' }]}
- columnsTemp={D4goodsTableC}
- startBtn={startBtn}
- lastBtn={tableLastBtn}
- pagingInfo={false}
- />
- </div>
- {/* 申请流程 */}
- {['3', '4'].includes(key) ? (
- <B3flowTable
- tableArr={
- [
- // 待完善
- ]
- }
- />
- ) : null}
- </div>
- {/* 底部按钮 */}
- <div className='D4btn'>
- {key === '4' ? (
- lookBtn
- ) : (
- <>
- <Button type='primary' onClick={() => btnClickFu(1)}>
- {key === '1' ? '创建' : '保存'}
- </Button>
- {key === '1' ? (
- <Button type='primary' onClick={() => btnClickFu(2)}>
- 存草稿
- </Button>
- ) : null}
- <MyPopconfirm txtK='取消' onConfirm={() => history.push('/impStor')} />
- </>
- )}
- </div>
- {/* 打开侧边栏 */}
- <Y1cathet sId={cathet} closeFu={() => setCathet(0)} />
- {/* 新增弹窗 */}
- {nowSta.id ? (
- <B3GaddNow
- nowSta={nowSta}
- closeFu={() => setNowSta({ key: '', id: '' })}
- dataResFu={data => {}}
- // 待完善
- oldCheckArr={[]}
- />
- ) : null}
- {/* 批量设置存放位置 */}
- {setLoc ? <X1setStoreLocS closeFu={() => setSetLoc(false)} /> : null}
- </div>
- )
- }
- const MemoD4edit = React.memo(D4edit)
- export default MemoD4edit
|