123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- import React from 'react';
- import { Icon, Modal, Button, Form, message, Input, Spin, Select, DatePicker, Upload } from 'antd';
- import { intellectualGetList, catagoryList } from '../../../../dataDic.js';
- import { beforeUploadFile, newDownloadFile, getPreview } from '../../../../tools.js';
- import ajax from 'jquery/src/ajax/xhr.js'
- import $ from 'jquery/src/ajax';
- import moment from 'moment';
- const IntellectualDescFrom = Form.create()(React.createClass({
- loadData(id, type) {
- this.props.spinState(true);
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/admin/intellectualDetail",
- data: {
- id: id ? id : this.props.data.id,
- type: type != undefined && type != null ? type : this.props.data.type
- }
- }).done((data) => {
- if (!data.data) {
- if (data.error && data.error.length) {
- message.warning(data.error[0].message);
- };
- this.state.data = {};
- } else { this.state.data = data.data };
- }).always(function () {
- this.props.spinState(false);
- }.bind(this));
- },
- getInitialState() {
- return {
- loading: false,
- intellectualGetOption: [],
- catagoryOption: [],
- data: {}
- };
- },
- componentWillMount() {
- let _me = this;
- intellectualGetList.map(function (item) {
- _me.state.intellectualGetOption.push(
- <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
- )
- });
- catagoryList.map(function (item) {
- _me.state.catagoryOption.push(
- <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
- )
- });
- if (this.props.data.id && this.props.data.type != undefined && this.props.data.type != null) {
- this.loadData();
- };
- },
- 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/admin/intellectual",
- data: {
- id: this.props.data.id,
- uid: this.props.uid,
- intellectualPropertyNumber: values.intellectualPropertyNumber,
- intellectualPropertyName: values.intellectualPropertyName,
- catagory: values.catagory,
- obtainWay: values.obtainWay,
- sortNumber: values.sortNumber,
- authorizationNumber: values.authorizationNumber,
- authorizationDateFormattedDate: values.authorizationDate._i || this.state.authorizationDateFormattedDate,
- propertyRightUrl: this.state.propertyRightUrl
- }
- }).done(function (data) {
- if (!data.error.length) {
- message.success('保存成功!');
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this)).always(function () {
- this.props.spinState(false);
- this.props.clickOk();
- this.props.form.resetFields();
- }.bind(this));
- }
- });
- },
- componentWillReceiveProps(nextProps) {
- if (!this.props.visible && nextProps.visible) {
- if (nextProps.data.id && nextProps.data.type != undefined && nextProps.data.type != null) {
- this.loadData(nextProps.data.id, nextProps.data.type);
- };
- this.state.data = {};
- this.state.fileList = [];
- this.state.propertyRightUrl = undefined;
- };
- },
- render() {
- const FormItem = Form.Item;
- const { getFieldDecorator } = this.props.form;
- const formItemLayout = {
- labelCol: { span: 6 },
- wrapperCol: { span: 12 },
- };
- const _me = this;
- const theData = this.state.data;
- return (
- <Form horizontal onSubmit={this.handleSubmit}>
- <FormItem
- {...formItemLayout}
- label="知识产权编号"
- >
- {getFieldDecorator('intellectualPropertyNumber', {
- rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }],
- initialValue: theData.intellectualPropertyNumber
- })(
- <Input placeholder="请输入知识产权编号" />
- )}
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="知识产权名称"
- >
- {getFieldDecorator('intellectualPropertyName', {
- rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }],
- initialValue: theData.intellectualPropertyName
- })(
- <Input placeholder="请输入知识产权名称" />
- )}
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="排序号"
- >
- {getFieldDecorator('sortNumber', {
- rules: [{ required: true, message: '请输入,排序号不能为空!' }],
- initialValue: theData.sortNumber
- })(
- <Input placeholder="请输入排序号" />
- )}
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="知识产权类型"
- >
- {getFieldDecorator('catagory', {
- rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }],
- initialValue: theData.catagory
- })(
- <Select placeholder="请选择知识产权类型" style={{ width: 200 }}
- onChange={(e) => { this.state.catagory = e; }}>
- {this.state.catagoryOption}
- </Select>
- )}
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="获得方式"
- >
- {getFieldDecorator('obtainWay', {
- rules: [{ required: true, message: '请选择,获得方式不能为空!' }],
- initialValue: theData.obtainWay
- })(
- <Select placeholder="请选择获得方式" style={{ width: 200 }}
- onChange={(e) => { this.state.obtainWay = e; }}>
- {this.state.intellectualGetOption}
- </Select>
- )}
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="授权号"
- >
- {getFieldDecorator('authorizationNumber', {
- rules: [{ required: true, message: '请输入,授权号不能为空!' }],
- initialValue: theData.authorizationNumber
- })(
- <Input placeholder="请输入授权号" />
- )}
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="授权日期"
- >
- {getFieldDecorator('authorizationDate', {
- rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }],
- initialValue: !theData.authorizationDateFormattedDate ? null : moment(theData.authorizationDateFormattedDate, 'YYYY/MM/DD')
- })(
- <DatePicker style={{ width: 200 }}
- onChange={(data, dataString) => { this.state.authorizationDateFormattedDate = dataString }} />
- )}
- </FormItem>
- <div className="hrSituation-roster">
- <Upload
- name="ratepay"
- action={globalConfig.context + "/api/admin/uploadPropertyRight"}
- data={{ 'sign': 'property_right', 'uid': this.props.uid }}
- beforeUpload={beforeUploadFile}
- fileList={this.state.fileList}
- onChange={(info) => {
- 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.propertyRightUrl = info.file.response.data;
- } else if (info.file.status === 'error') {
- message.error(`${info.file.name} 文件上传失败。`);
- };
- this.setState({ fileList: info.fileList.slice(-1) });
- }}
- >
- <Button><Icon type="upload" /> 上传知识产权证书 </Button>
- </Upload>
- <p style={{ margin: '10px 0' }}>
- {theData.propertyRightUrl ?
- <span className="download-file">
- <a onClick={newDownloadFile.bind(null, this.props.data.id, 'property_right', '/api/admin/downloadPropertyRight')}>{theData.propertyRightDownloadFileName}</a>
- <a onClick={() => {
- var newTab = window.open('about:blank'); getPreview(theData.id, 'intellectualProperty', 'property_right', function (data) {
- newTab.location.href = data;
- });
- }}><Icon style={{ fontSize: '16px' }} type="eye-o" /></a>
- </span>
- : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传知识产权证书!</span>}
- </p>
- {theData.type != 0 ? <p style={{ margin: '10px 0' }}>
- {theData.manuscript ?
- <span className="download-file">
- <a onClick={newDownloadFile.bind(null, this.props.data.id, 'manuscript', '/api/admin/downloadManuscript', this.props.data.type)}>稿件下载</a>
- <a onClick={() => {
- var newTab = window.open('about:blank'); getPreview(theData.pid, 'intellectualProperty', theData.type == 1 ? 'patent_writing' : 'copyright_apply', function (data) { newTab.location.href = data; });
- }}><Icon style={{ fontSize: '16px' }} type="eye-o" /></a>
- </span>
- : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传稿件!</span>}
- </p> : <span></span>}
- </div>
- <FormItem>
- <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
- <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
- </FormItem>
- </Form >
- );
- },
- }));
- const intellectualDesc = 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 (
- <div className="patent-addNew">
- <Modal maskClosable={false} title="知识产权详情" visible={this.state.visible}
- onOk={this.handleOk} onCancel={this.handleCancel}
- width='600px'
- footer=''>
- <Spin spinning={this.state.loading} className='spin-box'>
- <IntellectualDescFrom
- uid={this.props.uid}
- data={this.props.data}
- spinState={this.spinChange}
- closeModal={this.handleCancel}
- visible={this.state.visible}
- clickOk={this.handleOk} />
- </Spin>
- </Modal>
- </div>
- );
- },
- });
- export default intellectualDesc;
|