websiteManage.jsx 9.5 KB

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