修改任务的新建和编辑

This commit is contained in:
sylor_huang@126.com 2020-06-01 18:28:42 +08:00
parent 4eb2c407c3
commit 7bd87013bc
8 changed files with 909 additions and 1551 deletions

View File

@ -121,7 +121,7 @@ class UserSubmitComponent extends Component {
};
return (
<div>
<span className="df mt20" style={{ alignItems: "center" }}>
<span className="df mt30" style={{ alignItems: "center" }}>
<Link
to={`/users/${current_user && current_user.login}/projects`}
className="show-user-link"
@ -185,7 +185,7 @@ class UserSubmitComponent extends Component {
</Form>
</div>
</div>
<div className="mt50 text-center">
<div className="mt20 text-center">
<Button
type="primary"
onClick={editor_type === "new" ? this.subMitFrom : this.UpdateFile}

View File

@ -45,7 +45,7 @@ class m_editor extends Component {
<div>
<div className="branchTable">
<Editor
height="320px"
height="600px"
language={language ? language : "plaintext"}
theme={"vs-grey"}
defaultValue="请输入内容"

View File

@ -74,92 +74,7 @@ class Detail extends Component {
});
};
// imgshow = () => {
// this.setState({
// isShow: true,
// });
// };
//添加评论
// addjournals = () => {
// const { quillValue } = this.state;
// this.setState({
// journal_spin: true,
// });
// if (!quillValue) {
// this.setState({
// quillFlag: true,
// journal_spin: false,
// });
// return;
// }
// this.props.form.validateFieldsAndScroll((err, values) => {
// if (!err) {
// const { data, page, limit, fileList } = this.state;
// const url = `/issues/${data.id}/journals.json`;
// axios
// .post(url, {
// ...values,
// content: quillValue,
// issue_id: data.id,
// attachment_ids: fileList,
// })
// .then((result) => {
// if (result) {
// this.props.showNotification("评论成功!");
// this.props.form.setFieldsValue({
// content: "",
// });
// this.setState({
// showFiles: false,
// quillValue: "",
// quillFlag: false,
// journal_spin: false,
// });
// this.getjournalslist(page, limit);
// }
// })
// .catch((error) => {
// this.setState({
// journal_spin: false,
// });
// console.log(error);
// });
// } else {
// this.setState({
// journal_spin: false,
// });
// }
// });
// };
//获取评论信息
// getjournalslist = (page, limit) => {
// const { data } = this.state;
// const url = `/issues/${data.id}/journals.json`;
// let id = data.id;
// axios
// .get(url, {
// params: {
// id,
// page,
// limit,
// },
// })
// .then((result) => {
// if (result) {
// this.setState({
// journalsdata: result.data,
// search_count: result.data.journals_count,
// isSpin: false,
// fileList: undefined,
// });
// }
// })
// .catch((error) => {
// console.log(error);
// });
// };
//删除任务信息
deletedetail = (id) => {
const { projectsId, orderId } = this.props.match.params;
@ -201,65 +116,6 @@ class Detail extends Component {
});
};
//修改评论
// updatedetail = (id) => {
// const { page, limit, countvalue } = this.state;
// const { orderId } = this.props.match.params;
// this.setState({
// edit_spin: true,
// });
// const url = `/issues/${orderId}/journals/${id}.json`;
// axios
// .put(url, {
// issue_id: orderId,
// id: id,
// content: countvalue,
// })
// .then((result) => {
// if (result) {
// this.setState({
// isedit: undefined,
// edit_spin: false,
// });
// this.getjournalslist(page, limit);
// }
// })
// .catch((error) => {
// this.setState({
// edit_spin: false,
// });
// console.log(error);
// });
// };
// 获取上传后的文件id数组
// UploadFunc = (fileList) => {
// this.setState({
// fileList,
// });
// };
//删除评论
// deleteorder = (id) => {
// const { orderId } = this.props.match.params;
// const { page, limit } = this.state;
// const url = `/issues/${orderId}/journals/${id}.json`;
// axios
// .delete(url, {
// data: {
// issue_id: orderId,
// id: id,
// },
// })
// .then((result) => {
// if (result) {
// this.getjournalslist(page, limit);
// }
// })
// .catch((error) => {
// console.log(error);
// });
// };
editdetail = (count, status) => {
this.setState({
countvalue: this.stringJson(count),
@ -341,23 +197,6 @@ class Detail extends Component {
showFiles: flag,
});
};
// // 新建评论
// onContentChange = (value) => {
// if (value) {
// this.setState({
// quillValue: value,
// quillFlag: false,
// });
// }
// };
// // 编辑评论
// onEditContentChange = (value) => {
// if (value) {
// this.setState({
// countvalue: value,
// });
// }
// };
handleShowImage = (value) => {
this.setState({
@ -390,193 +229,7 @@ class Detail extends Component {
const { projectsId, orderId } = this.props.match.params;
const {
data,
// journalsdata,
// page,
// limit,
// search_count,
// isSpin,
// isedit,
// showFiles,
// quillValue,
// quillFlag,
// countvalue,
// imageUrl,
// visible,
// journal_spin,
// edit_spin,
} = this.state;
// const { current_user } = this.props;
// const Paginations = (
// <React.Fragment>
// {search_count > limit ? (
// <div className="pt30 mb50 edu-txt-center btp1">
// <Pagination
// simple
// defaultCurrent={page}
// total={search_count}
// pageSize={limit}
// onChange={this.ChangePage}
// ></Pagination>
// </div>
// ) : (
// ""
// )}
// </React.Fragment>
// );
// const renderList = () => {
// if (
// journalsdata &&
// journalsdata.issue_journals &&
// journalsdata.issue_journals.length > 0
// ) {
// return (
// <div className="tagList">
// {journalsdata.issue_journals.map((item, key) => {
// return (
// <li key={key}>
// {key > 0 && (
// <div
// className="order_line"
// style={{ marginLeft: 80 }}
// ></div>
// )}
// <div className="df">
// <Link
// to={`/users/${item && item.user_login}/projects`}
// className="show-user-link"
// >
// <img
// className="user_img"
// src={getImageUrl(`images/${item && item.user_picture}`)}
// alt=""
// />
// </Link>
// <div className="detail_context">
// <div className="topWrapper_detali">
// <p className="ml6 detail_p lineH40">
// {item.user_name}
// <span className="color-grey-9 ml3 mr3">评论于</span>
// <Tooltip title={item.format_time} placement="bottom">
// <span>{item.created_at}</span>
// </Tooltip>
// </p>
// <div
// className="detail_right"
// style={{
// display:
// current_user &&
// isedit === undefined &&
// (current_user.admin ||
// current_user.login === item.user_login)
// ? "block"
// : "none",
// }}
// >
// <span
// onClick={() =>
// this.editdetail(item.content, item.id)
// }
// className="detail_edit_action"
// >
// 编辑
// </span>
// <Popconfirm
// placement="bottom"
// title={"确定要删除当前评论吗?"}
// okText="是"
// cancelText="否"
// onConfirm={() => this.deleteorder(item.id)}
// >
// <span className="detail_edit_action">删除</span>
// </Popconfirm>
// </div>
// </div>
// <div className="detail_ptitlecount">
// <div
// style={{
// display:
// isedit && isedit === item.id ? "none" : "block",
// }}
// >
// {item.content ? (
// this.commentCtx(item.content)
// ) : (
// <div>
// {this.renderJournalList(item.journal_details)}
// </div>
// )}
// {item &&
// item.attachments &&
// item.attachments.length > 0 ? (
// <Attachments
// attachments={item.attachments}
// showNotification={this.props.showNotification}
// canDelete={
// current_user &&
// (current_user.admin ||
// current_user.login === item.user_login)
// }
// />
// ) : (
// ""
// )}
// </div>
// <div
// style={{
// display:
// isedit && isedit === item.id ? "block" : "none",
// }}
// >
// <div className="quillContent mt20">
// <MDEditor
// placeholder={"添加评论..."}
// height={200}
// mdID={`orderdetail-add-description${item.id}`}
// startInit={isedit && isedit === item.id}
// initValue={countvalue}
// onChange={this.onEditContentChange}
// ></MDEditor>
// <p className="quillFlag">
// {quillFlag && (
// <span className="">请输入评论内容</span>
// )}
// </p>
// </div>
// <p className="clearfix mt15">
// <Spin spinning={edit_spin}>
// <a
// className="topWrapper_btn fr"
// type="submit"
// onClick={() => this.updatedetail(item.id)}
// >
// 保存
// </a>
// <a
// className="a_btn cancel_btn fr"
// type="submit"
// onClick={() =>
// this.editdetail(item.content, undefined)
// }
// >
// 取消
// </a>
// </Spin>
// </p>
// </div>
// </div>
// <div style={{ display: this.state.display }}>
// <div className="div_line"></div>
// </div>
// </div>
// </div>
// </li>
// );
// })}
// </div>
// );
// }
// };
const get_color = (type) => {
if (type === "高") {
return "#e67e22";
@ -693,6 +346,18 @@ class Detail extends Component {
<span className="issue_detail_info">分支:</span>
<span>{data && data.branch_name ? data.branch_name : "--"}</span>
</p>
<p className="grid-item pb15">
<span className="issue_detail_info">是否上链:</span>
<span>{data && data.issue_type==="2" ? '是' : "--"}</span>
</p>
{
data && data.issue_type==="2" &&
<p className="grid-item pb15">
<span className="issue_detail_info">token值:</span>
<span>{data && data.token ? data.token : "--"}</span>
</p>
}
<p className="grid-item pb15">
<span className="issue_detail_info">标签:</span>
<span>
@ -738,10 +403,7 @@ class Detail extends Component {
<span className="issue_detail_info">结束日期:</span>
<span>{data && data.due_date ? data.due_date : "--"}</span>
</p>
<p className="grid-item pb15">
<span className="issue_detail_info">token值:</span>
<span>{data && data.token ? data.token : "--"}</span>
</p>
<p className="grid-item pb15">
<span className="issue_detail_info">完成度:</span>
<span>{data && data.done_ratio ? data.done_ratio : "--"}</span>

View File

@ -1,312 +1,17 @@
import React, { Component } from "react";
import { Form, Input, Select, Spin } from 'antd';
import { getImageUrl } from 'educoder';
import UploadComponent from '../Upload/Index';
import MDEditor from '../../modules/tpm/challengesnew/tpm-md-editor';
import './order.css';
import axios from 'axios';
import { Link } from "react-router-dom";
const Option = Select.Option;
import OrderItem from './order_form'
class New extends Component {
constructor(props) {
super(props);
this.state = {
branch_name: "",
issue_tag_ids: "",
fixed_version_id: "",
tracker_id: "缺陷",
issue_type: "普通",
status_id: '新增',
assigned_to_id: "",
priority_id: "正常",
done_ratio: "0%",
issue_chosen: undefined,
branches: undefined,
fileList: undefined,
description: undefined,
isSpin: false
}
}
componentDidMount = () => {
console.log("current_user", this.props.current_user)
if (!this.props.checkIfLogin()) {
this.props.showLoginDialog();
return;
}
this.InitData();
this.getSelectList();
}
InitData = () => {
this.props.form.setFieldsValue({
...this.state
});
}
getSelectList = () => {
let projectsId = ""
if (this.props.match.params.milepostId) {
projectsId = this.props.match.params.projectsId;
this.props.form.setFieldsValue({
fixed_version_id: this.props.match.params.milepostId
});
} else {
projectsId = this.props.match.params.projectsId;
}
const url = `/projects/${projectsId}/issues/new.json`;
axios.get(url).then((result) => {
if (result) {
this.setState({
issue_chosen: result.data.issue_chosen,
branches: result.data.branches
})
}
}).catch((error) => {
console.log(error);
})
}
renderSelect = (list) => {
if (list && list.length > 0) {
return (
list.map((item, key) => {
return (
<Option key={key + 1} value={item.id + ""}>{item.name}</Option>
)
})
)
}
}
// 创建
handleSubmit = () => {
this.setState({
isSpin: true
})
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
const { projectsId } = this.props.match.params;
const { fileList } = this.state;
const url = `/projects/${projectsId}/issues.json`;
if (values.status_id === "新增") {
values.status_id = "1"
}
// if(values.issue_type==="普通"){
// values.issue_type="1"
// }
if (values.tracker_id === "缺陷") {
values.tracker_id = "1"
}
if (values.priority_id === "正常") {
values.priority_id = "2"
}
if (values.done_ratio === "0%") {
values.done_ratio = "0"
}
if (values.issue_tag_ids.length > 0) {
values.issue_tag_ids = [values.issue_tag_ids]
}
const { description } = this.state;
axios.post(url, {
...values,
description: description,
attachment_ids: fileList
}).then(result => {
if (result) {
this.props.showNotification("任务创建成功!");
this.props.history.push(`/projects/${projectsId}/orders`);
this.setState({
description: '',
isSpin: false
})
const { getDetail } = this.props;
getDetail && getDetail();
}
}).catch(error => {
this.setState({
isSpin: false
})
console.log(error);
})
}else{
this.setState({
isSpin: false
})
}
})
}
// 获取上传后的文件id数组
UploadFunc = (fileList) => {
this.setState({
fileList
})
}
onContentChange = (value) => {
this.setState({
description: value
})
}
render() {
const { getFieldDecorator } = this.props.form;
const { current_user } = this.props;
const { description, issue_chosen, branches, isSpin } = this.state;
return (
<div className="main">
<Form>
<div className="f-wrap-between mt20" style={{ alignItems: "flex-start" }}>
<div className="list-right df">
<Link to={`/users/${current_user && current_user.login}/projects`} className="show-user-link">
<img className="user_img" src={getImageUrl(`images/${current_user && current_user.image_url}`)} alt="" />
</Link>
<div className="new_context">
<Form.Item>
{getFieldDecorator('subject', {
rules: [{
required: true, message: '请填写任务标题'
}],
})(
<Input placeholder="标题" />
)}
</Form.Item>
<div className="quillContent" style={{ marginBottom: "20px" }}>
<MDEditor placeholder={'请输入描述信息'} height={350}
mdID={'order-new-description'} initValue={description} onChange={this.onContentChange} ></MDEditor>
</div>
<UploadComponent load={this.UploadFunc} showNotification={this.props.showNotification} isComplete={true} size={100}></UploadComponent>
<p className="clearfix mt15">
<Spin spinning={isSpin}>
<a className="topWrapper_btn fr" type="submit" onClick={this.handleSubmit}>创建任务</a>
</Spin>
</p>
</div>
</div>
<div className="list-left mt10" style={{ paddingRight: "0px", paddingLeft: "0px", width: "25%", backgroundColor: "#fff" }}>
<div className="list-l-panel">
<Form.Item>
{getFieldDecorator('branch_name', {
rules: [],
})(
<Select>
<Option value={''}>分支未指定</Option>
{
branches && branches.length > 0 && branches.map((item, key) => {
return (
<Option value={item}>{item}</Option>
)
})
}
</Select>
)}
</Form.Item>
<Form.Item
label="标签"
>
{getFieldDecorator('issue_tag_ids', {
rules: [],
})(
<Select>
<Option value={""}>{issue_chosen && issue_chosen.issue_tag.length > 0 ? '未选择标签' : '请在仓库设置里添加标签'}</Option>
{this.renderSelect(issue_chosen && issue_chosen.issue_tag)}
</Select>
)}
</Form.Item>
<Form.Item
label="里程碑"
>
{getFieldDecorator('fixed_version_id', {
rules: [],
})(
<Select>
<Option value={""}>{issue_chosen && issue_chosen.issue_version.length > 0 ? '未选择里程碑' : '请添加里程碑'}</Option>
{this.renderSelect(issue_chosen && issue_chosen.issue_version)}
</Select>
)}
</Form.Item>
<Form.Item
label="状态"
>
{getFieldDecorator('status_id', {
rules: [{
required: true, message: '请选择完成状态'
}],
})(
<Select>
{this.renderSelect(issue_chosen && issue_chosen.issue_status)}
</Select>
)}
</Form.Item>
<Form.Item
label="分类"
>
{getFieldDecorator('tracker_id', {
rules: [{
required: true, message: '请选择分类'
}],
})(
<Select>
{this.renderSelect(issue_chosen && issue_chosen.tracker)}
</Select>
)}
</Form.Item>
<Form.Item
label="指派成员"
>
{getFieldDecorator('assigned_to_id', {
rules: [{
}],
})(
<Select>
<Option value={""}>未指派成员</Option>
{this.renderSelect(issue_chosen && issue_chosen.assign_user)}
</Select>
)}
</Form.Item>
<Form.Item
label="优先度"
>
{getFieldDecorator('priority_id', {
rules: [{
required: true, message: '请选择优先度'
}],
})(
<Select>
{this.renderSelect(issue_chosen && issue_chosen.priority)}
</Select>
)}
</Form.Item>
<Form.Item
label="完成度"
>
{getFieldDecorator('done_ratio', {
rules: [{
required: true, message: '请选择完成度'
}],
})(
<Select>
{this.renderSelect(issue_chosen && issue_chosen.done_ratio)}
</Select>
)}
</Form.Item>
</div>
</div>
</div>
</Form>
</div>
<OrderItem form_type="new" {...this.props}></OrderItem>
)
}
}
const WrappedNewForm = Form.create({ name: 'NewOrderForm' })(New);
export default WrappedNewForm;
export default New;

View File

@ -1,403 +1,17 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import axios from 'axios';
import UploadComponent from '../Upload/Index';
import { getImageUrl } from 'educoder';
import { Modal, Form, Input, Select, Spin } from 'antd'
import Attachments from '../Upload/attachment';
import MDEditor from '../../modules/tpm/challengesnew/tpm-md-editor';
const Option = Select.Option;
import React, { Component } from "react";
import OrderItem from './order_form'
class UpdateDetail extends Component {
constructor(props) {
super(props);
this.state = {
data: undefined,
isShow: false,
imgsrc: '',
journalsdata: undefined,
//图片区域是否显示 none 隐藏 block 显示
display: 'none',
titledisplay: 'none',
subject: '',
branch_name: "",
issue_tag_ids: "",
fixed_version_id: "",
tracker_id: 0,
issue_type: 0,
status_id: 0,
assigned_to_id: "",
priority_id: 0,
done_ratio: 0,
textcount: "",
fileList: undefined,
get_attachments: undefined,
isSpin: false
}
}
componentDidMount = () => {
this.getDetail();
}
getDetail = () => {
const { projectsId, orderId } = this.props.match.params;
const url = `/projects/${projectsId}/issues/${orderId}/edit.json`;
axios.get(url).then((result) => {
if (result) {
this.setState({
data: result.data,
subject: result.data.subject,
issue_chosen: result.data.issue_chosen,
branches: result.data.branches,
tracker_id: result.data.tracker_id,
issue_type: result.data.issue_type,
status_id: result.data.status_id,
priority_id: result.data.priority_id,
done_ratio: result.data.done_ratio,
textcount: result.data.description,
branch_name: result.data.branch_name,
get_attachments: result.data.attachments,
fileList: undefined,
issue_tag_ids: result.data.issue_tags && result.data.issue_tags[0].id,
fixed_version_id: result.data.fixed_version_id,
assigned_to_id: result.data.assigned_to_id
})
}
}).catch((error) => {
console.log(error);
})
}
handleok = () => {
this.setState({
isShow: false
});
};
handleCancel = () => {
this.setState({
isShow: false
});
}
imgshow = () => {
this.setState({
isShow: true
});
};
onContentChange = (value) => {
this.setState({
textcount: value
})
}
changmodelname = (e) => {
this.setState({
subject: e.target.value
})
}
changmodelcount = (e) => {
this.setState({
textcount: e.target.value
})
}
renderSelect = (list) => {
if (list && list.length > 0) {
return (
list.map((item, key) => {
return (
<Option key={key + 1} value={item.id}>{item.name}</Option>
)
})
)
}
}
// 切换完成度
changeRatio = (e) => {
if (e === 0) {
this.props.form.setFieldsValue({
status_id: 1
})
this.setState({
status_id: 1
})
} else if (e === 100) {
this.props.form.setFieldsValue({
status_id: 3
})
this.setState({
status_id: 3
})
} else {
this.props.form.setFieldsValue({
status_id: 2
})
this.setState({
status_id: 2
})
}
}
// 切换状态
changeStatus = (e) => {
// console.log(e);
if (e === 1) {
this.props.form.setFieldsValue({
done_ratio: 0
})
this.setState({
done_ratio: 0
})
} else if (e === 3) {
this.props.form.setFieldsValue({
done_ratio: 100
})
this.setState({
done_ratio: 100
})
}
}
// 获取上传后的文件id数组
UploadFunc = (fileList) => {
this.setState({
fileList
})
}
handleSubmit = () => {
this.setState({
isSpin: true
})
const { fileList } = this.state;
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
const { projectsId, orderId } = this.props.match.params;
const { subject } = this.state;
const url = `/projects/${projectsId}/issues/${orderId}.json`;
if (values.issue_tag_ids === 0) {
values.issue_tag_ids = ""
} else {
values.issue_tag_ids = [values.issue_tag_ids]
}
if (values.assigned_to_id === 0) {
values.assigned_to_id = ""
}
const { textcount } = this.state;
axios.put(url, {
project_id: projectsId,
subject: subject,
id: orderId,
description: textcount,
attachment_ids: fileList,
...values
}).then(result => {
if (result) {
this.props.history.push(`/projects/${projectsId}/orders/${orderId}/detail`);
}
}).catch(error => {
this.setState({
isSpin: false
})
console.log(error);
})
}else{
this.setState({
isSpin: false
})
}
})
}
render() {
const { projectsId, orderId } = this.props.match.params;
const { getFieldDecorator } = this.props.form;
const { current_user } = this.props;
const { issue_tag_ids, fixed_version_id, branch_name, status_id, tracker_id, issue_type, assigned_to_id, priority_id, done_ratio,
issue_chosen, branches, subject, textcount, get_attachments, isSpin } = this.state;
return (
<div className="main">
<div>
<Form>
<div className="f-wrap-between mt20" style={{ alignItems: "flex-start" }}>
<div className="list-right df" >
<Link to={`/users/${current_user && current_user.login}/projects`} className="show-user-link">
<img className="user_img" src={getImageUrl(`images/${current_user && current_user.image_url}`)} alt="" />
</Link>
<div className="new_context">
<Form.Item>
{getFieldDecorator('subject', {
rules: [{
required: true, message: '请填写任务标题'
}],
initialValue: subject
})(
<Input placeholder="标题" onChange={this.changmodelname} />
)}
</Form.Item>
<MDEditor placeholder={'请输入任务的描述...'} height={350}
mdID={'order-update-description'} initValue={textcount} onChange={this.onContentChange} ></MDEditor>
<UploadComponent load={this.UploadFunc} showNotification={this.props.showNotification} isComplete={true}></UploadComponent>
{
get_attachments ?
<Attachments attachments={get_attachments} showNotification={this.props.showNotification} canDelete={true} />
:
""
}
<p className="clearfix mt15 text-right">
<Spin spinning={isSpin}>
<a className="topWrapper_btn fr" type="submit" style={{ marginLeft: 5 }} onClick={this.handleSubmit}>保存</a>
<Link to={`/projects/${projectsId}/orders/${orderId}/detail`} className="a_btn cancel_btn fr">取消</Link>
</Spin>
</p>
</div>
</div>
<div className="list-left mt10" style={{ paddingRight: "0px", paddingLeft: "0px", width: "25%", backgroundColor: "#fff" }}>
<div className="list-l-panel">
<Form.Item
label="分支"
>
{getFieldDecorator('branch_name', {
initialValue: branch_name,
rules: [],
})(
<Select>
<Option value={''}>分支未指定</Option>
{
branches && branches.length > 0 && branches.map((item, key) => {
return (
<Option value={item}>{item}</Option>
)
})
}
</Select>
)}
</Form.Item>
<Form.Item
label="标签"
>
{getFieldDecorator('issue_tag_ids', {
initialValue: issue_tag_ids ? [issue_tag_ids] : '',
rules: [],
})(
<Select>
<Option value={''}>{issue_chosen && issue_chosen.issue_tag.length > 0 ? '未选择标签' : '请在仓库设置里添加标签'}</Option>
{this.renderSelect(issue_chosen && issue_chosen.issue_tag)}
</Select>
)}
</Form.Item>
<Form.Item
label="里程碑"
>
{getFieldDecorator('fixed_version_id', {
initialValue: fixed_version_id ? fixed_version_id : "",
rules: [],
})(
<Select>
<Option value={''}>{issue_chosen && issue_chosen.issue_version.length > 0 ? '未选择里程碑' : '请添加里程碑'}</Option>
{this.renderSelect(issue_chosen && issue_chosen.issue_version)}
</Select>
)}
</Form.Item>
<Form.Item
label="状态"
>
{getFieldDecorator('status_id', {
initialValue: status_id,
rules: [{
required: true, message: '请选择完成状态'
}],
})(
<Select onChange={this.changeStatus}>
{this.renderSelect(issue_chosen && issue_chosen.issue_status)}
</Select>
)}
</Form.Item>
<Form.Item
label="分类"
>
{getFieldDecorator('tracker_id', {
initialValue: tracker_id,
rules: [{
required: true, message: '请选择分类'
}],
})(
<Select>
{this.renderSelect(issue_chosen && issue_chosen.tracker)}
</Select>
)}
</Form.Item>
<Form.Item
label="指派成员"
>
{getFieldDecorator('assigned_to_id', {
initialValue: assigned_to_id ? assigned_to_id : "",
})(
<Select>
<Option value={''}>未指派成员</Option>
{this.renderSelect(issue_chosen && issue_chosen.assign_user)}
</Select>
)}
</Form.Item>
<Form.Item
label="优先度"
>
{getFieldDecorator('priority_id', {
initialValue: priority_id,
rules: [{
required: true, message: '请选择优先度'
}],
})(
<Select>
{this.renderSelect(issue_chosen && issue_chosen.priority)}
</Select>
)}
</Form.Item>
<Form.Item
label="完成度"
>
{getFieldDecorator('done_ratio', {
initialValue: done_ratio,
rules: [{
required: true, message: '请选择完成度'
}],
})(
<Select value={done_ratio} onChange={this.changeRatio}>
{this.renderSelect(issue_chosen && issue_chosen.done_ratio)}
</Select>
)}
</Form.Item>
</div>
</div>
</div>
</Form>
</div>
<Modal
onCancel={this.handleCancel}
visible={this.state.isShow}
width="400px"
footer={
[]
}
bodyStyle={{ textAlign: 'center' }}
>
<img class="list_img" src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1608431072,669449145&fm=27&gp=0.jpg" alt="" />
</Modal>
</div>
<OrderItem form_type="edit" {...this.props}></OrderItem>
)
}
}
const UpdateDetailForm = Form.create({ name: 'UpdateDetailForm' })(UpdateDetail);
export default UpdateDetailForm;
}
export default UpdateDetail;

View File

@ -1,24 +1,24 @@
.topWrapper {
padding-bottom:20px;
padding-bottom: 20px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.quillContent{
.quillContent {
position: relative;
margin-bottom: 4px;
}
.quillFlag{
.quillFlag {
position: absolute;
bottom:0px;
left:6px;
bottom: 0px;
left: 6px;
height: 20px;
line-height: 18px;
color: red;
}
.topmilepost{
.topmilepost {
padding: 20px 0;
box-sizing: border-box;
display: flex;
@ -26,18 +26,17 @@
flex-wrap: wrap;
}
.miledetail{
.miledetail {
padding: 20px 0;
box-sizing: border-box;
justify-content: space-between;
border-bottom: 1px solid #EEEEEE;
border-bottom: 1px solid #eeeeee;
flex-wrap: wrap;
}
.topWrapper_nav{
.topWrapper_nav {
display: flex;
}
.detail_p{
.detail_p {
display: flex;
/*padding:10px;*/
/*width: 80%;*/
@ -45,7 +44,7 @@
/*margin: auto;*/
}
.detail_right{
.detail_right {
/*display: flex;*/
flex-grow: 1;
text-align: right;
@ -53,99 +52,102 @@
/*padding-left: 15px;*/
/*margin: auto; */
}
.commit_p{
.commit_p {
font-size: 12px;
padding-top: 10px;
padding-left: 5px;
}
.ul_width{
.ul_width {
width: 100%;
}
.a_btn{
border-radius:4px;
padding:0 12px;
.a_btn {
border-radius: 4px;
padding: 0 12px;
margin-right: 15px;
line-height: 30px;
}
.cancel_btn{
border:1px solid #e6e6e6;
.cancel_btn {
border: 1px solid #e6e6e6;
color: #333 !important;
}
.delete_btn{
border:1px solid red;
.delete_btn {
border: 1px solid red;
color: red !important;
}
.cancel_btn:hover{background: #e6e6e6}
.Closeor_btn{
border:1px solid red;
.cancel_btn:hover {
background: #e6e6e6;
}
.Closeor_btn {
border: 1px solid red;
color: red;
height: 32px;
text-align: center;
border-radius:4px;
padding:0px 12px;
border-radius: 4px;
padding: 0px 12px;
margin-right: 15px;
line-height: 32px;
}
.rectangle {
width: 8px;
height: 8px;
border-radius: 100%;
margin-top: 15px;
margin-left: -4px;
margin-bottom: 10px;
background: green;
}
.order_line{
display: flex;
height: 32px;
margin: auto;
border-left:1px solid #eee;
}
.comment_img{
height: 25px;
width: 25px;
margin-top: 5px;
border-radius: 100%;
}
width: 8px;
height: 8px;
border-radius: 100%;
margin-top: 15px;
margin-left: -4px;
margin-bottom: 10px;
background: green;
}
.order_line {
display: flex;
height: 32px;
margin: auto;
border-left: 1px solid #eee;
}
.comment_img {
height: 25px;
width: 25px;
margin-top: 5px;
border-radius: 100%;
}
.topWrapper_nav a,.topWrapper_nav span{
border:1px solid #f4f4f4;
.topWrapper_nav a,
.topWrapper_nav span {
border: 1px solid #f4f4f4;
border-radius: 5px 0px 0px 5px;
height: 34px;
line-height: 34px;
text-align: center;
padding:0px 10px;
padding: 0px 10px;
display: block;
cursor: pointer;
}
.topWrapper_nav a:hover{
.topWrapper_nav a:hover {
background: #f4f4f4;
}
.topWrapper_nav a:last-child,.topWrapper_nav span:last-child{
.topWrapper_nav a:last-child,
.topWrapper_nav span:last-child {
border-left: none;
border-radius: 0px 5px 5px 0px;
}
.topWrapper_btn {
background: #fff;
border:1px solid #5091FF;
color: #5091FF!important;
padding:0px 12px;
border: 1px solid #5091ff;
color: #5091ff !important;
padding: 0px 12px;
text-align: center;
height: 32px;
line-height: 32px;
border-radius: 4px;
}
.topWrapper_type{
.topWrapper_type {
display: flex;
}
.topWrapper_type li{
.topWrapper_type li {
display: flex;
align-items: center;
margin-right: 30px;
}
.topWrapper_type li >span{
.topWrapper_type li > span {
display: block;
height: 30px;
line-height: 30px;
@ -154,23 +156,23 @@
min-width: 60px;
box-sizing: border-box;
text-align: center;
background:rgba(250,250,250,1);
border:1px solid rgba(221,221,221,1);
background: rgba(250, 250, 250, 1);
border: 1px solid rgba(221, 221, 221, 1);
cursor: pointer;
}
.topWrapper_type li > span.active{
color: #4CACFF;
border:1px solid rgba(80,145,255,1);
.topWrapper_type li > span.active {
color: #4cacff;
border: 1px solid rgba(80, 145, 255, 1);
}
.topWrapper_select{
.topWrapper_select {
display: flex;
flex-wrap: wrap;
align-items: center;
}
.topWrapper .ant-btn.ant-input-search-button{
.topWrapper .ant-btn.ant-input-search-button {
height: 30px;
}
.title_overflow{
.title_overflow {
max-width: 220px;
white-space: nowrap;
overflow: hidden;
@ -179,11 +181,11 @@
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
}
.topWrapper_select li{
.topWrapper_select li {
text-align: center;
cursor: pointer;
color: #666;
width:90px;
width: 90px;
text-align: center;
display: inline-block;
overflow: hidden;
@ -191,39 +193,41 @@
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
}
.topWrapper_select li:active{
.topWrapper_select li:active {
background: #f4f4f4;
border-radius: 4px;
}
.no-cursor li{cursor: default !important;}
.ant-dropdown-menu .ant-dropdown-menu-item{
.no-cursor li {
cursor: default !important;
}
.ant-dropdown-menu .ant-dropdown-menu-item {
text-align: center;
padding:6px 30px;
padding: 6px 30px;
cursor: pointer;
}
.issueItem{
.issueItem {
display: flex;
flex-wrap: wrap;
align-content: center;
border-bottom:1px dashed #cecdcd;
padding:16px 0px 16px 20px;
border-bottom: 1px dashed #cecdcd;
padding: 16px 0px 16px 20px;
}
.issueNo{
padding:0px 5px;
.issueNo {
padding: 0px 5px;
border-radius: 4px;
background: #f4f4f4;
display: block;
margin-right: 8px;
color:#666;
color: #666;
height: 30px;
line-height: 30px;
}
.issueOpen{
.issueOpen {
background: #21ba45 !important;
color: #fff !important;
}
.margin_detail{
.margin_detail {
margin-left: 15px;
margin-right: 15px;
}
@ -241,7 +245,7 @@
margin-left: 15px;
padding: 15px;
position: relative;
background: #FFFFFF;
background: #ffffff;
}
.new_context:before {
position: absolute;
@ -265,41 +269,41 @@
top: 14px;
right: 100%;
}
.list-l-panel{
border:1px solid #f4f4f4;
.list-l-panel {
border: 1px solid #f4f4f4;
border-radius: 4px;
padding:10px 15px;
padding: 10px 15px;
}
.list-l-panel .ant-row{
.list-l-panel .ant-row {
margin-bottom: 0px;
}
/*编辑任务*/
.editingsheet{
/*编辑任务*/
.editingsheet {
background: #ffffff;
color: #21ba45!important;
padding:0px 12px;
color: #21ba45 !important;
padding: 0px 12px;
text-align: center;
height: 32px;
line-height: 32px;
}
/*开启中 关闭中*/
.opendetail{
.opendetail {
display: inline-block;
background: #21ba45;
color: #ffffff!important;
padding:0px 12px;
color: #ffffff !important;
padding: 0px 12px;
text-align: center;
height: 32px;
/*width: 110px;*/
border-radius: 4px;
line-height: 32px;
}
.closedetail{
.closedetail {
display: inline-block;
background: #e60b0b;
color: #ffffff!important;
padding:0px 12px;
color: #ffffff !important;
padding: 0px 12px;
text-align: center;
height: 32px;
/*width: 110px;*/
@ -307,30 +311,29 @@
line-height: 32px;
}
.commenttitle{
color: #21ba45!important;
.commenttitle {
color: #21ba45 !important;
}
.topWrapper_detali{
.topWrapper_detali {
display: flex;
/*height: 35px;*/
background-color: #eee;
align-items: center;
margin-bottom: 10px;
}
.towwrapper_img_detali{
.towwrapper_img_detali {
display: flex;
padding-left: 80px;
margin-left: 80px;
margin-right: 20px;
border: 1px solid #4CACFF;
border: 1px solid #4cacff;
}
.div_line{
.div_line {
width: 100%;
border: 10px solid #4CACFF;
border: 10px solid #4cacff;
}
.list_img{
.list_img {
height: 145px;
padding: 15px;
width: 145px;
@ -345,7 +348,7 @@
/*padding-left: 0px;*/
/*margin-right: 15px;*/
position: relative;
background: #FFFFFF;
background: #ffffff;
border-radius: 4px;
width: 0;
}
@ -372,34 +375,38 @@
right: 100%;
}
/* 任务标签列表 */
.tagList > div{
.tagList > div {
border-bottom: 1px dashed #f4f4f4;
display: flex;
justify-content: space-around;
padding:15px 0px;
padding: 15px 0px;
}
.divwidth{
.divwidth {
width: 74%;
}
.listTowItems{
.listTowItems {
width: 80%;
padding-left: 80px;
}
.tagList > div:last-child{
.tagList > div:last-child {
border-bottom: none;
}
.mr10{margin-right: 10px;}
.text-right{text-align: right;}
.mr10 {
margin-right: 10px;
}
.text-right {
text-align: right;
}
/*.tagList > div > span{*/
/*display: block*/
/*display: block*/
/*}*/
/*.tagList > div > span:nth-child(2){*/
/*width: 450px;*/
/*width: 450px;*/
/*}*/
.tagColor{
.tagColor {
display: inline-block;
width:28px;
width: 28px;
height: 14px;
border-radius: 4px;
margin-right: 5px;
@ -407,87 +414,87 @@
}
/*里程碑*/
.milepostdiv{
.milepostdiv {
display: flex;
}
.milepostwidth{
.milepostwidth {
display: flex;
width: 60%;
}
.mileposwidth{
.mileposwidth {
background: #21ba45;
border-radius: 4px;
width: 40%;
}
.milepostrighe{
.milepostrighe {
display: flex;
width: 80%;
}
.milepostleft{
.milepostleft {
display: flex;
justify-content: center;
}
.textwidth{
.textwidth {
display: flex;
width: 100%;
}
.newmilepostleft{
.newmilepostleft {
padding: 15px;
margin-right: 50px;
width: 60%;
}
.newmilepostrighe{
.newmilepostrighe {
margin-left: 50px;
padding: 15px;
width: 30%;
}
/* 任务详情 */
.detailContent{
padding:15px 0px;
.detailContent {
padding: 15px 0px;
border-bottom: 1px solid #f4f4f4;
}
.DetailRight{
padding: 10px 15px;
border:1px solid #f4f4f4;
.DetailRight {
padding: 10px 15px;
border: 1px solid #f4f4f4;
border-radius: 4px;
}
.DetailRight > p{
.DetailRight > p {
height: 30px;
line-height:30px;
line-height: 30px;
}
.inptwidth{
.inptwidth {
width: 20%;
}
.inputcount{
.inputcount {
width: 40%;
}
.loginDiv{
.loginDiv {
border: 1px solid #f7c977;
background: rgb(255, 204, 113,0.3);
background: rgb(255, 204, 113, 0.3);
text-align: center;
padding:8px 0px;
padding: 8px 0px;
border-radius: 4px;
width: 100%;
color: #999;
margin-top: 15px;
}
.loginDiv a{
.loginDiv a {
text-decoration: underline;
color: #4CACFF;
color: #4cacff;
margin-right: 3px;
}
.tagdiv{
.tagdiv {
padding: 15px;
height: 75px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
border: 1px solid #EEEEEE;
border: 1px solid #eeeeee;
flex-wrap: wrap;
}
.dialogdiv{
.dialogdiv {
padding: 5px;
height: 45px;
box-sizing: border-box;
@ -495,94 +502,183 @@
justify-content: space-between;
flex-wrap: wrap;
}
.issue-tag-show{padding: 3px 8px; color: #fff; border-radius: 6px;}
.journal-list-item{padding: 10px}
.issue-tag-show {
padding: 3px 8px;
color: #fff;
border-radius: 6px;
}
.journal-list-item {
padding: 10px;
}
/*.DetailRight > p >span:nth-child(1){*/
/*min-width: 90px;*/
/*margin-right: 15px;*/
/*text-align: right;*/
/*min-width: 90px;*/
/*margin-right: 15px;*/
/*text-align: right;*/
/*}*/
.span_title{
.span_title {
min-width: 40px;
margin-right: 15px;
text-align: right;
color: rgba(0, 0, 0, 0.65);
}
.target-detail-search .ant-input-group-addon{border: none !important;}
.target-detail-search .ant-input-search-button{height: 32px !important;}
a.issue-type-button.active{background: #4CACFF; color: #fff;}
a.issue-type-button.active:hover{background: #f4f4f4; color: #4CACFF;}
@media screen and (max-width: 700px){
.topWrapper_select li{
width:auto;
.target-detail-search .ant-input-group-addon {
border: none !important;
}
.target-detail-search .ant-input-search-button {
height: 32px !important;
}
a.issue-type-button.active {
background: #4cacff;
color: #fff;
}
a.issue-type-button.active:hover {
background: #f4f4f4;
color: #4cacff;
}
@media screen and (max-width: 700px) {
.topWrapper_select li {
width: auto;
}
}
.ml10{margin-left: 10px;}
.lineH32{line-height: 32px;}
.lineH40{line-height: 40px;}
.item-list-right{width: 74%; padding: 0px 15px 10px 0}
.detail_edit_action{padding:10px; color: #999; cursor: pointer; line-height: 40px;}
.attachmentsList{
margin-left:4px;
.ml10 {
margin-left: 10px;
}
.lineH32 {
line-height: 32px;
}
.lineH40 {
line-height: 40px;
}
.item-list-right {
width: 74%;
padding: 0px 15px 10px 0;
}
.detail_edit_action {
padding: 10px;
color: #999;
cursor: pointer;
line-height: 40px;
}
.attachmentsList {
margin-left: 4px;
}
.paper-clip-color {
color: #29bd8b !important;
}
.attachment-list-delete {
display: none;
}
.attachment-list-div:hover {
background-color: #e6f7ff;
}
.attachment-list-div:hover .attachment-list-delete {
display: block !important;
}
.attachment-list-a {
color: rgba(0, 0, 0, 0.65) !important;
}
.btp1 {
border-top: 1px solid #f4f4f4;
}
.paper-clip-color{color:#29bd8b !important}
.attachment-list-delete{display: none;}
.attachment-list-div:hover{background-color: #e6f7ff;}
.attachment-list-div:hover .attachment-list-delete{display: block !important;}
.attachment-list-a{color: rgba(0, 0, 0, 0.65) !important;}
.btp1{border-top: 1px solid #f4f4f4;}
.grid-item{display: grid; align-items: center; grid-template-columns: max-content 1fr;}
.grid-item-left{display: grid; align-items: center; grid-template-columns: 1fr max-content ;}
.fwb{font-weight: bold;}
.grid-item {
display: grid;
align-items: center;
grid-template-columns: max-content 1fr;
}
.grid-item-left {
display: grid;
align-items: center;
grid-template-columns: 1fr max-content;
}
.fwb {
font-weight: bold;
}
/* 发布人、指派人数量过多时要出现滚动条 */
.ant-dropdown-menu{
.ant-dropdown-menu {
max-height: 350px;
overflow-y:auto;
overflow-y: auto;
}
.ql-bubble .ql-editor img{
min-width:100px!important;
.ql-bubble .ql-editor img {
min-width: 100px !important;
}
.AmplifyImg .ant-modal{
padding:0px;
.AmplifyImg .ant-modal {
padding: 0px;
}
.AmplifyImg img{
.AmplifyImg img {
max-width: 100%;
margin: 0px auto;
}
.AmplifyImg .ant-modal-body{
padding:25px;
.AmplifyImg .ant-modal-body {
padding: 25px;
}
.amplifyContent{
.amplifyContent {
text-align: center;
}
.mb-0{margin-bottom: 0 !important;}
.text-yellow{color: #FF6E21;}
.border-1f{border-bottom: 1px solid #f4f4f4;}
.background-f{background: #fff;}
.issue_detail_info{
.mb-0 {
margin-bottom: 0 !important;
}
.text-yellow {
color: #ff6e21;
}
.border-1f {
border-bottom: 1px solid #f4f4f4;
}
.background-f {
background: #fff;
}
.issue_detail_info {
width: 65px;
margin-right: 15px;
text-align: right;
color:#888888;
color: #888888;
}
.list-left-padding{padding: 0 0 0 20px !important;}
.comment-background{
background:rgba(250,250,250,1);
.list-left-padding {
padding: 0 0 0 20px !important;
}
.comment-background {
background: rgba(250, 250, 250, 1);
/* padding: 15px; */
border: 1px solid #f4f4f4;
}
.border-bottom-comment{border-bottom: 1px solid #eee;}
.comment-background .ant-list-header{padding: 20px;}
.comment-background .ant-list-item{padding: 16px;}
.border-bottom-comment {
border-bottom: 1px solid #eee;
}
.comment-background .ant-list-header {
padding: 20px;
}
.comment-background .ant-list-item {
padding: 16px;
}
/* .comment-background .ant-list-split .ant-list-item:last-child{border-bottom: 1px solid #e8e8e8;} */
.border-top-e{border-top: 1px solid #e8e8e8;}
.commentStyle{background-color: #fff !important;}
.reply-comment-input .add_reply_button{background-color: #fff !important; color: #bbb; width: 100%; text-align: left; border: 1px solid rgba(238,238,238,1);
box-shadow: none;}
.children-comment-bg{
background:rgba(241,248,255,1);
border:1px solid rgba(238,238,238,1);
}
.border-top-e {
border-top: 1px solid #e8e8e8;
}
.commentStyle {
background-color: #fff !important;
}
.reply-comment-input .add_reply_button {
background-color: #fff !important;
color: #bbb;
width: 100%;
text-align: left;
border: 1px solid rgba(238, 238, 238, 1);
box-shadow: none;
}
.children-comment-bg {
background: rgba(241, 248, 255, 1);
border: 1px solid rgba(238, 238, 238, 1);
}
.display-in{
display: inherit;
}
.issue-form-right .ant-form-item{
margin-bottom: 8px !important;
}
.issue-form-right .ant-row label{font-size: 14px !important; font-weight: 500;}
.issue-edit-form-right{margin-bottom: 0 !important;}
.plr10{padding: 0 10px;}
.issue-form-index .editormd-toolbar{position: absolute !important;}

View File

@ -37,7 +37,7 @@ class order extends Component {
assigned_to_id: undefined,
search_count: undefined,
issue_type: undefined,
status_type: undefined,
status_type: "1", // 默认显示开启中的
issue_tag_ids: "标签",
tracker_ids: "类型",
author_ids: "发布人",
@ -55,7 +55,7 @@ class order extends Component {
allValue: [],
all: false,
select_params: {
status_type: undefined, //开启中和关闭中,全部,默认为全部
status_type: "1", //开启中和关闭中,全部,默认为全部
assigned_to_id: undefined, // 负责人
author_id: undefined, // 发布人
issue_tag_id: undefined, // 标签

View File

@ -1,318 +1,599 @@
// import React, { Component } from "react";
// import { Form, Input, Select, Spin } from 'antd';
// import { getImageUrl } from 'educoder';
// import UploadComponent from '../Upload/Index';
// import MDEditor from '../../modules/tpm/challengesnew/tpm-md-editor';
import React, { Component } from "react";
import { Form, Input, Select, Button, DatePicker, Switch } from "antd";
import Upload from "../Upload/Index";
import UploadImg from "../Images/upload.png";
import MDEditor from "../../modules/tpm/challengesnew/tpm-md-editor";
import moment from "moment";
import "./order.css";
import Attachments from "../Upload/attachment";
// import './order.css';
import axios from "axios";
// import axios from 'axios';
// import { Link } from "react-router-dom";
const Option = Select.Option;
class order_form extends Component {
constructor(props) {
super(props);
this.state = {
branch_name: "",
issue_tag_ids: "",
fixed_version_id: "",
tracker_id: "缺陷",
issue_type: "1",
status_id: "新增",
assigned_to_id: "",
priority_id: "正常",
done_ratio: "0%",
issue_chosen: undefined,
branches: undefined,
fileList: undefined,
description: undefined,
isSpin: false,
token: undefined,
start_date: "",
due_date: "",
subject: "",
get_attachments: undefined,
show_token: false,
};
}
// const Option = Select.Option;
// class order_form extends Component {
// constructor(props) {
// super(props);
// this.state = {
// branch_name: "",
// issue_tag_ids: "",
// fixed_version_id: "",
// tracker_id: "缺陷",
// issue_type: "普通",
// status_id: '新增',
// assigned_to_id: "",
// priority_id: "正常",
// done_ratio: "0%",
// issue_chosen: undefined,
// branches: undefined,
// fileList: undefined,
// description: undefined,
// isSpin: false
// }
// }
componentDidMount = () => {
this.getSelectList();
this.get_detail();
};
get_detail = () => {
const { form_type } = this.props;
if (form_type === "edit") {
this.state.isSpin = true;
const { projectsId, orderId } = this.props.match.params;
const url = `/projects/${projectsId}/issues/${orderId}/edit.json`;
axios
.get(url)
.then((result) => {
if (result) {
this.setState(
{
branch_name: result.data.branch_name,
issue_tag_ids: [
result.data.issue_tags && result.data.issue_tags[0].id
? String(
result.data.issue_tags && result.data.issue_tags[0].id
)
: "",
],
fixed_version_id: result.data.fixed_version_id
? String(result.data.fixed_version_id)
: "",
tracker_id: result.data.tracker_id
? String(result.data.tracker_id)
: "",
issue_type: result.data.issue_type,
status_id: result.data.status_id
? String(result.data.status_id)
: "",
assigned_to_id: result.data.assigned_to_id
? String(result.data.assigned_to_id)
: "",
priority_id: result.data.priority_id
? String(result.data.priority_id)
: "",
done_ratio: result.data.done_ratio,
fileList: undefined,
description: result.data.description,
isSpin: false,
token: result.data.token,
get_attachments: result.data.attachments,
start_date: result.data.start_date,
due_date: result.data.due_date,
subject: result.data.subject,
},
() => this.InitData()
);
}
})
.catch((error) => {
this.state.isSpin = false;
console.log(error);
});
} else {
this.InitData();
this.getSelectList();
}
};
// componentDidMount = () => {
// // console.log("current_user", this.props.current_user)
// // if (!this.props.checkIfLogin()) {
// // this.props.showLoginDialog();
// // return;
// // }
// this.InitData();
// this.getSelectList();
// }
InitData = () => {
// this.props.form.setFieldsValue({
// ...this.state,
// });
};
// InitData = () => {
// this.props.form.setFieldsValue({
// ...this.state
// });
// }
getSelectList = () => {
let projectsId = "";
if (this.props.match.params.milepostId) {
projectsId = this.props.match.params.projectsId;
this.props.form.setFieldsValue({
fixed_version_id: this.props.match.params.milepostId,
});
} else {
projectsId = this.props.match.params.projectsId;
}
// getSelectList = () => {
// let projectsId = ""
// if (this.props.match.params.milepostId) {
// projectsId = this.props.match.params.projectsId;
// this.props.form.setFieldsValue({
// fixed_version_id: this.props.match.params.milepostId
// });
// } else {
// projectsId = this.props.match.params.projectsId;
// }
const url = `/projects/${projectsId}/issues/new.json`;
axios
.get(url)
.then((result) => {
if (result) {
this.setState({
issue_chosen: result.data.issue_chosen,
branches: result.data.branches,
});
}
})
.catch((error) => {
console.log(error);
});
};
// const url = `/projects/${projectsId}/issues/new.json`;
// axios.get(url).then((result) => {
// if (result) {
// this.setState({
// issue_chosen: result.data.issue_chosen,
// branches: result.data.branches
// })
// }
// }).catch((error) => {
// console.log(error);
// })
// }
renderSelect = (list) => {
if (list && list.length > 0) {
return list.map((item, key) => {
return (
<Option key={key + 1} value={item.id + ""}>
{item.name}
</Option>
);
});
}
};
// renderSelect = (list) => {
// if (list && list.length > 0) {
// return (
// list.map((item, key) => {
// return (
// <Option key={key + 1} value={item.id + ""}>{item.name}</Option>
// )
// })
// )
// }
// }
// 创建
handleSubmit = () => {
this.setState({
isSpin: true,
});
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
const { form_type } = this.props;
const { projectsId, orderId } = this.props.match.params;
// // 创建
// handleSubmit = () => {
// this.setState({
// isSpin: true
// })
// this.props.form.validateFieldsAndScroll((err, values) => {
// if (!err) {
// const { projectsId } = this.props.match.params;
const { fileList } = this.state;
// const { projectsId } = this.props.match.params;
// const { fileList } = this.state;
// const url = `/projects/${projectsId}/issues.json`;
// if (values.status_id === "新增") {
// values.status_id = "1"
// }
// // if(values.issue_type==="普通"){
// // values.issue_type="1"
// // }
// if (values.tracker_id === "缺陷") {
// values.tracker_id = "1"
// }
// if (values.priority_id === "正常") {
// values.priority_id = "2"
// }
// if (values.done_ratio === "0%") {
// values.done_ratio = "0"
// }
// if (values.issue_tag_ids.length > 0) {
// values.issue_tag_ids = [values.issue_tag_ids]
// }
// const { description } = this.state;
if (values.status_id === "新增") {
values.status_id = "1";
}
if (values.tracker_id === "缺陷") {
values.tracker_id = "1";
}
if (values.priority_id === "正常") {
values.priority_id = "2";
}
if (values.done_ratio === "0%") {
values.done_ratio = "0";
}
if (values.issue_tag_ids.length > 0) {
values.issue_tag_ids = [values.issue_tag_ids];
}
const { description, start_date, due_date, issue_type } = this.state;
if (form_type === "new") {
const url = `/projects/${projectsId}/issues.json`;
axios
.post(url, {
...values,
description: description,
attachment_ids: fileList,
start_date: start_date,
due_date: due_date,
issue_type: issue_type,
})
.then((result) => {
if (result) {
this.props.showNotification("任务创建成功!");
this.props.history.push(`/projects/${projectsId}/orders`);
this.setState({
description: "",
isSpin: false,
});
const { getDetail } = this.props;
getDetail && getDetail();
}
})
.catch((error) => {
this.setState({
isSpin: false,
});
console.log(error);
});
} else {
const url = `/projects/${projectsId}/issues/${orderId}.json`;
axios
.put(url, {
description: description,
attachment_ids: fileList,
start_date: start_date,
due_date: due_date,
issue_type: issue_type,
...values,
})
.then((result) => {
if (result) {
this.props.history.push(
`/projects/${projectsId}/orders/${orderId}/detail`
);
this.props.showNotification("任务更新成功!");
}
})
.catch((error) => {
this.setState({
isSpin: false,
});
console.log(error);
});
}
}
this.setState({
isSpin: false,
});
});
};
// axios.post(url, {
// ...values,
// description: description,
// attachment_ids: fileList
// }).then(result => {
// if (result) {
// this.props.showNotification("任务创建成功!");
// this.props.history.push(`/projects/${projectsId}/orders`);
// this.setState({
// description: '',
// isSpin: false
// })
// const { getDetail } = this.props;
// getDetail && getDetail();
// }
// }).catch(error => {
// this.setState({
// isSpin: false
// })
// console.log(error);
// })
// }else{
// this.setState({
// isSpin: false
// })
// }
// })
// }
// 获取上传后的文件id数组
UploadFunc = (fileList) => {
this.setState({
fileList,
});
};
// // 获取上传后的文件id数组
// UploadFunc = (fileList) => {
// this.setState({
// fileList
// })
// }
onContentChange = (value) => {
this.setState({
description: value,
});
};
// 修改开始时间
changeBeginTime = (start_date, value) => {
this.setState({
start_date: value,
});
};
changeEndTime = (due_date, value) => {
this.setState({
due_date: value,
});
};
// 切换完成度
changeRatio = (e) => {
if (e === "0") {
this.props.form.setFieldsValue({
status_id: "1",
});
this.setState({
status_id: "1",
});
} else if (e === "100") {
this.props.form.setFieldsValue({
status_id: "3",
});
this.setState({
status_id: "3",
});
} else {
this.props.form.setFieldsValue({
status_id: "2",
});
this.setState({
status_id: "2",
});
}
};
//切换状态
changeStatus = (e) => {
if (e === "1") {
this.props.form.setFieldsValue({
done_ratio: "0",
});
this.setState({
done_ratio: "0",
});
} else if (e === "3") {
this.props.form.setFieldsValue({
done_ratio: "100",
});
this.setState({
done_ratio: "100",
});
}
};
// onContentChange = (value) => {
// this.setState({
// description: value
// })
// }
//切换是否上链操作
change_issue_type = (e) => {
if (e) {
this.setState({
issue_type: "2",
show_token: true,
});
} else {
this.setState({
issue_type: "1",
show_token: false,
});
}
};
// render() {
// const { getFieldDecorator } = this.props.form;
// const { current_user } = this.props;
// const { description, issue_chosen, branches, isSpin } = this.state;
render() {
const { getFieldDecorator } = this.props.form;
const projectsId = this.props.match.params.projectsId;
const { form_type } = this.props;
const {
issue_tag_ids,
fixed_version_id,
branch_name,
status_id,
tracker_id,
issue_type,
assigned_to_id,
priority_id,
done_ratio,
issue_chosen,
branches,
subject,
description,
get_attachments,
isSpin,
start_date,
due_date,
token,
show_token,
} = this.state;
return (
<div className="ProjectListIndex issue-form-index">
<Form className="width100 display-in" size="small">
<div className="list-right">
<div className="pd20">
<h3 className="mb15">
{form_type === "new" ? "新建" : "编辑"}任务
</h3>
<Form.Item>
{getFieldDecorator("subject", {
rules: [
{
required: true,
message: "请填写任务标题",
},
],
initialValue: subject,
})(<Input placeholder="标题" size="large" />)}
</Form.Item>
<div className="quillContent">
<MDEditor
placeholder={"请输入描述信息"}
height={500}
mdID={"order-new-description"}
initValue={description}
onChange={this.onContentChange}
></MDEditor>
</div>
{get_attachments && get_attachments.length > 0 ? (
<div className="mt20">
<Attachments
attachments={get_attachments}
showNotification={this.props.showNotification}
canDelete={true}
/>
</div>
) : (
""
)}
<Upload
className="commentStyle mt30"
isComplete={true}
load={this.UploadFunc}
icon={
<img
src={UploadImg}
width="58"
alt=""
style={{ marginBottom: 15 }}
/>
}
size={100}
showNotification={this.props.showNotification}
/>
<p className="clearfix mt20 text-right">
<Button
type="primary"
loading={isSpin}
onClick={this.handleSubmit}
size="large"
>
<span className="plr10">
{form_type === "new" ? "创建" : "提交"}
</span>
</Button>
<Button
type="default"
className="ml30"
href={`/projects/${projectsId}/orders`}
size="large"
>
<span className="plr10">取消</span>
</Button>
</p>
</div>
</div>
<div className="list-left list-left-padding issue-edit-form-right">
<div className="pd20 background-f issue-form-right">
<Form.Item>
{getFieldDecorator("branch_name", {
rules: [],
initialValue: branch_name,
})(
<Select>
<Option value={""}>分支未指定</Option>
{branches &&
branches.length > 0 &&
branches.map((item, key) => {
return (
<Option value={item} key={key}>
{item}
</Option>
);
})}
</Select>
)}
</Form.Item>
<Form.Item label="状态">
{getFieldDecorator("status_id", {
rules: [
{
required: true,
message: "请选择完成状态",
},
],
initialValue: status_id,
})(
<Select onChange={this.changeStatus}>
{this.renderSelect(
issue_chosen && issue_chosen.issue_status
)}
</Select>
)}
</Form.Item>
<Form.Item label="类型">
{getFieldDecorator("tracker_id", {
rules: [
{
required: true,
message: "请选择类型",
},
],
initialValue: tracker_id,
})(
<Select>
{this.renderSelect(issue_chosen && issue_chosen.tracker)}
</Select>
)}
</Form.Item>
// return (
// <div className="ProjectListIndex">
// <Form>
// <div className="list-right">
<Form.Item label="优先度">
{getFieldDecorator("priority_id", {
rules: [
{
required: true,
message: "请选择优先度",
},
],
initialValue: priority_id,
})(
<Select>
{this.renderSelect(issue_chosen && issue_chosen.priority)}
</Select>
)}
</Form.Item>
<Form.Item label="完成度">
{getFieldDecorator("done_ratio", {
rules: [
{
required: true,
message: "请选择完成度",
},
],
initialValue: done_ratio,
})(
<Select onChange={this.changeRatio}>
{this.renderSelect(issue_chosen && issue_chosen.done_ratio)}
</Select>
)}
</Form.Item>
<Form.Item label="里程碑">
{getFieldDecorator("fixed_version_id", {
rules: [],
initialValue: fixed_version_id,
})(
<Select>
<Option value={""}>
{issue_chosen && issue_chosen.issue_version.length > 0
? "未选择里程碑"
: "请添加里程碑"}
</Option>
{this.renderSelect(
issue_chosen && issue_chosen.issue_version
)}
</Select>
)}
</Form.Item>
<Form.Item label="标签">
{getFieldDecorator("issue_tag_ids", {
rules: [],
initialValue: issue_tag_ids,
})(
<Select>
<Option value={""}>
{issue_chosen && issue_chosen.issue_tag.length > 0
? "未选择标签"
: "请在仓库设置里添加标签"}
</Option>
{this.renderSelect(issue_chosen && issue_chosen.issue_tag)}
</Select>
)}
</Form.Item>
// </div>
// <div className="list-left list-left-padding">
// </div>
// <div className="f-wrap-between mt20" style={{ alignItems: "flex-start" }}>
// <div className="list-right df">
// <Link to={`/users/${current_user && current_user.login}/projects`} className="show-user-link">
// <img className="user_img" src={getImageUrl(`images/${current_user && current_user.image_url}`)} alt="" />
// </Link>
// <div className="new_context">
// <Form.Item>
// {getFieldDecorator('subject', {
// rules: [{
// required: true, message: '请填写任务标题'
// }],
// })(
// <Input placeholder="标题" />
// )}
// </Form.Item>
// <div className="quillContent" style={{ marginBottom: "20px" }}>
// <MDEditor placeholder={'请输入描述信息'} height={350}
// mdID={'order-new-description'} initValue={description} onChange={this.onContentChange} ></MDEditor>
// </div>
// <UploadComponent load={this.UploadFunc} showNotification={this.props.showNotification} isComplete={true} size={100}></UploadComponent>
// <p className="clearfix mt15">
// <Spin spinning={isSpin}>
// <a className="topWrapper_btn fr" type="submit" onClick={this.handleSubmit}>创建任务</a>
// </Spin>
// </p>
// </div>
// </div>
// <div className="list-left mt10" style={{ paddingRight: "0px", paddingLeft: "0px", width: "25%", backgroundColor: "#fff" }}>
// <div className="list-l-panel">
// <Form.Item>
// {getFieldDecorator('branch_name', {
// rules: [],
// })(
// <Select>
// <Option value={''}>分支未指定</Option>
// {
// branches && branches.length > 0 && branches.map((item, key) => {
// return (
// <Option value={item}>{item}</Option>
// )
// })
// }
// </Select>
// )}
// </Form.Item>
// <Form.Item
// label="标签"
// >
// {getFieldDecorator('issue_tag_ids', {
// rules: [],
// })(
// <Select>
// <Option value={""}>{issue_chosen && issue_chosen.issue_tag.length > 0 ? '未选择标签' : '请在仓库设置里添加标签'}</Option>
// {this.renderSelect(issue_chosen && issue_chosen.issue_tag)}
// </Select>
// )}
// </Form.Item>
// <Form.Item
// label="里程碑"
// >
// {getFieldDecorator('fixed_version_id', {
// rules: [],
// })(
// <Select>
// <Option value={""}>{issue_chosen && issue_chosen.issue_version.length > 0 ? '未选择里程碑' : '请添加里程碑'}</Option>
// {this.renderSelect(issue_chosen && issue_chosen.issue_version)}
// </Select>
// )}
// </Form.Item>
// <Form.Item
// label="状态"
// >
// {getFieldDecorator('status_id', {
// rules: [{
// required: true, message: '请选择完成状态'
// }],
// })(
// <Select>
// {this.renderSelect(issue_chosen && issue_chosen.issue_status)}
// </Select>
// )}
// </Form.Item>
// <Form.Item
// label="分类"
// >
// {getFieldDecorator('tracker_id', {
// rules: [{
// required: true, message: '请选择分类'
// }],
// })(
// <Select>
// {this.renderSelect(issue_chosen && issue_chosen.tracker)}
// </Select>
// )}
// </Form.Item>
// <Form.Item
// label="指派成员"
// >
// {getFieldDecorator('assigned_to_id', {
// rules: [{
// }],
// })(
// <Select>
// <Option value={""}>未指派成员</Option>
// {this.renderSelect(issue_chosen && issue_chosen.assign_user)}
// </Select>
// )}
// </Form.Item>
// <Form.Item
// label="优先度"
// >
// {getFieldDecorator('priority_id', {
// rules: [{
// required: true, message: '请选择优先度'
// }],
// })(
// <Select>
// {this.renderSelect(issue_chosen && issue_chosen.priority)}
// </Select>
// )}
// </Form.Item>
// <Form.Item
// label="完成度"
// >
// {getFieldDecorator('done_ratio', {
// rules: [{
// required: true, message: '请选择完成度'
// }],
// })(
// <Select>
// {this.renderSelect(issue_chosen && issue_chosen.done_ratio)}
// </Select>
// )}
// </Form.Item>
// </div>
// </div>
// </div>
// </Form>
// </div>
// )
// }
// }
// const WrappedNewForm = Form.create({ name: 'NewOrderForm' })(order_form);
// export default WrappedNewForm;
<Form.Item label="指派成员">
{getFieldDecorator("assigned_to_id", {
rules: [{}],
initialValue: assigned_to_id,
})(
<Select>
<Option value={""}>未指派成员</Option>
{this.renderSelect(
issue_chosen && issue_chosen.assign_user
)}
</Select>
)}
</Form.Item>
<Form.Item label="开始日期">
<DatePicker
value={start_date ? moment(start_date, "YYYY-MM-DD") : null}
style={{ width: "100%" }}
placeholder="请选择开始日期"
onChange={this.changeBeginTime}
/>
</Form.Item>
<Form.Item label="结束日期">
<DatePicker
value={due_date ? moment(due_date, "YYYY-MM-DD") : null}
style={{ width: "100%" }}
placeholder="请选择结束日期"
onChange={this.changeEndTime}
/>
</Form.Item>
<Form.Item label="是否上链">
<Switch
checkedChildren="是"
unCheckedChildren="否"
defaultChecked={false}
checked={issue_type && issue_type === "2"}
onChange={this.change_issue_type}
/>
</Form.Item>
{(show_token || (issue_type && issue_type === "2")) && (
<Form.Item label="token">
{getFieldDecorator("token", {
rules: [
{
required: true,
message: "请填写token值",
},
],
initialValue: token,
})(<Input placeholder="请填写token值" />)}
</Form.Item>
)}
</div>
</div>
</Form>
</div>
);
}
}
const WrappedNewForm = Form.create({ name: "NewOrderForm" })(order_form);
export default WrappedNewForm;