demandExamine.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. this.loadData(this.state.page);
  213. };
  214. },
  215. search() {
  216. this.loadData();
  217. },
  218. reset() {
  219. this.state.nameSearch = '';
  220. this.state.demandTypeSearch = undefined;
  221. this.state.auditStatus = undefined;
  222. this.state.statusSearch = undefined;
  223. this.state.employerNameSearch='';
  224. this.state.releaseDate = [];
  225. this.loadData();
  226. },
  227. searchSwitch() {
  228. this.setState({
  229. searchMore: !this.state.searchMore
  230. });
  231. },
  232. render() {
  233. const rowSelection = {
  234. selectedRowKeys: this.state.selectedRowKeys,
  235. onChange: (selectedRowKeys, selectedRows) => {
  236. this.setState({
  237. selectedRows: selectedRows.slice(-1),
  238. selectedRowKeys: selectedRowKeys.slice(-1)
  239. });
  240. }
  241. };
  242. const hasSelected = this.state.selectedRowKeys.length > 0;
  243. const { RangePicker } = DatePicker;
  244. return (
  245. <div className="user-content" >
  246. <div className="content-title">
  247. <span>需求发布审核</span>
  248. </div>
  249. <div className="user-search">
  250. <Input placeholder="需求名称"
  251. value={this.state.nameSearch}
  252. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  253. <Select placeholder="选择需求类型"
  254. style={{ width: 120 }}
  255. value={this.state.demandTypeSearch}
  256. onChange={(e) => { this.setState({ demandTypeSearch: e }) }}>
  257. {this.state.demandTypeOption}
  258. </Select>
  259. <Select placeholder="需求状态" style={{ width: 160 }}
  260. value={this.state.statusSearch}
  261. onChange={(e) => { this.setState({ statusSearch: e }) }}>
  262. <Select.Option value="0" >进行中</Select.Option>
  263. <Select.Option value="1" >未解决</Select.Option>
  264. <Select.Option value="2" >已解决</Select.Option>
  265. </Select>
  266. <Button type="primary" onClick={this.search}>搜索</Button>
  267. <Button onClick={this.reset}>重置</Button>
  268. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  269. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  270. <Input style={{width:140,marginRight:10}} value={this.state.employerNameSearch} onChange={(e)=>{this.setState({employerNameSearch:e.target.value})}} placeholder="客户名称"/>
  271. <span>发布时间 :</span>
  272. <RangePicker
  273. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  274. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  275. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  276. </div>
  277. </div>
  278. <div className="patent-table">
  279. <Spin spinning={this.state.loading}>
  280. <Table columns={this.state.columns}
  281. dataSource={this.state.dataSource}
  282. rowSelection={rowSelection}
  283. pagination={this.state.pagination}
  284. />
  285. </Spin>
  286. </div>
  287. <TechDemandDesc
  288. data={this.state.RowData}
  289. demandTypeOption={this.state.demandTypeOption}
  290. examineState={this.state.examineState}
  291. showDesc={this.state.showDesc}
  292. closeDesc={this.closeDesc} />
  293. </div >
  294. );
  295. }
  296. });
  297. export default DemandList;