Commit 25f5b613 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫
parents 7f5c7d16 b58802fb
import React, { useState, useCallback, useEffect } from 'react'; import React, { useState, } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons'; import { SaveOutlined } from '@ant-design/icons';
import { Button, Card, Select, DatePicker, Radio, Table, Space, message } from 'antd'; import { Button, Card, Select, DatePicker, Radio, Table, Space, message } from 'antd';
...@@ -222,36 +222,11 @@ const Add: React.FC<{}> = () => { ...@@ -222,36 +222,11 @@ const Add: React.FC<{}> = () => {
formActions.setFieldValue('Tabs.tab-1.layout.processRoleId', roleId); formActions.setFieldValue('Tabs.tab-1.layout.processRoleId', roleId);
} }
const getChangeRows = (rows, primaryKey: string) => {
const {selectedRowKeys, selectRow} = rows;
const currentList = formActions.getFieldValue('Tabs.tab-2.layout.someLists');
// 首先去除掉没有在selectedRowkeys 的那些数据
const inKeys = [];
const hasRemovedList = currentList.filter(
(item) => {
const flag = selectedRowKeys.includes(item[primaryKey])
if(flag) {
inKeys.push(item[primaryKey]);
}
return flag
}
);
// 找到没有在数组中的key,即新增加的key
const newAddKeys = selectedRowKeys.filter((item) => { return !inKeys.includes(item)});
const appendRow = selectRow.filter((item) => newAddKeys.includes(item[primaryKey]));
const newRows = hasRemovedList.concat(appendRow); // 最新的数组
return newRows
}
/** /**
* 加工商品Modal框 行勾选回调 * 加工商品Modal框 行勾选回调
* @param rows * @param rows
*/ */
const processProductSelected = () => { const processProductSelected = () => {
console.log(productSelectRowCtl);
// const newRows = getChangeRows(productSelectRowCtl, "id");
// console.log("newRows", newRows)
formActions.setFieldValue('Tabs.tab-2.layout.someLists', productSelectRowCtl.selectRow) formActions.setFieldValue('Tabs.tab-2.layout.someLists', productSelectRowCtl.selectRow)
} }
...@@ -260,10 +235,8 @@ const Add: React.FC<{}> = () => { ...@@ -260,10 +235,8 @@ const Add: React.FC<{}> = () => {
* @param row * @param row
*/ */
const processOrderOnok = () => { const processOrderOnok = () => {
console.log(selectRowCtl); formActions.setFieldValue('Tabs.tab-2.layout.someLists', selectRowCtl.selectRow)
const newRows = getChangeRows(selectRowCtl, "fullId")
console.log(newRows);
formActions.setFieldValue('Tabs.tab-2.layout.someLists', newRows)
} }
/** /**
...@@ -378,7 +351,7 @@ const Add: React.FC<{}> = () => { ...@@ -378,7 +351,7 @@ const Add: React.FC<{}> = () => {
const primaryKey = activeSource === '加工订单' ? 'fullId' : 'id' const primaryKey = activeSource === '加工订单' ? 'fullId' : 'id'
const newList = currentList.filter((item) => item[primaryKey] !== id); const newList = currentList.filter((item) => item[primaryKey] !== id);
formActions.setFieldValue('Tabs.tab-2.layout.someLists', newList) formActions.setFieldValue('Tabs.tab-2.layout.someLists', newList)
const newSelectedKeys = newList.map((item) => item.id); const newSelectedKeys = newList.map((item) => item[primaryKey]);
const newSelectedRows = newList; const newSelectedRows = newList;
if(activeSource === '加工订单') { if(activeSource === '加工订单') {
selectRowCtl.setSelectedRowKeys(newSelectedKeys); selectRowCtl.setSelectedRowKeys(newSelectedKeys);
......
...@@ -223,7 +223,7 @@ const detailTab = { ...@@ -223,7 +223,7 @@ const detailTab = {
}, },
'x-component': 'MultTable', 'x-component': 'MultTable',
'x-component-props': { 'x-component-props': {
rowKey: 'id', rowKey: (record) => record.id + "_" + record.fullId,
prefix: "{{tableAddButton}}", prefix: "{{tableAddButton}}",
columns: "{{noticesDetailColumn}}" columns: "{{noticesDetailColumn}}"
// columns: "{{tableColumns}}", // columns: "{{tableColumns}}",
......
...@@ -38,7 +38,7 @@ const EnterPrise = ({visible, cancel, ...restProps}) => { ...@@ -38,7 +38,7 @@ const EnterPrise = ({visible, cancel, ...restProps}) => {
return ( return (
<Modal <Modal
title="选择加工商品" title="选择加工企业"
width={704} width={704}
visible={visible} visible={visible}
onCancel={cancel} onCancel={cancel}
......
...@@ -83,6 +83,7 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => { ...@@ -83,6 +83,7 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
}, },
// defaultExpandAllRows: true // defaultExpandAllRows: true
} }
// console.log("rowSelection",rowSelection);
const handleSubmit = () => { const handleSubmit = () => {
// console.log(selectRowCtl, mainTableSelectRowCtl); // console.log(selectRowCtl, mainTableSelectRowCtl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment