websiteAdd.jsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import React from 'react';
  2. import { Button, Input, Select, message, Modal } from 'antd';
  3. import { companySearch } from '../../../tools.js';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import $ from 'jquery/src/ajax';
  6. const WebsiteAdd = React.createClass({
  7. getInitialState() {
  8. return {
  9. visible: false,
  10. loading: false
  11. };
  12. },
  13. componentWillReceiveProps(nextProps) {
  14. this.state.visible = nextProps.showAdd
  15. },
  16. showModal() {
  17. this.setState({
  18. visible: true,
  19. });
  20. },
  21. handleOk() {
  22. this.setState({
  23. loading: true
  24. });
  25. if (!this.state.unitName) {
  26. message.warning('请选择一个公司!');
  27. this.setState({
  28. loading: false
  29. });
  30. return;
  31. };
  32. $.ajax({
  33. method: "POST",
  34. dataType: "json",
  35. crossDomain: false,
  36. url: globalConfig.context + "/api/admintechproject/disposeTechWebsite",
  37. data: {
  38. uid: this.state.unitName,
  39. department: this.state.department,
  40. website: this.state.website,
  41. accountNumber: this.state.accountNumber,
  42. password: this.state.password
  43. }
  44. }).done(function (data) {
  45. if (!data.error.length) {
  46. message.success('保存成功!');
  47. this.setState({
  48. visible: false
  49. });
  50. this.props.closeAdd(false);
  51. } else {
  52. message.warning(data.error[0].message);
  53. this.setState({
  54. loading: false
  55. });
  56. }
  57. }.bind(this));
  58. },
  59. handleCancel(e) {
  60. this.setState({
  61. visible: false,
  62. });
  63. this.props.closeAdd(false);
  64. },
  65. spinChange(e) {
  66. this.setState({
  67. loading: e
  68. });
  69. },
  70. render() {
  71. return (
  72. <div className="cognizance-add">
  73. <Modal title="添加科技部门网址" visible={this.state.visible}
  74. onOk={this.handleOk} onCancel={this.handleCancel}
  75. width='800px'
  76. footer={[
  77. <Button key="submit" type="primary" loading={this.state.loading} onClick={this.handleOk}>
  78. 确认
  79. </Button>,
  80. <Button key="back" onClick={this.handleCancel}>
  81. 取消
  82. </Button>,
  83. ]}
  84. >
  85. <div className="clearfix" style={{ marginBottom: '10px' }}>
  86. <div className="half-item">
  87. <span className="item-title">选择公司: </span>
  88. <Select
  89. placeholder="请选择公司"
  90. style={{ width: 200 }}
  91. showSearch
  92. filterOption={companySearch}
  93. onChange={(e)=>{ this.state.unitName = e;}}>
  94. {this.props.companyAddOption}
  95. </Select>
  96. </div>
  97. </div>
  98. <div className="clearfix">
  99. <div className="half-item">
  100. <span className="item-title">科技部门名称: </span>
  101. <Input value={this.state.department} onChange={(e) => { this.setState({ department: e.target.value }); }} style={{ width: 200 }} />
  102. </div>
  103. </div>
  104. <div className="clearfix">
  105. <div className="half-item">
  106. <span className="item-title">网址: </span>
  107. <Input value={this.state.website} onChange={(e) => { this.setState({ website: e.target.value }); }} style={{ width: 200 }} />
  108. </div>
  109. </div>
  110. <div className="clearfix">
  111. <div className="half-item">
  112. <span className="item-title">账号: </span>
  113. <Input value={this.state.accountNumber} onChange={(e) => { this.setState({ accountNumber: e.target.value }); }} style={{ width: 200 }} />
  114. </div>
  115. </div>
  116. <div className="clearfix">
  117. <div className="half-item">
  118. <span className="item-title">密码: </span>
  119. <Input value={this.state.password} onChange={(e) => { this.setState({ password: e.target.value }); }} style={{ width: 200 }} />
  120. </div>
  121. </div>
  122. </Modal>
  123. </div>
  124. );
  125. }
  126. });
  127. export default WebsiteAdd;