feat:pPid和时间设置
This commit is contained in:
parent
a17155a649
commit
8c7ea87a0f
|
@ -155,6 +155,8 @@ export const DetailForm: React.FC<DetailFormProps> = (props) => {
|
||||||
if (response.status.success) {
|
if (response.status.success) {
|
||||||
message.success("修改任务成功:" + response.data)
|
message.success("修改任务成功:" + response.data)
|
||||||
props.handleCancel()
|
props.handleCancel()
|
||||||
|
}else {
|
||||||
|
message.error(response.status.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -225,12 +227,14 @@ export const DetailForm: React.FC<DetailFormProps> = (props) => {
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item<DataType> name={['expectedTimeRange']} label="期望">
|
<Form.Item<DataType> name={'expectedTimeRange'} label="期望">
|
||||||
<RangePicker
|
<RangePicker
|
||||||
disabledDate={disabledDate}
|
disabledDate={disabledDate}
|
||||||
disabledTime={disabledRangeTime}
|
disabledTime={disabledRangeTime}
|
||||||
placeholder={['开始时间', '结束时间']}
|
placeholder={['开始时间', '结束时间']}
|
||||||
allowEmpty={[true, true]}
|
allowEmpty={[true, true]}
|
||||||
|
needConfirm={false}
|
||||||
|
defaultValue={[dayjs(), undefined]}
|
||||||
showTime={{
|
showTime={{
|
||||||
hideDisabledOptions: true,
|
hideDisabledOptions: true,
|
||||||
defaultValue: [dayjs('00:00:00', 'HH:mm:ss'), dayjs('11:59:59', 'HH:mm:ss')],
|
defaultValue: [dayjs('00:00:00', 'HH:mm:ss'), dayjs('11:59:59', 'HH:mm:ss')],
|
||||||
|
@ -244,6 +248,7 @@ export const DetailForm: React.FC<DetailFormProps> = (props) => {
|
||||||
disabledTime={disabledRangeTime}
|
disabledTime={disabledRangeTime}
|
||||||
placeholder={['开始时间', '结束时间']}
|
placeholder={['开始时间', '结束时间']}
|
||||||
allowEmpty={[true, true]}
|
allowEmpty={[true, true]}
|
||||||
|
needConfirm={false}
|
||||||
showTime={{
|
showTime={{
|
||||||
hideDisabledOptions: true,
|
hideDisabledOptions: true,
|
||||||
defaultValue: [dayjs('00:00:00', 'HH:mm:ss'), dayjs('11:59:59', 'HH:mm:ss')],
|
defaultValue: [dayjs('00:00:00', 'HH:mm:ss'), dayjs('11:59:59', 'HH:mm:ss')],
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
ProFormText, ProFormTextArea, ProFormTreeSelect,
|
ProFormText, ProFormTextArea, ProFormTreeSelect,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Button, Form, message } from 'antd';
|
import { Button, Form, message } from 'antd';
|
||||||
import React from "react";
|
import React, {useState} from "react";
|
||||||
import {
|
import {
|
||||||
addTask,
|
addTask,
|
||||||
getTaskTreeResult,
|
getTaskTreeResult,
|
||||||
|
@ -25,13 +25,14 @@ export type DetailModelFormProps={
|
||||||
description:string,
|
description:string,
|
||||||
reloadData?: () => void
|
reloadData?: () => void
|
||||||
}
|
}
|
||||||
export type PidSelectTree= { label: string; value: number; children?: PidSelectTree[] }
|
export type PidSelectTree= { label: string; value: number;pPid:number; children?: PidSelectTree[] }
|
||||||
export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
const [form] = Form.useForm<DataType>();
|
const [form] = Form.useForm<DataType>();
|
||||||
|
const [pPid, setPPid] = useState<number>(0);
|
||||||
function childReduce(child:DataType[]):PidSelectTree[]{
|
function childReduce(child:DataType[]):PidSelectTree[]{
|
||||||
const result:PidSelectTree[] = [];
|
const result:PidSelectTree[] = [];
|
||||||
child.map(data=> {
|
child.map(data=> {
|
||||||
const resultData:PidSelectTree = {label:data.name,value:data.id};
|
const resultData:PidSelectTree = {label:data.name,value:data.id,pPid:data.pPid};
|
||||||
if (data.children){
|
if (data.children){
|
||||||
resultData.children=childReduce(data.children);
|
resultData.children=childReduce(data.children);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,25 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
}}
|
}}
|
||||||
// submitTimeout={2000}
|
// submitTimeout={2000}
|
||||||
onFinish={async (values) => {
|
onFinish={async (values) => {
|
||||||
addTask(values).then(response => {
|
console.log('Received values of form: ', values);
|
||||||
|
if (values.pid===undefined){
|
||||||
|
values.pid=0
|
||||||
|
}
|
||||||
|
if (values.expectedTimeRange?.[0]!=undefined) {
|
||||||
|
values.expectedStartTime=dayjs(values.expectedTimeRange[0]).toDate()
|
||||||
|
}
|
||||||
|
if (values.expectedTimeRange?.[1]!=undefined) {
|
||||||
|
values.expectedEndTime=dayjs(values.expectedTimeRange[1]).toDate()
|
||||||
|
}
|
||||||
|
if (values.actualTimeRange?.[0]!=undefined) {
|
||||||
|
values.actualStartTime=dayjs(values.actualTimeRange[0]).toDate()
|
||||||
|
}
|
||||||
|
if (values.actualTimeRange?.[1]!=undefined) {
|
||||||
|
values.actualEndTime=dayjs(values.actualTimeRange[1]).toDate()
|
||||||
|
}
|
||||||
|
values.pPid=pPid;
|
||||||
|
var result:boolean=false;
|
||||||
|
await addTask(values).then(response => {
|
||||||
console.log('response', response)
|
console.log('response', response)
|
||||||
if (response.status.success) {
|
if (response.status.success) {
|
||||||
message.success("添加任务成功:" + response.data)
|
message.success("添加任务成功:" + response.data)
|
||||||
|
@ -69,10 +88,14 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
// 如果可以直接更新列表而不请求。。。。。。
|
// 如果可以直接更新列表而不请求。。。。。。
|
||||||
console.log('props.reloadData?.()',props.reloadData)
|
console.log('props.reloadData?.()',props.reloadData)
|
||||||
props.reloadData?.()
|
props.reloadData?.()
|
||||||
|
result= true
|
||||||
|
}else {
|
||||||
|
message.error(response.status.message)
|
||||||
|
result= false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
return true;
|
return result;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProFormText width="sm" name="id" hidden={true} label="主键" />
|
<ProFormText width="sm" name="id" hidden={true} label="主键" />
|
||||||
|
@ -88,6 +111,7 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
}}
|
}}
|
||||||
name="pid"
|
name="pid"
|
||||||
label="父级任务"
|
label="父级任务"
|
||||||
|
fieldProps={{onSelect: (e,node) => {console.log('onSelect',e,node);setPPid(node.pPid)}}}
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
|
@ -139,16 +163,17 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
|
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormDateTimeRangePicker
|
<ProFormDateTimeRangePicker
|
||||||
|
initialValue={[dayjs(), undefined]}
|
||||||
name="expectedTimeRange"
|
name="expectedTimeRange"
|
||||||
label="期望时间"
|
label="期望时间"
|
||||||
fieldProps={{allowEmpty:[true, true],defaultValue:[dayjs(), undefined]}}
|
fieldProps={{allowEmpty:[true, true],showTime:true,needConfirm:false}}
|
||||||
placeholder={['开始时间','结束时间']}
|
placeholder={['开始时间','结束时间']}
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
||||||
/>
|
/>
|
||||||
<ProFormDateTimeRangePicker
|
<ProFormDateTimeRangePicker
|
||||||
name="actualTimeRange"
|
name="actualTimeRange"
|
||||||
label="实际时间"
|
label="实际时间"
|
||||||
fieldProps={ {allowEmpty:[true, true]}}
|
fieldProps={ {allowEmpty:[true, true],showTime:true,needConfirm:false}}
|
||||||
placeholder={['开始时间','结束时间']}
|
placeholder={['开始时间','结束时间']}
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue