skyouc
4 天以前 ed08477d187fe143566c9baeeef365b1eacbdfd4
rsf-admin/src/page/orders/transfer/TransferEdit.jsx
@@ -1,171 +1,152 @@
import React, { useState, useRef, useEffect, useMemo } from "react";
import {
    Edit,
    SimpleForm,
    FormDataConsumer,
    useTranslate,
    TextInput,
    NumberInput,
    BooleanInput,
    DateInput,
    SelectInput,
    ReferenceInput,
    ReferenceArrayInput,
    AutocompleteInput,
    SaveButton,
    Toolbar,
    Labeled,
    NumberField,
    required,
    useRecordContext,
    DeleteButton,
} from 'react-admin';
  Edit,
  SimpleForm,
  FormDataConsumer,
  useTranslate,
  TextInput,
  NumberInput,
  BooleanInput,
  DateInput,
  SelectInput,
  ReferenceInput,
  ReferenceArrayInput,
  AutocompleteInput,
  SaveButton,
  Toolbar,
  Labeled,
  NumberField,
  required,
  useRecordContext,
  DeleteButton,
} from "react-admin";
import { useWatch, useFormContext } from "react-hook-form";
import { Stack, Grid, Box, Typography } from '@mui/material';
import * as Common from '@/utils/common.js';
import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting.js';
import { Stack, Grid, Box, Typography } from "@mui/material";
import * as Common from "@/utils/common.js";
import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from "@/config/setting.js";
import EditBaseAside from "../../components/EditBaseAside.jsx";
import CustomerTopToolBar from "../../components/EditTopToolBar.jsx";
import MemoInput from "../../components/MemoInput.jsx";
import StatusSelectInput from "../../components/StatusSelectInput.jsx";
import TransferItemList from "./TransferItemList.jsx";
const FormToolbar = () => {
    const { getValues } = useFormContext();
  const { getValues } = useFormContext();
    return (
        <Toolbar sx={{ justifyContent: 'space-between' }}>
            <SaveButton />
            <DeleteButton mutationMode="optimistic" />
        </Toolbar>
    )
}
  return (
    <Toolbar sx={{ justifyContent: "space-between" }}>
      <SaveButton />
      <DeleteButton mutationMode="optimistic" />
    </Toolbar>
  );
};
const TransferEdit = () => {
    const translate = useTranslate();
  const translate = useTranslate();
    return (
        <Edit
            redirect="list"
            mutationMode={EDIT_MODE}
            actions={<CustomerTopToolBar />}
            aside={<EditBaseAside />}
  return (
    <>
      <Edit
        redirect="list"
        mutationMode={EDIT_MODE}
        actions={<CustomerTopToolBar />}
        aside={<EditBaseAside />}
      >
        <SimpleForm
          shouldUnregister
          warnWhenUnsavedChanges
          toolbar={<FormToolbar />}
          mode="onTouched"
          defaultValues={{}}
          // validate={(values) => { }}
        >
            <SimpleForm
                shouldUnregister
                warnWhenUnsavedChanges
                toolbar={<FormToolbar />}
                mode="onTouched"
                defaultValues={{}}
            // validate={(values) => { }}
            >
                <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}>
                    <Grid item xs={12} md={8}>
                        <Typography variant="h6" gutterBottom>
                            {translate('common.edit.title.main')}
                        </Typography>
                        <Stack direction='row' gap={2}>
                            <TextInput
                                label="table.field.transfer.code"
                                source="code"
                                parse={v => v}
                                autoFocus
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <NumberInput
                                label="table.field.transfer.type"
                                source="type"
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <SelectInput
                                label="table.field.transfer.source"
                                source="source"
                                choices={[
                                    { id: 1, name: 'ERP系统' },
                                    { id:  2, name: 'WMS系统生成' },
                                    { id:  3, name: 'EXCEL导入 ' },
                                    { id:  4, name: 'QMS系统' },
                                ]}
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <SelectInput
                                label="table.field.transfer.exceStatus"
                                source="exceStatus"
                                choices={[
                                    { id: 0, name: '未执行' },
                                    { id:  1, name: '执行中' },
                                    { id:  2, name: '执行完成' },
                                ]}
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <NumberInput
                                label="table.field.transfer.orgWareId"
                                source="orgWareId"
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <TextInput
                                label="table.field.transfer.orgWareName"
                                source="orgWareName"
                                parse={v => v}
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <NumberInput
                                label="table.field.transfer.tarWareId"
                                source="tarWareId"
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <TextInput
                                label="table.field.transfer.tarWareName"
                                source="tarWareName"
                                parse={v => v}
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <NumberInput
                                label="table.field.transfer.orgAreaId"
                                source="orgAreaId"
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <TextInput
                                label="table.field.transfer.orgAreaName"
                                source="orgAreaName"
                                parse={v => v}
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <NumberInput
                                label="table.field.transfer.tarAreaId"
                                source="tarAreaId"
                            />
                        </Stack>
                        <Stack direction='row' gap={2}>
                            <TextInput
                                label="table.field.transfer.tarAreaName"
                                source="tarAreaName"
                                parse={v => v}
                            />
                        </Stack>
                    </Grid>
                    <Grid item xs={12} md={4}>
                        <Typography variant="h6" gutterBottom>
                            {translate('common.edit.title.common')}
                        </Typography>
                        <StatusSelectInput />
                        <Box mt="2em" />
                        <MemoInput />
                    </Grid>
                </Grid>
            </SimpleForm>
        </Edit >
    )
}
          <Grid
            container
            width={{ xs: "100%", xl: "80%" }}
            rowSpacing={3}
            columnSpacing={3}
          >
            <Grid item xs={12} md={8}>
              <Typography variant="h6" gutterBottom>
                {translate("common.edit.title.main")}
              </Typography>
              <Stack direction="row" gap={2}>
                <TextInput
                  label="table.field.transfer.code"
                  source="code"
                  parse={(v) => v}
                  autoFocus
                />
              </Stack>
              <Stack direction="row" gap={2}>
                <NumberInput label="table.field.transfer.type" source="type" />
                <SelectInput
                  label="table.field.transfer.source"
                  source="source"
                  choices={[
                    { id: 1, name: "ERP系统" },
                    { id: 2, name: "WMS系统生成" },
                    { id: 3, name: "EXCEL导入 " },
                    { id: 4, name: "QMS系统" },
                  ]}
                />
                <SelectInput
                  label="table.field.transfer.exceStatus"
                  source="exceStatus"
                  choices={[
                    { id: 0, name: "未执行" },
                    { id: 1, name: "执行中" },
                    { id: 2, name: "执行完成" },
                  ]}
                />
              </Stack>
              <Stack direction="row" gap={2}>
                <NumberInput
                  label="table.field.transfer.orgWareId"
                  source="orgWareId"
                />
                <TextInput
                  label="table.field.transfer.orgWareName"
                  source="orgWareName"
                  parse={(v) => v}
                />
                <NumberInput
                  label="table.field.transfer.tarWareId"
                  source="tarWareId"
                />
                <TextInput
                  label="table.field.transfer.tarWareName"
                  source="tarWareName"
                  parse={(v) => v}
                />
              </Stack>
              <Stack direction="row" gap={2}>
                <NumberInput
                  label="table.field.transfer.orgAreaId"
                  source="orgAreaId"
                />
                <TextInput
                  label="table.field.transfer.orgAreaName"
                  source="orgAreaName"
                  parse={(v) => v}
                />
                <NumberInput
                  label="table.field.transfer.tarAreaId"
                  source="tarAreaId"
                />
                <TextInput
                  label="table.field.transfer.tarAreaName"
                  source="tarAreaName"
                  parse={(v) => v}
                />
              </Stack>
            </Grid>
          </Grid>
        </SimpleForm>
      </Edit>
      <TransferItemList />
    </>
  );
};
export default TransferEdit;