websiteChange.jsx 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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() {
  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: 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();
  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. {getFieldDecorator('unitName', {
  151. initialValue: theData.unitName
  152. })(
  153. <Select>{this.props.companyOption}</Select>
  154. )}
  155. </FormItem>
  156. </div>
  157. <div className="clearfix">
  158. <FormItem
  159. {...formItemLayout}
  160. label="科技部门名称:"
  161. >
  162. {getFieldDecorator('department', {
  163. initialValue: theData.department
  164. })(
  165. <Select>{this.state.departmentOption}</Select>
  166. )}
  167. </FormItem>
  168. </div>
  169. <div className="clearfix">
  170. <FormItem
  171. {...formItemLayout}
  172. label="网址:"
  173. >
  174. {getFieldDecorator('website', {
  175. initialValue: theData.website
  176. })(
  177. <Input />
  178. )}
  179. </FormItem>
  180. </div>
  181. <div className="clearfix">
  182. <FormItem
  183. {...formItemLayout}
  184. label="账号:"
  185. >
  186. {getFieldDecorator('accountNumber', {
  187. initialValue: theData.accountNumber
  188. })(
  189. <Input />
  190. )}
  191. </FormItem>
  192. </div>
  193. <div className="clearfix">
  194. <FormItem
  195. {...formItemLayout}
  196. label="密码:"
  197. >
  198. {getFieldDecorator('password', {
  199. initialValue: theData.password
  200. })(
  201. <Input />
  202. )}
  203. </FormItem>
  204. </div>
  205. <FormItem style={{ marginTop: '20px' }}>
  206. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  207. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  208. </FormItem>
  209. </Form >
  210. );
  211. } else {
  212. return (<div></div>)
  213. };
  214. },
  215. }));
  216. const WebsiteChange = React.createClass({
  217. getInitialState() {
  218. return {
  219. visible: false,
  220. loading: false
  221. };
  222. },
  223. componentWillReceiveProps(nextProps) {
  224. this.state.visible = nextProps.showDesc
  225. },
  226. showModal() {
  227. this.setState({
  228. visible: true,
  229. });
  230. },
  231. handleOk() {
  232. this.setState({
  233. visible: false,
  234. });
  235. this.props.closeDesc(false);
  236. },
  237. handleCancel(e) {
  238. this.setState({
  239. visible: false,
  240. });
  241. this.props.closeDesc(false);
  242. },
  243. spinChange(e) {
  244. this.setState({
  245. loading: e
  246. });
  247. },
  248. render() {
  249. return (
  250. <div className="patent-addNew">
  251. <Spin spinning={this.state.loading} className='spin-box'>
  252. <Modal title="编辑科技部门网址" visible={this.state.visible}
  253. onOk={this.handleOk} onCancel={this.handleCancel}
  254. width='800px'
  255. footer=''
  256. >
  257. <WebsiteChangeFrom
  258. visible={this.state.visible}
  259. companyOption={this.props.companyOption}
  260. data={this.props.data}
  261. spinState={this.spinChange} closeModal={this.handleCancel} />
  262. </Modal>
  263. </Spin>
  264. </div>
  265. );
  266. }
  267. });
  268. export default WebsiteChange;