demandExamine.jsx 12 KB

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