feat:表单字段修改,及后端添加pPid.
This commit is contained in:
parent
8fcc35d3cb
commit
f208fc593a
Binary file not shown.
|
@ -130,16 +130,17 @@ class OperationButton extends React.Component<OperationButtonProps, OperationMod
|
||||||
</Space>
|
</Space>
|
||||||
</a>
|
</a>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<DetailModelForm
|
{this.state.openModal&&<DetailModelForm
|
||||||
haveButton={false}
|
haveButton={false}
|
||||||
itemId={this.props.itemId}
|
itemId={this.props.itemId}
|
||||||
pPid={this.props.pPid}
|
pPid={this.props.pPid}
|
||||||
|
pid={this.state.operationId === OPERATION_BUTTON_TYPE.ADD_CHILD ?this.props.itemId:this.props.pid}
|
||||||
operationId={this.state.operationId}
|
operationId={this.state.operationId}
|
||||||
description={this.state.operationId === OPERATION_BUTTON_TYPE.DETAIL ? '任务详情' :
|
description={this.state.operationId === OPERATION_BUTTON_TYPE.DETAIL ? '任务详情' :
|
||||||
this.state.operationId === OPERATION_BUTTON_TYPE.ADD_CHILD ? '添加支线任务' :
|
this.state.operationId === OPERATION_BUTTON_TYPE.ADD_CHILD ? '添加支线任务' :
|
||||||
this.state.operationId === OPERATION_BUTTON_TYPE.UPDATE ? '修改任务' : '未知操作'}
|
this.state.operationId === OPERATION_BUTTON_TYPE.UPDATE ? '修改任务' : '未知操作'}
|
||||||
open={this.state.openModal}
|
open={this.state.openModal}
|
||||||
reloadData={handleCancel}/>
|
reloadData={handleCancel}/>}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ const CalShow: React.FC = () => {
|
||||||
)
|
)
|
||||||
return <div className="App" style={{height: '90vh'}}>
|
return <div className="App" style={{height: '90vh'}}>
|
||||||
{open&&<DetailModelForm operationId={operationId} description={description} open={open} haveButton={false}
|
{open&&<DetailModelForm operationId={operationId} description={description} open={open} haveButton={false}
|
||||||
itemId={itemId}
|
itemId={itemId} pid={pid?Number(pid):0}
|
||||||
reloadData={reloadData} expectedStartTime={expectedStartTime}
|
reloadData={reloadData} expectedStartTime={expectedStartTime}
|
||||||
expectedEndTime={expectedEndTime}/>}
|
expectedEndTime={expectedEndTime}/>}
|
||||||
<DragAndDropCalendar
|
<DragAndDropCalendar
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PlusOutlined } from '@ant-design/icons';
|
import {PlusOutlined, QuestionCircleOutlined} from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
ModalForm,
|
ModalForm,
|
||||||
ProForm,
|
ProForm,
|
||||||
|
@ -6,14 +6,14 @@ import {
|
||||||
ProFormSelect,
|
ProFormSelect,
|
||||||
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, Popconfirm} from 'antd';
|
||||||
import React, {useEffect, useState} from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import {
|
import {
|
||||||
addTask, getTask,
|
addTask, deleteTask, getTask,
|
||||||
getTaskTreeResult,
|
getTaskTreeResult,
|
||||||
OPERATION_BUTTON_TYPE,
|
OPERATION_BUTTON_TYPE,
|
||||||
taskPriorityList,
|
taskPriorityList,
|
||||||
taskStateList
|
taskStateList, updateTask
|
||||||
} from "@/lib/task/project/data";
|
} from "@/lib/task/project/data";
|
||||||
import {DataType} from "@/lib/definitions";
|
import {DataType} from "@/lib/definitions";
|
||||||
import dayjs, {Dayjs} from "dayjs";
|
import dayjs, {Dayjs} from "dayjs";
|
||||||
|
@ -21,7 +21,8 @@ import dayjs, {Dayjs} from "dayjs";
|
||||||
export type DetailModelFormProps={
|
export type DetailModelFormProps={
|
||||||
// 当前内容id
|
// 当前内容id
|
||||||
itemId?: number,
|
itemId?: number,
|
||||||
// 父任务id
|
pid?:number,
|
||||||
|
// 祖宗任务id
|
||||||
pPid?:number,
|
pPid?:number,
|
||||||
// 操作id
|
// 操作id
|
||||||
operationId: number,
|
operationId: number,
|
||||||
|
@ -36,13 +37,14 @@ export type DetailModelFormProps={
|
||||||
// 重新加载数据
|
// 重新加载数据
|
||||||
reloadData?: () => void
|
reloadData?: () => void
|
||||||
}
|
}
|
||||||
export type PidSelectTree= { label: string; value: number;pPid:number; children?: PidSelectTree[] }
|
export type PidSelectTree= { label: string; value: number;pid:number; children?: PidSelectTree[] }
|
||||||
|
|
||||||
export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
console.log("DetailModelForm:props:",props,props.itemId!=undefined&&(
|
console.log("DetailModelForm:props:",props,props.itemId!=undefined&&(
|
||||||
props.operationId === OPERATION_BUTTON_TYPE.DETAIL || props.operationId === OPERATION_BUTTON_TYPE.UPDATE))
|
props.operationId === OPERATION_BUTTON_TYPE.DETAIL || props.operationId === OPERATION_BUTTON_TYPE.UPDATE))
|
||||||
const [form] = Form.useForm<DataType>();
|
const [form] = Form.useForm<DataType>();
|
||||||
const [pPid, setPPid] = useState<number>(0);
|
const [pid, setPid] = useState<number>(props.pid?props.pid:0);
|
||||||
|
const [editFormDisable, setEditFormDisable] = useState(props.operationId === OPERATION_BUTTON_TYPE.DETAIL)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.itemId!=undefined&&(
|
if (props.itemId!=undefined&&(
|
||||||
props.operationId === OPERATION_BUTTON_TYPE.DETAIL || props.operationId === OPERATION_BUTTON_TYPE.UPDATE)) {
|
props.operationId === OPERATION_BUTTON_TYPE.DETAIL || props.operationId === OPERATION_BUTTON_TYPE.UPDATE)) {
|
||||||
|
@ -63,14 +65,14 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}else if(props.operationId === OPERATION_BUTTON_TYPE.ADD|| props.operationId === OPERATION_BUTTON_TYPE.ADD_CHILD){
|
}else if(props.operationId === OPERATION_BUTTON_TYPE.ADD|| props.operationId === OPERATION_BUTTON_TYPE.ADD_CHILD){
|
||||||
let data={'expectedTimeRange':[props.expectedStartTime?props.expectedStartTime:dayjs(), props.expectedEndTime]};
|
let data={'expectedTimeRange':[props.expectedStartTime?props.expectedStartTime:dayjs(), props.expectedEndTime],'pid':props.pid};
|
||||||
form.setFieldsValue(data)
|
form.setFieldsValue(data)
|
||||||
}
|
}
|
||||||
}, [props])
|
}, [props])
|
||||||
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,pPid:data.pPid};
|
const resultData:PidSelectTree = {label:data.name,value:data.id,pid:data.pid};
|
||||||
if (data.children){
|
if (data.children){
|
||||||
resultData.children=childReduce(data.children);
|
resultData.children=childReduce(data.children);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +100,44 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
props.reloadData?.();
|
props.reloadData?.();
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
submitter={props.itemId!==undefined?{
|
||||||
|
render: (prop, defaultDoms) => {
|
||||||
|
return [
|
||||||
|
<Button
|
||||||
|
key="edit"
|
||||||
|
onClick={() => {
|
||||||
|
// props.submit();
|
||||||
|
setEditFormDisable(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</Button>,
|
||||||
|
<Popconfirm
|
||||||
|
title="删除任务"
|
||||||
|
description="确认要删除任务?"
|
||||||
|
icon={<QuestionCircleOutlined style={{color: 'red'}}/>}
|
||||||
|
okText="确认"
|
||||||
|
cancelText="取消"
|
||||||
|
onConfirm={() => {
|
||||||
|
if (props.itemId!==undefined) {
|
||||||
|
deleteTask(props.itemId).then((response => {
|
||||||
|
console.log('response', response)
|
||||||
|
if (response.status.success) {
|
||||||
|
message.success("删除任务成功:" + response.data)
|
||||||
|
props.reloadData?.()
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
><Button type="primary" danger>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
,
|
||||||
|
...defaultDoms
|
||||||
|
];
|
||||||
|
},
|
||||||
|
}:undefined}
|
||||||
onFinish={async (values) => {
|
onFinish={async (values) => {
|
||||||
console.log('Received values of form: ', values);
|
console.log('Received values of form: ', values);
|
||||||
if (values.pid===undefined){
|
if (values.pid===undefined){
|
||||||
|
@ -115,25 +155,53 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
if (values.actualTimeRange?.[1]!=undefined) {
|
if (values.actualTimeRange?.[1]!=undefined) {
|
||||||
values.actualEndTime=dayjs(values.actualTimeRange[1]).toDate()
|
values.actualEndTime=dayjs(values.actualTimeRange[1]).toDate()
|
||||||
}
|
}
|
||||||
values.pPid=pPid;
|
values.pid=pid;
|
||||||
var result:boolean=false;
|
var result:boolean=false;
|
||||||
|
|
||||||
|
let state = taskStateList.find(taskState => taskState.name === values.state?.toString());
|
||||||
|
if (state) {
|
||||||
|
values.state = state.code
|
||||||
|
}
|
||||||
|
let priority = taskPriorityList.find(taskPriority => taskPriority.name === values.priority?.toString())
|
||||||
|
if (priority) {
|
||||||
|
values.priority = priority.code
|
||||||
|
}
|
||||||
// todo 修改
|
// todo 修改
|
||||||
await addTask(values).then(response => {
|
if (props.operationId === OPERATION_BUTTON_TYPE.UPDATE) {
|
||||||
console.log('response', response)
|
await updateTask(values).then(response => {
|
||||||
if (response.status.success) {
|
console.log('response', response)
|
||||||
message.success("添加任务成功:" + response.data)
|
if (response.status.success) {
|
||||||
// 树任务重新刷新
|
message.success("修改任务成功:" + response.data)
|
||||||
// 四象限任务重新刷新
|
// 树任务重新刷新
|
||||||
// 如果可以直接更新列表而不请求。。。。。。
|
// 四象限任务重新刷新
|
||||||
console.log('props.reloadData?.()',props.reloadData)
|
// 如果可以直接更新列表而不请求。。。。。。
|
||||||
props.reloadData?.()
|
console.log('props.reloadData?.()',props.reloadData)
|
||||||
result= true
|
props.reloadData?.()
|
||||||
}else {
|
result= true
|
||||||
message.error(response.status.message)
|
}else {
|
||||||
result= false
|
message.error(response.status.message)
|
||||||
|
result= false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
}else {
|
||||||
|
await addTask(values).then(response => {
|
||||||
|
console.log('response', response)
|
||||||
|
if (response.status.success) {
|
||||||
|
message.success("添加任务成功:" + response.data)
|
||||||
|
// 树任务重新刷新
|
||||||
|
// 四象限任务重新刷新
|
||||||
|
// 如果可以直接更新列表而不请求。。。。。。
|
||||||
|
console.log('props.reloadData?.()',props.reloadData)
|
||||||
|
props.reloadData?.()
|
||||||
|
result= true
|
||||||
|
}else {
|
||||||
|
message.error(response.status.message)
|
||||||
|
result= false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -150,8 +218,8 @@ 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)}}}
|
fieldProps={{onSelect: (e,node) => {console.log('onSelect',e,node);setPid(node.pid)}}}
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={editFormDisable}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
width="md"
|
width="md"
|
||||||
|
@ -159,7 +227,7 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
label="任务名称"
|
label="任务名称"
|
||||||
tooltip="最长为 24 位"
|
tooltip="最长为 24 位"
|
||||||
placeholder="请输入任务名称"
|
placeholder="请输入任务名称"
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={editFormDisable}
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
<ProFormTextArea
|
<ProFormTextArea
|
||||||
|
@ -168,7 +236,7 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
label="任务描述"
|
label="任务描述"
|
||||||
// tooltip="最长为 24 位"
|
// tooltip="最长为 24 位"
|
||||||
placeholder="请输入任务描述"
|
placeholder="请输入任务描述"
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={editFormDisable}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
|
@ -183,7 +251,7 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
name="priority"
|
name="priority"
|
||||||
label="任务优先级"
|
label="任务优先级"
|
||||||
initialValue='3'
|
initialValue='3'
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={editFormDisable}
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
width="sm"
|
width="sm"
|
||||||
|
@ -196,7 +264,7 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
name="state"
|
name="state"
|
||||||
label="任务状态"
|
label="任务状态"
|
||||||
initialValue='8'
|
initialValue='8'
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={editFormDisable}
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
|
@ -207,14 +275,14 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
label="期望时间"
|
label="期望时间"
|
||||||
fieldProps={{allowEmpty:[true, true],showTime:true,needConfirm:false}}
|
fieldProps={{allowEmpty:[true, true],showTime:true,needConfirm:false}}
|
||||||
placeholder={['开始时间','结束时间']}
|
placeholder={['开始时间','结束时间']}
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={editFormDisable}
|
||||||
/>
|
/>
|
||||||
<ProFormDateTimeRangePicker
|
<ProFormDateTimeRangePicker
|
||||||
name="actualTimeRange"
|
name="actualTimeRange"
|
||||||
label="实际时间"
|
label="实际时间"
|
||||||
fieldProps={ {allowEmpty:[true, true],showTime:true,needConfirm:false}}
|
fieldProps={ {allowEmpty:[true, true],showTime:true,needConfirm:false}}
|
||||||
placeholder={['开始时间','结束时间']}
|
placeholder={['开始时间','结束时间']}
|
||||||
disabled ={props.operationId === OPERATION_BUTTON_TYPE.DETAIL}
|
disabled ={editFormDisable}
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue