techDemand.jsx 13 KB

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