import React from 'react';
import { Icon, Form, Button, Input, Spin, Table, message, Modal, Upload, DatePicker } from 'antd';
import './techProduct.less';
import { beforeUploadFile, newDownloadFile } from '../../tools.js';
import moment from 'moment';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
const CenterListDescFrom = Form.create()(React.createClass({
getInitialState() {
return {
loading: false,
fileList_protocol: []
};
},
handleSubmit(e) {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
this.props.spinState(true);
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/user/cognizance/disposeCenterDetail",
data: {
id: this.props.data.id,
cid: this.props.cid,
projectName: values.projectName,
projectTimeFormattedDate: values.projectTimeFormattedDate ? values.projectTimeFormattedDate.format("YYYY-MM-DD") : null,
institution: values.institution,
termStartTimeFormattedDate: values.termTimeFormattedDate ? values.termTimeFormattedDate[0].format("YYYY-MM-DD") : null,
termEndTimeFormattedDate: values.termTimeFormattedDate ? values.termTimeFormattedDate[1].format("YYYY-MM-DD") : null,
protocolUrl: this.state.protocolUrl
}
}).done(function (data) {
if (!data.error.length) {
message.success('保存成功!');
this.props.clickOk();
this.props.spinState(false);
this.props.form.resetFields();
} else {
message.warning(data.error[0].message);
this.props.spinState(false);
}
}.bind(this));
}
});
},
componentWillReceiveProps(nextProps) {
if (!this.props.visible && nextProps.visible) {
this.props.form.resetFields();
this.state.fileList_protocol = [];
this.state.protocolUrl = undefined;
};
},
render() {
const FormItem = Form.Item;
const { getFieldDecorator } = this.props.form;
const { RangePicker } = DatePicker;
const theData = this.props.data;
const formItemLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 14 },
};
const _me = this;
return (
);
},
}));
const CenterListDesc = React.createClass({
getInitialState() {
return {
visible: false,
loading: false
};
},
componentWillReceiveProps(nextProps) {
this.state.visible = nextProps.showDesc
},
showModal() {
this.setState({
visible: true,
});
},
handleOk() {
this.setState({
visible: false,
});
this.props.closeDesc(false, true);
},
handleCancel(e) {
this.setState({
visible: false,
});
this.props.closeDesc(false);
},
spinChange(e) {
this.setState({
loading: e
});
},
render() {
return (
);
}
});
const CenterList = React.createClass({
loadOrgTechCenterDetail() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/user/cognizance/center",
data: {
}
}).done((data) => {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
this.state.ButtonDisabled = true;
}
return;
};
this.state.cid = data.data.id;
this.state.foundingTime = data.data.foundingTimeFormattedDate;
this.state.principal = data.data.principal;
this.state.systemCatalog = data.data.systemCatalog;
this.state.systemUrl = data.data.systemUrl;
this.state.systemDownloadFileName = data.data.systemDownloadFileName;
this.state.centerName = data.data.centerName;
this.state.comment = data.data.comment;
this.loadData();
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
loadData(pageNo) {
this.state.data = [];
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/user/cognizance/centerDetail",
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize,
cid: this.state.cid
}
}).done((data) => {
if (!data.data || !data.data.list) {
if (data.error.length) {
message.warning(data.error[0].message);
}
return;
};
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
this.state.data.push({
key: i,
id: thisdata.id,
cid: thisdata.cid,
projectTimeFormattedDate: thisdata.projectTimeFormattedDate,
projectName: thisdata.projectName,
protocolDownloadFileName: thisdata.protocolDownloadFileName,
protocolUrl: thisdata.protocolUrl,
protocol: [thisdata.id, thisdata.protocolDownloadFileName],
institution: thisdata.institution,
termTimeFormattedDate: [thisdata.termStartTimeFormattedDate, thisdata.termEndTimeFormattedDate],
termStartTimeFormattedDate: thisdata.termStartTimeFormattedDate,
termEndTimeFormattedDate: thisdata.termEndTimeFormattedDate
});
};
this.state.pagination.current = data.data.pageNo;
this.state.pagination.total = data.data.totalCount;
this.setState({
dataSource: this.state.data,
pagination: this.state.pagination
});
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getInitialState() {
return {
selectedRowKeys: [],
selectedRows: [],
loading: false,
pagination: {
defaultCurrent: 1,
defaultPageSize: 10,
showQuickJumper: true,
pageSize: 10,
onChange: function (page) {
this.loadData(page);
}.bind(this),
showTotal: function (total) {
return '共' + total + '条数据';
}
},
columns: [
{
title: '时间',
dataIndex: 'projectTimeFormattedDate',
key: 'projectTimeFormattedDate'
}, {
title: '项目名称',
dataIndex: 'projectName',
key: 'projectName'
}, {
title: '期限',
dataIndex: 'termTimeFormattedDate',
key: 'termTimeFormattedDate',
render: (text) => {
return text[0] + ' - ' + text[1];
}
}, {
title: '科研院所',
dataIndex: 'institution',
key: 'institution'
}, {
title: '协议附件',
dataIndex: 'protocol',
key: 'protocol',
render: (text) => {
return {text[1]}
}
}
],
dataSource: []
};
},
componentWillMount() {
this.loadOrgTechCenterDetail();
},
tableRowClick(record, index) {
this.state.RowData = record;
this.setState({
showDesc: true
});
},
delectRow() {
let deletedIds = [];
for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
let rowItem = this.state.selectedRows[idx];
if (rowItem.id) {
deletedIds.push(rowItem.id)
}
};
this.setState({
selectedRowKeys: [],
loading: deletedIds.length > 0
});
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/user/cognizance/deleteOrgTechCenterDetail",
data: {
ids: deletedIds
}
}).done(function (data) {
if (!data.error.length) {
message.success('删除成功!');
this.setState({
loading: false,
});
} else {
message.warning(data.error[0].message);
};
this.loadData();
}.bind(this));
},
closeDesc(e, s) {
this.state.showDesc = e;
if (s) {
this.loadData();
};
},
saveCenterDetail() {
if (!this.state.centerName) {
message.warning('研发部门名称不能为空!');
return;
};
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/user/cognizance/disposeCenter",
data: {
id: this.state.cid,
principal: this.state.principal,
systemUrl: this.state.systemUrl,
systemCatalog: this.state.systemCatalog,
foundingTimeFormattedDate: this.state.foundingTime,
comment: this.state.comment,
centerName: this.state.centerName
}
}).done((data) => {
if (!data.error.length) {
message.success('保存成功!');
this.loadOrgTechCenterDetail();
this.setState({
loading: false,
});
} else {
message.warning(data.error[0].message);
};
});
},
render() {
const rowSelection = {
selectedRowKeys: this.state.selectedRowKeys,
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
selectedRows: selectedRows,
selectedRowKeys: selectedRowKeys
});
}
};
const hasSelected = this.state.selectedRowKeys.length > 0;
return (
研发部门
制度上传: (上传 zip 或者 rar 文件)
{
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
if (!info.file.response.error.length) {
message.success(`${info.file.name} 文件上传成功!`);
} else {
message.warning(info.file.response.error[0].message);
return;
};
this.state.systemUrl = info.file.response.data;
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 文件上传失败。`);
};
this.setState({ fileList_institution: info.fileList.slice(-1) });
}} >
{this.state.systemUrl ? {this.state.systemDownloadFileName} : 未上传!}
产学研情况
);
}
});
export default CenterList;