websiteChange.jsx 9.1 KB

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