| | |
| | | import { buildProTableDataSource, sendRequest, showDelConfirm } from '@/utils/antdUtils'; |
| | | import { PageContainer, ProTable } from '@ant-design/pro-components'; |
| | | import { Button, Space, Tag } from 'antd'; |
| | | import { Button, DatePicker, Form, Input, message, Modal, Space, Tag } from 'antd'; |
| | | import moment from 'moment'; |
| | | import { useRef, useState } from 'react'; |
| | | import { history, useAccess, Access } from 'umi'; |
| | | import AddAndEdit from './components/addAndEdit'; |
| | | import { maskPhoneNumber, maskString } from '@/utils/utils' |
| | | import { batchDelete, getList, refuse } from './service'; |
| | | import { maskString } from '@/utils/utils' |
| | | import { batchDelete, getList, manualHandle, refuse } from './service'; |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { span: 5 }, |
| | | wrapperCol: { span: 16 }, |
| | | }; |
| | | |
| | | const Banner = () => { |
| | | const actionRef = useRef(); |
| | | const addViewRef = useRef(); |
| | | const access = useAccess(); |
| | | const [form] = Form.useForm(); |
| | | const [modalVisible, handleModalVisible] = useState(false); |
| | | const [reassignmentRecord, setReassignmentRecord] = useState({}); |
| | | |
| | | const [selectedRowKeys, setSelectedRowKeys] = useState([]); |
| | | const [selectedRows, setSelectedRows] = useState([]); |
| | | const isPendingReassignment = (state) => [0, 997].includes(Number(state)); |
| | | const disabledDate = (current) => current && current < moment().subtract(1, 'days').endOf('day'); |
| | | const openReassignmentModal = (record) => { |
| | | setReassignmentRecord(record || {}); |
| | | form.resetFields(); |
| | | form.setFieldsValue({ |
| | | time: record?.newDoorTime ? moment(record.newDoorTime) : undefined, |
| | | applyReason: record?.applyReason, |
| | | }); |
| | | handleModalVisible(true); |
| | | }; |
| | | const closeReassignmentModal = () => { |
| | | handleModalVisible(false); |
| | | setReassignmentRecord({}); |
| | | form.resetFields(); |
| | | }; |
| | | const parseDispatchResponse = (res) => { |
| | | if (res.code == 200) { |
| | | const result = res.data || {}; |
| | | const msg = result.message || res.msg || '操作成功'; |
| | | if (result.success === false) { |
| | | message.warning(msg); |
| | | } else { |
| | | message.success(msg); |
| | | } |
| | | return true; |
| | | } |
| | | message.error(res.msg || '操作失败'); |
| | | return false; |
| | | }; |
| | | const submitReassignment = async () => { |
| | | const values = await form.validateFields(); |
| | | const res = await manualHandle({ |
| | | orderId: reassignmentRecord.orderId, |
| | | time: moment(values.time).format('YYYY-MM-DD'), |
| | | applyReason: reassignmentRecord.applyReason, |
| | | }); |
| | | if (parseDispatchResponse(res)) { |
| | | closeReassignmentModal(); |
| | | actionRef.current?.reload(); |
| | | } |
| | | }; |
| | | const columns = [ |
| | | { |
| | | title: '申请司机', |
| | |
| | | <Button |
| | | type="link" |
| | | onClick={() => { |
| | | addViewRef.current.refreshData(record); |
| | | handleModalVisible(true); |
| | | openReassignmentModal(record); |
| | | }} |
| | | > |
| | | 改派 |
| | |
| | | ]} |
| | | /> |
| | | |
| | | <AddAndEdit |
| | | ref={addViewRef} |
| | | visible={modalVisible} |
| | | onCancel={() => handleModalVisible(false)} |
| | | onSuccess={async () => { |
| | | handleModalVisible(false); |
| | | actionRef.current?.reload(); |
| | | }} |
| | | /> |
| | | <Modal |
| | | getContainer={false} |
| | | width="40%" |
| | | destroyOnClose |
| | | cancelText="取消" |
| | | okText="确认改派" |
| | | title="改派" |
| | | open={modalVisible} |
| | | onCancel={closeReassignmentModal} |
| | | onOk={submitReassignment} |
| | | > |
| | | <Form scrollToFirstError layout="horizontal" {...formItemLayout} form={form}> |
| | | <Form.Item |
| | | name="time" |
| | | label="上门时间" |
| | | rules={[{ required: true, message: '请选择上门时间' }]} |
| | | > |
| | | <DatePicker |
| | | placeholder="请选择上门时间" |
| | | disabledDate={disabledDate} |
| | | format="YYYY-MM-DD" |
| | | style={{ width: '250px' }} |
| | | /> |
| | | </Form.Item> |
| | | <Form.Item name="applyReason" label="再投原因"> |
| | | <Input.TextArea disabled autoSize={{ minRows: 2, maxRows: 4 }} /> |
| | | </Form.Item> |
| | | </Form> |
| | | </Modal> |
| | | </PageContainer> |
| | | </div> |
| | | ); |