山西督察-superintend-distribute-web react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.9 KiB

  1. import React, { useEffect, useState } from 'react';
  2. import { Input, Radio, Form, Button, Spin, Modal, Space } from 'antd';
  3. import { connect } from 'umi';
  4. import { CCQK } from '@/utils/constants';
  5. /**
  6. *
  7. *
  8. *
  9. */
  10. const { Item } = Form;
  11. const { TextArea } = Input;
  12. const layout = {
  13. labelCol: { span: 4 },
  14. wrapperCol: { span: 18 },
  15. };
  16. const tailLayout = {
  17. wrapperCol: { offset: 10, span: 10 },
  18. };
  19. const CC = (props) => {
  20. const { id, sysToken, loading } = props;
  21. const [form] = Form.useForm();
  22. const [visible, setVisible] = useState(false);
  23. useEffect(() => {
  24. return () => {
  25. // cleanup
  26. };
  27. }, []);
  28. const onClose = () => {
  29. form.resetFields();
  30. setVisible(false);
  31. }
  32. const onFinish = (values) => {
  33. const params = { ...values, pfId: id };
  34. props.fetchSaveCC({ params, sysToken }).then((data) => {
  35. if (data) {
  36. onClose();
  37. props.hideModal(true);
  38. }
  39. });
  40. };
  41. return (
  42. <div title="">
  43. <Spin spinning={loading}>
  44. <div style={{textAlign: 'right', marginBottom: 20 }}><Button type='primary' onClick={() => setVisible(true)}>抽查</Button></div>
  45. <Modal
  46. title='抽查情况'
  47. onCancel={onClose}
  48. visible={visible}
  49. footer={null}
  50. width={640}
  51. maskClosable={false}
  52. >
  53. <Form onFinish={onFinish} {...layout}>
  54. {/* <Item label='' name='ccSj' rules={[{ required: true, message: '!' }]}>
  55. <DatePicker format='YYYY-MM-DD HH:mm:ss' />
  56. </Item> */}
  57. <Item label='抽查结果' name='ccjg' rules={[{ required: true, message: '请选择抽查结果!' }]}>
  58. <Radio.Group>
  59. {Object.keys(CCQK).map(key => {
  60. if (key !== 'WCC') { // 抽查不显示‘未抽查’选项
  61. return <Radio key={key} value={CCQK[key].value}>{CCQK[key].name}</Radio>
  62. }
  63. })}
  64. </Radio.Group>
  65. </Item>
  66. <Item label='备注' name='bzxx' rules={[{ max: 200, message: '最多能输入200字!' }]}>
  67. <TextArea />
  68. </Item>
  69. <Form.Item {...tailLayout}>
  70. <Space>
  71. <Button type="default" onClick={onClose}>
  72. 取消
  73. </Button>
  74. <Button type="primary" htmlType="submit">
  75. 确认
  76. </Button>
  77. </Space>
  78. </Form.Item>
  79. </Form>
  80. </Modal>
  81. </Spin>
  82. </div>
  83. );
  84. };
  85. const mapStateToProps = ({ doing, global, loading }) => ({
  86. doing,
  87. global,
  88. loading: loading.effects['doing/fetchSaveCC'] || false,
  89. });
  90. const mapDispatchToProps = (dispatch) => ({
  91. fetchSaveCC(params) {
  92. return dispatch({ type: 'doing/fetchSaveCC', payload: params });
  93. },
  94. });
  95. export default connect(mapStateToProps, mapDispatchToProps)(CC);