websiteManage.jsx 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. import React from 'react';
  2. import { Icon, Button, Select, Spin, Table, message } from 'antd';
  3. import { provinceArr } from '../../../dataDic.js';
  4. import { companySearch } from '../../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. import './technology.less';
  8. import WebsiteAdd from './websiteAdd.jsx';
  9. import WebsiteChange from './websiteChange.jsx';
  10. const Cognizance = React.createClass({
  11. loadData(pageNo) {
  12. this.state.data = [];
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "post",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + "/api/admintechproject/listTechWebsite",
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. province: this.state.province,
  25. uid: this.state.unitName,
  26. },
  27. success: function (data) {
  28. if (data.error.length || !data.data || !data.data.list) {
  29. message.warning(data.error[0].message);
  30. return;
  31. }
  32. for (let i = 0; i < data.data.list.length; i++) {
  33. let thisdata = data.data.list[i];
  34. this.state.data.push({
  35. key: i,
  36. id: thisdata.id,
  37. uid: thisdata.uid,
  38. unitName: thisdata.unitName,
  39. department: thisdata.department,
  40. webSite: thisdata.website,
  41. userName: thisdata.accountNumber,
  42. password: thisdata.password
  43. });
  44. };
  45. this.state.pagination.current = data.data.pageNo;
  46. this.state.pagination.total = data.data.totalCount;
  47. this.setState({
  48. dataSource: this.state.data,
  49. pagination: this.state.pagination
  50. });
  51. }.bind(this),
  52. }).always(function () {
  53. this.setState({
  54. loading: false
  55. });
  56. }.bind(this));
  57. },
  58. getCompanyList() {
  59. this.setState({
  60. loading: true
  61. });
  62. $.ajax({
  63. method: "get",
  64. dataType: "json",
  65. crossDomain: false,
  66. url: globalConfig.context + "/techservice/patent/getUnitNames",
  67. success: function (data) {
  68. if (data.error.length || !data.data) {
  69. return;
  70. };
  71. let _me = this;
  72. for (var item in data.data) {
  73. _me.state.companyOption.push(
  74. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  75. )
  76. };
  77. }.bind(this),
  78. }).always(function () {
  79. this.setState({
  80. loading: false
  81. });
  82. }.bind(this));
  83. },
  84. getInitialState() {
  85. return {
  86. provinceOption: [],
  87. companyOption: [],
  88. authorOption: [],
  89. selectedRows: [],
  90. loading: false,
  91. showAdd: false,
  92. showDesc: false,
  93. pagination: {
  94. defaultCurrent: 1,
  95. defaultPageSize: 10,
  96. showQuickJumper: true,
  97. pageSize: 10,
  98. onChange: function (page) {
  99. this.loadData(page);
  100. }.bind(this),
  101. showTotal: function (total) {
  102. return '共' + total + '条数据';
  103. }
  104. },
  105. columns: [
  106. {
  107. title: '公司',
  108. dataIndex: 'unitName',
  109. key: 'unitName'
  110. }, {
  111. title: '科技单位',
  112. dataIndex: 'department',
  113. key: 'department'
  114. }, {
  115. title: '网址',
  116. dataIndex: 'webSite',
  117. key: 'webSite'
  118. }, {
  119. title: '用户名',
  120. dataIndex: 'userName',
  121. key: 'userName'
  122. }, {
  123. title: '密码',
  124. dataIndex: 'password',
  125. key: 'password'
  126. }
  127. ],
  128. dataSource: []
  129. };
  130. },
  131. componentWillMount() {
  132. let _me = this;
  133. provinceArr.map(function (item) {
  134. _me.state.provinceOption.push(
  135. <Select.Option value={item} key={item}>{item}</Select.Option>
  136. )
  137. });
  138. this.loadData();
  139. this.getCompanyList();
  140. // this.getContactsList();
  141. },
  142. tableRowClick(record, index) {
  143. this.state.RowData = record;
  144. this.setState({
  145. showDesc: true
  146. });
  147. },
  148. addClick() {
  149. this.setState({
  150. showAdd: true
  151. });
  152. },
  153. delectRow() {
  154. let deletedIds = [];
  155. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  156. let rowItem = this.state.selectedRows[idx];
  157. if (rowItem.id) {
  158. deletedIds.push(rowItem.id)
  159. }
  160. }
  161. $.ajax({
  162. method: "POST",
  163. dataType: "json",
  164. crossDomain: false,
  165. url: globalConfig.context + "/techservice/cognizance/deleteCognizance",
  166. data: {
  167. ids: deletedIds
  168. }
  169. }).done(function (data) {
  170. if (!data.error.length) {
  171. message.success('保存成功!');
  172. this.setState({
  173. loading: false,
  174. });
  175. } else {
  176. message.warning(data.error[0].message);
  177. };
  178. this.loadData();
  179. }.bind(this));
  180. },
  181. closeDesc(e) {
  182. this.state.showDesc = e;
  183. this.loadData();
  184. },
  185. closeAdd(e) {
  186. this.state.showAdd = e;
  187. this.loadData();
  188. },
  189. search() {
  190. this.loadData();
  191. },
  192. reset() {
  193. this.state.province = undefined;
  194. this.state.unitName = undefined;
  195. this.loadData();
  196. },
  197. render() {
  198. return (
  199. <div className="foster-content" >
  200. <div className="content-title">
  201. <span>科技单位网址管理</span>
  202. <div className="foster-query" style={{ float: "right" }}>
  203. <div>
  204. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  205. onClick={this.addClick}>创建新单位网址<Icon type="plus" /></Button>
  206. </div>
  207. </div>
  208. </div>
  209. <div className="foster-query">
  210. <Select placeholder="选择省份"
  211. style={{ width: 200 }}
  212. value={this.state.province}
  213. showSearch
  214. filterOption={companySearch}
  215. onChange={(e) => { this.setState({ province: e }) }}>
  216. {this.state.provinceOption}
  217. </Select>
  218. <Select placeholder="选择公司"
  219. style={{ width: 200 }}
  220. value={this.state.unitName}
  221. showSearch
  222. filterOption={companySearch}
  223. onChange={(e) => { this.setState({ unitName: e }) }}>
  224. {this.state.companyOption}
  225. </Select>
  226. <Button type="primary" onClick={this.search}>搜索</Button>
  227. <Button onClick={this.reset}>重置</Button>
  228. </div>
  229. <div className="patent-table">
  230. <Spin spinning={this.state.loading}>
  231. <Table columns={this.state.columns}
  232. dataSource={this.state.dataSource}
  233. pagination={this.state.pagination}
  234. onRowClick={this.tableRowClick} />
  235. </Spin>
  236. </div>
  237. <WebsiteChange
  238. data={this.state.RowData}
  239. companyOption={this.state.companyOption}
  240. showDesc={this.state.showDesc}
  241. closeDesc={this.closeDesc} />
  242. <WebsiteAdd
  243. companyOption={this.state.companyOption}
  244. showAdd={this.state.showAdd}
  245. closeAdd={this.closeAdd} />
  246. </div >
  247. );
  248. }
  249. });
  250. export default Cognizance;