|
|
@@ -1,7 +1,7 @@
|
|
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
import { useDispatch, useSelector } from 'react-redux'
|
|
|
-import { D2_APIgetList } from '@/store/action/D2storSet'
|
|
|
+import { D2_APIgetList, D2_APIgetSiteList } from '@/store/action/D2storSet'
|
|
|
import { RootState } from '@/store'
|
|
|
import { useParams } from 'react-router-dom'
|
|
|
import { FourTableType } from '@/pages/B_enterTibet/B1collect/type'
|
|
|
@@ -21,13 +21,12 @@ import { API_goodsInfo } from '@/store/action/C1ledger'
|
|
|
import { pageTitTxtObj } from '../../D4impStor/D4edit'
|
|
|
import dayjs from 'dayjs'
|
|
|
import { MessageFu } from '@/utils/message'
|
|
|
-import { findFirstDuplicate } from '../../D4impStor/data'
|
|
|
import history, { btnFlagFu2, infoPageBackFu, openGoodsInfoFu } from '@/utils/history'
|
|
|
import classNames from 'classnames'
|
|
|
-import { Button, DatePicker, Input, InputNumber, Modal, Select } from 'antd'
|
|
|
+import { Button, DatePicker, Input, Modal, Select } from 'antd'
|
|
|
import TextArea from 'antd/es/input/TextArea'
|
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
-import { EXbtnFu } from '@/utils/EXBtn'
|
|
|
+// import { EXbtnFu } from '@/utils/EXBtn'
|
|
|
import D4check, { D4checkArrType } from '../../D4impStor/D4edit/D4check'
|
|
|
import X3auditInfo from '@/pages/X_stock/X3auditInfo'
|
|
|
import { D4tableCgoods, statusObj } from '@/utils/tableData'
|
|
|
@@ -36,7 +35,8 @@ import ZflowTable from '@/components/ZflowTable'
|
|
|
import ZupFileTable from '@/components/ZupFileTable'
|
|
|
import Y1cathet from '@/pages/Y_goodsDetails/Y1cathet'
|
|
|
import ZGaddNow from '@/components/ZGaddNow'
|
|
|
-import { EXPORT_WORD_ENUM } from '@/utils/exportTemplates'
|
|
|
+import { TypeD2listSite } from '../../D2storSet/type'
|
|
|
+// import { EXPORT_WORD_ENUM } from '@/utils/exportTemplates'
|
|
|
|
|
|
function D5edit() {
|
|
|
// 获取库房设置列表 用于分库缩写下拉
|
|
|
@@ -60,6 +60,13 @@ function D5edit() {
|
|
|
const delSnapIdsRef = useRef<number[]>([])
|
|
|
|
|
|
const snapsID2ref = useRef<{ goodsId: number; id: number }[]>([])
|
|
|
+ const [siteList, setSiteList] = useState<TypeD2listSite[]>([])
|
|
|
+
|
|
|
+ // 获取仓位列表
|
|
|
+ const getSiteList = useCallback(async (id: number) => {
|
|
|
+ const { data } = await D2_APIgetSiteList(id)
|
|
|
+ setSiteList(data)
|
|
|
+ }, [])
|
|
|
|
|
|
// 创建订单
|
|
|
const creatFu = useCallback(async () => {
|
|
|
@@ -100,9 +107,11 @@ function D5edit() {
|
|
|
arrTemp.push(obj)
|
|
|
})
|
|
|
setSnaps(arrTemp)
|
|
|
+
|
|
|
+ getSiteList(data.storageId)
|
|
|
}
|
|
|
},
|
|
|
- [id]
|
|
|
+ [getSiteList, id]
|
|
|
)
|
|
|
|
|
|
useEffect(() => {
|
|
|
@@ -171,11 +180,7 @@ function D5edit() {
|
|
|
|
|
|
if (val !== '草稿') {
|
|
|
if (snaps.length === 0) return MessageFu.warning('请添加藏品')
|
|
|
- if (snaps.some(v => !v.siteNumNew)) return MessageFu.warning('请输入入库分库号')
|
|
|
- // 分库号输入重复校验
|
|
|
- const siteNumArr = snaps.map(v => v.siteNumNew!)
|
|
|
- const num = findFirstDuplicate(siteNumArr)
|
|
|
- if (num) return MessageFu.warning(`入库分库号${num}重复`)
|
|
|
+ if (snaps.some(v => !v.siteNumNew)) return MessageFu.warning('请选择入库仓位')
|
|
|
}
|
|
|
|
|
|
if (val === '审批') {
|
|
|
@@ -204,12 +209,14 @@ function D5edit() {
|
|
|
const obj = {
|
|
|
...topInfo,
|
|
|
goodsIds: snaps.map(v => v.id).join(','),
|
|
|
+ siteIds: snaps.map(v => v.siteIdNew).join(','),
|
|
|
siteNums: snaps.map(v => v.siteNumNew).join(','),
|
|
|
delSnapIds: delSnapIdsRef.current.length ? delSnapIdsRef.current : '',
|
|
|
snaps: snaps.map(v => ({
|
|
|
goodsId: v.id,
|
|
|
id: v.id2 ? v.id2 : null,
|
|
|
orderId: topInfo.id,
|
|
|
+ siteId: v.siteIdNew,
|
|
|
siteNum: v.siteNumNew,
|
|
|
snap: JSON.stringify(v)
|
|
|
}))
|
|
|
@@ -235,7 +242,7 @@ function D5edit() {
|
|
|
const data = JSON.parse(res.msg || '[]')
|
|
|
// setCheckArr(data)
|
|
|
const siteNumArr = data.map((v: any) => v.siteNum)
|
|
|
- MessageFu.warning(`入库分库号${siteNumArr}已存在`)
|
|
|
+ MessageFu.warning(`入库仓位${siteNumArr}已存在`)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -248,11 +255,11 @@ function D5edit() {
|
|
|
|
|
|
// 表格的输入框改变
|
|
|
const tableInputChange = useCallback(
|
|
|
- (id: number, val: number | null, key: 'siteNumNew') => {
|
|
|
+ (id: number, val = {} as Partial<Record<keyof C1GoodType, any>>) => {
|
|
|
setSnaps(
|
|
|
snaps.map(v => ({
|
|
|
...v,
|
|
|
- [key]: v.id === id ? val : v[key]
|
|
|
+ ...(v.id === id ? val : {})
|
|
|
}))
|
|
|
)
|
|
|
},
|
|
|
@@ -285,26 +292,32 @@ function D5edit() {
|
|
|
{
|
|
|
title: (
|
|
|
<div>
|
|
|
- <span style={{ color: '#ff4d4f' }}> * </span>入库分库号
|
|
|
+ <span style={{ color: '#ff4d4f' }}> * </span>入库仓位
|
|
|
</div>
|
|
|
),
|
|
|
width: 180,
|
|
|
render: (item: C1GoodType) => (
|
|
|
- <InputNumber
|
|
|
- style={{ width: 170 }}
|
|
|
- disabled={!topInfo.storageId}
|
|
|
- readOnly={['3', '4'].includes(key)}
|
|
|
- min={1}
|
|
|
- max={99999999}
|
|
|
- precision={0}
|
|
|
- value={item.siteNumNew}
|
|
|
- onChange={e => tableInputChange(item.id, e, 'siteNumNew')}
|
|
|
- placeholder={!topInfo.storageId ? '请先选择入库分库缩写' : '请输入'}
|
|
|
+ <Select
|
|
|
+ labelInValue
|
|
|
+ value={item.siteIdNew ? { value: item.siteIdNew, label: item.siteNumNew } : null}
|
|
|
+ style={{ width: 140 }}
|
|
|
+ disabled={!topInfo.storageId || ['3', '4'].includes(key)}
|
|
|
+ onChange={e => {
|
|
|
+ tableInputChange(item.id, {
|
|
|
+ siteIdNew: e.value,
|
|
|
+ siteNumNew: e.label
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ options={siteList.map(i => ({
|
|
|
+ label: `${i.layer1}-${i.layer2}-${i.layer3}`,
|
|
|
+ value: i.id
|
|
|
+ }))}
|
|
|
+ placeholder={!topInfo.storageId ? '请先选择入库分库缩写' : '请选择'}
|
|
|
/>
|
|
|
)
|
|
|
}
|
|
|
]
|
|
|
- }, [cathet, key, tableInputChange, topInfo.storageId])
|
|
|
+ }, [cathet, key, siteList, tableInputChange, topInfo.storageId])
|
|
|
|
|
|
const tableLastBtn = useMemo(() => {
|
|
|
return [
|
|
|
@@ -370,22 +383,20 @@ function D5edit() {
|
|
|
if (val === '创建') history.push(`/moveStor_edit/2/${id}`)
|
|
|
return MessageFu.warning('请添加藏品')
|
|
|
}
|
|
|
- if (snaps.some(v => !v.siteNumNew)) return MessageFu.warning('请输入入库分库号')
|
|
|
- // 分库号输入重复校验
|
|
|
- const siteNumArr = snaps.map(v => v.siteNumNew!)
|
|
|
- const num = findFirstDuplicate(siteNumArr)
|
|
|
- if (num) return MessageFu.warning(`入库分库号${num}重复`)
|
|
|
+ if (snaps.some(v => !v.siteNumNew)) return MessageFu.warning('请选择入库仓位')
|
|
|
}
|
|
|
|
|
|
const obj = {
|
|
|
...topInfo,
|
|
|
goodsIds: snaps.map(v => v.id).join(','),
|
|
|
+ siteIds: snaps.map(v => v.siteIdNew).join(','),
|
|
|
siteNums: snaps.map(v => v.siteNumNew).join(','),
|
|
|
delSnapIds: delSnapIdsRef.current.length ? delSnapIdsRef.current : '',
|
|
|
snaps: snaps.map(v => ({
|
|
|
goodsId: v.id,
|
|
|
id: v.id2 ? v.id2 : null,
|
|
|
orderId: topInfo.id,
|
|
|
+ siteId: v.siteIdNew,
|
|
|
siteNum: v.siteNumNew,
|
|
|
snap: JSON.stringify(v)
|
|
|
}))
|
|
|
@@ -410,7 +421,7 @@ function D5edit() {
|
|
|
const data = JSON.parse(res.msg || '[]')
|
|
|
// setCheckArr(data)
|
|
|
const siteNumArr = data.map((v: any) => v.siteNum)
|
|
|
- MessageFu.warning(`入库分库号${siteNumArr}已存在`)
|
|
|
+ MessageFu.warning(`入库仓位${siteNumArr}已存在`)
|
|
|
}
|
|
|
},
|
|
|
[getInfoFu, id, snaps, topInfo]
|
|
|
@@ -478,9 +489,9 @@ function D5edit() {
|
|
|
</Button>
|
|
|
) : null}
|
|
|
|
|
|
- {EXbtnFu({ ...topInfo, sonNum: storageIdArr.find(i => i.id === topInfo.storageId)?.num }, [
|
|
|
+ {/* {EXbtnFu({ ...topInfo, sonNum: storageIdArr.find(i => i.id === topInfo.storageId)?.num }, [
|
|
|
EXPORT_WORD_ENUM.COLLECTION_RELOCATION
|
|
|
- ])}
|
|
|
+ ])} */}
|
|
|
|
|
|
{btnFlagFu2(topInfo)['删除'] ? (
|
|
|
<MyPopconfirm
|
|
|
@@ -497,7 +508,7 @@ function D5edit() {
|
|
|
<Button onClick={() => infoPageBackFu('/moveStor')}>返回</Button>
|
|
|
</>
|
|
|
)
|
|
|
- }, [delFu, lookBtnFu, lookJumpFu, storageIdArr, topInfo])
|
|
|
+ }, [delFu, lookBtnFu, lookJumpFu, topInfo])
|
|
|
|
|
|
// 申请记录
|
|
|
const [auditsShow, setAuditsShow] = useState(false)
|
|
|
@@ -510,7 +521,8 @@ function D5edit() {
|
|
|
setSnaps(
|
|
|
snaps.map((v, i) => ({
|
|
|
...v,
|
|
|
- siteNumNew: res.data[i]
|
|
|
+ siteIdNew: res.data[i].id,
|
|
|
+ siteNumNew: `${res.data[i].layer1}-${res.data[i].layer2}-${res.data[i].layer3}`
|
|
|
}))
|
|
|
)
|
|
|
MessageFu.success('分配成功')
|
|
|
@@ -632,10 +644,12 @@ function D5edit() {
|
|
|
setSnaps(
|
|
|
snaps.map(v => ({
|
|
|
...v,
|
|
|
- siteNumNew: null
|
|
|
+ siteNumNew: '',
|
|
|
+ siteIdNew: null
|
|
|
}))
|
|
|
)
|
|
|
setTopInfo({ ...topInfo, storageId: e ? e : null })
|
|
|
+ getSiteList(e)
|
|
|
}}
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -682,7 +696,7 @@ function D5edit() {
|
|
|
{['3', '4'].includes(key) ? null : (
|
|
|
<>
|
|
|
<Button type='primary' onClick={autoFu} disabled={snaps.length === 0}>
|
|
|
- 自动分配空置分库号
|
|
|
+ 自动分配空置仓位
|
|
|
</Button>
|
|
|
 
|
|
|
<Button
|
|
|
@@ -794,7 +808,7 @@ function D5edit() {
|
|
|
storageId={Number(topInfo.storageId)}
|
|
|
closeFu={() => setCheckArr([])}
|
|
|
listTemp={checkArr}
|
|
|
- waiSiteNumArr={snaps.map(v => v.siteNumNew!)}
|
|
|
+ waiSiteNumArr={snaps.map(v => v.siteIdNew!)}
|
|
|
type='移库'
|
|
|
/>
|
|
|
) : null}
|