zjj
2025-05-23 48ad97c8a8afa2c9333bd00545dbc54bb4f0870a
rsf-admin/src/page/waitPakin/SelectSiteModel.jsx
@@ -19,6 +19,27 @@
    },
}));
const SelectSiteButton = (props) => {
    const { source, setOpen, refresh, notify } = props;
    const record = useRecordContext();
    const handleClick = async () => {
        setOpen(false);
        const id = record.id;
        const res = await request.post(`/waitPakin/merge`, {waitPakins: source, siteId: id});
        if (res?.data?.code === 200) {
            refresh();
            notify(res.data.msg);
        } else {
            notify(res.data.msg);
        }
    };
    return (
        <Button label="toolbar.selectSite" onClick={handleClick} />
    );
};
const SelectSiteModel = (props) => {
    const { open, setOpen, source } = props;
    const translate = useTranslate();
@@ -34,7 +55,7 @@
    return (
        <Box>
            <Dialog
            sx={{width: '90%'}}
            sx={{width: '100%'}}
                open={open}
                onClose={handleClose}
                fullWidth
@@ -43,10 +64,12 @@
            >
                <DialogTitle>
                    {translate('toolbar.selectSite')}
                    <DialogCloseButton onClose={() => setOpen(false)} />
                </DialogTitle>
                <DialogContent>
                    <List
                        resource='deviceSite'
                        filter={{type : 1}}
                        sx={{
                            flexGrow: 1,
                            transition: (theme) =>
@@ -68,17 +91,7 @@
                        <StyledDatagrid
                            preferenceKey='deviceSite'
                            bulkActionButtons={false}
                            rowClick='toggleSelection'
                            onToggleItem={async (id)=>{
                                setOpen(false);
                                const res = await request.post(`/waitPakin/merge`, {waitPakins: source, siteId: id});
                                if (res?.data?.code === 200) {
                                    refresh();
                                    notify(res.data.msg);
                                } else {
                                    notify(res.data.msg);
                                }
                            }}
                            rowClick={false}
                            omit={['id','name', 'createTime','label', 'createBy', 'memo', 'updateBy$', 'createBy$', 'createTime', 'updateTime']}
                        >
                            <NumberField source="id" />
@@ -97,13 +110,11 @@
                            <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">
                                <Button label="toolbar.selectSite" onClick={(event)=>{
                                    setOpen(false)
                                 }}/>
                                <SelectSiteButton source={source} setOpen={setOpen} refresh={refresh} notify={notify} />
                            </WrapperField>
                        </StyledDatagrid>
                    </List>
                </DialogContent>
                </DialogContent>
            </Dialog>
        </Box>
    )