Commit 626d778a authored by 前端-许佳敏's avatar 前端-许佳敏

仓位

parent d3096785
...@@ -7,7 +7,7 @@ const { onFormInit$ } = FormEffectHooks ...@@ -7,7 +7,7 @@ const { onFormInit$ } = FormEffectHooks
* @param name 待处理的表单路径 * @param name 待处理的表单路径
* @param service 触发的异步函数, 需返回一个{label: any, value: any}形式的数组 * @param service 触发的异步函数, 需返回一个{label: any, value: any}形式的数组
*/ */
export const useAsyncSelect = (name, service: () => Promise<any[]>) => { export const useAsyncSelect = async (name, service: () => Promise<any[]>) => {
const { dispatch, setFieldState } = createFormActions() const { dispatch, setFieldState } = createFormActions()
const linkage = useLinkageUtils() const linkage = useLinkageUtils()
onFormInit$().subscribe(() => { onFormInit$().subscribe(() => {
......
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { IApiRequest } from '@/utils/request'; import { IApiRequest } from '@/utils/request';
export interface IHttpRequestReturn<T> { export interface IHttpRequestReturn<T> {
...@@ -8,15 +8,18 @@ export interface IHttpRequestReturn<T> { ...@@ -8,15 +8,18 @@ export interface IHttpRequestReturn<T> {
run(params?: any) run(params?: any)
} }
export interface useHttpRequestConfig extends IApiRequest {
autoRun?: boolean
}
/** /**
* 简易版本的useRequest hooks, 用于处理带有loading的业务场景 * 简易版本的useRequest hooks, 用于处理带有loading的业务场景
* @auth xjm * @auth xjm
*/ */
export function useHttpRequest<T>(api: (params?, config?) => Promise<T>, config?: IApiRequest): IHttpRequestReturn<T> { export function useHttpRequest<T>(api: (params?, config?) => Promise<T>, selfConfig?: useHttpRequestConfig): IHttpRequestReturn<T> {
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [data, setData] = useState<T | null>(null) const [data, setData] = useState<T | null>(null)
const [err, setErr] = useState() const [err, setErr] = useState()
const run = (params) => { const run = (params) => {
setLoading(true) setLoading(true)
api(params).then((res: any) => { api(params).then((res: any) => {
......
...@@ -26,6 +26,7 @@ import { useSyncValues } from '@/formSchema/effects/useSyncValues' ...@@ -26,6 +26,7 @@ import { useSyncValues } from '@/formSchema/effects/useSyncValues'
import { useLinkageUtils } from '@/utils/formEffectUtils' import { useLinkageUtils } from '@/utils/formEffectUtils'
import { createAddRepositoryEffect, useUnitPreview } from './effects' import { createAddRepositoryEffect, useUnitPreview } from './effects'
import ModalTable from '@/components/ModalTable' import ModalTable from '@/components/ModalTable'
import { useHttpRequest } from '@/hooks/useHttpRequest'
const fetchMemberList = async (params) => { const fetchMemberList = async (params) => {
const res = await PublicApi.getMemberMaintenancePage(params) const res = await PublicApi.getMemberMaintenancePage(params)
...@@ -60,21 +61,13 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -60,21 +61,13 @@ const AddRepository:React.FC<{}> = (props) => {
// 获取到的所有仓库, 用于选中后获得仓库库存 // 获取到的所有仓库, 用于选中后获得仓库库存
const [reposits, setReposits] = useState<any>(null) const [reposits, setReposits] = useState<any>(null)
const fetchWarehouseAll = async () => {
const { data } = await PublicApi.getWarehouseWarehouseAll()
setReposits(data)
return data.map(v => ({
value: v.id,
label: v.name
}))
}
const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails) const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails)
const [visibleChannelMember, setVisibleChannelMember] = useState(false) const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false) const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable() const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'}) const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
useUnitPreview(initValue, addSchemaAction) useUnitPreview(initValue, addSchemaAction)
const columnsSetMember: ColumnType<any>[] = [ const columnsSetMember: ColumnType<any>[] = [
{ {
...@@ -141,6 +134,12 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -141,6 +134,12 @@ const AddRepository:React.FC<{}> = (props) => {
}, },
] ]
useEffect(() => {
PublicApi.getWarehouseWarehouseAll().then(({data}) => {
setReposits(data)
})
}, [])
// 弹出会员 // 弹出会员
const handleAddMemberBtn = () => { const handleAddMemberBtn = () => {
const checkBoxs = addSchemaAction.getFieldValue('applyMember') const checkBoxs = addSchemaAction.getFieldValue('applyMember')
...@@ -329,28 +328,26 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -329,28 +328,26 @@ const AddRepository:React.FC<{}> = (props) => {
schema={repositInSchema} schema={repositInSchema}
actions={repositSchemaAction} actions={repositSchemaAction}
onSubmit={handleRespotIn} onSubmit={handleRespotIn}
effects={($, {setFieldState}) => { effects={async ($, {setFieldState}) => {
const utils = useLinkageUtils() const utils = useLinkageUtils()
FormEffectHooks.onFormMount$().subscribe(() => { FormEffectHooks.onFormMount$().subscribe(() => {
const name = spyForm.getFieldValue('name') const name = spyForm.getFieldValue('name')
console.log(reposits)
PublicApi.getWarehouseFreightSpaceAll().then(res => { const asyncEnums = reposits.map(v => ({
const { data } = res
const asyncEnums = data.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 numberValue = data.find(v => v.id === state.value).inventory const numberValue = reposits.find(v => v.id === state.value).principal || 0
utils.value('NO_SUBMIT1', numberValue) utils.value('NO_SUBMIT1', numberValue)
}) })
}) // 调入仓位信息
utils.enum('foldFreightSpaceId', [ utils.enum('foldFreightSpaceId', [
{label: name, value: id} {label: name, value: id}
]) ])
utils.value('foldFreightSpaceId', id) utils.value('foldFreightSpaceId', id)
utils.value('NO_SUBMIT2', spyForm.getFieldValue('inventory'))
}) })
}} }}
expressionScope={{ expressionScope={{
......
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