|
@@ -1,27 +1,21 @@
|
|
|
import React from 'react';
|
|
|
-import { Icon, Modal, Button, Form, message, Input, Spin, Select, Checkbox, InputNumber } from 'antd';
|
|
|
+import { Icon, Modal, Button, Form, message, Input, Spin, Select, Checkbox, InputNumber, DatePicker } from 'antd';
|
|
|
import './contract.less';
|
|
|
import { companySearch } from '../../../tools.js';
|
|
|
import ajax from 'jquery/src/ajax/xhr.js'
|
|
|
import $ from 'jquery/src/ajax';
|
|
|
|
|
|
const ContractAddFrom = Form.create()(React.createClass({
|
|
|
- getContactsList(theUid) {
|
|
|
+ getContactsList() {
|
|
|
$.ajax({
|
|
|
method: "get",
|
|
|
dataType: "json",
|
|
|
crossDomain: false,
|
|
|
- url: globalConfig.context + "/api/admin/getContacts",
|
|
|
- data: {
|
|
|
- uid: theUid || this.state.uid
|
|
|
- },
|
|
|
+ url: globalConfig.context + "/api/user/cognizance/getContacts",
|
|
|
success: function (data) {
|
|
|
let theOption = [];
|
|
|
- if (!data.data) {
|
|
|
- if (data.error && data.error.length) {
|
|
|
- message.warning(data.error[0].message);
|
|
|
- return;
|
|
|
- };
|
|
|
+ if (data.error.length || !data.data) {
|
|
|
+ return;
|
|
|
};
|
|
|
for (let item in data.data) {
|
|
|
let theData = data.data[item];
|
|
@@ -44,6 +38,39 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
visible: "visible"
|
|
|
};
|
|
|
},
|
|
|
+ loadData(id) {
|
|
|
+ this.setState({
|
|
|
+ loading: true
|
|
|
+ });
|
|
|
+ $.ajax({
|
|
|
+ method: "get",
|
|
|
+ dataType: "json",
|
|
|
+ crossDomain: false,
|
|
|
+ cache: false,
|
|
|
+ url: globalConfig.context + "/api/admin/contract/detail",
|
|
|
+ data: {
|
|
|
+ id: id || this.props.data.id
|
|
|
+ }
|
|
|
+ }).done((data) => {
|
|
|
+ if (!data.data) {
|
|
|
+ if (data.error && data.error.length) {
|
|
|
+ message.warning(data.error[0].message);
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ this.setState({
|
|
|
+ data: data.data,
|
|
|
+ patentCheck: data.data.patentNum ? true : false,
|
|
|
+ copyrightCheck: data.data.copyrightNum ? true : false,
|
|
|
+ highTechCheck: data.data.cognizanceYear ? true : false,
|
|
|
+ techProjectCheck: data.data.techProjectNum ? true : false,
|
|
|
+ });
|
|
|
+ };
|
|
|
+ }).always(function () {
|
|
|
+ this.setState({
|
|
|
+ loading: false
|
|
|
+ });
|
|
|
+ }.bind(this));
|
|
|
+ },
|
|
|
componentWillMount() {
|
|
|
let d = new Date(), _me = this, theArr = [];
|
|
|
d = d.getFullYear() - 1;
|
|
@@ -53,23 +80,35 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
)
|
|
|
};
|
|
|
this.state.yearOption = theArr;
|
|
|
- },
|
|
|
- componentWillReceiveProps(nextProps) {
|
|
|
- if (!this.props.visible && nextProps.visible) {
|
|
|
+ if (this.props.data.id) {
|
|
|
+ this.getContactsList();
|
|
|
+ this.loadData(this.props.data.id);
|
|
|
+ } else {
|
|
|
+ this.state.data = {};
|
|
|
this.state.patentCheck = false;
|
|
|
this.state.copyrightCheck = false;
|
|
|
this.state.highTechCheck = false;
|
|
|
this.state.techProjectCheck = false;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ componentWillReceiveProps(nextProps) {
|
|
|
+ if (!this.props.visible && nextProps.visible) {
|
|
|
+ if (nextProps.data.id) {
|
|
|
+ this.getContactsList();
|
|
|
+ this.loadData(nextProps.data.id);
|
|
|
+ } else {
|
|
|
+ this.state.data = {};
|
|
|
+ this.state.patentCheck = false;
|
|
|
+ this.state.copyrightCheck = false;
|
|
|
+ this.state.highTechCheck = false;
|
|
|
+ this.state.techProjectCheck = false;
|
|
|
+ };
|
|
|
this.props.form.resetFields();
|
|
|
};
|
|
|
},
|
|
|
handleSave(e) {
|
|
|
e.preventDefault();
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
- if (!values.uid || values.uid === "") {
|
|
|
- message.warning('请先选择公司!');
|
|
|
- return;
|
|
|
- };
|
|
|
if (!err) {
|
|
|
this.props.spinState(true);
|
|
|
$.ajax({
|
|
@@ -78,14 +117,15 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
crossDomain: false,
|
|
|
url: globalConfig.context + "/api/admin/contract/apply",
|
|
|
data: {
|
|
|
- "uid": values.uid,
|
|
|
+ "uid": this.state.data.uid || values.uid,
|
|
|
+ "id": this.state.data.id,
|
|
|
"contacts": values.contacts, //联系人
|
|
|
"type": values.type, //合同类型
|
|
|
"depict": values.depict, // "合同描述",
|
|
|
- "patentNum": this.state.patentCheck ? values.patentNum : undefined,
|
|
|
- "copyrightNum": this.state.copyrightCheck ? values.copyrightNum : undefined,
|
|
|
+ "patentNum": this.state.patentCheck ? values.patentNum : 0,
|
|
|
+ "copyrightNum": this.state.copyrightCheck ? values.copyrightNum : 0,
|
|
|
"cognizanceYear": this.state.highTechCheck ? values.cognizanceYear : undefined,
|
|
|
- "techProjectNum": this.state.techProjectCheck ? values.techProjectNum : undefined,
|
|
|
+ "techProjectNum": this.state.techProjectCheck ? values.techProjectNum : 0,
|
|
|
"comment": values.comment //"备注"
|
|
|
}
|
|
|
}).done(function (data) {
|
|
@@ -103,49 +143,10 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- handleSubmit() {
|
|
|
- this.props.form.validateFields((err, values) => {
|
|
|
- if (!values.uid || values.uid === "") {
|
|
|
- message.warning('请先选择公司!');
|
|
|
- return;
|
|
|
- };
|
|
|
- if (!err) {
|
|
|
- this.props.spinState(true);
|
|
|
- $.ajax({
|
|
|
- method: "POST",
|
|
|
- dataType: "json",
|
|
|
- crossDomain: false,
|
|
|
- url: globalConfig.context + "/api/admin/contract/submit",
|
|
|
- data: {
|
|
|
- "uid": values.uid,
|
|
|
- "contacts": values.contacts, //联系人
|
|
|
- "type": values.type, //合同类型
|
|
|
- "depict": values.depict, // "合同描述",
|
|
|
- "patentNum": this.state.patentCheck ? values.patentNum : undefined,
|
|
|
- "copyrightNum": this.state.copyrightCheck ? values.copyrightNum : undefined,
|
|
|
- "cognizanceYear": this.state.highTechCheck ? values.cognizanceYear : undefined,
|
|
|
- "techProjectNum": this.state.techProjectCheck ? values.techProjectNum : undefined,
|
|
|
- "principals": values.principals,
|
|
|
- "comment": values.comment //"备注"
|
|
|
- }
|
|
|
- }).done(function (data) {
|
|
|
- if (!data.error.length) {
|
|
|
- message.success('提交成功!');
|
|
|
- this.props.okClick();
|
|
|
- this.props.closeModal();
|
|
|
- this.props.form.resetFields();
|
|
|
- } else {
|
|
|
- message.warning(data.error[0].message);
|
|
|
- }
|
|
|
- }.bind(this)).always(function () {
|
|
|
- this.props.spinState(false);
|
|
|
- }.bind(this));
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
render() {
|
|
|
const FormItem = Form.Item;
|
|
|
const { getFieldDecorator } = this.props.form;
|
|
|
+ const theData = this.state.data || {};
|
|
|
const formItemLayout = {
|
|
|
labelCol: { span: 6 },
|
|
|
wrapperCol: { span: 14 },
|
|
@@ -157,49 +158,45 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
<FormItem className="half-item"
|
|
|
{...formItemLayout}
|
|
|
label="公司名称" >
|
|
|
- {getFieldDecorator('uid')(
|
|
|
- <Select
|
|
|
- placeholder="请选择公司"
|
|
|
- notFoundContent="未找到公司"
|
|
|
- style={{ width: 260 }}
|
|
|
- showSearch
|
|
|
- filterOption={companySearch}
|
|
|
- onSelect={(e, n) => { this.getContactsList(e); }}>
|
|
|
- {this.props.companyOption}
|
|
|
- </Select>
|
|
|
- )}
|
|
|
+ <span>{theData.unitName}</span>
|
|
|
</FormItem>
|
|
|
<FormItem className="half-item"
|
|
|
{...formItemLayout}
|
|
|
label="联系人" >
|
|
|
- {getFieldDecorator('contacts')(
|
|
|
+ {getFieldDecorator('contacts', {
|
|
|
+ initialValue: theData.contacts
|
|
|
+ })(
|
|
|
<Select placeholder="请选择联系人"
|
|
|
style={{ width: 260 }}
|
|
|
notFoundContent="未获取到联系人列表">
|
|
|
{this.state.contactsOption}
|
|
|
</Select>
|
|
|
- )}
|
|
|
+ )}
|
|
|
</FormItem>
|
|
|
<FormItem className="half-item"
|
|
|
{...formItemLayout}
|
|
|
label="合同类型" >
|
|
|
- {getFieldDecorator('type')(
|
|
|
+ {getFieldDecorator('type', {
|
|
|
+ initialValue: theData.type
|
|
|
+ })(
|
|
|
<Select placeholder="请选择合同类型"
|
|
|
style={{ width: 260 }}>
|
|
|
{this.props.typeOption}
|
|
|
</Select>
|
|
|
- )}
|
|
|
+ )}
|
|
|
</FormItem>
|
|
|
</div>
|
|
|
<FormItem
|
|
|
labelCol={{ span: 3 }}
|
|
|
wrapperCol={{ span: 19 }}
|
|
|
label="合同描述" >
|
|
|
- {getFieldDecorator('depict')(
|
|
|
+ {getFieldDecorator('depict', {
|
|
|
+ initialValue: theData.depict
|
|
|
+ })(
|
|
|
<Input type="textarea"
|
|
|
placeholder="多行输入"
|
|
|
rows={4} />
|
|
|
- )}
|
|
|
+ )}
|
|
|
</FormItem>
|
|
|
<div className="clearfix">
|
|
|
<span style={{ float: "left", lineHeight: '32px', marginLeft: '50px' }}>
|
|
@@ -210,13 +207,15 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
<FormItem className="half-item"
|
|
|
{...formItemLayout}
|
|
|
label={"高企申请"} >
|
|
|
- {getFieldDecorator('cognizanceYear')(
|
|
|
+ {getFieldDecorator('cognizanceYear', {
|
|
|
+ initialValue: theData.cognizanceYear || undefined
|
|
|
+ })(
|
|
|
<Select placeholder="请选择年份"
|
|
|
style={{ width: 120 }}
|
|
|
onSelect={(e, n) => { this.setState({ year: e }); }}>
|
|
|
{this.state.yearOption}
|
|
|
</Select>
|
|
|
- )}
|
|
|
+ )}
|
|
|
</FormItem>
|
|
|
</div>
|
|
|
<div className="clearfix">
|
|
@@ -228,9 +227,11 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
<FormItem className="half-item"
|
|
|
{...formItemLayout}
|
|
|
label={"专利申请"} >
|
|
|
- {getFieldDecorator('patentNum')(
|
|
|
+ {getFieldDecorator('patentNum', {
|
|
|
+ initialValue: theData.patentNum
|
|
|
+ })(
|
|
|
<InputNumber />
|
|
|
- )}
|
|
|
+ )}
|
|
|
</FormItem>
|
|
|
</div>
|
|
|
<div className="clearfix">
|
|
@@ -242,9 +243,11 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
<FormItem className="half-item"
|
|
|
{...formItemLayout}
|
|
|
label={"软著申请"} >
|
|
|
- {getFieldDecorator('copyrightNum')(
|
|
|
+ {getFieldDecorator('copyrightNum', {
|
|
|
+ initialValue: theData.copyrightNum
|
|
|
+ })(
|
|
|
<InputNumber />
|
|
|
- )}
|
|
|
+ )}
|
|
|
</FormItem>
|
|
|
</div>
|
|
|
<div className="clearfix">
|
|
@@ -256,9 +259,11 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
<FormItem className="half-item"
|
|
|
{...formItemLayout}
|
|
|
label={"科技项目申请"} >
|
|
|
- {getFieldDecorator('techProjectNum')(
|
|
|
+ {getFieldDecorator('techProjectNum', {
|
|
|
+ initialValue: theData.techProjectNum
|
|
|
+ })(
|
|
|
<InputNumber />
|
|
|
- )}
|
|
|
+ )}
|
|
|
</FormItem>
|
|
|
</div>
|
|
|
<div className="clearfix">
|
|
@@ -277,20 +282,29 @@ const ContractAddFrom = Form.create()(React.createClass({
|
|
|
</Select>
|
|
|
)}
|
|
|
</FormItem>
|
|
|
+ <FormItem className="half-item"
|
|
|
+ {...formItemLayout}
|
|
|
+ label="处理时间"
|
|
|
+ >
|
|
|
+ {getFieldDecorator('recordTime')(
|
|
|
+ <DatePicker />
|
|
|
+ )}
|
|
|
+ </FormItem>
|
|
|
</div>
|
|
|
<FormItem
|
|
|
labelCol={{ span: 3 }}
|
|
|
wrapperCol={{ span: 19 }}
|
|
|
label="备注" >
|
|
|
- {getFieldDecorator('comment')(
|
|
|
+ {getFieldDecorator('comment', {
|
|
|
+ initialValue: theData.comment
|
|
|
+ })(
|
|
|
<Input type="textarea"
|
|
|
placeholder="多行输入"
|
|
|
rows={2} />
|
|
|
- )}
|
|
|
+ )}
|
|
|
</FormItem>
|
|
|
<FormItem style={{ paddingLeft: '40px' }}>
|
|
|
- <Button className="set-submit" type="primary" htmlType="submit">保存草稿</Button>
|
|
|
- <Button onClick={this.handleSubmit} type="ghost" style={{ marginLeft: '20px' }}>提交</Button>
|
|
|
+ <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
|
|
|
<Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
|
|
|
</FormItem>
|
|
|
</Form >
|
|
@@ -310,6 +324,7 @@ const ContractAdd = React.createClass({
|
|
|
showModal() {
|
|
|
this.setState({
|
|
|
visible: true,
|
|
|
+ data: {}
|
|
|
});
|
|
|
},
|
|
|
handleCancel(e) {
|
|
@@ -318,6 +333,12 @@ const ContractAdd = React.createClass({
|
|
|
});
|
|
|
this.props.closeAdd(false);
|
|
|
},
|
|
|
+ componentWillReceiveProps(nextProps) {
|
|
|
+ if (nextProps.showAdd && nextProps.data) {
|
|
|
+ this.state.data = nextProps.data;
|
|
|
+ };
|
|
|
+ this.state.visible = nextProps.showAdd;
|
|
|
+ },
|
|
|
spinChange(e) {
|
|
|
this.setState({
|
|
|
loading: e
|
|
@@ -328,7 +349,7 @@ const ContractAdd = React.createClass({
|
|
|
<div className="patent-addNew">
|
|
|
<Button className="patent-addNew" type="primary" onClick={this.showModal}>申请合同<Icon type="plus" /></Button>
|
|
|
<Spin spinning={this.state.loading} className='spin-box'>
|
|
|
- <Modal title="申请新合同"
|
|
|
+ <Modal title="合同详情"
|
|
|
visible={this.state.visible}
|
|
|
onCancel={this.handleCancel}
|
|
|
width='800px'
|
|
@@ -338,6 +359,7 @@ const ContractAdd = React.createClass({
|
|
|
spinState={this.spinChange}
|
|
|
closeModal={this.handleCancel}
|
|
|
visible={this.state.visible}
|
|
|
+ data={this.state.data}
|
|
|
okClick={() => { this.props.closeAdd(false, true) }}
|
|
|
companyOption={this.props.companyOption}
|
|
|
authorOption={this.props.authorOption}
|