|
@@ -1,11 +1,13 @@
|
|
|
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 { Button, Modal, Form, Input, message, Select, DatePicker, Upload } from 'antd'
|
|
|
import { withRouter } from 'react-router-dom'
|
|
|
-import { User } from '../../services/user'
|
|
|
+import { FixApi } from '../../services/fix'
|
|
|
import './index.scss'
|
|
|
-import {PlusOutlined} from "@ant-design/icons";
|
|
|
+import { PlusOutlined } from "@ant-design/icons"
|
|
|
+import { useFixClass } from "./hooks"
|
|
|
+import { useBuildingHouse } from "../building/hooks"
|
|
|
|
|
|
const FixOnlineForm: React.FC = (props: any) => {
|
|
|
const columns: any = [
|
|
@@ -16,43 +18,50 @@ const FixOnlineForm: React.FC = (props: any) => {
|
|
|
},
|
|
|
{
|
|
|
title: '分类名称',
|
|
|
- dataIndex: 'user_name',
|
|
|
+ dataIndex: 'class_name',
|
|
|
search: true,
|
|
|
},
|
|
|
{
|
|
|
title: '联系地址',
|
|
|
- dataIndex: 'user_name',
|
|
|
+ dataIndex: 'house_name',
|
|
|
search: false,
|
|
|
},
|
|
|
{
|
|
|
title: '报修人',
|
|
|
- dataIndex: 'user_name',
|
|
|
+ dataIndex: 'apply_people',
|
|
|
search: true,
|
|
|
},
|
|
|
{
|
|
|
title: '联系电话',
|
|
|
- dataIndex: 'user_name',
|
|
|
+ dataIndex: 'apply_people_phone',
|
|
|
search: true,
|
|
|
},
|
|
|
{
|
|
|
title: '预约时间',
|
|
|
- dataIndex: 'user_name',
|
|
|
+ dataIndex: 'appointment',
|
|
|
search: false,
|
|
|
+ valueType: 'dateTime',
|
|
|
},
|
|
|
{
|
|
|
title: '报修内容',
|
|
|
- dataIndex: 'user_name',
|
|
|
+ dataIndex: 'apply_content',
|
|
|
search: false,
|
|
|
},
|
|
|
{
|
|
|
title: '报修时间',
|
|
|
- dataIndex: 'user_name',
|
|
|
+ dataIndex: 'created_at',
|
|
|
search: false,
|
|
|
+ valueType: 'dateTime',
|
|
|
},
|
|
|
{
|
|
|
title: '状态',
|
|
|
- dataIndex: 'phone',
|
|
|
+ dataIndex: 'status',
|
|
|
search: true,
|
|
|
+ valueEnum: {
|
|
|
+ 1: { text: '未派单' },
|
|
|
+ 2: { text: '已派单' },
|
|
|
+ 3: { text: '已完结' },
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
title: '操作',
|
|
@@ -91,7 +100,7 @@ const FixOnlineForm: React.FC = (props: any) => {
|
|
|
title: '删除记录',
|
|
|
content: '你确定删除这条记录吗?',
|
|
|
onOk: async () => {
|
|
|
- await User({ method: 'delete', id: row.id })
|
|
|
+ await FixApi({ method: 'delete', id: row.id })
|
|
|
message.success('操作成功!')
|
|
|
actionRef.current.reload()
|
|
|
}
|
|
@@ -103,6 +112,13 @@ const FixOnlineForm: React.FC = (props: any) => {
|
|
|
]
|
|
|
|
|
|
const [pic, setPic]: any = React.useState([])
|
|
|
+ const [fixClass, setFixClass] = useFixClass()
|
|
|
+ const [buildHouse, setBuildHouse]: any = useBuildingHouse()
|
|
|
+
|
|
|
+ React.useEffect(() => {
|
|
|
+ setFixClass()
|
|
|
+ setBuildHouse()
|
|
|
+ }, [])
|
|
|
|
|
|
const uploadButton = (
|
|
|
<div>
|
|
@@ -122,16 +138,18 @@ const FixOnlineForm: React.FC = (props: any) => {
|
|
|
|
|
|
const onSubmit = () => {
|
|
|
form.validateFields().then(async values => {
|
|
|
- await User({
|
|
|
- method: 'post',
|
|
|
+ await FixApi({
|
|
|
+ method: state.editId ? 'put' : 'post',
|
|
|
...values,
|
|
|
- group_id: 11,
|
|
|
- department_id: 0
|
|
|
+ apply_pic: pic.map(({ response }) => response.data),
|
|
|
+ appointment: values.appointment.valueOf(),
|
|
|
+ id: state.editId,
|
|
|
+ // garden_id: 3,
|
|
|
})
|
|
|
message.success('操作成功!')
|
|
|
form.resetFields()
|
|
|
actionRef.current?.reloadAndRest()
|
|
|
- setState(prevState => ({ ...prevState, visible: false }))
|
|
|
+ setState(prevState => ({ ...prevState, visible: false, editId: null }))
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -141,7 +159,7 @@ const FixOnlineForm: React.FC = (props: any) => {
|
|
|
headerTitle="报事报修/在线报修"
|
|
|
actionRef={actionRef}
|
|
|
rowKey="key"
|
|
|
- request={User}
|
|
|
+ request={FixApi}
|
|
|
toolBarRender={() => [
|
|
|
<Button
|
|
|
type="primary"
|
|
@@ -186,36 +204,31 @@ const FixOnlineForm: React.FC = (props: any) => {
|
|
|
wrapperCol={{ span: 15 }}
|
|
|
form={form}
|
|
|
>
|
|
|
- <Form.Item label='报修分类' name="group_id" rules={[{ required: true }]}>
|
|
|
- <Select placeholder='请选择' options={[]} />
|
|
|
+ <Form.Item label='报修分类' name="class_id" rules={[{ required: true }]}>
|
|
|
+ <Select placeholder='请选择' options={fixClass} />
|
|
|
</Form.Item>
|
|
|
- <Form.Item label='报修人' name="user_name" rules={[{ required: true }]}>
|
|
|
+ <Form.Item label='报修人' name="apply_people" rules={[{ required: true }]}>
|
|
|
<Input placeholder="请输入" />
|
|
|
</Form.Item>
|
|
|
- <Form.Item label='联系方式' name="user_name" rules={[{ required: true }]}>
|
|
|
+ <Form.Item label='联系方式' name="apply_people_phone" rules={[{ required: true }]}>
|
|
|
<Input placeholder="请输入" />
|
|
|
</Form.Item>
|
|
|
- <Form.Item label='预约时间' rules={[{ required: true }]}>
|
|
|
- <DatePicker placeholder="选择时间" format="YYYY-MM-DD" />
|
|
|
+ <Form.Item label='预约时间' name="appointment" rules={[{ required: true }]}>
|
|
|
+ <DatePicker showTime placeholder="选择时间" format="YYYY-MM-DD" />
|
|
|
</Form.Item>
|
|
|
- <Form.Item label='报修内容' name="user_name" rules={[{ required: true }]}>
|
|
|
+ <Form.Item label='报修内容' name="apply_content" rules={[{ required: true }]}>
|
|
|
<Input.TextArea placeholder="多行输入" rows={4} />
|
|
|
</Form.Item>
|
|
|
- <Form.Item label='报修图片' name="user_name" rules={[{ required: true }]}>
|
|
|
+ <Form.Item label='报修图片' name="apply_pic" rules={[{ required: true }]}>
|
|
|
<Upload
|
|
|
action="http://localhost:3000/api/v1/upload"
|
|
|
listType="picture-card"
|
|
|
fileList={pic}
|
|
|
onChange={(({ fileList }) => setPic(fileList))}
|
|
|
- >
|
|
|
- { uploadButton }
|
|
|
- </Upload>
|
|
|
+ >{ 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 label='联系地址' name="house_id" rules={[{ required: true }]}>
|
|
|
+ <Select placeholder='请选择' options={buildHouse} />
|
|
|
</Form.Item>
|
|
|
</Form>
|
|
|
</Modal>
|