import React, { useState, useRef, useEffect, useMemo } from "react"; 
 | 
import { 
 | 
    Edit, 
 | 
    SimpleForm, 
 | 
    FormDataConsumer, 
 | 
    useTranslate, 
 | 
    TextInput, 
 | 
    NumberInput, 
 | 
    BooleanInput, 
 | 
    DateInput, 
 | 
    SelectInput, 
 | 
    ReferenceInput, 
 | 
    ReferenceArrayInput, 
 | 
    AutocompleteInput, 
 | 
    SaveButton, 
 | 
    Toolbar, 
 | 
    required, 
 | 
    DeleteButton, 
 | 
} from 'react-admin'; 
 | 
import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; 
 | 
import StatusSelectInput from "../../components/StatusSelectInput"; 
 | 
import CustomerTopToolBar from "../../components/EditTopToolBar"; 
 | 
import { Stack, Grid, Box, Typography } from '@mui/material'; 
 | 
import { useWatch, useFormContext } from "react-hook-form"; 
 | 
import EditBaseAside from "../../components/EditBaseAside"; 
 | 
import MemoInput from "../../components/MemoInput"; 
 | 
import OrderItemList from "./OrderItemList"; 
 | 
import * as Common from '@/utils/common'; 
 | 
  
 | 
  
 | 
const OrderEdit = () => { 
 | 
    const translate = useTranslate(); 
 | 
    const business = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_business_type')) || []; 
 | 
    const dicts = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_order_type')) || []; 
 | 
  
 | 
    return ( 
 | 
        <Box> 
 | 
            <Edit 
 | 
                redirect="list" 
 | 
                mutationMode={EDIT_MODE} 
 | 
                actions={<CustomerTopToolBar />} 
 | 
                aside={<EditBaseAside />} 
 | 
            > 
 | 
                <SimpleForm 
 | 
                    shouldUnregister 
 | 
                    warnWhenUnsavedChanges 
 | 
                    toolbar={false} 
 | 
                    mode="onTouched" 
 | 
                    defaultValues={{}} 
 | 
                    sx={{ 
 | 
                        "& .MuiFormLabel-root.MuiInputLabel-root.Mui-disabled": { 
 | 
                            bgcolor: 'white', 
 | 
                            WebkitTextFillColor: "rgba(0, 0, 0)" 
 | 
                        }, 
 | 
  
 | 
                        "& .MuiInputBase-input.MuiFilledInput-input.Mui-disabled": { 
 | 
                            bgcolor: 'white', 
 | 
                            WebkitTextFillColor: "rgba(0, 0, 0)" 
 | 
                        }, 
 | 
  
 | 
                        "& .MuiFilledInput-root.MuiInputBase-sizeSmall": { 
 | 
                            bgcolor: 'white', 
 | 
                        } 
 | 
                    }} 
 | 
                > 
 | 
                    <Grid container width={{ xs: '100%', xl: '90%' }} rowSpacing={3} columnSpacing={3}> 
 | 
                        <Grid item xs={24} md={12}> 
 | 
                            <Typography variant="h6" gutterBottom> 
 | 
                                {translate('common.edit.title.main')} 
 | 
                            </Typography> 
 | 
                            <Stack direction='row' gap={2}> 
 | 
                                <TextInput 
 | 
                                    label="table.field.stock.code" 
 | 
                                    source="code" 
 | 
                                    parse={v => v} 
 | 
                                    autoFocus 
 | 
                                /> 
 | 
                                <TextInput 
 | 
                                    label="table.field.stock.sourceCode" 
 | 
                                    source="sourceCode" 
 | 
                                    parse={v => v} 
 | 
                                /> 
 | 
                                <NumberInput 
 | 
                                    label="table.field.stock.sourceId" 
 | 
                                    source="sourceId" 
 | 
                                /> 
 | 
                            </Stack> 
 | 
                            <Stack direction='row' gap={2}> 
 | 
                                <AutocompleteInput 
 | 
                                    choices={dicts} 
 | 
                                    optionText="label" 
 | 
                                    label="table.field.asnOrder.type" 
 | 
                                    source="type" 
 | 
                                    optionValue="value" 
 | 
                                    parse={v => v} 
 | 
                                /> 
 | 
                                <AutocompleteInput 
 | 
                                    choices={business} 
 | 
                                    optionText="label" 
 | 
                                    label="table.field.asnOrder.wkType" 
 | 
                                    source="wkType" 
 | 
                                    optionValue="value" 
 | 
                                    parse={v => v} 
 | 
                                /> 
 | 
                                <NumberInput 
 | 
                                    label="table.field.stock.anfme" 
 | 
                                    source="anfme" 
 | 
                                    validate={required()} 
 | 
                                /> 
 | 
                            </Stack> 
 | 
                        </Grid> 
 | 
                    </Grid> 
 | 
                </SimpleForm> 
 | 
            </Edit > 
 | 
            <OrderItemList /> 
 | 
        </Box> 
 | 
    ) 
 | 
} 
 | 
  
 | 
export default OrderEdit; 
 |