skyouc
22 小时以前 92a30abbdc9f65cb1a45a65e39cbfd3f6b52461e
rsf-admin/src/page/outWork/outBound/OutBoundList.jsx
@@ -57,12 +57,18 @@
import request from '@/utils/request';
import LocItemInfoModal from "./locItemInfoModal";
import { Delete } from '@mui/icons-material';
import _, { set } from 'lodash';
import StaSelect from "./StaSelect";
const OutBoundList = () => {    
    const [createDialog, setCreateDialog] = useState(false);
    const [tabelData, setTableData] = useState([]);
    const [selectedRows, setSelectedRows] = useState([]);
    const [sta,setSta] = useState([
    ])
    const notify = useNotify();
    const tableRef = useRef();
    tableRef.current = useGridApiRef();
    const translate = useTranslate();
@@ -71,6 +77,19 @@
        const newTableData = _.filter(tabelData, (item) => !selectedRows.includes(item.matnrId));
        setTableData(newTableData);
    }
    // 添加一个处理新数据的函数,设置outQty默认值
    const handleSetData = (newData) => {
        // 为新添加的数据设置outQty默认值为anfme的值
        const dataWithDefaultQty = newData.map(item => ({
            ...item,
            outQty: item.outQty || item.anfme // 如果outQty已存在则保留,否则使用anfme的值
        }));
        setTableData([...tabelData, ...dataWithDefaultQty]);
    };
    return (
        <>
        <Card sx={{ p: 2, mb: 2, mt:2}}>
@@ -88,37 +107,42 @@
                                onClick={() => setCreateDialog(true)}
                            >
                                {translate('table.field.outBound.withdrawal')}
                            </Button>
                            <ConfirmButton
                                label={'删除'}
                                variant="outlined"
                                color="error"
                                onConfirm={handleDeleteItem}
                            />
                            </Button>
                        </Stack>
                    </Box>
                </Grid>
            </Grid>
        </Card>
        <Card sx={{ p: 2, mb: 2, mt:2}}>
            <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
                <Grid container spacing={2}>
                    <Grid item md={2}>
                        <Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 1 }}>
                            <Typography width={100} vvariant="h6" gutterBottom>
        <Card sx={{ p: 2, mb: 2}}>
            <Form>
            <Grid container spacing={2}>
                <Grid item xs={12}>
                    <Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 1 }}>
                        <Typography width={100} vvariant="h6" gutterBottom>
                            {translate('table.field.outBound.outSta')}
                                </Typography>
                            <DictSelect
                                label={translate("table.field.outStock.wkType")}
                                variant="filled"
                                group='2'
                                dictTypeCode="sys_business_type"
                                required
                         </Typography>
                        <Stack direction='row' spacing={2} minWidth={200}>
                            <StaSelect
                                source="sta"
                                label={translate("table.field.outBound.outSta")}
                                onChange={(e) => {
                                    setSta(e.target.value);
                                    console.log("站点已选择:", e.target.value);
                                }}
                                size="small"
                                type="1"
                            />
                        </Box>
                    </Grid>
                </Grid>
            </Box>
                        </Stack>
                        <Stack direction='row' spacing={2} minWidth={200}>
                            <SubmitButton
                                sta={sta}
                                data={tabelData}
                            />
                        </Stack>
                    </Box>
                </Grid>
            </Grid>
            </Form>
        </Card>
        <Card sx={{ mb: 2}}>
            <Box sx={{  }}>
@@ -129,7 +153,7 @@
                open={createDialog}
                setOpen={setCreateDialog}
                data={tabelData}
                setData={setTableData}
                setData={handleSetData}
            />
            
        </>
@@ -137,6 +161,54 @@
}
export default OutBoundList;
const SubmitButton = (props) =>{
    const translate = useTranslate();
    const notify = useNotify();
    const { sta, data } = props;
    const check = ()=>{
        if(sta === ""){
            notify("请选择站点");
            return;
        }
        if(data.length === 0){
            notify("请选择物料");
            return;
        }
        http(sta,data);
    }
    const http = async (sta,data) => {
        console.log("提交数据",sta,data);
    }
    return (
        <Button
            variant="contained"
            color="primary"
            onClick={check}
        >
          {translate('table.field.outBound.createTask')}
        </Button>
    )
}
const BulkResortButton = () => {
    const record = useRecordContext();
    const bulkResort = () => {
        resortTask([record])
    };
    //批量排序
    const resortTask = async (row) => { }
    return (
        <Button
            onClick={bulkResort}
            label="toolbar.resort">
            <SwapVertIcon />
        </Button>
    )
}
const ModalTable = ({ tabelData, setTableData, selectedRows, setSelectedRows, tableRef }) => {
@@ -146,9 +218,10 @@
    const [columns, setColumns] = useState([
        {
            field: 'outQty',
            headerName: translate('table.field.outBound.outQty'),
            headerName: translate('table.field.outBound.outQty')+"*",
            width: 100,
            editable: true,
            editable: true,
            headerClassName: "custom",
        },
        {
            field: 'anfme',
@@ -201,7 +274,6 @@
        cdata.current = tabelData
    }, [tabelData]);
    const getDynamicFields = async () => {
        const {
            data: { code, data, msg },
@@ -222,14 +294,14 @@
    const handleDelete = (row) => {
        const newData = _.filter(cdata.current, (item) => item.matnrId !== row.matnrId);
        const newData = _.filter(cdata.current, (item) => item.id !== row.id);
        setTableData(newData);
    };
    const processRowUpdate = (newRow, oldRow) => {
        const rows = tabelData.map((r) =>
            r.matnrId === newRow.matnrId ? { ...newRow } : r
            r.id === newRow.id ? { ...newRow } : r
        )
        setTableData(rows)
        return newRow;