|
@@ -12,13 +12,14 @@ import {
|
|
queryLeader,
|
|
queryLeader,
|
|
} from '@/services/boom';
|
|
} from '@/services/boom';
|
|
import { useParams, useRequest, useNavigate } from 'umi';
|
|
import { useParams, useRequest, useNavigate } from 'umi';
|
|
|
|
+import table from '../Table';
|
|
|
|
|
|
const OaDetail = () => {
|
|
const OaDetail = () => {
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
|
|
|
|
const [approvalProcess, setApprovalProcess] = useState([]);
|
|
const [approvalProcess, setApprovalProcess] = useState([]);
|
|
const [auditCheck, setAuditCheck] = useState([]);
|
|
const [auditCheck, setAuditCheck] = useState([]);
|
|
- const [tableData, setTableData] = useState({});
|
|
|
|
|
|
+ const [tableData, setTableData] = useState([]);
|
|
|
|
|
|
const { oaId } = useParams();
|
|
const { oaId } = useParams();
|
|
const formValueRef = useRef({
|
|
const formValueRef = useRef({
|
|
@@ -94,48 +95,77 @@ const OaDetail = () => {
|
|
let ids = id.split(';');
|
|
let ids = id.split(';');
|
|
let [rowIndex, colIndex] = ids[0].split(',').map((item) => Number(item));
|
|
let [rowIndex, colIndex] = ids[0].split(',').map((item) => Number(item));
|
|
let [columnID, tableID] = ids[1].split('>');
|
|
let [columnID, tableID] = ids[1].split('>');
|
|
- let cell = { [columnID]: value + '|' + label };
|
|
|
|
- let rows = [];
|
|
|
|
- rows[rowIndex] = cell;
|
|
|
|
- let table = { [tableID]: rows };
|
|
|
|
- if (tableData) {
|
|
|
|
- if (tableData[tableID]) {
|
|
|
|
- if (tableData[tableID][rowIndex]) {
|
|
|
|
- tableData[tableID][rowIndex][columnID] = value + '|' + label;
|
|
|
|
- } else {
|
|
|
|
- tableData[tableID][rowIndex] = cell;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- tableData[tableID] = rows;
|
|
|
|
- }
|
|
|
|
- setTableData(tableData);
|
|
|
|
- } else {
|
|
|
|
- setTableData(table);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ let [columnLabel, tableLabel] = label.split('>');
|
|
|
|
|
|
- const convertTableData = () => {
|
|
|
|
- let result = [];
|
|
|
|
- for (const tableKey in tableData) {
|
|
|
|
- if (Object.hasOwn(tableData, tableKey)) {
|
|
|
|
- for (const rows of tableData[tableKey]) {
|
|
|
|
- if (rows) {
|
|
|
|
- for (const rowKey in rows) {
|
|
|
|
- if (Object.hasOwn(rows, rowKey)) {
|
|
|
|
- let [value, label] = rows[rowKey].split('|');
|
|
|
|
- result.push({
|
|
|
|
- id: tableKey + '<' + rowKey,
|
|
|
|
- name: label,
|
|
|
|
- type: rowKey.split('_')[0],
|
|
|
|
- value: [value],
|
|
|
|
- });
|
|
|
|
|
|
+ const cell = {
|
|
|
|
+ name: columnLabel,
|
|
|
|
+ id: columnID,
|
|
|
|
+ type: columnID.split('_')[0],
|
|
|
|
+ value: [value],
|
|
|
|
+ };
|
|
|
|
+ // 组装可能用到的数据
|
|
|
|
+ const cols = [];
|
|
|
|
+ cols[colIndex] = cell;
|
|
|
|
+ const rows = [];
|
|
|
|
+ rows[rowIndex] = cols;
|
|
|
|
+ if (tableData.length > 0) {
|
|
|
|
+ let table = tableData.find((item) => item.id === tableID);
|
|
|
|
+ if (table) {
|
|
|
|
+ const oldRows = table.value;
|
|
|
|
+ if (oldRows) {
|
|
|
|
+ let odlCols = oldRows[rowIndex];
|
|
|
|
+ if (odlCols) {
|
|
|
|
+ table.value[rowIndex][colIndex] = cell;
|
|
|
|
+ const newTableData = tableData.map((item) => {
|
|
|
|
+ if (item.id === table.id) {
|
|
|
|
+ return table;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ return item;
|
|
|
|
+ });
|
|
|
|
+ setTableData(newTableData);
|
|
|
|
+ } else {
|
|
|
|
+ table.value[rowIndex] = cols;
|
|
|
|
+ const newTableData = tableData.map((item) => {
|
|
|
|
+ if (item.id === table.id) {
|
|
|
|
+ return table;
|
|
|
|
+ }
|
|
|
|
+ return item;
|
|
|
|
+ });
|
|
|
|
+ setTableData(newTableData);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ table.value = rows;
|
|
|
|
+ const newTableData = tableData.map((item) => {
|
|
|
|
+ if (item.id === table.id) {
|
|
|
|
+ return table;
|
|
|
|
+ }
|
|
|
|
+ return item;
|
|
|
|
+ });
|
|
|
|
+ setTableData(newTableData);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ const newTableData = [
|
|
|
|
+ ...tableData,
|
|
|
|
+ {
|
|
|
|
+ name: tableLabel,
|
|
|
|
+ id: tableID,
|
|
|
|
+ type: tableID.split('_')[0],
|
|
|
|
+ value: rows,
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
|
|
+ setTableData(newTableData);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ const newTableData = [
|
|
|
|
+ {
|
|
|
|
+ name: tableLabel,
|
|
|
|
+ id: tableID,
|
|
|
|
+ type: tableID.split('_')[0],
|
|
|
|
+ value: rows,
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
|
|
+ setTableData(newTableData);
|
|
}
|
|
}
|
|
- return result;
|
|
|
|
};
|
|
};
|
|
|
|
|
|
const submit = async () => {
|
|
const submit = async () => {
|
|
@@ -163,7 +193,15 @@ const OaDetail = () => {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- formData = formData.concat(...convertTableData());
|
|
|
|
|
|
+ // 根据表格在原来的form中的顺序插入
|
|
|
|
+ const tableIndex = tableData.map((table) => {
|
|
|
|
+ return data.formData.findIndex((item) => item.props.id === table.id);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 按保存的顺序把表格再插入进去
|
|
|
|
+ tableIndex.forEach((item, index) => {
|
|
|
|
+ formData.splice(item, 0, tableData[index]);
|
|
|
|
+ });
|
|
|
|
|
|
createRun({
|
|
createRun({
|
|
flow_id: Number(oaId),
|
|
flow_id: Number(oaId),
|