合并代码
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Modal, Form, Select, Button, Tree, message, DatePicker, Radio, Upload, Input } from 'antd';
|
||||
//
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import type { UploadFile } from 'antd/es/upload/interface';
|
||||
//组件
|
||||
@ -82,7 +81,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
? checkedKeysValue
|
||||
: checkedKeysValue.checked;
|
||||
|
||||
// 只取叶子节点 key
|
||||
// 只取叶子节点 key
|
||||
const leafKeys = findLeafKeys(convertTreeData(categoriesTreeData));
|
||||
const onlyLeafChecked = keys.filter(key => leafKeys.includes(String(key)));
|
||||
|
||||
@ -115,7 +114,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
try {
|
||||
// 1. 调用你自己写的上传接口
|
||||
const res = await uploadFile(file);
|
||||
|
||||
|
||||
// 2. 可根据后端返回结构,给 fileList 项增加 url 或其他字段
|
||||
const uploadedFile: UploadFile = {
|
||||
...file,
|
||||
@ -144,12 +143,12 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
accessType: string;
|
||||
accessWorkName: string;
|
||||
deptId: string;
|
||||
};
|
||||
categoryIds: string[];
|
||||
supplierIds: string[];
|
||||
coscoAccessUserls: { userId: string; deptId: string; isLeader: number }[];
|
||||
coscoAccessItems: { itemName: string; reviewBy: string[] }[];
|
||||
coscoAccessWorkAttachments: any;
|
||||
};
|
||||
categoryIds: string[];
|
||||
supplierIds: string[];
|
||||
coscoAccessUserls: { userId: string; deptId: string; isLeader: number }[];
|
||||
coscoAccessItems: { itemName: string; reviewBy: string[] }[];
|
||||
coscoAccessWorkAttachments: any;
|
||||
} = {
|
||||
coscoAccessWork: {
|
||||
startTime: '',
|
||||
@ -174,12 +173,9 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
//品类选择
|
||||
finalPayload.categoryIds = values.categoryIds;
|
||||
//选择供应商
|
||||
if(values.supplier.length != 0) {
|
||||
values.supplier.forEach((item: { id: string }) => {
|
||||
finalPayload.supplierIds.push(item.id)
|
||||
})
|
||||
}
|
||||
|
||||
values.supplier.forEach((item: { id: string }) => {
|
||||
finalPayload.supplierIds.push(item.id)
|
||||
})
|
||||
if (values.accessType === 'online') {
|
||||
// 评审时间
|
||||
if (values.rangePicker && values.rangePicker.length === 2) {
|
||||
@ -188,8 +184,8 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
finalPayload.coscoAccessWork.endTime = end.format('YYYY-MM-DD HH:mm');
|
||||
}
|
||||
//选择评审人员
|
||||
finalPayload.coscoAccessUserls = values.reviewers.selected.map((item:{ userId:string, deptId:string,isLeader:number }) => {
|
||||
return { userId: item.userId, deptId: item.deptId, isLeader: item.isLeader }
|
||||
finalPayload.coscoAccessUserls = values.reviewers.selected.map((item: { userId: string, deptId: string, isLeader: number }) => {
|
||||
return { userId: item.userId, deptId: item.deptId, isLeader: item.isLeader }
|
||||
});
|
||||
//评审分工
|
||||
values.division.forEach((item: any) => {
|
||||
@ -207,7 +203,6 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
finalPayload.coscoAccessWorkAttachments = values.supplierCompliance[0].response
|
||||
}
|
||||
|
||||
console.log( finalPayload, values);
|
||||
const res = await add(finalPayload);
|
||||
if (res?.success) {
|
||||
message.success('创建成功');
|
||||
@ -255,6 +250,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
onFinish={onFinish}
|
||||
labelCol={{ span: 5 }}
|
||||
wrapperCol={{ span: 19 }}
|
||||
initialValues={{ accessType: 'online' }}
|
||||
>
|
||||
<Form.Item
|
||||
label="标题名称"
|
||||
@ -392,11 +388,32 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
<Form.Item
|
||||
label="评审分工"
|
||||
name="division"
|
||||
rules={[{ required: true, message: '请设置评审分工' }]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '请设置评审分工',
|
||||
},
|
||||
{
|
||||
validator: (_, value) => {
|
||||
if (!value || !Array.isArray(value) || value.length === 0) {
|
||||
return Promise.reject(new Error('请设置评审分工'));
|
||||
}
|
||||
// 判断所有分工的checkbox数量总和是否≥1
|
||||
let checkedCount = 0;
|
||||
for (const row of value) {
|
||||
checkedCount += Object.values(row.reviewerChecks || {}).filter(Boolean).length;
|
||||
}
|
||||
if (checkedCount < 1) {
|
||||
return Promise.reject(new Error('至少分配一名评审人'));
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
]}
|
||||
>
|
||||
<Button onClick={() => {
|
||||
if (selectedReviewers.selected.length != 0) {
|
||||
setDivisionModalVisible(true)
|
||||
if (selectedReviewers.selected.length !== 0) {
|
||||
setDivisionModalVisible(true);
|
||||
} else {
|
||||
message.warning('请选择评审人员');
|
||||
}
|
||||
@ -439,9 +456,9 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
<ReviewerSelector
|
||||
visible={reviewerModalVisible}
|
||||
onCancel={() => setReviewerModalVisible(false)}
|
||||
selected={selectedReviewers.selected.map(i => i.userId)}
|
||||
leader={selectedReviewers.leader?.userId}
|
||||
onSelect={(result) => {
|
||||
console.log(result,'result');
|
||||
|
||||
setSelectedReviewers(result);
|
||||
form.setFieldsValue({ reviewers: result });
|
||||
setReviewerModalVisible(false);
|
||||
|
Reference in New Issue
Block a user