techDemand.jsx 12 KB

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