techAchievement.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import './techAchievement.less';
  7. import TechAchievementDesc from './techAchievementDesc.jsx';
  8. import { provinceArr, achievementCategoryList, techAuditStatusList } from '../../dataDic.js';
  9. import { companySearch, getAchievementCategory, getSearchUrl, getTechAuditStatus } from '../../tools.js';
  10. const AchievementList = React.createClass({
  11. loadData(pageNo) {
  12. this.state.data = [];
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "get",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + '/api/admin/achievement/list',
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. serialNumber: this.state.serialNumber, //编号
  25. name: this.state.name, //名称
  26. keyword: this.state.keyword, // 关键词
  27. category: this.state.category, //类型(0--专利, 2--软著, 3--项目, 4--版权, 5--工业设计, 6--配方, 7--非标)
  28. ownerType: this.state.ownerType, //所有人类型(0-个人,1-组织)
  29. releaseDateStartDate: this.state.releaseDate[0],
  30. releaseDateEndDate: this.state.releaseDate[1],
  31. releaseStatus: this.state.releaseStatus ? Number(this.state.releaseStatus) : undefined, //是否发布(0--未发布,1--已发布)
  32. auditStatus: this.state.auditStatus
  33. },
  34. success: function (data) {
  35. let theArr = [];
  36. if (!data.data && !data.data.list) {
  37. if (data.error && data.error.length) {
  38. message.warning(data.error[0].message);
  39. };
  40. } else {
  41. for (let i = 0; i < data.data.list.length; i++) {
  42. let thisdata = data.data.list[i];
  43. theArr.push({
  44. key: i,
  45. id: thisdata.id,
  46. serialNumber: thisdata.serialNumber,
  47. dataCategory: thisdata.dataCategory,
  48. name: thisdata.name,
  49. keyword: thisdata.keyword,
  50. category: thisdata.category,
  51. ownerName: thisdata.ownerName,
  52. ownerType: thisdata.ownerType,
  53. ownerMobile: thisdata.ownerMobile,
  54. status: thisdata.status,
  55. releaseDate: thisdata.releaseDate,
  56. releaseDateFormattedDate: thisdata.releaseDateFormattedDate,
  57. auditStatus: thisdata.auditStatus
  58. });
  59. };
  60. }
  61. this.state.pagination.current = data.data.pageNo;
  62. this.state.pagination.total = data.data.totalCount;
  63. this.setState({
  64. dataSource: theArr,
  65. pagination: this.state.pagination
  66. });
  67. }.bind(this),
  68. }).always(function () {
  69. this.setState({
  70. loading: false
  71. });
  72. }.bind(this));
  73. },
  74. getInitialState() {
  75. return {
  76. searchMore: true,
  77. validityPeriodDate: [],
  78. releaseDate: [],
  79. selectedRowKeys: [],
  80. selectedRows: [],
  81. loading: false,
  82. pagination: {
  83. defaultCurrent: 1,
  84. defaultPageSize: 10,
  85. showQuickJumper: true,
  86. pageSize: 10,
  87. onChange: function (page) {
  88. this.loadData(page);
  89. }.bind(this),
  90. showTotal: function (total) {
  91. return '共' + total + '条数据';
  92. }
  93. },
  94. columns: [
  95. {
  96. title: '编号',
  97. dataIndex: 'serialNumber',
  98. key: 'serialNumber',
  99. }, {
  100. title: '名称',
  101. dataIndex: 'name',
  102. key: 'name',
  103. }, {
  104. title: '关键字',
  105. dataIndex: 'keyword',
  106. key: 'keyword',
  107. }, {
  108. title: '类型',
  109. dataIndex: 'category',
  110. key: 'category',
  111. render: text => { return getAchievementCategory(text); }
  112. }, {
  113. title: '所有人名称',
  114. dataIndex: 'ownerName',
  115. key: 'ownerName',
  116. }, {
  117. title: '所有人类型',
  118. dataIndex: 'ownerType',
  119. key: 'ownerType',
  120. render: text => {
  121. switch (text) {
  122. case "0":
  123. return <span>个人</span>;
  124. case "1":
  125. return <span>组织</span>
  126. }
  127. }
  128. }, {
  129. title: '审核状态',
  130. dataIndex: 'auditStatus',
  131. key: 'auditStatus',
  132. render: text => { return getTechAuditStatus(text) }
  133. }, {
  134. title: '发布时间',
  135. dataIndex: 'releaseDateFormattedDate',
  136. key: 'releaseDateFormattedDate',
  137. }
  138. ],
  139. dataSource: [],
  140. searchTime: [,]
  141. };
  142. },
  143. componentWillMount() {
  144. let theArr = [];
  145. achievementCategoryList.map(function (item) {
  146. theArr.push(
  147. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  148. )
  149. });
  150. let auditArr = [];
  151. techAuditStatusList.map(function (item) {
  152. auditArr.push(
  153. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  154. )
  155. });
  156. this.state.achievementCategoryOption = theArr;
  157. this.state.auditStatusOption = auditArr;
  158. if (window.location.search) {
  159. let theObj = getSearchUrl(window.location.search);
  160. if (theObj.rid) {
  161. theObj.id = theObj.rid;
  162. if (theObj.rid != 'null' && theObj.uid != 'null') {
  163. this.tableRowClick(theObj);
  164. };
  165. };
  166. };
  167. this.loadData();
  168. },
  169. tableRowClick(record, index) {
  170. this.state.RowData = record;
  171. this.setState({
  172. showDesc: true
  173. });
  174. },
  175. delectRow() {
  176. let deletedIds = [];
  177. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  178. let rowItem = this.state.selectedRows[idx];
  179. if (rowItem.id) {
  180. deletedIds.push(rowItem.id)
  181. };
  182. };
  183. this.setState({
  184. selectedRowKeys: [],
  185. loading: deletedIds.length > 0
  186. });
  187. $.ajax({
  188. method: "POST",
  189. dataType: "json",
  190. crossDomain: false,
  191. url: globalConfig.context + "/api/admin/achievement/delete",
  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. addClick() {
  208. this.state.RowData = {};
  209. this.setState({
  210. showDesc: true
  211. });
  212. },
  213. closeDesc(e, s) {
  214. this.state.showDesc = e;
  215. if (s) {
  216. this.loadData();
  217. };
  218. },
  219. search() {
  220. this.loadData();
  221. },
  222. reset() {
  223. this.state.serialNumber = undefined;
  224. this.state.name = undefined;
  225. this.state.keyword = undefined;
  226. this.state.category = undefined;
  227. this.state.ownerType = undefined;
  228. this.state.releaseStatus = undefined;
  229. this.state.auditStatus = undefined;
  230. this.state.releaseDate = [];
  231. this.loadData();
  232. },
  233. searchSwitch() {
  234. this.setState({
  235. searchMore: !this.state.searchMore
  236. });
  237. },
  238. render() {
  239. const rowSelection = {
  240. selectedRowKeys: this.state.selectedRowKeys,
  241. onChange: (selectedRowKeys, selectedRows) => {
  242. this.setState({
  243. selectedRows: selectedRows,
  244. selectedRowKeys: selectedRowKeys
  245. });
  246. }
  247. };
  248. const hasSelected = this.state.selectedRowKeys.length > 0;
  249. const { RangePicker } = DatePicker;
  250. return (
  251. <div className="user-content" >
  252. <div className="content-title">
  253. <span>科技成果管理</span>
  254. <div className="patent-addNew">
  255. <Button type="primary" onClick={this.addClick}>发布成果<Icon type="plus" /></Button>
  256. </div>
  257. </div>
  258. <div className="user-search">
  259. <Input placeholder="编号"
  260. value={this.state.serialNumber}
  261. onChange={(e) => { this.setState({ serialNumber: e.target.value }); }} />
  262. <Input placeholder="名称"
  263. value={this.state.name}
  264. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  265. <Input placeholder="关键字"
  266. value={this.state.keyword}
  267. onChange={(e) => { this.setState({ keyword: e.target.value }); }} />
  268. <Select placeholder="选择类型" style={{ width: 160 }}
  269. value={this.state.category}
  270. onChange={(e) => { this.setState({ category: e }) }}>
  271. {this.state.achievementCategoryOption}
  272. </Select>
  273. <Select placeholder="选择审核状态"
  274. style={{ width: 160 }}
  275. value={this.state.auditStatus}
  276. onChange={(e) => { this.setState({ auditStatus: e }) }}>
  277. {this.state.auditStatusOption}
  278. </Select>
  279. <Select placeholder="选择是否发布" style={{ width: 120 }}
  280. value={this.state.releaseStatus}
  281. onChange={(e) => { this.setState({ releaseStatus: e }) }}>
  282. <Select.Option value="0" >未发布</Select.Option>
  283. <Select.Option value="1" >已发布</Select.Option>
  284. </Select>
  285. <Button type="primary" onClick={this.search}>搜索</Button>
  286. <Button onClick={this.reset}>重置</Button>
  287. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  288. disabled={!hasSelected}
  289. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  290. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  291. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  292. <Select placeholder="选择所有人类型"
  293. style={{ width: 140 }}
  294. value={this.state.ownerType}
  295. onChange={(e) => { this.setState({ ownerType: e }) }}>
  296. <Select.Option value="0" >个人</Select.Option>
  297. <Select.Option value="1" >组织</Select.Option>
  298. </Select>
  299. <span>发布时间 :</span>
  300. <RangePicker
  301. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  302. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  303. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  304. </div>
  305. </div>
  306. <div className="patent-table">
  307. <Spin spinning={this.state.loading}>
  308. <Table columns={this.state.columns}
  309. dataSource={this.state.dataSource}
  310. rowSelection={rowSelection}
  311. pagination={this.state.pagination}
  312. onRowClick={this.tableRowClick} />
  313. </Spin>
  314. </div>
  315. <TechAchievementDesc
  316. data={this.state.RowData}
  317. achievementCategoryOption={this.state.achievementCategoryOption}
  318. showDesc={this.state.showDesc}
  319. closeDesc={this.closeDesc} />
  320. </div >
  321. );
  322. }
  323. });
  324. export default AchievementList;