intellectualDesc.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. import React from 'react';
  2. import { Icon, Modal, Button, Form, message, Input, Spin, Select, DatePicker, Upload } from 'antd';
  3. import { intellectualGetList, catagoryList } from '../../../../dataDic.js';
  4. import { beforeUploadFile, downloadFile } from '../../../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js'
  6. import $ from 'jquery/src/ajax';
  7. import moment from 'moment';
  8. const IntellectualDescFrom = Form.create()(React.createClass({
  9. getInitialState() {
  10. return {
  11. loading: false,
  12. intellectualGetOption: [],
  13. catagoryOption: []
  14. };
  15. },
  16. componentWillMount() {
  17. let _me = this;
  18. intellectualGetList.map(function (item) {
  19. _me.state.intellectualGetOption.push(
  20. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  21. )
  22. });
  23. catagoryList.map(function (item) {
  24. _me.state.catagoryOption.push(
  25. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  26. )
  27. });
  28. },
  29. handleSubmit(e) {
  30. e.preventDefault();
  31. this.props.form.validateFields((err, values) => {
  32. if (!err) {
  33. this.props.spinState(true);
  34. $.ajax({
  35. method: "POST",
  36. dataType: "json",
  37. crossDomain: false,
  38. url: globalConfig.context + "/api/admin/intellectual",
  39. data: {
  40. id: this.props.data.id,
  41. uid: this.props.uid,
  42. intellectualPropertyNumber: values.intellectualPropertyNumber,
  43. intellectualPropertyName: values.intellectualPropertyName,
  44. catagory: values.catagory,
  45. obtainWay: values.obtainWay,
  46. sortNumber: values.sortNumber,
  47. authorizationNumber: values.authorizationNumber,
  48. authorizationDateFormattedDate: values.authorizationDate._i || this.state.authorizationDateFormattedDate,
  49. propertyRightUrl: this.state.propertyRightUrl
  50. }
  51. }).done(function (data) {
  52. if (!data.error.length) {
  53. message.success('保存成功!');
  54. } else {
  55. message.warning(data.error[0].message);
  56. }
  57. }.bind(this)).always(function () {
  58. this.props.spinState(false);
  59. this.props.clickOk();
  60. this.props.form.resetFields();
  61. }.bind(this));
  62. }
  63. });
  64. },
  65. componentWillReceiveProps(nextProps) {
  66. if (!this.props.visible && nextProps.visible) {
  67. this.props.form.resetFields();
  68. };
  69. },
  70. // checkIdcardnum(rule, value, callback) {
  71. // if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) {
  72. // callback('请输入正确的身份证号!');
  73. // } else {
  74. // callback();
  75. // }
  76. // },
  77. render() {
  78. const FormItem = Form.Item;
  79. const { getFieldDecorator } = this.props.form;
  80. const formItemLayout = {
  81. labelCol: { span: 6 },
  82. wrapperCol: { span: 12 },
  83. };
  84. const _me = this;
  85. return (
  86. <Form horizontal onSubmit={this.handleSubmit}>
  87. <FormItem
  88. {...formItemLayout}
  89. label="知识产权编号"
  90. >
  91. {getFieldDecorator('intellectualPropertyNumber', {
  92. rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }],
  93. initialValue: this.props.data.intellectualPropertyNumber
  94. })(
  95. <Input placeholder="请输入知识产权编号" />
  96. )}
  97. </FormItem>
  98. <FormItem
  99. {...formItemLayout}
  100. label="知识产权名称"
  101. >
  102. {getFieldDecorator('intellectualPropertyName', {
  103. rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }],
  104. initialValue: this.props.data.intellectualPropertyName
  105. })(
  106. <Input placeholder="请输入知识产权名称" />
  107. )}
  108. </FormItem>
  109. <FormItem
  110. {...formItemLayout}
  111. label="排序号"
  112. >
  113. {getFieldDecorator('sortNumber', {
  114. rules: [{ required: true, message: '请输入,排序号不能为空!' }],
  115. initialValue: this.props.data.sortNumber
  116. })(
  117. <Input placeholder="请输入排序号" />
  118. )}
  119. </FormItem>
  120. <FormItem
  121. {...formItemLayout}
  122. label="知识产权类型"
  123. >
  124. {getFieldDecorator('catagory', {
  125. rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }],
  126. initialValue: this.props.data.catagory
  127. })(
  128. <Select placeholder="请选择知识产权类型" style={{ width: 200 }}
  129. onChange={(e) => { this.state.catagory = e; }}>
  130. {this.state.catagoryOption}
  131. </Select>
  132. )}
  133. </FormItem>
  134. <FormItem
  135. {...formItemLayout}
  136. label="获得方式"
  137. >
  138. {getFieldDecorator('obtainWay', {
  139. rules: [{ required: true, message: '请选择,获得方式不能为空!' }],
  140. initialValue: this.props.data.obtainWay
  141. })(
  142. <Select placeholder="请选择获得方式" style={{ width: 200 }}
  143. onChange={(e) => { this.state.obtainWay = e; }}>
  144. {this.state.intellectualGetOption}
  145. </Select>
  146. )}
  147. </FormItem>
  148. <FormItem
  149. {...formItemLayout}
  150. label="授权号"
  151. >
  152. {getFieldDecorator('authorizationNumber', {
  153. rules: [{ required: true, message: '请输入,授权号不能为空!' }],
  154. initialValue: this.props.data.authorizationNumber
  155. })(
  156. <Input placeholder="请输入授权号" />
  157. )}
  158. </FormItem>
  159. <FormItem
  160. {...formItemLayout}
  161. label="授权日期"
  162. >
  163. {getFieldDecorator('authorizationDate', {
  164. rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }],
  165. initialValue: !this.props.data.authorizationDateFormattedDate ? null : moment(this.props.data.authorizationDateFormattedDate, 'YYYY/MM/DD')
  166. })(
  167. <DatePicker style={{ width: 200 }}
  168. onChange={(data, dataString) => { this.state.authorizationDateFormattedDate = dataString }} />
  169. )}
  170. </FormItem>
  171. <div className="hrSituation-roster">
  172. <Upload
  173. name="ratepay"
  174. action={globalConfig.context + "/techservice/cognizance/upload"}
  175. data={{ 'sign': 'property_ritht' }}
  176. beforeUpload={beforeUploadFile}
  177. showUploadList={false}
  178. onChange={(info) => {
  179. if (info.file.status !== 'uploading') {
  180. console.log(info.file, info.fileList);
  181. }
  182. if (info.file.status === 'done') {
  183. if (!info.file.response.error.length) {
  184. message.success(`${info.file.name} 文件上传成功!`);
  185. } else {
  186. message.warning(info.file.response.error[0].message);
  187. return;
  188. };
  189. this.state.propertyRightUrl = info.file.response.data;
  190. } else if (info.file.status === 'error') {
  191. message.error(`${info.file.name} 文件上传失败。`);
  192. }
  193. }}
  194. >
  195. <Button><Icon type="upload" /> 上传知识产权证书 </Button>
  196. </Upload>
  197. <p style={{ margin: '10px 0' }}>{theData.propertyRightUrl ? <a onClick={downloadFile.bind(null, theData.propertyRightUrl, theData.propertyRightDownloadFileName)}>{theData.propertyRightDownloadFileName}</a> : <span>未上传!</span>}</p>
  198. </div>
  199. <FormItem>
  200. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  201. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  202. </FormItem>
  203. </Form >
  204. );
  205. },
  206. }));
  207. const intellectualDesc = React.createClass({
  208. getInitialState() {
  209. return {
  210. visible: false,
  211. loading: false
  212. };
  213. },
  214. componentWillReceiveProps(nextProps) {
  215. this.state.visible = nextProps.showDesc
  216. },
  217. showModal() {
  218. this.setState({
  219. visible: true,
  220. });
  221. },
  222. handleOk() {
  223. this.setState({
  224. visible: false,
  225. });
  226. this.props.closeDesc(false, true);
  227. },
  228. handleCancel(e) {
  229. this.setState({
  230. visible: false,
  231. });
  232. this.props.closeDesc(false);
  233. },
  234. spinChange(e) {
  235. this.setState({
  236. loading: e
  237. });
  238. },
  239. render() {
  240. return (
  241. <div className="patent-addNew">
  242. <Spin spinning={this.state.loading} className='spin-box'>
  243. <Modal title="知识产权详情" visible={this.state.visible}
  244. onOk={this.handleOk} onCancel={this.handleCancel}
  245. width='600px'
  246. footer=''
  247. >
  248. <IntellectualDescFrom
  249. uid={this.props.uid}
  250. data={this.props.data}
  251. spinState={this.spinChange}
  252. closeModal={this.handleCancel}
  253. visible={this.state.visible}
  254. clickOk={this.handleOk} />
  255. </Modal>
  256. </Spin>
  257. </div>
  258. );
  259. },
  260. });
  261. export default intellectualDesc;