|  |  |  | 
|---|
|  |  |  | import React, { | 
|---|
|  |  |  | useState, | 
|---|
|  |  |  | useRef, | 
|---|
|  |  |  | useEffect, | 
|---|
|  |  |  | useMemo, | 
|---|
|  |  |  | useCallback, | 
|---|
|  |  |  | } from "react"; | 
|---|
|  |  |  | import { useNavigate } from "react-router-dom"; | 
|---|
|  |  |  | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; | 
|---|
|  |  |  | import { useNavigate } from 'react-router-dom'; | 
|---|
|  |  |  | import { | 
|---|
|  |  |  | List, | 
|---|
|  |  |  | DatagridConfigurable, | 
|---|
|  |  |  | 
|---|
|  |  |  | ReferenceArrayInput, | 
|---|
|  |  |  | AutocompleteInput, | 
|---|
|  |  |  | DeleteButton, | 
|---|
|  |  |  | } from "react-admin"; | 
|---|
|  |  |  | import { Box, Typography, Card, Stack } from "@mui/material"; | 
|---|
|  |  |  | import { styled } from "@mui/material/styles"; | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { Box, Typography, Card, Stack } from '@mui/material'; | 
|---|
|  |  |  | import { styled } from '@mui/material/styles'; | 
|---|
|  |  |  | import PurchaseCreate from "./PurchaseCreate"; | 
|---|
|  |  |  | import PurchasePanel from "./PurchasePanel"; | 
|---|
|  |  |  | import EmptyData from "../components/EmptyData"; | 
|---|
|  |  |  | import MyCreateButton from "../components/MyCreateButton"; | 
|---|
|  |  |  | import MyExportButton from "../components/MyExportButton"; | 
|---|
|  |  |  | import MyExportButton from '../components/MyExportButton'; | 
|---|
|  |  |  | import PageDrawer from "../components/PageDrawer"; | 
|---|
|  |  |  | import MyField from "../components/MyField"; | 
|---|
|  |  |  | import { | 
|---|
|  |  |  | PAGE_DRAWER_WIDTH, | 
|---|
|  |  |  | OPERATE_MODE, | 
|---|
|  |  |  | DEFAULT_PAGE_SIZE, | 
|---|
|  |  |  | } from "@/config/setting"; | 
|---|
|  |  |  | import * as Common from "@/utils/common"; | 
|---|
|  |  |  | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
|---|
|  |  |  | import * as Common from '@/utils/common'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|---|
|  |  |  | "& .css-1vooibu-MuiSvgIcon-root": { | 
|---|
|  |  |  | height: ".9em", | 
|---|
|  |  |  | '& .css-1vooibu-MuiSvgIcon-root': { | 
|---|
|  |  |  | height: '.9em' | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | "& .RaDatagrid-row": { | 
|---|
|  |  |  | cursor: "auto", | 
|---|
|  |  |  | '& .RaDatagrid-row': { | 
|---|
|  |  |  | cursor: 'auto' | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | "& .column-name": {}, | 
|---|
|  |  |  | "& .opt": { | 
|---|
|  |  |  | width: 200, | 
|---|
|  |  |  | '& .column-name': { | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | '& .opt': { | 
|---|
|  |  |  | width: 200 | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | })); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const filters = [ | 
|---|
|  |  |  | <SearchInput source="condition" alwaysOn />, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <TextInput source="code" label="table.field.purchase.code" />, | 
|---|
|  |  |  | <TextInput source="type" label="table.field.purchase.type" />, | 
|---|
|  |  |  | <TextInput source="from" label="table.field.purchase.from" />, | 
|---|
|  |  |  | <TextInput source="source" label="table.field.purchase.source" />, | 
|---|
|  |  |  | <DateInput source="preArr" label="table.field.purchase.preArr" />, | 
|---|
|  |  |  | <NumberInput source="anfme" label="table.field.purchase.anfme" />, | 
|---|
|  |  |  | <NumberInput source="qty" label="table.field.purchase.qty" />, | 
|---|
|  |  |  | <NumberInput source="workQty" label="table.field.purchase.workQty" />, | 
|---|
|  |  |  | <TextInput source="channel" label="table.field.purchase.channel" />, | 
|---|
|  |  |  | <TextInput source="erpCode" label="table.field.purchase.erpCode" />, | 
|---|
|  |  |  | <TextInput source="platCode" label="table.field.purchase.platCode" />, | 
|---|
|  |  |  | <DateInput source="startTime" label="table.field.purchase.startTime" />, | 
|---|
|  |  |  | <DateInput source="endTime" label="table.field.purchase.endTime" />, | 
|---|
|  |  |  | <TextInput source="project" label="table.field.purchase.project" />, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <TextInput label="common.field.memo" source="memo" />, | 
|---|
|  |  |  | <SelectInput | 
|---|
|  |  |  | label="common.field.status" | 
|---|
|  |  |  | source="status" | 
|---|
|  |  |  | choices={[ | 
|---|
|  |  |  | { id: "1", name: "common.enums.statusTrue" }, | 
|---|
|  |  |  | { id: "0", name: "common.enums.statusFalse" }, | 
|---|
|  |  |  | { id: '1', name: 'common.enums.statusTrue' }, | 
|---|
|  |  |  | { id: '0', name: 'common.enums.statusFalse' }, | 
|---|
|  |  |  | ]} | 
|---|
|  |  |  | resettable | 
|---|
|  |  |  | />, | 
|---|
|  |  |  | ]; | 
|---|
|  |  |  | ] | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const PurchaseList = () => { | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | 
|---|
|  |  |  | sx={{ | 
|---|
|  |  |  | flexGrow: 1, | 
|---|
|  |  |  | transition: (theme) => | 
|---|
|  |  |  | theme.transitions.create(["all"], { | 
|---|
|  |  |  | theme.transitions.create(['all'], { | 
|---|
|  |  |  | duration: theme.transitions.duration.enteringScreen, | 
|---|
|  |  |  | }), | 
|---|
|  |  |  | marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | title={"menu.purchase"} | 
|---|
|  |  |  | empty={ | 
|---|
|  |  |  | <EmptyData | 
|---|
|  |  |  | onClick={() => { | 
|---|
|  |  |  | setCreateDialog(true); | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | } | 
|---|
|  |  |  | empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} | 
|---|
|  |  |  | filters={filters} | 
|---|
|  |  |  | sort={{ field: "create_time", order: "desc" }} | 
|---|
|  |  |  | actions={ | 
|---|
|  |  |  | actions={( | 
|---|
|  |  |  | <TopToolbar> | 
|---|
|  |  |  | <FilterButton /> | 
|---|
|  |  |  | <MyCreateButton | 
|---|
|  |  |  | onClick={() => { | 
|---|
|  |  |  | setCreateDialog(true); | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <SelectColumnsButton preferenceKey="purchase" /> | 
|---|
|  |  |  | <MyCreateButton onClick={() => { setCreateDialog(true) }} /> | 
|---|
|  |  |  | <SelectColumnsButton preferenceKey='purchase' /> | 
|---|
|  |  |  | <MyExportButton /> | 
|---|
|  |  |  | </TopToolbar> | 
|---|
|  |  |  | } | 
|---|
|  |  |  | )} | 
|---|
|  |  |  | perPage={DEFAULT_PAGE_SIZE} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <StyledDatagrid | 
|---|
|  |  |  | preferenceKey="purchase" | 
|---|
|  |  |  | bulkActionButtons={() => ( | 
|---|
|  |  |  | <BulkDeleteButton mutationMode={OPERATE_MODE} /> | 
|---|
|  |  |  | )} | 
|---|
|  |  |  | rowClick={(id, resource, record) => false} | 
|---|
|  |  |  | preferenceKey='purchase' | 
|---|
|  |  |  | bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
|---|
|  |  |  | rowClick={'edit'} | 
|---|
|  |  |  | expand={() => <PurchasePanel />} | 
|---|
|  |  |  | expandSingle={true} | 
|---|
|  |  |  | omit={["id", "createTime", "createBy", "memo"]} | 
|---|
|  |  |  | omit={['id', 'createTime', 'createBy', 'memo']} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <NumberField source="id" /> | 
|---|
|  |  |  | <TextField source="code" label="table.field.purchase.code" /> | 
|---|
|  |  |  | <TextField source="type" label="table.field.purchase.type" /> | 
|---|
|  |  |  | <TextField source="from" label="table.field.purchase.from" /> | 
|---|
|  |  |  | <DateField | 
|---|
|  |  |  | source="preArr" | 
|---|
|  |  |  | label="table.field.purchase.preArr" | 
|---|
|  |  |  | showTime | 
|---|
|  |  |  | <MyField | 
|---|
|  |  |  | source="code" | 
|---|
|  |  |  | label="table.field.purchase.code" | 
|---|
|  |  |  | onClick={(event, record, val) => { | 
|---|
|  |  |  | event.stopPropagation(); | 
|---|
|  |  |  | assign(record); | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <TextField source="type" label="table.field.purchase.type" /> | 
|---|
|  |  |  | <TextField source="source" label="table.field.purchase.source" /> | 
|---|
|  |  |  | <DateField source="preArr" label="table.field.purchase.preArr" showTime /> | 
|---|
|  |  |  | <NumberField source="anfme" label="table.field.purchase.anfme" /> | 
|---|
|  |  |  | <NumberField source="qty" label="table.field.purchase.qty" /> | 
|---|
|  |  |  | <NumberField source="workQty" label="table.field.purchase.workQty" /> | 
|---|
|  |  |  | <TextField source="channel" label="table.field.purchase.channel" /> | 
|---|
|  |  |  | <TextField source="erpCode" label="table.field.purchase.erpCode" /> | 
|---|
|  |  |  | <DateField | 
|---|
|  |  |  | source="startTime" | 
|---|
|  |  |  | label="table.field.purchase.startTime" | 
|---|
|  |  |  | showTime | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <DateField | 
|---|
|  |  |  | source="endTime" | 
|---|
|  |  |  | label="table.field.purchase.endTime" | 
|---|
|  |  |  | showTime | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <TextField source="platCode" label="table.field.purchase.platCode" /> | 
|---|
|  |  |  | <DateField source="startTime" label="table.field.purchase.startTime" showTime /> | 
|---|
|  |  |  | <DateField source="endTime" label="table.field.purchase.endTime" showTime /> | 
|---|
|  |  |  | <TextField source="project" label="table.field.purchase.project" /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ReferenceField | 
|---|
|  |  |  | source="updateBy" | 
|---|
|  |  |  | label="common.field.updateBy" | 
|---|
|  |  |  | reference="user" | 
|---|
|  |  |  | link={false} | 
|---|
|  |  |  | sortable={false} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="nickname" /> | 
|---|
|  |  |  | </ReferenceField> | 
|---|
|  |  |  | <DateField | 
|---|
|  |  |  | source="updateTime" | 
|---|
|  |  |  | label="common.field.updateTime" | 
|---|
|  |  |  | showTime | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <ReferenceField | 
|---|
|  |  |  | source="createBy" | 
|---|
|  |  |  | label="common.field.createBy" | 
|---|
|  |  |  | reference="user" | 
|---|
|  |  |  | link={false} | 
|---|
|  |  |  | sortable={false} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <DateField source="updateTime" label="common.field.updateTime" showTime /> | 
|---|
|  |  |  | <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="nickname" /> | 
|---|
|  |  |  | </ReferenceField> | 
|---|
|  |  |  | <DateField | 
|---|
|  |  |  | source="createTime" | 
|---|
|  |  |  | label="common.field.createTime" | 
|---|
|  |  |  | showTime | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <BooleanField | 
|---|
|  |  |  | source="statusBool" | 
|---|
|  |  |  | label="common.field.status" | 
|---|
|  |  |  | sortable={false} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <DateField source="createTime" label="common.field.createTime" showTime /> | 
|---|
|  |  |  | <BooleanField source="statusBool" label="common.field.status" sortable={false} /> | 
|---|
|  |  |  | <TextField source="memo" label="common.field.memo" sortable={false} /> | 
|---|
|  |  |  | <WrapperField cellClassName="opt" label="common.field.opt"> | 
|---|
|  |  |  | <EditButton sx={{ padding: "1px", fontSize: ".75rem" }} /> | 
|---|
|  |  |  | <DeleteButton | 
|---|
|  |  |  | sx={{ padding: "1px", fontSize: ".75rem" }} | 
|---|
|  |  |  | mutationMode={OPERATE_MODE} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> | 
|---|
|  |  |  | <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> | 
|---|
|  |  |  | </WrapperField> | 
|---|
|  |  |  | </StyledDatagrid> | 
|---|
|  |  |  | </List> | 
|---|
|  |  |  | <PurchaseCreate open={createDialog} setOpen={setCreateDialog} /> | 
|---|
|  |  |  | <PurchaseCreate | 
|---|
|  |  |  | open={createDialog} | 
|---|
|  |  |  | setOpen={setCreateDialog} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <PageDrawer | 
|---|
|  |  |  | title="Purchase Detail" | 
|---|
|  |  |  | title='Purchase Detail' | 
|---|
|  |  |  | drawerVal={drawerVal} | 
|---|
|  |  |  | setDrawerVal={setDrawerVal} | 
|---|
|  |  |  | ></PageDrawer> | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </PageDrawer> | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export default PurchaseList; | 
|---|