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);
......
...@@ -92,7 +92,7 @@ const basicTab = { ...@@ -92,7 +92,7 @@ const basicTab = {
], ],
default: 1 default: 1
}, },
deliveryDate: { deliveryDate: {
type: 'string', type: 'string',
title: '交期', title: '交期',
...@@ -126,7 +126,7 @@ const basicTab = { ...@@ -126,7 +126,7 @@ const basicTab = {
target: '*(receivefullAddress, receiveAddressID, receiveAddress,receiveUserName,receiveUserTel)', target: '*(receivefullAddress, receiveAddressID, receiveAddress,receiveUserName,receiveUserTel)',
condition: '{{$value == 1}}' condition: '{{$value == 1}}'
}, },
], ],
}, },
receivefullAddress: { receivefullAddress: {
type: 'string', type: 'string',
...@@ -191,7 +191,7 @@ const basicTab = { ...@@ -191,7 +191,7 @@ const basicTab = {
/** /**
* 通知单明细 * 通知单明细
*/ */
const detailTab = { const detailTab = {
'tab-2': { 'tab-2': {
type: 'object', type: 'object',
...@@ -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}}",
...@@ -277,7 +277,7 @@ const otherRequired = { ...@@ -277,7 +277,7 @@ const otherRequired = {
'x-component-props': { 'x-component-props': {
placeholder: '最长100个字符,50个汉字', placeholder: '最长100个字符,50个汉字',
rows: 5 rows: 5
} }
}, },
taxDesc: { taxDesc: {
...@@ -381,7 +381,7 @@ const historyRecord = { ...@@ -381,7 +381,7 @@ const historyRecord = {
controller: { controller: {
type: 'object', type: 'object',
'x-component': 'Children', 'x-component': 'Children',
'x-component-props': { 'x-component-props': {
children: '{{RadioBtnGroup}}' children: '{{RadioBtnGroup}}'
} }
...@@ -389,7 +389,7 @@ const historyRecord = { ...@@ -389,7 +389,7 @@ const historyRecord = {
historyTable: { historyTable: {
type: 'object', type: 'object',
'x-component': 'Table', 'x-component': 'Table',
'x-component-props': { 'x-component-props': {
columns: historyColumn columns: historyColumn
} }
......
...@@ -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}
...@@ -51,10 +51,10 @@ const EnterPrise = ({visible, cancel, ...restProps}) => { ...@@ -51,10 +51,10 @@ const EnterPrise = ({visible, cancel, ...restProps}) => {
effects={effects} effects={effects}
expressionScope={{rowSelection: selectRow}} expressionScope={{rowSelection: selectRow}}
></SearchForm> ></SearchForm>
</Modal> </Modal>
) )
} }
export default EnterPrise export default EnterPrise
\ No newline at end of file
...@@ -24,11 +24,11 @@ const expandRowColumn = [ ...@@ -24,11 +24,11 @@ const expandRowColumn = [
const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => { const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
// const [mainTableSelectRow, mainTableSelectRowCtl] = useRowSelectionTable({customKey: 'id'}); // const [mainTableSelectRow, mainTableSelectRowCtl] = useRowSelectionTable({customKey: 'id'});
const [selectRow, selectRowCtl] = useRowSelectionTable({ const [selectRow, selectRowCtl] = useRowSelectionTable({
customKey: 'fullId', customKey: 'fullId',
extendsSelection: { extendsSelection: {
getCheckboxProps: record => ({ 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}) => { ...@@ -36,7 +36,7 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
const fetchData = useCallback(async (params: any) => { const fetchData = useCallback(async (params: any) => {
const {orderTime, ...rest} = params const {orderTime, ...rest} = params
const {st, et} = timeRange(orderTime); const {st, et} = timeRange(orderTime);
let postData = { let postData = {
startCreateTime: st, startCreateTime: st,
endCreateTime: et, endCreateTime: et,
...@@ -44,8 +44,8 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => { ...@@ -44,8 +44,8 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
} }
let res = await PublicApi.getOrderProcessingOrderList(postData); let res = await PublicApi.getOrderProcessingOrderList(postData);
return res; return res;
}, []) }, [])
const expandable = { const expandable = {
expandedRowRender: record => { expandedRowRender: record => {
const renderData = record.productDateilss && record.productDateilss.map( const renderData = record.productDateilss && record.productDateilss.map(
...@@ -70,20 +70,21 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => { ...@@ -70,20 +70,21 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
} }
) )
return ( return (
<Table <Table
columns={expandRowColumn} columns={expandRowColumn}
rowKey={(row) => row.fullId} rowKey={(row) => row.fullId}
// rowSelection={selectRow} // rowSelection={selectRow}
rowSelection={rowSelection} rowSelection={rowSelection}
dataSource={renderData} dataSource={renderData}
pagination={false} pagination={false}
/> />
) )
}, },
// defaultExpandAllRows: true // defaultExpandAllRows: true
} }
// console.log("rowSelection",rowSelection);
const handleSubmit = () => { const handleSubmit = () => {
// console.log(selectRowCtl, mainTableSelectRowCtl); // console.log(selectRowCtl, mainTableSelectRowCtl);
// console.log(selectRowCtl) // console.log(selectRowCtl)
...@@ -129,4 +130,4 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => { ...@@ -129,4 +130,4 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
} }
export default ProcessProducts export default ProcessProducts
\ No newline at end of file
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