杨磊
2025-07-25 03177e1d421c090185dc3a5f57a9d3704334d94e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import {
  Button,
  Col,
  DatePicker,
  Divider,
  Form,
  Input,
  Modal,
  Row,
  Select,
} from "antd";
import React, { useEffect, useState } from "react";
 
interface ApplyProps {
  visible: boolean;
  onCancel?: () => void;
  setFormData: (data: any) => void;
  applyType: string;
  title: string;
  formItems: any[];
}
 
const Apply: React.FC<ApplyProps> = (props) => {
  const { visible, setFormDat, onCancel, applyType, title, formItems } = props;
 
  const [staffVisible, setStaffVisible] = useState(false);
 
  const onFinish = (values: any) => {
    console.log(values);
    // setFormDat(values);
  };
 
  // 打开员工列表
  const onStaffVisible = () => {
    setStaffVisible(true);
  };
 
  // 设置选中员工
  const onSetStaff = (val: any) => {
    console.log(val);
  };
 
  useEffect(() => {
    if (visible) {
      setStaffVisible(false);
    }
  }, [visible]);
 
  return (
    <Modal
      width={910}
      title={title + "申请"}
      open={visible}
      onCancel={onCancel}
      footer={null}
      className="ModelForm"
    >
      <Form
        name="basic"
        initialValues={{ remember: true }}
        style={{ paddingTop: 20 }}
        onFinish={onFinish}
        autoComplete="off"
      >
        <Row>
          {formItems?.length &&
            formItems.map((item, index) => {
              if (item.type === "input") {
                return (
                  <Col span={item.width > 300 ? 24 : 12} key={index}>
                    <Form.Item
                      labelCol={{ span: item.labelCol }}
                      label={item.label}
                      name={item.name}
                      rules={item.rules}
                    >
                      <Input style={{ width: item.width }} />
                    </Form.Item>
                  </Col>
                );
              } else if (item.type === "select") {
                return (
                  <Col span={12} key={index}>
                    <Form.Item
                      labelCol={{ span: item.labelCol }}
                      label={item.label}
                      name={item.name}
                      rules={item.rules}
                    >
                      <Select
                        options={item?.options}
                        style={{ width: item.width }}
                      />
                    </Form.Item>
                  </Col>
                );
              } else if (item.type === "textArea") {
                return (
                  <Col span={24} key={index}>
                    <Form.Item
                      labelCol={{ span: item.labelCol }}
                      label={item.label}
                      name={item.name}
                      rules={item.rules}
                    >
                      <Input.TextArea
                        style={{ width: item.width }}
                        showCount
                        maxLength={item?.maxLength || 100}
                      />
                    </Form.Item>
                  </Col>
                );
              } else if (item.type === "divider") {
                return (
                  <Col span={24} key={index}>
                    <Divider orientation="left" style={{ marginBottom: 20 }}>
                      {item.label}
                    </Divider>
                  </Col>
                );
              } else if (item.type === "date") {
                return (
                  <Col span={12} key={index}>
                    <Form.Item
                      labelCol={{ span: item.labelCol }}
                      label={item.label}
                      name={item.name}
                      rules={item.rules}
                    >
                      <DatePicker style={{ width: item.width }} />
                    </Form.Item>
                  </Col>
                );
              } else {
                return null;
              }
            })}
        </Row>
        <Form.Item label={null}>
          <div className="functionBtn">
            <Button type="primary" htmlType="submit">
              提交
            </Button>
            <Button onClick={onCancel}>关闭</Button>
          </div>
        </Form.Item>
      </Form>
    </Modal>
  );
};
 
export default Apply;