123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- import { Form, Input, Card, InputNumber, Select, message, Button } from 'antd';
- import { history } from 'umi';
- import ProCard from '@ant-design/pro-card';
- import { useState, useEffect } from 'react';
- // import { getTagList } from '@/services/tag';
- // import { addAttaList, gettaTouristForm, EditaddAttaList } from '@/services/AttaList'
-
- const { TextArea } = Input;
- const { Option } = Select;
- const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
-
- const goBack = () => {
- history.goBack();
- };
- const FormItem = Form.Item;
- export default (props) => {
- const { location } = props;
- const { id } = location.query;
- const [form] = Form.useForm();
- const [listForm, setListForm] = useState({});
- const [loading, setLoading] = useState(false);
- const [imageList, setImageList] = useState([]);
-
- const Submit = (data) => {
- const typeList = (data.typeList || []).map((x) => {
- return { ...x, targetId: id, targetType: 'tourist' };
- });
- setLoading(true);
-
- // if (id) {
- // EditaddAttaList(id, { ...listForm, ...data, imageList, typeList }).then(() => {
- // setLoading(false);
- // message.success('数据更新成功');
- // goBack();
- // })
- // .catch(err => {
- // setLoading(false);
- // message.error(err.message || err);
- // });
- // } else {
- // addAttaList({ ...data, imageList, typeList }).then((res) => {
- // setLoading(false);
- // message.success('数据保存成功');
- // history.replace(`/Attractions/Edit?id=${res.touristId}`)
- // })
- // .catch(err => {
- // setLoading(false);
- // message.error(err.message || err);
- // });
- // }
- };
-
- //地址--占位
- const [newLocName, setLocName] = useState('');
- const [newAddress, setAddress] = useState('');
-
- const selectTagList = (params) => {
- // return getTagList({
- // }).then((res) => {
- // }).catch((err) => {
- // return {
- // success: false,
- // }
- // })
- };
-
- const imageInput = (image) => {
- return {
- uid: image.imageId,
- url: image.url,
- };
- };
-
- const imageOutput = (image) => {
- return {
- imageId: image?.raw?.imageId,
- shopId: id,
- url: image.url,
- };
- };
- useEffect(() => {
- selectTagList();
- // if (id) {
- // gettaTouristForm(id).then((res) => {
- // setListForm(res)
- // form.setFieldsValue(res)
- // setImageList(res?.imageList || [])
- // })
- // }
- }, [id]);
-
- return (
- <Card>
- <ProCard tabs={{ type: 'card' }}>
- <ProCard.TabPane key={1} tab="员工编辑">
- <Form {...formItemLayout} onFinish={Submit} form={form}>
- <FormItem label="姓名" name="name" rules={[{ required: true, message: '请输入姓名' }]}>
- <Input placeholder="请输入姓名" style={{ width: '350px' }} />
- </FormItem>
- <FormItem
- label="手机号"
- name="phone"
- rules={[{ required: true, message: '请输入手机号' }]}
- >
- <Input placeholder="请输入手机号" style={{ width: '350px' }} />
- </FormItem>
- <FormItem
- label="所属机构"
- name="cooperative_id"
- rules={[{ required: true, message: '请选择所属机构' }]}
- >
- <Select style={{ width: '350px' }}>
- <Option value="6" key="6">
- {6}
- </Option>
- <Option value="7" key="7">
- {7}
- </Option>
- </Select>
- </FormItem>
- <FormItem
- label="身份"
- name="identity"
- rules={[{ required: true, message: '请选择身份' }]}
- >
- <Select style={{ width: '350px' }}>
- <Option value="6" key="6">
- 农机手
- </Option>
- <Option value="7" key="7">
- 合作社负责人
- </Option>
- </Select>
- </FormItem>
- <FormItem label=" " colon={false}>
- <Button type="default" onClick={() => goBack()}>
- 返回
- </Button>
- <Button
- type="primary"
- loading={loading}
- htmlType="submit"
- style={{ marginLeft: '4em' }}
- >
- 保存
- </Button>
- </FormItem>
- </Form>
- </ProCard.TabPane>
- </ProCard>
- </Card>
- );
- };
|