DemandExamine.jsx 12 KB

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