demandDetaiel.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. import React from 'react';
  2. import $ from 'jquery/src/ajax';
  3. import {
  4. Modal,
  5. message,
  6. Spin,
  7. Upload,
  8. Input,
  9. Button,
  10. Form
  11. } from 'antd';
  12. import { getIndustryCategory } from '@/industryList.js';
  13. import { splitUrl, getDemandType,getReleaseStateList,getReleasePositionList } from '@/tools.js';
  14. const DemandDetail = Form.create()(React.createClass({
  15. getInitialState() {
  16. return {
  17. visible: false,
  18. loading: false,
  19. auditStatus: 0,
  20. textFileList: [],
  21. videoFileList: [],
  22. pictureUrl: [],
  23. pictureUrlMin: [],
  24. };
  25. },
  26. loadData(id) {
  27. this.setState({
  28. loading: true
  29. });
  30. $.ajax({
  31. method: "get",
  32. dataType: "json",
  33. crossDomain: false,
  34. url: globalConfig.context + '/api/user/demand/demandDetail' ,
  35. data: {
  36. id: id
  37. },
  38. success: function (data) {
  39. let thisData = data.data;
  40. if (!thisData) {
  41. if (data.error && data.error.length) {
  42. message.warning(data.error[0].message);
  43. };
  44. thisData = {};
  45. };
  46. let publishPagesArr = [];
  47. thisData.publishPages.map(item=>{
  48. publishPagesArr.push(item.publishPage)
  49. })
  50. // let ProvinceCityArr = [];
  51. // let ProvinceS = thisData.locationProvince; //getprovince
  52. // let citys = thisData.locationCity;
  53. // let Areas = thisData.locationArea;
  54. // ProvinceCityArr.push(ProvinceS, citys, Areas);
  55. this.setState({
  56. //ProvinceCity:ProvinceCityArr,
  57. id:thisData.id,
  58. publishPagesArr:publishPagesArr,
  59. data: thisData,
  60. isHot:thisData.isHot,
  61. isUrgent:thisData.isUrgent,
  62. status:thisData.status,
  63. isHot:thisData.isHot,
  64. pictureUrlMin: thisData.pictureUrlMin ? splitUrl(thisData.pictureUrlMin, ',', globalConfig.avatarHost + '/upload') : [],
  65. pictureUrl: thisData.pictureUrl ? splitUrl(thisData.pictureUrl, ',', globalConfig.avatarHost + '/upload') : []
  66. });
  67. }.bind(this),
  68. }).always(function () {
  69. this.setState({
  70. loading: false
  71. });
  72. }.bind(this));
  73. },
  74. getPictureUrl(e) {
  75. this.setState({ pictureUrl: e });
  76. },
  77. cancelFun(){
  78. this.props.closeDesc();
  79. },
  80. //审核通过/拒绝
  81. updateFun(index){
  82. this.setState({
  83. loading:true
  84. })
  85. $.ajax({
  86. method: "get",
  87. dataType: "JSON",
  88. crossDomain: false,
  89. url: globalConfig.context + '/api/admin/demand/auditDemand',
  90. data: {
  91. id: this.state.id,
  92. auditResult:index,
  93. auditInfo:this.state.refuseValue
  94. }
  95. }).done(function (data) {
  96. if (!data.error.length) {
  97. message.success('操作成功!');
  98. this.setState({
  99. loading: false,
  100. });
  101. this.props.handOk()
  102. } else {
  103. message.warning(data.error[0].message);
  104. };
  105. }.bind(this));
  106. },
  107. //审核拒绝
  108. refuse(){
  109. this.setState({
  110. refuseValue:'',
  111. refuseVisible:true
  112. })
  113. },
  114. refuseOk(){
  115. if(!this.state.refuseValue){
  116. message.warning('请填写拒绝原因。')
  117. return;
  118. }
  119. this.setState({
  120. refuseVisible:false
  121. })
  122. this.updateFun(0)
  123. },
  124. refuseCancel(){
  125. this.setState({
  126. refuseValue:'',
  127. refuseVisible:false
  128. })
  129. },
  130. componentWillMount() {
  131. if (this.props.data.id) {
  132. this.loadData(this.props.data.id);
  133. } else {
  134. this.state.data = {};
  135. };
  136. },
  137. componentWillReceiveProps(nextProps) {
  138. if (!this.props.visible && nextProps.visible) {
  139. this.state.textFileList = [];
  140. this.state.videoFileList = [];
  141. if (nextProps.data.id) {
  142. this.loadData(nextProps.data.id);
  143. } else {
  144. this.state.data = {};
  145. this.state.demandType=undefined; //需求类型
  146. this.state.urgent=undefined;//加急需求
  147. this.state.offer=undefined;//是否悬赏
  148. this.state.hotDemand=undefined;
  149. this.state.solve=undefined;
  150. this.state.pictureUrl = [];
  151. this.state.pictureUrlMin=[]
  152. };
  153. this.props.form.resetFields();
  154. };
  155. },
  156. render() {
  157. const theData = this.state.data || {};
  158. const { getFieldDecorator } = this.props.form;
  159. const FormItem = Form.Item
  160. const formItemLayout = {
  161. labelCol: { span: 6 },
  162. wrapperCol: { span: 12 },
  163. };
  164. return (
  165. <div className='login'>
  166. <Form layout="horizontal" id="demand-form">
  167. <Spin spinning={this.state.loading}>
  168. <div className="clearfix">
  169. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="发个需求吧">
  170. <span>{theData.problemDes}</span>
  171. </FormItem>
  172. <FormItem className="half-item" {...formItemLayout} label="标题">
  173. <span>{theData.name}</span>
  174. </FormItem>
  175. </div>
  176. <div className>
  177. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="关键字">
  178. <span>{theData.keyword}</span>
  179. </FormItem>
  180. </div>
  181. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="行业领域">
  182. <span>{getIndustryCategory(theData.industryCategoryA,theData.industryCategoryB)}</span>
  183. </FormItem>
  184. <div className="clearfix">
  185. <FormItem className="half-item" {...formItemLayout} label="需求类型">
  186. <span>{getDemandType(theData.demandType)}</span>
  187. </FormItem>
  188. {theData.demandType=='5'&&
  189. <FormItem className="half-item" {...formItemLayout} label="人才需求酬劳">
  190. <span>{theData.budgetCost} 万元</span>
  191. </FormItem>}
  192. {theData.demandType=='3'&&<div className="clearfix"><FormItem className="half-item" {...formItemLayout} label="资金需求额度">
  193. <span>{theData.budgetCost}万元</span>
  194. </FormItem>
  195. <FormItem className="half-item" {...formItemLayout} label="资金用途">
  196. <span>{theData.researchType=='1'&&'扩大再生产'}</span>
  197. <span>{theData.researchType=='0'&&'研发'}</span>
  198. </FormItem>
  199. </div>
  200. }
  201. </div>
  202. <p style={{marginLeft:40,fontSize:18,marginBottom:15}}>您还可以说明</p>
  203. <div className="clearfix">
  204. <FormItem className="half-item" {...formItemLayout} label="加急需求">
  205. <span>{theData.isUrgent?'加急':'非加急'}</span>
  206. </FormItem>
  207. {theData.isUrgent?<div><FormItem className="half-item" {...formItemLayout} label="日期">
  208. <span>{theData.urgentDays}天</span>
  209. </FormItem>
  210. <FormItem className="half-item" {...formItemLayout} label="悬赏金额">
  211. <span>{theData.urgentMoney}万元</span>
  212. </FormItem>
  213. </div>:''}
  214. </div>
  215. <div className="clearfix">
  216. <FormItem className="half-item" {...formItemLayout} label="热点需求">
  217. <span>{theData.isHot?'热点':'非热点'}</span>
  218. </FormItem>
  219. <FormItem className="half-item" {...formItemLayout} label="解决">
  220. <span>
  221. {theData.status=='0'&&'进行中'}
  222. {theData.status=='1'&&'未解决'}
  223. {theData.status=='2'&&'已解决'}
  224. </span>
  225. </FormItem>
  226. </div>
  227. {/* <div className="clearfix">
  228. <FormItem
  229. className="half-item"
  230. {...formItemLayout}
  231. label="地区"
  232. >
  233. {this.state.ProvinceCity}
  234. </FormItem>
  235. </div> */}
  236. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="需求(大图)">
  237. <div className="clearfix">
  238. <Upload className="demandDetailShow-upload"
  239. listType="picture-card"
  240. fileList={this.state.pictureUrl}
  241. onPreview={(file) => {
  242. this.setState({
  243. previewImage: file.url || file.thumbUrl,
  244. previewVisible: true,
  245. });
  246. }} >
  247. </Upload>
  248. <Modal maskClosable={false} footer={null}
  249. visible={this.state.previewVisible}
  250. onCancel={() => { this.setState({ previewVisible: false }) }}>
  251. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  252. </Modal>
  253. </div>
  254. </FormItem>
  255. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="需求(小图)">
  256. <div className="clearfix">
  257. <Upload className="demandDetailShow-upload"
  258. listType="picture-card"
  259. fileList={this.state.pictureUrlMin}
  260. onPreview={(file) => {
  261. this.setState({
  262. previewImage: file.url || file.thumbUrl,
  263. previewVisible: true,
  264. });
  265. }} >
  266. </Upload>
  267. <Modal maskClosable={false} footer={null}
  268. visible={this.state.previewVisible}
  269. onCancel={() => { this.setState({ previewVisible: false }) }}>
  270. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  271. </Modal>
  272. </div>
  273. </FormItem>
  274. <div>
  275. <FormItem className="half-item" {...formItemLayout} label="发布状态">
  276. <span>{getReleaseStateList(theData.auditStatus)}</span>
  277. </FormItem>
  278. </div>
  279. <div>
  280. <FormItem className="half-item" labelCol={{ span: 6 }}
  281. wrapperCol={{ span: 18 }} label="发布位置">
  282. <span>{getReleasePositionList(this.state.publishPagesArr)}</span>
  283. </FormItem>
  284. </div>
  285. <div className="clearfix">
  286. {this.props.examineState&&<FormItem wrapperCol={{ span: 12, offset: 3 }}>
  287. <Button className="set-submit" type="primary" onClick={(e)=>{this.updateFun(1)}} >
  288. 审核通过
  289. </Button>
  290. <Button type="danger" style={{marginRight:20}} onClick={(e)=>{this.refuse()}}>
  291. 审核拒绝
  292. </Button>
  293. <Button className="set-submit" type="ghost" onClick={this.cancelFun}>
  294. 取消
  295. </Button>
  296. </FormItem>}
  297. </div>
  298. </Spin>
  299. </Form>
  300. <Modal
  301. title="审核拒绝"
  302. visible={this.state.refuseVisible}
  303. onOk={this.refuseOk}
  304. onCancel={this.refuseCancel}
  305. >
  306. <div>
  307. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} label="拒绝原因">
  308. <Input type="textarea" rows={4} value={this.state.refuseValue} placeholder="输入拒绝原因" onChange={(e)=>{this.setState({refuseValue:e.target.value})}}/>
  309. </FormItem>
  310. </div>
  311. </Modal>
  312. </div>
  313. )
  314. }
  315. }));
  316. export default DemandDetail;