From d835d1b51f832889929cdf69010034a30ef44d02 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 17 十月 2024 13:57:29 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/task/task/index.jsx |  150 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 141 insertions(+), 9 deletions(-)

diff --git a/zy-asrs-flow/src/pages/task/task/index.jsx b/zy-asrs-flow/src/pages/task/task/index.jsx
index 44c0a24..6f7590f 100644
--- a/zy-asrs-flow/src/pages/task/task/index.jsx
+++ b/zy-asrs-flow/src/pages/task/task/index.jsx
@@ -1,6 +1,6 @@
 
 import React, { useState, useRef, useEffect } from 'react';
-import { Button, message, Modal, Tag  } from 'antd';
+import { Button, message, Modal, Tag } from 'antd';
 import {
     FooterToolbar,
     PageContainer,
@@ -11,6 +11,7 @@
 import { PlusOutlined, ExportOutlined } from '@ant-design/icons';
 import Http from '@/utils/http';
 import Edit from './components/edit'
+import ShuttleCommand from './components/shuttleCommand'
 import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
 import { statusMap } from '@/utils/enum-util'
 import { repairBug } from '@/utils/common-util';
@@ -75,6 +76,46 @@
     }
 };
 
+const handleComplete = async (rows, intl) => {
+    if (!rows) return true;
+    const hide = message.loading(intl.formatMessage({ id: 'page.completeing', defaultMessage: '姝e湪瀹屾垚' }));
+    try {
+        const resp = await Http.doPost('api/task/complete/' + rows.map((row) => row.id).join(','));
+        if (resp.code === 200) {
+            message.success(intl.formatMessage({ id: 'page.complete.success', defaultMessage: '瀹屾垚鎴愬姛' }));
+            return true;
+        } else {
+            message.error(resp.msg);
+            return false;
+        }
+    } catch (error) {
+        message.error(intl.formatMessage({ id: 'page.complete.fail', defaultMessage: '瀹屾垚澶辫触锛岃閲嶈瘯锛�' }));
+        return false;
+    } finally {
+        hide();
+    }
+};
+
+const handleCancel = async (rows, intl) => {
+    if (!rows) return true;
+    const hide = message.loading(intl.formatMessage({ id: 'page.canceling', defaultMessage: '姝e湪鍙栨秷' }));
+    try {
+        const resp = await Http.doPost('api/task/cancel/' + rows.map((row) => row.id).join(','));
+        if (resp.code === 200) {
+            message.success(intl.formatMessage({ id: 'page.cancel.success', defaultMessage: '鍙栨秷鎴愬姛' }));
+            return true;
+        } else {
+            message.error(resp.msg);
+            return false;
+        }
+    } catch (error) {
+        message.error(intl.formatMessage({ id: 'page.cancel.fail', defaultMessage: '鍙栨秷澶辫触锛岃閲嶈瘯锛�' }));
+        return false;
+    } finally {
+        hide();
+    }
+};
+
 const handleExport = async (intl) => {
     const hide = message.loading(intl.formatMessage({ id: 'page.exporting', defaultMessage: '姝e湪瀵煎嚭' }));
     try {
@@ -91,13 +132,13 @@
     }
 };
 
-
 const Main = () => {
     const intl = useIntl();
     const formTableRef = useRef();
     const actionRef = useRef();
     const [selectedRows, setSelectedRows] = useState([]);
     const [modalVisible, setModalVisible] = useState(false);
+    const [shuttleCommandModalVisible, setShuttleCommandModalVisible] = useState(false);
     const [currentRow, setCurrentRow] = useState();
     const [searchParam, setSearchParam] = useState({});
 
@@ -151,6 +192,20 @@
             copyable: true,
             filterDropdown: (props) => <TextFilter
                 name='taskNo'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
+        },
+        {
+            title: 'WMS浠诲姟鍙�',
+            dataIndex: 'wmsTaskNo',
+            valueType: 'text',
+            hidden: false,
+            width: 140,
+            copyable: true,
+            filterDropdown: (props) => <TextFilter
+                name='wmsTaskNo'
                 {...props}
                 actionRef={actionRef}
                 setSearchParam={setSearchParam}
@@ -471,7 +526,7 @@
         {
             title: '鎿嶄綔',
             dataIndex: 'option',
-            width: 140,
+            width: 300,
             valueType: 'option',
             render: (_, record) => [
                 <Button
@@ -486,14 +541,44 @@
                 </Button>,
                 <Button
                     type="link"
-                    danger
-                    key="batchRemove"
+                    key="shuttleCommand"
+                    onClick={() => {
+                        setShuttleCommandModalVisible(true);
+                        setCurrentRow(record);
+                    }}
+                >
+                    <FormattedMessage id='page.shuttleCommand' defaultMessage='绌挎杞︽寚浠�' />
+                </Button>,
+                // <Button
+                //     type="link"
+                //     danger
+                //     key="batchRemove"
+                //     onClick={async () => {
+                //         Modal.confirm({
+                //             title: intl.formatMessage({ id: 'page.delete', defaultMessage: '鍒犻櫎' }),
+                //             content: intl.formatMessage({ id: 'page.delete.confirm', defaultMessage: '纭畾鍒犻櫎璇ラ」鍚楋紵' }),
+                //             onOk: async () => {
+                //                 const success = await handleRemove([record], intl);
+                //                 if (success) {
+                //                     if (actionRef.current) {
+                //                         actionRef.current.reload();
+                //                     }
+                //                 }
+                //             },
+                //         });
+                //     }}
+                // >
+                //     <FormattedMessage id='page.delete' defaultMessage='鍒犻櫎' />
+                // </Button>,
+                <Button
+                    type="link"
+                    key="complete"
                     onClick={async () => {
                         Modal.confirm({
-                            title: intl.formatMessage({ id: 'page.delete', defaultMessage: '鍒犻櫎' }),
-                            content: intl.formatMessage({ id: 'page.delete.confirm', defaultMessage: '纭畾鍒犻櫎璇ラ」鍚楋紵' }),
+                            title: intl.formatMessage({ id: 'page.complete', defaultMessage: '瀹屾垚' }),
+                            content: intl.formatMessage({ id: 'page.complete.confirm', defaultMessage: '纭畾瀹屾垚璇ラ」鍚楋紵' }),
                             onOk: async () => {
-                                const success = await handleRemove([record], intl);
+                                const success = await handleComplete([record], intl);
                                 if (success) {
                                     if (actionRef.current) {
                                         actionRef.current.reload();
@@ -503,7 +588,27 @@
                         });
                     }}
                 >
-                    <FormattedMessage id='page.delete' defaultMessage='鍒犻櫎' />
+                    <FormattedMessage id='page.complete' defaultMessage='瀹屾垚' />
+                </Button>,
+                <Button
+                    type="link"
+                    key="cancel"
+                    onClick={async () => {
+                        Modal.confirm({
+                            title: intl.formatMessage({ id: 'page.cancel', defaultMessage: '鍙栨秷' }),
+                            content: intl.formatMessage({ id: 'page.cancel.confirm', defaultMessage: '纭畾鍙栨秷璇ラ」鍚楋紵' }),
+                            onOk: async () => {
+                                const success = await handleCancel([record], intl);
+                                if (success) {
+                                    if (actionRef.current) {
+                                        actionRef.current.reload();
+                                    }
+                                }
+                            },
+                        });
+                    }}
+                >
+                    <FormattedMessage id='page.cancel' defaultMessage='鍙栨秷' />
                 </Button>,
             ],
         },
@@ -649,6 +754,33 @@
                     }
                 }}
             />
+
+            <ShuttleCommand
+                open={shuttleCommandModalVisible}
+                values={currentRow || {}}
+                onCancel={
+                    () => {
+                        setShuttleCommandModalVisible(false);
+                        setCurrentRow(undefined);
+                    }
+                }
+                onSubmit={async (values) => {
+                    let ok = false;
+                    if (values.id) {
+                        ok = await handleUpdate({ ...values }, intl)
+                    } else {
+                        ok = await handleSave({ ...values }, intl)
+                    }
+                    if (ok) {
+                        setShuttleCommandModalVisible(false);
+                        setCurrentRow(undefined);
+                        if (actionRef.current) {
+                            actionRef.current.reload();
+                        }
+                    }
+                }}
+            />
+
         </PageContainer>
     );
 };

--
Gitblit v1.9.1