demandExamine.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. loading: true
  14. });
  15. $.ajax({
  16. method: "get",
  17. dataType: "json",
  18. crossDomain: false,
  19. url: globalConfig.context + "/api/admin/demand/list",
  20. data: {
  21. pageNo: pageNo || 1,
  22. pageSize: this.state.pagination.pageSize,
  23. employerName: this.state.employerNameSearch,//客户名称
  24. name: this.state.nameSearch,
  25. demandType: this.state.demandTypeSearch ? Number(this.state.demandTypeSearch) : undefined,
  26. status: this.state.statusSearch ? Number(this.state.statusSearch) : undefined,
  27. startDate: this.state.releaseDate[0],
  28. endDate: this.state.releaseDate[1],
  29. auditStatus: 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. title: '审核',
  155. dataIndex: 'caozuo',
  156. key: 'caozuo',
  157. render:(text,recard) => {
  158. return <div className="btnRight">
  159. <Button type="primary" onClick={(e)=>{e.stopPropagation();this.tableRowClick(recard)}}>审核</Button>
  160. </div>
  161. }
  162. }
  163. ],
  164. dataSource: [],
  165. searchTime: [,]
  166. };
  167. },
  168. componentWillMount() {
  169. let theArr = [];
  170. demandTypeList.map(function (item) {
  171. theArr.push(
  172. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  173. )
  174. });
  175. this.state.demandTypeOption = theArr;
  176. this.loadData();
  177. },
  178. tableRowClick(record, index) {
  179. this.state.RowData = record;
  180. this.setState({
  181. showDesc: true,
  182. examineState:true
  183. });
  184. },
  185. delectRow(recard) {
  186. this.setState({
  187. loading:true
  188. })
  189. $.ajax({
  190. method: "POST",
  191. dataType: "json",
  192. crossDomain: false,
  193. url: globalConfig.context + "/api/user/demand/delete",
  194. data: {
  195. ids: recard.id
  196. }
  197. }).done(function (data) {
  198. if (!data.error.length) {
  199. message.success('删除成功!');
  200. this.setState({
  201. loading: false,
  202. });
  203. } else {
  204. message.warning(data.error[0].message);
  205. };
  206. this.loadData();
  207. }.bind(this));
  208. },
  209. closeDesc(e, s) {
  210. this.state.showDesc = e;
  211. if (s) {
  212. if(this.state.pagination.total%10==1){
  213. this.loadData((this.state.page)-1);
  214. }else{
  215. this.loadData(this.state.page);
  216. }
  217. };
  218. },
  219. search() {
  220. this.loadData();
  221. },
  222. reset() {
  223. this.state.nameSearch = '';
  224. this.state.demandTypeSearch = undefined;
  225. this.state.auditStatus = undefined;
  226. this.state.statusSearch = undefined;
  227. this.state.employerNameSearch='';
  228. this.state.releaseDate = [];
  229. this.loadData();
  230. },
  231. searchSwitch() {
  232. this.setState({
  233. searchMore: !this.state.searchMore
  234. });
  235. },
  236. render() {
  237. const rowSelection = {
  238. selectedRowKeys: this.state.selectedRowKeys,
  239. onChange: (selectedRowKeys, selectedRows) => {
  240. this.setState({
  241. selectedRows: selectedRows.slice(-1),
  242. selectedRowKeys: selectedRowKeys.slice(-1)
  243. });
  244. }
  245. };
  246. const hasSelected = this.state.selectedRowKeys.length > 0;
  247. const { RangePicker } = DatePicker;
  248. return (
  249. <div className="user-content" >
  250. <div className="content-title">
  251. <span>需求发布审核</span>
  252. </div>
  253. <div className="user-search">
  254. <Input placeholder="需求名称"
  255. value={this.state.nameSearch}
  256. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  257. <Select placeholder="选择需求类型"
  258. style={{ width: 120 }}
  259. value={this.state.demandTypeSearch}
  260. onChange={(e) => { this.setState({ demandTypeSearch: e }) }}>
  261. {this.state.demandTypeOption}
  262. </Select>
  263. <Select placeholder="需求状态" style={{ width: 160 }}
  264. value={this.state.statusSearch}
  265. onChange={(e) => { this.setState({ statusSearch: e }) }}>
  266. <Select.Option value="0" >进行中</Select.Option>
  267. <Select.Option value="1" >未解决</Select.Option>
  268. <Select.Option value="2" >已解决</Select.Option>
  269. </Select>
  270. <Button type="primary" onClick={this.search}>搜索</Button>
  271. <Button onClick={this.reset}>重置</Button>
  272. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  273. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  274. <Input style={{width:140,marginRight:10}} value={this.state.employerNameSearch} onChange={(e)=>{this.setState({employerNameSearch:e.target.value})}} placeholder="客户名称"/>
  275. <span>发布时间 :</span>
  276. <RangePicker
  277. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  278. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  279. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  280. </div>
  281. </div>
  282. <div className="patent-table">
  283. <Spin spinning={this.state.loading}>
  284. <Table columns={this.state.columns}
  285. dataSource={this.state.dataSource}
  286. rowSelection={rowSelection}
  287. pagination={this.state.pagination}
  288. />
  289. </Spin>
  290. </div>
  291. <TechDemandDesc
  292. data={this.state.RowData}
  293. demandTypeOption={this.state.demandTypeOption}
  294. examineState={this.state.examineState}
  295. showDesc={this.state.showDesc}
  296. closeDesc={this.closeDesc} />
  297. </div >
  298. );
  299. }
  300. });
  301. export default DemandList;