2020-05-07 10:10:13 +08:00
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
import { Calendar, Select, Radio, Col, Row, Divider, Input, Form, Spin } from 'antd';
|
2020-03-16 14:12:11 +08:00
|
|
|
|
import axios from 'axios';
|
2020-05-28 11:52:59 +08:00
|
|
|
|
import moment from 'moment';
|
2022-06-16 09:48:41 +08:00
|
|
|
|
import '../Order/order.scss';
|
2020-03-16 14:12:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const TextArea = Input.TextArea;
|
|
|
|
|
|
const { Group, Button } = Radio;
|
2020-05-07 10:10:13 +08:00
|
|
|
|
class UpdateMilepost extends Component {
|
|
|
|
|
|
constructor(props) {
|
2020-03-16 14:12:11 +08:00
|
|
|
|
super(props);
|
2020-05-07 10:10:13 +08:00
|
|
|
|
this.state = {
|
|
|
|
|
|
data: undefined,
|
2020-03-16 14:12:11 +08:00
|
|
|
|
value: moment('2017-01-25'),
|
|
|
|
|
|
selectedValue: moment('2020-2-12'),
|
2020-04-30 10:34:06 +08:00
|
|
|
|
isSpin: false
|
2020-03-16 14:12:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-07 10:10:13 +08:00
|
|
|
|
componentDidMount = () => {
|
|
|
|
|
|
this.getmeil();
|
2020-03-16 14:12:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-07 10:10:13 +08:00
|
|
|
|
onPanelChange = (time, mode) => {
|
2020-03-16 14:12:11 +08:00
|
|
|
|
this.setState({
|
2020-05-07 10:10:13 +08:00
|
|
|
|
value: time
|
|
|
|
|
|
});
|
2020-03-16 14:12:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-07 10:10:13 +08:00
|
|
|
|
onSelect = (time) => {
|
2020-03-16 14:12:11 +08:00
|
|
|
|
this.setState({
|
2020-05-07 10:10:13 +08:00
|
|
|
|
value: time,
|
2020-03-16 14:12:11 +08:00
|
|
|
|
selectedValue: time,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-07 10:10:13 +08:00
|
|
|
|
getmeil = () => {
|
2020-08-13 11:42:44 +08:00
|
|
|
|
const { projectsId , owner } = this.props.match.params;
|
2020-03-16 14:12:11 +08:00
|
|
|
|
const { meilid } = this.props.match.params;
|
2020-08-13 11:42:44 +08:00
|
|
|
|
const url = `/${owner}/${projectsId}/milestones/${meilid}/edit.json`;
|
2020-05-07 10:10:13 +08:00
|
|
|
|
axios.get(url, {
|
|
|
|
|
|
params: {
|
|
|
|
|
|
projectsId, meilid
|
2020-03-16 14:12:11 +08:00
|
|
|
|
}
|
2020-05-07 10:10:13 +08:00
|
|
|
|
}).then((result) => {
|
|
|
|
|
|
if (result) {
|
2020-03-16 14:12:11 +08:00
|
|
|
|
this.setState({
|
2020-05-07 10:10:13 +08:00
|
|
|
|
data: result.data,
|
2020-05-28 11:52:59 +08:00
|
|
|
|
selectedValue: result.data.effective_date && moment(result.data.effective_date)
|
2020-03-16 14:12:11 +08:00
|
|
|
|
})
|
|
|
|
|
|
this.props.form.setFieldsValue({
|
2020-05-07 10:10:13 +08:00
|
|
|
|
name: result.data.name,
|
|
|
|
|
|
description: result.data.description
|
|
|
|
|
|
});
|
2020-03-16 14:12:11 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2020-05-07 10:10:13 +08:00
|
|
|
|
}).catch((error) => {
|
2020-03-16 14:12:11 +08:00
|
|
|
|
console.log(error);
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-07 10:10:13 +08:00
|
|
|
|
submit = () => {
|
|
|
|
|
|
this.setState({ isSpin: true })
|
2020-03-16 14:12:11 +08:00
|
|
|
|
this.props.form.validateFieldsAndScroll((err, values) => {
|
2020-05-07 10:10:13 +08:00
|
|
|
|
if (!err) {
|
2020-08-13 11:42:44 +08:00
|
|
|
|
const { projectsId , owner } = this.props.match.params;
|
2020-03-16 14:12:11 +08:00
|
|
|
|
const { meilid } = this.props.match.params;
|
2020-08-13 11:42:44 +08:00
|
|
|
|
const url = `/${owner}/${projectsId}/milestones/${meilid}.json`;
|
2020-05-07 10:10:13 +08:00
|
|
|
|
|
2020-05-28 11:52:59 +08:00
|
|
|
|
let time = this.state.selectedValue && this.state.selectedValue.format("YYYY-MM-DD");
|
|
|
|
|
|
|
2020-05-07 10:10:13 +08:00
|
|
|
|
axios.put(url, {
|
2020-03-16 14:12:11 +08:00
|
|
|
|
...values,
|
2020-05-07 10:10:13 +08:00
|
|
|
|
project_id: projectsId,
|
|
|
|
|
|
id: meilid,
|
|
|
|
|
|
effective_date: time,
|
|
|
|
|
|
status: 'open'
|
|
|
|
|
|
}).then(result => {
|
|
|
|
|
|
if (result) {
|
|
|
|
|
|
this.setState({ isSpin: false })
|
2021-09-01 09:33:22 +08:00
|
|
|
|
this.props.history.push(`/${owner}/${projectsId}/milestones`);
|
2020-03-16 14:12:11 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2020-05-07 10:10:13 +08:00
|
|
|
|
|
|
|
|
|
|
}).catch(error => {
|
2020-05-08 10:28:21 +08:00
|
|
|
|
this.setState({ isSpin: false })
|
2020-03-16 14:12:11 +08:00
|
|
|
|
console.log(error);
|
|
|
|
|
|
})
|
2020-05-08 10:28:21 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
this.setState({ isSpin: false })
|
2020-03-16 14:12:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2020-05-28 11:52:59 +08:00
|
|
|
|
// 清楚截止日期
|
2020-05-07 10:10:13 +08:00
|
|
|
|
claertime = () => {
|
2020-03-16 14:12:11 +08:00
|
|
|
|
this.setState({
|
|
|
|
|
|
selectedValue: undefined,
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-07 10:10:13 +08:00
|
|
|
|
render() {
|
2020-03-16 14:12:11 +08:00
|
|
|
|
const { getFieldDecorator } = this.props.form;
|
2020-05-28 11:52:59 +08:00
|
|
|
|
const { isSpin , selectedValue } = this.state;
|
2020-05-07 10:10:13 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div className="main">
|
|
|
|
|
|
<Form>
|
|
|
|
|
|
<div style={{ marginLeft: 15, marginTop: 24 }}>
|
|
|
|
|
|
<h1 >编辑里程碑</h1>
|
|
|
|
|
|
<h5 className="mt-5 color-grey-9">里程碑可以组织任务和合并请求,并跟踪进度.</h5>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<Divider />
|
|
|
|
|
|
<div style={{ display: 'flex' }}>
|
|
|
|
|
|
<div className="newmilepostleft">
|
|
|
|
|
|
标题
|
2020-03-16 14:12:11 +08:00
|
|
|
|
<div>
|
2020-05-07 10:10:13 +08:00
|
|
|
|
<Form.Item>
|
2020-03-16 14:12:11 +08:00
|
|
|
|
{getFieldDecorator('name', {
|
|
|
|
|
|
rules: [{
|
|
|
|
|
|
required: true, message: '请输入标题'
|
|
|
|
|
|
}],
|
|
|
|
|
|
})(
|
|
|
|
|
|
<Input placeholder="标题" />
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</div>
|
2020-05-07 10:10:13 +08:00
|
|
|
|
描述
|
2020-03-16 14:12:11 +08:00
|
|
|
|
<Form.Item>
|
2020-05-07 10:10:13 +08:00
|
|
|
|
{getFieldDecorator('description', {
|
|
|
|
|
|
rules: [{
|
|
|
|
|
|
required: true, message: '请输入描述内容'
|
|
|
|
|
|
}],
|
|
|
|
|
|
})(
|
|
|
|
|
|
<TextArea placeholder="请输入描述内容..." style={{ height: "150px" }} />
|
|
|
|
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="newmilepostrighe" >
|
|
|
|
|
|
截止日期(可选) <a style={{ color: 'red' }} onClick={this.claertime}>清除</a>
|
2020-03-16 14:12:11 +08:00
|
|
|
|
<div>
|
2020-05-28 11:52:59 +08:00
|
|
|
|
<Input style={{ width: "120px" }} value={selectedValue && selectedValue.format('YYYY-MM-DD')} />
|
2020-05-07 10:10:13 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{ width: 300, border: '1px solid #d9d9d9', borderRadius: 4, marginTop: 5 }}>
|
|
|
|
|
|
<Calendar
|
|
|
|
|
|
fullscreen={false}
|
|
|
|
|
|
headerRender={({ value, type, onChange, onTypeChange }) => {
|
|
|
|
|
|
const start = 0;
|
|
|
|
|
|
const end = 12;
|
|
|
|
|
|
const monthOptions = [];
|
|
|
|
|
|
const current = value.clone();
|
|
|
|
|
|
const localeData = value.localeData();
|
|
|
|
|
|
const months = [];
|
|
|
|
|
|
for (let i = 0; i < 12; i++) {
|
|
|
|
|
|
current.month(i);
|
|
|
|
|
|
months.push(localeData.monthsShort(current));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (let index = start; index < end; index++) {
|
|
|
|
|
|
monthOptions.push(
|
|
|
|
|
|
<Select.Option className="month-item" key={`${index}`}>
|
|
|
|
|
|
{months[index]}
|
|
|
|
|
|
</Select.Option>,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
const month = value.month();
|
|
|
|
|
|
|
|
|
|
|
|
const year = value.year();
|
|
|
|
|
|
const options = [];
|
|
|
|
|
|
for (let i = year - 10; i < year + 10; i += 1) {
|
|
|
|
|
|
options.push(
|
|
|
|
|
|
<Select.Option key={i} value={i} className="year-item">
|
|
|
|
|
|
{i}
|
|
|
|
|
|
</Select.Option>,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div style={{ padding: 10 }}>
|
|
|
|
|
|
|
|
|
|
|
|
<Row type="flex" justify="space-between">
|
|
|
|
|
|
<Col>
|
|
|
|
|
|
<Group size="small" onChange={e => onTypeChange(e.target.value)} value={type}>
|
2021-08-03 17:37:14 +08:00
|
|
|
|
<Button value="month">日期</Button>
|
|
|
|
|
|
<Button value="year">月份</Button>
|
2020-05-07 10:10:13 +08:00
|
|
|
|
</Group>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col>
|
|
|
|
|
|
<Select
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
dropdownMatchSelectWidth={false}
|
|
|
|
|
|
className="my-year-select"
|
|
|
|
|
|
style={{ width: 80 }}
|
|
|
|
|
|
onChange={newYear => {
|
|
|
|
|
|
const now = value.clone().year(newYear);
|
|
|
|
|
|
onChange(now);
|
|
|
|
|
|
}}
|
|
|
|
|
|
value={String(year)}
|
|
|
|
|
|
>
|
|
|
|
|
|
{options}
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col>
|
|
|
|
|
|
<Select
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
dropdownMatchSelectWidth={false}
|
|
|
|
|
|
value={String(month)}
|
|
|
|
|
|
onChange={selectedMonth => {
|
|
|
|
|
|
const newValue = value.clone();
|
|
|
|
|
|
newValue.month(parseInt(selectedMonth, 10));
|
|
|
|
|
|
onChange(newValue);
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{monthOptions}
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}}
|
|
|
|
|
|
onPanelChange={this.onPanelChange}
|
|
|
|
|
|
onSelect={this.onSelect}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2020-03-16 14:12:11 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-05-07 10:10:13 +08:00
|
|
|
|
<Divider />
|
|
|
|
|
|
<div className="clearfix mt15" onClick={this.submit}>
|
|
|
|
|
|
<Spin spinning={isSpin}>
|
|
|
|
|
|
<a className="topWrapper_btn fr" >更新里程碑</a>
|
|
|
|
|
|
</Spin>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
2020-03-16 14:12:11 +08:00
|
|
|
|
</Form>
|
2020-05-07 10:10:13 +08:00
|
|
|
|
</div>
|
2020-03-16 14:12:11 +08:00
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
const WrappedUpdatemile = Form.create({ name: 'UpdatemileFrom' })(UpdateMilepost);
|
|
|
|
|
|
|
|
|
|
|
|
export default WrappedUpdatemile;
|