intellectualDesc.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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, newDownloadFile } 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. const theData = this.props.data;
  86. return (
  87. <Form horizontal onSubmit={this.handleSubmit}>
  88. <FormItem
  89. {...formItemLayout}
  90. label="知识产权编号"
  91. >
  92. {getFieldDecorator('intellectualPropertyNumber', {
  93. rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }],
  94. initialValue: theData.intellectualPropertyNumber
  95. })(
  96. <Input placeholder="请输入知识产权编号" />
  97. )}
  98. </FormItem>
  99. <FormItem
  100. {...formItemLayout}
  101. label="知识产权名称"
  102. >
  103. {getFieldDecorator('intellectualPropertyName', {
  104. rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }],
  105. initialValue: theData.intellectualPropertyName
  106. })(
  107. <Input placeholder="请输入知识产权名称" />
  108. )}
  109. </FormItem>
  110. <FormItem
  111. {...formItemLayout}
  112. label="排序号"
  113. >
  114. {getFieldDecorator('sortNumber', {
  115. rules: [{ required: true, message: '请输入,排序号不能为空!' }],
  116. initialValue: theData.sortNumber
  117. })(
  118. <Input placeholder="请输入排序号" />
  119. )}
  120. </FormItem>
  121. <FormItem
  122. {...formItemLayout}
  123. label="知识产权类型"
  124. >
  125. {getFieldDecorator('catagory', {
  126. rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }],
  127. initialValue: theData.catagory
  128. })(
  129. <Select placeholder="请选择知识产权类型" style={{ width: 200 }}
  130. onChange={(e) => { this.state.catagory = e; }}>
  131. {this.state.catagoryOption}
  132. </Select>
  133. )}
  134. </FormItem>
  135. <FormItem
  136. {...formItemLayout}
  137. label="获得方式"
  138. >
  139. {getFieldDecorator('obtainWay', {
  140. rules: [{ required: true, message: '请选择,获得方式不能为空!' }],
  141. initialValue: theData.obtainWay
  142. })(
  143. <Select placeholder="请选择获得方式" style={{ width: 200 }}
  144. onChange={(e) => { this.state.obtainWay = e; }}>
  145. {this.state.intellectualGetOption}
  146. </Select>
  147. )}
  148. </FormItem>
  149. <FormItem
  150. {...formItemLayout}
  151. label="授权号"
  152. >
  153. {getFieldDecorator('authorizationNumber', {
  154. rules: [{ required: true, message: '请输入,授权号不能为空!' }],
  155. initialValue: theData.authorizationNumber
  156. })(
  157. <Input placeholder="请输入授权号" />
  158. )}
  159. </FormItem>
  160. <FormItem
  161. {...formItemLayout}
  162. label="授权日期"
  163. >
  164. {getFieldDecorator('authorizationDate', {
  165. rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }],
  166. initialValue: !theData.authorizationDateFormattedDate ? null : moment(theData.authorizationDateFormattedDate, 'YYYY/MM/DD')
  167. })(
  168. <DatePicker style={{ width: 200 }}
  169. onChange={(data, dataString) => { this.state.authorizationDateFormattedDate = dataString }} />
  170. )}
  171. </FormItem>
  172. <div className="hrSituation-roster">
  173. <Upload
  174. name="ratepay"
  175. action={globalConfig.context + "/api/admin/uploadPropertyRight"}
  176. data={{ 'sign': 'property_right','uid': this.props.uid }}
  177. beforeUpload={beforeUploadFile}
  178. showUploadList={false}
  179. onChange={(info) => {
  180. if (info.file.status !== 'uploading') {
  181. console.log(info.file, info.fileList);
  182. }
  183. if (info.file.status === 'done') {
  184. if (!info.file.response.error.length) {
  185. message.success(`${info.file.name} 文件上传成功!`);
  186. } else {
  187. message.warning(info.file.response.error[0].message);
  188. return;
  189. };
  190. this.state.propertyRightUrl = info.file.response.data;
  191. } else if (info.file.status === 'error') {
  192. message.error(`${info.file.name} 文件上传失败。`);
  193. }
  194. }}
  195. >
  196. <Button><Icon type="upload" /> 上传知识产权证书 </Button>
  197. </Upload>
  198. <p style={{ margin: '10px 0' }}>{theData.propertyRightUrl ? <a onClick={newDownloadFile.bind(null, this.props.data.id, 'property_right', '/api/admin/downloadPropertyRight')}>{theData.propertyRightDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  199. </div>
  200. <FormItem>
  201. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  202. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  203. </FormItem>
  204. </Form >
  205. );
  206. },
  207. }));
  208. const intellectualDesc = React.createClass({
  209. getInitialState() {
  210. return {
  211. visible: false,
  212. loading: false
  213. };
  214. },
  215. componentWillReceiveProps(nextProps) {
  216. this.state.visible = nextProps.showDesc
  217. },
  218. showModal() {
  219. this.setState({
  220. visible: true,
  221. });
  222. },
  223. handleOk() {
  224. this.setState({
  225. visible: false,
  226. });
  227. this.props.closeDesc(false, true);
  228. },
  229. handleCancel(e) {
  230. this.setState({
  231. visible: false,
  232. });
  233. this.props.closeDesc(false);
  234. },
  235. spinChange(e) {
  236. this.setState({
  237. loading: e
  238. });
  239. },
  240. render() {
  241. return (
  242. <div className="patent-addNew">
  243. <Spin spinning={this.state.loading} className='spin-box'>
  244. <Modal title="知识产权详情" visible={this.state.visible}
  245. onOk={this.handleOk} onCancel={this.handleCancel}
  246. width='600px'
  247. footer=''
  248. >
  249. <IntellectualDescFrom
  250. uid={this.props.uid}
  251. data={this.props.data}
  252. spinState={this.spinChange}
  253. closeModal={this.handleCancel}
  254. visible={this.state.visible}
  255. clickOk={this.handleOk} />
  256. </Modal>
  257. </Spin>
  258. </div>
  259. );
  260. },
  261. });
  262. export default intellectualDesc;