Commit 4dba1d79 authored by 许佳敏's avatar 许佳敏

Merge branch '20418order' into 'v2-220418'

送货单管理-新增送货单时,选择物料处,在已选择的物料里将记录删除,在弹框选择页并没有取消选择,应该要取消选择才对 See merge request linkseeks-design/pro-platform!620
parents aedfae11 444b8b50
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
import moment from 'moment'; import moment from 'moment';
import React, { useEffect, useState } from 'react'; import React, { MutableRefObject, useEffect, useRef, useState } from 'react';
interface DatePickerSelectProps { interface DatePickerSelectProps {
...@@ -10,6 +10,7 @@ interface DatePickerSelectProps { ...@@ -10,6 +10,7 @@ interface DatePickerSelectProps {
value?: any value?: any
disabled?: boolean disabled?: boolean
hidden?: boolean hidden?: boolean
errorMsg?: any
} }
/** /**
...@@ -19,12 +20,25 @@ interface DatePickerSelectProps { ...@@ -19,12 +20,25 @@ interface DatePickerSelectProps {
*/ */
function DatePickerSelect(props: DatePickerSelectProps) { function DatePickerSelect(props: DatePickerSelectProps) {
const { defualtToday = false, onChange, className, value, disabled = false, hidden = false } = props; const { defualtToday = false, onChange, className, value, disabled = false, hidden = false, errorMsg = '' } = props;
const dom = useRef<any>(null)
const disabledDate = (current) => { const disabledDate = (current) => {
return current && current < moment().startOf('day'); return current && current < moment().startOf('day');
} }
useEffect(() => {
if (errorMsg.length > 0) {
dom.current.focus()
} else {
dom.current.blur()
}
}, [
errorMsg
])
const renderDefaultValue = () => { const renderDefaultValue = () => {
if (defualtToday) { if (defualtToday) {
let result = moment().startOf('day') let result = moment().startOf('day')
...@@ -38,6 +52,8 @@ function DatePickerSelect(props: DatePickerSelectProps) { ...@@ -38,6 +52,8 @@ function DatePickerSelect(props: DatePickerSelectProps) {
return ( return (
<DatePicker <DatePicker
ref={dom}
autoFocus
style={{ style={{
display: hidden ? 'none' : 'block' display: hidden ? 'none' : 'block'
}} }}
......
...@@ -6,7 +6,7 @@ import { PlannedDeliveryMaterialExpandableTableColumn, PlannedDeliveryMaterialTa ...@@ -6,7 +6,7 @@ import { PlannedDeliveryMaterialExpandableTableColumn, PlannedDeliveryMaterialTa
import ExpandedRowTableRender from "./ExpandedRowTableRender"; import ExpandedRowTableRender from "./ExpandedRowTableRender";
import { PlusOutlined } from '@ant-design/icons' import { PlusOutlined } from '@ant-design/icons'
const selectedRowKeys = new Map() let selectedRowKeys = new Map()
interface DeliveryGoodTableModalProps { interface DeliveryGoodTableModalProps {
form: FormInstance form: FormInstance
onChange: (value) => void onChange: (value) => void
...@@ -23,7 +23,10 @@ interface DeliveryGoodTableModalProps { ...@@ -23,7 +23,10 @@ interface DeliveryGoodTableModalProps {
*/ */
function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) { function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
const { onChange, form, disabled, orderType, title = '选择送货物料' } = props; const { onChange, form, disabled, orderType, title = '选择送货物料', value } = props;
console.log(value);
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const service = DeliveryNoticeOrderFactory.getInstance() const service = DeliveryNoticeOrderFactory.getInstance()
...@@ -32,22 +35,15 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) { ...@@ -32,22 +35,15 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
const handleVisible = useCallback(() => { const handleVisible = useCallback(() => {
setVisible(true) setVisible(true)
selectedRowKeys = value
}, [visible]) }, [visible])
const handleSubmit = useCallback(() => { const handleSubmit = useCallback(() => {
let result = [] onChange(selectedRowKeys);
for (const v of selectedRowKeys) {
result.push(...v[1])
}
let targetValue = Array.from(new Set(result))
onChange(targetValue);
setVisible(false); setVisible(false);
}, [visible]) }, [visible])
useEffect(() => { useEffect(() => {
console.log(form.getFieldValue('member'));
if (form.getFieldValue('member')) { if (form.getFieldValue('member')) {
service.getOrderDeliveryPlanOrderProductPage(form, 1, orderType).then(handleResponseHttp) service.getOrderDeliveryPlanOrderProductPage(form, 1, orderType).then(handleResponseHttp)
...@@ -68,7 +64,6 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) { ...@@ -68,7 +64,6 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
} }
const expandedRowRender = (record, index) => { const expandedRowRender = (record, index) => {
let data = record;
let combination = (record.orders as any[]).map(v => { let combination = (record.orders as any[]).map(v => {
let result = { let result = {
...@@ -81,11 +76,11 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) { ...@@ -81,11 +76,11 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
return ( return (
<ExpandedRowTableRender <ExpandedRowTableRender
row={data.id} selectedRowKeys={value.get(index)}
dataSource={combination} dataSource={combination}
onChange={(keys, index) => { onChange={(keys) => {
console.log('keys,index :>> ', keys, index);
selectedRowKeys.set(index, keys); selectedRowKeys.set(index, keys);
onChange(selectedRowKeys);
}} }}
/> />
); );
...@@ -123,14 +118,14 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) { ...@@ -123,14 +118,14 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
> >
{ {
tableData.map(t => { tableData.map((t, i) => {
return ( return (
<Table <Table
className="mt-16" className="mt-16"
columns={PlannedDeliveryMaterialTableColumn} columns={PlannedDeliveryMaterialTableColumn}
rowKey={row => row.no} rowKey={row => row.no}
dataSource={[t]} dataSource={[t]}
expandedRowRender={expandedRowRender} expandedRowRender={(r) => expandedRowRender(r, i)}
defaultExpandAllRows={true} defaultExpandAllRows={true}
expandIcon={() => ""} expandIcon={() => ""}
pagination={false} pagination={false}
......
import { Table } from "antd"; import { Table, TableProps } from "antd";
import { useState } from "react"; import { useEffect, useState } from "react";
import { PlannedDeliveryMaterialExpandableTableColumn } from "../../constants/page-table-column"; import { PlannedDeliveryMaterialExpandableTableColumn } from "../../constants/page-table-column";
/** /**
...@@ -11,29 +11,28 @@ import { PlannedDeliveryMaterialExpandableTableColumn } from "../../constants/pa ...@@ -11,29 +11,28 @@ import { PlannedDeliveryMaterialExpandableTableColumn } from "../../constants/pa
interface ExpandedRowTableRenderProps { interface ExpandedRowTableRenderProps {
dataSource: any[], dataSource: any[],
row?: number, row?: number,
onChange?: (selectedRowKeys, index?: number) => void onChange?: (selectedRowKeys, index?: number) => void,
selectedRowKeys?: any[]
} }
function ExpandedRowTableRender(props: ExpandedRowTableRenderProps) { function ExpandedRowTableRender(props: ExpandedRowTableRenderProps) {
const { row = 0, onChange } = props; const { row = 0, onChange, selectedRowKeys: selectedRowKeysProps = [] } = props;
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const onSelectChange = (selectedRowKeys: any[]) => { const onSelectChange = (selectedRowKeys: any[]) => {
setSelectedRowKeys(selectedRowKeys)
let result = props.dataSource.filter(v => selectedRowKeys.includes(v.orderNo)); let result = props.dataSource.filter(v => selectedRowKeys.includes(v.orderNo));
console.log(row)
onChange(result, row) onChange(result, row)
}; };
const rowSelection = { const rowSelection = {
selectedRowKeys, selectedRowKeys: selectedRowKeysProps.map(v => v.orderNo),
onChange: onSelectChange, onChange: onSelectChange,
}; };
return ( return (
<Table <Table
rowSelection={rowSelection} rowSelection={rowSelection}
dataSource={props.dataSource} dataSource={props.dataSource}
rowKey={record => record.orderNo} rowKey={record => record.orderNo}
......
export function formatTable(selectedRowKeys: Map<string, any>) {
console.log(selectedRowKeys);
let result = []
for (const v of selectedRowKeys) {
result.push(...v[1])
}
console.log(result);
let targetValue = Array.from(new Set(result))
return targetValue;
}
export function formMapData(selectedRowKeys, currentTable: any[]) {
let result = new Map<string, any>()
let orderNos = currentTable.map(v => v.orderNo);
for (const v of selectedRowKeys) {
let tpm = [];
for (const t of v[1]) {
if (orderNos.includes(t.orderNo)) {
tpm.push(t);
}
}
result.set(v[0], tpm);
}
return result;
}
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @description: 与B2B内容大致相同,文件分开方便后续对接以及日后变动修改二开 * @description: 与B2B内容大致相同,文件分开方便后续对接以及日后变动修改二开
*/ */
import AnchorPage, { AnchorsItem } from '@/components/AnchorPage' import AnchorPage, { AnchorsItem } from '@/components/AnchorPage'
import React, { useCallback, useEffect, useState, useContext } from 'react' import React, { useCallback, useEffect, useState, useContext, useMemo } from 'react'
import { BillsInfo, BuyerLabel, ConsigneeTimeLabel, DeliveryAbstractLabel, DeliveryDate, DeliveryDateLabel, DeliveryGood, DeliveryInfo, DeliveryNameLabel, DeliveryPhoneLabel, DeliverySlefAddrLabel, DeliveryTimeLabel, DeliveryTypeLabel, Distribution, LogisticsCarNoLabel, LogisticsCompanyLabel, LogisticsInfo, LogisticsNoLabel, NoteLabel, ReceivingAddress } from '../../constants' import { BillsInfo, BuyerLabel, ConsigneeTimeLabel, DeliveryAbstractLabel, DeliveryDate, DeliveryDateLabel, DeliveryGood, DeliveryInfo, DeliveryNameLabel, DeliveryPhoneLabel, DeliverySlefAddrLabel, DeliveryTimeLabel, DeliveryTypeLabel, Distribution, LogisticsCarNoLabel, LogisticsCompanyLabel, LogisticsInfo, LogisticsNoLabel, NoteLabel, ReceivingAddress } from '../../constants'
import { BaseInfo as ContentBox } from '@/components/BaseInfo' import { BaseInfo as ContentBox } from '@/components/BaseInfo'
import { Input, Table, Radio, Form, Button, Modal } from 'antd'; import { Input, Table, Radio, Form, Button, Modal } from 'antd';
...@@ -27,10 +27,13 @@ import { size } from 'lodash'; ...@@ -27,10 +27,13 @@ import { size } from 'lodash';
import usePrompt from '@/hooks/usePrompt'; import usePrompt from '@/hooks/usePrompt';
import useLogistics from '../../assets/hooks/useLogistics'; import useLogistics from '../../assets/hooks/useLogistics';
import { validatorByteObject } from '@/utils/regExp'; import { validatorByteObject } from '@/utils/regExp';
import { formatTable, formMapData } from '../../components/DeliveryGoodTableSelect/useformatTable';
const DeliveryNoticeManageSRMDetails: React.FC = () => { const DeliveryNoticeManageSRMDetails: React.FC = () => {
const [tableDataSource, setTableDataSource] = useState<any[]>(); const [tableDataSource, setTableDataSource] = useState<Map<string, any>>(new Map());
const [tableDataSourceContext, setTableDataSourceContext] = useState([])
const { renderPrompt, handleLeave } = usePrompt() const { renderPrompt, handleLeave } = usePrompt()
const [form] = Form.useForm() const [form] = Form.useForm()
...@@ -64,7 +67,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -64,7 +67,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
content: "确认送货单资料填写是否正确,提交后不能再撤回!", content: "确认送货单资料填写是否正确,提交后不能再撤回!",
onOk: () => { onOk: () => {
service.setTableData(tableDataSource); service.setTableData(tableDataSourceContext);
service.submit().then(res => { service.submit().then(res => {
if (res.code === 1000) { if (res.code === 1000) {
handleLeave(false) handleLeave(false)
...@@ -78,12 +81,12 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -78,12 +81,12 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
}) })
}, [form, tableDataSource]) }, [form, tableDataSourceContext])
const handleRemoveMaterialTableRow = (i: number) => { const handleRemoveMaterialTableRow = (i: number) => {
const source: any[] = JSON.parse(JSON.stringify(tableDataSource)); const source: any[] = JSON.parse(JSON.stringify(tableDataSourceContext));
source.splice(i, 1); source.splice(i, 1);
setTableDataSource(source);
let atpm = JSON.parse(JSON.stringify(anchors)); let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop() atpm.pop()
...@@ -94,6 +97,11 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -94,6 +97,11 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
name: `${DeliveryGood.name}(${source.length})` name: `${DeliveryGood.name}(${source.length})`
} }
]) ])
const r = formMapData(tableDataSource, source)
setTableDataSource(r);
setTableDataSourceContext(source);
} }
return ( return (
...@@ -176,7 +184,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -176,7 +184,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
{ pattern: PATTERN_MAPS.phone, message: "手机号是否正确" } { pattern: PATTERN_MAPS.phone, message: "手机号是否正确" }
]} ]}
label={DeliveryPhoneLabel} name="executorVO.phone"> label={DeliveryPhoneLabel} name="executorVO.phone">
<Input type="tel" placeholder={`请输入${DeliveryPhoneLabel}`} /> <Input type="tel" placeholder={`请输入${DeliveryPhoneLabel}`} />
</FormItem> </FormItem>
</ContentBox> </ContentBox>
...@@ -195,6 +203,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -195,6 +203,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
label={ReceivingAddress} name="receiveVO"> label={ReceivingAddress} name="receiveVO">
<ReceiverAddress <ReceiverAddress
disabled={true} disabled={true}
hiddenBtn={true}
/> />
</FormItem> </FormItem>
...@@ -247,42 +256,50 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -247,42 +256,50 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
<ContentBox title={DeliveryGood.name} id={DeliveryGood.key} cols={1}> <ContentBox title={DeliveryGood.name} id={DeliveryGood.key} cols={1}>
{/* 在编辑的时候不需要进行此操作 */} {/* 在编辑的时候不需要进行此操作 */}
<DeliveryGoodTableSelectB2B <DeliveryGoodTableSelectB2B
value={tableDataSource}
form={form} form={form}
onChange={(value) => { onChange={(value) => {
if (value.length > 0) {
let addr = {
provinceName: value[0].provinceName,
cityName: value[0].cityName,
districtName: value[0].districtName,
streetName: value[0].streetName,
address: value[0].address,
phone: value[0].phone,
consignee: value[0].consignee,
receiverName: value[0].consignee,
fullAddress: `${value[0].provinceName}${value[0].cityName}${value[0].districtName}${value[0].streetName}${value[0].address}`
}
form.setFieldsValue({
'receiveVO': addr
})
}
let atpm = JSON.parse(JSON.stringify(anchors)); let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop() atpm.pop()
const ft = formatTable(value);
setAnchors([ setAnchors([
...atpm, ...atpm,
{ {
...DeliveryGood, ...DeliveryGood,
name: `${DeliveryGood.name}(${value.length})` name: `${DeliveryGood.name}(${ft.length})`
} }
]) ])
if (ft.length > 0) {
let addr = {
provinceName: ft[0].provinceName,
cityName: ft[0].cityName,
districtName: ft[0].districtName,
streetName: ft[0].streetName,
address: ft[0].address,
phone: ft[0].phone,
consignee: ft[0].consignee,
receiverName: ft[0].consignee,
fullAddress: `${ft[0].provinceName}${ft[0].cityName}${ft[0].districtName}${ft[0].streetName}${ft[0].address}`
}
form.setFieldsValue({
'receiveVO': addr
})
}
setTableDataSource(value) setTableDataSource(value)
setTableDataSourceContext(ft)
}} }}
/> />
<HarvestMaterialContextProvider value={{ <HarvestMaterialContextProvider value={{
dataSource: tableDataSource dataSource: tableDataSourceContext
}}> }}>
<Table <Table
rowKey={row => row.orderNo} rowKey={row => row.orderNo}
...@@ -309,7 +326,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -309,7 +326,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
} }
} }
]} ]}
dataSource={tableDataSource} dataSource={tableDataSourceContext}
pagination={{ pagination={{
size: "small" size: "small"
}} }}
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @description: 与B2B内容大致相同,文件分开方便后续对接以及日后变动修改二开 * @description: 与B2B内容大致相同,文件分开方便后续对接以及日后变动修改二开
*/ */
import AnchorPage, { AnchorsItem } from '@/components/AnchorPage' import AnchorPage, { AnchorsItem } from '@/components/AnchorPage'
import React, { useCallback, useEffect, useState, useContext } from 'react' import React, { useCallback, useEffect, useState, useContext, useMemo } from 'react'
import { BaseInfo, BillsInfo, BuyerLabel, ConsigneeLabel, ConsigneePhoneLabel, ConsigneeTimeLabel, DeliveryAbstractLabel, DeliveryAddrLabel, DeliveryDate, DeliveryDateLabel, DeliveryGood, DeliveryInfo, DeliveryNameLabel, DeliveryNoLabel, DeliveryPhoneLabel, DeliverySlefAddrLabel, DeliveryTime, DeliveryTimeLabel, DeliveryTypeLabel, Distribution, LogisticsCarNoLabel, LogisticsCompanyLabel, LogisticsInfo, LogisticsNoLabel, Material, NoteLabel, OutStatusLabel, ReceivingAddress } from '../../constants' import { BaseInfo, BillsInfo, BuyerLabel, ConsigneeLabel, ConsigneePhoneLabel, ConsigneeTimeLabel, DeliveryAbstractLabel, DeliveryAddrLabel, DeliveryDate, DeliveryDateLabel, DeliveryGood, DeliveryInfo, DeliveryNameLabel, DeliveryNoLabel, DeliveryPhoneLabel, DeliverySlefAddrLabel, DeliveryTime, DeliveryTimeLabel, DeliveryTypeLabel, Distribution, LogisticsCarNoLabel, LogisticsCompanyLabel, LogisticsInfo, LogisticsNoLabel, Material, NoteLabel, OutStatusLabel, ReceivingAddress } from '../../constants'
import { BaseInfo as ContentBox } from '@/components/BaseInfo' import { BaseInfo as ContentBox } from '@/components/BaseInfo'
import { Input, Table, Row, Col, Select, Radio, Form, Button, Modal } from 'antd'; import { Input, Table, Row, Col, Select, Radio, Form, Button, Modal } from 'antd';
...@@ -29,12 +29,14 @@ import { PATTERN_MAPS } from '@/constants/regExp'; ...@@ -29,12 +29,14 @@ import { PATTERN_MAPS } from '@/constants/regExp';
import usePrompt from '@/hooks/usePrompt'; import usePrompt from '@/hooks/usePrompt';
import useLogistics from '../../assets/hooks/useLogistics'; import useLogistics from '../../assets/hooks/useLogistics';
import { validatorByteObject } from '@/utils/regExp'; import { validatorByteObject } from '@/utils/regExp';
import { formatTable, formMapData } from '../../components/DeliveryGoodTableSelect/useformatTable';
const ContentBoxItem = ContentBox.BaseInfoItem; const ContentBoxItem = ContentBox.BaseInfoItem;
const DeliveryNoticeManageSRMDetails: React.FC = () => { const DeliveryNoticeManageSRMDetails: React.FC = () => {
const [tableDataSource, setTableDataSource] = useState<any[]>(); const [tableDataSource, setTableDataSource] = useState<Map<string, any>>(new Map());
const [tableDataSourceContext, setTableDataSourceContext] = useState([])
const { renderPrompt, handleLeave } = usePrompt() const { renderPrompt, handleLeave } = usePrompt()
...@@ -68,7 +70,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -68,7 +70,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
content: "确认送货单资料填写是否正确,提交后不能再撤回!", content: "确认送货单资料填写是否正确,提交后不能再撤回!",
onOk: () => { onOk: () => {
service.setTableData(tableDataSource); service.setTableData(tableDataSourceContext);
service.submit().then(res => { service.submit().then(res => {
if (res.code === 1000) { if (res.code === 1000) {
setTimeout(() => { setTimeout(() => {
...@@ -80,9 +82,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -80,9 +82,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
} }
}) })
}, [form, tableDataSource]) }, [form, tableDataSourceContext])
return ( return (
<AnchorPage title="新增送货单" <AnchorPage title="新增送货单"
...@@ -239,43 +239,48 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -239,43 +239,48 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
<ContentBox title={Material.name} id={Material.key} cols={1}> <ContentBox title={Material.name} id={Material.key} cols={1}>
{/* 在编辑的时候不需要进行此操作 */} {/* 在编辑的时候不需要进行此操作 */}
<DeliveryGoodTableSelectSRM <DeliveryGoodTableSelectSRM
value={tableDataSource}
form={form} form={form}
onChange={(value) => { onChange={(value) => {
if (value.length > 0) { let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop()
const ft = formatTable(value)
if (ft.length > 0) {
let addr = { let addr = {
provinceName: value[0].provinceName, provinceName: ft[0].provinceName,
cityName: value[0].cityName, cityName: ft[0].cityName,
districtName: value[0].districtName, districtName: ft[0].districtName,
streetName: value[0].streetName, streetName: ft[0].streetName,
address: value[0].address, address: ft[0].address,
phone: value[0].phone, phone: ft[0].phone,
consignee: value[0].consignee, consignee: ft[0].consignee,
receiverName: value[0].consignee, receiverName: ft[0].consignee,
fullAddress: `${value[0].provinceName}${value[0].cityName}${value[0].districtName}${value[0].streetName}${value[0].address}` fullAddress: `${ft[0].provinceName}${ft[0].cityName}${ft[0].districtName}${ft[0].streetName}${ft[0].address}`
} }
form.setFieldsValue({ form.setFieldsValue({
'receiveVO': addr 'receiveVO': addr
}) })
} }
let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop()
setAnchors([ setAnchors([
...atpm, ...atpm,
{ {
...Material, ...Material,
name: `${Material.name}(${value.length})` name: `${Material.name}(${ft.length})`
} }
]) ])
setTableDataSource(value) setTableDataSource(value)
setTableDataSourceContext(ft)
}} }}
/> />
<HarvestMaterialContextProvider value={{ <HarvestMaterialContextProvider value={{
dataSource: tableDataSource dataSource: tableDataSourceContext
}}> }}>
<Table <Table
rowKey={row => row.orderNo} rowKey={row => row.orderNo}
...@@ -299,7 +304,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -299,7 +304,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
render: (t, r, i) => { render: (t, r, i) => {
return ( return (
<Button type='link' onClick={() => { <Button type='link' onClick={() => {
let tpm = JSON.parse(JSON.stringify(tableDataSource)) let tpm = JSON.parse(JSON.stringify(tableDataSourceContext))
tpm.splice(i, 1); tpm.splice(i, 1);
let atpm = JSON.parse(JSON.stringify(anchors)); let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop(); atpm.pop();
...@@ -311,14 +316,18 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -311,14 +316,18 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
name: `${Material.name}(${tpm.length})` name: `${Material.name}(${tpm.length})`
} }
]) ])
setTableDataSource(tpm);
const r = formMapData(tableDataSource, tpm)
setTableDataSource(r);
setTableDataSourceContext(tpm);
}}>删除</Button> }}>删除</Button>
) )
} }
} }
]} ]}
dataSource={tableDataSource} dataSource={tableDataSourceContext}
/> />
</HarvestMaterialContextProvider> </HarvestMaterialContextProvider>
......
...@@ -21,6 +21,7 @@ import usePrompt from '@/hooks/usePrompt' ...@@ -21,6 +21,7 @@ import usePrompt from '@/hooks/usePrompt'
import FormProgress, { HandleType } from '@/components/FormProgress' import FormProgress, { HandleType } from '@/components/FormProgress'
import { getMemberManageBuyerMember } from '@/services/MemberV2Api' import { getMemberManageBuyerMember } from '@/services/MemberV2Api'
import { validatorByte } from '@/utils/regExp' import { validatorByte } from '@/utils/regExp'
import { formatTable, formMapData } from '@/pages/order/components/DeliveryGoodTableSelect/useformatTable'
type PropsType = { type PropsType = {
type: 'add' | 'edit'; type: 'add' | 'edit';
...@@ -56,13 +57,19 @@ const getConst = (len = 0) => { ...@@ -56,13 +57,19 @@ const getConst = (len = 0) => {
const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id, planData, btnCode }) => { const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id, planData, btnCode }) => {
const [form] = Form.useForm() const [form] = Form.useForm()
const { renderPrompt, handleLeave } = usePrompt() const { renderPrompt, handleLeave } = usePrompt()
const [tableDataSource, setTableDataSource] = useState<any[]>([]) const [tableDataSource, setTableDataSource] = useState<any>([])
const [tableDataSourceContext, setTableDataSourceContext] = useState([])
const [loading, setLoading] = useState<boolean>(false) const [loading, setLoading] = useState<boolean>(false)
const progressRef = useRef<HandleType>() const progressRef = useRef<HandleType>()
const changeTableSource = (data = []) => { const changeTableSource = (data = []) => {
setTableDataSource(data) const r = formMapData(tableDataSource, data)
setTableDataSource(r);
setTableDataSourceContext(data);
renderProgress(data) renderProgress(data)
} }
...@@ -324,36 +331,40 @@ const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id ...@@ -324,36 +331,40 @@ const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id
</BaseInfo> </BaseInfo>
<BaseInfo className='mt-16' title={DeliveryGood.name} id={DeliveryGood.key} cols={1}> <BaseInfo className='mt-16' title={DeliveryGood.name} id={DeliveryGood.key} cols={1}>
<DeliveryGoodTableSelect <DeliveryGoodTableSelect
value={tableDataSource}
title={`选择${DeliveryGood.name}`} title={`选择${DeliveryGood.name}`}
disabled={!!planData} disabled={!!planData}
form={form} form={form}
onChange={(value) => { onChange={(value) => {
if (value.length > 0) { const ft = formatTable(value)
if (ft.length > 0) {
let addr = { let addr = {
provinceName: value[0].provinceName, provinceName: ft[0].provinceName,
cityName: value[0].cityName, cityName: ft[0].cityName,
districtName: value[0].districtName, districtName: ft[0].districtName,
streetName: value[0].streetName, streetName: ft[0].streetName,
address: value[0].address, address: ft[0].address,
phone: value[0].phone, phone: ft[0].phone,
consignee: value[0].consignee, consignee: ft[0].consignee,
consigneeId: value[0].consigneeId, consigneeId: ft[0].consigneeId,
fullAddress: `${value[0].provinceName}${value[0].cityName}${value[0].districtName}${value[0].streetName}${value[0].address}` fullAddress: `${ft[0].provinceName}${ft[0].cityName}${ft[0].districtName}${ft[0].streetName}${ft[0].address}`
} }
form.setFieldsValue({ form.setFieldsValue({
'receivingAddress': addr 'receivingAddress': addr
}) })
} }
changeTableSource(value)
setTableDataSource(value)
changeTableSource(ft)
}} }}
/> />
<HarvestMaterialContextProvider value={{ <HarvestMaterialContextProvider value={{
dataSource: tableDataSource dataSource: tableDataSourceContext
}}> }}>
<Table <Table
rowKey={row => row.orderNo} rowKey={row => row.orderNo}
columns={columns} columns={columns}
dataSource={tableDataSource} dataSource={tableDataSourceContext}
/> />
</HarvestMaterialContextProvider> </HarvestMaterialContextProvider>
</BaseInfo> </BaseInfo>
......
...@@ -24,6 +24,7 @@ import usePrompt from '@/hooks/usePrompt' ...@@ -24,6 +24,7 @@ import usePrompt from '@/hooks/usePrompt'
import FormProgress, { HandleType } from '@/components/FormProgress' import FormProgress, { HandleType } from '@/components/FormProgress'
import { getMemberManageUpperConsumerMerchantPage } from '@/services/MemberV2Api' import { getMemberManageUpperConsumerMerchantPage } from '@/services/MemberV2Api'
import { validatorByte } from '@/utils/regExp' import { validatorByte } from '@/utils/regExp'
import { formatTable, formMapData } from '@/pages/order/components/DeliveryGoodTableSelect/useformatTable'
type PropsType = { type PropsType = {
type: 'add' | 'edit'; type: 'add' | 'edit';
...@@ -59,13 +60,21 @@ const getConst = (len = 0) => { ...@@ -59,13 +60,21 @@ const getConst = (len = 0) => {
const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id, planData, btnCode }) => { const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id, planData, btnCode }) => {
const [form] = Form.useForm() const [form] = Form.useForm()
const { renderPrompt, handleLeave } = usePrompt() const { renderPrompt, handleLeave } = usePrompt()
const [tableDataSource, setTableDataSource] = useState<any[]>([]) const [tableDataSource, setTableDataSource] = useState<any>([])
const [tableDataSourceContext, setTableDataSourceContext] = useState([])
const [loading, setLoading] = useState<boolean>(false) const [loading, setLoading] = useState<boolean>(false)
const progressRef = useRef<HandleType>() const progressRef = useRef<HandleType>()
const changeTableSource = (data = []) => { const changeTableSource = (data = []) => {
setTableDataSource(data)
const r = formMapData(tableDataSource, data)
setTableDataSource(r);
setTableDataSourceContext(data);
renderProgress(data) renderProgress(data)
} }
...@@ -118,9 +127,10 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id ...@@ -118,9 +127,10 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id
} }
const handleRemoveMaterialTableRow = (i: number) => { const handleRemoveMaterialTableRow = (i: number) => {
const source: any[] = tableDataSource; const source: any[] = tableDataSourceContext;
const newSource = source.splice(i, 0) const newSource = source.splice(i, 0)
changeTableSource(newSource) changeTableSource(newSource)
} }
const getDetail = async () => { const getDetail = async () => {
...@@ -311,7 +321,7 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id ...@@ -311,7 +321,7 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id
{ required: true, message: `请选择${ReceivingAddress}` } { required: true, message: `请选择${ReceivingAddress}` }
]} ]}
> >
<ReceiverAddress disabled /> <ReceiverAddress disabled hiddenBtn={true} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
...@@ -328,36 +338,43 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id ...@@ -328,36 +338,43 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id
</BaseInfo> </BaseInfo>
<BaseInfo className='mt-16' title={Material.name} id={Material.key} cols={1}> <BaseInfo className='mt-16' title={Material.name} id={Material.key} cols={1}>
<DeliveryGoodTableSelect <DeliveryGoodTableSelect
value={tableDataSource}
disabled={!!planData} disabled={!!planData}
form={form} form={form}
orderType={2} orderType={2}
onChange={(value) => { onChange={(value) => {
if (value.length > 0) {
const ft = formatTable(value)
if (ft.length > 0) {
let addr = { let addr = {
provinceName: value[0].provinceName, provinceName: ft[0].provinceName,
cityName: value[0].cityName, cityName: ft[0].cityName,
districtName: value[0].districtName, districtName: ft[0].districtName,
streetName: value[0].streetName, streetName: ft[0].streetName,
address: value[0].address, address: ft[0].address,
phone: value[0].phone, phone: ft[0].phone,
consignee: value[0].consignee, consignee: ft[0].consignee,
consigneeId: value[0].consigneeId, consigneeId: ft[0].consigneeId,
fullAddress: `${value[0].provinceName}${value[0].cityName}${value[0].districtName}${value[0].streetName}${value[0].address}` fullAddress: `${ft[0].provinceName}${ft[0].cityName}${ft[0].districtName}${ft[0].streetName}${ft[0].address}`
} }
form.setFieldsValue({ form.setFieldsValue({
'receivingAddress': addr 'receivingAddress': addr
}) })
} }
changeTableSource(value)
setTableDataSource(value)
changeTableSource(ft)
}} }}
/> />
<HarvestMaterialContextProvider value={{ <HarvestMaterialContextProvider value={{
dataSource: tableDataSource dataSource: tableDataSourceContext
}}> }}>
<Table <Table
rowKey={row => row.orderNo} rowKey={row => row.orderNo}
columns={columns} columns={columns}
dataSource={tableDataSource} dataSource={tableDataSourceContext}
/> />
</HarvestMaterialContextProvider> </HarvestMaterialContextProvider>
</BaseInfo> </BaseInfo>
......
...@@ -216,6 +216,7 @@ function DeliveryNoticeFromCreate() { ...@@ -216,6 +216,7 @@ function DeliveryNoticeFromCreate() {
label={ReceivingAddress} name="receiveVO"> label={ReceivingAddress} name="receiveVO">
<ReceiverAddress <ReceiverAddress
hiddenBtn={true}
disabled={false} disabled={false}
/> />
......
import AnchorPage, { AnchorsItem } from "@/components/AnchorPage" import AnchorPage, { AnchorsItem } from "@/components/AnchorPage"
import { BaseInfo } from "@/components/BaseInfo" import { BaseInfo } from "@/components/BaseInfo"
import { useContext, useEffect, useState } from "react" import { useContext, useEffect, useRef, useState } from "react"
import { import {
BillsInfo, DeliveryInfo, LogisticsInfo, Harvest, HarvestMaterial, BillsInfo, DeliveryInfo, LogisticsInfo, Harvest, HarvestMaterial,
ReceiptAddLabel, NoteLabel, DeliveryTimeLabel, ReceiptAddLabel, NoteLabel, DeliveryTimeLabel,
...@@ -41,6 +41,7 @@ function DeliveryNoteAddForm() { ...@@ -41,6 +41,7 @@ function DeliveryNoteAddForm() {
service.setTableData(tableDataSource) service.setTableData(tableDataSource)
const { renderPrompt, handleLeave } = usePrompt() const { renderPrompt, handleLeave } = usePrompt()
const [info, setInfo] = useState<any>(); const [info, setInfo] = useState<any>();
const [errorMsg, setErrorMsg] = useState("")
const [anchors, setAnchors] = useState<AnchorsItem[]>(() => { const [anchors, setAnchors] = useState<AnchorsItem[]>(() => {
return [ return [
...@@ -91,6 +92,8 @@ function DeliveryNoteAddForm() { ...@@ -91,6 +92,8 @@ function DeliveryNoteAddForm() {
history.go(-1) history.go(-1)
}, 1000); }, 1000);
} }
}).catch(err => {
setErrorMsg(err.errorFields[0].errors[0])
}) })
} }
...@@ -157,10 +160,10 @@ function DeliveryNoteAddForm() { ...@@ -157,10 +160,10 @@ function DeliveryNoteAddForm() {
<div> <div>
<FormItem <FormItem
rules={[ rules={[
required() required(`请输入${ReceivingTime}`)
]} ]}
label={ReceivingTime} name="receiveTime"> label={ReceivingTime} name="receiveTime">
<DatePickerSelect className='w-full' /> <DatePickerSelect errorMsg={errorMsg} className='w-full' />
</FormItem> </FormItem>
<FormItem <FormItem
...@@ -178,6 +181,7 @@ function DeliveryNoteAddForm() { ...@@ -178,6 +181,7 @@ function DeliveryNoteAddForm() {
<FormItem <FormItem
label={ReceivingAddress} name="receiveVO"> label={ReceivingAddress} name="receiveVO">
<ReceiverAddress <ReceiverAddress
hiddenBtn={true}
disabled={true} disabled={true}
/> />
</FormItem> </FormItem>
......
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