techAchievement.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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 TechDemandDesc from './achievementDesc.jsx';
  8. import { achievementType,achievementCategoryList } from '@/dataDic.js';
  9. import { IndustryObject, getIndustryCategory } from '@/DicIndustryList.js';
  10. import { getTransaction,getReleaseStateList ,getAchievementCategory,getAchievementType} from '@/tools.js';
  11. const DemandList = React.createClass({
  12. loadData(pageNo) {
  13. this.state.data = [];
  14. this.setState({
  15. page:pageNo,
  16. loading: true
  17. });
  18. $.ajax({
  19. method: "get",
  20. dataType: "json",
  21. crossDomain: false,
  22. url: globalConfig.context + "/api/admin/achievement/list",
  23. data: {
  24. pageNo: pageNo || 1,
  25. pageSize: this.state.pagination.pageSize,
  26. ownerName: this.state.employerNameSearch,//客户名称
  27. name: this.state.nameSearch,
  28. dataCategory: this.state.dataCategorySearch ? Number(this.state.dataCategorySearch) : undefined,
  29. auditStatus:this.state.auditStatusSearch,
  30. startDate: this.state.releaseDate[0],
  31. endDate: this.state.releaseDate[1],
  32. },
  33. success: function (data) {
  34. let theArr = [];
  35. if (!data.data || !data.data.list) {
  36. if (data.error && data.error.length) {
  37. message.warning(data.error[0].message);
  38. };
  39. } else {
  40. for (let i = 0; i < data.data.list.length; i++) {
  41. let thisdata = data.data.list[i];
  42. theArr.push({
  43. key: i,
  44. id: thisdata.id,
  45. serialNumber: thisdata.serialNumber,
  46. name: thisdata.name,
  47. category:thisdata.category,
  48. fieldA:thisdata.thisdata,
  49. fieldB:thisdata.fieldB,
  50. dataCategory: thisdata.dataCategory,
  51. auditStatus: thisdata.auditStatus,
  52. isHot: thisdata.isHot,
  53. boutique: thisdata.boutique,
  54. ownerName:thisdata.ownerName,
  55. releaseDate:thisdata.releaseDate?(new Date(thisdata.releaseDate)).toLocaleString():''
  56. });
  57. };
  58. }
  59. this.state.pagination.current = data.data.pageNo;
  60. this.state.pagination.total = data.data.totalCount;
  61. if(data.data&&data.data.list&&!data.data.list.length){
  62. this.state.pagination.current=0
  63. this.state.pagination.total=0
  64. }
  65. this.setState({
  66. dataSource: theArr,
  67. pagination: this.state.pagination
  68. });
  69. }.bind(this),
  70. }).always(function () {
  71. this.setState({
  72. loading: false
  73. });
  74. }.bind(this));
  75. },
  76. getInitialState() {
  77. return {
  78. searchMore: true,
  79. validityPeriodDate: [],
  80. releaseDate: [],
  81. selectedRowKeys: [],
  82. selectedRows: [],
  83. loading: false,
  84. pagination: {
  85. defaultCurrent: 1,
  86. defaultPageSize: 10,
  87. showQuickJumper: true,
  88. pageSize: 10,
  89. onChange: function (page) {
  90. this.loadData(page);
  91. }.bind(this),
  92. showTotal: function (total) {
  93. return '共' + total + '条数据';
  94. }
  95. },
  96. columns: [
  97. {
  98. title: '编号',
  99. dataIndex: 'serialNumber',
  100. key: 'serialNumber',
  101. }, {
  102. title: '成果名称',
  103. dataIndex: 'name',
  104. key: 'name',
  105. }, {
  106. title: '成果类型',
  107. dataIndex: 'dataCategory',
  108. key: 'dataCategory',
  109. render: (text) => { return getAchievementType(text); }
  110. },
  111. {
  112. title: '知识产权类型',
  113. dataIndex: 'category',
  114. key: 'category',
  115. render: (text) => { return getAchievementCategory(text); }
  116. },
  117. {
  118. title: '精品标识',
  119. dataIndex: 'boutique',
  120. key: 'boutique',
  121. render: text => { return text?'精品':'非精品' }
  122. },
  123. {
  124. title: '客户名称',
  125. dataIndex: 'ownerName',
  126. key: 'ownerName'
  127. },
  128. {
  129. title: '发布状态',
  130. dataIndex: 'auditStatus',
  131. key: 'auditStatus',
  132. render: text => { return getReleaseStateList(text) }
  133. },
  134. {
  135. title: '发布时间',
  136. dataIndex: 'releaseDate',
  137. key: 'releaseDate'
  138. }
  139. ],
  140. dataSource: [],
  141. searchTime: [,]
  142. };
  143. },
  144. componentWillMount() {
  145. let theArr = [];
  146. achievementType.map(function (item) {
  147. theArr.push(
  148. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  149. )
  150. });
  151. this.state.demandTypeOption = theArr;
  152. this.loadData();
  153. },
  154. tableRowClick(record, index) {
  155. this.state.RowData = record;
  156. this.setState({
  157. showDesc: true,
  158. examineState:false
  159. });
  160. },
  161. delectRow(recard) {
  162. this.setState({
  163. loading:true
  164. })
  165. let deletedIds =[];
  166. let rowItem = this.state.selectedRowKeys[0];
  167. let data = this.state.dataSource ||[];
  168. if (data.length) {
  169. deletedIds.push(data[rowItem].id);
  170. }
  171. $.ajax({
  172. method: "POST",
  173. dataType: "json",
  174. crossDomain: false,
  175. url: globalConfig.context + "/api/admin/achievement/annul",
  176. data: {
  177. id: deletedIds[0]
  178. }
  179. }).done(function (data) {
  180. if (!data.error.length) {
  181. message.success('下架成功!');
  182. this.setState({
  183. loading: false,
  184. selectedRowKeys:[],
  185. });
  186. } else {
  187. message.warning(data.error[0].message);
  188. };
  189. this.loadData();
  190. }.bind(this));
  191. },
  192. closeDesc(e, s) {
  193. this.state.showDesc = e;
  194. if (s) {
  195. this.loadData(this.state.page);
  196. };
  197. },
  198. search() {
  199. this.loadData();
  200. },
  201. reset() {
  202. this.state.nameSearch = '';
  203. this.state.dataCategorySearch = undefined;
  204. this.state.auditStatusSearch = undefined;
  205. this.state.releaseDate = [];
  206. this.state.employerNameSearch=''
  207. this.loadData();
  208. },
  209. searchSwitch() {
  210. this.setState({
  211. searchMore: !this.state.searchMore
  212. });
  213. },
  214. render() {
  215. const rowSelection = {
  216. selectedRowKeys: this.state.selectedRowKeys,
  217. onChange: (selectedRowKeys, selectedRows) => {
  218. this.setState({
  219. selectedRows: selectedRows.slice(-1),
  220. selectedRowKeys: selectedRowKeys.slice(-1)
  221. });
  222. }
  223. };
  224. const hasSelected = this.state.selectedRowKeys.length > 0;
  225. const { RangePicker } = DatePicker;
  226. const hasSelect = this.state.selectedRowKeys.length;
  227. return (
  228. <div className="user-content" >
  229. <div className="content-title">
  230. <span>科技成果库</span>
  231. </div>
  232. <div className="user-search">
  233. <Input placeholder="成果名称"
  234. value={this.state.nameSearch}
  235. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  236. <Select placeholder="发布状态" style={{ width: 120 }}
  237. value={this.state.auditStatusSearch}
  238. onChange={(e) => { this.setState({ auditStatusSearch: e }) }}>
  239. <Select.Option value="0" >草稿</Select.Option>
  240. <Select.Option value="1" >发布审核</Select.Option>
  241. <Select.Option value="2" >已发布</Select.Option>
  242. <Select.Option value="3" >发布失败</Select.Option>
  243. <Select.Option value="4" >已撤销</Select.Option>
  244. </Select>
  245. <Select placeholder="成果类型" style={{ width: 120 }}
  246. value={this.state.dataCategorySearch}
  247. onChange={(e) => { this.setState({ dataCategorySearch: e }) }}>
  248. {
  249. achievementType.map(function (item) {
  250. return <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  251. })
  252. }
  253. </Select>
  254. <Button type="primary" onClick={this.search}>搜索</Button>
  255. <Button onClick={this.reset}>重置</Button>
  256. <Button type="danger" disabled={!hasSelect} onClick={(e)=>{this.delectRow()}}>下架</Button>
  257. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  258. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  259. <Input style={{width:140,marginRight:10}} value={this.state.employerNameSearch} onChange={(e)=>{this.setState({employerNameSearch:e.target.value})}} placeholder="客户名称"/>
  260. <span>发布时间 :</span>
  261. <RangePicker
  262. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  263. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  264. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  265. </div>
  266. </div>
  267. <div className="patent-table">
  268. <Spin spinning={this.state.loading}>
  269. <Table columns={this.state.columns}
  270. dataSource={this.state.dataSource}
  271. rowSelection={rowSelection}
  272. pagination={this.state.pagination}
  273. onRowClick={this.tableRowClick} />
  274. </Spin>
  275. </div>
  276. <TechDemandDesc
  277. data={this.state.RowData}
  278. examineState={this.state.examineState}
  279. demandTypeOption={this.state.demandTypeOption}
  280. showDesc={this.state.showDesc}
  281. closeDesc={this.closeDesc} />
  282. </div>
  283. );
  284. }
  285. });
  286. export default DemandList;