techDemand.jsx 12 KB

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