Selaa lähdekoodia

feat: 增加物料未绑定列表

xyh 2 vuotta sitten
vanhempi
commit
c87fcb24c1

+ 15 - 0
packages/app/src/apis/materialBind.ts

@@ -4,7 +4,9 @@ import {
   BaseResult,
   EditMaterialBindListParams,
   GetMaterialBindrListParams,
+  GetUnBindListParams,
   MaterialBindListData,
+  UnBindListData,
   UserListData,
 } from '@models';
 import {request} from './request';
@@ -80,3 +82,16 @@ export function exportUserBind(data: GetMaterialBindrListParams): any {
     skipError: true,
   });
 }
+
+/** 查询未绑定列表 */
+export function getUnBindList(
+  data: GetUnBindListParams,
+  signal?: AbortSignal,
+): BaseListResult<UnBindListData> {
+  return request({
+    method: 'GET',
+    url: `${BASE_URL}/getBindMaterial`,
+    data,
+    signal,
+  });
+}

+ 6 - 0
packages/app/src/models/request/materialBind.ts

@@ -26,3 +26,9 @@ export type GetMaterialBindrListParams = {
   /** 最后修改人 */
   modifyUser: string;
 } & ListParams;
+
+/** 获取未绑定物料信息 */
+export type GetUnBindListParams = {
+  /** 物料编号 */
+  code: string;
+} & ListParams;

+ 2 - 0
packages/app/src/models/request/semiManufactures.ts

@@ -99,6 +99,8 @@ export type SemiManufacturesOutParams = {
   storageLocationCode: string;
   /** 分录号 */
   entryNumber: string;
+  /** 真实姓名 */
+  realName: string;
 };
 
 /** 产成品/半成品出库物料列表 */

+ 9 - 0
packages/app/src/models/response/materialBind.ts

@@ -9,3 +9,12 @@ export type MaterialBindListData = {
   wllbCode: string;
   userId: string;
 } & ModifyData;
+
+/** 未绑定物料信息 */
+export type UnBindListData = {
+  code: string;
+  id: number;
+  material_id: string;
+  name: string;
+  scrq: string;
+};

+ 2 - 0
packages/app/src/pages/semi-draw/table/put-out-modal/hooks.ts

@@ -88,6 +88,7 @@ export function useFormState({
   });
 
   const userId = useStore(userStore, state => String(state.id));
+  const realName = useStore(userStore, state => state.realName);
 
   const onSubmit = handleSubmit(function({location, outNum}) {
     if (!data)
@@ -112,6 +113,7 @@ export function useFormState({
       storageLocationCode: location,
       userId,
       entryNumber,
+      realName,
     });
   });
 

+ 13 - 0
packages/app/src/pages/unbind-material/context.ts

@@ -0,0 +1,13 @@
+import {
+  createPageContext,
+  createSearchContext,
+  createTableSearchContext,
+} from '@hooks';
+import {GetUnBindListParams, OriginalListParams} from '@models';
+
+export const contextState: OriginalListParams<GetUnBindListParams> = {
+  code: '',
+};
+export const context = createTableSearchContext(contextState);
+export const pageContext = createPageContext();
+export const searchContext = createSearchContext();

+ 41 - 0
packages/app/src/pages/unbind-material/filter/index.tsx

@@ -0,0 +1,41 @@
+import {FilterButtonGroup, FilterField, FilterFieldWrapper} from '@components';
+import {FC} from 'react';
+import {
+  useContextSection,
+  useFilterField,
+  useTableSearchToolEvents,
+} from '@hooks';
+import {context, contextState, searchContext} from '../context';
+import {Card} from 'antd';
+
+const Filter: FC = function() {
+  const [fields, {onChange, resetState}] = useFilterField(
+    {...contextState},
+    true,
+  );
+  const [, {onSearch, onReset}] = useTableSearchToolEvents(context, fields, {
+    resetCallback: resetState,
+  });
+
+  const {isSearching} = useContextSection(searchContext, state => state[0]);
+
+  return (
+    <Card>
+      <FilterFieldWrapper onSearch={onSearch} testId="unbind_filter">
+        <FilterField
+          label="物料编号"
+          name="code"
+          value={fields.code}
+          onChange={onChange('code')}
+        />
+        <FilterButtonGroup
+          onSearch={onSearch}
+          isSearching={isSearching}
+          onReset={onReset}
+        />
+      </FilterFieldWrapper>
+    </Card>
+  );
+};
+
+export default Filter;

+ 22 - 0
packages/app/src/pages/unbind-material/index.tsx

@@ -0,0 +1,22 @@
+import {FC} from 'react';
+import {context, contextState, pageContext, searchContext} from './context';
+import {PageProvider, SearchProvider, TableSearchProvider} from '@components';
+import Filter from './filter';
+import Table from './table';
+
+const UnBind: FC = function() {
+  return (
+    <TableSearchProvider context={context} state={contextState}>
+      <SearchProvider context={searchContext}>
+        <PageProvider context={pageContext}>
+          <section className="content-main">
+            <Filter />
+            <Table />
+          </section>
+        </PageProvider>
+      </SearchProvider>
+    </TableSearchProvider>
+  );
+};
+
+export default UnBind;

+ 53 - 0
packages/app/src/pages/unbind-material/table/index.tsx

@@ -0,0 +1,53 @@
+import {Card} from 'antd';
+import {FC} from 'react';
+import {context, pageContext, searchContext} from '../context';
+import {Table, TableTools} from '@components';
+import {getUnBindList} from '@apis';
+import {useContextSection, useQueryTableList} from '@hooks';
+import {ColumnsType} from 'antd/es/table';
+import {UnBindListData} from '@models';
+import {
+  MATERIAL_CODE_COL_WIDTH,
+  MATERIAL_NAME_COL_WIDTH,
+  MIDDLE_TABLE_WIDTH,
+} from '@utils';
+
+const columns: ColumnsType<UnBindListData> = [
+  {title: '物料ID', dataIndex: 'material_id', width: MATERIAL_CODE_COL_WIDTH},
+  {title: '物料编号', dataIndex: 'code', width: MATERIAL_CODE_COL_WIDTH},
+  {title: '物料名称', dataIndex: 'name', width: MATERIAL_NAME_COL_WIDTH},
+  {title: '日期', dataIndex: 'scrq', width: MIDDLE_TABLE_WIDTH},
+];
+
+const TableList: FC = function() {
+  const params = useContextSection(context, state => state[0]);
+  const [{data, count}] = useQueryTableList({
+    queryFn: getUnBindList,
+    params,
+    pageContext,
+    searchContext,
+  });
+
+  return (
+    <>
+      <Card className="table-wrapper">
+        <TableTools
+          searchContext={searchContext}
+          pageContext={pageContext}
+        />
+
+        <Table
+          data-testid="role_table"
+          columns={columns}
+          data={data}
+          pageContext={pageContext}
+          searchContext={searchContext}
+          count={count}
+        />
+      </Card>
+
+    </>
+  );
+};
+
+export default TableList;

+ 9 - 0
packages/app/src/routes/index.tsx

@@ -42,6 +42,7 @@ import {
   SOFTWARE_BIND_PATH,
   GUN_PATH,
   AGV_PATH,
+  MATERIAL_UNBIND,
 } from './name';
 import {
   Container,
@@ -85,6 +86,7 @@ import {
   SoftwareBind,
   Gun,
   Agv,
+  Unbind,
 } from './routes';
 import Main from '@pages/main';
 import Home from '@pages/home';
@@ -390,6 +392,13 @@ export const routes: RouteObject[] = [
       return await preloadSettings(AGV_PATH);
     },
   },
+  {
+    path: MATERIAL_UNBIND,
+    element: <Unbind />,
+    async loader() {
+      return await preloadSettings(MATERIAL_UNBIND);
+    },
+  },
   {
     path: SCREEN_PURCHASE_PATH,
     element: <ScreenPurchase />,

+ 2 - 0
packages/app/src/routes/name.ts

@@ -114,3 +114,5 @@ export const SOFTWARE_BIND_PATH = '/softwarebind';
 export const GUN_PATH = '/gun/:type';
 /** agv管理 */
 export const AGV_PATH = '/agv';
+/** 物料未绑定列表 */
+export const MATERIAL_UNBIND = '/unbind';

+ 1 - 0
packages/app/src/routes/routes.tsx

@@ -214,3 +214,4 @@ export const SoftwareBind = lazy(
 );
 export const Gun = lazy(() => import(/* webpackChunkName: "gun" */'@pages/gun'));
 export const Agv = lazy(() => import(/* webpackChunkName: "agv" */'@pages/agv'));
+export const Unbind = lazy(() => import(/* webpackChunkName: "unbind" */'@pages/unbind-material'));