Commit cad56126 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 处理调整仓位后切换切换无法实时更新库存问题

parent 10bc76c7
...@@ -34,7 +34,8 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -34,7 +34,8 @@ const AddRepository:React.FC<{}> = (props) => {
const [forceRender, setForceRender] = useState(0) const [forceRender, setForceRender] = useState(0)
// 获取到的所有仓库, 用于选中后获得仓库库存 // 获取到的所有仓库, 用于选中后获得仓库库存
const [reposits, setReposits] = useState<any>([]) // const [reposits, setReposits] = useState<any>([])
const reposits = useRef<any>([])
const [isEdit, setIsEdit] = useState(false) const [isEdit, setIsEdit] = useState(false)
const { data: foldValue, loading: foldLoading, run: foldFn } = useHttpRequest(PublicApi.postWarehouseFreightSpaceAllotFold) const { data: foldValue, loading: foldLoading, run: foldFn } = useHttpRequest(PublicApi.postWarehouseFreightSpaceAllotFold)
...@@ -59,7 +60,8 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -59,7 +60,8 @@ const AddRepository:React.FC<{}> = (props) => {
productId: initValue.productId productId: initValue.productId
}).then(({data, code}) => { }).then(({data, code}) => {
if (code === 1000) { if (code === 1000) {
setReposits(data) // setReposits(data)
reposits.current = data
} }
}) })
} }
...@@ -231,13 +233,13 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -231,13 +233,13 @@ const AddRepository:React.FC<{}> = (props) => {
// }) // })
FormEffectHooks.onFormMount$().subscribe(() => { FormEffectHooks.onFormMount$().subscribe(() => {
const name = spyForm.getFieldValue('name') const name = spyForm.getFieldValue('name')
const asyncEnums = reposits.map(v => ({ const asyncEnums = reposits.current.map(v => ({
label: v.name, label: v.name,
value: v.id value: v.id
})) }))
utils.enum('freightSpaceId', asyncEnums) utils.enum('freightSpaceId', asyncEnums)
$('onFieldInputChange', 'freightSpaceId').subscribe(state => { $('onFieldInputChange', 'freightSpaceId').subscribe(state => {
const repositValue = reposits.find(v => v.id === state.value) const repositValue = reposits.current.find(v => v.id === state.value)
const numberValue = repositValue.inventory || 0 const numberValue = repositValue.inventory || 0
utils.value('NO_SUBMIT1', numberValue) utils.value('NO_SUBMIT1', numberValue)
setFieldState('NO_SUBMIT1', state => { setFieldState('NO_SUBMIT1', state => {
...@@ -247,6 +249,7 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -247,6 +249,7 @@ const AddRepository:React.FC<{}> = (props) => {
state.props["x-component-props"].max = numberValue state.props["x-component-props"].max = numberValue
state.props["x-component-props"].marks = getStepNumber(numberValue) state.props["x-component-props"].marks = getStepNumber(numberValue)
}) })
setForceRender(forceRender + 1)
}) })
// 调入仓位信息 // 调入仓位信息
utils.enum('foldFreightSpaceId', [ utils.enum('foldFreightSpaceId', [
...@@ -287,18 +290,19 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -287,18 +290,19 @@ const AddRepository:React.FC<{}> = (props) => {
console.log('mount') console.log('mount')
const name = spyForm.getFieldValue('name') const name = spyForm.getFieldValue('name')
const inventoryNumber = spyForm.getFieldValue('inventory') const inventoryNumber = spyForm.getFieldValue('inventory')
const asyncEnums = reposits.map(v => ({ const asyncEnums = reposits.current.map(v => ({
label: v.name, label: v.name,
value: v.id value: v.id
})) }))
utils.enum('foldFreightSpaceId', asyncEnums) utils.enum('foldFreightSpaceId', asyncEnums)
$('onFieldInputChange', 'foldFreightSpaceId').subscribe(state => { $('onFieldInputChange', 'foldFreightSpaceId').subscribe(state => {
const repositValue = reposits.find(v => v.id === state.value) const repositValue = reposits.current.find(v => v.id === state.value)
const numberValue = repositValue.inventory || 0 const numberValue = repositValue.inventory || 0
utils.value('NO_SUBMIT2', numberValue) utils.value('NO_SUBMIT2', numberValue)
setFieldState('NO_SUBMIT2', state => { setFieldState('NO_SUBMIT2', state => {
state.props.title = `当前仓位库存(${repositValue.unit})` state.props.title = `当前仓位库存(${repositValue.unit})`
}) })
setForceRender(forceRender + 1)
}) })
setFieldState('foldInventory', state => { setFieldState('foldInventory', state => {
state.props["x-component-props"].max = initValue.inventory state.props["x-component-props"].max = initValue.inventory
......
...@@ -608,7 +608,10 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({ ...@@ -608,7 +608,10 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({
type: 'string', type: 'string',
enum: getShopTypeMap, enum: getShopTypeMap,
title: '商城类型', title: '商城类型',
required: true required: true,
"x-component-props": {
disabled: true
}
}, },
productName: { productName: {
type: 'string', type: 'string',
......
...@@ -161,6 +161,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => { ...@@ -161,6 +161,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
} }
return fetchOrderApi.getProductList(params) return fetchOrderApi.getProductList(params)
} }
return ( return (
<ModalTable <ModalTable
modalTitle='选择订单商品' modalTitle='选择订单商品'
...@@ -171,6 +172,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => { ...@@ -171,6 +172,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
cancel={() => setVisible(false)} cancel={() => setVisible(false)}
fetchTableData={fetchProductList} fetchTableData={fetchProductList}
rowSelection={rowSelection} rowSelection={rowSelection}
resetModal={{destroyOnClose: true, forceRender: true}}
modalType='productByDefault' modalType='productByDefault'
tableProps={{ tableProps={{
rowKey: 'id', rowKey: 'id',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment