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

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

parent 10bc76c7
......@@ -34,7 +34,8 @@ const AddRepository:React.FC<{}> = (props) => {
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 { data: foldValue, loading: foldLoading, run: foldFn } = useHttpRequest(PublicApi.postWarehouseFreightSpaceAllotFold)
......@@ -59,7 +60,8 @@ const AddRepository:React.FC<{}> = (props) => {
productId: initValue.productId
}).then(({data, code}) => {
if (code === 1000) {
setReposits(data)
// setReposits(data)
reposits.current = data
}
})
}
......@@ -231,13 +233,13 @@ const AddRepository:React.FC<{}> = (props) => {
// })
FormEffectHooks.onFormMount$().subscribe(() => {
const name = spyForm.getFieldValue('name')
const asyncEnums = reposits.map(v => ({
const asyncEnums = reposits.current.map(v => ({
label: v.name,
value: v.id
}))
utils.enum('freightSpaceId', asyncEnums)
$('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
utils.value('NO_SUBMIT1', numberValue)
setFieldState('NO_SUBMIT1', state => {
......@@ -247,6 +249,7 @@ const AddRepository:React.FC<{}> = (props) => {
state.props["x-component-props"].max = numberValue
state.props["x-component-props"].marks = getStepNumber(numberValue)
})
setForceRender(forceRender + 1)
})
// 调入仓位信息
utils.enum('foldFreightSpaceId', [
......@@ -287,18 +290,19 @@ const AddRepository:React.FC<{}> = (props) => {
console.log('mount')
const name = spyForm.getFieldValue('name')
const inventoryNumber = spyForm.getFieldValue('inventory')
const asyncEnums = reposits.map(v => ({
const asyncEnums = reposits.current.map(v => ({
label: v.name,
value: v.id
}))
utils.enum('foldFreightSpaceId', asyncEnums)
$('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
utils.value('NO_SUBMIT2', numberValue)
setFieldState('NO_SUBMIT2', state => {
state.props.title = `当前仓位库存(${repositValue.unit})`
})
setForceRender(forceRender + 1)
})
setFieldState('foldInventory', state => {
state.props["x-component-props"].max = initValue.inventory
......
......@@ -608,7 +608,10 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({
type: 'string',
enum: getShopTypeMap,
title: '商城类型',
required: true
required: true,
"x-component-props": {
disabled: true
}
},
productName: {
type: 'string',
......
......@@ -161,6 +161,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
}
return fetchOrderApi.getProductList(params)
}
return (
<ModalTable
modalTitle='选择订单商品'
......@@ -171,6 +172,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
cancel={() => setVisible(false)}
fetchTableData={fetchProductList}
rowSelection={rowSelection}
resetModal={{destroyOnClose: true, forceRender: true}}
modalType='productByDefault'
tableProps={{
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