intellectualDesc.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 } 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.closeModal();
  60. this.props.form.resetFields();
  61. }.bind(this));
  62. }
  63. });
  64. },
  65. checkIdcardnum(rule, value, callback) {
  66. if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) {
  67. callback('请输入正确的身份证号!');
  68. } else {
  69. callback();
  70. }
  71. },
  72. render() {
  73. const FormItem = Form.Item;
  74. const { getFieldDecorator } = this.props.form;
  75. const formItemLayout = {
  76. labelCol: { span: 6 },
  77. wrapperCol: { span: 12 },
  78. };
  79. const _me = this;
  80. return (
  81. <Form horizontal onSubmit={this.handleSubmit}>
  82. <FormItem
  83. {...formItemLayout}
  84. label="知识产权编号"
  85. >
  86. {getFieldDecorator('intellectualPropertyNumber', {
  87. rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }],
  88. initialValue: this.props.data.intellectualPropertyNumber
  89. })(
  90. <Input placeholder="请输入知识产权编号" />
  91. )}
  92. </FormItem>
  93. <FormItem
  94. {...formItemLayout}
  95. label="知识产权名称"
  96. >
  97. {getFieldDecorator('intellectualPropertyName', {
  98. rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }],
  99. initialValue: this.props.data.intellectualPropertyName
  100. })(
  101. <Input placeholder="请输入知识产权名称" />
  102. )}
  103. </FormItem>
  104. <FormItem
  105. {...formItemLayout}
  106. label="排序号"
  107. >
  108. {getFieldDecorator('sortNumber', {
  109. rules: [{ required: true, message: '请输入,排序号不能为空!' }],
  110. initialValue: this.props.data.sortNumber
  111. })(
  112. <Input placeholder="请输入排序号" />
  113. )}
  114. </FormItem>
  115. <FormItem
  116. {...formItemLayout}
  117. label="知识产权类型"
  118. >
  119. {getFieldDecorator('catagory', {
  120. rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }],
  121. initialValue: this.props.data.catagory
  122. })(
  123. <Select placeholder="请选择知识产权类型" style={{ width: 200 }}
  124. onChange={(e) => { this.state.catagory = e; }}>
  125. {this.state.catagoryOption}
  126. </Select>
  127. )}
  128. </FormItem>
  129. <FormItem
  130. {...formItemLayout}
  131. label="获得方式"
  132. >
  133. {getFieldDecorator('obtainWay', {
  134. rules: [{ required: true, message: '请选择,获得方式不能为空!' }],
  135. initialValue: this.props.data.obtainWay
  136. })(
  137. <Select placeholder="请选择获得方式" style={{ width: 200 }}
  138. onChange={(e) => { this.state.obtainWay = e; }}>
  139. {this.state.intellectualGetOption}
  140. </Select>
  141. )}
  142. </FormItem>
  143. <FormItem
  144. {...formItemLayout}
  145. label="授权号"
  146. >
  147. {getFieldDecorator('authorizationNumber', {
  148. rules: [{ required: true, message: '请输入,授权号不能为空!' }],
  149. initialValue: this.props.data.authorizationNumber
  150. })(
  151. <Input placeholder="请输入授权号" />
  152. )}
  153. </FormItem>
  154. <FormItem
  155. {...formItemLayout}
  156. label="授权日期"
  157. >
  158. {getFieldDecorator('authorizationDate', {
  159. rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }],
  160. initialValue: !this.props.data.authorizationDateFormattedDate ? null : moment(this.props.data.authorizationDateFormattedDate, 'YYYY/MM/DD')
  161. })(
  162. <DatePicker style={{ width: 200 }}
  163. onChange={(data, dataString) => { this.state.authorizationDateFormattedDate = dataString }} />
  164. )}
  165. </FormItem>
  166. <FormItem>
  167. <Upload
  168. name="ratepay"
  169. action={globalConfig.context + "/techservice/cognizance/upload"}
  170. data={{ 'sign': this.props.year + 'propertyRight' }}
  171. beforeUpload={beforeUploadFile}
  172. onChange={(info) => {
  173. if (info.file.status !== 'uploading') {
  174. console.log(info.file, info.fileList);
  175. }
  176. if (info.file.status === 'done') {
  177. message.success(`${info.file.name} 文件上传成功!`);
  178. this.state.propertyRightUrl = info.file.response.data;
  179. } else if (info.file.status === 'error') {
  180. message.error(`${info.file.name} 文件上传失败。`);
  181. }
  182. }}
  183. >
  184. <Button><Icon type="upload" /> 上传知识产权证书 </Button>
  185. </Upload>
  186. </FormItem>
  187. <FormItem>
  188. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  189. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  190. </FormItem>
  191. </Form >
  192. );
  193. },
  194. }));
  195. const intellectualDesc = React.createClass({
  196. getInitialState() {
  197. return {
  198. visible: false,
  199. loading: false
  200. };
  201. },
  202. componentWillReceiveProps(nextProps) {
  203. this.state.visible = nextProps.showDesc
  204. },
  205. showModal() {
  206. this.setState({
  207. visible: true,
  208. });
  209. },
  210. handleOk() {
  211. this.setState({
  212. visible: false,
  213. });
  214. this.props.closeDesc(false);
  215. },
  216. handleCancel(e) {
  217. this.setState({
  218. visible: false,
  219. });
  220. this.props.closeDesc(false);
  221. },
  222. spinChange(e) {
  223. this.setState({
  224. loading: e
  225. });
  226. },
  227. render() {
  228. return (
  229. <div className="patent-addNew">
  230. <Spin spinning={this.state.loading} className='spin-box'>
  231. <Modal title="知识产权详情" visible={this.state.visible}
  232. onOk={this.handleOk} onCancel={this.handleCancel}
  233. width='600px'
  234. footer=''
  235. >
  236. <IntellectualDescFrom uid={this.props.uid} data={this.props.data} spinState={this.spinChange} closeModal={this.handleCancel} />
  237. </Modal>
  238. </Spin>
  239. </div>
  240. );
  241. },
  242. });
  243. export default intellectualDesc;