businessDetails.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. import React from 'react';
  2. import $ from 'jquery/src/ajax';
  3. import { Modal, message, Spin, Upload, Button, Form } from 'antd';
  4. import { getprovince, splitUrl } from '@/tools.js';
  5. import './business.less';
  6. import 'react-quill/dist/quill.bubble.css';
  7. const DemandDetail = Form.create()(
  8. React.createClass({
  9. getInitialState() {
  10. return {
  11. visible: false,
  12. loading: false,
  13. auditStatus: 0,
  14. textFileList: [],
  15. videoFileList: [],
  16. pictureUrl: []
  17. };
  18. },
  19. loadData(id) {
  20. this.setState({
  21. loading: true
  22. });
  23. $.ajax({
  24. method: 'get',
  25. dataType: 'json',
  26. crossDomain: false,
  27. url: globalConfig.context + '/api/user/jtBusiness/project/detail',
  28. data: {
  29. id: id
  30. },
  31. success: function(data) {
  32. let thisData = data.data;
  33. if (!thisData) {
  34. if (data.error && data.error.length) {
  35. message.warning(data.error[0].message);
  36. }
  37. thisData = {};
  38. }
  39. let categoryList = this.props.categoryList,name='';
  40. categoryList.map(item=>{
  41. if((item.children).length){
  42. (item.children).map(atem=>{
  43. if(atem.value==thisData.categoryId){
  44. name=item.label+'/'+atem.label;
  45. return;
  46. }
  47. })
  48. }
  49. })
  50. let tagFirst =thisData.tags,tagTxt=[];
  51. tagFirst.map(item=>{
  52. tagTxt.push(item.name);
  53. })
  54. //富文本处理
  55. document.querySelector('.txt').innerHTML='';
  56. let eleDiv = document.createElement('div');
  57. eleDiv.innerHTML=thisData.introduce;
  58. document.querySelector('.txt').append(eleDiv);
  59. this.setState({
  60. id: thisData.id,
  61. data: thisData,
  62. name:name,
  63. tags:tagTxt.join(' - '),
  64. createTime: thisData.createTime ? new Date(thisData.createTime).toLocaleString() : '',
  65. auditStatus: thisData.auditStatus,
  66. orgCodeUrl: thisData.minImgUrl
  67. ? splitUrl(thisData.minImgUrl, ',', globalConfig.avatarHost + '/upload')
  68. : [],
  69. companyLogoUrl: thisData.maxImgUrl
  70. ? splitUrl(thisData.maxImgUrl, ',', globalConfig.avatarHost + '/upload')
  71. : []
  72. });
  73. }.bind(this)
  74. }).always(
  75. function() {
  76. this.setState({
  77. loading: false
  78. });
  79. }.bind(this)
  80. );
  81. },
  82. cancelFun() {
  83. this.props.closeDesc();
  84. },
  85. //刷新发布
  86. updateFun(inex) {
  87. this.setState({
  88. loading: true
  89. });
  90. $.ajax({
  91. method: 'get',
  92. dataType: 'json',
  93. crossDomain: false,
  94. url: globalConfig.context + '/api/user/jtBusiness/project/refreshPublish',
  95. data: {
  96. id: this.state.id,
  97. auditStatus: this.state.auditStatus
  98. }
  99. }).done(
  100. function(data) {
  101. if (!data.error.length) {
  102. message.success('刷新成功!');
  103. this.setState({
  104. loading: false
  105. });
  106. } else {
  107. message.warning(data.error[0].message);
  108. }
  109. this.props.handOk();
  110. }.bind(this)
  111. );
  112. },
  113. //撤销发布
  114. revokeFun() {
  115. this.setState({
  116. loading: true
  117. });
  118. $.ajax({
  119. method: 'get',
  120. dataType: 'json',
  121. crossDomain: false,
  122. url: globalConfig.context + '/api/user/jtBusiness/project/offShelf',
  123. data: {
  124. id: this.state.id,
  125. auditStatus:this.state.auditStatus
  126. }
  127. }).done(
  128. function(data) {
  129. if (!data.error.length) {
  130. message.success('撤销成功!');
  131. this.setState({
  132. loading: false
  133. });
  134. } else {
  135. message.warning(data.error[0].message);
  136. }
  137. this.props.handOk();
  138. }.bind(this)
  139. );
  140. },
  141. componentWillMount() {
  142. if (this.props.data.id) {
  143. this.loadData(this.props.data.id);
  144. } else {
  145. this.state.data = {};
  146. }
  147. },
  148. componentWillReceiveProps(nextProps) {
  149. if (!this.props.visible && nextProps.visible) {
  150. this.state.textFileList = [];
  151. this.state.videoFileList = [];
  152. if (nextProps.data.id) {
  153. this.loadData(nextProps.data.id);
  154. } else {
  155. this.state.data = {};
  156. this.state.pictureUrl = [];
  157. }
  158. this.props.form.resetFields();
  159. }
  160. },
  161. render() {
  162. const theData = this.state.data || {};
  163. const FormItem = Form.Item;
  164. return (
  165. <div className="patent-desc">
  166. <Form
  167. layout="horizontal"
  168. onSubmit={(e) => {
  169. this.handleSubmit(e, 0);
  170. }}
  171. id="demand-form"
  172. >
  173. <Spin spinning={this.state.loading}>
  174. <div className="clearfix">
  175. <FormItem
  176. className="half-item"
  177. labelCol={{ span:8 }}
  178. wrapperCol={{ span: 12 }}
  179. label="项目名称"
  180. >
  181. <span>{theData.name}</span>
  182. </FormItem>
  183. <FormItem
  184. className="half-item"
  185. labelCol={{ span: 8 }}
  186. wrapperCol={{ span: 12 }}
  187. label="业务品类"
  188. >
  189. <span>{this.state.name}</span>
  190. </FormItem>
  191. </div>
  192. <div className="clearfix">
  193. <FormItem
  194. className="half-item"
  195. labelCol={{ span:8 }}
  196. wrapperCol={{ span: 12 }}
  197. label="省份"
  198. >
  199. <span>{theData.province!='0'?getprovince(theData.province):'全国'}</span>
  200. </FormItem>
  201. {/*<FormItem
  202. className="half-item"
  203. labelCol={{ span: 8 }}
  204. wrapperCol={{ span: 12 }}
  205. label="热点"
  206. >
  207. <span>{theData.isHot=='1' ? '是' :theData.isHot=='0'?'否':''}</span>
  208. </FormItem>*/}
  209. <FormItem
  210. className="half-item"
  211. labelCol={{ span: 8}}
  212. wrapperCol={{ span: 12 }}
  213. label="创建时间"
  214. >
  215. <span>{this.state.createTime}</span>
  216. </FormItem>
  217. </div>
  218. <div className="clearfix">
  219. <FormItem
  220. className="half-item"
  221. labelCol={{ span:8 }}
  222. wrapperCol={{ span: 12 }}
  223. label="市场价"
  224. >
  225. <span>{theData.price?theData.price+' 万元':''}</span>
  226. </FormItem>
  227. <FormItem
  228. className="half-item"
  229. labelCol={{ span:8 }}
  230. wrapperCol={{ span: 12 }}
  231. label="活动价"
  232. >
  233. <span>{theData.activityPrice?theData.activityPrice+' 万元':''}</span>
  234. </FormItem>
  235. <FormItem
  236. className="half-item"
  237. labelCol={{ span:8 }}
  238. wrapperCol={{ span: 12 }}
  239. label="最低折扣"
  240. >
  241. <span>{theData.offset?theData.offset+' 万元':''}</span>
  242. </FormItem>
  243. <FormItem
  244. className="half-item"
  245. labelCol={{ span:8 }}
  246. wrapperCol={{ span: 12 }}
  247. label="会员价"
  248. >
  249. <span>{theData.memberPrice?theData.memberPrice+' 万元':''}</span>
  250. </FormItem>
  251. <FormItem
  252. className="half-item"
  253. labelCol={{ span: 8 }}
  254. wrapperCol={{ span: 12 }}
  255. label="活动生效"
  256. >
  257. <span>{theData.activityFlag=='1' ? '有效' :theData.activityFlag=='0'?'无效':''}</span>
  258. </FormItem>
  259. <FormItem
  260. className="half-item"
  261. labelCol={{ span:8 }}
  262. wrapperCol={{ span: 12 }}
  263. label="关键字"
  264. >
  265. <span>{theData.keyword}</span>
  266. </FormItem>
  267. </div>
  268. <div className="clearfix">
  269. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="标签">
  270. <span>{this.state.tags}</span>
  271. </FormItem>
  272. </div>
  273. <div className="clearfix">
  274. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="项目简介">
  275. <span>{theData.summary}</span>
  276. </FormItem>
  277. </div>
  278. <div className="clearfix">
  279. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="项目营销说明">
  280. <span>{theData.advertisement}</span>
  281. </FormItem>
  282. </div>
  283. {/*
  284. <div className="clearfix">
  285. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="业务项目价值及作用">
  286. <span>{theData.value}</span>
  287. </FormItem>
  288. </div>
  289. <div className="clearfix">
  290. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="业务项目客户基本条件">
  291. <span>{theData.applyConditions}</span>
  292. </FormItem>
  293. </div>*/}
  294. <div className="clearfix">
  295. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} label="业务项目服务内容">
  296. <div className="ql-editor">
  297. <div className="txt"></div>
  298. </div>
  299. </FormItem>
  300. </div>
  301. <div className="clearfix pictures">
  302. <FormItem
  303. className="half-item"
  304. labelCol={{ span: 8 }}
  305. wrapperCol={{ span: 10 }}
  306. label="业务项目图标(小)"
  307. >
  308. <Upload
  309. className="demandDetailShow-upload"
  310. listType="picture-card"
  311. fileList={this.state.orgCodeUrl}
  312. onPreview={(file) => {
  313. this.setState({
  314. previewImage: file.url || file.thumbUrl,
  315. previewVisible: true
  316. });
  317. }}
  318. />
  319. <Modal
  320. maskClosable={false}
  321. footer={null}
  322. visible={this.state.previewVisible}
  323. onCancel={() => {
  324. this.setState({ previewVisible: false });
  325. }}
  326. >
  327. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  328. </Modal>
  329. </FormItem>
  330. <FormItem
  331. className="half-item"
  332. labelCol={{ span: 8 }}
  333. wrapperCol={{ span: 12 }}
  334. label="业务项目图标(大)"
  335. >
  336. <Upload
  337. className="demandDetailShow-upload"
  338. listType="picture-card"
  339. fileList={this.state.companyLogoUrl}
  340. onPreview={(file) => {
  341. this.setState({
  342. previewImage: file.url || file.thumbUrl,
  343. previewVisible: true
  344. });
  345. }}
  346. />
  347. <Modal
  348. maskClosable={false}
  349. footer={null}
  350. visible={this.state.previewVisible}
  351. onCancel={() => {
  352. this.setState({ previewVisible: false });
  353. }}
  354. >
  355. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  356. </Modal>
  357. </FormItem>
  358. </div>
  359. <div className="clearfix">
  360. {this.props.data.auditStatus == '2' && (
  361. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  362. <Button
  363. className="set-submit"
  364. type="primary"
  365. onClick={(e) => {
  366. this.updateFun();
  367. }}
  368. >
  369. 刷新发布
  370. </Button>
  371. <Button
  372. type="danger"
  373. style={{ marginRight: 20 }}
  374. onClick={(e) => {
  375. this.revokeFun();
  376. }}
  377. >
  378. 撤销发布
  379. </Button>
  380. <Button className="set-submit" type="ghost" onClick={this.cancelFun}>
  381. 取消
  382. </Button>
  383. </FormItem>
  384. )}
  385. </div>
  386. </Spin>
  387. </Form>
  388. </div>
  389. );
  390. }
  391. })
  392. );
  393. export default DemandDetail;