Commit de8d205d authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

🐞 fix: 修改采购计划BUG

parent af3fccf0
......@@ -13,6 +13,7 @@ const { onFieldChange$ } = FormEffectHooks;
export interface IProps {
title: string,
visible: boolean,
data?: any,
id: number,
modalType: 'audit' | 'abandon' | 'date' | 'next' | 'key' | 'discard' | 'planAudit' | 'billBack',
onCancel?: () => void,
......@@ -24,6 +25,7 @@ export interface IProps {
const ModalOperate: React.FC<IProps> = (props: any) => {
const {
title,
data,
visible,
id,
onCancel,
......@@ -193,6 +195,9 @@ const ModalOperate: React.FC<IProps> = (props: any) => {
if (modalType === 'abandon') {
actions.setFieldValue('reasonTime', moment().format())
}
if (modalType === 'date') {
actions.setFieldValue('quotedPriceTime', moment(data).format())
}
actions.clearErrors();
}, [visible])
......
......@@ -22,6 +22,7 @@ const OfferInquire = () => {
const ref = useRef<any>({});
const [id, setId] = useState<number>();
const [visible, setVisible] = useState<boolean>(false);
const [dataSoucre, setDataSoucre] = useState<number>()
const format = (text) => {
return <>{moment(text).format("YYYY-MM-DD HH:mm:ss")}</>
}
......@@ -104,6 +105,7 @@ const OfferInquire = () => {
<Button
type='link'
onClick={() => {
setDataSoucre(record.offerEndTime)
setId(record.id);
setVisible(true);
}}
......@@ -135,6 +137,7 @@ const OfferInquire = () => {
title="调整截止时间"
visible={visible}
modalType='date'
data={dataSoucre}
onOk={() => handleSubmit()}
onCancel={() => setVisible(false)}
fetch={PublicApi.postPurchaseConfirmQuotedPriceAdjustTime}
......
......@@ -15,6 +15,7 @@ import {
import { CheckCircleOutlined } from '@ant-design/icons';
import ModalOperate from '../../components/modalOperate';
import PurchasePlanMaterialLayout from '../../components/detail/components/purchasePlanMaterialLayout';
import ModalLayout from './modal';
const TABLINK = [
{ id: 'progressLayout', title: '流转进度' },
......@@ -23,6 +24,17 @@ const TABLINK = [
{ id: 'recordLyout', title: '流转记录' },
]
interface PropsType {
/** 类型 */
type?: string,
/** 显示隐藏 */
visible?: boolean,
/** 标题 */
title?: string,
/** 传进来的数据 */
dataScoure: string | number,
}
const PurchasePlanDetailed = () => {
const format = (text) => {
return <>{moment(text).format("YYYY-MM-DD HH:mm:ss")}</>
......@@ -38,6 +50,17 @@ const PurchasePlanDetailed = () => {
const [visible, setVisible] = useState<boolean>(false);
const [dataSource, setDataSource] = useState<any>({});
const [basicEffect, setBasicEffect] = useState<any>([]);
const [props, setProps] = useState<PropsType>()
const handleEidt = (value: string | number, title: string, type: string) => {
setProps({
title,
visible: true,
dataScoure: value,
type
})
}
const handleBasicEffect = (data: any) => {
setBasicEffect([
{
......@@ -47,7 +70,7 @@ const PurchasePlanDetailed = () => {
label: '采购计划摘要', extra: (
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<span>{data.summary}</span>
{ (pathPci === 'purchasePlanSubmit' && path === 'detail') && (<span style={{ padding: 0, color: '#00B37A', cursor: 'pointer' }}>修改摘要</span>)}
{ (pathPci === 'purchasePlanSubmit' && path === 'detail') && (<span onClick={() => handleEidt(data.summary, '采购计划摘要', 'summary')} style={{ padding: 0, color: '#00B37A', cursor: 'pointer' }}>修改摘要</span>)}
</div>
)
......@@ -61,7 +84,7 @@ const PurchasePlanDetailed = () => {
label: '采购计划开始', extra: (
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<span>{format(data.startTime)}</span>
{(pathPci === 'purchasePlanSubmit' && path === 'detail') && (<span style={{ padding: 0, color: '#00B37A', cursor: 'pointer' }}>修改时间</span>)}
{(pathPci === 'purchasePlanSubmit' && path === 'detail') && (<span onClick={() => handleEidt(data.startTime, '计划开始时间', 'startTime')} style={{ padding: 0, color: '#00B37A', cursor: 'pointer' }}>修改时间</span>)}
</div>
)
},
......@@ -69,7 +92,7 @@ const PurchasePlanDetailed = () => {
label: '采购计划截止', extra: (
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<span>{format(data.endTime)}</span>
{(pathPci === 'purchasePlanSubmit' && path === 'detail') && (<span style={{ padding: 0, color: '#00B37A', cursor: 'pointer' }}>修改时间</span>)}
{(pathPci === 'purchasePlanSubmit' && path === 'detail') && (<span onClick={() => handleEidt(data.endTime, '计划结束时间', 'endTime')} style={{ padding: 0, color: '#00B37A', cursor: 'pointer' }}>修改时间</span>)}
</div>
)
},
......@@ -161,6 +184,19 @@ const PurchasePlanDetailed = () => {
return fetchSoure
}
const reload = () => {
fetchDataSource()
}
const handleClose = () => {
setProps({
title: '',
visible: false,
dataScoure: null,
type: ''
})
}
return (
<Context.Provider value={dataSource}>
<PeripheralLayout
......@@ -202,6 +238,12 @@ const PurchasePlanDetailed = () => {
onCancel={() => setVisible(false)}
onOk={() => history.goBack()}
/>
<ModalLayout
{...props}
id={id}
reload={reload}
onClose={handleClose}
/>
</Context.Provider>
)
}
......
import React, { useEffect } from 'react';
import { Modal } from 'antd';
import {
SchemaForm, SchemaMarkupField as Field,
createFormActions,
FormEffectHooks,
} from '@formily/antd'
import { Input, DatePicker } from '@formily/antd-components'
import moment from 'moment';
import { PublicApi } from '@/services/api';
const actions = createFormActions()
const { onFieldChange$ } = FormEffectHooks;
interface ModalLayoutProps {
/** 单据id */
id: number,
/** 类型 */
type?: string,
/** 显示隐藏 */
visible?: boolean,
/** 标题 */
title?: string,
/** 传进来的数据 */
dataScoure: string | number,
/** onClose */
onClose?: () => void,
/** 刷新 */
reload: () => void,
}
const ModalLayout: React.FC<ModalLayoutProps> = (props: any) => {
const { id, type, visible, title, dataScoure, onClose, reload } = props;
const disabledDate = (current) => {
return current && current <= moment().startOf('day');
}
const useFormEffects = () => {
const { setFieldState } = createFormActions()
}
const handleSubmit = (value: any) => {
const params: any = {
id,
}
if (type === 'summary') {
params.summary = value.summary
}
if (type === 'startTime') {
params.startTime = new Date(value.startTime).getTime();
}
if (type === 'endTime') {
params.endTime = new Date(value.endTime).getTime();
}
PublicApi.postPurchasePurchasePlanUpdate({ ...params }).then(res => {
if (res.code !== 1000) {
return
}
onClose();
reload();
})
}
useEffect(() => {
if (type === 'summary') {
actions.setFieldValue('summary', dataScoure)
}
if (type === 'startTime') {
actions.setFieldValue('startTime', moment(dataScoure).format())
}
if (type === 'endTime') {
actions.setFieldValue('endTime', moment(dataScoure).format())
}
actions.clearErrors();
}, [visible])
const handleClose = () => {
onClose();
actions.reset();
}
return (
<Modal
width={600}
title={title}
visible={visible}
onCancel={handleClose}
onOk={() => actions.submit()}
afterClose={() => actions.reset()}
>
<SchemaForm
layout="vertical"
components={{
Input,
DatePicker
}}
actions={actions}
effects={() => useFormEffects()}
onSubmit={(values) => handleSubmit(values)}
>
{type === 'summary' && (
<Field
title="采购计划摘要"
name="summary"
required
x-component="Input"
x-component-props={{
style: {
width: '100%'
},
}}
/>
)}
{type === 'startTime' && (
<Field
title="计划开始时间"
name="startTime"
required
x-component="DatePicker"
x-component-props={{
style: {
width: '100%'
},
format: 'YYYY-MM-DD HH:mm:ss',
disabledDate,
}}
/>
)}
{type === 'endTime' && (
<Field
title="计划结束时间"
name="endTime"
required
x-component="DatePicker"
x-component-props={{
style: {
width: '100%'
},
format: 'YYYY-MM-DD HH:mm:ss',
disabledDate,
}}
/>
)}
</SchemaForm>
</Modal>
)
}
export default ModalLayout;
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