Commit a01929a6 authored by Gavin Peng's avatar Gavin Peng

fix: 对接送货计划协同

parent 65449c05
/**
* 业务定制弹窗
* @author: Gavin
* @description: 【Ref 版本】选状态反馈选择结果, 示例应用场景: 详情页面点击提交, 弹窗选择审核状态, 是否需要填写原因。 ~~~!!!!单选模式,暂为不可异步, 待优化。
*/
import { Form, Input, Modal, Radio } from 'antd';
import React, { useEffect, useState } from 'react'
import { ModalCancelText, ModalOkText, ReasonPlaceholder, ReasonRulesMessage, SelectRadioRulesMessage } from '../translate';
export interface IRadioGroup {
/**
* Radio Label
*/
label: string,
/**
* Radio Value (Must be unique)
*/
value: string | number,
/**
* Need to fill in the reason
*/
isReason?: boolean
}
export interface SubmitFeedback {
/**
* Radio box checked value
*/
selectedRadio: string | number,
/**
* Input content
*/
reason?: string,
}
interface CustomizedModalProps {
/**
* (必填) 标题
*/
title: string,
/**
* (必填) 是否显示
*/
visible: boolean,
/**
* (必填) Radio.Group渲染数组
*/
radioGroup: IRadioGroup[],
/**
* (必填) 内部校验通过返回
*/
onSubmit: (values: SubmitFeedback) => void
/**
* (必填) 关闭操作反馈 visible 布尔值
*/
onCancel: (visible: boolean) => void
/**
* (非必填) 默认选中 Radio
*/
defaultRadioValue?: string | number,
/**
* (非必填) 确认按钮文字自定义
*/
okText?: string,
/**
* (非必填) 取消按钮文字自定义
*/
cancelText?: string,
}
const CustomizedModal: React.FC<CustomizedModalProps> = (props) => {
const [form] = Form.useForm()
const [visibleReason, setVisibleReason] = useState<boolean>(false)
const onOk = () => {
form.validateFields().then(values => {
props.onSubmit(values)
})
}
const onCancel = () => {
props.onCancel(false)
}
const onRadioGroupChange = (val: any) => {
setVisibleReason(props.radioGroup.find(_f => _f.value == val)?.isReason)
}
useEffect(() => {
if (!props.visible) {
form.resetFields()
} else {
if (props?.defaultRadioValue) {
const _visibleReason = props.radioGroup.find(_f => _f.value === props?.defaultRadioValue)?.isReason
setVisibleReason(_visibleReason)
}
}
},[props.visible])
return (
<Modal
title={props.title}
visible={props.visible}
okText={props?.okText || ModalOkText}
cancelText={props?.okText || ModalCancelText}
onOk={onOk}
onCancel={onCancel}
>
<Form form={form}>
<Form.Item
name='isPass'
initialValue={props.defaultRadioValue}
rules={[{ required: true, message: SelectRadioRulesMessage }]}
>
<Radio.Group onChange={(e) => onRadioGroupChange(e.target.value)}>
{
props.radioGroup?.map((item: IRadioGroup, index: number) => (
<Radio value={item.value} key={index}>{item.label}</Radio>
))
}
</Radio.Group>
</Form.Item>
{
visibleReason
? <Form.Item
name='reason'
rules={[{ required: true, message: ReasonRulesMessage }]}
>
<Input.TextArea allowClear rows={3} maxLength={60} placeholder={ReasonPlaceholder} />
</Form.Item>
: null
}
</Form>
</Modal>
)
}
CustomizedModal.defaultProps = {
visible: false,
radioGroup: [],
onSubmit: (values) => {},
onCancel: (visible) => {},
}
export default CustomizedModal;
...@@ -26,7 +26,7 @@ export interface SubmitFeedback { ...@@ -26,7 +26,7 @@ export interface SubmitFeedback {
/** /**
* Radio box checked value * Radio box checked value
*/ */
selectedRadio: string | number, isPass: string | number,
/** /**
* Input content * Input content
*/ */
......
...@@ -7,7 +7,7 @@ import React, { useRef } from 'react' ...@@ -7,7 +7,7 @@ import React, { useRef } from 'react'
import { history } from 'umi' import { history } from 'umi'
import moment from 'moment' import moment from 'moment'
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Button, Card, Space, Tag } from 'antd' import { Card, Space, Tag } from 'antd'
import StandardTable from '@/components/StandardTable' import StandardTable from '@/components/StandardTable'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import TableOperation from '@/components/TableOperation' import TableOperation from '@/components/TableOperation'
......
...@@ -63,7 +63,7 @@ const DeliveryPlanCollaborationQuery: React.FC = () => { ...@@ -63,7 +63,7 @@ const DeliveryPlanCollaborationQuery: React.FC = () => {
...PlanNumberColumn, ...PlanNumberColumn,
dataIndex: 'planNo', dataIndex: 'planNo',
key: 'planNo', key: 'planNo',
render: (text: unknown, record: any) => <EyePreview url={`/memberCenter/order/deliveryPlanCollaboration/query/details?ty=${godBtoa(record.orderType)}&i=${godBtoa(record.id)}}`}>{text}</EyePreview> render: (text: unknown, record: any) => <EyePreview url={`/memberCenter/order/deliveryPlanCollaboration/query/details?ty=${godBtoa(record.orderType)}&i=${godBtoa(record.id)}`}>{text}</EyePreview>
}, },
{ ...PlanSummaryColumn, dataIndex: 'digest', key: 'digest' }, { ...PlanSummaryColumn, dataIndex: 'digest', key: 'digest' },
{ ...PlannedStartDateColumn, dataIndex: 'planStartTime', key: 'planStartTime', render: (text: string, record: any) => (moment(text).format('YYYY-MM-DD')) }, { ...PlannedStartDateColumn, dataIndex: 'planStartTime', key: 'planStartTime', render: (text: string, record: any) => (moment(text).format('YYYY-MM-DD')) },
......
...@@ -97,7 +97,7 @@ const DeliveryPlanManagementDetails: React.FC = () => { ...@@ -97,7 +97,7 @@ const DeliveryPlanManagementDetails: React.FC = () => {
setExpandIconColumn([...expandIconColumn, ...datesExpandIconColumn]) setExpandIconColumn([...expandIconColumn, ...datesExpandIconColumn])
} }
// 获取计划送货 物料 // 获取计划送货
const getPlannedDelivery = () => { const getPlannedDelivery = () => {
getOrderDeliveryPlanDetailProductPage({ getOrderDeliveryPlanDetailProductPage({
id, id,
...@@ -139,7 +139,6 @@ const DeliveryPlanManagementDetails: React.FC = () => { ...@@ -139,7 +139,6 @@ const DeliveryPlanManagementDetails: React.FC = () => {
}) })
} }
useEffect(() => { useEffect(() => {
getDetails() getDetails()
getExternalRoamRecordData() getExternalRoamRecordData()
......
...@@ -57,7 +57,7 @@ const DeliveryPlanManagementUpdate: React.FC = () => { ...@@ -57,7 +57,7 @@ const DeliveryPlanManagementUpdate: React.FC = () => {
const [form] = Form.useForm() const [form] = Form.useForm()
const datesRef = useRef(null) const datesRef = useRef(null)
const materialTableDataRef = useRef(null) const tableDataRef = useRef(null)
const [spinning, setSpinning] = useState<boolean>(false) const [spinning, setSpinning] = useState<boolean>(false)
...@@ -97,12 +97,12 @@ const DeliveryPlanManagementUpdate: React.FC = () => { ...@@ -97,12 +97,12 @@ const DeliveryPlanManagementUpdate: React.FC = () => {
// 保存 // 保存
const save = () => { const save = () => {
form.validateFields().then(values => { form.validateFields().then(values => {
if (_.isEmpty(materialTableDataRef.current)) { if (_.isEmpty(tableDataRef.current)) {
message.warning('没有找到可执行计划送货') message.warning('没有找到可执行计划送货')
return return
} }
setSpinning(true) setSpinning(true)
const orders = materialTableDataRef.current.flatMap((item: any) => item.orders).flatMap((o: any) => ({ const orders = tableDataRef.current.flatMap((item: any) => item.orders).flatMap((o: any) => ({
...o, ...o,
planDays: Object.keys(o).filter((f: any) => f.startsWith('$')).map((p: any) => o[p]) planDays: Object.keys(o).filter((f: any) => f.startsWith('$')).map((p: any) => o[p])
})) }))
...@@ -125,11 +125,11 @@ const DeliveryPlanManagementUpdate: React.FC = () => { ...@@ -125,11 +125,11 @@ const DeliveryPlanManagementUpdate: React.FC = () => {
// 对应日期填入的送货数量 // 对应日期填入的送货数量
const inputChange = (val: any, text: any, record: any) => { const inputChange = (val: any, text: any, record: any) => {
let { day } = text let { day } = text
let dataArr = JSON.parse(JSON.stringify(materialTableDataRef.current)) let dataArr = JSON.parse(JSON.stringify(tableDataRef.current))
let index = dataArr.findIndex(f => f.skuId === record.skuId) let index = dataArr.findIndex(f => f.skuId === record.skuId)
let childIndex = dataArr[index].orders.findIndex(f => f.orderProductId === record.orderProductId) let childIndex = dataArr[index].orders.findIndex(f => f.orderProductId === record.orderProductId)
dataArr[index].orders[childIndex][`$${day}`].planCount = val dataArr[index].orders[childIndex][`$${day}`].planCount = val
materialTableDataRef.current = dataArr tableDataRef.current = dataArr
setTableData(dataArr) setTableData(dataArr)
} }
...@@ -166,7 +166,7 @@ const DeliveryPlanManagementUpdate: React.FC = () => { ...@@ -166,7 +166,7 @@ const DeliveryPlanManagementUpdate: React.FC = () => {
orders: item.orders.map(o => ({ ...o, ...integrationArrToObj(o.planDays) })) orders: item.orders.map(o => ({ ...o, ...integrationArrToObj(o.planDays) }))
} }
}) })
materialTableDataRef.current = assemble tableDataRef.current = assemble
setTableData(assemble) setTableData(assemble)
} }
}) })
......
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