|
@@ -1,15 +1,17 @@
|
|
|
-import { Button, Col, Form, Input, Modal, Row, Select } from 'antd';
|
|
|
+import { Button, Col, Form, Input, Modal, Row, Select, message } from 'antd';
|
|
|
import styles from './index.less';
|
|
|
-import { useEffect, useState } from 'react';
|
|
|
+import { useEffect, useMemo, useState } from 'react';
|
|
|
import { DeleteOutlined } from '@ant-design/icons';
|
|
|
+import { approvalLog } from '@/services/record';
|
|
|
|
|
|
const WriteRecordModal = ({ visible, user, projects, loading = false, onOk, onCancel }) => {
|
|
|
const [form] = Form.useForm();
|
|
|
- const defaultData = { projectName: '', tip: '', doc: '' };
|
|
|
+ const defaultData = { code_id: '', title: '', content: '' };
|
|
|
const [list, setList] = useState([defaultData]);
|
|
|
- console.log(user);
|
|
|
+ console.log(user, list);
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
- if (!visible) setList([]);
|
|
|
+ if (!visible) setList([defaultData]);
|
|
|
}, [visible]);
|
|
|
|
|
|
const handleAddClick = () => {
|
|
@@ -28,8 +30,14 @@ const WriteRecordModal = ({ visible, user, projects, loading = false, onOk, onCa
|
|
|
newList.splice(idx, 1);
|
|
|
setList(newList);
|
|
|
};
|
|
|
+ console.log('00000000000---------', list);
|
|
|
+
|
|
|
+ const handleOk = () => {
|
|
|
+ onOk(list);
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
- <Modal title="写日志" open={visible} width={800} onOk={onOk} onCancel={onCancel}>
|
|
|
+ <Modal title="写日志" open={visible} width={800} onOk={handleOk} onCancel={onCancel}>
|
|
|
<Form
|
|
|
labelCol={{ span: 4 }}
|
|
|
wrapperCol={{ span: 18 }}
|
|
@@ -53,7 +61,7 @@ const WriteRecordModal = ({ visible, user, projects, loading = false, onOk, onCa
|
|
|
>
|
|
|
{list.map((item, idx) => (
|
|
|
<RenderItem
|
|
|
- key={`${item.projectName}_${idx}`}
|
|
|
+ key={`${item.code_id}_${idx}`}
|
|
|
idx={idx}
|
|
|
projects={projects}
|
|
|
data={item}
|
|
@@ -77,6 +85,9 @@ export default WriteRecordModal;
|
|
|
|
|
|
const RenderItem = ({ idx, data, projects, onChange, onDelete }) => {
|
|
|
const [form] = Form.useForm();
|
|
|
+ const projectName = useMemo(() => {
|
|
|
+ return projects.find(item => item.ID == data.code_id)?.Name || '';
|
|
|
+ }, [data.code_id]);
|
|
|
return (
|
|
|
<div className={styles.itemContent}>
|
|
|
<Form labelCol={{ span: 7 }} wrapperCol={{ span: 17 }} width="100%" form={form}>
|
|
@@ -85,7 +96,7 @@ const RenderItem = ({ idx, data, projects, onChange, onDelete }) => {
|
|
|
<Form.Item
|
|
|
label="项目名称"
|
|
|
name="projectName"
|
|
|
- initialValue={data.projectName}
|
|
|
+ initialValue={projectName}
|
|
|
rules={[{ required: true, message: '请选择项目' }]}
|
|
|
>
|
|
|
<Select
|
|
@@ -93,17 +104,21 @@ const RenderItem = ({ idx, data, projects, onChange, onDelete }) => {
|
|
|
options={projects?.map(item => {
|
|
|
return { label: item.Name, value: item.ID };
|
|
|
})}
|
|
|
+ onChange={id => onChange(idx, { ...data, code_id: id })}
|
|
|
/>
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
<Col span={11} offset={1}>
|
|
|
<Form.Item
|
|
|
label="日志概述"
|
|
|
- name="tip"
|
|
|
- initialValue={data.tip}
|
|
|
+ name="title"
|
|
|
+ initialValue={data.title}
|
|
|
rules={[{ required: true, message: '请选择成员' }]}
|
|
|
>
|
|
|
- <Input />
|
|
|
+ <Input
|
|
|
+ value={data.title}
|
|
|
+ onChange={e => onChange(idx, { ...data, title: e.target.value })}
|
|
|
+ />
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
</Row>
|
|
@@ -112,10 +127,14 @@ const RenderItem = ({ idx, data, projects, onChange, onDelete }) => {
|
|
|
labelCol={{ span: 3 }}
|
|
|
wrapperCol={{ span: 21 }}
|
|
|
label="日志详情"
|
|
|
- initialValue={data.doc}
|
|
|
- name="doc"
|
|
|
+ initialValue={data.content}
|
|
|
+ name="content"
|
|
|
>
|
|
|
- <Input.TextArea style={{ height: 120 }} />
|
|
|
+ <Input.TextArea
|
|
|
+ style={{ height: 120 }}
|
|
|
+ value={data.content}
|
|
|
+ onChange={e => onChange(idx, { ...data, content: e.target.value })}
|
|
|
+ />
|
|
|
</Form.Item>
|
|
|
</Form>
|
|
|
<DeleteOutlined className={styles.delIcon} onClick={idx => onDelete(idx)} />
|