demandExamine.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. render:text=>{
  103. return text&&text.length>16?text.substr(0,16)+'...':text
  104. }
  105. }, {
  106. title: '需求类型',
  107. dataIndex: 'demandType',
  108. key: 'demandType',
  109. render: (text) => { return getDemandType(text); }
  110. },
  111. {
  112. title: '是否热门',
  113. dataIndex: 'isHot',
  114. key: 'isHot',
  115. render: text => { return text?'热门':'非热门'; }
  116. },
  117. {
  118. title: '是否加急',
  119. dataIndex: 'isUrgent',
  120. key: 'isUrgent',
  121. render: text => { return text?'加急':'未加急' }
  122. },
  123. {
  124. title: '客户名称',
  125. dataIndex: 'employerName',
  126. key: 'employerName',
  127. render:text=>{
  128. return text&&text.length>16?text.substr(0,16)+'...':text
  129. }
  130. },
  131. {
  132. title: '发布状态',
  133. dataIndex: 'auditStatus',
  134. key: 'auditStatus',
  135. render: text => { return getReleaseStateList(text) }
  136. },
  137. {
  138. title: '需求状态',
  139. dataIndex: 'status',
  140. key: 'status',
  141. render: text => {
  142. return <div>
  143. {text=='0'&&<span>进行中</span>}
  144. {text=='1'&&<span>未解决</span>}
  145. {text=='2'&&<span>已解决</span>}
  146. </div>
  147. }
  148. },
  149. {
  150. title: '创建时间',
  151. dataIndex: 'createTime',
  152. key: 'createTime'
  153. },
  154. {
  155. title: '发布时间',
  156. dataIndex: 'releaseDate',
  157. key: 'releaseDate'
  158. },
  159. {
  160. title: '审核',
  161. dataIndex: 'caozuo',
  162. key: 'caozuo',
  163. render:(text,recard) => {
  164. return <div className="btnRight">
  165. <Button type="primary" onClick={(e)=>{e.stopPropagation();this.tableRowClick(recard)}}>审核</Button>
  166. </div>
  167. }
  168. }
  169. ],
  170. dataSource: [],
  171. searchTime: [,]
  172. };
  173. },
  174. componentWillMount() {
  175. let theArr = [];
  176. demandTypeList.map(function (item) {
  177. theArr.push(
  178. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  179. )
  180. });
  181. this.state.demandTypeOption = theArr;
  182. this.loadData();
  183. },
  184. tableRowClick(record, index) {
  185. this.state.RowData = record;
  186. this.setState({
  187. showDesc: true,
  188. examineState:true
  189. });
  190. },
  191. delectRow(recard) {
  192. this.setState({
  193. loading:true
  194. })
  195. $.ajax({
  196. method: "POST",
  197. dataType: "json",
  198. crossDomain: false,
  199. url: globalConfig.context + "/api/user/demand/delete",
  200. data: {
  201. ids: recard.id
  202. }
  203. }).done(function (data) {
  204. if (!data.error.length) {
  205. message.success('删除成功!');
  206. this.setState({
  207. loading: false,
  208. });
  209. } else {
  210. message.warning(data.error[0].message);
  211. };
  212. this.loadData();
  213. }.bind(this));
  214. },
  215. closeDesc(e, s) {
  216. this.state.showDesc = e;
  217. if (s) {
  218. if(this.state.pagination.total%10==1){
  219. this.loadData((this.state.page)-1);
  220. }else{
  221. this.loadData(this.state.page);
  222. }
  223. };
  224. },
  225. search() {
  226. this.loadData();
  227. },
  228. reset() {
  229. this.state.nameSearch = '';
  230. this.state.demandTypeSearch = undefined;
  231. this.state.auditStatus = undefined;
  232. this.state.statusSearch = undefined;
  233. this.state.employerNameSearch='';
  234. this.state.releaseDate = [];
  235. this.loadData();
  236. },
  237. searchSwitch() {
  238. this.setState({
  239. searchMore: !this.state.searchMore
  240. });
  241. },
  242. render() {
  243. const rowSelection = {
  244. selectedRowKeys: this.state.selectedRowKeys,
  245. onChange: (selectedRowKeys, selectedRows) => {
  246. this.setState({
  247. selectedRows: selectedRows.slice(-1),
  248. selectedRowKeys: selectedRowKeys.slice(-1)
  249. });
  250. }
  251. };
  252. const hasSelected = this.state.selectedRowKeys.length > 0;
  253. const { RangePicker } = DatePicker;
  254. return (
  255. <div className="user-content" >
  256. <div className="content-title">
  257. <span>需求发布审核</span>
  258. </div>
  259. <div className="user-search">
  260. <Input placeholder="需求名称"
  261. value={this.state.nameSearch}
  262. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  263. <Select placeholder="选择需求类型"
  264. style={{ width: 120 }}
  265. value={this.state.demandTypeSearch}
  266. onChange={(e) => { this.setState({ demandTypeSearch: e }) }}>
  267. {this.state.demandTypeOption}
  268. </Select>
  269. <Select placeholder="需求状态" style={{ width: 160 }}
  270. value={this.state.statusSearch}
  271. onChange={(e) => { this.setState({ statusSearch: e }) }}>
  272. <Select.Option value="0" >进行中</Select.Option>
  273. <Select.Option value="1" >未解决</Select.Option>
  274. <Select.Option value="2" >已解决</Select.Option>
  275. </Select>
  276. <Button type="primary" onClick={this.search}>搜索</Button>
  277. <Button onClick={this.reset}>重置</Button>
  278. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  279. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  280. <Input style={{width:140,marginRight:10}} value={this.state.employerNameSearch} onChange={(e)=>{this.setState({employerNameSearch:e.target.value})}} placeholder="客户名称"/>
  281. {/* <span>发布时间 :</span>
  282. <RangePicker
  283. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  284. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  285. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} /> */}
  286. </div>
  287. </div>
  288. <div className="patent-table">
  289. <Spin spinning={this.state.loading}>
  290. <Table columns={this.state.columns}
  291. dataSource={this.state.dataSource}
  292. rowSelection={rowSelection}
  293. pagination={this.state.pagination}
  294. />
  295. </Spin>
  296. </div>
  297. <TechDemandDesc
  298. data={this.state.RowData}
  299. demandTypeOption={this.state.demandTypeOption}
  300. examineState={this.state.examineState}
  301. showDesc={this.state.showDesc}
  302. closeDesc={this.closeDesc} />
  303. </div >
  304. );
  305. }
  306. });
  307. export default DemandList;