Commit d16a42c7 authored by 许佳敏's avatar 许佳敏

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

B2B送货通知单 物料选择 See merge request linkseeks-design/pro-platform!628
parents de60ef92 04b555e2
......@@ -25,9 +25,6 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
const { onChange, form, disabled, orderType, title = '选择送货物料', value } = props;
console.log(value);
const [visible, setVisible] = useState(false)
const service = DeliveryNoticeOrderFactory.getInstance()
const [tableData, setTableData] = useState([])
......@@ -36,12 +33,13 @@ function DeliveryGoodTableModal(props: DeliveryGoodTableModalProps) {
const handleVisible = useCallback(() => {
setVisible(true)
selectedRowKeys = value
}, [visible])
}, [visible, value])
const handleSubmit = useCallback(() => {
console.log(selectedRowKeys);
onChange(selectedRowKeys);
setVisible(false);
}, [visible])
}, [visible, value])
useEffect(() => {
......
......@@ -53,15 +53,15 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
Material,
])
useEffect(() => {
form.setFieldsValue({
sourceType: 0,
deliveryRangeTime: [
moment().startOf('day').add('hour', 8),
moment().startOf('day').add('hour', 12)
]
})
}, [])
// useEffect(() => {
// form.setFieldsValue({
// sourceType: 0,
// deliveryRangeTime: [
// moment().startOf('day').add('hour', 8),
// moment().startOf('day').add('hour', 12)
// ]
// })
// }, [])
const handleSubmit = useCallback(() => {
......@@ -73,6 +73,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
service.setTableData(tableDataSourceContext);
service.submit().then(res => {
if (res.code === 1000) {
handleLeave(false)
setTimeout(() => {
history.go(-1)
}, 1000);
......@@ -95,9 +96,12 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
>
<Form
form={form}
onValuesChange={() => { handleLeave() }}
onValuesChange={() => {
console.log('dada');
handleLeave()
}}
>
<FormItem name="sourceType">
<FormItem name="sourceType" initialValue={0}>
<Input type="hidden" />
</FormItem>
......@@ -153,7 +157,12 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
rules={[
required()
]}
label={DeliveryTime} name="deliveryRangeTime">
label={DeliveryTime} name="deliveryRangeTime"
initialValue={[
moment().startOf('day').add('hour', 8),
moment().startOf('day').add('hour', 12)
]}
>
<DatePickerSelect.RangePicker className="w-full" picker='time' />
</FormItem>
......@@ -246,7 +255,7 @@ const DeliveryNoticeManageSRMDetails: React.FC = () => {
let atpm = JSON.parse(JSON.stringify(anchors));
atpm.pop()
const ft = formatTable(value)
if (ft.length > 0) {
......
......@@ -57,7 +57,7 @@ const getConst = (len = 0) => {
const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id, planData, btnCode }) => {
const [form] = Form.useForm()
const { renderPrompt, handleLeave } = usePrompt()
const [tableDataSource, setTableDataSource] = useState<any>([])
const [tableDataSource, setTableDataSource] = useState<any>(new Map())
const [tableDataSourceContext, setTableDataSourceContext] = useState([])
const [loading, setLoading] = useState<boolean>(false)
......@@ -65,20 +65,16 @@ const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id
const progressRef = useRef<HandleType>()
const changeTableSource = (data = []) => {
const r = formMapData(tableDataSource, data)
setTableDataSource(r);
setTableDataSourceContext(data);
renderProgress(data)
}
const renderProgress = (data = tableDataSource) => {
const renderProgress = (data = tableDataSourceContext) => {
const planCountValues: any = {}
data.forEach((item, index) => {
planCountValues[`planCount${index}`] = item.planCount
})
progressRef.current.render(form, { tableDataSource: data, ...planCountValues })
progressRef.current.render(form, { tableDataSourceContext: data, ...planCountValues })
}
const handleSubmit = () => {
......@@ -90,7 +86,7 @@ const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id
receivingAddress,
remark
}) => {
if (tableDataSource.some(item => !item.planCount)) {
if (tableDataSourceContext.some(item => !item.planCount)) {
message.warning('请填写计划送货数量')
return
}
......@@ -104,7 +100,7 @@ const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id
deliveryTime: moment(deliveryTime).format('YYYY-MM-DD'),
deliveryStartTime: moment(deliveryStartEndTime[0]).format('HH:mm'),
deliveryEndTime: moment(deliveryStartEndTime[1]).format('HH:mm'),
products: tableDataSource,
products: tableDataSourceContext,
remark
}
const requestApi = id ? postOrderDeliveryNoticeOrderUpdate : postOrderDeliveryNoticeOrderB2bCreate
......@@ -124,9 +120,14 @@ const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id
}
const handleRemoveMaterialTableRow = (i: number) => {
const source: any[] = tableDataSource;
const newSource = source.splice(i, 0)
changeTableSource(newSource);
const source: any[] = JSON.parse(JSON.stringify(tableDataSourceContext));
source.splice(i, 1);
const r = formMapData(tableDataSource, source)
setTableDataSource(r);
changeTableSource(source);
}
const getDetail = async () => {
......@@ -314,7 +315,7 @@ const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id
{ required: true, message: `请选择${ReceivingAddress}` }
]}
>
<ReceiverAddress disabled />
<ReceiverAddress disabled hiddenBtn={true} />
</Form.Item>
<Form.Item
......@@ -353,7 +354,7 @@ const DeliveryNoticeManagementAwaitB2BDetails: React.FC<PropsType> = ({ type, id
'receivingAddress': addr
})
}
console.log(value);
setTableDataSource(value)
changeTableSource(ft)
}}
......
......@@ -60,7 +60,7 @@ const getConst = (len = 0) => {
const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id, planData, btnCode }) => {
const [form] = Form.useForm()
const { renderPrompt, handleLeave } = usePrompt()
const [tableDataSource, setTableDataSource] = useState<any>([])
const [tableDataSource, setTableDataSource] = useState<any>(new Map())
const [tableDataSourceContext, setTableDataSourceContext] = useState([])
......@@ -69,21 +69,16 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id
const progressRef = useRef<HandleType>()
const changeTableSource = (data = []) => {
const r = formMapData(tableDataSource, data)
setTableDataSource(r);
setTableDataSourceContext(data);
renderProgress(data)
}
const renderProgress = (data = tableDataSource) => {
const renderProgress = (data = tableDataSourceContext) => {
const planCountValues: any = {}
data.forEach((item, index) => {
planCountValues[`planCount${index}`] = item.planCount
})
progressRef.current.render(form, { tableDataSource: data, ...planCountValues })
progressRef.current.render(form, { tableDataSourceContext: data, ...planCountValues })
}
const handleSubmit = () => {
......@@ -95,7 +90,7 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id
receivingAddress,
remark
}) => {
if (tableDataSource.some(item => !item.planCount)) {
if (tableDataSourceContext.some(item => !item.planCount)) {
message.warning('请填写计划送货数量')
return
}
......@@ -109,7 +104,7 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id
deliveryTime: moment(deliveryTime).format('YYYY-MM-DD'),
deliveryStartTime: moment(deliveryStartEndTime[0]).format('HH:mm'),
deliveryEndTime: moment(deliveryStartEndTime[1]).format('HH:mm'),
products: tableDataSource,
products: tableDataSourceContext,
remark
}
const requestApi = id ? postOrderDeliveryNoticeOrderUpdate : postOrderDeliveryNoticeOrderSrmCreate
......@@ -127,10 +122,15 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id
}
const handleRemoveMaterialTableRow = (i: number) => {
const source: any[] = tableDataSourceContext;
const newSource = source.splice(i, 0)
changeTableSource(newSource)
const source: any[] = JSON.parse(JSON.stringify(tableDataSourceContext));
source.splice(i, 1)
const r = formMapData(tableDataSource, source)
console.log(r);
setTableDataSource(r);
changeTableSource(source)
}
const getDetail = async () => {
......@@ -362,7 +362,7 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ type, id
'receivingAddress': addr
})
}
setTableDataSource(value)
changeTableSource(ft)
......
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