|
@@ -0,0 +1,227 @@
|
|
|
|
+import React from 'react'
|
|
|
|
+import type { ActionType } from '@ant-design/pro-table'
|
|
|
|
+import ProTable from '@ant-design/pro-table'
|
|
|
|
+import {Button, Modal, Form, Radio, Input, message, Select, DatePicker, Upload} from 'antd'
|
|
|
|
+import { withRouter } from 'react-router-dom'
|
|
|
|
+import { User } from '../../services/user'
|
|
|
|
+import './index.scss'
|
|
|
|
+import {PlusOutlined} from "@ant-design/icons";
|
|
|
|
+
|
|
|
|
+const FixOnlineForm: React.FC = (props: any) => {
|
|
|
|
+ const columns: any = [
|
|
|
|
+ {
|
|
|
|
+ title: 'ID',
|
|
|
|
+ dataIndex: 'id',
|
|
|
|
+ search: false
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '分类名称',
|
|
|
|
+ dataIndex: 'user_name',
|
|
|
|
+ search: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '联系地址',
|
|
|
|
+ dataIndex: 'user_name',
|
|
|
|
+ search: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '报修人',
|
|
|
|
+ dataIndex: 'user_name',
|
|
|
|
+ search: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '联系电话',
|
|
|
|
+ dataIndex: 'user_name',
|
|
|
|
+ search: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '预约时间',
|
|
|
|
+ dataIndex: 'user_name',
|
|
|
|
+ search: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '报修内容',
|
|
|
|
+ dataIndex: 'user_name',
|
|
|
|
+ search: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '报修时间',
|
|
|
|
+ dataIndex: 'user_name',
|
|
|
|
+ search: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '状态',
|
|
|
|
+ dataIndex: 'phone',
|
|
|
|
+ search: false,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '操作',
|
|
|
|
+ dataIndex: 'option',
|
|
|
|
+ search: false,
|
|
|
|
+ render: (_, row, index, action) => {
|
|
|
|
+ return [
|
|
|
|
+ <Button
|
|
|
|
+ className="mr-1.5"
|
|
|
|
+ onClick={() => {
|
|
|
|
+ form.setFieldsValue(row)
|
|
|
|
+ setState(prevState => ({
|
|
|
|
+ ...prevState,
|
|
|
|
+ visible: true,
|
|
|
|
+ editId: row.id
|
|
|
|
+ }))
|
|
|
|
+ }}
|
|
|
|
+ >编辑</Button>,
|
|
|
|
+ <Button
|
|
|
|
+ className="mr-1.5"
|
|
|
|
+ onClick={() => {
|
|
|
|
+ setState(prevState => ({
|
|
|
|
+ ...prevState,
|
|
|
|
+ orderVisible: true
|
|
|
|
+ }))
|
|
|
|
+ }}
|
|
|
|
+ >派单</Button>,
|
|
|
|
+ <Button
|
|
|
|
+ className="mr-1.5"
|
|
|
|
+ onClick={() => {
|
|
|
|
+ props.history.push('/admin/fix/order-detail')
|
|
|
|
+ }}
|
|
|
|
+ >详情</Button>,
|
|
|
|
+ <Button onClick={() => {
|
|
|
|
+ Modal.confirm({
|
|
|
|
+ title: '删除记录',
|
|
|
|
+ content: '你确定删除这条记录吗?',
|
|
|
|
+ onOk: async () => {
|
|
|
|
+ await User({ method: 'delete', id: row.id })
|
|
|
|
+ message.success('操作成功!')
|
|
|
|
+ actionRef.current.reload()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }}>删除</Button>
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+
|
|
|
|
+ const [pic, setPic]: any = React.useState([])
|
|
|
|
+
|
|
|
|
+ const uploadButton = (
|
|
|
|
+ <div>
|
|
|
|
+ <PlusOutlined />
|
|
|
|
+ <div style={{ marginTop: 8 }}>上传图片</div>
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
|
|
+ const [state, setState] = React.useState({
|
|
|
|
+ visible: false,
|
|
|
|
+ orderVisible: false,
|
|
|
|
+ editId: null
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ const actionRef: any = React.useRef<ActionType>()
|
|
|
|
+ const [form] = Form.useForm()
|
|
|
|
+ const [orderForm] = Form.useForm()
|
|
|
|
+
|
|
|
|
+ const onSubmit = () => {
|
|
|
|
+ form.validateFields().then(async values => {
|
|
|
|
+ await User({
|
|
|
|
+ method: 'post',
|
|
|
|
+ ...values,
|
|
|
|
+ group_id: 11,
|
|
|
|
+ department_id: 0
|
|
|
|
+ })
|
|
|
|
+ message.success('操作成功!')
|
|
|
|
+ form.resetFields()
|
|
|
|
+ actionRef.current?.reloadAndRest()
|
|
|
|
+ setState(prevState => ({ ...prevState, visible: false }))
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return (
|
|
|
|
+ <React.Fragment>
|
|
|
|
+ <ProTable
|
|
|
|
+ headerTitle="报事报修/在线报修"
|
|
|
|
+ actionRef={actionRef}
|
|
|
|
+ rowKey="key"
|
|
|
|
+ search={false}
|
|
|
|
+ request={User}
|
|
|
|
+ toolBarRender={() => [
|
|
|
|
+ <Button
|
|
|
|
+ type="primary"
|
|
|
|
+ key="primary"
|
|
|
|
+ onClick={() => {
|
|
|
|
+ setState(preState => ({ ...preState, visible: true }))
|
|
|
|
+ }}
|
|
|
|
+ >添加</Button>
|
|
|
|
+ ]}
|
|
|
|
+ columns={columns}
|
|
|
|
+ />
|
|
|
|
+ <Modal
|
|
|
|
+ title='派单'
|
|
|
|
+ visible={state.orderVisible}
|
|
|
|
+ onOk={onSubmit}
|
|
|
|
+ onCancel={() => setState(pre => ({ ...pre, orderVisible: false }))}
|
|
|
|
+ >
|
|
|
|
+ <Form
|
|
|
|
+ labelCol={{ span: 5 }}
|
|
|
|
+ wrapperCol={{ span: 15 }}
|
|
|
|
+ form={orderForm}
|
|
|
|
+ >
|
|
|
|
+ <Form.Item label='部门' name="group_id" rules={[{ required: true }]}>
|
|
|
|
+ <Select placeholder='请选择' options={[]} />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label='报修师傅' name="group_id" rules={[{ required: true }]}>
|
|
|
|
+ <Select placeholder='请选择' options={[]} />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label='处理意见' name="group_id" rules={[{ required: true }]}>
|
|
|
|
+ <Input.TextArea placeholder="多行输入" rows={4} />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ </Form>
|
|
|
|
+ </Modal>
|
|
|
|
+ <Modal
|
|
|
|
+ title='添加报修'
|
|
|
|
+ visible={state.visible}
|
|
|
|
+ onOk={onSubmit}
|
|
|
|
+ onCancel={() => setState(pre => ({ ...pre, visible: false }))}
|
|
|
|
+ >
|
|
|
|
+ <Form
|
|
|
|
+ labelCol={{ span: 5 }}
|
|
|
|
+ wrapperCol={{ span: 15 }}
|
|
|
|
+ form={form}
|
|
|
|
+ >
|
|
|
|
+ <Form.Item label='报修分类' name="group_id" rules={[{ required: true }]}>
|
|
|
|
+ <Select placeholder='请选择' options={[]} />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label='报修人' name="user_name" rules={[{ required: true }]}>
|
|
|
|
+ <Input placeholder="请输入" />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label='联系方式' name="user_name" rules={[{ required: true }]}>
|
|
|
|
+ <Input placeholder="请输入" />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label='预约时间' rules={[{ required: true }]}>
|
|
|
|
+ <DatePicker placeholder="选择时间" format="YYYY-MM-DD" />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label='报修内容' name="user_name" rules={[{ required: true }]}>
|
|
|
|
+ <Input.TextArea placeholder="多行输入" rows={4} />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label='报修图片' name="user_name" rules={[{ required: true }]}>
|
|
|
|
+ <Upload
|
|
|
|
+ action="http://localhost:3000/api/v1/upload"
|
|
|
|
+ listType="picture-card"
|
|
|
|
+ fileList={pic}
|
|
|
|
+ onChange={(({ fileList }) => setPic(fileList))}
|
|
|
|
+ >
|
|
|
|
+ { uploadButton }
|
|
|
|
+ </Upload>
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label='分类状态' name="user_name" rules={[{ required: true }]}>
|
|
|
|
+ <Radio.Group>
|
|
|
|
+ <Radio value={true}>开启</Radio>
|
|
|
|
+ <Radio value={false}>关闭</Radio>
|
|
|
|
+ </Radio.Group>
|
|
|
|
+ </Form.Item>
|
|
|
|
+ </Form>
|
|
|
|
+ </Modal>
|
|
|
|
+ </React.Fragment>
|
|
|
|
+ )
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export default withRouter(FixOnlineForm)
|