知与行后台管理端

addChannel.jsx 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React, { useState, useEffect } from 'react';
  2. import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Form, Alert } from 'antd';
  3. import { FormattedMessage } from 'umi-plugin-react/locale';
  4. import channels from './channelList.less';
  5. import router from 'umi/router';
  6. import apis from '../../services/apis';
  7. import request from '../../utils/request'
  8. const { TextArea } = Input;
  9. const { Option } = Select;
  10. const header = props => {
  11. // eslint-disable-next-line react-hooks/rules-of-hooks
  12. const [data, setData] = useState({ channelNmae: [], result: [] })
  13. // eslint-disable-next-line react-hooks/rules-of-hooks
  14. // useEffect(() => {
  15. // addChannel({ pageNum: 1, pageSize: 10 })
  16. // }, [])
  17. function addChannel(params) {
  18. request({ ...apis.channelList.addChannel, data: { ...params } }).then((data) => {
  19. setData(data)
  20. router.go(-1)
  21. }).catch((err) => {
  22. console.log(err)
  23. message.info(err.msg || err.message)
  24. })
  25. }
  26. function handleSubmit (e) {
  27. e.preventDefault();
  28. props.form.validateFields((err, values) => {
  29. if (!err) {
  30. console.log('Received values of form: ', values);
  31. // eslint-disable-next-line max-len
  32. addChannel({ channelName: values.channelName,
  33. channelContact: values.channelContact,
  34. contactTel: values.contactTel,
  35. explain: values.explain })
  36. }
  37. });
  38. }
  39. const { getFieldDecorator } = props.form;
  40. return (
  41. <>
  42. <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
  43. <Form.Item label="渠道名称">
  44. {getFieldDecorator('channelName', {
  45. rules: [{ required: true, message: '请输入渠道名称' }],
  46. })(<Input className={channels.inpuit} />)}
  47. </Form.Item>
  48. <Form.Item label="联系人">
  49. {getFieldDecorator('channelContact', {
  50. rules: [{ required: true, message: ' 请输入联系人' }],
  51. })(<Input className={channels.inpuit} />)}
  52. </Form.Item>
  53. <Form.Item label="联系电话">
  54. {getFieldDecorator('contactTel', {
  55. rules: [{ required: true, message: '请输入联系电话' }],
  56. })(<Input className={channels.inpuit} />)}
  57. </Form.Item>
  58. <Form.Item label="说明描述">
  59. {getFieldDecorator('explain', {
  60. })(<TextArea className={channels.inpuitTxt} rows={8} />)}
  61. </Form.Item>
  62. <Form.Item wrapperCol={{ span: 15, offset: 7 }}>
  63. <Button type="primary" htmlType="submit">
  64. 保存
  65. </Button>
  66. <Button className={channels.formButton} onClick={() => router.go(-1)} type="primary" htmlType="submit">
  67. 取消
  68. </Button>
  69. </Form.Item>
  70. </Form>
  71. </>
  72. )
  73. }
  74. const WrappedNormalLoginForm = Form.create({ name: 'header' })(header);
  75. export default WrappedNormalLoginForm