businessDetails.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. </div>
  210. <div className="clearfix">
  211. <FormItem
  212. className="half-item"
  213. labelCol={{ span:8 }}
  214. wrapperCol={{ span: 12 }}
  215. label="市场价"
  216. >
  217. <span>{theData.price?theData.price+' 万元':''}</span>
  218. </FormItem>
  219. <FormItem
  220. className="half-item"
  221. labelCol={{ span:8 }}
  222. wrapperCol={{ span: 12 }}
  223. label="活动价"
  224. >
  225. <span>{theData.activityPrice?theData.activityPrice+' 万元':''}</span>
  226. </FormItem>
  227. <FormItem
  228. className="half-item"
  229. labelCol={{ span:8 }}
  230. wrapperCol={{ span: 12 }}
  231. label="最低折扣"
  232. >
  233. <span>{theData.offset?theData.offset+' 万元':''}</span>
  234. </FormItem>
  235. <FormItem
  236. className="half-item"
  237. labelCol={{ span:8 }}
  238. wrapperCol={{ span: 12 }}
  239. label="会员价"
  240. >
  241. <span>{theData.memberPrice?theData.memberPrice+' 万元':''}</span>
  242. </FormItem>
  243. <FormItem
  244. className="half-item"
  245. labelCol={{ span: 8 }}
  246. wrapperCol={{ span: 12 }}
  247. label="活动生效"
  248. >
  249. <span>{theData.activityFlag=='1' ? '有效' :theData.activityFlag=='0'?'无效':''}</span>
  250. </FormItem>
  251. <FormItem
  252. className="half-item"
  253. labelCol={{ span:8 }}
  254. wrapperCol={{ span: 12 }}
  255. label="关键字"
  256. >
  257. <span>{theData.keyword}</span>
  258. </FormItem>
  259. <FormItem
  260. className="half-item"
  261. labelCol={{ span: 8}}
  262. wrapperCol={{ span: 12 }}
  263. label="创建时间"
  264. >
  265. <span>{this.state.createTime}</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.advertisement}</span>
  276. </FormItem>
  277. </div>
  278. <div className="clearfix">
  279. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="业务项目价值及作用">
  280. <span>{theData.value}</span>
  281. </FormItem>
  282. </div>
  283. <div className="clearfix">
  284. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="业务项目客户基本条件">
  285. <span>{theData.applyConditions}</span>
  286. </FormItem>
  287. </div>
  288. <div className="clearfix">
  289. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} label="业务项目服务内容">
  290. <div className="ql-editor">
  291. <div className="txt"></div>
  292. </div>
  293. </FormItem>
  294. </div>
  295. <div className="clearfix pictures">
  296. <FormItem
  297. className="half-item"
  298. labelCol={{ span: 8 }}
  299. wrapperCol={{ span: 10 }}
  300. label="业务项目图标(小)"
  301. >
  302. <Upload
  303. className="demandDetailShow-upload"
  304. listType="picture-card"
  305. fileList={this.state.orgCodeUrl}
  306. onPreview={(file) => {
  307. this.setState({
  308. previewImage: file.url || file.thumbUrl,
  309. previewVisible: true
  310. });
  311. }}
  312. />
  313. <Modal
  314. maskClosable={false}
  315. footer={null}
  316. visible={this.state.previewVisible}
  317. onCancel={() => {
  318. this.setState({ previewVisible: false });
  319. }}
  320. >
  321. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  322. </Modal>
  323. </FormItem>
  324. <FormItem
  325. className="half-item"
  326. labelCol={{ span: 8 }}
  327. wrapperCol={{ span: 12 }}
  328. label="业务项目图标(大)"
  329. >
  330. <Upload
  331. className="demandDetailShow-upload"
  332. listType="picture-card"
  333. fileList={this.state.companyLogoUrl}
  334. onPreview={(file) => {
  335. this.setState({
  336. previewImage: file.url || file.thumbUrl,
  337. previewVisible: true
  338. });
  339. }}
  340. />
  341. <Modal
  342. maskClosable={false}
  343. footer={null}
  344. visible={this.state.previewVisible}
  345. onCancel={() => {
  346. this.setState({ previewVisible: false });
  347. }}
  348. >
  349. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  350. </Modal>
  351. </FormItem>
  352. </div>
  353. <div className="clearfix">
  354. {this.props.data.auditStatus == '2' && (
  355. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  356. <Button
  357. className="set-submit"
  358. type="primary"
  359. onClick={(e) => {
  360. this.updateFun();
  361. }}
  362. >
  363. 刷新发布
  364. </Button>
  365. <Button
  366. type="danger"
  367. style={{ marginRight: 20 }}
  368. onClick={(e) => {
  369. this.revokeFun();
  370. }}
  371. >
  372. 撤销发布
  373. </Button>
  374. <Button className="set-submit" type="ghost" onClick={this.cancelFun}>
  375. 取消
  376. </Button>
  377. </FormItem>
  378. )}
  379. </div>
  380. </Spin>
  381. </Form>
  382. </div>
  383. );
  384. }
  385. })
  386. );
  387. export default DemandDetail;