techAchievementQuery.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. import React from 'react';
  2. import { Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload,Tabs } 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 './techAchievementQueryDesc.jsx';
  8. import { achievementCategoryList, techAuditStatusList } from '../../dataDic.js';
  9. import { beforeUploadFile, companySearch, getAchievementCategory, getSearchUrl, getTechAuditStatus ,getboutique,gethot} from '../../tools.js';
  10. import BatchImport from './batchImport';
  11. import {ChooseList} from "../order/orderNew/chooseList";
  12. const {TabPane} = Tabs
  13. const AchievementList = React.createClass({
  14. loadData(pageNo, apiUrl) {
  15. this.state.data = [];
  16. if(this.state.serialNumber&&isNaN(this.state.serialNumber)){
  17. message.warning('请输入正确的编号格式');
  18. return false;
  19. }
  20. this.setState({
  21. loading: true
  22. });
  23. $.ajax({
  24. method: "get",
  25. dataType: "json",
  26. crossDomain: false,
  27. url: globalConfig.context + (apiUrl || this.props['data-listApiUrl']),
  28. data: {
  29. pageNo: pageNo || 1,
  30. pageSize: this.state.pagination.pageSize,
  31. serialNumber: this.state.serialNumber, //编号
  32. name: this.state.name, //名称
  33. recordPerson: this.state.recordPerson,
  34. ownerName: this.state.ownerName,
  35. username: this.state.searchType == 0 && this.props['data-listApiUrl'].indexOf('org') == -1 ? this.state.searchName : undefined,
  36. unitName: this.state.searchType == 0 && this.props['data-listApiUrl'].indexOf('user') == -1 ? this.state.searchName : undefined,
  37. keyword: this.state.keyword, // 关键词
  38. category: this.state.category, //类型(0--专利, 2--软著, 3--项目, 4--版权, 5--工业设计, 6--配方, 7--非标)
  39. releaseDateStartDate: this.state.releaseDate[0],
  40. releaseDateEndDate: this.state.releaseDate[1],
  41. releaseStatus: this.state.releaseStatus ? Number(this.state.releaseStatus) : undefined, //是否发布(0--未发布,1--已发布)
  42. auditStatus: this.state.auditStatus,
  43. boutique:this.state.boutique,
  44. hot:this.state.hot,
  45. createDateStartDate: this.state.releaseDateS[0],
  46. createDateEndDate: this.state.releaseDateS[1],
  47. ownerType:this.state.ownerType,
  48. },
  49. success: function (data) {
  50. let theArr = [];
  51. if (!data.data || !data.data.list) {
  52. if (data.error && data.error.length) {
  53. message.warning(data.error[0].message);
  54. };
  55. } else {
  56. for (let i = 0; i < data.data.list.length; i++) {
  57. let thisdata = data.data.list[i];
  58. theArr.push({
  59. key: i,
  60. id: thisdata.id,
  61. serialNumber: thisdata.serialNumber,
  62. dataCategory: thisdata.dataCategory,
  63. name: thisdata.name,
  64. keyword: thisdata.keyword,
  65. theName: thisdata.username || thisdata.ownerName,
  66. category: thisdata.category,
  67. ownerName: thisdata.username ? thisdata.username : thisdata.ownerName,
  68. ownerType: thisdata.ownerType,
  69. ownerMobile: thisdata.ownerMobile,
  70. status: thisdata.status,
  71. releaseDate: thisdata.releaseDate,
  72. releaseDateFormattedDate: thisdata.releaseDateFormattedDate,
  73. auditStatus: thisdata.auditStatus,
  74. boutique: thisdata.boutique,
  75. hot: thisdata.hot,
  76. techBrokerId:thisdata.techBrokerId,
  77. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  78. remark:thisdata.remark
  79. });
  80. };
  81. this.state.pagination.current = data.data.pageNo;
  82. this.state.pagination.total = data.data.totalCount;
  83. };
  84. this.setState({
  85. dataSource: theArr,
  86. pagination: this.state.pagination
  87. });
  88. }.bind(this),
  89. }).always(function () {
  90. this.setState({
  91. loading: false
  92. });
  93. }.bind(this));
  94. },
  95. getInitialState() {
  96. return {
  97. searchMore: true,
  98. searchType: 0,
  99. validityPeriodDate: [],
  100. releaseDate: [],
  101. releaseDateS: [],
  102. selectedRowKeys: [],
  103. selectedRows: [],
  104. loading: false,
  105. pagination: {
  106. defaultCurrent: 1,
  107. defaultPageSize: 10,
  108. showQuickJumper: true,
  109. pageSize: 10,
  110. onChange: function (page) {
  111. this.loadData(page);
  112. }.bind(this),
  113. showTotal: function (total) {
  114. return '共' + total + '条数据';
  115. }
  116. },
  117. columns: [
  118. {
  119. title: '编号',
  120. dataIndex: 'serialNumber',
  121. key: 'serialNumber',
  122. }, {
  123. title: '名称',
  124. dataIndex: 'name',
  125. key: 'name',
  126. }, {
  127. title: '关键字',
  128. dataIndex: 'keyword',
  129. key: 'keyword',
  130. }, {
  131. title: '类型',
  132. dataIndex: 'category',
  133. key: 'category',
  134. render: text => { return getAchievementCategory(text); }
  135. }, {
  136. title: '录入人',
  137. dataIndex: 'techBrokerId',
  138. key: 'techBrokerId',
  139. },{
  140. title: '审核状态',
  141. dataIndex: 'auditStatus',
  142. key: 'auditStatus',
  143. render: text => { return getTechAuditStatus(text) }
  144. },
  145. {
  146. title: '是否精品',
  147. dataIndex: 'boutique',
  148. key: 'boutique',
  149. render: text => { return getboutique(text) }
  150. },
  151. {
  152. title: '发布时间',
  153. dataIndex: 'releaseDateFormattedDate',
  154. key: 'releaseDateFormattedDate',
  155. },{
  156. title: '录入时间',
  157. dataIndex: 'createTimeFormattedDate',
  158. key: 'createTimeFormattedDate',
  159. },
  160. ],
  161. dataSource: [],
  162. searchTime: [,]
  163. };
  164. },
  165. componentWillMount() {
  166. let theArr = [];
  167. achievementCategoryList.map(function (item) {
  168. theArr.push(
  169. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  170. )
  171. });
  172. let auditArr = [];
  173. techAuditStatusList.map(function (item) {
  174. auditArr.push(
  175. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  176. )
  177. });
  178. this.state.achievementCategoryOption = theArr;
  179. this.state.auditStatusOption = auditArr;
  180. if (window.location.search) {
  181. let theObj = getSearchUrl(window.location.search);
  182. if (theObj.rid) {
  183. theObj.id = theObj.rid;
  184. if (theObj.rid != 'null') {
  185. this.tableRowClick(theObj);
  186. };
  187. };
  188. };
  189. this.loadData();
  190. },
  191. componentWillReceiveProps(nextProps) {
  192. if (this.props['data-listApiUrl'] != nextProps['data-listApiUrl']) {
  193. this.state.selectedRowKeys = [];
  194. this.state.selectedRows = [];
  195. this.state.serialNumber = undefined;
  196. this.state.name = undefined;
  197. this.state.keyword = undefined;
  198. this.state.category = undefined;
  199. this.state.ownerType = undefined;
  200. this.state.releaseStatus = undefined;
  201. this.state.auditStatus = undefined;
  202. this.state.searchName = undefined;
  203. this.state.searchType = 0;
  204. this.state.releaseDate = [];
  205. this.state.releaseDateS = [];
  206. this.loadData(null, nextProps['data-listApiUrl']);
  207. };
  208. },
  209. tableRowClick(record, index) {
  210. this.state.RowData = record;
  211. if(index!=undefined){
  212. this.setState({
  213. showDesc: true
  214. });
  215. }
  216. },
  217. addClick() {
  218. this.state.RowData = {};
  219. this.setState({
  220. showDesc: true
  221. });
  222. },
  223. closeDesc(e, s) {
  224. this.state.showDesc = e;
  225. if (s) {
  226. this.loadData();
  227. };
  228. },
  229. search() {
  230. this.loadData();
  231. },
  232. reset() {
  233. this.state.serialNumber = undefined;
  234. this.state.name = undefined;
  235. this.state.ownerName= undefined;
  236. this.state.recordPerson= undefined;
  237. this.state.keyword = undefined;
  238. this.state.category = undefined;
  239. this.state.ownerType = undefined;
  240. this.state.releaseStatus = undefined;
  241. this.state.auditStatus = undefined;
  242. this.state.searchName = undefined;
  243. this.state.releaseDate = [];
  244. this.state.releaseDateS = [];
  245. this.state.boutique = '';
  246. this.state.hot='' ;
  247. this.loadData();
  248. },
  249. searchSwitch() {
  250. this.setState({
  251. searchMore: !this.state.searchMore
  252. });
  253. },
  254. changeList(arr) {
  255. const newArr = [];
  256. this.state.columns.forEach(item => {
  257. arr.forEach(val => {
  258. if (val === item.title) {
  259. newArr.push(item);
  260. }
  261. });
  262. });
  263. this.setState({
  264. changeList: newArr
  265. });
  266. },
  267. render() {
  268. const rowSelection = {
  269. selectedRowKeys: this.state.selectedRowKeys,
  270. onChange: (selectedRowKeys, selectedRows) => {
  271. this.setState({
  272. selectedRows: selectedRows.slice(-1),
  273. selectedRowKeys: selectedRowKeys.slice(-1)
  274. });
  275. }
  276. };
  277. const hasSelected = this.state.selectedRowKeys.length > 0;
  278. const { RangePicker } = DatePicker;
  279. return (
  280. <div className="user-content" >
  281. <div className="content-title">
  282. {this.props['data-listApiUrl'].indexOf('org') == -1 ? <span>个人科技成果管理</span> : <span>科技成果查询</span>}
  283. <div className="patent-addNew clearfix">
  284. <Upload
  285. action={globalConfig.context + "/api/admin/achievement/uploadTemplate"}
  286. data={{ 'sign': 'achievement_template' }}
  287. beforeUpload={beforeUploadFile}
  288. showUploadList={false}
  289. onChange={(info) => {
  290. if (info.file.status !== 'uploading') {
  291. }
  292. if (info.file.status === 'done') {
  293. if (!info.file.response.error.length) {
  294. message.success(`${info.file.name} 文件上传成功!`);
  295. } else {
  296. message.warning(info.file.response.error[0].message);
  297. return;
  298. };
  299. } else if (info.file.status === 'error') {
  300. message.error(`${info.file.name} 文件上传失败。`);
  301. };
  302. }} >
  303. <Button style={{"display":"none"}}>上传批量导入模板</Button>
  304. </Upload>
  305. <Button onClick={() => { window.open(globalConfig.context + '/api/admin/achievement/downloadTemplate?sign=achievement_template') }} style={{"display":"none"}}>下载批量导入模板</Button>
  306. <Button type="primary" className="addButton" onClick={this.addClick} style={{"display":"none"}}>发布成果<Icon type="plus" /></Button>
  307. </div>
  308. </div>
  309. <Tabs
  310. defaultActiveKey="1"
  311. onChange={this.callback}
  312. className="test">
  313. <TabPane tab="搜索" key="1">
  314. <div className="user-search">
  315. <Input placeholder="编号"
  316. value={this.state.serialNumber}
  317. onChange={(e) => { this.setState({ serialNumber: e.target.value }); }} />
  318. <Input placeholder="名称"
  319. value={this.state.name}
  320. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  321. <Input placeholder="关键字"
  322. value={this.state.keyword}
  323. onChange={(e) => { this.setState({ keyword: e.target.value }); }} />
  324. <Input placeholder="录入人名称"
  325. value={this.state.recordPerson}
  326. onChange={(e) => { this.setState({ recordPerson: e.target.value }); }} />
  327. <Input placeholder="成果所有人"
  328. value={this.state.ownerName}
  329. onChange={(e) => { this.setState({ ownerName: e.target.value }); }} />
  330. <Radio.Group value={this.state.searchType} onChange={(e) => {
  331. this.setState({ searchType: e.target.value })
  332. }}>
  333. <Radio value={0}>认证用户</Radio>
  334. <Radio value={1}>非认证用户</Radio>
  335. </Radio.Group>
  336. <Button type="primary" onClick={this.search}>搜索</Button>
  337. <Button onClick={this.reset}>重置</Button>
  338. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  339. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  340. <Radio.Group value={this.state.boutique} onChange={(e) => {
  341. this.setState({ boutique: e.target.value })
  342. }}>
  343. <Radio value={1}>精品</Radio>
  344. <Radio value={0}>非精品</Radio>
  345. </Radio.Group>
  346. <Select placeholder="选择类型" style={{ width: 160 }}
  347. value={this.state.category}
  348. onChange={(e) => { this.setState({ category: e }) }}>
  349. {this.state.achievementCategoryOption}
  350. </Select>
  351. <Select placeholder="选择审核状态"
  352. style={{ width: 160 }}
  353. value={this.state.auditStatus}
  354. onChange={(e) => { this.setState({ auditStatus: e }) }}>
  355. {this.state.auditStatusOption}
  356. </Select>
  357. <Select placeholder="选择是否发布" style={{ width: 120 }}
  358. value={this.state.releaseStatus}
  359. onChange={(e) => { this.setState({ releaseStatus: e }) }}>
  360. <Select.Option value="0" >未发布</Select.Option>
  361. <Select.Option value="1" >已发布</Select.Option>
  362. </Select>
  363. <Select placeholder="选择所有人类型" style={{ width: 120 }}
  364. value={this.state.ownerType}
  365. onChange={(e) => { this.setState({ ownerType: e }) }}>
  366. <Select.Option value="0" >个人</Select.Option>
  367. <Select.Option value="1" >组织</Select.Option>
  368. </Select>
  369. <div style={{marginTop:'10px'}}>
  370. <span>发布时间 :</span>
  371. <RangePicker
  372. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  373. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  374. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  375. <span style={{marginLeft:'5px'}}>录入时间 :</span>
  376. <RangePicker
  377. value={[this.state.releaseDateS[0] ? moment(this.state.releaseDateS[0]) : null,
  378. this.state.releaseDateS[1] ? moment(this.state.releaseDateS[1]) : null]}
  379. onChange={(data, dataString) => { this.setState({ releaseDateS: dataString }); }} />
  380. </div>
  381. </div>
  382. </div>
  383. </TabPane>
  384. <TabPane tab="更改表格显示数据" key="2">
  385. <div style={{ marginLeft: 10 }}>
  386. <ChooseList
  387. columns={this.state.columns}
  388. changeFn={this.changeList}
  389. changeList={this.state.changeList}
  390. top={55}
  391. margin={11}
  392. />
  393. </div>
  394. </TabPane>
  395. </Tabs>
  396. <div className="patent-table">
  397. <Spin spinning={this.state.loading}>
  398. <Table columns={
  399. this.state.changeList
  400. ? this.state.changeList
  401. : this.state.columns
  402. }
  403. style={{
  404. cursor: 'pointer',
  405. }}
  406. dataSource={this.state.dataSource}
  407. rowSelection={rowSelection}
  408. pagination={this.state.pagination}
  409. onRowClick={this.tableRowClick} />
  410. </Spin>
  411. </div>
  412. <TechAchievementDesc
  413. data={this.state.RowData}
  414. detailApiUrl={this.props['data-detailApiUrl']}
  415. achievementCategoryOption={this.state.achievementCategoryOption}
  416. showDesc={this.state.showDesc}
  417. closeDesc={this.closeDesc} />
  418. </div >
  419. );
  420. }
  421. });
  422. export default AchievementList;