Browse Source

chore: 新增单据调整

xyh 2 years ago
parent
commit
62dd5c10df

+ 1 - 0
packages/app/src/pages/production-requisition/table/modal/index.tsx

@@ -44,6 +44,7 @@ const AddModal: FC<Props> = function (props) {
         control={control}
         label='领用部门'
         name='useDepartment'
+        showSearch
       />
       {type === '2' && (
         <ModalField control={control} label='要货申请类型' name='requestOrderType' />

+ 6 - 3
packages/app/src/pages/quality/table/modal/hooks.ts

@@ -2,6 +2,7 @@ import {addQuality} from '@apis';
 import {yupResolver} from '@hookform/resolvers/yup';
 import {AddQualityParams} from '@models';
 import {useMutation} from '@tanstack/react-query';
+import {useLatest} from 'ahooks';
 import {message} from 'antd';
 import dayjs, {Dayjs} from 'dayjs';
 import {useEffect} from 'react';
@@ -129,7 +130,7 @@ export function useFormState({
   visible: boolean;
   onFetch: () => void;
   onClose: () => void;
-  onSearch: (val: string) => void;
+  onSearch: () => void;
 }) {
   const {control, handleSubmit, reset, clearErrors} = useForm<FormState>({
     resolver: yupResolver(validate),
@@ -152,15 +153,17 @@ export function useFormState({
     },
   });
 
+  const clearSearch = useLatest(onSearch);
+
   useEffect(
     function () {
       if (visible) {
         reset();
         clearErrors();
-        onSearch('');
+        clearSearch.current();
       }
     },
-    [clearErrors, reset, visible, onSearch],
+    [clearErrors, reset, visible, clearSearch],
   );
 
   const {isLoading, mutate} = useMutation({

+ 7 - 4
packages/app/src/pages/quality/table/modal/index.tsx

@@ -11,16 +11,19 @@ type Props = {
 
 const AddModal: FC<Props> = function ({visible, onClose, onFetch}) {
   const [materialOptions, onMaterialSearch] = useDictionaryWidthCode('物料字典');
+  const [supplierOptions, onSupplierSearch] = useDictionaryWidthCode('供应商/客户', {
+    findValue: state => state.code,
+  });
   const [{control, isLoading}, {onSubmit}] = useFormState({
     visible,
     onClose,
     onFetch,
-    onSearch: onMaterialSearch,
+    onSearch() {
+      onMaterialSearch('');
+      onSupplierSearch('');
+    },
   });
   const corporationOptions = useDictionaryOptions('公司', false, state => state.code);
-  const [supplierOptions, onSupplierSearch] = useDictionaryWidthCode('供应商/客户', {
-    findValue: state => state.code,
-  });
   const measUnitOptions = useDictionaryOptions('计量单位');
 
   return (

+ 6 - 3
packages/app/src/pages/sell-order/table/modal/hooks.ts

@@ -2,6 +2,7 @@ import {addSell} from '@apis';
 import {yupResolver} from '@hookform/resolvers/yup';
 import {useMutateAddOrder} from '@hooks';
 import {AddSellParams} from '@models';
+import {useLatest} from 'ahooks';
 import dayjs, {Dayjs} from 'dayjs';
 import {useEffect} from 'react';
 import {useForm} from 'react-hook-form';
@@ -89,7 +90,7 @@ export function useFormState({
   visible: boolean;
   onClose: () => void;
   onFetch: () => void;
-  onSearch: (val: string) => void;
+  onSearch: () => void;
 }) {
   const {clearErrors, reset, control, handleSubmit} = useForm<FormState>({
     resolver: yupResolver(validate),
@@ -112,15 +113,17 @@ export function useFormState({
     },
   });
 
+  const clearSearch = useLatest(onSearch);
+
   useEffect(
     function () {
       if (visible) {
         clearErrors();
         reset();
-        onSearch('');
+        clearSearch.current();
       }
     },
-    [clearErrors, onSearch, reset, visible],
+    [clearErrors, clearSearch, reset, visible],
   );
 
   const [isLoading, mutate] = useMutateAddOrder(addSell, onFetch, onClose);

+ 11 - 3
packages/app/src/pages/sell-order/table/modal/index.tsx

@@ -11,9 +11,17 @@ type Props = {
 
 const AddModal: FC<Props> = function (props) {
   const [materialOptions, onMaterialSearch] = useDictionaryWidthCode('物料字典');
-  const [{isLoading, control}, {onSubmit}] = useFormState({...props, onSearch: onMaterialSearch});
+  const [customerOptions, onCustomerSearch] = useDictionaryWidthCode('供应商/客户', {
+    findValue: state => state.code,
+  });
+  const [{isLoading, control}, {onSubmit}] = useFormState({
+    ...props,
+    onSearch() {
+      onMaterialSearch('');
+      onCustomerSearch('');
+    },
+  });
   const companyOptions = useDictionaryOptions('公司', false, state => state.code);
-  const customerOptions = useDictionaryOptions('供应商/客户', false, state => state.code);
   const utilsOptions = useDictionaryOptions('计量单位');
 
   return (
@@ -40,7 +48,7 @@ const AddModal: FC<Props> = function (props) {
         label='客户'
         name='customerNo'
         data={customerOptions}
-        showSearch
+        onSearch={onCustomerSearch}
       />
       <ModalSelect control={control} label='公司' name='companyNumber' data={companyOptions} />
       <ModalDate control={control} label='单据日期' name='docDate' />

+ 1 - 0
packages/app/src/pages/semi-draw/table/modal/index.tsx

@@ -37,6 +37,7 @@ const AddModal: FC<Props> = function (props) {
         control={control}
         label='领用部门'
         name='useDepartment'
+        showSearch
       />
       <ModalField control={control} label='来源类型' name='sourceType' />
       <ModalField control={control} label='移动类型' name='moveType' />