| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { Button, message, Modal, Tag } from 'antd'; |
| | | import { Button, message, Modal, Tag } from 'antd'; |
| | | import { |
| | | FooterToolbar, |
| | | PageContainer, |
| | |
| | | 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'; |
| | |
| | | } |
| | | }; |
| | | |
| | | const handleComplete = async (rows, intl) => { |
| | | if (!rows) return true; |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.completeing', defaultMessage: '正在完成' })); |
| | | 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: '正在取消' })); |
| | | 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: '正在导出' })); |
| | | try { |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | 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({}); |
| | | |
| | |
| | | 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} |
| | |
| | | { |
| | | title: '操作', |
| | | dataIndex: 'option', |
| | | width: 140, |
| | | width: 300, |
| | | valueType: 'option', |
| | | render: (_, record) => [ |
| | | <Button |
| | |
| | | </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(); |
| | |
| | | }); |
| | | }} |
| | | > |
| | | <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>, |
| | | ], |
| | | }, |
| | |
| | | } |
| | | }} |
| | | /> |
| | | |
| | | <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> |
| | | ); |
| | | }; |