Commit 444b8b50 authored by rainbowmorel@163.com's avatar rainbowmorel@163.com

选择物料 逻辑修改

parent 13deed51
...@@ -84,9 +84,9 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -84,9 +84,9 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
}, [form, tableDataSourceContext]) }, [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);
let atpm = JSON.parse(JSON.stringify(anchors)); let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop() atpm.pop()
...@@ -203,6 +203,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -203,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>
...@@ -255,38 +256,45 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -255,38 +256,45 @@ 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(formatTable(value)) setTableDataSourceContext(ft)
}} }}
/> />
......
...@@ -180,7 +180,6 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -180,7 +180,6 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
<FormItem <FormItem
label={ReceivingAddress} name="receiveVO"> label={ReceivingAddress} name="receiveVO">
<ReceiverAddress <ReceiverAddress
disabled={true} disabled={true}
hiddenBtn={true} hiddenBtn={true}
/> />
...@@ -244,18 +243,10 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -244,18 +243,10 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
form={form} form={form}
onChange={(value) => { onChange={(value) => {
let atpm = JSON.parse(JSON.stringify(anchors)); let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop() atpm.pop()
setAnchors([
...atpm,
{
...Material,
name: `${Material.name}(${value.length})`
}
])
const ft = formatTable(value) const ft = formatTable(value)
if (ft.length > 0) { if (ft.length > 0) {
...@@ -275,6 +266,14 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => { ...@@ -275,6 +266,14 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
}) })
} }
setAnchors([
...atpm,
{
...Material,
name: `${Material.name}(${ft.length})`
}
])
setTableDataSource(value) setTableDataSource(value)
setTableDataSourceContext(ft) setTableDataSourceContext(ft)
}} }}
......
...@@ -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}
/> />
......
...@@ -181,6 +181,7 @@ function DeliveryNoteAddForm() { ...@@ -181,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