demandDetaiel.jsx 12 KB

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