Commit b58802fb authored by Bill's avatar Bill

fix: 修改加工选择加工订单回显问题

parent 76efb002
import React, { useState, useCallback, useEffect } from 'react';
import React, { useState, } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons';
import { Button, Card, Select, DatePicker, Radio, Table, Space, message } from 'antd';
......@@ -222,36 +222,11 @@ const Add: React.FC<{}> = () => {
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框 行勾选回调
* @param rows
*/
const processProductSelected = () => {
console.log(productSelectRowCtl);
// const newRows = getChangeRows(productSelectRowCtl, "id");
// console.log("newRows", newRows)
formActions.setFieldValue('Tabs.tab-2.layout.someLists', productSelectRowCtl.selectRow)
}
......@@ -260,10 +235,8 @@ const Add: React.FC<{}> = () => {
* @param row
*/
const processOrderOnok = () => {
console.log(selectRowCtl);
const newRows = getChangeRows(selectRowCtl, "fullId")
console.log(newRows);
formActions.setFieldValue('Tabs.tab-2.layout.someLists', newRows)
formActions.setFieldValue('Tabs.tab-2.layout.someLists', selectRowCtl.selectRow)
}
/**
......@@ -378,7 +351,7 @@ const Add: React.FC<{}> = () => {
const primaryKey = activeSource === '加工订单' ? 'fullId' : 'id'
const newList = currentList.filter((item) => item[primaryKey] !== id);
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;
if(activeSource === '加工订单') {
selectRowCtl.setSelectedRowKeys(newSelectedKeys);
......
......@@ -92,7 +92,7 @@ const basicTab = {
],
default: 1
},
deliveryDate: {
type: 'string',
title: '交期',
......@@ -126,7 +126,7 @@ const basicTab = {
target: '*(receivefullAddress, receiveAddressID, receiveAddress,receiveUserName,receiveUserTel)',
condition: '{{$value == 1}}'
},
],
],
},
receivefullAddress: {
type: 'string',
......@@ -191,7 +191,7 @@ const basicTab = {
/**
* 通知单明细
*/
*/
const detailTab = {
'tab-2': {
type: 'object',
......@@ -223,7 +223,7 @@ const detailTab = {
},
'x-component': 'MultTable',
'x-component-props': {
rowKey: 'id',
rowKey: (record) => record.id + "_" + record.fullId,
prefix: "{{tableAddButton}}",
columns: "{{noticesDetailColumn}}"
// columns: "{{tableColumns}}",
......@@ -277,7 +277,7 @@ const otherRequired = {
'x-component-props': {
placeholder: '最长100个字符,50个汉字',
rows: 5
}
},
taxDesc: {
......@@ -381,7 +381,7 @@ const historyRecord = {
controller: {
type: 'object',
'x-component': 'Children',
'x-component-props': {
children: '{{RadioBtnGroup}}'
}
......@@ -389,7 +389,7 @@ const historyRecord = {
historyTable: {
type: 'object',
'x-component': 'Table',
'x-component-props': {
columns: historyColumn
}
......
......@@ -38,7 +38,7 @@ const EnterPrise = ({visible, cancel, ...restProps}) => {
return (
<Modal
title="选择加工商品"
title="选择加工企业"
width={704}
visible={visible}
onCancel={cancel}
......@@ -51,10 +51,10 @@ const EnterPrise = ({visible, cancel, ...restProps}) => {
effects={effects}
expressionScope={{rowSelection: selectRow}}
></SearchForm>
</Modal>
)
}
export default EnterPrise
\ No newline at end of file
export default EnterPrise
......@@ -24,11 +24,11 @@ const expandRowColumn = [
const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
// const [mainTableSelectRow, mainTableSelectRowCtl] = useRowSelectionTable({customKey: 'id'});
const [selectRow, selectRowCtl] = useRowSelectionTable({
customKey: 'fullId',
const [selectRow, selectRowCtl] = useRowSelectionTable({
customKey: 'fullId',
extendsSelection: {
getCheckboxProps: record => ({
disabled: record.purchaseCount - (record.processNum || 0) <= 0,
disabled: record.purchaseCount - (record.processNum || 0) <= 0,
}),
}
});
......@@ -36,7 +36,7 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
const fetchData = useCallback(async (params: any) => {
const {orderTime, ...rest} = params
const {st, et} = timeRange(orderTime);
let postData = {
startCreateTime: st,
endCreateTime: et,
......@@ -44,8 +44,8 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
}
let res = await PublicApi.getOrderProcessingOrderList(postData);
return res;
}, [])
}, [])
const expandable = {
expandedRowRender: record => {
const renderData = record.productDateilss && record.productDateilss.map(
......@@ -70,20 +70,21 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
}
)
return (
<Table
columns={expandRowColumn}
rowKey={(row) => row.fullId}
<Table
columns={expandRowColumn}
rowKey={(row) => row.fullId}
// rowSelection={selectRow}
rowSelection={rowSelection}
dataSource={renderData}
pagination={false}
rowSelection={rowSelection}
dataSource={renderData}
pagination={false}
/>
)
},
// defaultExpandAllRows: true
}
}
// console.log("rowSelection",rowSelection);
const handleSubmit = () => {
// console.log(selectRowCtl, mainTableSelectRowCtl);
// console.log(selectRowCtl)
......@@ -129,4 +130,4 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
}
export default ProcessProducts
\ No newline at end of file
export default ProcessProducts
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