From 9862254670581214fc78d46956267ad73cc59c56 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期六, 24 五月 2025 10:26:07 +0800
Subject: [PATCH] no message
---
rsf-admin/src/page/task/TaskList.jsx | 316 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 247 insertions(+), 69 deletions(-)
diff --git a/rsf-admin/src/page/task/TaskList.jsx b/rsf-admin/src/page/task/TaskList.jsx
index 4866fb1..3792b7a 100644
--- a/rsf-admin/src/page/task/TaskList.jsx
+++ b/rsf-admin/src/page/task/TaskList.jsx
@@ -1,48 +1,50 @@
import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
import { useNavigate } from 'react-router-dom';
+import request from '@/utils/request';
+
import {
List,
DatagridConfigurable,
SearchInput,
TopToolbar,
SelectColumnsButton,
- EditButton,
FilterButton,
- CreateButton,
- ExportButton,
BulkDeleteButton,
WrapperField,
useRecordContext,
useTranslate,
useNotify,
- useListContext,
- FunctionField,
+ useRefresh,
TextField,
NumberField,
DateField,
+ AutocompleteInput,
BooleanField,
- ReferenceField,
TextInput,
- DateTimeInput,
DateInput,
SelectInput,
NumberInput,
- ReferenceInput,
- ReferenceArrayInput,
- AutocompleteInput,
- DeleteButton,
+ Button,
+ EditButton,
} from 'react-admin';
-import { Box, Typography, Card, Stack } from '@mui/material';
+import { Box, Typography, Card, Stack, Drawer } from '@mui/material';
import { styled } from '@mui/material/styles';
import TaskCreate from "./TaskCreate";
import TaskPanel from "./TaskPanel";
import EmptyData from "../components/EmptyData";
import MyCreateButton from "../components/MyCreateButton";
import MyExportButton from '../components/MyExportButton';
+import SwapVertIcon from '@mui/icons-material/SwapVert';
+import AlignVerticalTopIcon from '@mui/icons-material/AlignVerticalTop';
+import TaskAltIcon from '@mui/icons-material/TaskAlt';
+import CancelIcon from '@mui/icons-material/Cancel';
import PageDrawer from "../components/PageDrawer";
import MyField from "../components/MyField";
+import ConfirmButton from "../components/ConfirmButton";
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import * as Common from '@/utils/common';
+import ColorizeOutlinedIcon from '@mui/icons-material/ColorizeOutlined';
+import GradingOutlinedIcon from '@mui/icons-material/GradingOutlined';
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
'& .css-1vooibu-MuiSvgIcon-root': {
@@ -54,48 +56,49 @@
'& .column-name': {
},
'& .opt': {
- width: 200
+ width: 248
},
}));
-const filters = [
- <SearchInput source="condition" alwaysOn />,
- <DateInput label='common.time.after' source="timeStart" alwaysOn />,
- <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
- <TextInput source="taskCode" label="table.field.task.taskCode" />,
- <NumberInput source="taskStatus" label="table.field.task.taskStatus" />,
- <NumberInput source="taskType" label="table.field.task.taskType" />,
- <TextInput source="orgLoc" label="table.field.task.orgLoc" />,
- <TextInput source="orgSite" label="table.field.task.orgSite" />,
- <TextInput source="targLoc" label="table.field.task.targLoc" />,
- <TextInput source="targSite" label="table.field.task.targSite" />,
- <TextInput source="barcode" label="table.field.task.barcode" />,
- <TextInput source="robotCode" label="table.field.task.robotCode" />,
- <NumberInput source="exceStatus" label="table.field.task.exceStatus" />,
- <TextInput source="expDesc" label="table.field.task.expDesc" />,
- <NumberInput source="sort" label="table.field.task.sort" />,
- <TextInput source="expCode" label="table.field.task.expCode" />,
- <DateInput source="startTime" label="table.field.task.startTime" />,
- <DateInput source="endTime" label="table.field.task.endTime" />,
-
- <TextInput label="common.field.memo" source="memo" />,
- <SelectInput
- label="common.field.status"
- source="status"
- choices={[
- { id: '1', name: 'common.enums.statusTrue' },
- { id: '0', name: 'common.enums.statusFalse' },
- ]}
- resettable
- />,
-]
-
-const TaskList = () => {
+const TaskList = (props) => {
const translate = useTranslate();
-
- const [createDialog, setCreateDialog] = useState(false);
const [drawerVal, setDrawerVal] = useState(false);
+ const dict = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_warehouse_type')) || [];
+
+ const filters = [
+ <SearchInput source="condition" alwaysOn />,
+ <DateInput label='common.time.after' source="timeStart" />,
+ <DateInput label='common.time.before' source="timeEnd" />,
+ <TextInput source="taskCode" label="table.field.task.taskCode" />,
+ <NumberInput source="taskStatus" label="table.field.task.taskStatus" />,
+ <NumberInput source="taskType" label="table.field.task.taskType" />,
+ <AutocompleteInput choices={dict} optionText='label' optionValue="value" source="warehType" label="table.field.task.warehType" />,
+ <TextInput source="orgLoc" label="table.field.task.orgLoc" />,
+ <TextInput source="orgSite" label="table.field.task.orgSite" />,
+ <TextInput source="targLoc" label="table.field.task.targLoc" />,
+ <TextInput source="targSite" label="table.field.task.targSite" />,
+ <TextInput source="barcode" label="table.field.task.barcode" />,
+ <TextInput source="robotCode" label="table.field.task.robotCode" />,
+ <NumberInput source="exceStatus" label="table.field.task.exceStatus" />,
+ <TextInput source="expDesc" label="table.field.task.expDesc" />,
+ <NumberInput source="sort" label="table.field.task.sort" />,
+ <TextInput source="expCode" label="table.field.task.expCode" />,
+ <DateInput source="startTime" label="table.field.task.startTime" />,
+ <DateInput source="endTime" label="table.field.task.endTime" />,
+ <TextInput label="common.field.memo" source="memo" />,
+ <SelectInput
+ label="common.field.status"
+ source="status"
+ choices={[
+ { id: '1', name: 'common.enums.statusTrue' },
+ { id: '0', name: 'common.enums.statusFalse' },
+ ]}
+ resettable
+ />,
+ ]
+
+
return (
<Box display="flex">
@@ -109,31 +112,36 @@
marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
}}
title={"menu.task"}
- empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
+ empty={false}
filters={filters}
sort={{ field: "create_time", order: "desc" }}
actions={(
<TopToolbar>
<FilterButton />
- <MyCreateButton onClick={() => { setCreateDialog(true) }} />
<SelectColumnsButton preferenceKey='task' />
- <MyExportButton />
</TopToolbar>
)}
perPage={DEFAULT_PAGE_SIZE}
>
<StyledDatagrid
preferenceKey='task'
- bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
- rowClick={(id, resource, record) => false}
- expand={() => <TaskPanel />}
+ bulkActionButtons={
+ <>
+ <BulkResortButton />
+ <BulkCancelButton />
+ <BulkDeleteButton mutationMode={OPERATE_MODE} />
+ </>
+ }
+ rowClick={false}
+ expand={false}
expandSingle={true}
- omit={['id', 'createTime', 'createBy', 'memo']}
+ omit={['id', 'createTime', 'createBy', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status', 'sort']}
>
<NumberField source="id" />
<TextField source="taskCode" label="table.field.task.taskCode" />
<NumberField source="taskStatus$" label="table.field.task.taskStatus" />
<NumberField source="taskType$" label="table.field.task.taskType" />
+ <NumberField source="warehType$" label="table.field.task.warehType" />
<TextField source="orgLoc" label="table.field.task.orgLoc" />
<TextField source="orgSite" label="table.field.task.orgSite" />
<TextField source="targLoc" label="table.field.task.targLoc" />
@@ -144,26 +152,21 @@
<TextField source="expDesc" label="table.field.task.expDesc" />
<NumberField source="sort" label="table.field.task.sort" />
<TextField source="expCode" label="table.field.task.expCode" />
- <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
- <TextField source="nickname" />
- </ReferenceField>
+ <TextField source="updateBy$" label="common.field.updateBy" />
+ <TextField source="createBy$" label="common.field.createBy" />
<DateField source="updateTime" label="common.field.updateTime" showTime />
- <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}>
- <TextField source="nickname" />
- </ReferenceField>
<DateField source="createTime" label="common.field.createTime" showTime />
- <BooleanField source="statusBool" label="common.field.status" sortable={false} />
+ {/* <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">
- <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} />
- <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
+ <WrapperField cellClassName="opt" label="common.field.opt" onClick={(e) => e.stopPropagation()} >
+ <EditButton label="toolbar.detail" />
+ <DoneButton sx={{ padding: '1px', fontSize: '.75rem' }} ></DoneButton>
+ <CancelButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
+ <CheckButton />
+ <PickButton />
</WrapperField>
</StyledDatagrid>
</List>
- <TaskCreate
- open={createDialog}
- setOpen={setCreateDialog}
- />
<PageDrawer
title='Task Detail'
drawerVal={drawerVal}
@@ -175,3 +178,178 @@
}
export default TaskList;
+
+
+const CheckButton = () => {
+ const record = useRecordContext();
+ const notify = useNotify();
+ const refresh = useRefresh();
+
+ const checkClick = async () => {
+ const { data: { code, data, msg } } = await request.post(`/task/check/` + record.id);
+ if (code === 200) {
+ notify(msg);
+ refresh();
+ } else {
+ notify(msg);
+ }
+ }
+
+ return (record?.taskStatus == 198 && record?.taskType == 107 ? <ConfirmButton label={"toolbar.check"} startIcon={<GradingOutlinedIcon />} onConfirm={checkClick} /> : <></>)
+}
+
+/**
+ * 鎷f枡鍑哄簱
+ * @returns
+ */
+const PickButton = () => {
+ const record = useRecordContext();
+ const notify = useNotify();
+ const refresh = useRefresh();
+
+ const pickClick = async () => {
+ const { data: { code, data, msg } } = await request.post(`/task/pick/` + record.id);
+ if (code === 200) {
+ notify(msg);
+ refresh();
+ } else {
+ notify(msg);
+ }
+ }
+
+ return (
+ record?.taskStatus == 198 && record?.taskType == 103 ? <ConfirmButton label={"toolbar.pick"} startIcon={<ColorizeOutlinedIcon />} onConfirm={pickClick} /> : <></>
+ )
+}
+
+
+/**
+ * 瀹屾垚鎿嶄綔
+ * @returns
+ */
+const DoneButton = (props) => {
+ const record = useRecordContext();
+ const notify = useNotify();
+ const refresh = useRefresh();
+ const clickComplete = () => {
+ completeTask(record)
+ };
+ //瀹屾垚浠诲姟
+ const completeTask = async (row) => {
+ const { data: { code, data, msg } } = await request.post(`task/complete/` + row.id);
+ if (code === 200) {
+ notify(msg);
+ refresh();
+ } else {
+ notify(msg);
+ }
+ }
+ return (
+ ((record?.taskStatus < 98) || (record?.taskType >= 101 && record?.taskStatus < 199)) ? (<ConfirmButton label={"toolbar.complete"} color="secondary" startIcon={<TaskAltIcon />} onConfirm={clickComplete} />) : (<></>)
+ )
+}
+
+/**
+ * 鍙栨秷鎸夐挳
+ * @returns
+ */
+const CancelButton = () => {
+ const record = useRecordContext();
+ const notify = useNotify();
+ const refresh = useRefresh();
+ const clickCancel = (event) => {
+ event.stopPropagation();
+ cancleTask(record)
+ };
+ //鍙栨秷浠诲姟
+ const cancleTask = async (row) => {
+ console.log(row);
+ const { data: { code, data, msg } } = await request.post(`/task/remove/` + row.id);
+ if (code === 200) {
+ notify(msg);
+ refresh();
+ } else {
+ notify(msg);
+ }
+ }
+ return (
+ record.taskStatus === 1 ?
+ <Button
+ onClick={clickCancel}
+ label="toolbar.cancel">
+ <CancelIcon />
+ </Button>
+ :
+ <></>
+ )
+}
+/**
+ * 缃《鎿嶄綔
+ * @returns
+ */
+const SetTopButton = () => {
+ const record = useRecordContext();
+ const notify = useNotify();
+ const refresh = useRefresh();
+ const clickTop = (event) => {
+ event.stopPropagation();
+ topTask(record)
+ };
+ //缃《浠诲姟
+ const topTask = async (row) => {
+ const { data: { code, data, msg } } = await request.post(`/task/top/` + row.id);
+ if (code === 200) {
+ notify(msg);
+ refresh();
+ } else {
+ notify(msg);
+ }
+ }
+ return (
+ <Button
+ onClick={clickTop}
+ label="toolbar.top">
+ <AlignVerticalTopIcon />
+ </Button>
+ )
+}
+
+/**
+ * 鎵归噺鍙栨秷
+ * @returns
+ */
+const BulkCancelButton = () => {
+ const record = useRecordContext();
+ const clickCancel = () => {
+ cancleTask([record])
+ };
+ //鍙栨秷浠诲姟
+ const cancleTask = async (row) => { }
+ return (
+ <Button
+ onClick={clickCancel}
+ label="toolbar.cancel">
+ <CancelIcon />
+ </Button>
+ )
+}
+
+/**
+ * 鎵归噺鎺掑簭
+ * @returns
+ */
+const BulkResortButton = () => {
+ const record = useRecordContext();
+ const bulkResort = () => {
+ resortTask([record])
+ };
+ //鎵归噺鎺掑簭
+ const resortTask = async (row) => { }
+ return (
+ <Button
+ onClick={bulkResort}
+ label="toolbar.resort">
+ <SwapVertIcon />
+ </Button>
+ )
+}
\ No newline at end of file
--
Gitblit v1.9.1