edit.jsx 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import { Form, Input, Card, InputNumber, Select, message, Button } from 'antd';
  2. import { history } from 'umi';
  3. import ProCard from '@ant-design/pro-card';
  4. import { useState, useEffect } from 'react';
  5. // import { getTagList } from '@/services/tag';
  6. // import { addAttaList, gettaTouristForm, EditaddAttaList } from '@/services/AttaList'
  7. const { TextArea } = Input;
  8. const { Option } = Select;
  9. const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
  10. const goBack = () => {
  11. history.goBack();
  12. };
  13. const FormItem = Form.Item;
  14. export default (props) => {
  15. const { location } = props;
  16. const { id } = location.query;
  17. const [form] = Form.useForm();
  18. const [listForm, setListForm] = useState({});
  19. const [loading, setLoading] = useState(false);
  20. const [imageList, setImageList] = useState([]);
  21. const Submit = (data) => {
  22. const typeList = (data.typeList || []).map((x) => {
  23. return { ...x, targetId: id, targetType: 'tourist' };
  24. });
  25. setLoading(true);
  26. // if (id) {
  27. // EditaddAttaList(id, { ...listForm, ...data, imageList, typeList }).then(() => {
  28. // setLoading(false);
  29. // message.success('数据更新成功');
  30. // goBack();
  31. // })
  32. // .catch(err => {
  33. // setLoading(false);
  34. // message.error(err.message || err);
  35. // });
  36. // } else {
  37. // addAttaList({ ...data, imageList, typeList }).then((res) => {
  38. // setLoading(false);
  39. // message.success('数据保存成功');
  40. // history.replace(`/Attractions/Edit?id=${res.touristId}`)
  41. // })
  42. // .catch(err => {
  43. // setLoading(false);
  44. // message.error(err.message || err);
  45. // });
  46. // }
  47. };
  48. //地址--占位
  49. const [newLocName, setLocName] = useState('');
  50. const [newAddress, setAddress] = useState('');
  51. const selectTagList = (params) => {
  52. // return getTagList({
  53. // }).then((res) => {
  54. // }).catch((err) => {
  55. // return {
  56. // success: false,
  57. // }
  58. // })
  59. };
  60. const imageInput = (image) => {
  61. return {
  62. uid: image.imageId,
  63. url: image.url,
  64. };
  65. };
  66. const imageOutput = (image) => {
  67. return {
  68. imageId: image?.raw?.imageId,
  69. shopId: id,
  70. url: image.url,
  71. };
  72. };
  73. useEffect(() => {
  74. selectTagList();
  75. // if (id) {
  76. // gettaTouristForm(id).then((res) => {
  77. // setListForm(res)
  78. // form.setFieldsValue(res)
  79. // setImageList(res?.imageList || [])
  80. // })
  81. // }
  82. }, [id]);
  83. return (
  84. <Card>
  85. <ProCard tabs={{ type: 'card' }}>
  86. <ProCard.TabPane key={1} tab="员工编辑">
  87. <Form {...formItemLayout} onFinish={Submit} form={form}>
  88. <FormItem label="姓名" name="name" rules={[{ required: true, message: '请输入姓名' }]}>
  89. <Input placeholder="请输入姓名" style={{ width: '350px' }} />
  90. </FormItem>
  91. <FormItem
  92. label="手机号"
  93. name="phone"
  94. rules={[{ required: true, message: '请输入手机号' }]}
  95. >
  96. <Input placeholder="请输入手机号" style={{ width: '350px' }} />
  97. </FormItem>
  98. <FormItem
  99. label="所属机构"
  100. name="cooperative_id"
  101. rules={[{ required: true, message: '请选择所属机构' }]}
  102. >
  103. <Select style={{ width: '350px' }}>
  104. <Option value="6" key="6">
  105. {6}
  106. </Option>
  107. <Option value="7" key="7">
  108. {7}
  109. </Option>
  110. </Select>
  111. </FormItem>
  112. <FormItem
  113. label="身份"
  114. name="identity"
  115. rules={[{ required: true, message: '请选择身份' }]}
  116. >
  117. <Select style={{ width: '350px' }}>
  118. <Option value="6" key="6">
  119. 农机手
  120. </Option>
  121. <Option value="7" key="7">
  122. 合作社负责人
  123. </Option>
  124. </Select>
  125. </FormItem>
  126. <FormItem label=" " colon={false}>
  127. <Button type="default" onClick={() => goBack()}>
  128. 返回
  129. </Button>
  130. <Button
  131. type="primary"
  132. loading={loading}
  133. htmlType="submit"
  134. style={{ marginLeft: '4em' }}
  135. >
  136. 保存
  137. </Button>
  138. </FormItem>
  139. </Form>
  140. </ProCard.TabPane>
  141. </ProCard>
  142. </Card>
  143. );
  144. };