From 16845ea7cd44511661766c28b1b17a8e5bdce2a9 Mon Sep 17 00:00:00 2001
From: verou <857149855@qq.com>
Date: 星期一, 17 三月 2025 18:41:49 +0800
Subject: [PATCH] feat:库位初始化

---
 rsf-admin/src/page/basicInfo/loc/LocList.jsx |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/rsf-admin/src/page/basicInfo/loc/LocList.jsx b/rsf-admin/src/page/basicInfo/loc/LocList.jsx
index 5ef83f5..fbbecc9 100644
--- a/rsf-admin/src/page/basicInfo/loc/LocList.jsx
+++ b/rsf-admin/src/page/basicInfo/loc/LocList.jsx
@@ -31,6 +31,8 @@
     ReferenceArrayInput,
     AutocompleteInput,
     DeleteButton,
+    useRefresh,
+    Button
 } from 'react-admin';
 import { Box, Typography, Card, Stack } from '@mui/material';
 import { styled } from '@mui/material/styles';
@@ -39,10 +41,13 @@
 import EmptyData from "../../components/EmptyData";
 import MyCreateButton from "../../components/MyCreateButton";
 import MyExportButton from '../../components/MyExportButton';
+import InitButton from './InitButton';
 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 DashboardIcon from '@mui/icons-material/Dashboard';
+import request from '@/utils/request';
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
     '& .css-1vooibu-MuiSvgIcon-root': {
@@ -98,6 +103,7 @@
     const [createDialog, setCreateDialog] = useState(false);
     const [drawerVal, setDrawerVal] = useState(false);
 
+
     return (
         <Box display="flex">
             <List
@@ -116,6 +122,7 @@
                 actions={(
                     <TopToolbar>
                         <FilterButton />
+                        <InitButton />
                         <MyCreateButton onClick={() => { setCreateDialog(true) }} />
                         <SelectColumnsButton preferenceKey='loc' />
                         <MyExportButton />
@@ -165,6 +172,7 @@
                     <WrapperField cellClassName="opt" label="common.field.opt">
                         <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} />
                         {/* <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> */}
+                        <EnableButton />
                     </WrapperField>
                 </StyledDatagrid>
             </List>
@@ -183,3 +191,29 @@
 }
 
 export default LocList;
+
+const EnableButton = () => {
+    const record = useRecordContext();
+    const notify = useNotify();
+    const refresh = useRefresh();
+    const enable = async () => {
+        const res = await request.post('/loc/update', {
+            ...record,
+            status: +!record.status
+        });
+        if (res?.data?.code === 200) {
+            refresh()
+        } else {
+            notify(res.data.msg);
+        }
+    }
+    return (
+        record.status === 1 ?
+            (<Button onClick={enable} label={"toolbar.unenable"}>
+                <DashboardIcon />
+            </Button>) : (<Button onClick={enable} label={"toolbar.enable"}>
+                <DashboardIcon />
+            </Button>)
+
+    )
+}

--
Gitblit v1.9.1