websiteChange.jsx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import React from 'react';
  2. import { Icon, Form, Button, Input, Select, Spin, Table, 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/admin/techproject/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/admin/techproject/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. } else {
  74. message.warning(data.error[0].message);
  75. };
  76. this.props.spinState(false);
  77. }.bind(this));
  78. }
  79. });
  80. },
  81. componentWillReceiveProps(nextProps) {
  82. if (!this.props.visible && nextProps.visible) {
  83. this.loadData(nextProps.data.id);
  84. };
  85. },
  86. projectEstablishmentCheck(e) {
  87. if (e.target.checked == true) {
  88. this.state.projectCheck = 1;
  89. } else if (e.target.checked == false) {
  90. this.state.projectCheck = 0;
  91. };
  92. },
  93. subsidyCheck(e) {
  94. if (e.target.checked == true) {
  95. this.state.subsidy = 1;
  96. } else if (e.target.checked == false) {
  97. this.state.subsidy = 0;
  98. };
  99. },
  100. render() {
  101. const FormItem = Form.Item;
  102. const { getFieldDecorator } = this.props.form;
  103. const theData = this.state.data;
  104. const formItemLayout = {
  105. labelCol: { span: 6 },
  106. wrapperCol: { span: 18 },
  107. };
  108. const _me = this;
  109. if (this.state.data) {
  110. return (
  111. <Form onSubmit={this.handleSubmit} id="highTechApply-form">
  112. <FormItem
  113. {...formItemLayout}
  114. label="公司名称:"
  115. >
  116. <span>{theData.unitName}</span>
  117. </FormItem>
  118. <FormItem
  119. {...formItemLayout}
  120. label="科技部门名称:"
  121. >
  122. {getFieldDecorator('department', {
  123. initialValue: theData.department
  124. })(
  125. <Input />
  126. )}
  127. </FormItem>
  128. <FormItem
  129. {...formItemLayout}
  130. label="网址:"
  131. >
  132. {getFieldDecorator('website', {
  133. initialValue: theData.website
  134. })(
  135. <Input />
  136. )}
  137. </FormItem>
  138. <FormItem
  139. {...formItemLayout}
  140. label="账号:"
  141. >
  142. {getFieldDecorator('accountNumber', {
  143. initialValue: theData.accountNumber
  144. })(
  145. <Input />
  146. )}
  147. </FormItem>
  148. <FormItem
  149. {...formItemLayout}
  150. label="密码:"
  151. >
  152. {getFieldDecorator('password', {
  153. initialValue: theData.password
  154. })(
  155. <Input />
  156. )}
  157. </FormItem>
  158. <FormItem style={{ marginTop: '20px' }} style={{textAlign:"center"}}>
  159. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  160. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  161. </FormItem>
  162. </Form >
  163. );
  164. } else {
  165. return (<div></div>)
  166. };
  167. },
  168. }));
  169. const WebsiteChange = React.createClass({
  170. getInitialState() {
  171. return {
  172. visible: false,
  173. loading: false
  174. };
  175. },
  176. componentWillReceiveProps(nextProps) {
  177. this.state.visible = nextProps.showDesc
  178. },
  179. showModal() {
  180. this.setState({
  181. visible: true,
  182. });
  183. },
  184. handleOk() {
  185. this.setState({
  186. visible: false,
  187. });
  188. this.props.closeDesc(false);
  189. },
  190. handleCancel(e) {
  191. this.setState({
  192. visible: false,
  193. });
  194. this.props.closeDesc(false);
  195. },
  196. spinChange(e) {
  197. this.setState({
  198. loading: e
  199. });
  200. },
  201. render() {
  202. return (
  203. <div className="patent-addNew">
  204. <Modal maskClosable={false} title="编辑科技部门网址" visible={this.state.visible}
  205. onOk={this.handleOk} onCancel={this.handleCancel}
  206. width='500px'
  207. footer='' >
  208. <Spin spinning={this.state.loading} className='spin-box'>
  209. <WebsiteChangeFrom
  210. visible={this.state.visible}
  211. companyOption={this.props.companyOption}
  212. data={this.props.data}
  213. spinState={this.spinChange} closeModal={this.handleCancel} />
  214. </Spin>
  215. </Modal>
  216. </div>
  217. );
  218. }
  219. });
  220. export default WebsiteChange;