websiteChange.jsx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. import React from 'react';
  2. import { Icon, Form, Button, Input, Select, Spin, Table, DatePicker, message, Modal, Checkbox, Upload } from 'antd';
  3. import { cognizanceStateList } from '../../../dataDic.js';
  4. import { getCognizanceState, beforeUpload, getBase64 } from '../../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. const WebsiteChangeFrom = Form.create()(React.createClass({
  8. loadData(id) {
  9. this.setState({
  10. loading: true
  11. });
  12. $.ajax({
  13. method: "post",
  14. dataType: "json",
  15. crossDomain: false,
  16. url: globalConfig.context + "/api/admintechproject/techWebsiteDetail",
  17. data: {
  18. id: id || this.props.data.id
  19. },
  20. success: function (data) {
  21. this.state.data = data.data;
  22. }.bind(this),
  23. }).always(function () {
  24. this.setState({
  25. loading: false
  26. });
  27. }.bind(this));
  28. },
  29. getInitialState() {
  30. return {
  31. loading: false,
  32. stateOption: [],
  33. introduce: '',
  34. projectCheck: 0,
  35. subsidy: 0,
  36. stateTable: []
  37. };
  38. },
  39. componentWillMount() {
  40. let _me = this;
  41. cognizanceStateList.map(function (item) {
  42. _me.state.stateOption.push(
  43. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  44. )
  45. });
  46. this.loadData();
  47. },
  48. handleSubmit(e) {
  49. e.preventDefault();
  50. this.props.form.validateFields((err, values) => {
  51. if (!err) {
  52. this.props.spinState(true);
  53. $.ajax({
  54. method: "POST",
  55. dataType: "json",
  56. crossDomain: false,
  57. url: globalConfig.context + "/api/admintechproject/disposeTechWebsite",
  58. data: {
  59. id: this.state.data.id,
  60. uid: this.state.data.uid,
  61. department: values.department,
  62. website: values.website,
  63. accountNumber: values.accountNumber,
  64. password: values.password,
  65. }
  66. }).done(function (data) {
  67. if (!data.error.length) {
  68. message.success('保存成功!');
  69. this.props.closeModal();
  70. this.props.form.resetFields();
  71. this.state.targetKeys = [];
  72. this.state.selectedKeys = [];
  73. this.props.spinState(false);
  74. } else {
  75. message.warning(data.error[0].message);
  76. this.props.spinState(false);
  77. }
  78. }.bind(this));
  79. }
  80. });
  81. },
  82. componentWillReceiveProps(nextProps) {
  83. if (!this.props.visible && nextProps.visible) {
  84. this.loadData(nextProps.data.id);
  85. };
  86. },
  87. projectEstablishmentCheck(e) {
  88. if (e.target.checked == true) {
  89. this.state.projectCheck = 1;
  90. } else if (e.target.checked == false) {
  91. this.state.projectCheck = 0;
  92. };
  93. },
  94. subsidyCheck(e) {
  95. if (e.target.checked == true) {
  96. this.state.subsidy = 1;
  97. } else if (e.target.checked == false) {
  98. this.state.subsidy = 0;
  99. };
  100. },
  101. render() {
  102. const FormItem = Form.Item;
  103. const { getFieldDecorator } = this.props.form;
  104. const theData = this.state.data;
  105. const formItemLayout = {
  106. labelCol: { span: 4 },
  107. wrapperCol: { span: 6 },
  108. };
  109. const _me = this;
  110. if (this.state.data) {
  111. return (
  112. <Form onSubmit={this.handleSubmit} id="highTechApply-form">
  113. <div className="half-item">
  114. <FormItem
  115. labelCol={{ span: 8 }}
  116. wrapperCol={{ span: 12 }}
  117. label="选择公司:"
  118. >
  119. <span>{theData.unitName}</span>
  120. </FormItem>
  121. </div>
  122. <div className="clearfix">
  123. <FormItem
  124. {...formItemLayout}
  125. label="科技部门名称:"
  126. >
  127. {getFieldDecorator('department', {
  128. initialValue: theData.department
  129. })(
  130. <Input />
  131. )}
  132. </FormItem>
  133. </div>
  134. <div className="clearfix">
  135. <FormItem
  136. {...formItemLayout}
  137. label="网址:"
  138. >
  139. {getFieldDecorator('website', {
  140. initialValue: theData.website
  141. })(
  142. <Input />
  143. )}
  144. </FormItem>
  145. </div>
  146. <div className="clearfix">
  147. <FormItem
  148. {...formItemLayout}
  149. label="账号:"
  150. >
  151. {getFieldDecorator('accountNumber', {
  152. initialValue: theData.accountNumber
  153. })(
  154. <Input />
  155. )}
  156. </FormItem>
  157. </div>
  158. <div className="clearfix">
  159. <FormItem
  160. {...formItemLayout}
  161. label="密码:"
  162. >
  163. {getFieldDecorator('password', {
  164. initialValue: theData.password
  165. })(
  166. <Input />
  167. )}
  168. </FormItem>
  169. </div>
  170. <FormItem style={{ marginTop: '20px' }}>
  171. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  172. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  173. </FormItem>
  174. </Form >
  175. );
  176. } else {
  177. return (<div></div>)
  178. };
  179. },
  180. }));
  181. const WebsiteChange = React.createClass({
  182. getInitialState() {
  183. return {
  184. visible: false,
  185. loading: false
  186. };
  187. },
  188. componentWillReceiveProps(nextProps) {
  189. this.state.visible = nextProps.showDesc
  190. },
  191. showModal() {
  192. this.setState({
  193. visible: true,
  194. });
  195. },
  196. handleOk() {
  197. this.setState({
  198. visible: false,
  199. });
  200. this.props.closeDesc(false);
  201. },
  202. handleCancel(e) {
  203. this.setState({
  204. visible: false,
  205. });
  206. this.props.closeDesc(false);
  207. },
  208. spinChange(e) {
  209. this.setState({
  210. loading: e
  211. });
  212. },
  213. render() {
  214. return (
  215. <div className="patent-addNew">
  216. <Spin spinning={this.state.loading} className='spin-box'>
  217. <Modal title="编辑科技部门网址" visible={this.state.visible}
  218. onOk={this.handleOk} onCancel={this.handleCancel}
  219. width='800px'
  220. footer=''
  221. >
  222. <WebsiteChangeFrom
  223. visible={this.state.visible}
  224. companyOption={this.props.companyOption}
  225. data={this.props.data}
  226. spinState={this.spinChange} closeModal={this.handleCancel} />
  227. </Modal>
  228. </Spin>
  229. </div>
  230. );
  231. }
  232. });
  233. export default WebsiteChange;