Commit 2c2382d2 authored by 前端-李俊鑫's avatar 前端-李俊鑫

fix: 修复送货单管理配送方式的问题

parent 67a39dca
......@@ -4,8 +4,8 @@ function FormItem<values = any>(prosp: FormItemProps<values>) {
return (
<Form.Item
labelAlign="left"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
labelCol={{ span: 5 }}
wrapperCol={{ span: 16 }}
{...prosp} className="w-full">
{prosp.children}
......@@ -14,4 +14,4 @@ function FormItem<values = any>(prosp: FormItemProps<values>) {
);
}
export default FormItem
\ No newline at end of file
export default FormItem
import { useMemo, useState } from "react"
function useLogistics() {
const [LogisticsShow, setLogisticsShow] = useState(1)
function useLogistics(defaultValue = 1) {
const [LogisticsShow, setLogisticsShow] = useState(defaultValue)
const handleLogisticsShow = (value) => {
setLogisticsShow(value)
......@@ -11,6 +11,10 @@ function useLogistics() {
return isDeliveryORSince(LogisticsShow)
}, [LogisticsShow])
const isNeedLogistics = useMemo(() => {
return [1, 4].includes(LogisticsShow)
}, [LogisticsShow])
const isLogistics = useMemo(() => {
return LogisticsShow == 3
}, [LogisticsShow])
......@@ -18,7 +22,8 @@ function useLogistics() {
return {
handleLogisticsShow,
isSince,
isLogistics
isLogistics,
isNeedLogistics
}
}
......@@ -27,5 +32,5 @@ export default useLogistics
export function isDeliveryORSince(type: number) {
return [5, 2].includes(type);
}
\ No newline at end of file
return [2, 3].includes(type);
}
......@@ -14,6 +14,8 @@ interface DeliveryGoodTableModalProps {
orderType?: number
value?: any
title?: string
tableDataSourceContext?: any[]
limitDeliveryType?: boolean
}
/**
......@@ -23,7 +25,7 @@ interface DeliveryGoodTableModalProps {
*/
function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
const { onChange, form, disabled, orderType, title = '选择送货物料', value } = props;
const { onChange, form, disabled, orderType, title = '选择送货物料', value, tableDataSourceContext, limitDeliveryType } = props;
const [visible, setVisible] = useState(false)
const service = DeliveryNoticeOrderFactory.getInstance()
......@@ -63,7 +65,7 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
const expandedRowRender = (record, index) => {
let combination = (record.orders as any[]).map(v => {
let combination = (record.orders as any[]).map((v, i) => {
let result = {
...record,
...v,
......@@ -76,6 +78,8 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
<ExpandedRowTableRender
selectedRowKeys={value.get(index)}
dataSource={combination}
limitDeliveryType={limitDeliveryType}
deliveryType={tableDataSourceContext[0]?.deliveryType}
onChange={(keys) => {
selectedRowKeys.set(index, keys);
onChange(selectedRowKeys);
......@@ -119,6 +123,7 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
tableData.map((t, i) => {
return (
<Table
key={t.skuId}
className="mt-16"
columns={PlannedDeliveryMaterialTableColumn}
rowKey={row => row.no}
......
......@@ -6,6 +6,8 @@ interface DeliveryGoodTableModalProps {
onChange: (value) => void
disabled?: boolean
value?: any
tableDataSourceContext?: any[]
limitDeliveryType?: boolean
}
function DeliveryGoodTableSelectB2B(props: DeliveryGoodTableModalProps) {
......@@ -14,4 +16,4 @@ function DeliveryGoodTableSelectB2B(props: DeliveryGoodTableModalProps) {
)
}
export default DeliveryGoodTableSelectB2B;
\ No newline at end of file
export default DeliveryGoodTableSelectB2B;
......@@ -6,6 +6,8 @@ interface DeliveryGoodTableModalProps {
onChange: (value) => void
disabled?: boolean
value?: any
tableDataSourceContext?: any[]
limitDeliveryType?: boolean
}
function DeliveryGoodTableSelectSRM(props: DeliveryGoodTableModalProps) {
......@@ -14,4 +16,4 @@ function DeliveryGoodTableSelectSRM(props: DeliveryGoodTableModalProps) {
)
}
export default DeliveryGoodTableSelectSRM;
\ No newline at end of file
export default DeliveryGoodTableSelectSRM;
......@@ -4,7 +4,7 @@ import { PlannedDeliveryMaterialExpandableTableColumn } from "../../constants/pa
/**
* 子table渲染
* @param dataSource
* @param dataSource
* @param row 下标index
* @param selectedRowKeys 勾选的值 callback func
*/
......@@ -13,11 +13,13 @@ interface ExpandedRowTableRenderProps {
row?: number,
onChange?: (selectedRowKeys, index?: number) => void,
selectedRowKeys?: any[]
limitDeliveryType?: boolean // 是否限制配送方式
deliveryType?: number // 配送方式
}
function ExpandedRowTableRender(props: ExpandedRowTableRenderProps) {
const { row = 0, onChange, selectedRowKeys: selectedRowKeysProps = [] } = props;
const { row = 0, onChange, selectedRowKeys: selectedRowKeysProps = [], limitDeliveryType, deliveryType } = props;
const onSelectChange = (selectedRowKeys: any[]) => {
......@@ -25,14 +27,19 @@ function ExpandedRowTableRender(props: ExpandedRowTableRenderProps) {
onChange(result, row)
};
// 这里通过 limitDeliveryType 和 deliveryType 控制订单的配送类型
// 选中一项后,其他项的配送方式与之不同的置为不可选
const rowSelection = {
hideSelectAll: limitDeliveryType, // 限制配送方式时不可全选
selectedRowKeys: selectedRowKeysProps.map(v => v.orderNo),
onChange: onSelectChange,
getCheckboxProps: (record: any) => ({
disabled: limitDeliveryType && deliveryType && record.deliveryType !== deliveryType
})
};
return (
<Table
rowSelection={rowSelection}
dataSource={props.dataSource}
rowKey={record => record.orderNo}
......@@ -43,4 +50,4 @@ function ExpandedRowTableRender(props: ExpandedRowTableRenderProps) {
}
export default ExpandedRowTableRender
\ No newline at end of file
export default ExpandedRowTableRender
......@@ -11,9 +11,8 @@ export function RenderLogisticsRadioList() {
<>
<Radio value={1}>物流</Radio>
<Radio value={2}>自提</Radio>
<Radio value={3}>无效配送</Radio>
<Radio value={3}>客户自提</Radio>
<Radio value={4}>供应商直发</Radio>
<Radio value={5}>客户自提</Radio>
</>
)
}
......@@ -45,4 +44,4 @@ export function RenderLogisticsRadioFormItem(props) {
</FormItem>
</>
);
}
\ No newline at end of file
}
......@@ -41,7 +41,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
const [form] = Form.useForm()
const service = new ReceivingNoteB2BAddService(form);
const { handleLogisticsShow, isSince } = useLogistics()
const { handleLogisticsShow, isSince, isNeedLogistics } = useLogistics(0)
const [anchors, setAnchors] = useState<AnchorsItem[]>([
BillsInfo,
......@@ -232,17 +232,50 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
rules={[
required()
]}
label={DeliveryTypeLabel} name="deliveryType">
<Radio.Group onChange={(e) => {
form.setFieldsValue({ 'deliveryType': e.target?.value })
handleLogisticsShow(e.target.value)
}}>
label={DeliveryTypeLabel}
name="deliveryType"
>
<Radio.Group
disabled
// onChange={(e) => {
// form.setFieldsValue({ 'deliveryType': e.target?.value })
// handleLogisticsShow(e.target.value)
// }}
>
{RenderLogisticsRadioList()}
</Radio.Group>
</FormItem>
<RenderLogisticsRadioFormItem form={form}/>
<FormItem
rules={[
validatorByteObject(20)
]}
hidden={!isNeedLogistics}
label={LogisticsCarNoLabel}
name="executorVO.carNumbers"
>
<Input placeholder={`请输入${LogisticsCarNoLabel}`} maxLength={20} />
</FormItem>
<FormItem
hidden={!isNeedLogistics}
label={LogisticsCompanyLabel}
name="logisticsCompanyInt"
>
<LogisticsCompanyMerchantsSelect formProp={form} />
</FormItem>
<FormItem
rules={[
validatorByteObject(20)
]}
hidden={!isNeedLogistics}
label={LogisticsNoLabel}
name="logisticsNo"
>
<Input placeholder={`请输入${LogisticsNoLabel}`} maxLength={20} />
</FormItem>
</ContentBox>
......@@ -250,10 +283,10 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
{/* 在编辑的时候不需要进行此操作 */}
<DeliveryGoodTableSelectB2B
value={tableDataSource}
limitDeliveryType
tableDataSourceContext={tableDataSourceContext}
form={form}
onChange={(value) => {
let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop()
......@@ -282,8 +315,10 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
fullAddress: `${ft[0].provinceName}${ft[0].cityName}${ft[0].districtName}${ft[0].streetName}${ft[0].address}`
}
form.setFieldsValue({
'receiveVO': addr
'receiveVO': addr,
'deliveryType': ft[0]?.deliverType
})
handleLogisticsShow(ft[0]?.deliverType)
}
setTableDataSource(value)
......@@ -334,4 +369,4 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
)
}
export default DeliveryNoticeManageSRMDetails
\ No newline at end of file
export default DeliveryNoticeManageSRMDetails
......@@ -40,10 +40,9 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
const [tableDataSource, setTableDataSource] = useState<Map<string, any>>(new Map());
const [tableDataSourceContext, setTableDataSourceContext] = useState([])
const { renderPrompt, handleLeave } = usePrompt()
const { handleLogisticsShow, isSince } = useLogistics()
const { handleLogisticsShow, isSince, isNeedLogistics } = useLogistics(0)
const [form] = Form.useForm()
const service = new DeliveryNoteAddService(form);
......@@ -91,6 +90,8 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
}, [form, tableDataSourceContext])
console.log('isNeedLogistics', isNeedLogistics)
return (
<AnchorPage title="新增送货单"
anchors={anchors}
......@@ -203,38 +204,70 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
</FormItem>
</ContentBox>
{/* 物流信息 */}
<ContentBox title={LogisticsInfo.name} id={LogisticsInfo.key}>
<FormItem
rules={[
required()
required('请选择配送方式')
]}
label={DeliveryTypeLabel} name="deliveryType">
<Radio.Group onChange={(e) => {
form.setFieldsValue({ 'deliveryType': e.target?.value })
handleLogisticsShow(e.target.value)
}}>
label={DeliveryTypeLabel}
name="deliveryType"
>
<Radio.Group
disabled
// onChange={(e) => {
// form.setFieldsValue({ 'deliveryType': e.target?.value })
// handleLogisticsShow(e.target.value)
// }}
>
{RenderLogisticsRadioList()}
</Radio.Group>
</FormItem>
<RenderLogisticsRadioFormItem form={form} isLogistics={isSince} />
<FormItem
rules={[
validatorByteObject(20)
]}
hidden={!isNeedLogistics}
label={LogisticsCarNoLabel}
name="executorVO.carNumbers"
>
<Input placeholder={`请输入${LogisticsCarNoLabel}`} maxLength={20} />
</FormItem>
</ContentBox>
<FormItem
hidden={!isNeedLogistics}
label={LogisticsCompanyLabel}
name="logisticsCompanyInt"
>
<LogisticsCompanyMerchantsSelect formProp={form} />
</FormItem>
<FormItem
rules={[
validatorByteObject(20)
]}
hidden={!isNeedLogistics}
label={LogisticsNoLabel}
name="logisticsNo"
>
<Input placeholder={`请输入${LogisticsNoLabel}`} maxLength={20} />
</FormItem>
</ContentBox>
{/* 送货物料 */}
<ContentBox title={Material.name} id={Material.key} cols={1}>
{/* 在编辑的时候不需要进行此操作 */}
<DeliveryGoodTableSelectSRM
value={tableDataSource}
limitDeliveryType
tableDataSourceContext={tableDataSourceContext}
form={form}
onChange={(value) => {
let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop()
const ft = formatTable(value)
if (ft.length > 0) {
let addr = {
......@@ -249,8 +282,10 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
fullAddress: `${ft[0].provinceName}${ft[0].cityName}${ft[0].districtName}${ft[0].streetName}${ft[0].address}`
}
form.setFieldsValue({
'receiveVO': addr
'receiveVO': addr,
'deliveryType': ft[0]?.deliverType
})
handleLogisticsShow(ft[0]?.deliverType)
}
setAnchors([
......@@ -270,7 +305,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
dataSource: tableDataSourceContext
}}>
<Table
rowKey={row => row.orderNo}
rowKey='orderNo'
columns={
[
...DeliveryNoticeTableColumnSRMSlef,
......
......@@ -5,7 +5,7 @@
*/
import AnchorPage, { AnchorsItem } from '@/components/AnchorPage'
import React, { useCallback, useEffect, useState, useContext } from 'react'
import { BillsInfo, BuyerLabel, ConsigneeLabel, ConsigneePhoneLabel, ConsigneeTimeLabel, DeliveryAbstractLabel, DeliveryAddrLabel, DeliveryDate, DeliveryDateLabel, DeliveryGood, DeliveryInfo, DeliveryNameLabel, DeliveryNoLabel, DeliveryPhoneLabel, DeliverySlefAddrLabel, DeliveryTimeLabel, DeliveryTypeLabel, Distribution, ExternalRoamRecord, LogisticsCarNoLabel, LogisticsCompanyLabel, LogisticsInfo, LogisticsNoLabel, Material, NoteLabel, OutStatusLabel, ReceivingAddress } from '../../constants'
import { BillsInfo, BuyerLabel, ConsigneeLabel, ConsigneePhoneLabel, ConsigneeTimeLabel, DeliveryAbstractLabel, DeliveryAddrLabel, DeliveryDate, DeliveryDateLabel, DeliveryInfo, DeliveryNameLabel, DeliveryNoLabel, DeliveryPhoneLabel, DeliverySlefAddrLabel, DeliveryTimeLabel, DeliveryTypeLabel, Distribution, ExternalRoamRecord, LogisticsCarNoLabel, LogisticsCompanyLabel, LogisticsInfo, LogisticsNoLabel, Material, NoteLabel, OutStatusLabel, ReceivingAddress } from '../../constants'
import { BaseInfo as ContentBox } from '@/components/BaseInfo'
import { Input, Table, Row, Col, Select, Radio, Form, Button, message, Modal } from 'antd';
import { DeliveryNoticeTableColumn, DeliveryNoticeTableColumnSRM, ExternalRoamRecordTableColumn } from '../../constants/page-table-column';
......@@ -29,6 +29,7 @@ import usePrompt from '@/hooks/usePrompt';
import useLogistics from '../../assets/hooks/useLogistics';
import usePageTitle from '../../assets/hooks/usePageTitle';
import { validatorByteObject } from '@/utils/regExp';
import { RenderLogisticsRadioList } from '../../components/RenderLogisticsRadioList';
const ContentBoxItem = ContentBox.BaseInfoItem;
......@@ -41,7 +42,7 @@ const DeliveryNoticeManageSRMEdit: React.FC = () => {
const { id } = location.query
const { renderPrompt, handleLeave } = usePrompt()
const { handleLogisticsShow, isSince } = useLogistics()
const { handleLogisticsShow, isSince, isNeedLogistics } = useLogistics()
const [form] = Form.useForm()
......@@ -222,25 +223,29 @@ const DeliveryNoticeManageSRMEdit: React.FC = () => {
required()
]}
label={DeliveryTypeLabel} name="deliveryType">
<Radio.Group onChange={(e) => {
form.setFieldsValue({ 'deliveryType': e.target?.value })
handleLogisticsShow(e.target.value)
}}>
<Radio value={0}>物流</Radio>
<Radio value={1}>自提</Radio>
<Radio.Group
disabled
// onChange={(e) => {
// form.setFieldsValue({ 'deliveryType': e.target?.value })
// handleLogisticsShow(e.target.value)
// }}
>
{RenderLogisticsRadioList()}
{/* <Radio value={0}>物流</Radio>
<Radio value={1}>自提</Radio> */}
{/* <Radio.Button value={3}>无效配送</Radio.Button> */}
</Radio.Group>
</FormItem>
<FormItem hidden={isSince} label={LogisticsCarNoLabel} name="executorVO.carNumbers">
<FormItem hidden={!isNeedLogistics} label={LogisticsCarNoLabel} name="executorVO.carNumbers">
<Input />
</FormItem>
<FormItem hidden={isSince} label={LogisticsCompanyLabel} name="logisticsCompanyInt">
<FormItem hidden={!isNeedLogistics} label={LogisticsCompanyLabel} name="logisticsCompanyInt">
<LogisticsCompanyMerchantsSelect />
</FormItem>
<FormItem
rules={
isSince ?
!isNeedLogistics ?
[
validatorByteObject(20),
] :
......@@ -249,13 +254,13 @@ const DeliveryNoticeManageSRMEdit: React.FC = () => {
required(`请输入${LogisticsNoLabel}`)
]
}
hidden={isSince} label={LogisticsNoLabel} name="logisticsNo">
hidden={!isNeedLogistics} label={LogisticsNoLabel} name="logisticsNo">
<Input maxLength={20} />
</FormItem>
</ContentBox>
<ContentBox title={DeliveryGood.name} id={DeliveryGood.key} cols={1}>
<ContentBox title={Material.name} id={Material.key} cols={1}>
<Table
rowKey={row => row.orderNo}
......@@ -288,4 +293,4 @@ const DeliveryNoticeManageSRMEdit: React.FC = () => {
)
}
export default DeliveryNoticeManageSRMEdit
\ No newline at end of file
export default DeliveryNoticeManageSRMEdit
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